lxfind updated this revision to Diff 333417. lxfind added a comment. This revision is now accepted and ready to land.
check null on S Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D98135/new/ https://reviews.llvm.org/D98135 Files: clang/lib/CodeGen/CGOpenMPRuntime.cpp clang/test/OpenMP/omp_with_loop_pragma_instr_profile.c Index: clang/test/OpenMP/omp_with_loop_pragma_instr_profile.c =================================================================== --- /dev/null +++ clang/test/OpenMP/omp_with_loop_pragma_instr_profile.c @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -verify -fopenmp -x c -emit-llvm %s -triple x86_64-unknown-linux -o - -femit-all-decls -disable-llvm-passes -fprofile-instrument=clang | FileCheck %s +// expected-no-diagnostics + +void sub(double *restrict a, double *restrict b, int n) { + int i; + +#pragma omp parallel for +#pragma clang loop vectorize(disable) + for (i = 0; i < n; i++) { + a[i] = a[i] + b[i]; + } +} + +// CHECK-LABEL: @.omp_outlined.( +// CHECK-NEXT: entry: +// CHECK: call void @llvm.instrprof.increment( +// CHECK: omp.precond.then: +// CHECK-NEXT: call void @llvm.instrprof.increment( +// CHECK: cond.true: +// CEHCK-NEXT: call void @llvm.instrprof.increment( +// CHECK: omp.inner.for.body: +// CHECK-NEXT: call void @llvm.instrprof.increment( Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp =================================================================== --- clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -1034,7 +1034,7 @@ getThreadIDVariable()->getType()->castAs<PointerType>()); } -void CGOpenMPRegionInfo::EmitBody(CodeGenFunction &CGF, const Stmt * /*S*/) { +void CGOpenMPRegionInfo::EmitBody(CodeGenFunction &CGF, const Stmt *S) { if (!CGF.HaveInsertPoint()) return; // 1.2.2 OpenMP Language Terminology @@ -1043,6 +1043,8 @@ // The point of exit cannot be a branch out of the structured block. // longjmp() and throw() must not violate the entry/exit criteria. CGF.EHStack.pushTerminate(); + if (S) + CGF.incrementProfileCounter(S); CodeGen(CGF); CGF.EHStack.popTerminate(); }
Index: clang/test/OpenMP/omp_with_loop_pragma_instr_profile.c =================================================================== --- /dev/null +++ clang/test/OpenMP/omp_with_loop_pragma_instr_profile.c @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -verify -fopenmp -x c -emit-llvm %s -triple x86_64-unknown-linux -o - -femit-all-decls -disable-llvm-passes -fprofile-instrument=clang | FileCheck %s +// expected-no-diagnostics + +void sub(double *restrict a, double *restrict b, int n) { + int i; + +#pragma omp parallel for +#pragma clang loop vectorize(disable) + for (i = 0; i < n; i++) { + a[i] = a[i] + b[i]; + } +} + +// CHECK-LABEL: @.omp_outlined.( +// CHECK-NEXT: entry: +// CHECK: call void @llvm.instrprof.increment( +// CHECK: omp.precond.then: +// CHECK-NEXT: call void @llvm.instrprof.increment( +// CHECK: cond.true: +// CEHCK-NEXT: call void @llvm.instrprof.increment( +// CHECK: omp.inner.for.body: +// CHECK-NEXT: call void @llvm.instrprof.increment( Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp =================================================================== --- clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -1034,7 +1034,7 @@ getThreadIDVariable()->getType()->castAs<PointerType>()); } -void CGOpenMPRegionInfo::EmitBody(CodeGenFunction &CGF, const Stmt * /*S*/) { +void CGOpenMPRegionInfo::EmitBody(CodeGenFunction &CGF, const Stmt *S) { if (!CGF.HaveInsertPoint()) return; // 1.2.2 OpenMP Language Terminology @@ -1043,6 +1043,8 @@ // The point of exit cannot be a branch out of the structured block. // longjmp() and throw() must not violate the entry/exit criteria. CGF.EHStack.pushTerminate(); + if (S) + CGF.incrementProfileCounter(S); CodeGen(CGF); CGF.EHStack.popTerminate(); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits