[llvm-branch-commits] [llvm] 6ce6dcf - [XCOFF] Enable available_externally linkage for functions.
Tobias Hieta via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jul 26 10:28:47 PDT 2023
Author: esmeyi
Date: 2023-07-26T19:27:54+02:00
New Revision: 6ce6dcf233ead31f1776a57a3dc80f722cfe2864
URL: https://github.com/llvm/llvm-project/commit/6ce6dcf233ead31f1776a57a3dc80f722cfe2864
DIFF: https://github.com/llvm/llvm-project/commit/6ce6dcf233ead31f1776a57a3dc80f722cfe2864.diff
LOG: [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 <esme.yi at ibm.com>
(cherry picked from commit e83b8a5e711a663c44e80965da5c747e08dea497)
Added:
llvm/test/CodeGen/PowerPC/aix-available-externally-linkage-fun.ll
Modified:
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 3994552884c4f6..647f570ab807e1 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -2628,12 +2628,12 @@ MCSymbol *TargetLoweringObjectFileXCOFF::getFunctionEntryPointSymbol(
// function entry point csect instead. And for function delcarations, the
// undefined symbols gets treated as csect with XTY_ER property.
if (((TM.getFunctionSections() && !Func->hasSection()) ||
- Func->isDeclaration()) &&
+ Func->isDeclarationForLinker()) &&
isa<Function>(Func)) {
return getContext()
.getXCOFFSection(
NameStr, SectionKind::getText(),
- XCOFF::CsectProperties(XCOFF::XMC_PR, Func->isDeclaration()
+ XCOFF::CsectProperties(XCOFF::XMC_PR, Func->isDeclarationForLinker()
? XCOFF::XTY_ER
: XCOFF::XTY_SD))
->getQualNameSymbol();
diff --git a/llvm/test/CodeGen/PowerPC/aix-available-externally-linkage-fun.ll b/llvm/test/CodeGen/PowerPC/aix-available-externally-linkage-fun.ll
new file mode 100644
index 00000000000000..f87184f7b4bf45
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/aix-available-externally-linkage-fun.ll
@@ -0,0 +1,51 @@
+; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN: -mattr=-altivec < %s | FileCheck %s
+
+; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN: -mattr=-altivec < %s | FileCheck %s
+
+; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN: -mattr=-altivec -filetype=obj -o %t.o < %s
+; RUN: llvm-readobj --symbols %t.o | FileCheck --check-prefix=OBJ %s
+
+; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \
+; RUN: -mattr=-altivec -filetype=obj -o %t64.o < %s
+; RUN: llvm-readobj --symbols %t64.o | FileCheck --check-prefix=OBJ %s
+
+define available_externally i32 @foo(i32 %a) {
+entry:
+ ret i32 %a
+}
+
+; CHECK: .extern .foo[PR]
+; CHECK: .extern foo[DS]
+
+; OBJ: Name: .foo
+; OBJ-NEXT: Value (RelocatableAddress): 0x0
+; OBJ-NEXT: Section: N_UNDEF
+; OBJ-NEXT: Type: 0x0
+; OBJ-NEXT: StorageClass: C_EXT (0x2)
+; OBJ-NEXT: NumberOfAuxEntries: 1
+; OBJ-NEXT: CSECT Auxiliary Entry {
+; OBJ-NEXT: Index: 2
+; OBJ-NEXT: SectionLen: 0
+; OBJ-NEXT: ParameterHashIndex: 0x0
+; OBJ-NEXT: TypeChkSectNum: 0x0
+; OBJ-NEXT: SymbolAlignmentLog2: 0
+; OBJ-NEXT: SymbolType: XTY_ER (0x0)
+; OBJ-NEXT: StorageMappingClass: XMC_PR (0x0)
+
+; OBJ: Name: foo
+; OBJ-NEXT: Value (RelocatableAddress): 0x0
+; OBJ-NEXT: Section: N_UNDEF
+; OBJ-NEXT: Type: 0x0
+; OBJ-NEXT: StorageClass: C_EXT (0x2)
+; OBJ-NEXT: NumberOfAuxEntries: 1
+; OBJ-NEXT: CSECT Auxiliary Entry {
+; OBJ-NEXT: Index: 4
+; OBJ-NEXT: SectionLen: 0
+; OBJ-NEXT: ParameterHashIndex: 0x0
+; OBJ-NEXT: TypeChkSectNum: 0x0
+; OBJ-NEXT: SymbolAlignmentLog2: 0
+; OBJ-NEXT: SymbolType: XTY_ER (0x0)
+; OBJ-NEXT: StorageMappingClass: XMC_DS (0xA)
More information about the llvm-branch-commits
mailing list