diff options
author | Dan Gohman <gohman@apple.com> | 2009-09-26 02:34:00 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-09-26 02:34:00 +0000 |
commit | 2f5bdcb7c254dace9f73ed536b5e61095a917bde (patch) | |
tree | 9c8969f9fa8fe8ce2c07cee9a01aa5a0c6c547e3 /llvm/lib/CodeGen/MachineSink.cpp | |
parent | bdaaab4671bccb5453837f982e062fb5407d59b4 (diff) | |
download | llvm-2f5bdcb7c254dace9f73ed536b5e61095a917bde.zip llvm-2f5bdcb7c254dace9f73ed536b5e61095a917bde.tar.gz llvm-2f5bdcb7c254dace9f73ed536b5e61095a917bde.tar.bz2 |
Don't hoist or sink instructions with physreg uses if the physreg is
allocatable. Even if it doesn't appear to have any defs, it may latter
on after register allocation.
llvm-svn: 82834
Diffstat (limited to 'llvm/lib/CodeGen/MachineSink.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineSink.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MachineSink.cpp b/llvm/lib/CodeGen/MachineSink.cpp index 5f555b2..636dad8 100644 --- a/llvm/lib/CodeGen/MachineSink.cpp +++ b/llvm/lib/CodeGen/MachineSink.cpp @@ -39,6 +39,7 @@ namespace { MachineFunction *CurMF; // Current MachineFunction MachineRegisterInfo *RegInfo; // Machine register information MachineDominatorTree *DT; // Machine dominator tree + BitVector AllocatableSet; // Which physregs are allocatable? public: static char ID; // Pass identification @@ -99,6 +100,7 @@ bool MachineSinking::runOnMachineFunction(MachineFunction &MF) { TRI = TM->getRegisterInfo(); RegInfo = &CurMF->getRegInfo(); DT = &getAnalysis<MachineDominatorTree>(); + AllocatableSet = TRI->getAllocatableSet(*CurMF); bool EverMadeChange = false; @@ -180,13 +182,20 @@ bool MachineSinking::SinkInstruction(MachineInstr *MI, bool &SawStore) { // we can move it, but only if the def is dead. if (MO.isUse()) { // If the physreg has no defs anywhere, it's just an ambient register - // and we can freely move its uses. + // and we can freely move its uses. Alternatively, if it's allocatable, + // it could get allocated to something with a def during allocation. if (!RegInfo->def_empty(Reg)) return false; + if (AllocatableSet.test(Reg)) + return false; // Check for a def among the register's aliases too. - for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias) - if (!RegInfo->def_empty(*Alias)) + for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias) { + unsigned AliasReg = *Alias; + if (!RegInfo->def_empty(AliasReg)) + return false; + if (AllocatableSet.test(AliasReg)) return false; + } } else if (!MO.isDead()) { // A def that isn't dead. We can't move it. return false; |