Skip to content

Weak alias assumed to be non-null results in wrong code for unwind-dw2.c #2018

@llvmbot

Description

@llvmbot
Bugzilla Link 1646
Resolution FIXED
Resolved on Sep 10, 2007 18:48
Version 2.0
OS Linux
Attachments testcase .ll
Reporter LLVM Bugzilla Contributor
CC @asl

Extended Description

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions