[clang] b116ded - [AIX] Avoid structor alias; die before bad alias codegen
Hubert Tong via cfe-commits
cfe-commits at lists.llvm.org
Fri May 8 13:51:42 PDT 2020
Author: Hubert Tong
Date: 2020-05-08T16:51:34-04:00
New Revision: b116ded57da3530e661f871f4191c59cd9e091cd
URL: https://github.com/llvm/llvm-project/commit/b116ded57da3530e661f871f4191c59cd9e091cd
DIFF: https://github.com/llvm/llvm-project/commit/b116ded57da3530e661f871f4191c59cd9e091cd.diff
LOG: [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
Added:
clang/test/Driver/aix-constructor-alias.c
llvm/test/CodeGen/PowerPC/aix-alias.ll
Modified:
clang/lib/Driver/ToolChains/Clang.cpp
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 3fc1ef49d1f7..04c05a8f53e3 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4675,8 +4675,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// Enable -mconstructor-aliases except on darwin, where we have to work around
// a linker bug (see <rdar://problem/7651567>), and CUDA device code, where
- // aliases aren't supported.
- if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX())
+ // aliases aren't supported. Similarly, aliases aren't yet supported for AIX.
+ if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() && !RawTriple.isOSAIX())
CmdArgs.push_back("-mconstructor-aliases");
// Darwin's kernel doesn't support guard variables; just die if we
diff --git a/clang/test/Driver/aix-constructor-alias.c b/clang/test/Driver/aix-constructor-alias.c
new file mode 100644
index 000000000000..18c5f5b5b877
--- /dev/null
+++ b/clang/test/Driver/aix-constructor-alias.c
@@ -0,0 +1,7 @@
+// Check that we don't pass -mconstructor-aliases when compiling for AIX.
+
+// RUN: %clang -### -target powerpc-ibm-aix7.1.0.0 %s -c -o %t.o 2>&1 \
+// RUN: | FileCheck %s
+// RUN: %clang -### -target powerpc64-ibm-aix7.1.0.0 %s -c -o %t.o 2>&1 \
+// RUN: | FileCheck %s
+// CHECK-NOT: "-mconstructor-aliases"
diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
index 2651b683bd0d..241a19d48027 100644
--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -155,6 +155,14 @@ class PPCAIXAsmPrinter : public PPCAsmPrinter {
StringRef getPassName() const override { return "AIX PPC Assembly Printer"; }
+ bool doInitialization(Module &M) override {
+ if (M.alias_size() > 0u)
+ report_fatal_error(
+ "module has aliases, which LLVM does not yet support for AIX");
+
+ return PPCAsmPrinter::doInitialization(M);
+ }
+
void SetupMachineFunction(MachineFunction &MF) override;
void emitGlobalVariable(const GlobalVariable *GV) override;
diff --git a/llvm/test/CodeGen/PowerPC/aix-alias.ll b/llvm/test/CodeGen/PowerPC/aix-alias.ll
new file mode 100644
index 000000000000..2183c2e8c557
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/aix-alias.ll
@@ -0,0 +1,10 @@
+; RUN: not --crash llc < %s -mtriple powerpc-ibm-aix-xcoff 2>&1 | FileCheck %s
+; RUN: not --crash llc < %s -mtriple powerpc64-ibm-aix-xcoff 2>&1 | FileCheck %s
+
+; Check that, while generation of aliases on AIX remains unimplemented, llc dies
+; with an appropriate message instead of generating incorrect output when an
+; alias is encountered.
+
+define i32 @a() { ret i32 0 }
+; CHECK: ERROR: module has aliases
+ at b = internal alias i32 (), i32 ()* @a
More information about the cfe-commits
mailing list