[llvm] f248d5e - [Local] Bring back check for FP types in getExpressionForConstant.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 31 05:52:13 PST 2023


Author: Florian Hahn
Date: 2023-12-31T13:50:25Z
New Revision: f248d5eed1ef49947c882c3c30d49ef061c12936

URL: https://github.com/llvm/llvm-project/commit/f248d5eed1ef49947c882c3c30d49ef061c12936
DIFF: https://github.com/llvm/llvm-project/commit/f248d5eed1ef49947c882c3c30d49ef061c12936.diff

LOG: [Local] Bring back check for FP types in getExpressionForConstant.

The check makes sure that the result for getZExtValue is guaranteed to
fit into 64 bit.

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/Local.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index e08c5f0a4e548e..c76cc9db16d7e7 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -3593,7 +3593,8 @@ DIExpression *llvm::getExpressionForConstant(DIBuilder &DIB, const Constant &C,
   if (isa<ConstantInt>(C))
     return createIntegerExpression(C);
 
-  if (auto *FP = dyn_cast<ConstantFP>(&C)) {
+  auto *FP = dyn_cast<ConstantFP>(&C);
+  if (FP && (Ty.isFloatTy() || Ty.isDoubleTy())) {
     const APFloat &APF = FP->getValueAPF();
     return DIB.createConstantValueExpression(
         APF.bitcastToAPInt().getZExtValue());


        


More information about the llvm-commits mailing list