summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/microsoft-abi-typeid.cpp
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2014-06-22 12:42:29 +0000
committerNAKAMURA Takumi <geek4civic@gmail.com>2014-06-22 12:42:29 +0000
commit7760db9216936c5f4cb327a8826dcfc4900ff65e (patch)
tree68b7e947f799bc1483dbe2a5054b57c6eb766922 /test/CodeGenCXX/microsoft-abi-typeid.cpp
parente9a4914d90298da2d771e96a47fa6cfad932870a (diff)
Revert r211402 (and r211408,r211410), "CodeGen: Refactor dynamic_cast and typeid" It crashes msvc codegen in clang/test/SemaCXX/undefined-internal.cpp.
It is reproducible with: $ clang -cc1 -triple i686-win32 -emit-llvm-only clang/test/SemaCXX/undefined-internal.cpp git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211467 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/microsoft-abi-typeid.cpp')
-rw-r--r--test/CodeGenCXX/microsoft-abi-typeid.cpp73
1 files changed, 43 insertions, 30 deletions
diff --git a/test/CodeGenCXX/microsoft-abi-typeid.cpp b/test/CodeGenCXX/microsoft-abi-typeid.cpp
index 3875c56ca4..ffbebec1fa 100644
--- a/test/CodeGenCXX/microsoft-abi-typeid.cpp
+++ b/test/CodeGenCXX/microsoft-abi-typeid.cpp
@@ -1,45 +1,58 @@
-// RUN: %clang_cc1 -emit-llvm -O1 -o - -triple=i386-pc-win32 %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -O2 -optzns -o - -triple=i386-pc-win32 2>/dev/null %s | FileCheck %s
+// REQUIRES: asserts
-struct type_info;
+struct type_info { const char* raw_name() const; };
namespace std { using ::type_info; }
-struct V { virtual void f(); };
-struct A : virtual V { A(); };
+struct V { virtual void f() {}; };
+struct A : virtual V {};
-extern A a;
-extern int b;
+A a;
+int b;
A* fn();
const std::type_info* test0_typeid() { return &typeid(int); }
-// 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*)
+// 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: }
const std::type_info* test1_typeid() { return &typeid(A); }
-// 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*)
+// 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: }
const std::type_info* test2_typeid() { return &typeid(&a); }
-// 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*)
+// 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: }
const std::type_info* test3_typeid() { return &typeid(*fn()); }
-// 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]]
+// 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: }
const std::type_info* test4_typeid() { return &typeid(b); }
-// 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*)
+// 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: }