From: David Majnemer Date: Tue, 26 Jan 2016 23:14:47 +0000 (+0000) Subject: [WinEH] Annotate calls to __RTtypeid with a funclet bundle X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9200182f8f5511fe3faa58cc0f758c8316691453;p=clang [WinEH] Annotate calls to __RTtypeid with a funclet bundle Clang's CodeGen has several paths which end up invoking or calling a function. The one that we used for calls to __RTtypeid did not appropriately annotate the call with a funclet bundle. This fixes PR26329. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258877 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index b589ae3f88..5bd452e1c9 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -3121,13 +3121,16 @@ CodeGenFunction::EmitCallOrInvoke(llvm::Value *Callee, ArrayRef Args, const Twine &Name) { llvm::BasicBlock *InvokeDest = getInvokeDest(); + SmallVector BundleList; + getBundlesForFunclet(Callee, CurrentFuncletPad, BundleList); llvm::Instruction *Inst; if (!InvokeDest) - Inst = Builder.CreateCall(Callee, Args, Name); + Inst = Builder.CreateCall(Callee, Args, BundleList, Name); else { llvm::BasicBlock *ContBB = createBasicBlock("invoke.cont"); - Inst = Builder.CreateInvoke(Callee, ContBB, InvokeDest, Args, Name); + Inst = Builder.CreateInvoke(Callee, ContBB, InvokeDest, Args, BundleList, + Name); EmitBlock(ContBB); } diff --git a/test/CodeGenCXX/microsoft-abi-typeid.cpp b/test/CodeGenCXX/microsoft-abi-typeid.cpp index 60c31ab470..d73f8483a7 100644 --- a/test/CodeGenCXX/microsoft-abi-typeid.cpp +++ b/test/CodeGenCXX/microsoft-abi-typeid.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -O1 -o - -triple=i386-pc-win32 %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -O1 -o - -triple=i386-pc-win32 %s -fexceptions -fcxx-exceptions | FileCheck %s struct type_info; namespace std { using ::type_info; } @@ -49,3 +49,22 @@ const std::type_info* test5_typeid() { return &typeid(v); } // CHECK: [[RT:%.*]] = tail call i8* @__RTtypeid(i8* bitcast (%struct.V* @"\01?v@@3UV@@A" to i8*)) // CHECK-NEXT: [[RET:%.*]] = bitcast i8* [[RT]] to %struct.type_info* // CHECK-NEXT: ret %struct.type_info* [[RET]] + +namespace PR26329 { +struct Polymorphic { + virtual ~Polymorphic(); +}; + +void f(const Polymorphic &poly) { + try { + throw; + } catch (...) { + Polymorphic cleanup; + typeid(poly); + } +} +// CHECK-LABEL: define void @"\01?f@PR26329@@YAXABUPolymorphic@1@@Z"( +// CHECK: %[[cs:.*]] = catchswitch within none [label %{{.*}}] unwind to caller +// CHECK: %[[cp:.*]] = catchpad within %[[cs]] [i8* null, i32 64, i8* null] +// CHECK: invoke i8* @__RTtypeid(i8* {{.*}}) [ "funclet"(token %[[cp]]) ] +}