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 }]