diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-06-22 19:05:33 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-06-22 19:05:33 +0000 |
commit | 6e1019e64f38ec1ae7f9c14b6f64c488981971a2 (patch) | |
tree | b2893523ebeba7322c153b7cc3f37ec18ebc27b7 /test | |
parent | 6d344ecf955af40c9a1419a0e1ba931959ed9dc6 (diff) | |
download | clang-6e1019e64f38ec1ae7f9c14b6f64c488981971a2.tar.gz clang-6e1019e64f38ec1ae7f9c14b6f64c488981971a2.tar.bz2 clang-6e1019e64f38ec1ae7f9c14b6f64c488981971a2.tar.xz |
Revert "Revert r211402 (and r211408,r211410), "CodeGen: Refactor dynamic_cast and typeid" It crashes msvc codegen in clang/test/SemaCXX/undefined-internal.cpp."
This reverts commit r211467 which reverted r211408,r211410, it caused
crashes in test/SemaCXX/undefined-internal.cpp for i686-win32 targets.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211473 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp | 238 | ||||
-rw-r--r-- | test/CodeGenCXX/microsoft-abi-typeid.cpp | 73 |
2 files changed, 135 insertions, 176 deletions
diff --git a/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp b/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp index 3084d0ea1c..2fc4a622c9 100644 --- a/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp +++ b/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp @@ -1,158 +1,130 @@ -// RUN: %clang_cc1 -emit-llvm -O2 -optzns -o - -triple=i386-pc-win32 2>/dev/null %s | FileCheck %s -// REQUIRES: asserts +// RUN: %clang_cc1 -emit-llvm -O1 -o - -triple=i386-pc-win32 %s | FileCheck %s struct S { char a; }; -struct V { virtual void f(){} }; +struct V { virtual void f(); }; struct A : virtual V {}; struct B : S, virtual V {}; struct T {}; T* test0() { return dynamic_cast<T*>((B*)0); } -// CHECK: define noalias %struct.T* @"\01?test0@@YAPAUT@@XZ"() #0 {
-// CHECK-NEXT: entry:
-// CHECK-NEXT: ret %struct.T* null
-// CHECK-NEXT: }
+// CHECK-LABEL: define noalias %struct.T* @"\01?test0@@YAPAUT@@XZ"() +// CHECK: ret %struct.T* null T* test1(V* x) { return &dynamic_cast<T&>(*x); } -// CHECK: define %struct.T* @"\01?test1@@YAPAUT@@PAUV@@@Z"(%struct.V* %x) #1 { -// CHECK-NEXT: entry: -// CHECK-NEXT: %0 = bitcast %struct.V* %x to i8* -// CHECK-NEXT: %1 = tail call i8* @__RTDynamicCast(i8* %0, i32 0, i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUV@@@8" to i8*), i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUT@@@8" to i8*), i32 1) #2 -// CHECK-NEXT: %2 = bitcast i8* %1 to %struct.T* -// CHECK-NEXT: ret %struct.T* %2 -// CHECK-NEXT: } +// CHECK-LABEL: define %struct.T* @"\01?test1@@YAPAUT@@PAUV@@@Z"(%struct.V* %x) +// CHECK: [[CAST:%.*]] = bitcast %struct.V* %x to i8* +// CHECK-NEXT: [[CALL:%.*]] = tail call i8* @__RTDynamicCast(i8* [[CAST]], i32 0, i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUV@@@8" to i8*), i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUT@@@8" to i8*), i32 1) +// CHECK-NEXT: [[RET:%.*]] = bitcast i8* [[CALL]] to %struct.T* +// CHECK-NEXT: ret %struct.T* [[RET]] T* test2(A* x) { return &dynamic_cast<T&>(*x); } -// CHECK: define %struct.T* @"\01?test2@@YAPAUT@@PAUA@@@Z"(%struct.A* %x) #1 { -// CHECK-NEXT: entry: -// CHECK-NEXT: %0 = bitcast %struct.A* %x to i8* -// CHECK-NEXT: %1 = bitcast %struct.A* %x to i8** -// CHECK-NEXT: %vbtable = load i8** %1, align 4 -// CHECK-NEXT: %2 = getelementptr inbounds i8* %vbtable, i32 4 -// CHECK-NEXT: %3 = bitcast i8* %2 to i32* -// CHECK-NEXT: %vbase_offs = load i32* %3, align 4 -// CHECK-NEXT: %4 = getelementptr inbounds i8* %0, i32 %vbase_offs -// CHECK-NEXT: %5 = tail call i8* @__RTDynamicCast(i8* %4, i32 %vbase_offs, i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUA@@@8" to i8*), i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUT@@@8" to i8*), i32 1) #2 -// CHECK-NEXT: %6 = bitcast i8* %5 to %struct.T* -// CHECK-NEXT: ret %struct.T* %6 -// CHECK-NEXT: } +// CHECK-LABEL: define %struct.T* @"\01?test2@@YAPAUT@@PAUA@@@Z"(%struct.A* %x) +// CHECK: [[CAST:%.*]] = bitcast %struct.A* %x to i8* +// CHECK-NEXT: [[BITCAST:%.*]] = bitcast %struct.A* %x to i8** +// CHECK-NEXT: [[VBTBL:%.*]] = load i8** [[BITCAST]], align 4 +// CHECK-NEXT: [[VBOFFP:%.*]] = getelementptr inbounds i8* [[VBTBL]], i32 4 +// CHECK-NEXT: [[VBOFFPCAST:%.*]] = bitcast i8* [[VBOFFP]] to i32* +// CHECK-NEXT: [[VBOFFS:%.*]] = load i32* [[VBOFFPCAST]], align 4 +// CHECK-NEXT: [[ADJ:%.*]] = getelementptr inbounds i8* [[CAST]], i32 [[VBOFFS]] +// CHECK-NEXT: [[CALL:%.*]] = tail call i8* @__RTDynamicCast(i8* [[ADJ]], i32 [[VBOFFS]], i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUA@@@8" to i8*), i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUT@@@8" to i8*), i32 1) +// CHECK-NEXT: [[RET:%.*]] = bitcast i8* [[CALL]] to %struct.T* +// CHECK-NEXT: ret %struct.T* [[RET]] T* test3(B* x) { return &dynamic_cast<T&>(*x); } -// CHECK: define %struct.T* @"\01?test3@@YAPAUT@@PAUB@@@Z"(%struct.B* %x) #1 { -// CHECK-NEXT: entry: -// CHECK-NEXT: %0 = getelementptr inbounds %struct.B* %x, i32 0, i32 0, i32 0 -// CHECK-NEXT: %vbptr = getelementptr inbounds i8* %0, i32 4 -// CHECK-NEXT: %1 = bitcast i8* %vbptr to i8** -// CHECK-NEXT: %vbtable = load i8** %1, align 4 -// CHECK-NEXT: %2 = getelementptr inbounds i8* %vbtable, i32 4 -// CHECK-NEXT: %3 = bitcast i8* %2 to i32* -// CHECK-NEXT: %vbase_offs = load i32* %3, align 4 -// CHECK-NEXT: %4 = add nsw i32 %vbase_offs, 4 -// CHECK-NEXT: %5 = getelementptr inbounds i8* %0, i32 %4 -// CHECK-NEXT: %6 = tail call i8* @__RTDynamicCast(i8* %5, i32 %4, i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUB@@@8" to i8*), i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUT@@@8" to i8*), i32 1) #2 -// CHECK-NEXT: %7 = bitcast i8* %6 to %struct.T* -// CHECK-NEXT: ret %struct.T* %7 -// CHECK-NEXT: } +// CHECK-LABEL: define %struct.T* @"\01?test3@@YAPAUT@@PAUB@@@Z"(%struct.B* %x) +// CHECK: [[VOIDP:%.*]] = getelementptr inbounds %struct.B* %x, i32 0, i32 0, i32 0 +// CHECK-NEXT: [[VBPTR:%.*]] = getelementptr inbounds i8* [[VOIDP]], i32 4 +// CHECK-NEXT: [[BITCAST:%.*]] = bitcast i8* [[VBPTR:%.*]] to i8** +// CHECK-NEXT: [[VBTBL:%.*]] = load i8** [[BITCAST]], align 4 +// CHECK-NEXT: [[VBOFFP:%.*]] = getelementptr inbounds i8* [[VBTBL]], i32 4 +// CHECK-NEXT: [[VBOFFPCAST:%.*]] = bitcast i8* [[VBOFFP]] to i32* +// CHECK-NEXT: [[VBOFFS:%.*]] = load i32* [[VBOFFPCAST]], align 4 +// CHECK-NEXT: [[DELTA:%.*]] = add nsw i32 [[VBOFFS]], 4 +// CHECK-NEXT: [[ADJ:%.*]] = getelementptr inbounds i8* [[VOIDP]], i32 [[DELTA]] +// CHECK-NEXT: [[CALL:%.*]] = tail call i8* @__RTDynamicCast(i8* [[ADJ]], i32 [[DELTA]], i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUB@@@8" to i8*), i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUT@@@8" to i8*), i32 1) +// CHECK-NEXT: [[RET:%.*]] = bitcast i8* [[CALL]] to %struct.T* +// CHECK-NEXT: ret %struct.T* [[RET]] T* test4(V* x) { return dynamic_cast<T*>(x); } -// CHECK: define %struct.T* @"\01?test4@@YAPAUT@@PAUV@@@Z"(%struct.V* %x) #1 { -// CHECK-NEXT: entry: -// CHECK-NEXT: %0 = bitcast %struct.V* %x to i8* -// CHECK-NEXT: %1 = tail call i8* @__RTDynamicCast(i8* %0, i32 0, i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUV@@@8" to i8*), i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUT@@@8" to i8*), i32 0) #2 -// CHECK-NEXT: %2 = bitcast i8* %1 to %struct.T* -// CHECK-NEXT: ret %struct.T* %2 -// CHECK-NEXT: } +// CHECK-LABEL: define %struct.T* @"\01?test4@@YAPAUT@@PAUV@@@Z"(%struct.V* %x) +// CHECK: [[CAST:%.*]] = bitcast %struct.V* %x to i8* +// CHECK-NEXT: [[CALL:%.*]] = tail call i8* @__RTDynamicCast(i8* [[CAST]], i32 0, i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUV@@@8" to i8*), i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUT@@@8" to i8*), i32 0) +// CHECK-NEXT: [[RET:%.*]] = bitcast i8* [[CALL]] to %struct.T* +// CHECK-NEXT: ret %struct.T* [[RET]] T* test5(A* x) { return dynamic_cast<T*>(x); } -// CHECK: define %struct.T* @"\01?test5@@YAPAUT@@PAUA@@@Z"(%struct.A* %x) #1 { -// CHECK-NEXT: entry: -// CHECK-NEXT: %0 = icmp eq %struct.A* %x, null -// CHECK-NEXT: br i1 %0, label %dynamic_cast.call, label %dynamic_cast.valid -// CHECK: dynamic_cast.valid: ; preds = %entry -// CHECK-NEXT: %1 = bitcast %struct.A* %x to i8* -// CHECK-NEXT: %2 = bitcast %struct.A* %x to i8** -// CHECK-NEXT: %vbtable = load i8** %2, align 4 -// CHECK-NEXT: %3 = getelementptr inbounds i8* %vbtable, i32 4 -// CHECK-NEXT: %4 = bitcast i8* %3 to i32* -// CHECK-NEXT: %vbase_offs = load i32* %4, align 4 -// CHECK-NEXT: %5 = getelementptr inbounds i8* %1, i32 %vbase_offs -// CHECK-NEXT: %6 = tail call i8* @__RTDynamicCast(i8* %5, i32 %vbase_offs, i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUA@@@8" to i8*), i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUT@@@8" to i8*), i32 0) #2 -// CHECK-NEXT: %phitmp = bitcast i8* %6 to %struct.T* -// CHECK-NEXT: br label %dynamic_cast.call -// CHECK: dynamic_cast.call: ; preds = %dynamic_cast.valid, %entry -// CHECK-NEXT: %7 = phi %struct.T* [ %phitmp, %dynamic_cast.valid ], [ null, %entry ] -// CHECK-NEXT: ret %struct.T* %7 -// CHECK-NEXT: } +// CHECK-LABEL: define %struct.T* @"\01?test5@@YAPAUT@@PAUA@@@Z"(%struct.A* %x) +// CHECK: [[CHECK:%.*]] = icmp eq %struct.A* %x, null +// CHECK-NEXT: br i1 [[CHECK]] +// CHECK: [[VOIDP:%.*]] = bitcast %struct.A* %x to i8* +// CHECK-NEXT: [[BITCAST:%.*]] = bitcast %struct.A* %x to i8** +// CHECK-NEXT: [[VBTBL:%.*]] = load i8** [[BITCAST]], align 4 +// CHECK-NEXT: [[VBOFFP:%.*]] = getelementptr inbounds i8* [[VBTBL]], i32 4 +// CHECK-NEXT: [[VBOFFPCAST:%.*]] = bitcast i8* [[VBOFFP]] to i32* +// CHECK-NEXT: [[VBOFFS:%.*]] = load i32* [[VBOFFPCAST:%.*]], align 4 +// CHECK-NEXT: [[ADJ:%.*]] = getelementptr inbounds i8* [[VOIDP]], i32 [[VBOFFS]] +// CHECK-NEXT: [[CALL:%.*]] = tail call i8* @__RTDynamicCast(i8* [[ADJ]], i32 [[VBOFFS]], i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUA@@@8" to i8*), i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUT@@@8" to i8*), i32 0) +// CHECK-NEXT: [[RES:%.*]] = bitcast i8* [[CALL]] to %struct.T* +// CHECK-NEXT: br label +// CHECK: [[RET:%.*]] = phi %struct.T* +// CHECK-NEXT: ret %struct.T* [[RET]] T* test6(B* x) { return dynamic_cast<T*>(x); } -// CHECK: define %struct.T* @"\01?test6@@YAPAUT@@PAUB@@@Z"(%struct.B* %x) #1 { -// CHECK-NEXT: entry: -// CHECK-NEXT: %0 = icmp eq %struct.B* %x, null -// CHECK-NEXT: br i1 %0, label %dynamic_cast.call, label %dynamic_cast.valid -// CHECK: dynamic_cast.valid: ; preds = %entry -// CHECK-NEXT: %1 = getelementptr inbounds %struct.B* %x, i32 0, i32 0, i32 0 -// CHECK-NEXT: %vbptr = getelementptr inbounds i8* %1, i32 4 -// CHECK-NEXT: %2 = bitcast i8* %vbptr to i8** -// CHECK-NEXT: %vbtable = load i8** %2, align 4 -// CHECK-NEXT: %3 = getelementptr inbounds i8* %vbtable, i32 4 -// CHECK-NEXT: %4 = bitcast i8* %3 to i32* -// CHECK-NEXT: %vbase_offs = load i32* %4, align 4 -// CHECK-NEXT: %5 = add nsw i32 %vbase_offs, 4 -// CHECK-NEXT: %6 = getelementptr inbounds i8* %1, i32 %5 -// CHECK-NEXT: %7 = tail call i8* @__RTDynamicCast(i8* %6, i32 %5, i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUB@@@8" to i8*), i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUT@@@8" to i8*), i32 0) #2 -// CHECK-NEXT: %phitmp = bitcast i8* %7 to %struct.T* -// CHECK-NEXT: br label %dynamic_cast.call -// CHECK: dynamic_cast.call: ; preds = %dynamic_cast.valid, %entry -// CHECK-NEXT: %8 = phi %struct.T* [ %phitmp, %dynamic_cast.valid ], [ null, %entry ] -// CHECK-NEXT: ret %struct.T* %8 -// CHECK-NEXT: } +// CHECK-LABEL: define %struct.T* @"\01?test6@@YAPAUT@@PAUB@@@Z"(%struct.B* %x) +// CHECK: [[CHECK:%.*]] = icmp eq %struct.B* %x, null +// CHECK-NEXT: br i1 [[CHECK]] +// CHECK: [[CAST:%.*]] = getelementptr inbounds %struct.B* %x, i32 0, i32 0, i32 0 +// CHECK-NEXT: [[VBPTR:%.*]] = getelementptr inbounds i8* [[CAST]], i32 4 +// CHECK-NEXT: [[BITCAST:%.*]] = bitcast i8* [[VBPTR]] to i8** +// CHECK-NEXT: [[VBTBL:%.*]] = load i8** [[BITCAST]], align 4 +// CHECK-NEXT: [[VBOFFP:%.*]] = getelementptr inbounds i8* [[VBTBL]], i32 4 +// CHECK-NEXT: [[VBOFFPCAST:%.*]] = bitcast i8* [[VBOFFP]] to i32* +// CHECK-NEXT: [[VBOFFS:%.*]] = load i32* [[VBOFFPCAST:%.*]], align 4 +// CHECK-NEXT: [[DELTA:%.*]] = add nsw i32 [[VBOFFS]], 4 +// CHECK-NEXT: [[ADJ:%.*]] = getelementptr inbounds i8* [[CAST]], i32 [[DELTA]] +// CHECK-NEXT: [[CALL:%.*]] = tail call i8* @__RTDynamicCast(i8* [[ADJ]], i32 [[DELTA]], i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUB@@@8" to i8*), i8* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUT@@@8" to i8*), i32 0) +// CHECK-NEXT: [[RES:%.*]] = bitcast i8* [[CALL]] to %struct.T* +// CHECK-NEXT: br label +// CHECK: [[RET:%.*]] = phi %struct.T* +// CHECK-NEXT: ret %struct.T* [[RET]] void* test7(V* x) { return dynamic_cast<void*>(x); } -// CHECK: define i8* @"\01?test7@@YAPAXPAUV@@@Z"(%struct.V* %x) #1 { -// CHECK-NEXT: entry: -// CHECK-NEXT: %0 = bitcast %struct.V* %x to i8* -// CHECK-NEXT: %1 = tail call i8* @__RTCastToVoid(i8* %0) #2 -// CHECK-NEXT: ret i8* %1 -// CHECK-NEXT: } +// CHECK-LABEL: define i8* @"\01?test7@@YAPAXPAUV@@@Z"(%struct.V* %x) +// CHECK: [[CAST:%.*]] = bitcast %struct.V* %x to i8* +// CHECK-NEXT: [[RET:%.*]] = tail call i8* @__RTCastToVoid(i8* [[CAST]]) +// CHECK-NEXT: ret i8* [[RET]] void* test8(A* x) { return dynamic_cast<void*>(x); } -// CHECK: define i8* @"\01?test8@@YAPAXPAUA@@@Z"(%struct.A* %x) #1 { -// CHECK-NEXT: entry: -// CHECK-NEXT: %0 = icmp eq %struct.A* %x, null -// CHECK-NEXT: br i1 %0, label %dynamic_cast.call, label %dynamic_cast.valid -// CHECK: dynamic_cast.valid: ; preds = %entry -// CHECK-NEXT: %1 = bitcast %struct.A* %x to i8* -// CHECK-NEXT: %2 = bitcast %struct.A* %x to i8** -// CHECK-NEXT: %vbtable = load i8** %2, align 4 -// CHECK-NEXT: %3 = getelementptr inbounds i8* %vbtable, i32 4 -// CHECK-NEXT: %4 = bitcast i8* %3 to i32* -// CHECK-NEXT: %vbase_offs = load i32* %4, align 4 -// CHECK-NEXT: %5 = getelementptr inbounds i8* %1, i32 %vbase_offs -// CHECK-NEXT: %6 = tail call i8* @__RTCastToVoid(i8* %5) #2 -// CHECK-NEXT: br label %dynamic_cast.call -// CHECK: dynamic_cast.call: ; preds = %dynamic_cast.valid, %entry -// CHECK-NEXT: %7 = phi i8* [ %6, %dynamic_cast.valid ], [ null, %entry ] -// CHECK-NEXT: ret i8* %7 -// CHECK-NEXT: } +// CHECK-LABEL: define i8* @"\01?test8@@YAPAXPAUA@@@Z"(%struct.A* %x) +// CHECK: [[CHECK:%.*]] = icmp eq %struct.A* %x, null +// CHECK-NEXT: br i1 [[CHECK]] +// CHECK: [[VOIDP:%.*]] = bitcast %struct.A* %x to i8* +// CHECK-NEXT: [[BITCAST:%.*]] = bitcast %struct.A* %x to i8** +// CHECK-NEXT: [[VBTBL:%.*]] = load i8** [[BITCAST]], align 4 +// CHECK-NEXT: [[VBOFFP:%.*]] = getelementptr inbounds i8* [[VBTBL]], i32 4 +// CHECK-NEXT: [[VBOFFPCAST:%.*]] = bitcast i8* [[VBOFFP]] to i32* +// CHECK-NEXT: [[VBOFFS:%.*]] = load i32* [[VBOFFPCAST:%.*]], align 4 +// CHECK-NEXT: [[ADJ:%.*]] = getelementptr inbounds i8* [[VOIDP]], i32 [[VBOFFS]] +// CHECK-NEXT: [[RES:%.*]] = tail call i8* @__RTCastToVoid(i8* [[ADJ]]) +// CHECK-NEXT: br label +// CHECK: [[RET:%.*]] = phi i8* +// CHECK-NEXT: ret i8* [[RET]] void* test9(B* x) { return dynamic_cast<void*>(x); } -// CHECK: define i8* @"\01?test9@@YAPAXPAUB@@@Z"(%struct.B* %x) #1 { -// CHECK-NEXT: entry: -// CHECK-NEXT: %0 = icmp eq %struct.B* %x, null -// CHECK-NEXT: br i1 %0, label %dynamic_cast.call, label %dynamic_cast.valid -// CHECK: dynamic_cast.valid: ; preds = %entry -// CHECK-NEXT: %1 = getelementptr inbounds %struct.B* %x, i32 0, i32 0, i32 0 -// CHECK-NEXT: %vbptr = getelementptr inbounds i8* %1, i32 4 -// CHECK-NEXT: %2 = bitcast i8* %vbptr to i8** -// CHECK-NEXT: %vbtable = load i8** %2, align 4 -// CHECK-NEXT: %3 = getelementptr inbounds i8* %vbtable, i32 4 -// CHECK-NEXT: %4 = bitcast i8* %3 to i32* -// CHECK-NEXT: %vbase_offs = load i32* %4, align 4 -// CHECK-NEXT: %5 = add nsw i32 %vbase_offs, 4 -// CHECK-NEXT: %6 = getelementptr inbounds i8* %1, i32 %5 -// CHECK-NEXT: %7 = tail call i8* @__RTCastToVoid(i8* %6) #2 -// CHECK-NEXT: br label %dynamic_cast.call -// CHECK: dynamic_cast.call: ; preds = %dynamic_cast.valid, %entry -// CHECK-NEXT: %8 = phi i8* [ %7, %dynamic_cast.valid ], [ null, %entry ] -// CHECK-NEXT: ret i8* %8 -// CHECK-NEXT: } +// CHECK-LABEL: define i8* @"\01?test9@@YAPAXPAUB@@@Z"(%struct.B* %x) +// CHECK: [[CHECK:%.*]] = icmp eq %struct.B* %x, null +// CHECK-NEXT: br i1 [[CHECK]] +// CHECK: [[CAST:%.*]] = getelementptr inbounds %struct.B* %x, i32 0, i32 0, i32 0 +// CHECK-NEXT: [[VBPTR:%.*]] = getelementptr inbounds i8* [[CAST]], i32 4 +// CHECK-NEXT: [[BITCAST:%.*]] = bitcast i8* [[VBPTR]] to i8** +// CHECK-NEXT: [[VBTBL:%.*]] = load i8** [[BITCAST]], align 4 +// CHECK-NEXT: [[VBOFFP:%.*]] = getelementptr inbounds i8* [[VBTBL]], i32 4 +// CHECK-NEXT: [[VBOFFPCAST:%.*]] = bitcast i8* [[VBOFFP]] to i32* +// CHECK-NEXT: [[VBOFFS:%.*]] = load i32* [[VBOFFPCAST:%.*]], align 4 +// CHECK-NEXT: [[DELTA:%.*]] = add nsw i32 [[VBOFFS]], 4 +// CHECK-NEXT: [[ADJ:%.*]] = getelementptr inbounds i8* [[CAST]], i32 [[DELTA]] +// CHECK-NEXT: [[CALL:%.*]] = tail call i8* @__RTCastToVoid(i8* [[ADJ]]) +// CHECK-NEXT: br label +// CHECK: [[RET:%.*]] = phi i8* +// CHECK-NEXT: ret i8* [[RET]] + diff --git a/test/CodeGenCXX/microsoft-abi-typeid.cpp b/test/CodeGenCXX/microsoft-abi-typeid.cpp index ffbebec1fa..3875c56ca4 100644 --- a/test/CodeGenCXX/microsoft-abi-typeid.cpp +++ b/test/CodeGenCXX/microsoft-abi-typeid.cpp @@ -1,58 +1,45 @@ -// RUN: %clang_cc1 -emit-llvm -O2 -optzns -o - -triple=i386-pc-win32 2>/dev/null %s | FileCheck %s -// REQUIRES: asserts +// RUN: %clang_cc1 -emit-llvm -O1 -o - -triple=i386-pc-win32 %s | FileCheck %s -struct type_info { const char* raw_name() const; }; +struct type_info; namespace std { using ::type_info; } -struct V { virtual void f() {}; }; -struct A : virtual V {}; +struct V { virtual void f(); }; +struct A : virtual V { A(); }; -A a; -int b; +extern A a; +extern int b; A* fn(); const std::type_info* test0_typeid() { return &typeid(int); } -// CHECK: define %struct.type_info* @"\01?test0_typeid@@YAPBUtype_info@@XZ"() #0 { -// CHECK-NEXT: entry: -// CHECK-NEXT: ret %struct.type_info* bitcast (%"MSRTTITypeDescriptor\02"* @"\01??_R0H@8" to %struct.type_info*) -// CHECK-NEXT: } +// CHECK-LABEL: define %struct.type_info* @"\01?test0_typeid@@YAPBUtype_info@@XZ"() +// CHECK: ret %struct.type_info* bitcast (%"MSRTTITypeDescriptor\02"* @"\01??_R0H@8" to %struct.type_info*) const std::type_info* test1_typeid() { return &typeid(A); } -// CHECK: define %struct.type_info* @"\01?test1_typeid@@YAPBUtype_info@@XZ"() #0 { -// CHECK-NEXT: entry: -// CHECK-NEXT: ret %struct.type_info* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUA@@@8" to %struct.type_info*) -// CHECK-NEXT: } +// CHECK-LABEL: define %struct.type_info* @"\01?test1_typeid@@YAPBUtype_info@@XZ"() +// CHECK: ret %struct.type_info* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0?AUA@@@8" to %struct.type_info*) const std::type_info* test2_typeid() { return &typeid(&a); } -// CHECK: define %struct.type_info* @"\01?test2_typeid@@YAPBUtype_info@@XZ"() #0 { -// CHECK-NEXT: entry: -// CHECK-NEXT: ret %struct.type_info* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0PAUA@@@8" to %struct.type_info*) -// CHECK-NEXT: } +// CHECK-LABEL: define %struct.type_info* @"\01?test2_typeid@@YAPBUtype_info@@XZ"() +// CHECK: ret %struct.type_info* bitcast (%"MSRTTITypeDescriptor\07"* @"\01??_R0PAUA@@@8" to %struct.type_info*) const std::type_info* test3_typeid() { return &typeid(*fn()); } -// CHECK: define %struct.type_info* @"\01?test3_typeid@@YAPBUtype_info@@XZ"() #1 { -// CHECK-NEXT: entry: -// CHECK-NEXT: %call = tail call %struct.A* @"\01?fn@@YAPAUA@@XZ"() #3 -// CHECK-NEXT: %0 = icmp eq %struct.A* %call, null -// CHECK-NEXT: br i1 %0, label %type_id.call, label %type_id.valid -// CHECK: type_id.valid: ; preds = %entry -// CHECK-NEXT: %1 = bitcast %struct.A* %call to i8* -// CHECK-NEXT: %2 = bitcast %struct.A* %call to i8** -// CHECK-NEXT: %vbtable = load i8** %2, align 4 -// CHECK-NEXT: %3 = getelementptr inbounds i8* %vbtable, i32 4 -// CHECK-NEXT: %4 = bitcast i8* %3 to i32* -// CHECK-NEXT: %vbase_offs = load i32* %4, align 4 -// CHECK-NEXT: %5 = getelementptr inbounds i8* %1, i32 %vbase_offs -// CHECK-NEXT: br label %type_id.call -// CHECK: type_id.call: ; preds = %type_id.valid, %entry -// CHECK-NEXT: %6 = phi i8* [ %5, %type_id.valid ], [ null, %entry ] -// CHECK-NEXT: %7 = tail call i8* @__RTtypeid(i8* %6) #3 -// CHECK-NEXT: %8 = bitcast i8* %7 to %struct.type_info* -// CHECK-NEXT: ret %struct.type_info* %8 -// CHECK-NEXT: } +// CHECK-LABEL: define %struct.type_info* @"\01?test3_typeid@@YAPBUtype_info@@XZ"() +// CHECK: [[CALL:%.*]] = tail call %struct.A* @"\01?fn@@YAPAUA@@XZ"() +// CHECK-NEXT: [[CMP:%.*]] = icmp eq %struct.A* [[CALL]], null +// CHECK-NEXT: br i1 [[CMP]] +// CHECK: tail call i8* @__RTtypeid(i8* null) +// CHECK-NEXT: unreachable +// CHECK: [[THIS:%.*]] = bitcast %struct.A* [[CALL]] to i8* +// CHECK-NEXT: [[VBTBLP:%.*]] = bitcast %struct.A* [[CALL]] to i8** +// CHECK-NEXT: [[VBTBL:%.*]] = load i8** [[VBTBLP]], align 4 +// CHECK-NEXT: [[VBSLOT:%.*]] = getelementptr inbounds i8* [[VBTBL]], i32 4 +// CHECK-NEXT: [[VBITCST:%.*]] = bitcast i8* [[VBSLOT]] to i32* +// CHECK-NEXT: [[VBASE_OFFS:%.*]] = load i32* [[VBITCST]], align 4 +// CHECK-NEXT: [[ADJ:%.*]] = getelementptr inbounds i8* [[THIS]], i32 [[VBASE_OFFS]] +// CHECK-NEXT: [[RT:%.*]] = tail call i8* @__RTtypeid(i8* [[ADJ]]) +// CHECK-NEXT: [[RET:%.*]] = bitcast i8* [[RT]] to %struct.type_info* +// CHECK-NEXT: ret %struct.type_info* [[RET]] const std::type_info* test4_typeid() { return &typeid(b); } -// CHECK: define %struct.type_info* @"\01?test4_typeid@@YAPBUtype_info@@XZ"() #0 { -// CHECK-NEXT: entry: -// CHECK-NEXT: ret %struct.type_info* bitcast (%"MSRTTITypeDescriptor\02"* @"\01??_R0H@8" to %struct.type_info*) -// CHECK-NEXT: } +// CHECK: define %struct.type_info* @"\01?test4_typeid@@YAPBUtype_info@@XZ"() +// CHECK: ret %struct.type_info* bitcast (%"MSRTTITypeDescriptor\02"* @"\01??_R0H@8" to %struct.type_info*) |