[PATCH] D142443: [ORC] Drop Comdat when discarding IR symbol
Jonas Hahnfeld via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 5 02:07:03 PST 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG50ca8b3e8726: [ORC] Drop Comdat when discarding IR symbol (authored by Hahnfeld).
Changed prior to commit:
https://reviews.llvm.org/D142443?vs=494524&id=494878#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142443/new/
https://reviews.llvm.org/D142443
Files:
llvm/lib/ExecutionEngine/Orc/Layer.cpp
llvm/test/ExecutionEngine/Orc/Inputs/weak-comdat-def.ll
llvm/test/ExecutionEngine/Orc/weak-comdat.ll
Index: llvm/test/ExecutionEngine/Orc/weak-comdat.ll
===================================================================
--- /dev/null
+++ llvm/test/ExecutionEngine/Orc/weak-comdat.ll
@@ -0,0 +1,18 @@
+; RUN: lli -extra-module %p/Inputs/weak-comdat-def.ll %s
+; UNSUPPORTED: target={{.*}}-darwin{{.*}}
+
+declare i32 @g()
+
+$f = comdat nodeduplicate
+
+define weak i32 @f() comdat {
+entry:
+ %0 = call i32 @g()
+ ret i32 %0
+}
+
+define i32 @main() {
+entry:
+ %0 = call i32 @f()
+ ret i32 %0
+}
Index: llvm/test/ExecutionEngine/Orc/Inputs/weak-comdat-def.ll
===================================================================
--- /dev/null
+++ llvm/test/ExecutionEngine/Orc/Inputs/weak-comdat-def.ll
@@ -0,0 +1,12 @@
+define i32 @g() {
+entry:
+ ret i32 0
+}
+
+$f = comdat nodeduplicate
+
+define i32 @f() comdat {
+entry:
+ %0 = call i32 @g()
+ ret i32 %0
+}
Index: llvm/lib/ExecutionEngine/Orc/Layer.cpp
===================================================================
--- llvm/lib/ExecutionEngine/Orc/Layer.cpp
+++ llvm/lib/ExecutionEngine/Orc/Layer.cpp
@@ -125,6 +125,10 @@
assert(!I->second->isDeclaration() &&
"Discard should only apply to definitions");
I->second->setLinkage(GlobalValue::AvailableExternallyLinkage);
+ // According to the IR verifier, "Declaration[s] may not be in a Comdat!"
+ // Remove it, if this is a GlobalObject.
+ if (auto *GO = dyn_cast<GlobalObject>(I->second))
+ GO->setComdat(nullptr);
SymbolToDefinition.erase(I);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142443.494878.patch
Type: text/x-patch
Size: 1494 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230205/5679d21d/attachment.bin>
More information about the llvm-commits
mailing list