aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2023-12-31 13:42:46 +0000
committerFlorian Hahn <flo@fhahn.com>2023-12-31 13:42:47 +0000
commitb46638dc76d35681fbbddc2fd17ef4cde6b057e3 (patch)
treeea0f2019dc92172be8afa61e139088bb2d8ed970 /llvm/lib/Transforms/Utils/Local.cpp
parent1228becf7df28c68579f2b9b390b74aa41149a0a (diff)
downloadllvm-b46638dc76d35681fbbddc2fd17ef4cde6b057e3.zip
llvm-b46638dc76d35681fbbddc2fd17ef4cde6b057e3.tar.gz
llvm-b46638dc76d35681fbbddc2fd17ef4cde6b057e3.tar.bz2
[Local] Handle undef FP constant in getExpressionForConstant.
Check for FP constant instead of checking for floating point types, as Undef/Poison values can have floating point types while not being FPConstants. This fixes a crash introduced by #66745 (f3b20cb).
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index a758fb3..e08c5f0 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -3593,8 +3593,8 @@ DIExpression *llvm::getExpressionForConstant(DIBuilder &DIB, const Constant &C,
if (isa<ConstantInt>(C))
return createIntegerExpression(C);
- if (Ty.isFloatTy() || Ty.isDoubleTy()) {
- const APFloat &APF = cast<ConstantFP>(&C)->getValueAPF();
+ if (auto *FP = dyn_cast<ConstantFP>(&C)) {
+ const APFloat &APF = FP->getValueAPF();
return DIB.createConstantValueExpression(
APF.bitcastToAPInt().getZExtValue());
}