[PATCH] D79044: [AIX] Avoid structor alias; die before bad alias codegen

Hubert Tong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 28 14:34:34 PDT 2020


hubert.reinterpretcast created this revision.
hubert.reinterpretcast added reviewers: cebowleratibm, jasonliu, sfertile, daltenty, DiggerLin.
Herald added subscribers: kbarton, hiraditya, nemanjai.
Herald added projects: clang, LLVM.
hubert.reinterpretcast edited the summary of this revision.
Herald added a subscriber: wuzish.

`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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79044

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-constructor-alias.c
  llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
  llvm/test/CodeGen/PowerPC/aix-alias.ll


Index: llvm/test/CodeGen/PowerPC/aix-alias.ll
===================================================================
--- /dev/null
+++ 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
Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -155,6 +155,14 @@
 
   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;
Index: clang/test/Driver/aix-constructor-alias.c
===================================================================
--- /dev/null
+++ 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"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4672,8 +4672,8 @@
 
   // 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79044.260767.patch
Type: text/x-patch
Size: 2583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200428/3b5af57a/attachment.bin>


More information about the llvm-commits mailing list