summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Target/X86/X86WinEHState.cpp2
-rw-r--r--llvm/test/CodeGen/WinEH/wineh-comdat.ll17
2 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86WinEHState.cpp b/llvm/lib/Target/X86/X86WinEHState.cpp
index 0c3b3434147..0472a85f50d 100644
--- a/llvm/lib/Target/X86/X86WinEHState.cpp
+++ b/llvm/lib/Target/X86/X86WinEHState.cpp
@@ -401,6 +401,8 @@ Function *WinEHStatePass::generateLSDAInEAXThunk(Function *ParentFunc) {
Twine("__ehhandler$") + GlobalValue::dropLLVMManglingEscape(
ParentFunc->getName()),
TheModule);
+ if (auto *C = ParentFunc->getComdat())
+ Trampoline->setComdat(C);
BasicBlock *EntryBB = BasicBlock::Create(Context, "entry", Trampoline);
IRBuilder<> Builder(EntryBB);
Value *LSDA = emitEHLSDA(Builder, ParentFunc);
diff --git a/llvm/test/CodeGen/WinEH/wineh-comdat.ll b/llvm/test/CodeGen/WinEH/wineh-comdat.ll
new file mode 100644
index 00000000000..5484370a767
--- /dev/null
+++ b/llvm/test/CodeGen/WinEH/wineh-comdat.ll
@@ -0,0 +1,17 @@
+; RUN: opt -mtriple=i686-unknown-windows-msvc -S -x86-winehstate < %s | FileCheck %s
+
+$f = comdat any
+
+define void @f() comdat personality i32 (...)* @__CxxFrameHandler3 {
+ invoke void @g() to label %return unwind label %unwind
+return:
+ ret void
+unwind:
+ %pad = cleanuppad within none []
+ cleanupret from %pad unwind to caller
+}
+
+declare void @g()
+declare i32 @__CxxFrameHandler3(...)
+
+; CHECK: define internal i32 @"__ehhandler$f"(i8*, i8*, i8*, i8*){{ .+}} comdat($f) {
OpenPOWER on IntegriCloud