Skip to content

Mergefunc removes functions that are on llvm.used / llvm.compiler.used list #55264

Closed
@tmiasko

Description

@tmiasko

For example, running:

; ModuleID = 'a.ll'
source_filename = "a.38475855-cgu.0"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@llvm.compiler.used = appending global [2 x i8*] [
  i8* bitcast (void ()* @f to i8*), 
  i8* bitcast (void ()* @g to i8*)
], section "llvm.metadata"

define void @f() unnamed_addr #0 {
start:
  ret void
}

define internal void @g() unnamed_addr #0 {
start:
  ret void
}

attributes #0 = { "target-cpu"="x86-64" }

through opt -S -mergefunc, results in g being removed, even though it was present on llvm.compiler.used.list:

; ModuleID = 'a.ll'
source_filename = "a.38475855-cgu.0"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@llvm.compiler.used = appending global [2 x i8*] [i8* bitcast (void ()* @f to i8*), i8* bitcast (void ()* @f to i8*)], section "llvm.metadata"

define void @f() unnamed_addr #0 {
start:
  ret void
}

attributes #0 = { "target-cpu"="x86-64" }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions