Skip to content

Commit b116ded

Browse files
[AIX] Avoid structor alias; die before bad alias codegen
Summary: `AsmPrinter::emitGlobalIndirectSymbol` is dependent on `MCStreamer::emitAssignment` to produce `.set` directives for alias symbols; however, the `.set` pseudo-op on AIX is documented as not usable with external relocatable terms or expressions, which limits its applicability in generating alias symbols. Disable generating aliases on AIX until a different implementation strategy is available. Reviewers: cebowleratibm, jasonliu, sfertile, daltenty, DiggerLin Reviewed By: jasonliu Differential Revision: https://reviews.llvm.org/D79044
1 parent f66309d commit b116ded

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4675,8 +4675,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
46754675

46764676
// Enable -mconstructor-aliases except on darwin, where we have to work around
46774677
// a linker bug (see <rdar://problem/7651567>), and CUDA device code, where
4678-
// aliases aren't supported.
4679-
if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX())
4678+
// aliases aren't supported. Similarly, aliases aren't yet supported for AIX.
4679+
if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() && !RawTriple.isOSAIX())
46804680
CmdArgs.push_back("-mconstructor-aliases");
46814681

46824682
// Darwin's kernel doesn't support guard variables; just die if we
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Check that we don't pass -mconstructor-aliases when compiling for AIX.
2+
3+
// RUN: %clang -### -target powerpc-ibm-aix7.1.0.0 %s -c -o %t.o 2>&1 \
4+
// RUN: | FileCheck %s
5+
// RUN: %clang -### -target powerpc64-ibm-aix7.1.0.0 %s -c -o %t.o 2>&1 \
6+
// RUN: | FileCheck %s
7+
// CHECK-NOT: "-mconstructor-aliases"

llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ class PPCAIXAsmPrinter : public PPCAsmPrinter {
155155

156156
StringRef getPassName() const override { return "AIX PPC Assembly Printer"; }
157157

158+
bool doInitialization(Module &M) override {
159+
if (M.alias_size() > 0u)
160+
report_fatal_error(
161+
"module has aliases, which LLVM does not yet support for AIX");
162+
163+
return PPCAsmPrinter::doInitialization(M);
164+
}
165+
158166
void SetupMachineFunction(MachineFunction &MF) override;
159167

160168
void emitGlobalVariable(const GlobalVariable *GV) override;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
; RUN: not --crash llc < %s -mtriple powerpc-ibm-aix-xcoff 2>&1 | FileCheck %s
2+
; RUN: not --crash llc < %s -mtriple powerpc64-ibm-aix-xcoff 2>&1 | FileCheck %s
3+
4+
; Check that, while generation of aliases on AIX remains unimplemented, llc dies
5+
; with an appropriate message instead of generating incorrect output when an
6+
; alias is encountered.
7+
8+
define i32 @a() { ret i32 0 }
9+
; CHECK: ERROR: module has aliases
10+
@b = internal alias i32 (), i32 ()* @a

0 commit comments

Comments
 (0)