diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -2235,6 +2235,8 @@ SmallVector AliasStack; SmallPtrSet AliasVisited; for (const auto &Alias : M.aliases()) { + if (Alias.hasAvailableExternallyLinkage()) + continue; for (const GlobalAlias *Cur = &Alias; Cur; Cur = dyn_cast(Cur->getAliasee())) { if (!AliasVisited.insert(Cur).second) diff --git a/llvm/test/CodeGen/Generic/available_externally_alias.ll b/llvm/test/CodeGen/Generic/available_externally_alias.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/Generic/available_externally_alias.ll @@ -0,0 +1,11 @@ +; RUN: llc < %s + +@v = available_externally global i32 42, align 4 +@va = available_externally alias i32, ptr @v + +define available_externally i32 @f() { +entry: + ret i32 0 +} + +@fa = available_externally alias i32(), ptr @f