diff options
| author | Nikita Popov <npopov@redhat.com> | 2023-09-28 16:44:52 +0200 |
|---|---|---|
| committer | Nikita Popov <npopov@redhat.com> | 2023-09-28 16:45:31 +0200 |
| commit | fb2bdbb83d3913d9d32b28c1de3f3d8b4e6dfc8a (patch) | |
| tree | f1f668d0fe457b5d6f43f5c8090882c7a8e03925 /clang/lib/CodeGen/CGExprConstant.cpp | |
| parent | 2ebd633f145615a42d7e8b1d07cbdad294c244aa (diff) | |
[CodeGen] Avoid use of ConstantExpr::getZExt() (NFC)
Use the constant folding API instead. In preparation for dropping
zext constant expressions.
Diffstat (limited to 'clang/lib/CodeGen/CGExprConstant.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGExprConstant.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index 2c847f0bb13f..9b67a8b3335a 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -25,6 +25,7 @@ #include "clang/Basic/Builtins.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Sequence.h" +#include "llvm/Analysis/ConstantFolding.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/Function.h" @@ -1761,7 +1762,10 @@ llvm::Constant *ConstantEmitter::emitForMemory(CodeGenModule &CGM, // Zero-extend bool. if (C->getType()->isIntegerTy(1) && !destType->isBitIntType()) { llvm::Type *boolTy = CGM.getTypes().ConvertTypeForMem(destType); - return llvm::ConstantExpr::getZExt(C, boolTy); + llvm::Constant *Res = llvm::ConstantFoldCastOperand( + llvm::Instruction::ZExt, C, boolTy, CGM.getDataLayout()); + assert(Res && "Constant folding must succeed"); + return Res; } return C; |
