Index: clang/lib/Sema/Sema.cpp =================================================================== --- clang/lib/Sema/Sema.cpp +++ clang/lib/Sema/Sema.cpp @@ -981,6 +981,14 @@ LateParsedInstantiations.begin(), LateParsedInstantiations.end()); LateParsedInstantiations.clear(); + + // FIXME: Instantiating implicit templates already in the PCH breaks some + // OpenMP-specific code paths, see https://reviews.llvm.org/D69585 . + if (!LangOpts.OpenMP) { + llvm::TimeTraceScope TimeScope("PerformPendingInstantiations", + StringRef("")); + PerformPendingInstantiations(); + } } DiagnoseUnterminatedPragmaPack(); Index: clang/test/CodeGenCXX/vla-lambda-capturing.cpp =================================================================== --- clang/test/CodeGenCXX/vla-lambda-capturing.cpp +++ clang/test/CodeGenCXX/vla-lambda-capturing.cpp @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECK-NOPCH %s // RUN: %clang_cc1 %s -std=c++11 -emit-pch -o %t -// RUN: %clang_cc1 %s -std=c++11 -include-pch %t -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -std=c++11 -include-pch %t -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECK-PCH %s #ifndef HEADER #define HEADER @@ -111,14 +111,14 @@ // CHECK: call void @llvm.stackrestore( // CHECK: ret void -// CHECK: define linkonce_odr{{.*}} void [[F_INT_LAMBDA]]([[CAP_TYPE2]]* -// CHECK: [[THIS:%.+]] = load [[CAP_TYPE2]]*, [[CAP_TYPE2]]** -// CHECK: [[SIZE_REF:%.+]] = getelementptr inbounds [[CAP_TYPE2]], [[CAP_TYPE2]]* [[THIS]], i{{.+}} 0, i{{.+}} 0 -// CHECK: [[SIZE:%.+]] = load [[INTPTR_T]], [[INTPTR_T]]* [[SIZE_REF]] -// CHECK: call i{{.+}}* @llvm.stacksave() -// CHECK: alloca [[INTPTR_T]], [[INTPTR_T]] [[SIZE]] -// CHECK: call void @llvm.stackrestore( -// CHECK: ret void +// CHECK-NOPCH: define linkonce_odr{{.*}} void [[F_INT_LAMBDA]]([[CAP_TYPE2]]* +// CHECK-NOPCH: [[THIS:%.+]] = load [[CAP_TYPE2]]*, [[CAP_TYPE2]]** +// CHECK-NOPCH: [[SIZE_REF:%.+]] = getelementptr inbounds [[CAP_TYPE2]], [[CAP_TYPE2]]* [[THIS]], i{{.+}} 0, i{{.+}} 0 +// CHECK-NOPCH: [[SIZE:%.+]] = load [[INTPTR_T]], [[INTPTR_T]]* [[SIZE_REF]] +// CHECK-NOPCH: call i{{.+}}* @llvm.stacksave() +// CHECK-NOPCH: alloca [[INTPTR_T]], [[INTPTR_T]] [[SIZE]] +// CHECK-NOPCH: call void @llvm.stackrestore( +// CHECK-NOPCH: ret void // CHECK: define linkonce_odr{{.*}} void [[B_INT_LAMBDA]]([[CAP_TYPE3]]* // CHECK: [[SIZE2_REF:%.+]] = getelementptr inbounds [[CAP_TYPE3]], [[CAP_TYPE3]]* [[THIS:%.+]], i{{[0-9]+}} 0, i{{[0-9]+}} 1 @@ -168,4 +168,14 @@ // CHECK: [[MUL:%.+]] = mul {{.*}} i{{[0-9]+}} [[SIZE2]], [[SIZE1]] // CHECK: mul {{.*}} i{{[0-9]+}} {{[0-9]+}}, [[MUL]] // CHECK: ret void + +// CHECK-PCH: define linkonce_odr{{.*}} void [[F_INT_LAMBDA]]([[CAP_TYPE2]]* +// CHECK-PCH: [[THIS:%.+]] = load [[CAP_TYPE2]]*, [[CAP_TYPE2]]** +// CHECK-PCH: [[SIZE_REF:%.+]] = getelementptr inbounds [[CAP_TYPE2]], [[CAP_TYPE2]]* [[THIS]], i{{.+}} 0, i{{.+}} 0 +// CHECK-PCH: [[SIZE:%.+]] = load [[INTPTR_T]], [[INTPTR_T]]* [[SIZE_REF]] +// CHECK-PCH: call i{{.+}}* @llvm.stacksave() +// CHECK-PCH: alloca [[INTPTR_T]], [[INTPTR_T]] [[SIZE]] +// CHECK-PCH: call void @llvm.stackrestore( +// CHECK-PCH: ret void + #endif