Skip to content

Commit e83b8a5

Browse files
author
esmeyi
committed
[XCOFF] Enable available_externally linkage for functions.
Summary: D80642 added support for emitting AvailableExternally Linkage on AIX. However, an assertion of "Trying to get csect representation of this symbol but none was set." occurred when a function is declared as available_externally. This is due to we missing to generate a csect for the function. This patch fixes it. Reviewed By: hubert.reinterpretcast, shchenz Differential Revision: https://reviews.llvm.org/D156213 Signed-off-by: Esme Yi <[email protected]>
1 parent c56514f commit e83b8a5

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2628,12 +2628,12 @@ MCSymbol *TargetLoweringObjectFileXCOFF::getFunctionEntryPointSymbol(
26282628
// function entry point csect instead. And for function delcarations, the
26292629
// undefined symbols gets treated as csect with XTY_ER property.
26302630
if (((TM.getFunctionSections() && !Func->hasSection()) ||
2631-
Func->isDeclaration()) &&
2631+
Func->isDeclarationForLinker()) &&
26322632
isa<Function>(Func)) {
26332633
return getContext()
26342634
.getXCOFFSection(
26352635
NameStr, SectionKind::getText(),
2636-
XCOFF::CsectProperties(XCOFF::XMC_PR, Func->isDeclaration()
2636+
XCOFF::CsectProperties(XCOFF::XMC_PR, Func->isDeclarationForLinker()
26372637
? XCOFF::XTY_ER
26382638
: XCOFF::XTY_SD))
26392639
->getQualNameSymbol();
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \
2+
; RUN: -mattr=-altivec < %s | FileCheck %s
3+
4+
; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \
5+
; RUN: -mattr=-altivec < %s | FileCheck %s
6+
7+
; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \
8+
; RUN: -mattr=-altivec -filetype=obj -o %t.o < %s
9+
; RUN: llvm-readobj --symbols %t.o | FileCheck --check-prefix=OBJ %s
10+
11+
; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \
12+
; RUN: -mattr=-altivec -filetype=obj -o %t64.o < %s
13+
; RUN: llvm-readobj --symbols %t64.o | FileCheck --check-prefix=OBJ %s
14+
15+
define available_externally i32 @foo(i32 %a) {
16+
entry:
17+
ret i32 %a
18+
}
19+
20+
; CHECK: .extern .foo[PR]
21+
; CHECK: .extern foo[DS]
22+
23+
; OBJ: Name: .foo
24+
; OBJ-NEXT: Value (RelocatableAddress): 0x0
25+
; OBJ-NEXT: Section: N_UNDEF
26+
; OBJ-NEXT: Type: 0x0
27+
; OBJ-NEXT: StorageClass: C_EXT (0x2)
28+
; OBJ-NEXT: NumberOfAuxEntries: 1
29+
; OBJ-NEXT: CSECT Auxiliary Entry {
30+
; OBJ-NEXT: Index: 2
31+
; OBJ-NEXT: SectionLen: 0
32+
; OBJ-NEXT: ParameterHashIndex: 0x0
33+
; OBJ-NEXT: TypeChkSectNum: 0x0
34+
; OBJ-NEXT: SymbolAlignmentLog2: 0
35+
; OBJ-NEXT: SymbolType: XTY_ER (0x0)
36+
; OBJ-NEXT: StorageMappingClass: XMC_PR (0x0)
37+
38+
; OBJ: Name: foo
39+
; OBJ-NEXT: Value (RelocatableAddress): 0x0
40+
; OBJ-NEXT: Section: N_UNDEF
41+
; OBJ-NEXT: Type: 0x0
42+
; OBJ-NEXT: StorageClass: C_EXT (0x2)
43+
; OBJ-NEXT: NumberOfAuxEntries: 1
44+
; OBJ-NEXT: CSECT Auxiliary Entry {
45+
; OBJ-NEXT: Index: 4
46+
; OBJ-NEXT: SectionLen: 0
47+
; OBJ-NEXT: ParameterHashIndex: 0x0
48+
; OBJ-NEXT: TypeChkSectNum: 0x0
49+
; OBJ-NEXT: SymbolAlignmentLog2: 0
50+
; OBJ-NEXT: SymbolType: XTY_ER (0x0)
51+
; OBJ-NEXT: StorageMappingClass: XMC_DS (0xA)

0 commit comments

Comments
 (0)