@@ -539,31 +539,43 @@ bool isNotCrossLaneOperation(const Instruction *I);
539539// / move the instruction as long as the correct dominance relationships for
540540// / the operands and users hold.
541541// /
542+ // / If \p UseVariableInfo is true, the information from non-constant operands
543+ // / will be taken into account.
544+ // /
545+ // / If \p AllowRefinement is true, UB-implying attributes and metadata will be
546+ // / ignored. The caller is responsible for correctly propagating them after
547+ // / hoisting.
548+ // /
542549// / This method can return true for instructions that read memory;
543550// / for such instructions, moving them may change the resulting value.
544551bool isSafeToSpeculativelyExecute (const Instruction *I,
545552 const Instruction *CtxI = nullptr ,
546553 AssumptionCache *AC = nullptr ,
547554 const DominatorTree *DT = nullptr ,
548555 const TargetLibraryInfo *TLI = nullptr ,
549- bool UseVariableInfo = true );
556+ bool UseVariableInfo = true ,
557+ bool AllowRefinement = true );
550558
551559inline bool isSafeToSpeculativelyExecute (const Instruction *I,
552560 BasicBlock::iterator CtxI,
553561 AssumptionCache *AC = nullptr ,
554562 const DominatorTree *DT = nullptr ,
555563 const TargetLibraryInfo *TLI = nullptr ,
556- bool UseVariableInfo = true ) {
564+ bool UseVariableInfo = true ,
565+ bool AllowRefinement = true ) {
557566 // Take an iterator, and unwrap it into an Instruction *.
558- return isSafeToSpeculativelyExecute (I, &*CtxI, AC, DT, TLI, UseVariableInfo);
567+ return isSafeToSpeculativelyExecute (I, &*CtxI, AC, DT, TLI, UseVariableInfo,
568+ AllowRefinement);
559569}
560570
561571// / Don't use information from its non-constant operands. This helper is used
562572// / when its operands are going to be replaced.
563573inline bool
564- isSafeToSpeculativelyExecuteWithVariableReplaced (const Instruction *I) {
574+ isSafeToSpeculativelyExecuteWithVariableReplaced (const Instruction *I,
575+ bool AllowRefinement = true ) {
565576 return isSafeToSpeculativelyExecute (I, nullptr , nullptr , nullptr , nullptr ,
566- /* UseVariableInfo=*/ false );
577+ /* UseVariableInfo=*/ false ,
578+ AllowRefinement);
567579}
568580
569581// / This returns the same result as isSafeToSpeculativelyExecute if Opcode is
@@ -586,7 +598,8 @@ isSafeToSpeculativelyExecuteWithVariableReplaced(const Instruction *I) {
586598bool isSafeToSpeculativelyExecuteWithOpcode (
587599 unsigned Opcode, const Instruction *Inst, const Instruction *CtxI = nullptr ,
588600 AssumptionCache *AC = nullptr , const DominatorTree *DT = nullptr ,
589- const TargetLibraryInfo *TLI = nullptr , bool UseVariableInfo = true );
601+ const TargetLibraryInfo *TLI = nullptr , bool UseVariableInfo = true ,
602+ bool AllowRefinement = true );
590603
591604// / Returns true if the result or effects of the given instructions \p I
592605// / depend values not reachable through the def use graph.
0 commit comments