[PATCH] D142443: [ORC] Drop Comdat when discarding IR symbol
Jonas Hahnfeld via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 24 01:57:27 PST 2023
Hahnfeld created this revision.
Hahnfeld added a reviewer: lhames.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Hahnfeld requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
According to the IR verifier, "Declaration[s] may not be in a Comdat!"
Repository:
rG LLVM Github Monorepo
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,14 @@
+; RUN: lli -extra-module %p/Inputs/weak-comdat-def.ll %s
+
+$c = comdat any
+
+define weak i32 @f() comdat($c) {
+entry:
+ 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,6 @@
+$c = comdat any
+
+define i32 @f() comdat($c) {
+entry:
+ ret i32 0
+}
Index: llvm/lib/ExecutionEngine/Orc/Layer.cpp
===================================================================
--- llvm/lib/ExecutionEngine/Orc/Layer.cpp
+++ llvm/lib/ExecutionEngine/Orc/Layer.cpp
@@ -122,6 +122,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.491671.patch
Type: text/x-patch
Size: 1327 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230124/863582b2/attachment.bin>
More information about the llvm-commits
mailing list