[PATCH] D110245: [ConstantFolding] Fold ptrtoint(gep i8 null, x) -> x
    Nikita Popov via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Thu Sep 23 02:35:41 PDT 2021
    
    
  
nikic added inline comments.
================
Comment at: llvm/lib/Analysis/ConstantFolding.cpp:1371-1373
+          // for the invalid inbounds case. Using the integer value is safer
+          // than unconditionally returning zero for inbounds since e.g. Clang
+          // will emit an inbounds GEP on null for hand-written offsetof().
----------------
lebedev.ri wrote:
> I don't think matters what is "safer", that mentioned code is UB, and UBSan will catch it.
I think this comment should just be dropped entirely. Any optimization that is valid without inbounds is valid with inbounds and does not require explicit justification.
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110245/new/
https://reviews.llvm.org/D110245
    
    
More information about the llvm-commits
mailing list