Skip to content

Commit a18dd29

Browse files
committed
[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.
1 parent d906ac5 commit a18dd29

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/Analysis/ConstantFolding.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,8 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
924924
Ptr = cast<Constant>(GEP->getOperand(0));
925925
SrcElemTy = GEP->getSourceElementType();
926926
Offset = Offset.sadd_ov(
927-
APInt(BitWidth, DL.getIndexedOffsetInType(SrcElemTy, NestedOps)),
927+
APInt(BitWidth, DL.getIndexedOffsetInType(SrcElemTy, NestedOps),
928+
/*isSigned=*/true, /*implicitTrunc=*/true),
928929
Overflow);
929930
}
930931

0 commit comments

Comments
 (0)