Skip to content

Commit eb7b0f6

Browse files
committed
Reject global ISel path for NPM
1 parent 375b3fe commit eb7b0f6

File tree

4 files changed

+27
-30
lines changed

4 files changed

+27
-30
lines changed

llvm/include/llvm/CodeGen/TargetPassConfig.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <cassert>
2121
#include <string>
2222

23+
2324
namespace llvm {
2425

2526
class TargetMachine;
@@ -478,6 +479,9 @@ class LLVM_ABI TargetPassConfig : public ImmutablePass {
478479
LLVM_ABI void registerCodeGenCallback(PassInstrumentationCallbacks &PIC,
479480
TargetMachine &);
480481

482+
enum class SelectorType { SelectionDAG, FastISel, GlobalISel };
483+
SelectorType getSelectorType(TargetMachine& TM);
484+
481485
} // end namespace llvm
482486

483487
#endif // LLVM_CODEGEN_TARGETPASSCONFIG_H

llvm/include/llvm/Passes/CodeGenPassBuilder.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -937,21 +937,7 @@ Error CodeGenPassBuilder<Derived, TargetMachineT>::addCoreISelPasses(
937937
TM.setO0WantsFastISel(Opt.EnableFastISelOption.value_or(true));
938938

939939
// Determine an instruction selector.
940-
enum class SelectorType { SelectionDAG, FastISel, GlobalISel };
941-
SelectorType Selector;
942-
943-
if (Opt.EnableFastISelOption && *Opt.EnableFastISelOption == true)
944-
Selector = SelectorType::FastISel;
945-
else if ((Opt.EnableGlobalISelOption &&
946-
*Opt.EnableGlobalISelOption == true) ||
947-
(TM.Options.EnableGlobalISel &&
948-
(!Opt.EnableGlobalISelOption ||
949-
*Opt.EnableGlobalISelOption == false)))
950-
Selector = SelectorType::GlobalISel;
951-
else if (TM.getOptLevel() == CodeGenOptLevel::None && TM.getO0WantsFastISel())
952-
Selector = SelectorType::FastISel;
953-
else
954-
Selector = SelectorType::SelectionDAG;
940+
SelectorType Selector = getSelectorType(TM);
955941

956942
// Set consistently TM.Options.EnableFastISel and EnableGlobalISel.
957943
if (Selector == SelectorType::FastISel) {

llvm/lib/CodeGen/TargetPassConfig.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,23 @@ void llvm::registerCodeGenCallback(PassInstrumentationCallbacks &PIC,
550550
});
551551
}
552552

553+
SelectorType llvm::getSelectorType(TargetMachine& TM) {
554+
SelectorType Selector;
555+
if (EnableFastISelOption == cl::BOU_TRUE)
556+
Selector = SelectorType::FastISel;
557+
else if (EnableGlobalISelOption == cl::BOU_TRUE ||
558+
(TM.Options.EnableGlobalISel &&
559+
EnableGlobalISelOption != cl::BOU_FALSE))
560+
Selector = SelectorType::GlobalISel;
561+
else if (TM.getOptLevel() == CodeGenOptLevel::None &&
562+
TM.getO0WantsFastISel())
563+
Selector = SelectorType::FastISel;
564+
else
565+
Selector = SelectorType::SelectionDAG;
566+
567+
return Selector;
568+
}
569+
553570
Expected<TargetPassConfig::StartStopInfo>
554571
TargetPassConfig::getStartStopInfo(PassInstrumentationCallbacks &PIC) {
555572
auto [StartBefore, StartBeforeInstanceNum] =
@@ -990,20 +1007,7 @@ bool TargetPassConfig::addCoreISelPasses() {
9901007
TM->setO0WantsFastISel(EnableFastISelOption != cl::BOU_FALSE);
9911008

9921009
// Determine an instruction selector.
993-
enum class SelectorType { SelectionDAG, FastISel, GlobalISel };
994-
SelectorType Selector;
995-
996-
if (EnableFastISelOption == cl::BOU_TRUE)
997-
Selector = SelectorType::FastISel;
998-
else if (EnableGlobalISelOption == cl::BOU_TRUE ||
999-
(TM->Options.EnableGlobalISel &&
1000-
EnableGlobalISelOption != cl::BOU_FALSE))
1001-
Selector = SelectorType::GlobalISel;
1002-
else if (TM->getOptLevel() == CodeGenOptLevel::None &&
1003-
TM->getO0WantsFastISel())
1004-
Selector = SelectorType::FastISel;
1005-
else
1006-
Selector = SelectorType::SelectionDAG;
1010+
SelectorType Selector = getSelectorType(*TM);
10071011

10081012
// Set consistently TM->Options.EnableFastISel and EnableGlobalISel.
10091013
if (Selector == SelectorType::FastISel) {

llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,10 @@ AMDGPUTargetMachine::AMDGPUTargetMachine(const Target &T, const Triple &TT,
751751
getEffectiveCodeModel(CM, CodeModel::Small), OptLevel),
752752
TLOF(createTLOF(getTargetTriple())) {
753753
initAsmInfo();
754-
setNewPMForBackend(true);
754+
755+
if (getSelectorType(*this) != SelectorType::GlobalISel)
756+
setNewPMForBackend(true);
757+
755758
if (TT.isAMDGCN()) {
756759
if (getMCSubtargetInfo()->checkFeatures("+wavefrontsize64"))
757760
MRI.reset(llvm::createGCNMCRegisterInfo(AMDGPUDwarfFlavour::Wave64));

0 commit comments

Comments
 (0)