[llvm] a18dd29 - [ConstantFolding] Set signed/implicitTrunc when handling GEP offsets
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 21 03:47:15 PDT 2024
Author: Nikita Popov
Date: 2024-10-21T12:47:02+02:00
New Revision: a18dd29077c84fc076a4ed431d9e815a3d0b6f24
URL: https://github.com/llvm/llvm-project/commit/a18dd29077c84fc076a4ed431d9e815a3d0b6f24
DIFF: https://github.com/llvm/llvm-project/commit/a18dd29077c84fc076a4ed431d9e815a3d0b6f24.diff
LOG: [ConstantFolding] Set signed/implicitTrunc when handling GEP offsets
GEP offsets have sext_or_trunc semantics. We were already doing
this for the outer-most GEP, but not for the inner ones.
I believe one of the sanitizer buildbot failures was due to this,
but I did not manage to reproduce the issue or come up with a
test case. Usually the problematic case will already be folded
away due to index type canonicalization.
Added:
Modified:
llvm/lib/Analysis/ConstantFolding.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index c0104d2bc26112..530e9287d9e102 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -924,7 +924,8 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
Ptr = cast<Constant>(GEP->getOperand(0));
SrcElemTy = GEP->getSourceElementType();
Offset = Offset.sadd_ov(
- APInt(BitWidth, DL.getIndexedOffsetInType(SrcElemTy, NestedOps)),
+ APInt(BitWidth, DL.getIndexedOffsetInType(SrcElemTy, NestedOps),
+ /*isSigned=*/true, /*implicitTrunc=*/true),
Overflow);
}
More information about the llvm-commits
mailing list