Open zhusihang opened 1 year ago
This is a bug in compiler-rt. Overflow in pointer arithmetic is undefined behavior, so it's not surprising the overflow check gets optimized away.
This is a bug in compiler-rt. Overflow in pointer arithmetic is undefined behavior, so it's not surprising the overflow check gets optimized away.
So is there any recommended solution for debugging? In addition to compiler_rt, there are 50 such scenes in libcxx and libcxxabi
When compiling compiler-rt/lib/profile/InstrProfilingMerge.c:125:20, bad instruction folding by foldGEPICmp during instcombine.
Unsigned comparison (aka. SrcName Start < Src Counter Start) becomes signed comparison (aka. Header->CountersSize * __llvm_profile_counter_entry_size() < 0). The original overflow judgment becomes a comparison of the second parameter of the gep instruction with 0. The result is always false, causing the corresponding overflow judgment semantics to fail.