[all-commits] [llvm/llvm-project] 0b0428: [clang][CodeGen] Compute the pointer-overflow offs...
Adam Magier via All-commits
all-commits at lists.llvm.org
Mon Sep 21 13:22:24 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 0b04288569e3daff0c42e302d6e024056eedb895
https://github.com/llvm/llvm-project/commit/0b04288569e3daff0c42e302d6e024056eedb895
Author: Adam Magier <adam.a.magier.foss at gmail.com>
Date: 2026-09-21 (Mon, 21 Sep 2026)
Changed paths:
Log Message:
-----------
[clang][CodeGen] Compute the pointer-overflow offset from the index list (#225139)
Follow up to #223446. EmitGEPOffsetInBytes recreated the offset by
walking the GEP value that EmitCheckedInBoundsGEP had just created. That
required a separate path for the case where CreateGEP folded the result,
because a folded GEP need not be a GEP at all: `gep(null, 1)` becomes
`inttoptr(1)`, and `gep(@g, 0)` becomes `@g`.
Pass ElemTy and IdxList instead and walk those directly. This removes
the constant path, the cast to GEPOperator, and two asserts that
restated the caller's own behaviour.
This is not quite NFC. The constant path reported OffsetOverflows as
false unconditionally, so a constant GEP whose byte offset wrapped to
exactly zero satisfied the TotalOffset == Zero early return and emitted
no check. The unified path computes the flag, so such a GEP now emits
one. It is provably valid, since TotalOffset == 0 makes the computed
address equal the base, so this is extra IR at -O0 rather than a change
in behaviour.
Add constant-base cases to ubsan-pointer-overflow-constant-fold.c,
including the wraps-to-zero case: it passes before this change only
because no check is emitted at all.
Assisted-by: Kiro CLI / Claude Opus 5
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list