[PATCH] D110256: [SelectionDAG] Replace error prone index check in BaseIndexOffset::computeAliasing
    Nikita Popov via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Thu Sep 23 00:50:45 PDT 2021
    
    
  
nikic added inline comments.
================
Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp:156
+      auto *GV1 = cast<GlobalAddressSDNode>(BasePtr1.getBase())->getGlobal();
+      // It doesn't make sense to access one global value using another globals
+      // values address, so we can assume that there is no aliasing in case of
----------------
bjope wrote:
> I'm not 100% sure about this. https://llvm.org/docs/LangRef.html#global-variables says that "code could assume that the globals are densely packed in their section and try to iterate over them as an array", so does that mean that for example a global variable `@foo` can be accessed using a global variable `@bar` as base ptr and with `(@bar - @foo)` as offset?
Accessing an object using a pointer that is based on a different object is undefined behavior under our [pointer aliasing rules](https://llvm.org/docs/LangRef.html#pointer-aliasing-rules).
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110256/new/
https://reviews.llvm.org/D110256
    
    
More information about the llvm-commits
mailing list