Skip to content

extern_weak globals may be nullptr #1185

@workingjubilee

Description

@workingjubilee

Alive2 asserts this transformation is correct: https://alive2.llvm.org/ce/z/YX8gMP

@GLIBC_PRIVATE = extern_weak global {}

define noundef zeroext i1 @src() unnamed_addr {
start:
  %_ptr = ptrtoint ptr @GLIBC_PRIVATE to i64
  %_0 = icmp eq i64 %_ptr, 0
  ret i1 %_0
}

define noundef zeroext i1 @tgt() unnamed_addr {
start:
  ret i1 false
}

However, I'm told by llvm/llvm-project#133621 that this is in fact incorrect specifically for the case of extern_weak linkage. This is a fairly subtle bug, but may be because Alive2 is discarding the linkage instead of examining it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions