Conversation
|
baseline: llvm/llvm-project@fe94ae8 |
|
Regression: |
|
@dtcxzyw It's possible to fold |
Alive2: https://alive2.llvm.org/ce/z/Zy_4Dz I will post a patch later. |
|
@dtcxzyw We could avoid doing the transform if the offset is also constant. Or change clang frontend to not emit |
|
A possible miscompilation after simplifying diff: But this BB seems to be unreachable. |
296115f to
7225cd8
Compare
…se pointers (#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.
…ith null base pointers (#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.
PR Link: llvm/llvm-project#76458