summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorRobert Lougher <rob.lougher@gmail.com>2019-05-10 15:55:06 +0000
committerRobert Lougher <rob.lougher@gmail.com>2019-05-10 15:55:06 +0000
commit986b6b86bb8e0f64c52f9fbf81697e398d79107a (patch)
tree113e944bef37a7f39d2d511601281b1411ba23f9 /llvm/lib
parenta0b1518a4a5738765619fd09a58d12573163ec79 (diff)
downloadbcm5719-llvm-986b6b86bb8e0f64c52f9fbf81697e398d79107a.tar.gz
bcm5719-llvm-986b6b86bb8e0f64c52f9fbf81697e398d79107a.zip
[X86] Avoid SFB - Fix inconsistent codegen with/without debug info
Fixes https://bugs.llvm.org/show_bug.cgi?id=40969 The functions findPotentiallyBlockedCopies and buildCopy are currently not accounting for the presence of debug instructions. In the former this results in the optimization not being trigerred, and in the latter results in inconsistent codegen. This patch enables the optimization to be performed in a debug build and ensures the codegen is consistent with non-debug builds. Patch by Chris Dawson. Differential Revision: https://reviews.llvm.org/D61680 llvm-svn: 360436
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/X86/X86AvoidStoreForwardingBlocks.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Target/X86/X86AvoidStoreForwardingBlocks.cpp b/llvm/lib/Target/X86/X86AvoidStoreForwardingBlocks.cpp
index 3ac0b1ae514..11a3ff1bd57 100644
--- a/llvm/lib/Target/X86/X86AvoidStoreForwardingBlocks.cpp
+++ b/llvm/lib/Target/X86/X86AvoidStoreForwardingBlocks.cpp
@@ -406,7 +406,9 @@ void X86AvoidSFBPass::buildCopy(MachineInstr *LoadInst, unsigned NLoadOpcode,
// If the load and store are consecutive, use the loadInst location to
// reduce register pressure.
MachineInstr *StInst = StoreInst;
- if (StoreInst->getPrevNode() == LoadInst)
+ auto PrevInstrIt = skipDebugInstructionsBackward(
+ std::prev(MachineBasicBlock::instr_iterator(StoreInst)), MBB->instr_begin());
+ if (PrevInstrIt.getNodePtr() == LoadInst)
StInst = LoadInst;
MachineInstr *NewStore =
BuildMI(*MBB, StInst, StInst->getDebugLoc(), TII->get(NStoreOpcode))
@@ -530,7 +532,7 @@ void X86AvoidSFBPass::findPotentiallylBlockedCopies(MachineFunction &MF) {
if (!isPotentialBlockedMemCpyLd(MI.getOpcode()))
continue;
int DefVR = MI.getOperand(0).getReg();
- if (!MRI->hasOneUse(DefVR))
+ if (!MRI->hasOneNonDBGUse(DefVR))
continue;
for (auto UI = MRI->use_nodbg_begin(DefVR), UE = MRI->use_nodbg_end();
UI != UE;) {
OpenPOWER on IntegriCloud