Skip to content

Commit

Permalink
Split MachineLICM into EarlyMachineLICM and MachineLICM; NFC
Browse files Browse the repository at this point in the history
This avoids playing games with pseudo pass IDs and avoids using an
unreliable MRI::isSSA() check to determine whether register allocation
has happened.

Note that this renames:
- MachineLICMID -> EarlyMachineLICM
- PostRAMachineLICMID -> MachineLICMID
to be consistent with the EarlyTailDuplicate/TailDuplicate naming.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322927 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
MatzeB committed Jan 19, 2018
1 parent 9334f5c commit 0900836
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 78 deletions.
6 changes: 5 additions & 1 deletion include/llvm/CodeGen/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,13 @@ namespace llvm {
/// memory operations.
extern char &ImplicitNullChecksID;

/// MachineLICM - This pass performs LICM on machine instructions.
/// This pass performs loop invariant code motion on machine instructions.
extern char &MachineLICMID;

/// This pass performs loop invariant code motion on machine instructions.
/// This variant works before register allocation. \see MachineLICMID.
extern char &EarlyMachineLICMID;

/// MachineSinking - This pass performs sinking on machine instructions.
extern char &MachineSinkingID;

Expand Down
10 changes: 0 additions & 10 deletions include/llvm/CodeGen/TargetPassConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,6 @@ template <> struct isPodLike<IdentifyingPassPtr> {
/// This is an ImmutablePass solely for the purpose of exposing CodeGen options
/// to the internals of other CodeGen passes.
class TargetPassConfig : public ImmutablePass {
public:
/// Pseudo Pass IDs. These are defined within TargetPassConfig because they
/// are unregistered pass IDs. They are only useful for use with
/// TargetPassConfig APIs to identify multiple occurrences of the same pass.
///

/// PostRAMachineLICM - A clone of the LICM pass that runs during late machine
/// optimization after regalloc.
static char PostRAMachineLICMID;

private:
PassManagerBase *PM = nullptr;
AnalysisID StartBefore = nullptr;
Expand Down
1 change: 1 addition & 0 deletions include/llvm/InitializePasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ void initializeConstantMergeLegacyPassPass(PassRegistry&);
void initializeConstantPropagationPass(PassRegistry&);
void initializeCorrelatedValuePropagationPass(PassRegistry&);
void initializeCostModelAnalysisPass(PassRegistry&);
void initializeEarlyMachineLICMPass(PassRegistry&);
void initializeEarlyTailDuplicatePass(PassRegistry&);
void initializeEntryExitInstrumenterPass(PassRegistry&);
void initializePostInlineEntryExitInstrumenterPass(PassRegistry&);
Expand Down
1 change: 1 addition & 0 deletions lib/CodeGen/CodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) {
initializeDetectDeadLanesPass(Registry);
initializeDwarfEHPreparePass(Registry);
initializeEarlyIfConverterPass(Registry);
initializeEarlyMachineLICMPass(Registry);
initializeEarlyTailDuplicatePass(Registry);
initializeExpandISelPseudosPass(Registry);
initializeExpandMemCmpPassPass(Registry);
Expand Down
128 changes: 74 additions & 54 deletions lib/CodeGen/MachineLICM.cpp

Large diffs are not rendered by default.

14 changes: 4 additions & 10 deletions lib/CodeGen/TargetPassConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,13 @@ static IdentifyingPassPtr overridePass(AnalysisID StandardID,
if (StandardID == &EarlyIfConverterID)
return applyDisable(TargetID, DisableEarlyIfConversion);

if (StandardID == &MachineLICMID)
if (StandardID == &EarlyMachineLICMID)
return applyDisable(TargetID, DisableMachineLICM);

if (StandardID == &MachineCSEID)
return applyDisable(TargetID, DisableMachineCSE);

if (StandardID == &TargetPassConfig::PostRAMachineLICMID)
if (StandardID == &MachineLICMID)
return applyDisable(TargetID, DisablePostRAMachineLICM);

if (StandardID == &MachineSinkingID)
Expand All @@ -267,9 +267,6 @@ INITIALIZE_PASS(TargetPassConfig, "targetpassconfig",
"Target Pass Configuration", false, false)
char TargetPassConfig::ID = 0;

// Pseudo Pass IDs.
char TargetPassConfig::PostRAMachineLICMID = 0;

namespace {

struct InsertedPass {
Expand Down Expand Up @@ -365,9 +362,6 @@ TargetPassConfig::TargetPassConfig(LLVMTargetMachine &TM, PassManagerBase &pm)
initializeBasicAAWrapperPassPass(*PassRegistry::getPassRegistry());
initializeAAResultsWrapperPassPass(*PassRegistry::getPassRegistry());

// Substitute Pseudo Pass IDs for real ones.
substitutePass(&PostRAMachineLICMID, &MachineLICMID);

if (StringRef(PrintMachineInstrs.getValue()).equals(""))
TM.Options.PrintMachineCode = true;

Expand Down Expand Up @@ -933,7 +927,7 @@ void TargetPassConfig::addMachineSSAOptimization() {
// loop info, just like LICM and CSE below.
addILPOpts();

addPass(&MachineLICMID, false);
addPass(&EarlyMachineLICMID, false);
addPass(&MachineCSEID, false);

addPass(&MachineSinkingID);
Expand Down Expand Up @@ -1085,7 +1079,7 @@ void TargetPassConfig::addOptimizedRegAlloc(FunctionPass *RegAllocPass) {
// Run post-ra machine LICM to hoist reloads / remats.
//
// FIXME: can this move into MachineLateOptimization?
addPass(&PostRAMachineLICMID);
addPass(&MachineLICMID);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ void GCNPassConfig::addMachineSSAOptimization() {
addPass(&SILoadStoreOptimizerID);
if (EnableSDWAPeephole) {
addPass(&SIPeepholeSDWAID);
addPass(&MachineLICMID);
addPass(&EarlyMachineLICMID);
addPass(&MachineCSEID);
addPass(&SIFoldOperandsID);
addPass(&DeadMachineInstructionElimID);
Expand Down
4 changes: 2 additions & 2 deletions lib/Target/NVPTX/NVPTXTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ void NVPTXPassConfig::addOptimizedRegAlloc(FunctionPass *RegAllocPass) {
addPass(&StackSlotColoringID);

// FIXME: Needs physical registers
//addPass(&PostRAMachineLICMID);
//addPass(&MachineLICMID);

printAndVerify("After StackSlotColoring");
}
Expand Down Expand Up @@ -358,7 +358,7 @@ void NVPTXPassConfig::addMachineSSAOptimization() {
if (addILPOpts())
printAndVerify("After ILP optimizations");

addPass(&MachineLICMID);
addPass(&EarlyMachineLICMID);
addPass(&MachineCSEID);

addPass(&MachineSinkingID);
Expand Down

0 comments on commit 0900836

Please sign in to comment.