Skip to content

Commit

Permalink
[llc][PPC] Move PIC check into TargetMachine (#66727)
Browse files Browse the repository at this point in the history
Matches other code like the code model checking.
  • Loading branch information
aeubanks authored Oct 16, 2023
1 parent d392073 commit 5e4ec53
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
5 changes: 3 additions & 2 deletions llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/tools/llc/aix-pic-setting.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 0 additions & 14 deletions llvm/tools/llc/llc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 5e4ec53

Please sign in to comment.