summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/BranchFolding.cpp
diff options
context:
space:
mode:
authorSasa Stankovic <Sasa.Stankovic@imgtec.com>2014-06-05 13:42:48 +0000
committerSasa Stankovic <Sasa.Stankovic@imgtec.com>2014-06-05 13:42:48 +0000
commit56c12e679aafae59f05e2ab15ba6c547a69bf97c (patch)
tree14c6b5148e5b7a3aaa6dcf5eb50ee2a7db924b06 /llvm/lib/CodeGen/BranchFolding.cpp
parenta46952221e44cb53b707bca433b5177191de779d (diff)
downloadbcm5719-llvm-56c12e679aafae59f05e2ab15ba6c547a69bf97c.tar.gz
bcm5719-llvm-56c12e679aafae59f05e2ab15ba6c547a69bf97c.zip
Prevent hoisting the instruction whose def might be clobbered by the terminator.
llvm-svn: 210261
Diffstat (limited to 'llvm/lib/CodeGen/BranchFolding.cpp')
-rw-r--r--llvm/lib/CodeGen/BranchFolding.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp
index f623a48cf0d..7503e575199 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -1505,10 +1505,17 @@ MachineBasicBlock::iterator findHoistingInsertPosAndDeps(MachineBasicBlock *MBB,
if (MO.isUse()) {
for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI)
Uses.insert(*AI);
- } else if (!MO.isDead())
- // Don't try to hoist code in the rare case the terminator defines a
- // register that is later used.
- return MBB->end();
+ } else {
+ if (!MO.isDead())
+ // Don't try to hoist code in the rare case the terminator defines a
+ // register that is later used.
+ return MBB->end();
+
+ // If the terminator defines a register, make sure we don't hoist
+ // the instruction whose def might be clobbered by the terminator.
+ for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI)
+ Defs.insert(*AI);
+ }
}
if (Uses.empty())
OpenPOWER on IntegriCloud