aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineLICM.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/MachineLICM.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineLICM.cpp38
1 files changed, 29 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/MachineLICM.cpp b/llvm/lib/CodeGen/MachineLICM.cpp
index 462d4d3b3726..5e8a916b3b3b 100644
--- a/llvm/lib/CodeGen/MachineLICM.cpp
+++ b/llvm/lib/CodeGen/MachineLICM.cpp
@@ -635,6 +635,12 @@ void MachineLICMBase::HoistPostRA(MachineInstr *MI, unsigned Def) {
MachineBasicBlock *MBB = MI->getParent();
Preheader->splice(Preheader->getFirstTerminator(), MBB, MI);
+ // Since we are moving the instruction out of its basic block, we do not
+ // retain its debug location. Doing so would degrade the debugging
+ // experience and adversely affect the accuracy of profiling information.
+ assert(!MI->isDebugInstr() && "Should not hoist debug inst");
+ MI->setDebugLoc(DebugLoc());
+
// Add register to livein list to all the BBs in the current loop since a
// loop invariant must be kept live throughout the whole loop. This is
// important to ensure later passes do not scavenge the def register.
@@ -731,8 +737,7 @@ void MachineLICMBase::HoistOutOfLoop(MachineDomTreeNode *HeaderN) {
continue;
Scopes.push_back(Node);
- const std::vector<MachineDomTreeNode*> &Children = Node->getChildren();
- unsigned NumChildren = Children.size();
+ unsigned NumChildren = Node->getNumChildren();
// Don't hoist things out of a large switch statement. This often causes
// code to be hoisted that wasn't going to be executed, and increases
@@ -741,13 +746,14 @@ void MachineLICMBase::HoistOutOfLoop(MachineDomTreeNode *HeaderN) {
NumChildren = 0;
OpenChildren[Node] = NumChildren;
- // Add children in reverse order as then the next popped worklist node is
- // the first child of this node. This means we ultimately traverse the
- // DOM tree in exactly the same order as if we'd recursed.
- for (int i = (int)NumChildren-1; i >= 0; --i) {
- MachineDomTreeNode *Child = Children[i];
- ParentMap[Child] = Node;
- WorkList.push_back(Child);
+ if (NumChildren) {
+ // Add children in reverse order as then the next popped worklist node is
+ // the first child of this node. This means we ultimately traverse the
+ // DOM tree in exactly the same order as if we'd recursed.
+ for (MachineDomTreeNode *Child : reverse(Node->children())) {
+ ParentMap[Child] = Node;
+ WorkList.push_back(Child);
+ }
}
}
@@ -829,7 +835,15 @@ void MachineLICMBase::SinkIntoLoop() {
}
if (!CanSink || !B || B == Preheader)
continue;
+
+ LLVM_DEBUG(dbgs() << "Sinking to " << printMBBReference(*B) << " from "
+ << printMBBReference(*I->getParent()) << ": " << *I);
B->splice(B->getFirstNonPHI(), Preheader, I);
+
+ // The instruction is is moved from its basic block, so do not retain the
+ // debug information.
+ assert(!I->isDebugInstr() && "Should not sink debug inst");
+ I->setDebugLoc(DebugLoc());
}
}
@@ -1367,6 +1381,11 @@ MachineInstr *MachineLICMBase::ExtractHoistableLoad(MachineInstr *MI) {
UpdateRegPressure(NewMIs[1]);
// Otherwise we successfully unfolded a load that we can hoist.
+
+ // Update the call site info.
+ if (MI->shouldUpdateCallSiteInfo())
+ MF.eraseCallSiteInfo(MI);
+
MI->eraseFromParent();
return NewMIs[0];
}
@@ -1519,6 +1538,7 @@ bool MachineLICMBase::Hoist(MachineInstr *MI, MachineBasicBlock *Preheader) {
// Since we are moving the instruction out of its basic block, we do not
// retain its debug location. Doing so would degrade the debugging
// experience and adversely affect the accuracy of profiling information.
+ assert(!MI->isDebugInstr() && "Should not hoist debug inst");
MI->setDebugLoc(DebugLoc());
// Update register pressure for BBs from header to this block.