aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp')
-rw-r--r--llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
index 6ee0468..2d1b762 100644
--- a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
+++ b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
@@ -1974,6 +1974,13 @@ void CHR::addToMergedCondition(bool IsTrueBiased, Value *Cond,
Cond = IRB.CreateXor(ConstantInt::getTrue(F.getContext()), Cond);
}
+ // Select conditions can be poison, while branching on poison is immediate
+ // undefined behavior. As such, we need to freeze potentially poisonous
+ // conditions derived from selects.
+ if (isa<SelectInst>(BranchOrSelect) &&
+ !isGuaranteedNotToBeUndefOrPoison(Cond))
+ Cond = IRB.CreateFreeze(Cond);
+
MergedCondition = IRB.CreateAnd(MergedCondition, Cond);
}