]> granicus.if.org Git - clang/commitdiff
[OPENMP]Fix PR40536: Do not emit __kmpc_push_target_tripcount if not
authorAlexey Bataev <a.bataev@hotmail.com>
Wed, 30 Jan 2019 20:49:52 +0000 (20:49 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Wed, 30 Jan 2019 20:49:52 +0000 (20:49 +0000)
required.

Function __kmpc_push_target_tripcount should be emitted only if the
offloading entry is going to be emitted (for use in tgt_target...
functions). Otherwise, it should not be emitted.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@352669 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGStmtOpenMP.cpp
test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp

index fe9b3bc37cb0961b8a02c3d1615f47ac88e733f3..a38e0afc6005fffa3e9bca75ccc461be6bb48d28 100644 (file)
@@ -4078,8 +4078,9 @@ static void emitCommonOMPTargetDirective(CodeGenFunction &CGF,
                                               /*IsSigned=*/false);
     return NumIterations;
   };
-  CGM.getOpenMPRuntime().emitTargetNumIterationsCall(CGF, S, Device,
-                                                     SizeEmitter);
+  if (IsOffloadEntry)
+    CGM.getOpenMPRuntime().emitTargetNumIterationsCall(CGF, S, Device,
+                                                       SizeEmitter);
   CGM.getOpenMPRuntime().emitTargetCall(CGF, S, Fn, FnID, IfCond, Device);
 }
 
index e439431a0518259b45b46b943b9f0da7d81a8a3b..4c7ac2441cc5cbaf1766415205abf0b8667e0a64 100644 (file)
@@ -2,6 +2,7 @@
 #ifndef HEADER
 #define HEADER
 // Test host codegen.
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix HCK_NO_TGT
 // RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64 --check-prefix HCK1 --check-prefix HCK1-64
 // RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
 // RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64 --check-prefix HCK1 --check-prefix HCK1-64
@@ -38,6 +39,8 @@
 
 #ifdef CK1
 
+// HCK_NO_TGT-NOT: @__kmpc_push_target_tripcount
+
 // HCK1: define{{.*}} i32 @{{.+}}target_teams_fun{{.*}}(
 int target_teams_fun(int *g){
   int n = 1000;
index af6ed9744a2cc3bca41c499fd4f7e7739285fb3e..8f1e88f980cdb1ee3fb4b36f9d711866969be95e 100644 (file)
@@ -83,7 +83,7 @@ int main() {
 // CHECK: call void @__kmpc_push_target_tripcount(i64 -1, i64 100)
 // CHECK: call i{{[0-9]+}} @__tgt_target_teams(
 // CHECK: call void [[OFFLOADING_FUN_0:@.+]](
-// CHECK: call void @__kmpc_push_target_tripcount(i64 -1, i64 100)
+// CHECK-NOT: call void @__kmpc_push_target_tripcount(i64 -1, i64 100)
 // CHECK: call void [[OFFLOADING_FUN_1:@.+]](
 // CHECK: call void @__kmpc_push_target_tripcount(i64 -1, i64 100)
 // CHECK: call i{{[0-9]+}} @__tgt_target_teams(
index b6778417be672c23dcf2d62d7e66ac0deb539edb..79ae4fe29a68b0b3e40225dc5d18370a9c5bd7dc 100644 (file)
@@ -83,7 +83,7 @@ int main() {
 // CHECK: call void @__kmpc_push_target_tripcount(i64 -1, i64 100)
 // CHECK: call i{{[0-9]+}} @__tgt_target_teams(
 // CHECK: call void [[OFFLOADING_FUN_0:@.+]](
-// CHECK: call void @__kmpc_push_target_tripcount(i64 -1, i64 100)
+// CHECK-NOT: call void @__kmpc_push_target_tripcount(i64 -1, i64 100)
 // CHECK: call void [[OFFLOADING_FUN_1:@.+]](
 // CHECK: call void @__kmpc_push_target_tripcount(i64 -1, i64 100)
 // CHECK: call i{{[0-9]+}} @__tgt_target_teams(