[PATCH] D38940: Make x86 __ehhandler comdat if parent function is

Dave Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 17 11:16:53 PDT 2017


kastiglione updated this revision to Diff 119355.
kastiglione added a comment.

Reuse parent comdat; Add test


https://reviews.llvm.org/D38940

Files:
  lib/Target/X86/X86WinEHState.cpp
  test/CodeGen/WinEH/wineh-comdat.ll


Index: test/CodeGen/WinEH/wineh-comdat.ll
===================================================================
--- /dev/null
+++ 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) {
Index: lib/Target/X86/X86WinEHState.cpp
===================================================================
--- lib/Target/X86/X86WinEHState.cpp
+++ lib/Target/X86/X86WinEHState.cpp
@@ -401,6 +401,8 @@
                        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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38940.119355.patch
Type: text/x-patch
Size: 1303 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171017/04089b2f/attachment.bin>


More information about the llvm-commits mailing list