From 3ea4ac5467aaa7355807a80b838ddeb025b2392e Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 11 Feb 2015 18:50:13 +0000 Subject: [PATCH] Add a comdat to __clang_call_terminate git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@228863 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGException.cpp | 2 ++ test/CodeGenCXX/exceptions.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp index a632a40e14..9df4f97731 100644 --- a/lib/CodeGen/CGException.cpp +++ b/lib/CodeGen/CGException.cpp @@ -1564,6 +1564,8 @@ static llvm::Constant *getClangCallTerminateFn(CodeGenModule &CGM) { // we don't want it to turn into an exported symbol. fn->setLinkage(llvm::Function::LinkOnceODRLinkage); fn->setVisibility(llvm::Function::HiddenVisibility); + if (CGM.supportsCOMDAT()) + fn->setComdat(CGM.getModule().getOrInsertComdat(fn->getName())); // Set up the function. llvm::BasicBlock *entry = diff --git a/test/CodeGenCXX/exceptions.cpp b/test/CodeGenCXX/exceptions.cpp index 5016e9a794..c1c678d832 100644 --- a/test/CodeGenCXX/exceptions.cpp +++ b/test/CodeGenCXX/exceptions.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s +// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s typedef typeof(sizeof(0)) size_t; @@ -71,7 +71,7 @@ namespace test1 { // rdar://11904428 // Terminate landing pads should call __cxa_begin_catch first. - // CHECK: define linkonce_odr hidden void @__clang_call_terminate(i8*) [[NI_NR_NUW:#[0-9]+]] + // CHECK: define linkonce_odr hidden void @__clang_call_terminate(i8*) [[NI_NR_NUW:#[0-9]+]] comdat // CHECK-NEXT: [[T0:%.*]] = call i8* @__cxa_begin_catch(i8* %0) [[NUW:#[0-9]+]] // CHECK-NEXT: call void @_ZSt9terminatev() [[NR_NUW:#[0-9]+]] // CHECK-NEXT: unreachable -- 2.40.0