[llvm] f1c4f92 - [CodeGen] Filter out available_externally aliases
Jonas Hahnfeld via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 1 00:41:24 PST 2023
Author: Jonas Hahnfeld
Date: 2023-02-01T09:40:30+01:00
New Revision: f1c4f927f7c15b5efdc3589c050fd0513bf6b303
URL: https://github.com/llvm/llvm-project/commit/f1c4f927f7c15b5efdc3589c050fd0513bf6b303
DIFF: https://github.com/llvm/llvm-project/commit/f1c4f927f7c15b5efdc3589c050fd0513bf6b303.diff
LOG: [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
Added:
llvm/test/CodeGen/Generic/available_externally_alias.ll
Modified:
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 0c199c2ab13dc..14df9e9d04c38 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -2235,6 +2235,8 @@ bool AsmPrinter::doFinalization(Module &M) {
SmallVector<const GlobalAlias *, 16> AliasStack;
SmallPtrSet<const GlobalAlias *, 16> AliasVisited;
for (const auto &Alias : M.aliases()) {
+ if (Alias.hasAvailableExternallyLinkage())
+ continue;
for (const GlobalAlias *Cur = &Alias; Cur;
Cur = dyn_cast<GlobalAlias>(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
index 0000000000000..90b289ff393e6
--- /dev/null
+++ b/llvm/test/CodeGen/Generic/available_externally_alias.ll
@@ -0,0 +1,11 @@
+; RUN: llc < %s
+
+ at v = available_externally global i32 42, align 4
+ at va = available_externally alias i32, ptr @v
+
+define available_externally i32 @f() {
+entry:
+ ret i32 0
+}
+
+ at fa = available_externally alias i32(), ptr @f
More information about the llvm-commits
mailing list