[all-commits] [llvm/llvm-project] 37f85a: [clang][CodeGen] Use ptrtoaddr for the pointer-ove...
Adam Magier via All-commits
all-commits at lists.llvm.org
Mon Sep 21 09:38:09 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 37f85ad1b302a993a6b2d3afd0a031baf64e7d9c
https://github.com/llvm/llvm-project/commit/37f85ad1b302a993a6b2d3afd0a031baf64e7d9c
Author: Adam Magier <adam.a.magier.foss at gmail.com>
Date: 2026-09-21 (Mon, 21 Sep 2026)
Changed paths:
M clang/lib/CodeGen/CGExprScalar.cpp
M clang/test/CodeGen/catch-nullptr-and-nonzero-offset-when-nullptr-is-defined.c
M clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
M clang/test/CodeGen/catch-pointer-overflow-volatile.c
M clang/test/CodeGen/catch-pointer-overflow.c
M clang/test/CodeGen/ubsan-pointer-overflow.c
Log Message:
-----------
[clang][CodeGen] Use ptrtoaddr for the pointer-overflow check (#223446)
Since 052dde9c3a62 ("[SCEV] Do not represent ptrtoint as ptrtoaddr")
SCEV treats the check's ptrtoint as opaque, so IndVarSimplify no longer
infers nuw on the reconstructed address and InstCombine no longer folds
the comparison. Provably safe checks now survive to run time.
ptrtoaddr is correct here: the address is only compared against the
recomputed one and passed to the handler, and is dead otherwise. This is
unlike the pointer subtraction in d7594bf4caa5 (reverted in
fcd814ae4357), whose result is a user-visible value that can be used to
reconstruct a pointer, e.g. via -(nullptr - ptr).
The result type becomes DL.getAddressType(), so the offset arithmetic is
done in the address width rather than the pointer width. They coincide
in every address space the check is emitted in on in-tree targets, and
where they do not the diagnostics are unaffected: EmitCheckValue
zero-extends a narrower argument to IntPtrTy before the handler call.
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