diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-08-29 20:48:45 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-08-29 20:48:45 +0000 |
commit | 813a109fa5b5f41534e0fcc22cfbaa0d0888c05b (patch) | |
tree | 3ce8db6d3c2ca4d7a9a1832fb196001fa65ea30f /llvm/lib/CodeGen/MachineInstr.cpp | |
parent | 84ee8bf34905f4bc0f8d296659bc16b138ca51cb (diff) | |
download | bcm5719-llvm-813a109fa5b5f41534e0fcc22cfbaa0d0888c05b.tar.gz bcm5719-llvm-813a109fa5b5f41534e0fcc22cfbaa0d0888c05b.zip |
Don't move normal loads across volatile/atomic loads.
It is technically allowed to move a normal load across a volatile load,
but probably not a good idea.
It is not allowed to move a load across an atomic load with
Ordering > Monotonic, and we model those with MOVolatile as well.
I recently removed the mayStore flag from atomic load instructions, so
they don't need a pseudo-opcode. This patch makes up for the difference.
llvm-svn: 162857
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index bfb722bf3bb..7ff79b3a223 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -1343,7 +1343,12 @@ bool MachineInstr::isSafeToMove(const TargetInstrInfo *TII, AliasAnalysis *AA, bool &SawStore) const { // Ignore stuff that we obviously can't move. - if (mayStore() || isCall()) { + // + // Treat volatile loads as stores. This is not strictly necessary for + // volatiles, but it is required for atomic loads. It is now allowed to move + // a load across an atomic load with Ordering > Monotonic. + if (mayStore() || isCall() || + (mayLoad() && hasVolatileMemoryRef())) { SawStore = true; return false; } @@ -1359,8 +1364,8 @@ bool MachineInstr::isSafeToMove(const TargetInstrInfo *TII, // load. if (mayLoad() && !isInvariantLoad(AA)) // Otherwise, this is a real load. If there is a store between the load and - // end of block, or if the load is volatile, we can't move it. - return !SawStore && !hasVolatileMemoryRef(); + // end of block, we can't move it. + return !SawStore; return true; } |