[LLVMbugs] [Bug 1646] New: Weak alias assumed to be non-null results in wrong code for unwind-dw2.c

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sat Sep 8 14:07:52 PDT 2007


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

           Summary: Weak alias assumed to be non-null results in wrong code
                    for unwind-dw2.c
           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


Created an attachment (id=1108)
 --> (http://llvm.org/bugs/attachment.cgi?id=1108)
testcase .ll

The attached testcase is the code used by gcc to test
whether a program was linked with the pthreads library.
LLVM optimizes it to

define i32 @__gthread_active_p() {
entry:
        ret i32 1
}

which is wrong.  Probably it thinks that the weak alias
@__gthrw_pthread_cancel = alias weak i32 (i32)* @pthread_cancel
is necessarily non-null.  The original code was:

static __typeof(pthread_cancel) __gthrw_pthread_cancel __attribute__
((__weakref__("pthread_cancel")));

static __inline__ int
__gthread_active_p (void)
{
  static void *const __gthread_active_ptr
    = __extension__ (void *) &__gthrw_pthread_cancel;
  return __gthread_active_ptr != 0;
}


-- 
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