[PATCH] D29015: [LoopUnswitch] Fix introduction of UB when hoisted condition may be undef or poison
Juneyoung Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 2 16:46:21 PST 2017
aqjune added inline comments.
================
Comment at: include/llvm/IR/IRBuilder.h:1718
+ FreezeInst *FI = nullptr;
+
+ if (Instruction *I = dyn_cast<Instruction>(Arg)) {
----------------
filcab wrote:
> Maybe add
> ```if (isa<FreezeInst>(Arg))
> return Arg;```
> so we don't need to create a `FreezeInst` that will be immediately simplified in the next run of instsimplify (and avoids `ReplaceAllUsesWith`)?
> Unless I missed something.
@filcab I think it is caller's job to check whether the value is simple enough and creating a new freeze is unnecessary. A function `FreezeBranchCondition` in this patch (which is in LoopUnswitch.cpp) does similar thing : first of all it checks whether the new freeze instruction is needed (by calling isGuaranteedNotToBeUndefOrPoison), and then calls this function (`CreateFreezeAtDef`).
https://reviews.llvm.org/D29015
More information about the llvm-commits
mailing list