Skip to content

EntryExitInstrumenter: skip available_externally linkage #121452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
6 changes: 6 additions & 0 deletions llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ static bool runOnFunction(Function &F, bool PostInlining) {
if (F.hasFnAttribute(Attribute::Naked))
return false;

// available_externally functions may not have definitions external to the
// module (e.g. gnu::always_inline). Instrumenting them might lead to linker
// errors if they are optimized out. Skip them like GCC.
if (F.hasAvailableExternallyLinkage())
return false;

StringRef EntryAttr = PostInlining ? "instrument-function-entry-inlined"
: "instrument-function-entry";

Expand Down
7 changes: 7 additions & 0 deletions llvm/test/Transforms/EntryExitInstrumenter/mcount.ll
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ define void @naked() naked {
ret void
}

define available_externally void @always_inline() {
; CHECK-LABEL: define available_externally void @always_inline() {
; CHECK-NEXT: ret void
;
ret void
}

; The attributes are "consumed" when the instrumentation is inserted.
; CHECK: attributes
; CHECK-NOT: instrument-function
Expand Down
Loading