diff options
author | Xinliang David Li <davidxl@google.com> | 2017-06-07 18:32:24 +0000 |
---|---|---|
committer | Xinliang David Li <davidxl@google.com> | 2017-06-07 18:32:24 +0000 |
commit | 4f49bee764da46d7d30408d8b3ff63e1127270dd (patch) | |
tree | f479872fefc744ede3a4bcd8c51ac5cb498eb8d8 /llvm/lib/Transforms | |
parent | c1e7a0dde551ff7778e38ce6a7c813958b220186 (diff) | |
download | bcm5719-llvm-4f49bee764da46d7d30408d8b3ff63e1127270dd.tar.gz bcm5719-llvm-4f49bee764da46d7d30408d8b3ff63e1127270dd.zip |
Fix builin_expect lowering bug
PR33346
Skip cases when expected value is not constant int.
llvm-svn: 304933
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp b/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp index 7d8da9b453f..46f8a356426 100644 --- a/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp +++ b/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp @@ -93,7 +93,9 @@ static bool handleSwitchExpect(SwitchInst &SI) { /// the branch probability info for the originating branch can be inferred. static void handlePhiDef(CallInst *Expect) { Value &Arg = *Expect->getArgOperand(0); - ConstantInt *ExpectedValue = cast<ConstantInt>(Expect->getArgOperand(1)); + ConstantInt *ExpectedValue = dyn_cast<ConstantInt>(Expect->getArgOperand(1)); + if (!ExpectedValue) + return; const APInt &ExpectedPhiValue = ExpectedValue->getValue(); // Walk up in backward a list of instructions that |