[Clang][CodeGen] Do not set inbounds flag for struct GEP with null base pointers by dtcxzyw · Pull Request #130734 · llvm/llvm-project (original) (raw)
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Clang issues not falling into any other category
IR generation bugs: mangling, exceptions, etc.
labels
dtcxzyw added a commit that referenced this pull request
… type (#134221)
If CreateConstInBoundsGEP2_32
returns a constant null/gep, the cast to
GetElementPtrInst will fail.
This patch uses two static helpers
GEPOperator::accumulateConstantOffset/GetElementPtrInst::getIndexedType
to infer offset and result type instead of depending on the GEP result.
This patch is extracted from #130734.
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request
… and result type (#134221)
If CreateConstInBoundsGEP2_32
returns a constant null/gep, the cast to
GetElementPtrInst will fail.
This patch uses two static helpers
GEPOperator::accumulateConstantOffset/GetElementPtrInst::getIndexedType
to infer offset and result type instead of depending on the GEP result.
This patch is extracted from llvm/llvm-project#130734.
dtcxzyw added a commit that referenced this pull request
This patch turns off inbounds/nuw flags for member accesses when
-fwrapv-pointer
is set.
Closes #132449.
It is required by #130734.
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request
AllinLeeYL pushed a commit to AllinLeeYL/llvm-project that referenced this pull request
dtcxzyw deleted the offsetof-inbounds branch
dtcxzyw added a commit that referenced this pull request
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request
var-const pushed a commit to ldionne/llvm-project that referenced this pull request
var-const pushed a commit to ldionne/llvm-project that referenced this pull request
…se pointers (llvm#130734)
In the LLVM middle-end we want to fold gep inbounds null, idx -> null
:
https://alive2.llvm.org/ce/z/5ZkPx-
This pattern is common in real-world programs
(dtcxzyw/llvm-opt-benchmark#55 (comment)).
Generally, it exists in some (actually) unreachable blocks, which is
introduced by JumpThreading.
However, some old-style offsetof macros are still widely used in real-world C/C++ code (e.g., hwloc/slurm/luajit). To avoid breaking existing code and inconvenience to downstream users, this patch removes the inbounds flag from the struct gep if the base pointer is null.
var-const pushed a commit to ldionne/llvm-project that referenced this pull request
dtcxzyw added a commit that referenced this pull request
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request