aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ConstantFolding.cpp
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-10-23 17:58:07 +0200
committerNikita Popov <nikita.ppv@gmail.com>2021-10-23 17:59:39 +0200
commit710596a1e15188171edd5c6fffe6b7fe483ca594 (patch)
tree29ce48fe686a3df59d1b274dfef2333b7cfd2b9d /llvm/lib/Analysis/ConstantFolding.cpp
parentd8e4170b0a1431edee939efc16b60b409affcb4d (diff)
downloadllvm-710596a1e15188171edd5c6fffe6b7fe483ca594.zip
llvm-710596a1e15188171edd5c6fffe6b7fe483ca594.tar.gz
llvm-710596a1e15188171edd5c6fffe6b7fe483ca594.tar.bz2
[ConstantFolding] Accept offset in ConstantFoldLoadFromConstPtr (NFCI)
As this API is now internally offset-based, we can accept a starting offset and remove the need to create a temporary bitcast+gep sequence to perform an offset load. The API now mirrors the ConstantFoldLoadFromConst() API.
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r--llvm/lib/Analysis/ConstantFolding.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 8ec4ea1..4cc3fcd 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -690,8 +690,8 @@ Constant *llvm::ConstantFoldLoadFromConst(Constant *C, Type *Ty,
}
Constant *llvm::ConstantFoldLoadFromConstPtr(Constant *C, Type *Ty,
+ APInt Offset,
const DataLayout &DL) {
- APInt Offset(DL.getIndexTypeSizeInBits(C->getType()), 0);
C = cast<Constant>(C->stripAndAccumulateConstantOffsets(
DL, Offset, /* AllowNonInbounds */ true));
@@ -715,6 +715,12 @@ Constant *llvm::ConstantFoldLoadFromConstPtr(Constant *C, Type *Ty,
return nullptr;
}
+Constant *llvm::ConstantFoldLoadFromConstPtr(Constant *C, Type *Ty,
+ const DataLayout &DL) {
+ APInt Offset(DL.getIndexTypeSizeInBits(C->getType()), 0);
+ return ConstantFoldLoadFromConstPtr(C, Ty, Offset, DL);
+}
+
namespace {
/// One of Op0/Op1 is a constant expression.