Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp =================================================================== --- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp +++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp @@ -35,6 +35,8 @@ OMPRTL_NVPTX__kmpc_spmd_kernel_init, /// Call to void __kmpc_spmd_kernel_deinit(); OMPRTL_NVPTX__kmpc_spmd_kernel_deinit, + /// Call to void __kmpc_spmd_kernel_deinit_v2(int16_t RequiresOMPRuntime); + OMPRTL_NVPTX__kmpc_spmd_kernel_deinit_v2, /// Call to void __kmpc_kernel_prepare_parallel(void /// *outlined_function, int16_t /// IsOMPRuntimeInitialized); @@ -1423,8 +1425,11 @@ CGF.EmitBlock(OMPDeInitBB); // DeInitialize the OMP state in the runtime; called by all active threads. + llvm::Value *Args[] = {/*RequiresOMPRuntime=*/ + CGF.Builder.getInt16(RequiresFullRuntime ? 1 : 0)}; CGF.EmitRuntimeCall( - createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_spmd_kernel_deinit), None); + createNVPTXRuntimeFunction( + OMPRTL_NVPTX__kmpc_spmd_kernel_deinit_v2), Args); CGF.EmitBranch(EST.ExitBB); CGF.EmitBlock(EST.ExitBB); @@ -1614,6 +1619,14 @@ RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_spmd_kernel_deinit"); break; } + case OMPRTL_NVPTX__kmpc_spmd_kernel_deinit_v2: { + // Build void __kmpc_spmd_kernel_deinit_v2(int16_t RequiresOMPRuntime); + llvm::Type *TypeParams[] = {CGM.Int16Ty}; + auto *FnTy = + llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false); + RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_spmd_kernel_deinit_v2"); + break; + } case OMPRTL_NVPTX__kmpc_kernel_prepare_parallel: { /// Build void __kmpc_kernel_prepare_parallel( /// void *outlined_function, int16_t IsOMPRuntimeInitialized); Index: test/OpenMP/nvptx_target_parallel_codegen.cpp =================================================================== --- test/OpenMP/nvptx_target_parallel_codegen.cpp +++ test/OpenMP/nvptx_target_parallel_codegen.cpp @@ -68,7 +68,7 @@ // CHECK: br label {{%?}}[[DONE:.+]] // // CHECK: [[DONE]] - // CHECK: call void @__kmpc_spmd_kernel_deinit() + // CHECK: call void @__kmpc_spmd_kernel_deinit_v2( // CHECK: br label {{%?}}[[EXIT:.+]] // // CHECK: [[EXIT]] @@ -111,7 +111,7 @@ // CHECK: br label {{%?}}[[DONE:.+]] // // CHECK: [[DONE]] - // CHECK: call void @__kmpc_spmd_kernel_deinit() + // CHECK: call void @__kmpc_spmd_kernel_deinit_v2( // CHECK: br label {{%?}}[[EXIT:.+]] // // CHECK: [[EXIT]] Index: test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp =================================================================== --- test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp +++ test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp @@ -57,7 +57,7 @@ // CHECK: br label {{%?}}[[DONE:.+]] // // CHECK: [[DONE]] - // CHECK: call void @__kmpc_spmd_kernel_deinit() + // CHECK: call void @__kmpc_spmd_kernel_deinit_v2( // CHECK: br label {{%?}}[[EXIT:.+]] // // CHECK: [[EXIT]] @@ -79,7 +79,7 @@ // CHECK: br label {{%?}}[[DONE:.+]] // // CHECK: [[DONE]] - // CHECK: call void @__kmpc_spmd_kernel_deinit() + // CHECK: call void @__kmpc_spmd_kernel_deinit_v2( // CHECK: br label {{%?}}[[EXIT:.+]] // // CHECK: [[EXIT]] @@ -100,7 +100,7 @@ // CHECK: br label {{%?}}[[DONE:.+]] // // CHECK: [[DONE]] - // CHECK: call void @__kmpc_spmd_kernel_deinit() + // CHECK: call void @__kmpc_spmd_kernel_deinit_v2( // CHECK: br label {{%?}}[[EXIT:.+]] // // CHECK: [[EXIT]] Index: test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp =================================================================== --- test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp +++ test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp @@ -60,7 +60,7 @@ // // CHECK: [[EXECUTE]] // CHECK: {{call|invoke}} void [[PFN:@.+]](i32* - // CHECK: call void @__kmpc_spmd_kernel_deinit() + // CHECK: call void @__kmpc_spmd_kernel_deinit_v2( // // // define internal void [[PFN]]( @@ -254,7 +254,7 @@ // // CHECK: [[EXECUTE]] // CHECK: {{call|invoke}} void [[PFN1:@.+]](i32* - // CHECK: call void @__kmpc_spmd_kernel_deinit() + // CHECK: call void @__kmpc_spmd_kernel_deinit_v2( // // // define internal void [[PFN1]]( @@ -527,7 +527,7 @@ // // CHECK: [[EXECUTE]] // CHECK: {{call|invoke}} void [[PFN2:@.+]](i32* - // CHECK: call void @__kmpc_spmd_kernel_deinit() + // CHECK: call void @__kmpc_spmd_kernel_deinit_v2( // // // define internal void [[PFN2]]( Index: test/OpenMP/nvptx_target_teams_codegen.cpp =================================================================== --- test/OpenMP/nvptx_target_teams_codegen.cpp +++ test/OpenMP/nvptx_target_teams_codegen.cpp @@ -234,7 +234,7 @@ // CHECK: call void [[L0:@.+]](i32* %{{.+}}, i32* %{{.+}}, i16* %{{.*}}) // CHECK-NOT: call void @__kmpc_end_serialized_parallel( // CHECK-NOT: call void @__kmpc_data_sharing_pop_stack( -// CHECK: call void @__kmpc_spmd_kernel_deinit() +// CHECK: call void @__kmpc_spmd_kernel_deinit_v2( // CHECK: ret // CHECK: define internal void [[L0]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i16* dereferenceable Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp =================================================================== --- test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp +++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp @@ -84,7 +84,7 @@ // CHECK: {{call|invoke}} void [[OUTL1:@.+]]( // CHECK: call void @__kmpc_for_static_fini( // CHECK: call void @__kmpc_restore_team_static_memory(i16 1) -// CHECK: call void @__kmpc_spmd_kernel_deinit() +// CHECK: call void @__kmpc_spmd_kernel_deinit_v2( // CHECK: ret void // CHECK: define internal void [[OUTL1]]( @@ -98,7 +98,7 @@ // CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91, // CHECK: {{call|invoke}} void [[OUTL2:@.+]]( // CHECK: call void @__kmpc_for_static_fini( -// CHECK: call void @__kmpc_spmd_kernel_deinit() +// CHECK: call void @__kmpc_spmd_kernel_deinit_v2( // CHECK: ret void // CHECK: define internal void [[OUTL2]]( @@ -112,7 +112,7 @@ // CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91, // CHECK: {{call|invoke}} void [[OUTL3:@.+]]( // CHECK: call void @__kmpc_for_static_fini( -// CHECK: call void @__kmpc_spmd_kernel_deinit() +// CHECK: call void @__kmpc_spmd_kernel_deinit_v2( // CHECK: ret void // CHECK: define internal void [[OUTL3]]( @@ -204,7 +204,7 @@ // CHECK: [[DIST_INNER_LOOP_END]]: // CHECK: call void @__kmpc_for_static_fini( -// CHECK: call void @__kmpc_spmd_kernel_deinit() +// CHECK: call void @__kmpc_spmd_kernel_deinit_v2( // CHECK: ret void // CHECK: define internal void [[OUTL4]]( Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp =================================================================== --- test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp +++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp @@ -32,7 +32,7 @@ // CHECK: call void @__kmpc_for_static_fini(%struct.ident_t* @ -// CHECK: call void @__kmpc_spmd_kernel_deinit() +// CHECK: call void @__kmpc_spmd_kernel_deinit_v2( // CHECK: define internal void [[PARALLEL]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i{{64|32}} %{{.+}}, i{{64|32}} %{{.+}}, i{{64|32}} [[ARGC:%.+]], i32* dereferenceable{{.*}}) // CHECK-NOT: call i8* @__kmpc_data_sharing_push_stack( Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp =================================================================== --- test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp +++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp @@ -79,7 +79,7 @@ // CHECK: {{call|invoke}} void [[OUTL1:@.+]]( // CHECK: call void @__kmpc_for_static_fini( // CHECK: call void @__kmpc_restore_team_static_memory(i16 1) -// CHECK: call void @__kmpc_spmd_kernel_deinit() +// CHECK: call void @__kmpc_spmd_kernel_deinit_v2( // CHECK: ret void // CHECK: define internal void [[OUTL1]]( @@ -93,7 +93,7 @@ // CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91, // CHECK: {{call|invoke}} void [[OUTL2:@.+]]( // CHECK: call void @__kmpc_for_static_fini( -// CHECK: call void @__kmpc_spmd_kernel_deinit() +// CHECK: call void @__kmpc_spmd_kernel_deinit_v2( // CHECK: ret void // CHECK: define internal void [[OUTL2]]( @@ -107,7 +107,7 @@ // CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91, // CHECK: {{call|invoke}} void [[OUTL3:@.+]]( // CHECK: call void @__kmpc_for_static_fini( -// CHECK: call void @__kmpc_spmd_kernel_deinit() +// CHECK: call void @__kmpc_spmd_kernel_deinit_v2( // CHECK: ret void // CHECK: define internal void [[OUTL3]]( @@ -123,7 +123,7 @@ // CHECK: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, {{.+}} 91, {{.+}}, {{.+}}, {{.+}}* [[COMB_UB]], // CHECK: {{call|invoke}} void [[OUTL4:@.+]]( // CHECK: call void @__kmpc_for_static_fini( -// CHECK: call void @__kmpc_spmd_kernel_deinit() +// CHECK: call void @__kmpc_spmd_kernel_deinit_v2( // CHECK: ret void // CHECK: define internal void [[OUTL4]]( Index: test/OpenMP/nvptx_teams_reduction_codegen.cpp =================================================================== --- test/OpenMP/nvptx_teams_reduction_codegen.cpp +++ test/OpenMP/nvptx_teams_reduction_codegen.cpp @@ -757,7 +757,7 @@ // // CHECK: [[EXIT]] // call void @__kmpc_restore_team_static_memory(i16 1) - // CHECK: call void @__kmpc_spmd_kernel_deinit( + // CHECK: call void @__kmpc_spmd_kernel_deinit_v2( // CHECK: define internal void [[OUTLINED]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i32* dereferenceable{{.+}}, i16* dereferenceable{{.+}}) //