diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-07-20 21:29:31 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-07-20 21:29:31 +0000 |
commit | e2cfd0d45a303a52b8f69f2071d8c5a355ccdba3 (patch) | |
tree | 90706bd736d547d63089298dbcf9aee6e13b50f6 /llvm/lib/CodeGen/LiveRangeEdit.cpp | |
parent | 8c9496a03c4912f9f8bda8eef17c243ace28bb4b (diff) | |
download | llvm-e2cfd0d45a303a52b8f69f2071d8c5a355ccdba3.zip llvm-e2cfd0d45a303a52b8f69f2071d8c5a355ccdba3.tar.gz llvm-e2cfd0d45a303a52b8f69f2071d8c5a355ccdba3.tar.bz2 |
Avoid folding loads that are unsafe to move.
LiveRangeEdit::foldAsLoad() can eliminate a register by folding a load
into its only use. Only do that when the load is safe to move, and it
won't extend any live ranges.
This fixes PR13414.
llvm-svn: 160575
Diffstat (limited to 'llvm/lib/CodeGen/LiveRangeEdit.cpp')
-rw-r--r-- | llvm/lib/CodeGen/LiveRangeEdit.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/LiveRangeEdit.cpp b/llvm/lib/CodeGen/LiveRangeEdit.cpp index 261d860..896fdbf 100644 --- a/llvm/lib/CodeGen/LiveRangeEdit.cpp +++ b/llvm/lib/CodeGen/LiveRangeEdit.cpp @@ -177,6 +177,19 @@ bool LiveRangeEdit::foldAsLoad(LiveInterval *LI, if (!DefMI || !UseMI) return false; + // Since we're moving the DefMI load, make sure we're not extending any live + // ranges. + if (!allUsesAvailableAt(DefMI, + LIS.getInstructionIndex(DefMI), + LIS.getInstructionIndex(UseMI))) + return false; + + // We also need to make sure it is safe to move the load. + // Assume there are stores between DefMI and UseMI. + bool SawStore = true; + if (!DefMI->isSafeToMove(&TII, 0, SawStore)) + return false; + DEBUG(dbgs() << "Try to fold single def: " << *DefMI << " into single use: " << *UseMI); |