[LLVMbugs] [Bug 1678] New: wrong weak alias optimization with llvm-gcc-4.2

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Sep 18 02:04:21 PDT 2007


http://llvm.org/bugs/show_bug.cgi?id=1678

           Summary: wrong weak alias optimization with llvm-gcc-4.2
           Product: new-bugs
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: baldrick at free.fr
                CC: llvmbugs at cs.uiuc.edu


This bug only effects llvm-gcc-4.2.  Here is the testcase:

extern void B (void);
static __typeof(B) A __attribute__ ((__weakref__("B")));
int active (void)
{
  static void *const p = __extension__ (void *) &A;
  return p != 0;
}

This is optimized to:

@A = alias weak void ()* @B
define i32 @active() {
entry:
        ret i32 1
}

which is wrong (see PR1646).  The cause is quite interesting though:
llvm-gcc emits the function @active and runs per function passes on
it.  At that point A has not yet been declared an alias for B!  It
is simply an ordinary global.  Thus the optimizers correctly decide
that &A is not null.  The alias is only output later.

This shows a danger with per-function passes: if a function refers
to globals then those globals had better be in their final state
before any passes are run.


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list