[PATCH] D72479: [PowerPC][AIX] Make PIC the default relocation model for AIX
Steven Wan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 10 14:34:21 PST 2020
stevewan updated this revision to Diff 237434.
stevewan marked 4 inline comments as done.
stevewan added a comment.
Herald added a subscriber: mgorny.
Address comments to:
1. disable setting anything other than PIC for AIX,
2. add an API unit test instead of LIT test.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72479/new/
https://reviews.llvm.org/D72479
Files:
llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
llvm/unittests/CodeGen/AIXRelocModelTest.cpp
llvm/unittests/CodeGen/CMakeLists.txt
Index: llvm/unittests/CodeGen/CMakeLists.txt
===================================================================
--- llvm/unittests/CodeGen/CMakeLists.txt
+++ llvm/unittests/CodeGen/CMakeLists.txt
@@ -14,6 +14,7 @@
add_llvm_unittest(CodeGenTests
AArch64SelectionDAGTest.cpp
+ AIXRelocModelTest.cpp
DIEHashTest.cpp
LowLevelTypeTest.cpp
MachineInstrBundleIteratorTest.cpp
Index: llvm/unittests/CodeGen/AIXRelocModelTest.cpp
===================================================================
--- /dev/null
+++ llvm/unittests/CodeGen/AIXRelocModelTest.cpp
@@ -0,0 +1,25 @@
+#include "llvm/ADT/Triple.h"
+#include "llvm/Support/TargetRegistry.h"
+#include "llvm/Target/TargetMachine.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+TEST(AIXRelocModelTest, ForceDefalutToPIC) {
+ Triple TheTriple(/*ArchStr*/ "powerpc", /*VendorStr*/ "", /*OSStr*/ "aix");
+ std::string Error;
+ const Target *TheTarget = TargetRegistry::lookupTarget("", TheTriple, Error);
+ ASSERT_TRUE(TheTarget) << Error;
+
+ TargetOptions Options;
+ // Create a TargetMachine for powerpc-aix target, and deliberately try to set
+ // its relocation model to static.
+ std::unique_ptr<TargetMachine> Target(TheTarget->createTargetMachine(
+ /*TT*/ TheTriple.getTriple(), /*CPU*/ "", /*Features*/ "",
+ /*Options*/ Options, /*RM*/ Reloc::Static, /*CM*/ None,
+ /*OL*/ CodeGenOpt::Default));
+ ASSERT_TRUE(Target) << "Could not allocate target machine!";
+
+ // The relocation model on AIX should be force to PIC regardeless.
+ EXPECT_TRUE(Target->getRelocationModel() == Reloc::PIC_);
+}
Index: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -223,6 +223,10 @@
static Reloc::Model getEffectiveRelocModel(const Triple &TT,
Optional<Reloc::Model> RM) {
+ // AIX only supports PIC, RM option is ignored.
+ if (TT.isOSAIX())
+ return Reloc::PIC_;
+
if (RM.hasValue())
return *RM;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72479.237434.patch
Type: text/x-patch
Size: 2117 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200110/ea171648/attachment.bin>
More information about the llvm-commits
mailing list