diff options
author | Luke Lau <luke@igalia.com> | 2025-05-01 22:39:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-01 22:39:37 +0800 |
commit | d33c6764680ed78ffe824a83b6a33c0b609bafce (patch) | |
tree | e16926c9d5bedf79e0659aaf05176c899aeea24d /llvm/lib/Analysis/ConstantFolding.cpp | |
parent | b877cfa8f25412a3946d1cde63a1dad95fd95c90 (diff) | |
download | llvm-d33c6764680ed78ffe824a83b6a33c0b609bafce.zip llvm-d33c6764680ed78ffe824a83b6a33c0b609bafce.tar.gz llvm-d33c6764680ed78ffe824a83b6a33c0b609bafce.tar.bz2 |
[ConstantFolding] Constify ConstantFoldInstOperands and ConstantFoldInstruction argument. NFC (#138108)
I tried to use these with a const reference in a separate patch, but the
pointers weren't marked as const. It turns out that these don't mutate
the instruction.
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index dc905ab..5b329e2 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -1123,7 +1123,8 @@ ConstantFoldConstantImpl(const Constant *C, const DataLayout &DL, } // end anonymous namespace -Constant *llvm::ConstantFoldInstruction(Instruction *I, const DataLayout &DL, +Constant *llvm::ConstantFoldInstruction(const Instruction *I, + const DataLayout &DL, const TargetLibraryInfo *TLI) { // Handle PHI nodes quickly here... if (auto *PN = dyn_cast<PHINode>(I)) { @@ -1156,7 +1157,7 @@ Constant *llvm::ConstantFoldInstruction(Instruction *I, const DataLayout &DL, // Scan the operand list, checking to see if they are all constants, if so, // hand off to ConstantFoldInstOperandsImpl. - if (!all_of(I->operands(), [](Use &U) { return isa<Constant>(U); })) + if (!all_of(I->operands(), [](const Use &U) { return isa<Constant>(U); })) return nullptr; SmallDenseMap<Constant *, Constant *> FoldedOps; @@ -1177,7 +1178,7 @@ Constant *llvm::ConstantFoldConstant(const Constant *C, const DataLayout &DL, return ConstantFoldConstantImpl(C, DL, TLI, FoldedOps); } -Constant *llvm::ConstantFoldInstOperands(Instruction *I, +Constant *llvm::ConstantFoldInstOperands(const Instruction *I, ArrayRef<Constant *> Ops, const DataLayout &DL, const TargetLibraryInfo *TLI, |