[llvm] 5e4ec53 - [llc][PPC] Move PIC check into TargetMachine (#66727)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 16 10:41:24 PDT 2023
Author: Arthur Eubanks
Date: 2023-10-16T10:41:20-07:00
New Revision: 5e4ec53b8efaa2a5215dd68f970d3c913ce07a20
URL: https://github.com/llvm/llvm-project/commit/5e4ec53b8efaa2a5215dd68f970d3c913ce07a20
DIFF: https://github.com/llvm/llvm-project/commit/5e4ec53b8efaa2a5215dd68f970d3c913ce07a20.diff
LOG: [llc][PPC] Move PIC check into TargetMachine (#66727)
Matches other code like the code model checking.
Added:
Modified:
llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
llvm/test/tools/llc/aix-pic-setting.ll
llvm/tools/llc/llc.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
index 42f052cb15d5cd7..b09975172bf5ecb 100644
--- a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -265,8 +265,9 @@ static PPCTargetMachine::PPCABI computeTargetABI(const Triple &TT,
static Reloc::Model getEffectiveRelocModel(const Triple &TT,
std::optional<Reloc::Model> RM) {
- assert((!TT.isOSAIX() || !RM || *RM == Reloc::PIC_) &&
- "Invalid relocation model for AIX.");
+ if (TT.isOSAIX() && RM && *RM != Reloc::PIC_)
+ report_fatal_error("invalid relocation model, AIX only supports PIC",
+ false);
if (RM)
return *RM;
diff --git a/llvm/test/tools/llc/aix-pic-setting.ll b/llvm/test/tools/llc/aix-pic-setting.ll
index 70e08e2513eeb9f..3537baf1cdebecd 100644
--- a/llvm/test/tools/llc/aix-pic-setting.ll
+++ b/llvm/test/tools/llc/aix-pic-setting.ll
@@ -6,4 +6,4 @@
; RUN: not llc -mtriple=powerpc64-ibm-aix --relocation-model=ropi-rwpi < %s 2>&1 | FileCheck --check-prefix=CHECK-NON-PIC %s
; CHECK-NOT: {{.}}
-; CHECK-NON-PIC: error: '<stdin>': invalid relocation model, AIX only supports PIC
+; CHECK-NON-PIC: invalid relocation model, AIX only supports PIC
diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp
index 0ca06cda20b6e66..0b174afc22ddced 100644
--- a/llvm/tools/llc/llc.cpp
+++ b/llvm/tools/llc/llc.cpp
@@ -558,12 +558,6 @@ static int compileModule(char **argv, LLVMContext &Context) {
exit(1);
}
- // On AIX, setting the relocation model to anything other than PIC is
- // considered a user error.
- if (TheTriple.isOSAIX() && RM && *RM != Reloc::PIC_)
- reportError("invalid relocation model, AIX only supports PIC",
- InputFilename);
-
InitializeOptions(TheTriple);
Target = std::unique_ptr<TargetMachine>(TheTarget->createTargetMachine(
TheTriple.getTriple(), CPUStr, FeaturesStr, Options, RM, CM, OLvl));
@@ -607,14 +601,6 @@ static int compileModule(char **argv, LLVMContext &Context) {
return 1;
}
- // On AIX, setting the relocation model to anything other than PIC is
- // considered a user error.
- if (TheTriple.isOSAIX() && RM && *RM != Reloc::PIC_) {
- WithColor::error(errs(), argv[0])
- << "invalid relocation model, AIX only supports PIC.\n";
- return 1;
- }
-
InitializeOptions(TheTriple);
Target = std::unique_ptr<TargetMachine>(TheTarget->createTargetMachine(
TheTriple.getTriple(), CPUStr, FeaturesStr, Options, RM, CM, OLvl));
More information about the llvm-commits
mailing list