aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/ConstantFold.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2023-01-06 12:02:52 +0100
committerNikita Popov <npopov@redhat.com>2023-01-06 12:06:42 +0100
commitf09d32d121cdb77603b677c9666cfffb2186f86c (patch)
treedc5481c50ff36a2df9ddcde6bcbdc69973530570 /llvm/lib/IR/ConstantFold.cpp
parent48c68367d0320e0d6ec03bb9cf76a108f9202cad (diff)
downloadllvm-f09d32d121cdb77603b677c9666cfffb2186f86c.zip
llvm-f09d32d121cdb77603b677c9666cfffb2186f86c.tar.gz
llvm-f09d32d121cdb77603b677c9666cfffb2186f86c.tar.bz2
[ConstantFold] Don't drop zero index gep with inrange attribute
This may cause GlobalSplit to fail if opaque pointers are used. inrange really needs a new representation, but for now restore the pre-opaque pointers status.
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r--llvm/lib/IR/ConstantFold.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index 2566617..f84fe79 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -2053,6 +2053,10 @@ Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C,
if (!C->getType()->getScalarType()->isOpaquePointerTy() && Idxs.size() != 1)
return false;
+ // Avoid losing inrange information.
+ if (InRangeIndex)
+ return false;
+
return all_of(Idxs, [](Value *Idx) {
Constant *IdxC = cast<Constant>(Idx);
return IdxC->isNullValue() || isa<UndefValue>(IdxC);