File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -1308,9 +1308,26 @@ bool MachineInstr::isSafeToMove(bool &SawStore) const {
13081308 return false ;
13091309 }
13101310
1311+ // Don't touch instructions that have non-trivial invariants. For example,
1312+ // terminators have to be at the end of a basic block.
13111313 if (isPosition () || isDebugInstr () || isTerminator () ||
1312- mayRaiseFPException () || hasUnmodeledSideEffects () ||
1313- isJumpTableDebugInfo () || isInlineAsm ())
1314+ isJumpTableDebugInfo ())
1315+ return false ;
1316+
1317+ // Don't touch instructions which can have non-load/store effects.
1318+ //
1319+ // Inline asm has a "sideeffect" marker to indicate whether the asm has
1320+ // intentional side-effects. Even if an inline asm is not "sideeffect",
1321+ // though, it still can't be speculatively executed: the operation might
1322+ // not be valid on the current target, or for some combinations of operands.
1323+ // (Some transforms that move an instruction don't speculatively execute it;
1324+ // we currently don't try to handle that distinction here.)
1325+ //
1326+ // Other instructions handled here include those that can raise FP
1327+ // exceptions, x86 "DIV" instructions which trap on divide by zero, and
1328+ // stack adjustments.
1329+ if (mayRaiseFPException () || hasProperty (MCID::UnmodeledSideEffects) ||
1330+ isInlineAsm ())
13141331 return false ;
13151332
13161333 // See if this instruction does a load. If so, we have to guarantee that the
You can’t perform that action at this time.
0 commit comments