Skip to content

Commit

Permalink
[CodeGen]Add NoVRegs property on PostRASink and ShrinkWrap
Browse files Browse the repository at this point in the history
Summary:
This change declare that PostRAMachineSinking and ShrinkWrap require NoVRegs
property, so now the MachineFunctionPass can enforce this check.
These passes are disabled in NVPTX & WebAssembly.

Reviewers: dschuff, jlebar, tra, jgravelle-google, MatzeB, sebpop, thegameg, mcrosier

Reviewed By: dschuff, thegameg

Subscribers: jholewinski, jfb, sbc100, aheejin, sunfish, llvm-commits

Differential Revision: https://reviews.llvm.org/D45183

llvm-svn: 329095
  • Loading branch information
Jun Bum Lim committed Apr 3, 2018
1 parent 2c5f944 commit 7ab1b32
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions llvm/lib/CodeGen/MachineSink.cpp
Expand Up @@ -953,6 +953,11 @@ class PostRAMachineSinking : public MachineFunctionPass {
MachineFunctionPass::getAnalysisUsage(AU);
}

MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
}

private:
/// Track which registers have been modified and used.
BitVector ModifiedRegs, UsedRegs;
Expand Down
5 changes: 5 additions & 0 deletions llvm/lib/CodeGen/ShrinkWrap.cpp
Expand Up @@ -219,6 +219,11 @@ class ShrinkWrap : public MachineFunctionPass {
MachineFunctionPass::getAnalysisUsage(AU);
}

MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
}

StringRef getPassName() const override { return "Shrink Wrapping analysis"; }

/// \brief Perform the shrink-wrapping analysis and update
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
Expand Up @@ -238,9 +238,11 @@ void NVPTXPassConfig::addIRPasses() {
disablePass(&TailDuplicateID);
disablePass(&StackMapLivenessID);
disablePass(&LiveDebugValuesID);
disablePass(&PostRAMachineSinkingID);
disablePass(&PostRASchedulerID);
disablePass(&FuncletLayoutID);
disablePass(&PatchableFunctionID);
disablePass(&ShrinkWrapID);

// NVVMReflectPass is added in addEarlyAsPossiblePasses, so hopefully running
// it here does nothing. But since we need it for correctness when lowering
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
Expand Up @@ -264,16 +264,15 @@ void WebAssemblyPassConfig::addPostRegAlloc() {
// virtual registers. Consider removing their restrictions and re-enabling
// them.

// Has no asserts of its own, but was not written to handle virtual regs.
disablePass(&ShrinkWrapID);

// These functions all require the NoVRegs property.
disablePass(&MachineCopyPropagationID);
disablePass(&PostRAMachineSinkingID);
disablePass(&PostRASchedulerID);
disablePass(&FuncletLayoutID);
disablePass(&StackMapLivenessID);
disablePass(&LiveDebugValuesID);
disablePass(&PatchableFunctionID);
disablePass(&ShrinkWrapID);

TargetPassConfig::addPostRegAlloc();
}
Expand Down

0 comments on commit 7ab1b32

Please sign in to comment.