Skip to content

Commit 07710e9

Browse files
committed
Merging r315578:
------------------------------------------------------------------------ r315578 | abataev | 2017-10-12 06:51:32 -0700 (Thu, 12 Oct 2017) | 7 lines [OPENMP] Fix PR34925: Fix getting thread_id lvalue for inlined regions in C. If we try to get the lvalue for thread_id variables in inlined regions, we did not use the correct version of function. Fixed this bug by adding overrided version of the function getThreadIDVariableLValue for inlined regions. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_50@318315 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent ba641b7 commit 07710e9

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,13 @@ class CGOpenMPInlinedRegionInfo : public CGOpenMPRegionInfo {
264264
return nullptr;
265265
}
266266

267+
/// \brief Get an LValue for the current ThreadID variable.
268+
LValue getThreadIDVariableLValue(CodeGenFunction &CGF) override {
269+
if (OuterRegionInfo)
270+
return OuterRegionInfo->getThreadIDVariableLValue(CGF);
271+
llvm_unreachable("No LValue for inlined OpenMP construct");
272+
}
273+
267274
/// \brief Get the name of the capture helper.
268275
StringRef getHelperName() const override {
269276
if (auto *OuterRegionInfo = getOldCSI())

test/OpenMP/task_codegen.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s
2+
// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -emit-pch -o %t %s
3+
// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
4+
// expected-no-diagnostics
5+
#ifndef HEADER
6+
#define HEADER
7+
8+
void foo();
9+
10+
// CHECK-LABEL: @main
11+
int main() {
12+
// CHECK: call i32 @__kmpc_global_thread_num(
13+
// CHECK: call i8* @__kmpc_omp_task_alloc(
14+
// CHECK: call i32 @__kmpc_omp_task(
15+
#pragma omp task
16+
{
17+
#pragma omp taskgroup
18+
{
19+
#pragma omp task
20+
foo();
21+
}
22+
}
23+
// CHECK: ret i32 0
24+
return 0;
25+
}
26+
// CHECK: call void @__kmpc_taskgroup(
27+
// CHECK: call i8* @__kmpc_omp_task_alloc(
28+
// CHECK: call i32 @__kmpc_omp_task(
29+
// CHECK: call void @__kmpc_end_taskgroup(
30+
#endif

0 commit comments

Comments
 (0)