[llvm] 4a7702b - [AsmPrinter] Avoid use of ConstantExpr::getIntegerCast() (NFCI)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 1 04:08:01 PDT 2023


Author: Nikita Popov
Date: 2023-11-01T12:05:58+01:00
New Revision: 4a7702b785809a0dcd8a38bf7cbdd8181427c716

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

LOG: [AsmPrinter] Avoid use of ConstantExpr::getIntegerCast() (NFCI)

In the cases where this used to create a sext/zext constant
expression we should later error for that expression anyway, so
this should be NFC.

Added: 
    

Modified: 
    llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index fd440718fd37837..c6014cff24c10e5 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -3052,9 +3052,12 @@ const MCExpr *AsmPrinter::lowerConstant(const Constant *CV) {
     // Handle casts to pointers by changing them into casts to the appropriate
     // integer type.  This promotes constant folding and simplifies this code.
     Constant *Op = CE->getOperand(0);
-    Op = ConstantExpr::getIntegerCast(Op, DL.getIntPtrType(CV->getType()),
-                                      false/*ZExt*/);
-    return lowerConstant(Op);
+    Op = ConstantFoldIntegerCast(Op, DL.getIntPtrType(CV->getType()),
+                                 /*IsSigned*/ false, DL);
+    if (Op)
+      return lowerConstant(Op);
+
+    break; // Error
   }
 
   case Instruction::PtrToInt: {


        


More information about the llvm-commits mailing list