diff options
author | Robert Lougher <rob.lougher@gmail.com> | 2016-10-25 18:44:07 +0000 |
---|---|---|
committer | Robert Lougher <rob.lougher@gmail.com> | 2016-10-25 18:44:07 +0000 |
commit | e32564774c09344e80ea8f17bdc652412543f77b (patch) | |
tree | b49727c3964bfd80289b4b6d258bdf1c25018b1a /llvm/lib/CodeGen/BranchFolding.cpp | |
parent | cffedc4a94cc21a124521e96280935ef7ca1aa85 (diff) | |
download | bcm5719-llvm-e32564774c09344e80ea8f17bdc652412543f77b.tar.gz bcm5719-llvm-e32564774c09344e80ea8f17bdc652412543f77b.zip |
Remove debug location from common tail when tail-merging
The branch folding pass tail merges blocks into a common-tail. However, the
tail retains the debug information from one of the original inputs to the
merge (chosen randomly). This is a problem for sampled-based PGO, as hits
on the common-tail will be attributed to whichever block was chosen,
irrespective of which path was actually taken to the common-tail.
This patch fixes the issue by nulling the debug location for the common-tail.
Differential Revision: https://reviews.llvm.org/D25742
llvm-svn: 285093
Diffstat (limited to 'llvm/lib/CodeGen/BranchFolding.cpp')
-rw-r--r-- | llvm/lib/CodeGen/BranchFolding.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp index 71074513c89..20c36a923df 100644 --- a/llvm/lib/CodeGen/BranchFolding.cpp +++ b/llvm/lib/CodeGen/BranchFolding.cpp @@ -720,8 +720,6 @@ bool BranchFolder::CreateCommonTailOnlyBlock(MachineBasicBlock *&PredBB, SameTails[commonTailIndex].getTailStartPos(); MachineBasicBlock *MBB = SameTails[commonTailIndex].getBlock(); - // If the common tail includes any debug info we will take it pretty - // randomly from one of the inputs. Might be better to remove it? DEBUG(dbgs() << "\nSplitting BB#" << MBB->getNumber() << ", size " << maxCommonTailLength); @@ -898,6 +896,11 @@ bool BranchFolder::TryTailMergeBlocks(MachineBasicBlock *SuccBB, // Recompute common tail MBB's edge weights and block frequency. setCommonTailEdgeWeights(*MBB); + // Remove the original debug location from the common tail. + for (auto &MI : *MBB) + if (!MI.isDebugValue()) + MI.setDebugLoc(DebugLoc()); + // MBB is common tail. Adjust all other BB's to jump to this one. // Traversal must be forwards so erases work. DEBUG(dbgs() << "\nUsing common tail in BB#" << MBB->getNumber() |