[PATCH] D30430: Make Lit tests C++11 compatible - IR ordering

Charles Li via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 27 14:16:06 PST 2017


tigerleapgorge created this revision.

This test failure is caused by difference in IR ordering when compiling at C++98 vs C++11
Because there was a CHECK-NOT between the two CHECKs, just changing the CHECKs to CHECK-DAG would not work.

So to make FileCheck more flexible.
I have changed the CHECK to CHECK-DAG.
I have changed CHECK-NOT to go under a new check-prefix CHECK2 so they are CHECK2-NOT.

IR in C++98
@_ZN5test022implicit_instantiationE = global %"struct.test0::stdio_sync_filebuf.2" zeroinitializer, align 8
@__dso_handle = external hidden global i8
@_ZN7PR100011xE = global i32 0, align 4
@_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr constant { [5 x i8*] } { [5 x i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* @_ZTIN5test018stdio_sync_filebufIA3_iEE to i8*), i8* bitcast (void (%"struct.test0::stdio_sync_filebuf.1"*)* @_ZN5test018stdio_sync_filebufIA3_iED1Ev to i8*), i8* bitcast (void (%"struct.test0::stdio_sync_filebuf.1"*)* @_ZN5test018stdio_sync_filebufIA3_iED0Ev to i8*), i8* bitcast (void (%"struct.test0::stdio_sync_filebuf.1"*)* @_ZN5test018stdio_sync_filebufIA3_iE6xsgetnEv to i8*)] }, align 8
@_ZTVN10__cxxabiv120__si_class_type_infoE = external global i8*
@_ZTSN5test018stdio_sync_filebufIA3_iEE = weak_odr constant [35 x i8] c"N5test018stdio_sync_filebufIA3_iEE\00"
@_ZTIN5test015basic_streambufE = external constant i8*
@_ZTIN5test018stdio_sync_filebufIA3_iEE = weak_odr constant { i8*, i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @_ZTSN5test018stdio_sync_filebufIA3_iEE, i32 0, i32 0), i8* bitcast (i8** @_ZTIN5test015basic_streambufE to i8*) }
@_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32] zeroinitializer, align 4
@_ZGVN7PR100011SIiE3arrE = linkonce_odr global i64 0, align 8
@_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr unnamed_addr constant { [5 x i8*] } { [5 x i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* @_ZTIN5test018stdio_sync_filebufIA4_iEE to i8*), i8* bitcast (void (%"struct.test0::stdio_sync_filebuf.2"*)* @_ZN5test018stdio_sync_filebufIA4_iED1Ev to i8*), i8* bitcast (void (%"struct.test0::stdio_sync_filebuf.2"*)* @_ZN5test018stdio_sync_filebufIA4_iED0Ev to i8*), i8* bitcast (void (%"struct.test0::stdio_sync_filebuf.2"*)* @_ZN5test018stdio_sync_filebufIA4_iE6xsgetnEv to i8*)] }, align 8
@_ZTSN5test018stdio_sync_filebufIA4_iEE = linkonce_odr constant [35 x i8] c"N5test018stdio_sync_filebufIA4_iEE\00"
@_ZTIN5test018stdio_sync_filebufIA4_iEE = linkonce_odr constant { i8*, i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @_ZTSN5test018stdio_sync_filebufIA4_iEE, i32 0, i32 0), i8* bitcast (i8** @_ZTIN5test015basic_streambufE to i8*) }
@_ZTVN5test015basic_streambufE = available_externally unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* bitcast (i8** @_ZTIN5test015basic_streambufE to i8*), i8* bitcast (void (%"struct.test0::basic_streambuf"*)* @_ZN5test015basic_streambufD1Ev to i8*), i8* bitcast (void (%"struct.test0::basic_streambuf"*)* @_ZN5test015basic_streambufD0Ev to i8*)] }, align 8
@_ZTVN5test21CIiEE = available_externally unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* bitcast (i8** @_ZTIN5test21CIiEE to i8*), i8* bitcast (void (%"class.test2::C"*)* @_ZN5test21CIiED1Ev to i8*), i8* bitcast (void (%"class.test2::C"*)* @_ZN5test21CIiED0Ev to i8*)] }, align 8
@_ZTIN5test21CIiEE = external constant i8*
@llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__cxx_global_var_init.2, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_template_instantiation.cpp, i8* null }]

IR in C++11
@_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr unnamed_addr constant { [5 x i8*] } { [5 x i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* @_ZTIN5test018stdio_sync_filebufIA4_iEE to i8*), i8* bitcast (void (%"struct.test0::stdio_sync_filebuf.2"*)* @_ZN5test018stdio_sync_filebufIA4_iED1Ev to i8*), i8* bitcast (void (%"struct.test0::stdio_sync_filebuf.2"*)* @_ZN5test018stdio_sync_filebufIA4_iED0Ev to i8*), i8* bitcast (void (%"struct.test0::stdio_sync_filebuf.2"*)* @_ZN5test018stdio_sync_filebufIA4_iE6xsgetnEv to i8*)] }, align 8
@_ZN5test022implicit_instantiationE = global { i8** } { i8** getelementptr inbounds ({ [5 x i8*] }, { [5 x i8*] }* @_ZTVN5test018stdio_sync_filebufIA4_iEE, i32 0, inrange i32 0, i32 2) }, align 8
@__dso_handle = external hidden global i8
@_ZN7PR100011xE = global i32 0, align 4
@_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr constant { [5 x i8*] } { [5 x i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* @_ZTIN5test018stdio_sync_filebufIA3_iEE to i8*), i8* bitcast (void (%"struct.test0::stdio_sync_filebuf.1"*)* @_ZN5test018stdio_sync_filebufIA3_iED1Ev to i8*), i8* bitcast (void (%"struct.test0::stdio_sync_filebuf.1"*)* @_ZN5test018stdio_sync_filebufIA3_iED0Ev to i8*), i8* bitcast (void (%"struct.test0::stdio_sync_filebuf.1"*)* @_ZN5test018stdio_sync_filebufIA3_iE6xsgetnEv to i8*)] }, align 8
@_ZTVN10__cxxabiv120__si_class_type_infoE = external global i8*
@_ZTSN5test018stdio_sync_filebufIA3_iEE = weak_odr constant [35 x i8] c"N5test018stdio_sync_filebufIA3_iEE\00"
@_ZTIN5test015basic_streambufE = external constant i8*
@_ZTIN5test018stdio_sync_filebufIA3_iEE = weak_odr constant { i8*, i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @_ZTSN5test018stdio_sync_filebufIA3_iEE, i32 0, i32 0), i8* bitcast (i8** @_ZTIN5test015basic_streambufE to i8*) }
@_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32] zeroinitializer, align 4
@_ZGVN7PR100011SIiE3arrE = linkonce_odr global i64 0, align 8
@_ZTSN5test018stdio_sync_filebufIA4_iEE = linkonce_odr constant [35 x i8] c"N5test018stdio_sync_filebufIA4_iEE\00"
@_ZTIN5test018stdio_sync_filebufIA4_iEE = linkonce_odr constant { i8*, i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @_ZTSN5test018stdio_sync_filebufIA4_iEE, i32 0, i32 0), i8* bitcast (i8** @_ZTIN5test015basic_streambufE to i8*) }
@_ZTVN5test21CIiEE = available_externally unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* bitcast (i8** @_ZTIN5test21CIiEE to i8*), i8* bitcast (void (%"class.test2::C"*)* @_ZN5test21CIiED1Ev to i8*), i8* bitcast (void (%"class.test2::C"*)* @_ZN5test21CIiED0Ev to i8*)] }, align 8
@_ZTIN5test21CIiEE = external constant i8*
@llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__cxx_global_var_init.2, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_template_instantiation.cpp, i8* null }]


https://reviews.llvm.org/D30430

Files:
  test/CodeGenCXX/template-instantiation.cpp


Index: test/CodeGenCXX/template-instantiation.cpp
===================================================================
--- test/CodeGenCXX/template-instantiation.cpp
+++ test/CodeGenCXX/template-instantiation.cpp
@@ -1,21 +1,25 @@
 // RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 -std=c++98 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 -std=c++98 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -disable-llvm-passes -triple=x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
+
+// CHECK-DAG: @_ZN7PR100011xE = global
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr constant
+// CHECK-DAG: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
+// CHECK-DAG: @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr unnamed_addr constant
+
+// CHECK2-NOT: @_ZN7PR100014kBarE = external global i32
+// CHECK2-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
+// CHECK2-NOT: _ZTVN5test315basic_fstreamXXIcEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
+// CHECK2-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
+// CHECK2-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
 
-// CHECK: @_ZN7PR100011xE = global
-// CHECK-NOT: @_ZN7PR100014kBarE = external global i32
-//
-// CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
-// CHECK-NOT: _ZTVN5test315basic_fstreamXXIcEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA1_iEE
-// CHECK-NOT: @_ZTVN5test018stdio_sync_filebufIA2_iEE
-// CHECK:     @_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr constant
 
-// CHECK: @_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32]
-// CHECK-NOT: @_ZN7PR100011SIiE3arr2E = linkonce_odr global [3 x i32]A
-
-// CHECK:     @_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr unnamed_addr constant
-
-// CHECK-NOT: _ZTVN5test31SIiEE
-// CHECK-NOT: _ZTSN5test31SIiEE
+// CHECK2-NOT: _ZTVN5test31SIiEE
+// CHECK2-NOT: _ZTSN5test31SIiEE
 
 // CHECK-LABEL: define linkonce_odr void @_ZN5test21CIiEC1Ev(%"class.test2::C"* %this) unnamed_addr
 // CHECK-LABEL: define linkonce_odr void @_ZN5test21CIiE6foobarIdEEvT_(
@@ -152,7 +156,7 @@
   void f () {}
 };
 // Should not instantiate class B since it is introduced in namespace scope.
-// CHECK-NOT: _ZN6PR85051AILi0EE1B1fEv
+// CHECK2-NOT: _ZN6PR85051AILi0EE1B1fEv
 template class A<0>;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30430.89921.patch
Type: text/x-patch
Size: 2822 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170227/4d877045/attachment-0001.bin>


More information about the cfe-commits mailing list