Skip to content

Commit 03d030b

Browse files
hahnjotstellar
authored andcommitted
[CodeGen] Filter out available_externally aliases
The Language Reference says that aliases can have available_externally linkage if their aliasee is an available_externally global value. Using this kind of aliases resulted in crashes during code generation, filter them out (the same that the AsmPrinter also filters out GlobalVariables in emitSpecialLLVMGlobal(); Functions are discarded in the machine pass infrastructure). Differential Revision: https://reviews.llvm.org/D142352 (cherry picked from commit f1c4f92)
1 parent aa2bbfa commit 03d030b

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2235,6 +2235,8 @@ bool AsmPrinter::doFinalization(Module &M) {
22352235
SmallVector<const GlobalAlias *, 16> AliasStack;
22362236
SmallPtrSet<const GlobalAlias *, 16> AliasVisited;
22372237
for (const auto &Alias : M.aliases()) {
2238+
if (Alias.hasAvailableExternallyLinkage())
2239+
continue;
22382240
for (const GlobalAlias *Cur = &Alias; Cur;
22392241
Cur = dyn_cast<GlobalAlias>(Cur->getAliasee())) {
22402242
if (!AliasVisited.insert(Cur).second)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; RUN: llc < %s
2+
3+
@v = available_externally global i32 42, align 4
4+
@va = available_externally alias i32, ptr @v
5+
6+
define available_externally i32 @f() {
7+
entry:
8+
ret i32 0
9+
}
10+
11+
@fa = available_externally alias i32(), ptr @f

0 commit comments

Comments
 (0)