https://bugs.llvm.org/show_bug.cgi?id=33878

            Bug ID: 33878
           Summary: BasicAA incorrectly assumes different address spaces
                    don't alias
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Keywords: miscompilation
          Severity: normal
          Priority: P
         Component: Global Analyses
          Assignee: unassignedb...@nondot.org
          Reporter: nunoplo...@sapo.pt
                CC: dav...@freebsd.org, dber...@dberlin.org,
                    gil....@sf.snu.ac.kr, hfin...@anl.gov,
                    jeehoon.k...@sf.snu.ac.kr, juneyoung....@sf.snu.ac.kr,
                    llvm-bugs@lists.llvm.org, reg...@cs.utah.edu,
                    san...@playingwithpointers.com

BasicAA assumes that pointers of different address spaces can't alias.  This is
not true is general, though.

in function BasicAAResult::aliasCheck():

  if (O1 != O2) {
    // Most objects can't alias null.
    if ((isa<ConstantPointerNull>(O2) && isKnownNonNull(O1)) ||
        (isa<ConstantPointerNull>(O1) && isKnownNonNull(O2)))
      return NoAlias;


There are two bugs here:
 - if O1 is null, and O2 is non-null, but they are in different address spaces,
then nothing can be concluded (unless we add target-specific hooks to tell us
that information).

 - isKnownNonNull assumes alloca produces a non-null result, which is not true
in general for address space != 0:

  bool llvm::isKnownNonNull(const Value *V) {
    assert(V->getType()->isPointerTy() && "V must be pointer type");

    // Alloca never returns null, malloc might.
    if (isa<AllocaInst>(V)) return true;
    (...)
  }

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to