Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions compiler/rustc_codegen_llvm/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ fn prepare_lto(
}
}

// __llvm_profile_counter_bias is pulled in at link time by an undefined reference to
// __llvm_profile_runtime, therefore we won't know until link time if this symbol
// should have default visibility.
symbols_below_threshold.push(CString::new("__llvm_profile_counter_bias").unwrap());
Ok((symbols_below_threshold, upstream_modules))
}

Expand Down
10 changes: 10 additions & 0 deletions src/test/codegen/pgo-counter-bias.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Test that __llvm_profile_counter_bias does not get internalized by lto.

// ignore-macos -runtime-counter-relocation not honored on Mach-O
// compile-flags: -Cprofile-generate -Cllvm-args=-runtime-counter-relocation -Clto=fat
// needs-profiler-support
// no-prefer-dynamic

// CHECK: @__llvm_profile_counter_bias = {{.*}}global

pub fn main() {}