r375257 - [DOCS]Update list of implemented constructs, NFC.

2019-10-18 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Oct 18 09:53:54 2019
New Revision: 375257

URL: http://llvm.org/viewvc/llvm-project?rev=375257=rev
Log:
[DOCS]Update list of implemented constructs, NFC.

Modified:
cfe/trunk/docs/OpenMPSupport.rst

Modified: cfe/trunk/docs/OpenMPSupport.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/OpenMPSupport.rst?rev=375257=375256=375257=diff
==
--- cfe/trunk/docs/OpenMPSupport.rst (original)
+++ cfe/trunk/docs/OpenMPSupport.rst Fri Oct 18 09:53:54 2019
@@ -181,9 +181,9 @@ implementation.
 
+--+--+--+---+
 | task extension   | master taskloop   
   | :good:`done` | 
  |
 
+--+--+--+---+
-| task extension   | parallel master taskloop  
   | :none:`unclaimed`| 
  |
+| task extension   | parallel master taskloop  
   | :none:`done` | 
  |
 
+--+--+--+---+
-| task extension   | master taskloop simd  
   | :none:`unclaimed`| 
  |
+| task extension   | master taskloop simd  
   | :none:`done` | 
  |
 
+--+--+--+---+
 | task extension   | parallel master taskloop simd 
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r375167 - [OPENMP]Dow not emit warnings for uninitialized loop counters.

2019-10-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct 17 13:35:08 2019
New Revision: 375167

URL: http://llvm.org/viewvc/llvm-project?rev=375167=rev
Log:
[OPENMP]Dow not emit warnings for uninitialized loop counters.

In OpenMP constructs all counters are initialized and we should not emit
warnings about uninitialized privatized loop control variables.

Modified:
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/test/Analysis/cfg-openmp.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_linear_messages.cpp

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=375167=375166=375167=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Thu Oct 17 13:35:08 2019
@@ -4824,7 +4824,8 @@ CFGBlock *CFGBuilder::VisitOMPExecutable
   }
   // Visit associated structured block if any.
   if (!D->isStandaloneDirective())
-if (Stmt *S = D->getStructuredBlock()) {
+if (CapturedStmt *CS = D->getInnermostCapturedStmt()) {
+  Stmt *S = CS->getCapturedStmt();
   if (!isa(S))
 addLocalScopeAndDtors(S);
   if (CFGBlock *R = addStmt(S))

Modified: cfe/trunk/test/Analysis/cfg-openmp.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cfg-openmp.cpp?rev=375167=375166=375167=diff
==
--- cfe/trunk/test/Analysis/cfg-openmp.cpp (original)
+++ cfe/trunk/test/Analysis/cfg-openmp.cpp Thu Oct 17 13:35:08 2019
@@ -27,72 +27,6 @@ void xxx(int argc) {
 // CHECK-NEXT:   [B1.[[#CRIT+3]]];
 #pragma omp critical
   argc = x;
-// CHECK-NEXT:  [[#DPF:]]: x
-// CHECK-NEXT:  [[#DPF+1]]: [B1.[[#DPF]]] (ImplicitCastExpr, LValueToRValue, 
int)
-// CHECK-NEXT:  [[#DPF+2]]: argc
-// CHECK-NEXT:  [[#DPF+3]]: [B1.[[#DPF+2]]] = [B1.[[#DPF+1]]]
-// CHECK-NEXT:  [[#DPF+4]]: cond
-// CHECK-NEXT:  [[#DPF+5]]: [B1.[[#DPF+4]]] (ImplicitCastExpr, LValueToRValue, 
int)
-// CHECK-NEXT:  [[#DPF+6]]: [B1.[[#DPF+5]]] (ImplicitCastExpr, 
IntegralToBoolean, _Bool)
-// CHECK-NEXT:  [[#DPF+7]]: fp
-// CHECK-NEXT:  [[#DPF+8]]: rd
-// CHECK-NEXT:  [[#DPF+9]]: #pragma omp distribute parallel for if(parallel: 
cond) firstprivate(fp) reduction(+: rd)
-// CHECK-NEXT:for (int i = 0; i < 10; ++i)
-// CHECK-NEXT:[B1.[[#DPF+3]]];
-#pragma omp distribute parallel for if(parallel:cond) firstprivate(fp) 
reduction(+:rd)
-  for (int i = 0; i < 10; ++i)
-argc = x;
-// CHECK-NEXT:  [[#DPFS:]]: x
-// CHECK-NEXT:  [[#DPFS+1]]: [B1.[[#DPFS]]] (ImplicitCastExpr, LValueToRValue, 
int)
-// CHECK-NEXT:  [[#DPFS+2]]: argc
-// CHECK-NEXT:  [[#DPFS+3]]: [B1.[[#DPFS+2]]] = [B1.[[#DPFS+1]]]
-// CHECK-NEXT:  [[#DPFS+4]]: cond
-// CHECK-NEXT:  [[#DPFS+5]]: [B1.[[#DPFS+4]]] (ImplicitCastExpr, 
LValueToRValue, int)
-// CHECK-NEXT:  [[#DPFS+6]]: [B1.[[#DPFS+5]]] (ImplicitCastExpr, 
IntegralToBoolean, _Bool)
-// CHECK-NEXT:  [[#DPFS+7]]: fp
-// CHECK-NEXT:  [[#DPFS+8]]: rd
-// CHECK-NEXT:  [[#DPFS+9]]: #pragma omp distribute parallel for simd if(cond) 
firstprivate(fp) reduction(-: rd)
-// CHECK-NEXT:for (int i = 0; i < 10; ++i)
-// CHECK-NEXT:[B1.[[#DPFS+3]]];
-#pragma omp distribute parallel for simd if(cond)  firstprivate(fp) 
reduction(-:rd)
-  for (int i = 0; i < 10; ++i)
-argc = x;
-// CHECK-NEXT:  [[#DS:]]: x
-// CHECK-NEXT:  [[#DS+1]]: [B1.[[#DS]]] (ImplicitCastExpr, LValueToRValue, int)
-// CHECK-NEXT:  [[#DS+2]]: argc
-// CHECK-NEXT:  [[#DS+3]]: [B1.[[#DS+2]]] = [B1.[[#DS+1]]]
-// CHECK-NEXT:  [[#DS+4]]: #pragma omp distribute simd
-// CHECK-NEXT:for (int i = 0; i < 10; ++i)
-// CHECK-NEXT:[B1.[[#DS+3]]];
-#pragma omp distribute simd
-  for (int i = 0; i < 10; ++i)
-argc = x;
-// CHECK-NEXT:  [[#FOR:]]: x
-// CHECK-NEXT:  [[#FOR+1]]: [B1.[[#FOR]]] (ImplicitCastExpr, LValueToRValue, 
int)
-// CHECK-NEXT:  [[#FOR+2]]: argc
-// CHECK-NEXT:  [[#FOR+3]]: [B1.[[#FOR+2]]] = [B1.[[#FOR+1]]]
-// CHECK-NEXT:  [[#FOR+4]]: lin
-// CHECK-NEXT:  [[#FOR+5]]: step
-// CHECK-NEXT:  [[#FOR+6]]: [B1.[[#FOR+5]]] (ImplicitCastExpr, LValueToRValue, 
int)
-// CHECK-NEXT:  [[#FOR+7]]: #pragma omp for linear(lin: step)
-// CHECK-NEXT:for (int i = 0; i < 10; ++i)
-// CHECK-NEXT:[B1.[[#FOR+3]]];
-#pragma omp for linear(lin : step)
-  for (int i = 0; i < 10; ++i)
-argc = x;
-// CHECK-NEXT:  [[#FS:]]: x
-// CHECK-NEXT:  [[#FS+1]]: [B1.[[#FS]]] (ImplicitCastExpr, LValueToRValue, int)
-// CHECK-NEXT:  [[#FS+2]]: argc
-// CHECK-NEXT:  [[#FS+3]]: [B1.[[#FS+2]]] = [B1.[[#FS+1]]]
-// CHECK-NEXT:  [[#FS+4]]: lin
-// CHECK-NEXT:  [[#FS+5]]: step
-// CHECK-NEXT:  [[#FS+6]]: [B1.[[#FS+5]]] (ImplicitCastExpr, LValueToRValue, 
int)
-// CHECK-NEXT:  [[#FS+7]]: #pragma omp for simd linear(lin: step)
-// CHECK-NEXT:for (int i = 0; i < 10; ++i)
-// CHECK-NEXT:[B1.[[#FS+3]]];
-#pragma omp for simd linear(lin: step)
-  

r375134 - [OPENMP]Improve use of the global tid parameter.

2019-10-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct 17 10:12:03 2019
New Revision: 375134

URL: http://llvm.org/viewvc/llvm-project?rev=375134=rev
Log:
[OPENMP]Improve use of the global tid parameter.

If we can determined, that the global tid parameter can be used in the
function, better to use it rather than calling __kmpc_global_thread_num
function.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/openmp_win_codegen.cpp
cfe/trunk/test/OpenMP/parallel_for_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=375134=375133=375134=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct 17 10:12:03 2019
@@ -1697,18 +1697,23 @@ llvm::Value *CGOpenMPRuntime::getThreadI
   return ThreadID;
   }
   // If exceptions are enabled, do not use parameter to avoid possible crash.
-  if (!CGF.EHStack.requiresLandingPad() || !CGF.getLangOpts().Exceptions ||
-  !CGF.getLangOpts().CXXExceptions ||
-  CGF.Builder.GetInsertBlock() == CGF.AllocaInsertPt->getParent()) {
-if (auto *OMPRegionInfo =
-dyn_cast_or_null(CGF.CapturedStmtInfo)) {
-  if (OMPRegionInfo->getThreadIDVariable()) {
-// Check if this an outlined function with thread id passed as 
argument.
-LValue LVal = OMPRegionInfo->getThreadIDVariableLValue(CGF);
+  if (auto *OMPRegionInfo =
+  dyn_cast_or_null(CGF.CapturedStmtInfo)) {
+if (OMPRegionInfo->getThreadIDVariable()) {
+  // Check if this an outlined function with thread id passed as argument.
+  LValue LVal = OMPRegionInfo->getThreadIDVariableLValue(CGF);
+  llvm::BasicBlock *TopBlock = CGF.AllocaInsertPt->getParent();
+  if (!CGF.EHStack.requiresLandingPad() || !CGF.getLangOpts().Exceptions ||
+  !CGF.getLangOpts().CXXExceptions ||
+  CGF.Builder.GetInsertBlock() == TopBlock ||
+  !isa(LVal.getPointer()) ||
+  cast(LVal.getPointer())->getParent() == TopBlock 
||
+  cast(LVal.getPointer())->getParent() ==
+  CGF.Builder.GetInsertBlock()) {
 ThreadID = CGF.EmitLoadOfScalar(LVal, Loc);
 // If value loaded in entry block, cache it and use it everywhere in
 // function.
-if (CGF.Builder.GetInsertBlock() == CGF.AllocaInsertPt->getParent()) {
+if (CGF.Builder.GetInsertBlock() == TopBlock) {
   auto  = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn);
   Elem.second.ThreadID = ThreadID;
 }

Modified: cfe/trunk/test/OpenMP/openmp_win_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/openmp_win_codegen.cpp?rev=375134=375133=375134=diff
==
--- cfe/trunk/test/OpenMP/openmp_win_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/openmp_win_codegen.cpp Thu Oct 17 10:12:03 2019
@@ -50,11 +50,10 @@ int main() {
 }
 
 // CHECK: define internal void [[OUTLINED]](
-// CHECK: [[GID:%.+]] = {{.*}}call i32 
@__kmpc_global_thread_num(%struct.ident_t* {{.*}}@0)
 // CHECK: invoke void @{{.+}}foo
 // CHECK: [[CATCHSWITCH:%.+]] = catchswitch within none
 // CHECK: [[CATCHPAD:%.+]] = catchpad within [[CATCHSWITCH]]
-// CHECK: call void @__kmpc_critical(%struct.ident_t* {{.*}}@0, i32 [[GID]],
+// CHECK: call void @__kmpc_critical(%struct.ident_t* {{.*}}@0, i32 
[[GID:%.+]],
 // CHECK: invoke void @{{.+}}bar
 // CHECK: call void @__kmpc_end_critical(%struct.ident_t* {{.*}}@0, i32 
[[GID]],
 // CHECK: catchret from [[CATCHPAD]] to

Modified: cfe/trunk/test/OpenMP/parallel_for_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_codegen.cpp?rev=375134=375133=375134=diff
==
--- cfe/trunk/test/OpenMP/parallel_for_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_for_codegen.cpp Thu Oct 17 10:12:03 2019
@@ -40,7 +40,7 @@ void with_var_schedule() {
 // CHECK: [[CHUNK_VAL:%.+]] = load i8, i8* %
 // CHECK: [[CHUNK_SIZE:%.+]] = sext i8 [[CHUNK_VAL]] to i64
 // CHECK: call void @__kmpc_for_static_init_8u([[IDENT_T_TY]]* [[LOOP_LOC]], 
i32 [[GTID:%[^,]+]], i32 33, i32* [[IS_LAST:%[^,]+]], i64* [[OMP_LB:%[^,]+]], 
i64* [[OMP_UB:%[^,]+]], i64* [[OMP_ST:%[^,]+]], i64 1, i64 [[CHUNK_SIZE]])
-// CHECK: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[LOOP_LOC]], i32 
[[GTID]])
+// CHECK: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[LOOP_LOC]], i32 
[[GTID:%.+]])
 #pragma omp parallel for schedule(static, char(a)) private(a)
   for (unsigned long long i = 1; i < 2 + a; ++i) {
   }
@@ -284,7 +284,7 @@ void test_auto(float *a, float *b, float
 // CHECK: store i32* [[GTID_PARAM_ADDR]], i32** [[GTID_REF_ADDR:%.+]],
 // CHECK: call void @__kmpc_dispatch_init_8([[IDENT_T_TY]]* [[DEFAULT_LOC]], 

r375119 - [OPENMP]Fix thread id passed to outlined region in sequential parallel

2019-10-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct 17 07:36:43 2019
New Revision: 375119

URL: http://llvm.org/viewvc/llvm-project?rev=375119=rev
Log:
[OPENMP]Fix thread id passed to outlined region in sequential parallel
regions.

The real global thread id must be passed to the outlined region instead
of the zero thread id.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/parallel_if_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=375119=375118=375119=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct 17 07:36:43 2019
@@ -3075,17 +3075,15 @@ void CGOpenMPRuntime::emitParallelCall(C
 CGF.EmitRuntimeCall(
 RT.createRuntimeFunction(OMPRTL__kmpc_serialized_parallel), Args);
 
-// OutlinedFn(, _bound, CapturedStruct);
-Address ZeroAddr = CGF.CreateDefaultAlignTempAlloca(CGF.Int32Ty,
-/*Name=*/".zero.addr");
-CGF.InitTempAlloca(ZeroAddr, CGF.Builder.getInt32(/*C*/ 0));
+// OutlinedFn(, _bound, CapturedStruct);
+Address ThreadIDAddr = RT.emitThreadIDAddress(CGF, Loc);
 Address ZeroAddrBound =
 CGF.CreateDefaultAlignTempAlloca(CGF.Int32Ty,
  /*Name=*/".bound.zero.addr");
 CGF.InitTempAlloca(ZeroAddrBound, CGF.Builder.getInt32(/*C*/ 0));
 llvm::SmallVector OutlinedFnArgs;
 // ThreadId for serialized parallels is 0.
-OutlinedFnArgs.push_back(ZeroAddr.getPointer());
+OutlinedFnArgs.push_back(ThreadIDAddr.getPointer());
 OutlinedFnArgs.push_back(ZeroAddrBound.getPointer());
 OutlinedFnArgs.append(CapturedVars.begin(), CapturedVars.end());
 RT.emitOutlinedFunctionCall(CGF, Loc, OutlinedFn, OutlinedFnArgs);

Modified: cfe/trunk/test/OpenMP/parallel_if_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_if_codegen.cpp?rev=375119=375118=375119=diff
==
--- cfe/trunk/test/OpenMP/parallel_if_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_if_codegen.cpp Thu Oct 17 07:36:43 2019
@@ -30,12 +30,12 @@ void gtid_test() {
 
 // CHECK: define internal {{.*}}void [[GTID_TEST_REGION1]](i{{.+}}* noalias 
[[GTID_PARAM:%.+]], i32* noalias
 // CHECK: store i32 0, i32* [[BND_ZERO_ADDR:%.+]],
-// CHECK: store i32 0, i32* [[ZERO_ADDR:%.+]],
 // CHECK: store i{{[0-9]+}}* [[GTID_PARAM]], i{{[0-9]+}}** 
[[GTID_ADDR_REF:%.+]],
 // CHECK: [[GTID_ADDR:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** 
[[GTID_ADDR_REF]]
 // CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_ADDR]]
 // CHECK: call {{.*}}void @__kmpc_serialized_parallel(%{{.+}}* @{{.+}}, 
i{{.+}} [[GTID]])
-// CHECK: call void [[GTID_TEST_REGION2:@.+]](i{{[0-9]+}}* [[ZERO_ADDR]], 
i{{[0-9]+}}* [[BND_ZERO_ADDR]]
+// CHECK: [[GTID_ADDR:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** 
[[GTID_ADDR_REF]]
+// CHECK: call void [[GTID_TEST_REGION2:@.+]](i{{[0-9]+}}* [[GTID_ADDR]], 
i{{[0-9]+}}* [[BND_ZERO_ADDR]]
 // CHECK: call {{.*}}void @__kmpc_end_serialized_parallel(%{{.+}}* @{{.+}}, 
i{{.+}} [[GTID]])
 // CHECK: ret void
 
@@ -57,15 +57,14 @@ int tmain(T Arg) {
 // CHECK-LABEL: define {{.*}}i{{[0-9]+}} @main()
 int main() {
 // CHECK: store i32 0, i32* [[BND_ZERO_ADDR2:%.+]],
-// CHECK: store i32 0, i32* [[ZERO_ADDR2:%.+]],
 // CHECK: store i32 0, i32* [[BND_ZERO_ADDR1:%.+]],
-// CHECK: store i32 0, i32* [[ZERO_ADDR1:%.+]],
 // CHECK: [[GTID:%.+]] = call {{.*}}i32 @__kmpc_global_thread_num(
 // CHECK: call {{.*}}void {{.+}} @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{.+}} 
0, void {{.+}}* [[CAP_FN4:@.+]] to void
 #pragma omp parallel if (true)
   fn4();
 // CHECK: call {{.*}}void @__kmpc_serialized_parallel(%{{.+}}* @{{.+}}, i32 
[[GTID]])
-// CHECK: call void [[CAP_FN5:@.+]](i32* [[ZERO_ADDR1]], i32* 
[[BND_ZERO_ADDR1]])
+// CHECK: store i32 [[GTID]], i32* [[GTID_ADDR:%.+]],
+// CHECK: call void [[CAP_FN5:@.+]](i32* [[GTID_ADDR]], i32* 
[[BND_ZERO_ADDR1]])
 // CHECK: call {{.*}}void @__kmpc_end_serialized_parallel(%{{.+}}* @{{.+}}, 
i32 [[GTID]])
 #pragma omp parallel if (false)
   fn5();
@@ -76,7 +75,8 @@ int main() {
 // CHECK: br label %[[OMP_END:.+]]
 // CHECK: [[OMP_ELSE]]
 // CHECK: call {{.*}}void @__kmpc_serialized_parallel(%{{.+}}* @{{.+}}, i32 
[[GTID]])
-// CHECK: call void [[CAP_FN6]](i32* [[ZERO_ADDR2]], i32* [[BND_ZERO_ADDR2]])
+// CHECK: store i32 [[GTID]], i32* [[GTID_ADDR:%.+]],
+// CHECK: call void [[CAP_FN6]](i32* [[GTID_ADDR]], i32* [[BND_ZERO_ADDR2]])
 // CHECK: call {{.*}}void @__kmpc_end_serialized_parallel(%{{.+}}* @{{.+}}, 
i32 [[GTID]])
 // CHECK: br label %[[OMP_END]]
 // CHECK: [[OMP_END]]
@@ -100,13 +100,12 @@ int main() {
 
 // CHECK-LABEL: define {{.+}} @{{.+}}tmain
 // CHECK: store i32 0, i32* [[BND_ZERO_ADDR2:%.+]],
-// 

r375026 - [OPENMP]Allow priority clause in combined task-based directives.

2019-10-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Oct 16 11:09:37 2019
New Revision: 375026

URL: http://llvm.org/viewvc/llvm-project?rev=375026=rev
Log:
[OPENMP]Allow priority clause in combined task-based directives.

The expression of the priority clause must be captured in the combined
task-based directives, like 'parallel master taskloop' directive.

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/OpenMP/parallel_master_taskloop_codegen.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=375026=375025=375026=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Wed Oct 16 11:09:37 2019
@@ -5206,7 +5206,7 @@ public:
 /// \endcode
 /// In this example directive '#pragma omp teams' has clause 'priority' with
 /// single expression 'n'.
-class OMPPriorityClause : public OMPClause {
+class OMPPriorityClause : public OMPClause, public OMPClauseWithPreInit {
   friend class OMPClauseReader;
 
   /// Location of '('.
@@ -5223,18 +5223,25 @@ class OMPPriorityClause : public OMPClau
 public:
   /// Build 'priority' clause.
   ///
-  /// \param E Expression associated with this clause.
+  /// \param Priority Expression associated with this clause.
+  /// \param HelperPriority Helper priority for the construct.
+  /// \param CaptureRegion Innermost OpenMP region where expressions in this
+  /// clause must be captured.
   /// \param StartLoc Starting location of the clause.
   /// \param LParenLoc Location of '('.
   /// \param EndLoc Ending location of the clause.
-  OMPPriorityClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc,
-SourceLocation EndLoc)
-  : OMPClause(OMPC_priority, StartLoc, EndLoc), LParenLoc(LParenLoc),
-Priority(E) {}
+  OMPPriorityClause(Expr *Priority, Stmt *HelperPriority,
+OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
+SourceLocation LParenLoc, SourceLocation EndLoc)
+  : OMPClause(OMPC_priority, StartLoc, EndLoc), OMPClauseWithPreInit(this),
+LParenLoc(LParenLoc), Priority(Priority) {
+setPreInitStmt(HelperPriority, CaptureRegion);
+  }
 
   /// Build an empty clause.
   OMPPriorityClause()
-  : OMPClause(OMPC_priority, SourceLocation(), SourceLocation()) {}
+  : OMPClause(OMPC_priority, SourceLocation(), SourceLocation()),
+OMPClauseWithPreInit(this) {}
 
   /// Sets the location of '('.
   void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
@@ -5254,11 +5261,10 @@ public:
 return const_child_range(,  + 1);
   }
 
-  child_range used_children() {
-return child_range(child_iterator(), child_iterator());
-  }
+  child_range used_children();
   const_child_range used_children() const {
-return const_child_range(const_child_iterator(), const_child_iterator());
+auto Children = const_cast(this)->used_children();
+return const_child_range(Children.begin(), Children.end());
   }
 
   static bool classof(const OMPClause *T) {

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=375026=375025=375026=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed Oct 16 11:09:37 2019
@@ -3277,6 +3277,7 @@ bool RecursiveASTVisitor::Visit
 template 
 bool RecursiveASTVisitor::VisitOMPPriorityClause(
 OMPPriorityClause *C) {
+  TRY_TO(VisitOMPClauseWithPreInit(C));
   TRY_TO(TraverseStmt(C->getPriority()));
   return true;
 }

Modified: cfe/trunk/lib/AST/OpenMPClause.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/OpenMPClause.cpp?rev=375026=375025=375026=diff
==
--- cfe/trunk/lib/AST/OpenMPClause.cpp (original)
+++ cfe/trunk/lib/AST/OpenMPClause.cpp Wed Oct 16 11:09:37 2019
@@ -90,6 +90,8 @@ const OMPClauseWithPreInit *OMPClauseWit
 return static_cast(C);
   case OMPC_final:
 return static_cast(C);
+  case OMPC_priority:
+return static_cast(C);
   case OMPC_default:
   case OMPC_proc_bind:
   case OMPC_safelen:
@@ -117,7 +119,6 @@ const OMPClauseWithPreInit *OMPClauseWit
   case OMPC_threads:
   case OMPC_simd:
   case OMPC_map:
-  case OMPC_priority:
   case OMPC_nogroup:
   case OMPC_hint:
   case OMPC_defaultmap:
@@ -255,6 +256,12 @@ OMPClause::child_range OMPFinalClause::u
   return child_range(,  + 1);

r375017 - [OPENMP]Use different addresses for zeroed thread_id/bound_id.

2019-10-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Oct 16 09:59:01 2019
New Revision: 375017

URL: http://llvm.org/viewvc/llvm-project?rev=375017=rev
Log:
[OPENMP]Use different addresses for zeroed thread_id/bound_id.

When the parallel region is called directly in the sequential region,
the zeroed tid/bound id are used. But they must point to the different
memory locations as the parameters are marked as noalias.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_teams_reduction_codegen.cpp
cfe/trunk/test/OpenMP/parallel_if_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=375017=375016=375017=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Oct 16 09:59:01 2019
@@ -3075,14 +3075,18 @@ void CGOpenMPRuntime::emitParallelCall(C
 CGF.EmitRuntimeCall(
 RT.createRuntimeFunction(OMPRTL__kmpc_serialized_parallel), Args);
 
-// OutlinedFn(, , CapturedStruct);
+// OutlinedFn(, _bound, CapturedStruct);
 Address ZeroAddr = CGF.CreateDefaultAlignTempAlloca(CGF.Int32Ty,
-/*Name*/ ".zero.addr");
+/*Name=*/".zero.addr");
 CGF.InitTempAlloca(ZeroAddr, CGF.Builder.getInt32(/*C*/ 0));
+Address ZeroAddrBound =
+CGF.CreateDefaultAlignTempAlloca(CGF.Int32Ty,
+ /*Name=*/".bound.zero.addr");
+CGF.InitTempAlloca(ZeroAddrBound, CGF.Builder.getInt32(/*C*/ 0));
 llvm::SmallVector OutlinedFnArgs;
 // ThreadId for serialized parallels is 0.
 OutlinedFnArgs.push_back(ZeroAddr.getPointer());
-OutlinedFnArgs.push_back(ZeroAddr.getPointer());
+OutlinedFnArgs.push_back(ZeroAddrBound.getPointer());
 OutlinedFnArgs.append(CapturedVars.begin(), CapturedVars.end());
 RT.emitOutlinedFunctionCall(CGF, Loc, OutlinedFn, OutlinedFnArgs);
 

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=375017=375016=375017=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Wed Oct 16 09:59:01 2019
@@ -2459,9 +2459,8 @@ void CGOpenMPRuntimeNVPTX::emitTeamsCall
   if (!CGF.HaveInsertPoint())
 return;
 
-  Address ZeroAddr = CGF.CreateMemTemp(
-  CGF.getContext().getIntTypeForBitwidth(/*DestWidth=*/32, /*Signed=*/1),
-  /*Name*/ ".zero.addr");
+  Address ZeroAddr = CGF.CreateDefaultAlignTempAlloca(CGF.Int32Ty,
+  /*Name=*/".zero.addr");
   CGF.InitTempAlloca(ZeroAddr, CGF.Builder.getInt32(/*C*/ 0));
   llvm::SmallVector OutlinedFnArgs;
   OutlinedFnArgs.push_back(emitThreadIDAddress(CGF, Loc).getPointer());
@@ -2490,16 +2489,19 @@ void CGOpenMPRuntimeNVPTX::emitNonSPMDPa
   // Force inline this outlined function at its call site.
   Fn->setLinkage(llvm::GlobalValue::InternalLinkage);
 
-  Address ZeroAddr = CGF.CreateMemTemp(CGF.getContext().getIntTypeForBitwidth(
-   /*DestWidth=*/32, /*Signed=*/1),
-   ".zero.addr");
+  Address ZeroAddr = CGF.CreateDefaultAlignTempAlloca(CGF.Int32Ty,
+  /*Name=*/".zero.addr");
   CGF.InitTempAlloca(ZeroAddr, CGF.Builder.getInt32(/*C*/ 0));
   // ThreadId for serialized parallels is 0.
   Address ThreadIDAddr = ZeroAddr;
-  auto & = [this, Fn, CapturedVars, Loc, ZeroAddr, ](
+  auto & = [this, Fn, CapturedVars, Loc, ](
CodeGenFunction , PrePostActionTy ) {
 Action.Enter(CGF);
 
+Address ZeroAddr =
+CGF.CreateDefaultAlignTempAlloca(CGF.Int32Ty,
+ /*Name=*/".bound.zero.addr");
+CGF.InitTempAlloca(ZeroAddr, CGF.Builder.getInt32(/*C*/ 0));
 llvm::SmallVector OutlinedFnArgs;
 OutlinedFnArgs.push_back(ThreadIDAddr.getPointer());
 OutlinedFnArgs.push_back(ZeroAddr.getPointer());
@@ -2656,17 +2658,19 @@ void CGOpenMPRuntimeNVPTX::emitSPMDParal
   //
   llvm::SmallVector OutlinedFnArgs;
 
-  Address ZeroAddr = CGF.CreateMemTemp(CGF.getContext().getIntTypeForBitwidth(
-   /*DestWidth=*/32, /*Signed=*/1),
-   ".zero.addr");
+  Address ZeroAddr = CGF.CreateDefaultAlignTempAlloca(CGF.Int32Ty,
+  /*Name=*/".zero.addr");
   CGF.InitTempAlloca(ZeroAddr, CGF.Builder.getInt32(/*C*/ 0));
   // ThreadId for serialized 

r374943 - [OPENMP]Fix comments/params, NFC.

2019-10-15 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Oct 15 12:51:30 2019
New Revision: 374943

URL: http://llvm.org/viewvc/llvm-project?rev=374943=rev
Log:
[OPENMP]Fix comments/params, NFC.

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=374943=374942=374943=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Tue Oct 15 12:51:30 2019
@@ -534,20 +534,19 @@ class OMPFinalClause : public OMPClause,
 public:
   /// Build 'final' clause with condition \a Cond.
   ///
-  /// \param Cond final condition.
+  /// \param Cond Condition of the clause.
   /// \param HelperCond Helper condition for the construct.
   /// \param CaptureRegion Innermost OpenMP region where expressions in this
   /// clause must be captured.
   /// \param StartLoc Starting location of the clause.
   /// \param LParenLoc Location of '('.
-  /// \param Cond Condition of the clause.
   /// \param EndLoc Ending location of the clause.
-  OMPFinalClause(Expr *Cond, Stmt *HelperSize,
+  OMPFinalClause(Expr *Cond, Stmt *HelperCond,
  OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
  SourceLocation LParenLoc, SourceLocation EndLoc)
   : OMPClause(OMPC_final, StartLoc, EndLoc), OMPClauseWithPreInit(this),
 LParenLoc(LParenLoc), Condition(Cond) {
-setPreInitStmt(HelperSize, CaptureRegion);
+setPreInitStmt(HelperCond, CaptureRegion);
   }
 
   /// Build an empty clause.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r374942 - [OPENMP]Allow final clause in combined task-based directives.

2019-10-15 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Oct 15 12:37:05 2019
New Revision: 374942

URL: http://llvm.org/viewvc/llvm-project?rev=374942=rev
Log:
[OPENMP]Allow final clause in combined task-based directives.
The condition of the final clause must be captured in the combined
task-based directives, like 'parallel master taskloop' directive.

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/OpenMP/parallel_master_taskloop_ast_print.cpp
cfe/trunk/test/OpenMP/parallel_master_taskloop_codegen.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=374942=374941=374942=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Tue Oct 15 12:37:05 2019
@@ -519,7 +519,7 @@ public:
 /// \endcode
 /// In this example directive '#pragma omp task' has simple 'final'
 /// clause with condition 'a > 5'.
-class OMPFinalClause : public OMPClause {
+class OMPFinalClause : public OMPClause, public OMPClauseWithPreInit {
   friend class OMPClauseReader;
 
   /// Location of '('.
@@ -534,18 +534,26 @@ class OMPFinalClause : public OMPClause
 public:
   /// Build 'final' clause with condition \a Cond.
   ///
+  /// \param Cond final condition.
+  /// \param HelperCond Helper condition for the construct.
+  /// \param CaptureRegion Innermost OpenMP region where expressions in this
+  /// clause must be captured.
   /// \param StartLoc Starting location of the clause.
   /// \param LParenLoc Location of '('.
   /// \param Cond Condition of the clause.
   /// \param EndLoc Ending location of the clause.
-  OMPFinalClause(Expr *Cond, SourceLocation StartLoc, SourceLocation LParenLoc,
- SourceLocation EndLoc)
-  : OMPClause(OMPC_final, StartLoc, EndLoc), LParenLoc(LParenLoc),
-Condition(Cond) {}
+  OMPFinalClause(Expr *Cond, Stmt *HelperSize,
+ OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
+ SourceLocation LParenLoc, SourceLocation EndLoc)
+  : OMPClause(OMPC_final, StartLoc, EndLoc), OMPClauseWithPreInit(this),
+LParenLoc(LParenLoc), Condition(Cond) {
+setPreInitStmt(HelperSize, CaptureRegion);
+  }
 
   /// Build an empty clause.
   OMPFinalClause()
-  : OMPClause(OMPC_final, SourceLocation(), SourceLocation()) {}
+  : OMPClause(OMPC_final, SourceLocation(), SourceLocation()),
+OMPClauseWithPreInit(this) {}
 
   /// Sets the location of '('.
   void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
@@ -562,11 +570,10 @@ public:
 return const_child_range(,  + 1);
   }
 
-  child_range used_children() {
-return child_range(child_iterator(), child_iterator());
-  }
+  child_range used_children();
   const_child_range used_children() const {
-return const_child_range(const_child_iterator(), const_child_iterator());
+auto Children = const_cast(this)->used_children();
+return const_child_range(Children.begin(), Children.end());
   }
 
   static bool classof(const OMPClause *T) {

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=374942=374941=374942=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Tue Oct 15 12:37:05 2019
@@ -2906,6 +2906,7 @@ bool RecursiveASTVisitor::Visit
 
 template 
 bool RecursiveASTVisitor::VisitOMPFinalClause(OMPFinalClause *C) {
+  TRY_TO(VisitOMPClauseWithPreInit(C));
   TRY_TO(TraverseStmt(C->getCondition()));
   return true;
 }

Modified: cfe/trunk/lib/AST/OpenMPClause.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/OpenMPClause.cpp?rev=374942=374941=374942=diff
==
--- cfe/trunk/lib/AST/OpenMPClause.cpp (original)
+++ cfe/trunk/lib/AST/OpenMPClause.cpp Tue Oct 15 12:37:05 2019
@@ -88,9 +88,10 @@ const OMPClauseWithPreInit *OMPClauseWit
 return static_cast(C);
   case OMPC_num_tasks:
 return static_cast(C);
+  case OMPC_final:
+return static_cast(C);
   case OMPC_default:
   case OMPC_proc_bind:
-  case OMPC_final:
   case OMPC_safelen:
   case OMPC_simdlen:
   case OMPC_allocator:
@@ -248,6 +249,12 @@ OMPClause::child_range OMPNumTasksClause
   return child_range(,  + 1);
 }
 
+OMPClause::child_range OMPFinalClause::used_children() {
+  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
+return child_range(C, C + 1);
+  

r374819 - [OPNEMP]Allow num_tasks clause in combined task-based directives.

2019-10-14 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Oct 14 13:44:34 2019
New Revision: 374819

URL: http://llvm.org/viewvc/llvm-project?rev=374819=rev
Log:
[OPNEMP]Allow num_tasks clause in combined task-based directives.

The expression of the num_tasks clause must be captured in the combined
task-based directives, like 'parallel master taskloop' directive.

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/OpenMP/parallel_master_taskloop_ast_print.cpp
cfe/trunk/test/OpenMP/parallel_master_taskloop_codegen.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=374819=374818=374819=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Mon Oct 14 13:44:34 2019
@@ -5375,7 +5375,7 @@ public:
 /// \endcode
 /// In this example directive '#pragma omp taskloop' has clause 'num_tasks'
 /// with single expression '4'.
-class OMPNumTasksClause : public OMPClause {
+class OMPNumTasksClause : public OMPClause, public OMPClauseWithPreInit {
   friend class OMPClauseReader;
 
   /// Location of '('.
@@ -5391,16 +5391,23 @@ public:
   /// Build 'num_tasks' clause.
   ///
   /// \param Size Expression associated with this clause.
+  /// \param HelperSize Helper grainsize for the construct.
+  /// \param CaptureRegion Innermost OpenMP region where expressions in this
+  /// clause must be captured.
   /// \param StartLoc Starting location of the clause.
   /// \param EndLoc Ending location of the clause.
-  OMPNumTasksClause(Expr *Size, SourceLocation StartLoc,
+  OMPNumTasksClause(Expr *Size, Stmt *HelperSize,
+OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc,
 SourceLocation LParenLoc, SourceLocation EndLoc)
-  : OMPClause(OMPC_num_tasks, StartLoc, EndLoc), LParenLoc(LParenLoc),
-NumTasks(Size) {}
+  : OMPClause(OMPC_num_tasks, StartLoc, EndLoc), 
OMPClauseWithPreInit(this),
+LParenLoc(LParenLoc), NumTasks(Size) {
+setPreInitStmt(HelperSize, CaptureRegion);
+  }
 
   /// Build an empty clause.
   explicit OMPNumTasksClause()
-  : OMPClause(OMPC_num_tasks, SourceLocation(), SourceLocation()) {}
+  : OMPClause(OMPC_num_tasks, SourceLocation(), SourceLocation()),
+OMPClauseWithPreInit(this) {}
 
   /// Sets the location of '('.
   void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
@@ -5417,11 +5424,10 @@ public:
 return const_child_range(,  + 1);
   }
 
-  child_range used_children() {
-return child_range(child_iterator(), child_iterator());
-  }
+  child_range used_children();
   const_child_range used_children() const {
-return const_child_range(const_child_iterator(), const_child_iterator());
+auto Children = const_cast(this)->used_children();
+return const_child_range(Children.begin(), Children.end());
   }
 
   static bool classof(const OMPClause *T) {

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=374819=374818=374819=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon Oct 14 13:44:34 2019
@@ -3283,6 +3283,7 @@ bool RecursiveASTVisitor::Visit
 template 
 bool RecursiveASTVisitor::VisitOMPNumTasksClause(
 OMPNumTasksClause *C) {
+  TRY_TO(VisitOMPClauseWithPreInit(C));
   TRY_TO(TraverseStmt(C->getNumTasks()));
   return true;
 }

Modified: cfe/trunk/lib/AST/OpenMPClause.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/OpenMPClause.cpp?rev=374819=374818=374819=diff
==
--- cfe/trunk/lib/AST/OpenMPClause.cpp (original)
+++ cfe/trunk/lib/AST/OpenMPClause.cpp Mon Oct 14 13:44:34 2019
@@ -86,6 +86,8 @@ const OMPClauseWithPreInit *OMPClauseWit
 return static_cast(C);
   case OMPC_grainsize:
 return static_cast(C);
+  case OMPC_num_tasks:
+return static_cast(C);
   case OMPC_default:
   case OMPC_proc_bind:
   case OMPC_final:
@@ -116,7 +118,6 @@ const OMPClauseWithPreInit *OMPClauseWit
   case OMPC_map:
   case OMPC_priority:
   case OMPC_nogroup:
-  case OMPC_num_tasks:
   case OMPC_hint:
   case OMPC_defaultmap:
   case OMPC_unknown:
@@ -241,6 +242,12 @@ OMPClause::child_range OMPGrainsizeClaus
   return child_range(,  + 1);
 }
 
+OMPClause::child_range OMPNumTasksClause::used_children() {
+  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
+

r374810 - [OPNEMP]Allow grainsize clause in combined task-based directives.

2019-10-14 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Oct 14 12:29:52 2019
New Revision: 374810

URL: http://llvm.org/viewvc/llvm-project?rev=374810=rev
Log:
[OPNEMP]Allow grainsize clause in combined task-based directives.

The expression of the grainsize clause must be captured in the combined
task-based directives, like 'parallel master taskloop' directive.

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/OpenMP/parallel_master_taskloop_codegen.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=374810=374809=374810=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Mon Oct 14 12:29:52 2019
@@ -5268,7 +5268,7 @@ public:
 /// \endcode
 /// In this example directive '#pragma omp taskloop' has clause 'grainsize'
 /// with single expression '4'.
-class OMPGrainsizeClause : public OMPClause {
+class OMPGrainsizeClause : public OMPClause, public OMPClauseWithPreInit {
   friend class OMPClauseReader;
 
   /// Location of '('.
@@ -5284,16 +5284,23 @@ public:
   /// Build 'grainsize' clause.
   ///
   /// \param Size Expression associated with this clause.
+  /// \param HelperSize Helper grainsize for the construct.
+  /// \param CaptureRegion Innermost OpenMP region where expressions in this
+  /// clause must be captured.
   /// \param StartLoc Starting location of the clause.
   /// \param EndLoc Ending location of the clause.
-  OMPGrainsizeClause(Expr *Size, SourceLocation StartLoc,
+  OMPGrainsizeClause(Expr *Size, Stmt *HelperSize,
+ OpenMPDirectiveKind CaptureRegion, SourceLocation 
StartLoc,
  SourceLocation LParenLoc, SourceLocation EndLoc)
-  : OMPClause(OMPC_grainsize, StartLoc, EndLoc), LParenLoc(LParenLoc),
-Grainsize(Size) {}
+  : OMPClause(OMPC_grainsize, StartLoc, EndLoc), 
OMPClauseWithPreInit(this),
+LParenLoc(LParenLoc), Grainsize(Size) {
+setPreInitStmt(HelperSize, CaptureRegion);
+  }
 
   /// Build an empty clause.
   explicit OMPGrainsizeClause()
-  : OMPClause(OMPC_grainsize, SourceLocation(), SourceLocation()) {}
+  : OMPClause(OMPC_grainsize, SourceLocation(), SourceLocation()),
+OMPClauseWithPreInit(this) {}
 
   /// Sets the location of '('.
   void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
@@ -5310,11 +5317,10 @@ public:
 return const_child_range(,  + 1);
   }
 
-  child_range used_children() {
-return child_range(child_iterator(), child_iterator());
-  }
+  child_range used_children();
   const_child_range used_children() const {
-return const_child_range(const_child_iterator(), const_child_iterator());
+auto Children = const_cast(this)->used_children();
+return const_child_range(Children.begin(), Children.end());
   }
 
   static bool classof(const OMPClause *T) {

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=374810=374809=374810=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon Oct 14 12:29:52 2019
@@ -3275,6 +3275,7 @@ bool RecursiveASTVisitor::Visit
 template 
 bool RecursiveASTVisitor::VisitOMPGrainsizeClause(
 OMPGrainsizeClause *C) {
+  TRY_TO(VisitOMPClauseWithPreInit(C));
   TRY_TO(TraverseStmt(C->getGrainsize()));
   return true;
 }

Modified: cfe/trunk/lib/AST/OpenMPClause.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/OpenMPClause.cpp?rev=374810=374809=374810=diff
==
--- cfe/trunk/lib/AST/OpenMPClause.cpp (original)
+++ cfe/trunk/lib/AST/OpenMPClause.cpp Mon Oct 14 12:29:52 2019
@@ -84,6 +84,8 @@ const OMPClauseWithPreInit *OMPClauseWit
 return static_cast(C);
   case OMPC_device:
 return static_cast(C);
+  case OMPC_grainsize:
+return static_cast(C);
   case OMPC_default:
   case OMPC_proc_bind:
   case OMPC_final:
@@ -113,7 +115,6 @@ const OMPClauseWithPreInit *OMPClauseWit
   case OMPC_simd:
   case OMPC_map:
   case OMPC_priority:
-  case OMPC_grainsize:
   case OMPC_nogroup:
   case OMPC_num_tasks:
   case OMPC_hint:
@@ -234,6 +235,12 @@ OMPClause::child_range OMPIfClause::used
   return child_range(,  + 1);
 }
 
+OMPClause::child_range OMPGrainsizeClause::used_children() {
+  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
+return child_range(C, C + 1);
+  return child_range(,  + 

r374787 - [OPENMP]Fix codegen for private variably length vars in combined

2019-10-14 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Oct 14 09:44:01 2019
New Revision: 374787

URL: http://llvm.org/viewvc/llvm-project?rev=374787=rev
Log:
[OPENMP]Fix codegen for private variably length vars in combined
constructs.

If OpenMP construct includes several capturing regions and the variable
is declared as private, the length of the inner variable length array is
not captured in outer captured regions, only in the innermost region.
Patch fixes this bug.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/target_teams_codegen.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=374787=374786=374787=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Oct 14 09:44:01 2019
@@ -9067,6 +9067,10 @@ private:
   void adjustOpenMPTargetScopeIndex(unsigned ,
 unsigned Level) const;
 
+  /// Returns the number of scopes associated with the construct on the given
+  /// OpenMP level.
+  int getNumberOfConstructScopes(unsigned Level) const;
+
   /// Push new OpenMP function region for non-capturing function.
   void pushOpenMPFunctionRegion();
 

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=374787=374786=374787=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Oct 14 09:44:01 2019
@@ -16092,7 +16092,25 @@ bool Sema::tryCaptureVariable(
 // target region should not be captured outside the scope of the 
region.
 if (RSI->CapRegionKind == CR_OpenMP) {
   bool IsOpenMPPrivateDecl = isOpenMPPrivateDecl(Var, 
RSI->OpenMPLevel);
-  auto IsTargetCap = !IsOpenMPPrivateDecl &&
+  // If the variable is private (i.e. not captured) and has variably
+  // modified type, we still need to capture the type for correct
+  // codegen in all regions, associated with the construct. Currently,
+  // it is captured in the innermost captured region only.
+  if (IsOpenMPPrivateDecl && Var->getType()->isVariablyModifiedType()) 
{
+QualType QTy = Var->getType();
+if (ParmVarDecl *PVD = dyn_cast_or_null(Var))
+  QTy = PVD->getOriginalType();
+for (int I = 1, E = getNumberOfConstructScopes(RSI->OpenMPLevel);
+ I < E; ++I) {
+  auto *OuterRSI = cast(
+  FunctionScopes[FunctionScopesIndex - I]);
+  assert(RSI->OpenMPLevel == OuterRSI->OpenMPLevel &&
+ "Wrong number of captured regions associated with the "
+ "OpenMP construct.");
+  captureVariablyModifiedType(Context, QTy, OuterRSI);
+}
+  }
+  bool IsTargetCap = !IsOpenMPPrivateDecl &&
  isOpenMPTargetCapturedDecl(Var, RSI->OpenMPLevel);
   // When we detect target captures we are looking from inside the
   // target region, therefore we need to propagate the capture from the

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=374787=374786=374787=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon Oct 14 09:44:01 2019
@@ -3435,6 +3435,10 @@ void Sema::ActOnOpenMPRegionStart(OpenMP
   }
 }
 
+int Sema::getNumberOfConstructScopes(unsigned Level) const {
+  return getOpenMPCaptureLevels(DSAStack->getDirective(Level));
+}
+
 int Sema::getOpenMPCaptureLevels(OpenMPDirectiveKind DKind) {
   SmallVector CaptureRegions;
   getOpenMPCaptureRegions(CaptureRegions, DKind);

Modified: cfe/trunk/test/OpenMP/target_teams_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_codegen.cpp?rev=374787=374786=374787=diff
==
--- cfe/trunk/test/OpenMP/target_teams_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/target_teams_codegen.cpp Mon Oct 14 09:44:01 2019
@@ -86,6 +86,7 @@
 // TCHECK: @{{.+}} = weak constant [[ENTTY]]
 // TCHECK: @{{.+}} = weak constant [[ENTTY]]
 // TCHECK: @{{.+}} = weak constant [[ENTTY]]
+// TCHECK: @{{.+}} = weak constant [[ENTTY]]
 // TCHECK-NOT: @{{.+}} = weak constant [[ENTTY]]
 
 // Check if offloading descriptor is created.
@@ -341,6 +342,13 @@ int foo(int n) {
 d.Y += 1;
   }
 
+  const int nn = 0;
+  #pragma omp target teams shared(nn)
+  #pragma omp parallel firstprivate(nn)
+  (void)nn;
+  #pragma omp target teams firstprivate(nn)
+  #pragma omp parallel shared(nn)
+  

r374438 - [OPENMP]Update doc for supported constructs, NFC.

2019-10-10 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct 10 13:15:54 2019
New Revision: 374438

URL: http://llvm.org/viewvc/llvm-project?rev=374438=rev
Log:
[OPENMP]Update doc for supported constructs, NFC.

Modified:
cfe/trunk/docs/OpenMPSupport.rst

Modified: cfe/trunk/docs/OpenMPSupport.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/OpenMPSupport.rst?rev=374438=374437=374438=diff
==
--- cfe/trunk/docs/OpenMPSupport.rst (original)
+++ cfe/trunk/docs/OpenMPSupport.rst Thu Oct 10 13:15:54 2019
@@ -179,7 +179,7 @@ implementation.
 
+--+--+--+---+
 | task extension   | combined taskloop constructs  
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+
-| task extension   | master taskloop   
   | :none:`unclaimed`| 
  |
+| task extension   | master taskloop   
   | :good:`done` | 
  |
 
+--+--+--+---+
 | task extension   | parallel master taskloop  
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r374387 - [OPENMP50]Support for declare variant directive for NVPTX target.

2019-10-10 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct 10 10:28:10 2019
New Revision: 374387

URL: http://llvm.org/viewvc/llvm-project?rev=374387=rev
Log:
[OPENMP50]Support for declare variant directive for NVPTX target.

NVPTX does not support global aliases. Instead, we have to copy the full
body of the variant function for the original function.

Added:

cfe/trunk/test/OpenMP/nvptx_declare_variant_implementation_vendor_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=374387=374386=374387=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct 10 10:28:10 2019
@@ -1264,9 +1264,10 @@ CGOpenMPRuntime::CGOpenMPRuntime(CodeGen
   loadOffloadInfoMetadata();
 }
 
-static bool tryEmitAlias(CodeGenModule , const GlobalDecl ,
- const GlobalDecl , llvm::GlobalValue *OrigAddr,
- bool IsForDefinition) {
+bool CGOpenMPRuntime::tryEmitDeclareVariant(const GlobalDecl ,
+const GlobalDecl ,
+llvm::GlobalValue *OrigAddr,
+bool IsForDefinition) {
   // Emit at least a definition for the aliasee if the the address of the
   // original function is requested.
   if (IsForDefinition || OrigAddr)
@@ -1327,8 +1328,8 @@ void CGOpenMPRuntime::clear() {
 StringRef MangledName = CGM.getMangledName(Pair.second.second);
 llvm::GlobalValue *Addr = CGM.GetGlobalValue(MangledName);
 // If not able to emit alias, just emit original declaration.
-(void)tryEmitAlias(CGM, Pair.second.first, Pair.second.second, Addr,
-   /*IsForDefinition=*/false);
+(void)tryEmitDeclareVariant(Pair.second.first, Pair.second.second, Addr,
+/*IsForDefinition=*/false);
   }
 }
 
@@ -11273,7 +11274,7 @@ bool CGOpenMPRuntime::emitDeclareVariant
   if (NewFD == D)
 return false;
   GlobalDecl NewGD = GD.getWithDecl(NewFD);
-  if (tryEmitAlias(CGM, NewGD, GD, Orig, IsForDefinition)) {
+  if (tryEmitDeclareVariant(NewGD, GD, Orig, IsForDefinition)) {
 DeferredVariantFunction.erase(D);
 return true;
   }

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=374387=374386=374387=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Thu Oct 10 10:28:10 2019
@@ -291,6 +291,17 @@ protected:
   /// default location.
   virtual unsigned getDefaultLocationReserved2Flags() const { return 0; }
 
+  /// Tries to emit declare variant function for \p OldGD from \p NewGD.
+  /// \param OrigAddr LLVM IR value for \p OldGD.
+  /// \param IsForDefinition true, if requested emission for the definition of
+  /// \p OldGD.
+  /// \returns true, was able to emit a definition function for \p OldGD, which
+  /// points to \p NewGD.
+  virtual bool tryEmitDeclareVariant(const GlobalDecl ,
+ const GlobalDecl ,
+ llvm::GlobalValue *OrigAddr,
+ bool IsForDefinition);
+
   /// Returns default flags for the barriers depending on the directive, for
   /// which this barier is going to be emitted.
   static unsigned getDefaultFlagsForBarriers(OpenMPDirectiveKind Kind);

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=374387=374386=374387=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Thu Oct 10 10:28:10 2019
@@ -1895,6 +1895,19 @@ unsigned CGOpenMPRuntimeNVPTX::getDefaul
   llvm_unreachable("Unknown flags are requested.");
 }
 
+bool CGOpenMPRuntimeNVPTX::tryEmitDeclareVariant(const GlobalDecl ,
+ const GlobalDecl ,
+ llvm::GlobalValue *OrigAddr,
+ bool IsForDefinition) {
+  // Emit the function in OldGD with the body from NewGD, if NewGD is defined.
+  auto *NewFD = cast(NewGD.getDecl());
+  if (NewFD->isDefined()) {
+CGM.emitOpenMPDeviceFunctionRedefinition(OldGD, NewGD, OrigAddr);
+return true;
+  }
+  return false;
+}
+
 

r374363 - [OPENMP50]Register vendor name only once in vendor context selector.

2019-10-10 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct 10 08:15:26 2019
New Revision: 374363

URL: http://llvm.org/viewvc/llvm-project?rev=374363=rev
Log:
[OPENMP50]Register vendor name only once in vendor context selector.

No need to store multiple copies of the same vendor names in the context
selector, keep only single copy.

Modified:
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/test/OpenMP/declare_variant_ast_print.c
cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp

Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=374363=374362=374363=diff
==
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Thu Oct 10 08:15:26 2019
@@ -17,6 +17,7 @@
 #include "clang/Parse/RAIIObjectsForParser.h"
 #include "clang/Sema/Scope.h"
 #include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/UniqueVector.h"
 
 using namespace clang;
 
@@ -853,7 +854,7 @@ static void parseImplementationSelector(
 (void)T.expectAndConsume(diag::err_expected_lparen_after,
  CtxSelectorName.data());
 const ExprResult Score = parseContextScore(P);
-SmallVector, 4> Vendors;
+llvm::UniqueVector> Vendors;
 do {
   // Parse .
   StringRef VendorName;
@@ -862,7 +863,7 @@ static void parseImplementationSelector(
 VendorName = P.getPreprocessor().getSpelling(P.getCurToken(), Buffer);
 (void)P.ConsumeToken();
 if (!VendorName.empty())
-  Vendors.push_back(VendorName);
+  Vendors.insert(VendorName);
   } else {
 P.Diag(Tok.getLocation(), diag::err_omp_declare_variant_item_expected)
 << "vendor identifier"
@@ -878,10 +879,10 @@ static void parseImplementationSelector(
 (void)T.consumeClose();
 if (!Vendors.empty()) {
   SmallVector ImplVendors(Vendors.size());
-  for (int I = 0, E = Vendors.size(); I < E; ++I)
-ImplVendors[I] = Vendors[I];
+  llvm::copy(Vendors, ImplVendors.begin());
   Sema::OpenMPDeclareVariantCtsSelectorData Data(
-  OMPDeclareVariantAttr::CtxSetImplementation, CSKind, ImplVendors,
+  OMPDeclareVariantAttr::CtxSetImplementation, CSKind,
+  llvm::makeMutableArrayRef(ImplVendors.begin(), ImplVendors.size()),
   Score);
   Callback(SourceRange(Loc, Tok.getLocation()), Data);
 }

Modified: cfe/trunk/test/OpenMP/declare_variant_ast_print.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_variant_ast_print.c?rev=374363=374362=374363=diff
==
--- cfe/trunk/test/OpenMP/declare_variant_ast_print.c (original)
+++ cfe/trunk/test/OpenMP/declare_variant_ast_print.c Thu Oct 10 08:15:26 2019
@@ -11,7 +11,7 @@ int foo(void);
 #pragma omp declare variant(foo) match(implementation={vendor(llvm)})
 #pragma omp declare variant(foo) match(implementation={vendor(llvm), xxx})
 #pragma omp declare variant(foo) match(implementation={vendor(unknown)})
-#pragma omp declare variant(foo) match(implementation={vendor(score(5): ibm, 
xxx)})
+#pragma omp declare variant(foo) match(implementation={vendor(score(5): ibm, 
xxx, ibm)})
 int bar(void);
 
 // CHECK:  int foo();

Modified: cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp?rev=374363=374362=374363=diff
==
--- cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp Thu Oct 10 08:15:26 2019
@@ -40,7 +40,7 @@ int bar();
 #pragma omp declare variant(foofoo ) match(user = {condition()})
 #pragma omp declare variant(foofoo ) match(implementation={vendor(llvm)})
 #pragma omp declare variant(foofoo ) match(implementation={vendor(unknown)})
-#pragma omp declare variant(foofoo ) 
match(implementation={vendor(score(C+5): ibm, xxx)})
+#pragma omp declare variant(foofoo ) 
match(implementation={vendor(score(C+5): ibm, xxx, ibm)})
 template 
 T barbar();
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r374224 - [OPENMP50]Fix scoring of contexts with and without user provided scores.

2019-10-09 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Oct  9 13:54:06 2019
New Revision: 374224

URL: http://llvm.org/viewvc/llvm-project?rev=374224=rev
Log:
[OPENMP50]Fix scoring of contexts with and without user provided scores.

The context selector with user provided score must have higher score
than the context selector without user provided score.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=374224=374223=374224=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Oct  9 13:54:06 2019
@@ -11187,7 +11187,7 @@ static bool greaterCtxScore(ASTContext &
 return false;
   llvm::APSInt LHSVal = LHS->EvaluateKnownConstInt(Ctx);
   llvm::APSInt RHSVal = RHS->EvaluateKnownConstInt(Ctx);
-  return llvm::APSInt::compareValues(LHSVal, RHSVal) <= 0;
+  return llvm::APSInt::compareValues(LHSVal, RHSVal) >= 0;
 }
 
 namespace {
@@ -11250,7 +11250,7 @@ static const FunctionDecl *getDeclareVar
 }
 // If the attribute matches the context, find the attribute with the 
highest
 // score.
-if (SelectedAttr && (!TopMostAttr || Comparer(TopMostAttr, SelectedAttr)))
+if (SelectedAttr && (!TopMostAttr || !Comparer(TopMostAttr, SelectedAttr)))
   TopMostAttr = SelectedAttr;
   }
   if (!TopMostAttr)

Modified: 
cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp?rev=374224=374223=374224=diff
==
--- cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp 
(original)
+++ cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp Wed 
Oct  9 13:54:06 2019
@@ -8,11 +8,11 @@
 // CHECK-DAG: @_ZN16SpecSpecialFuncs6MethodEv = {{.*}}alias i32 
(%struct.SpecSpecialFuncs*), i32 (%struct.SpecSpecialFuncs*)* 
@_ZN16SpecSpecialFuncs7method_Ev
 // CHECK-DAG: @_ZN16SpecSpecialFuncs6methodEv = linkonce_odr {{.*}}alias i32 
(%struct.SpecSpecialFuncs*), i32 (%struct.SpecSpecialFuncs*)* 
@_ZN16SpecSpecialFuncs7method_Ev
 // CHECK-DAG: @_ZN12SpecialFuncs6methodEv = linkonce_odr {{.*}}alias i32 
(%struct.SpecialFuncs*), i32 (%struct.SpecialFuncs*)* 
@_ZN12SpecialFuncs7method_Ev
-// CHECK-DAG: @_Z5prio_v = {{.*}}alias i32 (), i32 ()* @_Z4priov
+// CHECK-DAG: @_Z5prio_v = {{.*}}alias i32 (), i32 ()* @_Z5prio1v
 // CHECK-DAG: @_ZL6prio1_v = internal alias i32 (), i32 ()* @_ZL5prio2v
 // CHECK-DAG: @_Z4callv = {{.*}}alias i32 (), i32 ()* @_Z4testv
 // CHECK-DAG: @_ZL9stat_usedv = internal alias i32 (), i32 ()* 
@_ZL10stat_used_v
-// CHECK-DAG: @_ZN12SpecialFuncs6MethodEv =  {{.*}}alias i32 
(%struct.SpecialFuncs*), i32 (%struct.SpecialFuncs*)* 
@_ZN12SpecialFuncs7method_Ev
+// CHECK-DAG: @_ZN12SpecialFuncs6MethodEv = {{.*}}alias i32 
(%struct.SpecialFuncs*), i32 (%struct.SpecialFuncs*)* 
@_ZN12SpecialFuncs7method_Ev
 // CHECK-DAG: @fn_linkage = {{.*}}alias i32 (), i32 ()* 
@_Z18fn_linkage_variantv
 // CHECK-DAG: @_Z11fn_linkage1v = {{.*}}alias i32 (), i32 ()* 
@fn_linkage_variant1
 // CHECK-DAG: declare {{.*}}i32 @_Z5bazzzv()


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r374107 - [OPENMP50]Multiple vendors in vendor context must be treated as logical

2019-10-08 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Oct  8 12:44:16 2019
New Revision: 374107

URL: http://llvm.org/viewvc/llvm-project?rev=374107=rev
Log:
[OPENMP50]Multiple vendors in vendor context must be treated as logical
and of vendors, not or.

If several vendors are provided in the same vendor context trait, the
context shall match only if all vendors are matching, not one of them.
This is per OpenMP 5.0, 2.3.3 Matching and Scoring Context Selectors,
all selectors in the construct, device, and implementation sets of the
context selector appear in the corresponding trait set of the OpenMP
context.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/OpenMP/declare_variant_ast_print.c
cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp
cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=374107=374106=374107=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Oct  8 12:44:16 2019
@@ -3309,7 +3309,7 @@ def OMPDeclareVariant : InheritableAttr
  [
"CtxUnknown", "CtxVendor"
  ]>,
-StringArgument<"ImplVendor", 1>
+VariadicStringArgument<"ImplVendors">
   ];
   let AdditionalMembers = [{
 void printScore(raw_ostream & OS, const PrintingPolicy ) const {
@@ -3337,7 +3337,11 @@ def OMPDeclareVariant : InheritableAttr
 case CtxVendor:
   OS << "vendor(";
   printScore(OS, Policy);
-  OS << getImplVendor();
+  if (implVendors_size() > 0) {
+OS << *implVendors(). begin();
+for (StringRef VendorName : llvm::drop_begin(implVendors(), 1))
+  OS << ", " << VendorName;
+  }
   OS << ")";
   break;
 case CtxUnknown:

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=374107=374106=374107=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Oct  8 12:44:16 2019
@@ -9110,15 +9110,15 @@ public:
 OMPDeclareVariantAttr::CtxSetUnknown;
 OMPDeclareVariantAttr::CtxSelectorType Ctx =
 OMPDeclareVariantAttr::CtxUnknown;
-StringRef ImplVendor;
+MutableArrayRef ImplVendors;
 ExprResult CtxScore;
 explicit OpenMPDeclareVariantCtsSelectorData() = default;
 explicit OpenMPDeclareVariantCtsSelectorData(
 OMPDeclareVariantAttr::CtxSelectorSetType CtxSet,
-OMPDeclareVariantAttr::CtxSelectorType Ctx, StringRef ImplVendor,
-ExprResult CtxScore)
-: CtxSet(CtxSet), Ctx(Ctx), ImplVendor(ImplVendor), CtxScore(CtxScore) 
{
-}
+OMPDeclareVariantAttr::CtxSelectorType Ctx,
+MutableArrayRef ImplVendors, ExprResult CtxScore)
+: CtxSet(CtxSet), Ctx(Ctx), ImplVendors(ImplVendors),
+  CtxScore(CtxScore) {}
   };
 
   /// Checks if the variant/multiversion functions are compatible.

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=374107=374106=374107=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Oct  8 12:44:16 2019
@@ -11172,7 +11172,8 @@ template <>
 bool checkContext(
 const OMPDeclareVariantAttr *A) {
-  return !A->getImplVendor().compare("llvm");
+  return llvm::all_of(A->implVendors(),
+  [](StringRef S) { return !S.compare_lower("llvm"); });
 }
 
 static bool greaterCtxScore(ASTContext , const Expr *LHS, const Expr *RHS) 
{

Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=374107=374106=374107=diff
==
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Tue Oct  8 12:44:16 2019
@@ -853,6 +853,7 @@ static void parseImplementationSelector(
 (void)T.expectAndConsume(diag::err_expected_lparen_after,
  CtxSelectorName.data());
 const ExprResult Score = parseContextScore(P);
+SmallVector, 4> Vendors;
 do {
   // Parse .
   StringRef VendorName;
@@ -860,18 +861,14 @@ static void parseImplementationSelector(
 Buffer.clear();
 VendorName = 

r374093 - [OPENMP50]Do not allow multiple same context traits in the same context

2019-10-08 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Oct  8 10:47:52 2019
New Revision: 374093

URL: http://llvm.org/viewvc/llvm-project?rev=374093=rev
Log:
[OPENMP50]Do not allow multiple same context traits in the same context
selector.

According to OpenMP 5.0, 2.3.2 Context Selectors, Restrictions, each
trait-selector-name can only be specified once. Added check for this
restriction.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/test/OpenMP/declare_variant_ast_print.c
cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp
cfe/trunk/test/OpenMP/declare_variant_messages.c
cfe/trunk/test/OpenMP/declare_variant_messages.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=374093=374092=374093=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Tue Oct  8 10:47:52 
2019
@@ -1215,6 +1215,11 @@ def err_omp_declare_variant_ctx_set_muti
   "context selector set '%0' is used already in the same 'omp declare variant' 
directive">;
 def note_omp_declare_variant_ctx_set_used_here : Note<
   "previously context selector set '%0' used here">;
+def err_omp_expected_comma_brace : Error<"expected '}' or ',' after '%0'">;
+def err_omp_declare_variant_ctx_mutiple_use : Error<
+  "context trait selector '%0' is used already in the same '%1' context 
selector set of 'omp declare variant' directive">;
+def note_omp_declare_variant_ctx_used_here : Note<
+  "previously context trait selector '%0' used here">;
 def warn_omp_more_one_device_type_clause : Warning<
   "more than one 'device_type' clause is specified">,
   InGroup;

Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=374093=374092=374093=diff
==
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Tue Oct  8 10:47:52 2019
@@ -815,7 +815,7 @@ static ExprResult parseContextScore(Pars
 /// 'vendor' '(' [ 'score' '('  ')' ':' ]  { ','  
}
 /// ')'
 static void parseImplementationSelector(
-Parser , SourceLocation Loc,
+Parser , SourceLocation Loc, llvm::StringMap ,
 llvm::function_ref
 Callback) {
@@ -832,6 +832,15 @@ static void parseImplementationSelector(
   }
   SmallString<16> Buffer;
   StringRef CtxSelectorName = P.getPreprocessor().getSpelling(Tok, Buffer);
+  auto Res = UsedCtx.try_emplace(CtxSelectorName, Tok.getLocation());
+  if (!Res.second) {
+// OpenMP 5.0, 2.3.2 Context Selectors, Restrictions.
+// Each trait-selector-name can only be specified once.
+P.Diag(Tok.getLocation(), diag::err_omp_declare_variant_ctx_mutiple_use)
+<< CtxSelectorName << "implementation";
+P.Diag(Res.first->getValue(), diag::note_omp_declare_variant_ctx_used_here)
+<< CtxSelectorName;
+  }
   OMPDeclareVariantAttr::CtxSelectorType CSKind =
   OMPDeclareVariantAttr::CtxUnknown;
   (void)OMPDeclareVariantAttr::ConvertStrToCtxSelectorType(CtxSelectorName,
@@ -932,17 +941,25 @@ bool Parser::parseOpenMPContextSelectors
   OMPDeclareVariantAttr::CtxSetUnknown;
   (void)OMPDeclareVariantAttr::ConvertStrToCtxSelectorSetType(
   CtxSelectorSetName, CSSKind);
-  switch (CSSKind) {
-  case OMPDeclareVariantAttr::CtxSetImplementation:
-parseImplementationSelector(*this, Loc, Callback);
-break;
-  case OMPDeclareVariantAttr::CtxSetUnknown:
-// Skip until either '}', ')', or end of directive.
-while (!SkipUntil(tok::r_brace, tok::r_paren,
-  tok::annot_pragma_openmp_end, StopBeforeMatch))
-  ;
-break;
-  }
+  llvm::StringMap UsedCtx;
+  do {
+switch (CSSKind) {
+case OMPDeclareVariantAttr::CtxSetImplementation:
+  parseImplementationSelector(*this, Loc, UsedCtx, Callback);
+  break;
+case OMPDeclareVariantAttr::CtxSetUnknown:
+  // Skip until either '}', ')', or end of directive.
+  while (!SkipUntil(tok::r_brace, tok::r_paren,
+tok::annot_pragma_openmp_end, StopBeforeMatch))
+;
+  break;
+}
+const Token PrevTok = Tok;
+if (!TryConsumeToken(tok::comma) && Tok.isNot(tok::r_brace))
+  Diag(Tok, diag::err_omp_expected_comma_brace)
+  << (PrevTok.isAnnotation() ? "context selector trait"
+ : PP.getSpelling(PrevTok));
+  } while (Tok.is(tok::identifier));
   // Parse '}'.
   (void)TBr.consumeClose();
 }

Modified: cfe/trunk/test/OpenMP/declare_variant_ast_print.c
URL: 

r374072 - [OPENMP50]Prohibit multiple context selector sets in context selectors.

2019-10-08 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Oct  8 08:56:43 2019
New Revision: 374072

URL: http://llvm.org/viewvc/llvm-project?rev=374072=rev
Log:
[OPENMP50]Prohibit multiple context selector sets in context selectors.

According to OpenMP 5.0, 2.3.2 Context Selectors, Restrictions, each
trait-set-selector-name can only be specified once. Added check to
implement this restriction.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/test/OpenMP/declare_variant_ast_print.c
cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp
cfe/trunk/test/OpenMP/declare_variant_messages.c
cfe/trunk/test/OpenMP/declare_variant_messages.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=374072=374071=374072=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Tue Oct  8 08:56:43 
2019
@@ -1211,6 +1211,10 @@ def warn_omp_declare_variant_cs_name_exp
   InGroup;
 def err_omp_declare_variant_item_expected : Error<
   "expected %0 in '%1' context selector of '%2' selector set of 'omp declare 
variant' directive">;
+def err_omp_declare_variant_ctx_set_mutiple_use : Error<
+  "context selector set '%0' is used already in the same 'omp declare variant' 
directive">;
+def note_omp_declare_variant_ctx_set_used_here : Note<
+  "previously context selector set '%0' used here">;
 def warn_omp_more_one_device_type_clause : Warning<
   "more than one 'device_type' clause is specified">,
   InGroup;

Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=374072=374071=374072=diff
==
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Tue Oct  8 08:56:43 2019
@@ -892,6 +892,7 @@ bool Parser::parseOpenMPContextSelectors
 llvm::function_ref
 Callback) {
+  llvm::StringMap UsedCtxSets;
   do {
 // Parse inner context selector set name.
 if (!Tok.is(tok::identifier)) {
@@ -901,6 +902,16 @@ bool Parser::parseOpenMPContextSelectors
 }
 SmallString<16> Buffer;
 StringRef CtxSelectorSetName = PP.getSpelling(Tok, Buffer);
+auto Res = UsedCtxSets.try_emplace(CtxSelectorSetName, Tok.getLocation());
+if (!Res.second) {
+  // OpenMP 5.0, 2.3.2 Context Selectors, Restrictions.
+  // Each trait-set-selector-name can only be specified once.
+  Diag(Tok.getLocation(), 
diag::err_omp_declare_variant_ctx_set_mutiple_use)
+  << CtxSelectorSetName;
+  Diag(Res.first->getValue(),
+   diag::note_omp_declare_variant_ctx_set_used_here)
+  << CtxSelectorSetName;
+}
 // Parse '='.
 (void)ConsumeToken();
 if (Tok.isNot(tok::equal)) {

Modified: cfe/trunk/test/OpenMP/declare_variant_ast_print.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_variant_ast_print.c?rev=374072=374071=374072=diff
==
--- cfe/trunk/test/OpenMP/declare_variant_ast_print.c (original)
+++ cfe/trunk/test/OpenMP/declare_variant_ast_print.c Tue Oct  8 08:56:43 2019
@@ -8,7 +8,7 @@ int foo(void);
 
 #pragma omp declare variant(foo) match(xxx={}, yyy={ccc})
 #pragma omp declare variant(foo) match(xxx={vvv})
-#pragma omp declare variant(foo) match(implementation={vendor(ibm)}, 
implementation={vendor(llvm)})
+#pragma omp declare variant(foo) match(implementation={vendor(llvm)})
 #pragma omp declare variant(foo) match(implementation={vendor(unknown)})
 #pragma omp declare variant(foo) match(implementation={vendor(score(5): ibm, 
xxx)})
 int bar(void);
@@ -17,6 +17,5 @@ int bar(void);
 // CHECK-NEXT: #pragma omp declare variant(foo) 
match(implementation={vendor(score(5):ibm)})
 // CHECK-NEXT: #pragma omp declare variant(foo) 
match(implementation={vendor(score(5):xxx)})
 // CHECK-NEXT: #pragma omp declare variant(foo) 
match(implementation={vendor(unknown)})
-// CHECK-NEXT: #pragma omp declare variant(foo) 
match(implementation={vendor(ibm)})
 // CHECK-NEXT: #pragma omp declare variant(foo) 
match(implementation={vendor(llvm)})
 // CHECK-NEXT: int bar();

Modified: cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp?rev=374072=374071=374072=diff
==
--- cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp Tue Oct  8 08:56:43 2019
@@ -19,12 +19,11 @@ T foofoo() { return T(); }
 
 // CHECK:  #pragma omp declare variant(foofoo) 

r374057 - [OPENMP50]Allow functions in declare variant directive to have different

2019-10-08 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Oct  8 07:56:20 2019
New Revision: 374057

URL: http://llvm.org/viewvc/llvm-project?rev=374057=rev
Log:
[OPENMP50]Allow functions in declare variant directive to have different
C linkage.

After some discussion with OpenMP developers, it was decided that the
functions with the different C linkage can be used in declare variant
directive.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp
cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp
cfe/trunk/test/OpenMP/declare_variant_messages.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=374057=374056=374057=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Oct  8 07:56:20 2019
@@ -9128,7 +9128,7 @@ public:
   const PartialDiagnosticAt ,
   const PartialDiagnosticAt ,
   const PartialDiagnosticAt , bool TemplatesSupported,
-  bool ConstexprSupported);
+  bool ConstexprSupported, bool CLinkageMayDiffer);
 
   /// Function tries to capture lambda's captured variables in the OpenMP 
region
   /// before the original lambda is captured.

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=374057=374056=374057=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Oct  8 07:56:20 2019
@@ -9685,7 +9685,7 @@ bool Sema::areMultiversionVariantFunctio
 const PartialDiagnosticAt ,
 const PartialDiagnosticAt ,
 const PartialDiagnosticAt , bool TemplatesSupported,
-bool ConstexprSupported) {
+bool ConstexprSupported, bool CLinkageMayDiffer) {
   enum DoesntSupport {
 FuncTemplates = 0,
 VirtFuncs = 1,
@@ -9778,7 +9778,7 @@ bool Sema::areMultiversionVariantFunctio
 if (OldFD->getStorageClass() != NewFD->getStorageClass())
   return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << StorageClass;
 
-if (OldFD->isExternC() != NewFD->isExternC())
+if (!CLinkageMayDiffer && OldFD->isExternC() != NewFD->isExternC())
   return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << Linkage;
 
 if (CheckEquivalentExceptionSpec(
@@ -9831,7 +9831,8 @@ static bool CheckMultiVersionAdditionalR
   PartialDiagnosticAt(NewFD->getLocation(),
   S.PDiag(diag::err_multiversion_diff)),
   /*TemplatesSupported=*/false,
-  /*ConstexprSupported=*/!IsCPUSpecificCPUDispatchMVType);
+  /*ConstexprSupported=*/!IsCPUSpecificCPUDispatchMVType,
+  /*CLinkageMayDiffer=*/false);
 }
 
 /// Check the validity of a multiversion function declaration that is the

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=374057=374056=374057=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Oct  8 07:56:20 2019
@@ -5109,7 +5109,8 @@ Sema::checkOpenMPDeclareVariantFunction(
   PartialDiagnosticAt(VariantRef->getExprLoc(),
   PDiag(diag::err_omp_declare_variant_diff)
   << FD->getLocation()),
-  /*TemplatesSupported=*/true, /*ConstexprSupported=*/false))
+  /*TemplatesSupported=*/true, /*ConstexprSupported=*/false,
+  /*CLinkageMayDiffer=*/true))
 return None;
   return std::make_pair(FD, cast(DRE));
 }

Modified: cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp?rev=374057=374056=374057=diff
==
--- cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp Tue Oct  8 07:56:20 2019
@@ -201,3 +201,22 @@ void ba() {
   s.foo1();
   static_f();
 }
+
+// CHECK: int fn_linkage_variant();
+// CHECK: extern "C" {
+// CHECK: #pragma omp declare variant(fn_linkage_variant) 
match(implementation={vendor(xxx)})
+// CHECK: int fn_linkage();
+// CHECK: }
+int fn_linkage_variant();
+extern "C" {
+#pragma omp declare variant(fn_linkage_variant) match(implementation = 
{vendor(xxx)})
+int fn_linkage();
+}
+
+// CHECK: extern "C" int fn_linkage_variant1()
+// CHECK: #pragma omp declare variant(fn_linkage_variant1) 
match(implementation={vendor(xxx)})
+// CHECK: int fn_linkage1();
+extern "C" int fn_linkage_variant1();
+#pragma omp declare variant(fn_linkage_variant1) match(implementation = 
{vendor(xxx)})
+int fn_linkage1();
+


r373952 - [OPENMP]Fix caonical->canonical, NFC.

2019-10-07 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Oct  7 12:57:40 2019
New Revision: 373952

URL: http://llvm.org/viewvc/llvm-project?rev=373952=rev
Log:
[OPENMP]Fix caonical->canonical, NFC.

Fixed typo.

Modified:
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=373952=373951=373952=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Mon Oct  7 12:57:40 2019
@@ -1092,7 +1092,7 @@ public:
   Body = For->getBody();
 } else {
   assert(isa(Body) &&
- "Expected caonical for loop or range-based for loop.");
+ "Expected canonical for loop or range-based for loop.");
   Body = cast(Body)->getBody();
 }
 for (unsigned Cnt = 1; Cnt < CollapsedNum; ++Cnt) {
@@ -1101,7 +1101,7 @@ public:
 Body = For->getBody();
   } else {
 assert(isa(Body) &&
-   "Expected caonical for loop or range-based for loop.");
+   "Expected canonical for loop or range-based for loop.");
 Body = cast(Body)->getBody();
   }
 }

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=373952=373951=373952=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Mon Oct  7 12:57:40 2019
@@ -151,7 +151,7 @@ class OMPLoopScope : public CodeGenFunct
 Body = For->getBody();
   } else {
 assert(isa(Body) &&
-   "Expected caonical for loop or range-based for loop.");
+   "Expected canonical for loop or range-based for loop.");
 auto *CXXFor = cast(Body);
 if (const Stmt *Init = CXXFor->getInit())
   CGF.EmitStmt(Init);
@@ -1377,7 +1377,7 @@ void CodeGenFunction::EmitOMPLoopBody(co
   Body = For->getBody();
 } else {
   assert(isa(Body) &&
- "Expected caonical for loop or range-based for loop.");
+ "Expected canonical for loop or range-based for loop.");
   auto *CXXFor = cast(Body);
   EmitStmt(CXXFor->getLoopVarStmt());
   Body = CXXFor->getBody();


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r373939 - [OPENMP50]Treat range-based for as canonical loop.

2019-10-07 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Oct  7 11:54:57 2019
New Revision: 373939

URL: http://llvm.org/viewvc/llvm-project?rev=373939=rev
Log:
[OPENMP50]Treat range-based for as canonical loop.

According to OpenMP 5.0, range-based for is also considered as a
canonical form of loops.

Modified:
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/distribute_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/for_ast_print.cpp
cfe/trunk/test/OpenMP/for_loop_messages.cpp
cfe/trunk/test/OpenMP/for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_codegen.cpp
cfe/trunk/test/OpenMP/parallel_for_loop_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/simd_loop_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_loop_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/target_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_loop_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_loop_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/taskloop_loop_messages.cpp
cfe/trunk/test/OpenMP/taskloop_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_loop_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_loop_messages.cpp

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=373939=373938=373939=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Mon Oct  7 11:54:57 2019
@@ -17,6 +17,7 @@
 #include "clang/AST/Expr.h"
 #include "clang/AST/OpenMPClause.h"
 #include "clang/AST/Stmt.h"
+#include "clang/AST/StmtCXX.h"
 #include "clang/Basic/OpenMPKinds.h"
 #include "clang/Basic/SourceLocation.h"
 
@@ -1087,10 +1088,22 @@ public:
 // This relies on the loop form is already checked by Sema.
 const Stmt *Body =
 getInnermostCapturedStmt()->getCapturedStmt()->IgnoreContainers();
-Body = cast(Body)->getBody();
+if (auto *For = dyn_cast(Body)) {
+  Body = For->getBody();
+} else {
+  assert(isa(Body) &&
+ "Expected caonical for loop or range-based for loop.");
+  Body = cast(Body)->getBody();
+}
 for (unsigned Cnt = 1; Cnt < CollapsedNum; ++Cnt) {
   Body = Body->IgnoreContainers();
-  Body = cast(Body)->getBody();
+  if (auto *For = dyn_cast(Body)) {
+Body = For->getBody();
+  } else {
+assert(isa(Body) &&
+   "Expected caonical for loop or range-based for loop.");
+Body = cast(Body)->getBody();
+  }
 }
 return Body;
   }

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=373939=373938=373939=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Oct  7 11:54:57 2019
@@ -9154,6 +9154,10 @@ public:
   /// construct.
   void startOpenMPLoop();
 
+  /// If the current region is a range loop-based region, mark the start of the
+  /// loop construct.
+  void startOpenMPCXXRangeFor();
+
   /// Check if the specified variable is used in 'private' clause.
   /// \param Level Relative level of nested OpenMP construct for that the check
   /// is performed.

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=373939=373938=373939=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Mon Oct  7 11:54:57 2019
@@ -142,6 +142,24 @@ class OMPLoopScope : public CodeGenFunct
   }
 }
 (void)PreCondVars.apply(CGF);
+// Emit init, __range and __end variables for C++ range loops.
+const Stmt *Body =
+S.getInnermostCapturedStmt()->getCapturedStmt()->IgnoreContainers();
+for (unsigned Cnt = 0; Cnt < S.getCollapsedNumber(); ++Cnt) {
+  Body = Body->IgnoreContainers();
+  if (auto *For = dyn_cast(Body)) {
+Body = For->getBody();
+  } else {
+assert(isa(Body) &&
+   "Expected caonical for loop or range-based for loop.");
+auto *CXXFor = 

r373756 - [OPENMP50]Suppport for multiple vendors in the same vendor context

2019-10-04 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Oct  4 08:58:45 2019
New Revision: 373756

URL: http://llvm.org/viewvc/llvm-project?rev=373756=rev
Log:
[OPENMP50]Suppport for multiple vendors in the same vendor context
selector.

According to OpenMP 5.0, multiple vendors could be specified in the
vendor context selector via ',' as a separator.

Modified:
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/test/OpenMP/declare_variant_ast_print.c
cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp
cfe/trunk/test/OpenMP/declare_variant_messages.c
cfe/trunk/test/OpenMP/declare_variant_messages.cpp

Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=373756=373755=373756=diff
==
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Fri Oct  4 08:58:45 2019
@@ -812,10 +812,13 @@ static ExprResult parseContextScore(Pars
 }
 
 /// Parse context selector for 'implementation' selector set:
-/// 'vendor' '('  ')'
-static void
-parseImplementationSelector(Parser ,
-Sema::OpenMPDeclareVariantCtsSelectorData ) {
+/// 'vendor' '(' [ 'score' '('  ')' ':' ]  { ','  
}
+/// ')'
+static void parseImplementationSelector(
+Parser , SourceLocation Loc,
+llvm::function_ref
+Callback) {
   const Token  = P.getCurToken();
   // Parse inner context selector set name, if any.
   if (!Tok.is(tok::identifier)) {
@@ -840,20 +843,33 @@ parseImplementationSelector(Parser ,
 BalancedDelimiterTracker T(P, tok::l_paren, tok::annot_pragma_openmp_end);
 (void)T.expectAndConsume(diag::err_expected_lparen_after,
  CtxSelectorName.data());
-Data.CtxScore = parseContextScore(P);
-// Parse .
-StringRef VendorName;
-if (Tok.is(tok::identifier)) {
-  VendorName = P.getPreprocessor().getSpelling(P.getCurToken(), Buffer);
-  (void)P.ConsumeToken();
-} else {
-  P.Diag(Tok.getLocation(), diag::err_omp_declare_variant_item_expected)
-  << "vendor identifier" << "vendor" << "implementation";
-}
+const ExprResult Score = parseContextScore(P);
+do {
+  // Parse .
+  StringRef VendorName;
+  if (Tok.is(tok::identifier)) {
+Buffer.clear();
+VendorName = P.getPreprocessor().getSpelling(P.getCurToken(), Buffer);
+(void)P.ConsumeToken();
+  } else {
+P.Diag(Tok.getLocation(), diag::err_omp_declare_variant_item_expected)
+<< "vendor identifier"
+<< "vendor"
+<< "implementation";
+  }
+  if (!VendorName.empty()) {
+Sema::OpenMPDeclareVariantCtsSelectorData Data(
+OMPDeclareVariantAttr::CtxSetImplementation, CSKind, VendorName,
+Score);
+Callback(SourceRange(Loc, Tok.getLocation()), Data);
+  }
+  if (!P.TryConsumeToken(tok::comma) && Tok.isNot(tok::r_paren)) {
+P.Diag(Tok, diag::err_expected_punc)
+<< (VendorName.empty() ? "vendor name" : VendorName);
+  }
+} while (Tok.is(tok::identifier));
 // Parse ')'.
 (void)T.consumeClose();
-if (!VendorName.empty())
-  Data.ImplVendor = VendorName;
 break;
   }
   case OMPDeclareVariantAttr::CtxUnknown:
@@ -865,8 +881,6 @@ parseImplementationSelector(Parser ,
   ;
 return;
   }
-  Data.CtxSet = OMPDeclareVariantAttr::CtxSetImplementation;
-  Data.Ctx = CSKind;
 }
 
 /// Parses clauses for 'declare variant' directive.
@@ -897,7 +911,6 @@ bool Parser::parseOpenMPContextSelectors
 (void)ConsumeToken();
 // TBD: add parsing of known context selectors.
 // Unknown selector - just ignore it completely.
-Sema::OpenMPDeclareVariantCtsSelectorData Data;
 {
   // Parse '{'.
   BalancedDelimiterTracker TBr(*this, tok::l_brace,
@@ -910,7 +923,7 @@ bool Parser::parseOpenMPContextSelectors
   CtxSelectorSetName, CSSKind);
   switch (CSSKind) {
   case OMPDeclareVariantAttr::CtxSetImplementation:
-parseImplementationSelector(*this, Data);
+parseImplementationSelector(*this, Loc, Callback);
 break;
   case OMPDeclareVariantAttr::CtxSetUnknown:
 // Skip until either '}', ')', or end of directive.
@@ -922,7 +935,6 @@ bool Parser::parseOpenMPContextSelectors
   // Parse '}'.
   (void)TBr.consumeClose();
 }
-Callback(SourceRange(Loc, Tok.getLocation()), Data);
 // Consume ','
 if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::annot_pragma_openmp_end))
   (void)ExpectAndConsume(tok::comma);

Modified: cfe/trunk/test/OpenMP/declare_variant_ast_print.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_variant_ast_print.c?rev=373756=373755=373756=diff
==
--- cfe/trunk/test/OpenMP/declare_variant_ast_print.c (original)
+++ 

Re: r373661 - [OPENMP50]Codegen support for scores in context selectors.

2019-10-03 Thread Alexey Bataev via cfe-commits
Committed the fix for the test.

Best regards,
Alexey Bataev

3 окт. 2019 г., в 17:48, Nico Weber  написал(а):


Looks like this fails on Windows: 
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/11207/steps/stage%201%20check/logs/stdio

On Thu, Oct 3, 2019 at 4:47 PM Alexey Bataev via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: abataev
Date: Thu Oct  3 13:49:48 2019
New Revision: 373661

URL: http://llvm.org/viewvc/llvm-project?rev=373661=rev
Log:
[OPENMP50]Codegen support for scores in context selectors.

If the context selector has associated score and several contexts
selectors matches current context, the function with the highest score
must be selected.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=373661=373660=373661=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct  3 13:49:48 2019
@@ -11175,37 +11175,87 @@ bool checkContextgetImplVendor().compare("llvm");
 }

+static bool greaterCtxScore(ASTContext , const Expr *LHS, const Expr *RHS) 
{
+  // If both scores are unknown, choose the very first one.
+  if (!LHS && !RHS)
+return true;
+  // If only one is known, return this one.
+  if (LHS && !RHS)
+return true;
+  if (!LHS && RHS)
+return false;
+  llvm::APSInt LHSVal = LHS->EvaluateKnownConstInt(Ctx);
+  llvm::APSInt RHSVal = RHS->EvaluateKnownConstInt(Ctx);
+  return llvm::APSInt::compareValues(LHSVal, RHSVal) <= 0;
+}
+
+namespace {
+/// Comparator for the priority queue for context selector.
+class OMPDeclareVariantAttrComparer
+: public std::greater {
+private:
+  ASTContext 
+
+public:
+  OMPDeclareVariantAttrComparer(ASTContext ) : Ctx(Ctx) {}
+  bool operator()(const OMPDeclareVariantAttr *LHS,
+  const OMPDeclareVariantAttr *RHS) const {
+const Expr *LHSExpr = nullptr;
+const Expr *RHSExpr = nullptr;
+if (LHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  LHSExpr = LHS->getScore();
+if (RHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  RHSExpr = RHS->getScore();
+return greaterCtxScore(Ctx, LHSExpr, RHSExpr);
+  }
+};
+} // anonymous namespace
+
 /// Finds the variant function that matches current context with its context
 /// selector.
-static const FunctionDecl *getDeclareVariantFunction(const FunctionDecl *FD) {
+static const FunctionDecl *getDeclareVariantFunction(ASTContext ,
+ const FunctionDecl *FD) {
   if (!FD->hasAttrs() || !FD->hasAttr())
 return FD;
   // Iterate through all DeclareVariant attributes and check context selectors.
-  SmallVector MatchingAttributes;
-  for (const auto * A : FD->specific_attrs()) {
+  auto & = [](const OMPDeclareVariantAttr *LHS,
+   const OMPDeclareVariantAttr *RHS) {
+const Expr *LHSExpr = nullptr;
+const Expr *RHSExpr = nullptr;
+if (LHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  LHSExpr = LHS->getScore();
+if (RHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  RHSExpr = RHS->getScore();
+return greaterCtxScore(Ctx, LHSExpr, RHSExpr);
+  };
+  const OMPDeclareVariantAttr *TopMostAttr = nullptr;
+  for (const auto *A : FD->specific_attrs()) {
+const OMPDeclareVariantAttr *SelectedAttr = nullptr;
 switch (A->getCtxSelectorSet()) {
 case OMPDeclareVariantAttr::CtxSetImplementation:
   switch (A->getCtxSelector()) {
   case OMPDeclareVariantAttr::CtxVendor:
 if (checkContext(A))
-  MatchingAttributes.push_back(A);
+  SelectedAttr = A;
 break;
   case OMPDeclareVariantAttr::CtxUnknown:
 llvm_unreachable(
-"Unknown context selector in implementation selctor set.");
+"Unknown context selector in implementation selector set.");
   }
   break;
 case OMPDeclareVariantAttr::CtxSetUnknown:
   llvm_unreachable("Unknown context selector set.");
 }
+// If the attribute matches the context, find the attribute with the 
highest
+// score.
+if (SelectedAttr && (!TopMostAttr || Comparer(TopMostAttr, SelectedAttr)))
+  TopMostAttr = SelectedAttr;
   }
-  if (MatchingAttributes.empty())
+  if (!TopMostAttr)
 return FD;
-  // TODO: implement score analysis of multiple context selectors.
-  const OMPDeclareVariantAttr *MainAttr = MatchingAttributes.front();
   return cast(
-  cast(MainAttr->getVariantFuncRef()->IgnoreParenImpCasts())
+  
cast(TopMostAttr->getVariantFuncRe

r373672 - [OPENMP]Fix the test on Windows, NFC.

2019-10-03 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct  3 15:10:33 2019
New Revision: 373672

URL: http://llvm.org/viewvc/llvm-project?rev=373672=rev
Log:
[OPENMP]Fix the test on Windows, NFC.

Modified:
cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp

Modified: 
cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp?rev=373672=373671=373672=diff
==
--- cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp 
(original)
+++ cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp Thu 
Oct  3 15:10:33 2019
@@ -8,7 +8,7 @@
 // CHECK-DAG: @_ZN16SpecSpecialFuncs6MethodEv = {{.*}}alias i32 
(%struct.SpecSpecialFuncs*), i32 (%struct.SpecSpecialFuncs*)* 
@_ZN16SpecSpecialFuncs7method_Ev
 // CHECK-DAG: @_ZN16SpecSpecialFuncs6methodEv = linkonce_odr {{.*}}alias i32 
(%struct.SpecSpecialFuncs*), i32 (%struct.SpecSpecialFuncs*)* 
@_ZN16SpecSpecialFuncs7method_Ev
 // CHECK-DAG: @_ZN12SpecialFuncs6methodEv = linkonce_odr {{.*}}alias i32 
(%struct.SpecialFuncs*), i32 (%struct.SpecialFuncs*)* 
@_ZN12SpecialFuncs7method_Ev
-// CHECK-DAG: @_Z5prio_v = alias i32 (), i32 ()* @_Z4priov
+// CHECK-DAG: @_Z5prio_v = {{.*}}alias i32 (), i32 ()* @_Z4priov
 // CHECK-DAG: @_ZL6prio1_v = internal alias i32 (), i32 ()* @_ZL5prio2v
 // CHECK-DAG: @_Z4callv = {{.*}}alias i32 (), i32 ()* @_Z4testv
 // CHECK-DAG: @_ZL9stat_usedv = internal alias i32 (), i32 ()* 
@_ZL10stat_used_v


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r373661 - [OPENMP50]Codegen support for scores in context selectors.

2019-10-03 Thread Alexey Bataev via cfe-commits
Yep, I see. Will fix in couple minutes

Best regards,
Alexey Bataev

3 окт. 2019 г., в 17:48, Nico Weber  написал(а):


Looks like this fails on Windows: 
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/11207/steps/stage%201%20check/logs/stdio

On Thu, Oct 3, 2019 at 4:47 PM Alexey Bataev via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: abataev
Date: Thu Oct  3 13:49:48 2019
New Revision: 373661

URL: http://llvm.org/viewvc/llvm-project?rev=373661=rev
Log:
[OPENMP50]Codegen support for scores in context selectors.

If the context selector has associated score and several contexts
selectors matches current context, the function with the highest score
must be selected.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=373661=373660=373661=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct  3 13:49:48 2019
@@ -11175,37 +11175,87 @@ bool checkContextgetImplVendor().compare("llvm");
 }

+static bool greaterCtxScore(ASTContext , const Expr *LHS, const Expr *RHS) 
{
+  // If both scores are unknown, choose the very first one.
+  if (!LHS && !RHS)
+return true;
+  // If only one is known, return this one.
+  if (LHS && !RHS)
+return true;
+  if (!LHS && RHS)
+return false;
+  llvm::APSInt LHSVal = LHS->EvaluateKnownConstInt(Ctx);
+  llvm::APSInt RHSVal = RHS->EvaluateKnownConstInt(Ctx);
+  return llvm::APSInt::compareValues(LHSVal, RHSVal) <= 0;
+}
+
+namespace {
+/// Comparator for the priority queue for context selector.
+class OMPDeclareVariantAttrComparer
+: public std::greater {
+private:
+  ASTContext 
+
+public:
+  OMPDeclareVariantAttrComparer(ASTContext ) : Ctx(Ctx) {}
+  bool operator()(const OMPDeclareVariantAttr *LHS,
+  const OMPDeclareVariantAttr *RHS) const {
+const Expr *LHSExpr = nullptr;
+const Expr *RHSExpr = nullptr;
+if (LHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  LHSExpr = LHS->getScore();
+if (RHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  RHSExpr = RHS->getScore();
+return greaterCtxScore(Ctx, LHSExpr, RHSExpr);
+  }
+};
+} // anonymous namespace
+
 /// Finds the variant function that matches current context with its context
 /// selector.
-static const FunctionDecl *getDeclareVariantFunction(const FunctionDecl *FD) {
+static const FunctionDecl *getDeclareVariantFunction(ASTContext ,
+ const FunctionDecl *FD) {
   if (!FD->hasAttrs() || !FD->hasAttr())
 return FD;
   // Iterate through all DeclareVariant attributes and check context selectors.
-  SmallVector MatchingAttributes;
-  for (const auto * A : FD->specific_attrs()) {
+  auto & = [](const OMPDeclareVariantAttr *LHS,
+   const OMPDeclareVariantAttr *RHS) {
+const Expr *LHSExpr = nullptr;
+const Expr *RHSExpr = nullptr;
+if (LHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  LHSExpr = LHS->getScore();
+if (RHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  RHSExpr = RHS->getScore();
+return greaterCtxScore(Ctx, LHSExpr, RHSExpr);
+  };
+  const OMPDeclareVariantAttr *TopMostAttr = nullptr;
+  for (const auto *A : FD->specific_attrs()) {
+const OMPDeclareVariantAttr *SelectedAttr = nullptr;
 switch (A->getCtxSelectorSet()) {
 case OMPDeclareVariantAttr::CtxSetImplementation:
   switch (A->getCtxSelector()) {
   case OMPDeclareVariantAttr::CtxVendor:
 if (checkContext(A))
-  MatchingAttributes.push_back(A);
+  SelectedAttr = A;
 break;
   case OMPDeclareVariantAttr::CtxUnknown:
 llvm_unreachable(
-"Unknown context selector in implementation selctor set.");
+"Unknown context selector in implementation selector set.");
   }
   break;
 case OMPDeclareVariantAttr::CtxSetUnknown:
   llvm_unreachable("Unknown context selector set.");
 }
+// If the attribute matches the context, find the attribute with the 
highest
+// score.
+if (SelectedAttr && (!TopMostAttr || Comparer(TopMostAttr, SelectedAttr)))
+  TopMostAttr = SelectedAttr;
   }
-  if (MatchingAttributes.empty())
+  if (!TopMostAttr)
 return FD;
-  // TODO: implement score analysis of multiple context selectors.
-  const OMPDeclareVariantAttr *MainAttr = MatchingAttributes.front();
   return cast(
-  cast(MainAttr->getVariantFuncRef()->IgnoreParenImpCasts())
+  
cast(TopMostAttr->get

Re: r373661 - [OPENMP50]Codegen support for scores in context selectors.

2019-10-03 Thread Alexey Bataev via cfe-commits
Yep, I see. Will fix in couple minutes

Best regards,
Alexey Bataev

3 окт. 2019 г., в 17:48, Nico Weber  написал(а):


Looks like this fails on Windows: 
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/11207/steps/stage%201%20check/logs/stdio

On Thu, Oct 3, 2019 at 4:47 PM Alexey Bataev via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: abataev
Date: Thu Oct  3 13:49:48 2019
New Revision: 373661

URL: http://llvm.org/viewvc/llvm-project?rev=373661=rev
Log:
[OPENMP50]Codegen support for scores in context selectors.

If the context selector has associated score and several contexts
selectors matches current context, the function with the highest score
must be selected.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=373661=373660=373661=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct  3 13:49:48 2019
@@ -11175,37 +11175,87 @@ bool checkContextgetImplVendor().compare("llvm");
 }

+static bool greaterCtxScore(ASTContext , const Expr *LHS, const Expr *RHS) 
{
+  // If both scores are unknown, choose the very first one.
+  if (!LHS && !RHS)
+return true;
+  // If only one is known, return this one.
+  if (LHS && !RHS)
+return true;
+  if (!LHS && RHS)
+return false;
+  llvm::APSInt LHSVal = LHS->EvaluateKnownConstInt(Ctx);
+  llvm::APSInt RHSVal = RHS->EvaluateKnownConstInt(Ctx);
+  return llvm::APSInt::compareValues(LHSVal, RHSVal) <= 0;
+}
+
+namespace {
+/// Comparator for the priority queue for context selector.
+class OMPDeclareVariantAttrComparer
+: public std::greater {
+private:
+  ASTContext 
+
+public:
+  OMPDeclareVariantAttrComparer(ASTContext ) : Ctx(Ctx) {}
+  bool operator()(const OMPDeclareVariantAttr *LHS,
+  const OMPDeclareVariantAttr *RHS) const {
+const Expr *LHSExpr = nullptr;
+const Expr *RHSExpr = nullptr;
+if (LHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  LHSExpr = LHS->getScore();
+if (RHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  RHSExpr = RHS->getScore();
+return greaterCtxScore(Ctx, LHSExpr, RHSExpr);
+  }
+};
+} // anonymous namespace
+
 /// Finds the variant function that matches current context with its context
 /// selector.
-static const FunctionDecl *getDeclareVariantFunction(const FunctionDecl *FD) {
+static const FunctionDecl *getDeclareVariantFunction(ASTContext ,
+ const FunctionDecl *FD) {
   if (!FD->hasAttrs() || !FD->hasAttr())
 return FD;
   // Iterate through all DeclareVariant attributes and check context selectors.
-  SmallVector MatchingAttributes;
-  for (const auto * A : FD->specific_attrs()) {
+  auto & = [](const OMPDeclareVariantAttr *LHS,
+   const OMPDeclareVariantAttr *RHS) {
+const Expr *LHSExpr = nullptr;
+const Expr *RHSExpr = nullptr;
+if (LHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  LHSExpr = LHS->getScore();
+if (RHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  RHSExpr = RHS->getScore();
+return greaterCtxScore(Ctx, LHSExpr, RHSExpr);
+  };
+  const OMPDeclareVariantAttr *TopMostAttr = nullptr;
+  for (const auto *A : FD->specific_attrs()) {
+const OMPDeclareVariantAttr *SelectedAttr = nullptr;
 switch (A->getCtxSelectorSet()) {
 case OMPDeclareVariantAttr::CtxSetImplementation:
   switch (A->getCtxSelector()) {
   case OMPDeclareVariantAttr::CtxVendor:
 if (checkContext(A))
-  MatchingAttributes.push_back(A);
+  SelectedAttr = A;
 break;
   case OMPDeclareVariantAttr::CtxUnknown:
 llvm_unreachable(
-"Unknown context selector in implementation selctor set.");
+"Unknown context selector in implementation selector set.");
   }
   break;
 case OMPDeclareVariantAttr::CtxSetUnknown:
   llvm_unreachable("Unknown context selector set.");
 }
+// If the attribute matches the context, find the attribute with the 
highest
+// score.
+if (SelectedAttr && (!TopMostAttr || Comparer(TopMostAttr, SelectedAttr)))
+  TopMostAttr = SelectedAttr;
   }
-  if (MatchingAttributes.empty())
+  if (!TopMostAttr)
 return FD;
-  // TODO: implement score analysis of multiple context selectors.
-  const OMPDeclareVariantAttr *MainAttr = MatchingAttributes.front();
   return cast(
-  cast(MainAttr->getVariantFuncRef()->IgnoreParenImpCasts())
+  
cast(TopMostAttr->get

r373661 - [OPENMP50]Codegen support for scores in context selectors.

2019-10-03 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct  3 13:49:48 2019
New Revision: 373661

URL: http://llvm.org/viewvc/llvm-project?rev=373661=rev
Log:
[OPENMP50]Codegen support for scores in context selectors.

If the context selector has associated score and several contexts
selectors matches current context, the function with the highest score
must be selected.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=373661=373660=373661=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct  3 13:49:48 2019
@@ -11175,37 +11175,87 @@ bool checkContextgetImplVendor().compare("llvm");
 }
 
+static bool greaterCtxScore(ASTContext , const Expr *LHS, const Expr *RHS) 
{
+  // If both scores are unknown, choose the very first one.
+  if (!LHS && !RHS)
+return true;
+  // If only one is known, return this one.
+  if (LHS && !RHS)
+return true;
+  if (!LHS && RHS)
+return false;
+  llvm::APSInt LHSVal = LHS->EvaluateKnownConstInt(Ctx);
+  llvm::APSInt RHSVal = RHS->EvaluateKnownConstInt(Ctx);
+  return llvm::APSInt::compareValues(LHSVal, RHSVal) <= 0;
+}
+
+namespace {
+/// Comparator for the priority queue for context selector.
+class OMPDeclareVariantAttrComparer
+: public std::greater {
+private:
+  ASTContext 
+
+public:
+  OMPDeclareVariantAttrComparer(ASTContext ) : Ctx(Ctx) {}
+  bool operator()(const OMPDeclareVariantAttr *LHS,
+  const OMPDeclareVariantAttr *RHS) const {
+const Expr *LHSExpr = nullptr;
+const Expr *RHSExpr = nullptr;
+if (LHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  LHSExpr = LHS->getScore();
+if (RHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  RHSExpr = RHS->getScore();
+return greaterCtxScore(Ctx, LHSExpr, RHSExpr);
+  }
+};
+} // anonymous namespace
+
 /// Finds the variant function that matches current context with its context
 /// selector.
-static const FunctionDecl *getDeclareVariantFunction(const FunctionDecl *FD) {
+static const FunctionDecl *getDeclareVariantFunction(ASTContext ,
+ const FunctionDecl *FD) {
   if (!FD->hasAttrs() || !FD->hasAttr())
 return FD;
   // Iterate through all DeclareVariant attributes and check context selectors.
-  SmallVector MatchingAttributes;
-  for (const auto * A : FD->specific_attrs()) {
+  auto & = [](const OMPDeclareVariantAttr *LHS,
+   const OMPDeclareVariantAttr *RHS) {
+const Expr *LHSExpr = nullptr;
+const Expr *RHSExpr = nullptr;
+if (LHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  LHSExpr = LHS->getScore();
+if (RHS->getCtxScore() == OMPDeclareVariantAttr::ScoreSpecified)
+  RHSExpr = RHS->getScore();
+return greaterCtxScore(Ctx, LHSExpr, RHSExpr);
+  };
+  const OMPDeclareVariantAttr *TopMostAttr = nullptr;
+  for (const auto *A : FD->specific_attrs()) {
+const OMPDeclareVariantAttr *SelectedAttr = nullptr;
 switch (A->getCtxSelectorSet()) {
 case OMPDeclareVariantAttr::CtxSetImplementation:
   switch (A->getCtxSelector()) {
   case OMPDeclareVariantAttr::CtxVendor:
 if (checkContext(A))
-  MatchingAttributes.push_back(A);
+  SelectedAttr = A;
 break;
   case OMPDeclareVariantAttr::CtxUnknown:
 llvm_unreachable(
-"Unknown context selector in implementation selctor set.");
+"Unknown context selector in implementation selector set.");
   }
   break;
 case OMPDeclareVariantAttr::CtxSetUnknown:
   llvm_unreachable("Unknown context selector set.");
 }
+// If the attribute matches the context, find the attribute with the 
highest
+// score.
+if (SelectedAttr && (!TopMostAttr || Comparer(TopMostAttr, SelectedAttr)))
+  TopMostAttr = SelectedAttr;
   }
-  if (MatchingAttributes.empty())
+  if (!TopMostAttr)
 return FD;
-  // TODO: implement score analysis of multiple context selectors.
-  const OMPDeclareVariantAttr *MainAttr = MatchingAttributes.front();
   return cast(
-  cast(MainAttr->getVariantFuncRef()->IgnoreParenImpCasts())
+  
cast(TopMostAttr->getVariantFuncRef()->IgnoreParenImpCasts())
   ->getDecl());
 }
 
@@ -11216,7 +11266,7 @@ bool CGOpenMPRuntime::emitDeclareVariant
   llvm::GlobalValue *Orig = CGM.GetGlobalValue(MangledName);
   if (Orig && !Orig->isDeclaration())
 return false;
-  const FunctionDecl *NewFD = getDeclareVariantFunction(D);
+  const FunctionDecl *NewFD = getDeclareVariantFunction(CGM.getContext(), D);
   // Emit original function if it does not have declare variant attribute or 
the
   // context does not match.
   if 

r373624 - [OPENMP]Fix emission of the declare target variables in device mode.

2019-10-03 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct  3 09:46:49 2019
New Revision: 373624

URL: http://llvm.org/viewvc/llvm-project?rev=373624=rev
Log:
[OPENMP]Fix emission of the declare target variables in device mode.

Declare target variables must be emitted in device mode, target triples
can be empty in this case.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/declare_target_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=373624=373623=373624=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct  3 09:46:49 2019
@@ -2868,7 +2868,8 @@ llvm::Function *CGOpenMPRuntime::emitThr
 bool CGOpenMPRuntime::emitDeclareTargetVarDefinition(const VarDecl *VD,
  llvm::GlobalVariable 
*Addr,
  bool PerformInit) {
-  if (CGM.getLangOpts().OMPTargetTriples.empty())
+  if (CGM.getLangOpts().OMPTargetTriples.empty() &&
+  !CGM.getLangOpts().OpenMPIsDevice)
 return false;
   Optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
@@ -9806,7 +9807,8 @@ CGOpenMPRuntime::registerTargetFirstpriv
 
 void CGOpenMPRuntime::registerTargetGlobalVariable(const VarDecl *VD,
llvm::Constant *Addr) {
-  if (CGM.getLangOpts().OMPTargetTriples.empty())
+  if (CGM.getLangOpts().OMPTargetTriples.empty() &&
+  !CGM.getLangOpts().OpenMPIsDevice)
 return;
   llvm::Optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);

Modified: cfe/trunk/test/OpenMP/declare_target_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_codegen.cpp?rev=373624=373623=373624=diff
==
--- cfe/trunk/test/OpenMP/declare_target_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_target_codegen.cpp Thu Oct  3 09:46:49 2019
@@ -1,29 +1,22 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -emit-pch -o %t
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - 
| FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc 
-emit-pch -o %t
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc 
-include-pch %t -o - | FileCheck %s
 
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - 
-fopenmp-version=50 -DOMP5 | FileCheck %s --check-prefix HOST5
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc 
-fopenmp-version=50 -DOMP5
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -o - -fopenmp-version=50 -DOMP5 | 
FileCheck %s --check-prefix DEV5
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - 
-fopenmp-version=50 -DOMP5 | FileCheck %s --check-prefix DEV5
 
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -o - -fopenmp-version=50 -DOMP5 | FileCheck %s --check-prefix 
KMPC-ONLY
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm-bc %s -o %t-ppc-host.bc -fopenmp-version=50 -DOMP5
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - 
-fopenmp-version=50 -DOMP5 | FileCheck %s --check-prefix 

r373620 - [OPENMP]Improve diagnostics for not found declare target entries.

2019-10-03 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Oct  3 09:20:34 2019
New Revision: 373620

URL: http://llvm.org/viewvc/llvm-project?rev=373620=rev
Log:
[OPENMP]Improve diagnostics for not found declare target entries.

We can point to the target region + emit parent functions names/real var
names if they were not found in host module during device codegen.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/target_messages.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=373620=373619=373620=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Oct  3 09:20:34 2019
@@ -4201,7 +4201,9 @@ void CGOpenMPRuntime::createOffloadEntri
 
   llvm::Module  = CGM.getModule();
   llvm::LLVMContext  = M.getContext();
-  SmallVector
+  SmallVector,
+  16>
   OrderedEntries(OffloadEntriesInfoManager.size());
   llvm::SmallVector ParentFunctions(
   OffloadEntriesInfoManager.size());
@@ -4219,7 +4221,8 @@ void CGOpenMPRuntime::createOffloadEntri
 
   // Create function that emits metadata for each target region entry;
   auto & =
-  [, MD, , , , ](
+  [this, , MD, , , ,
+   ](
   unsigned DeviceID, unsigned FileID, StringRef ParentName,
   unsigned Line,
   const OffloadEntriesInfoManagerTy::OffloadEntryInfoTargetRegion ) {
@@ -4237,8 +4240,19 @@ void CGOpenMPRuntime::createOffloadEntri
  GetMDInt(FileID),  
GetMDString(ParentName),
  GetMDInt(Line),
GetMDInt(E.getOrder())};
 
+SourceLocation Loc;
+for (auto I = CGM.getContext().getSourceManager().fileinfo_begin(),
+  E = CGM.getContext().getSourceManager().fileinfo_end();
+ I != E; ++I) {
+  if (I->getFirst()->getUniqueID().getDevice() == DeviceID &&
+  I->getFirst()->getUniqueID().getFile() == FileID) {
+Loc = CGM.getContext().getSourceManager().translateFileLineCol(
+I->getFirst(), Line, 1);
+break;
+  }
+}
 // Save this entry in the right position of the ordered entries array.
-OrderedEntries[E.getOrder()] = 
+OrderedEntries[E.getOrder()] = std::make_tuple(, Loc, ParentName);
 ParentFunctions[E.getOrder()] = ParentName;
 
 // Add metadata to the named metadata node.
@@ -4266,7 +4280,8 @@ void CGOpenMPRuntime::createOffloadEntri
 GetMDInt(E.getFlags()), GetMDInt(E.getOrder())};
 
 // Save this entry in the right position of the ordered entries array.
-OrderedEntries[E.getOrder()] = 
+OrderedEntries[E.getOrder()] =
+std::make_tuple(, SourceLocation(), MangledName);
 
 // Add metadata to the named metadata node.
 MD->addOperand(llvm::MDNode::get(C, Ops));
@@ -4275,11 +4290,11 @@ void CGOpenMPRuntime::createOffloadEntri
   OffloadEntriesInfoManager.actOnDeviceGlobalVarEntriesInfo(
   DeviceGlobalVarMetadataEmitter);
 
-  for (const auto *E : OrderedEntries) {
-assert(E && "All ordered entries must exist!");
+  for (const auto  : OrderedEntries) {
+assert(std::get<0>(E) && "All ordered entries must exist!");
 if (const auto *CE =
 
dyn_cast(
-E)) {
+std::get<0>(E))) {
   if (!CE->getID() || !CE->getAddress()) {
 // Do not blame the entry if the parent funtion is not emitted.
 StringRef FnName = ParentFunctions[CE->getOrder()];
@@ -4287,16 +4302,16 @@ void CGOpenMPRuntime::createOffloadEntri
   continue;
 unsigned DiagID = CGM.getDiags().getCustomDiagID(
 DiagnosticsEngine::Error,
-"Offloading entry for target region is incorrect: either the "
+"Offloading entry for target region in %0 is incorrect: either the 
"
 "address or the ID is invalid.");
-CGM.getDiags().Report(DiagID);
+CGM.getDiags().Report(std::get<1>(E), DiagID) << FnName;
 continue;
   }
   createOffloadEntry(CE->getID(), CE->getAddress(), /*Size=*/0,
  CE->getFlags(), llvm::GlobalValue::WeakAnyLinkage);
-} else if (const auto *CE =
-   dyn_cast(E)) {
+} else if (const auto *CE = dyn_cast(
+   std::get<0>(E))) {
   OffloadEntriesInfoManagerTy::OMPTargetGlobalVarEntryKind Flags =
   
static_cast(
   CE->getFlags());
@@ -4307,10 +4322,10 @@ void CGOpenMPRuntime::createOffloadEntri
   continue;
 if (!CE->getAddress()) {
   unsigned DiagID = CGM.getDiags().getCustomDiagID(
-  DiagnosticsEngine::Error,
-  "Offloading entry for declare target variable is incorrect: the "
-  "address is invalid.");
-  

r373502 - [OPENMP50]Add parsing/sema analysis for declare variant score.

2019-10-02 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Oct  2 11:19:02 2019
New Revision: 373502

URL: http://llvm.org/viewvc/llvm-project?rev=373502=rev
Log:
[OPENMP50]Add parsing/sema analysis for declare variant score.

Context selectors may include optional score clause in format
`score():`, where `` must be a constant integer expression.
Added parsing/sema analysis only.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/OpenMP/declare_variant_ast_print.c
cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp
cfe/trunk/test/OpenMP/declare_variant_messages.c
cfe/trunk/test/OpenMP/declare_variant_messages.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=373502=373501=373502=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Oct  2 11:19:02 2019
@@ -3290,12 +3290,19 @@ def OMPDeclareVariant : InheritableAttr
   let Documentation = [OMPDeclareVariantDocs];
   let Args = [
 ExprArgument<"VariantFuncRef">,
+ExprArgument<"Score">,
 EnumArgument<"CtxSelectorSet", "CtxSelectorSetType",
  [ "", "implementation"
  ],
  [
"CtxSetUnknown", "CtxSetImplementation"
  ]>,
+EnumArgument<"CtxScore", "ScoreType",
+ [ "", "score"
+ ],
+ [
+   "ScoreUnknown", "ScoreSpecified"
+ ]>,
 EnumArgument<"CtxSelector", "CtxSelectorType",
  [ "", "vendor"
  ],
@@ -3305,6 +3312,13 @@ def OMPDeclareVariant : InheritableAttr
 StringArgument<"ImplVendor", 1>
   ];
   let AdditionalMembers = [{
+void printScore(raw_ostream & OS, const PrintingPolicy ) const {
+  if (const Expr *E = getScore()) {
+OS << "score(";
+E->printPretty(OS, nullptr, Policy);
+OS << "):";
+  }
+}
 void printPrettyPragma(raw_ostream & OS, const PrintingPolicy )
 const {
   assert(getCtxSelectorSet() != CtxSetUnknown &&
@@ -3322,6 +3336,7 @@ def OMPDeclareVariant : InheritableAttr
 switch (getCtxSelector()) {
 case CtxVendor:
   OS << "vendor(";
+  printScore(OS, Policy);
   OS << getImplVendor();
   OS << ")";
   break;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=373502=373501=373502=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Oct  2 11:19:02 2019
@@ -9109,11 +9109,14 @@ public:
 OMPDeclareVariantAttr::CtxSelectorType Ctx =
 OMPDeclareVariantAttr::CtxUnknown;
 StringRef ImplVendor;
+ExprResult CtxScore;
 explicit OpenMPDeclareVariantCtsSelectorData() = default;
 explicit OpenMPDeclareVariantCtsSelectorData(
 OMPDeclareVariantAttr::CtxSelectorSetType CtxSet,
-OMPDeclareVariantAttr::CtxSelectorType Ctx, StringRef ImplVendor)
-: CtxSet(CtxSet), Ctx(Ctx), ImplVendor(ImplVendor) {}
+OMPDeclareVariantAttr::CtxSelectorType Ctx, StringRef ImplVendor,
+ExprResult CtxScore)
+: CtxSet(CtxSet), Ctx(Ctx), ImplVendor(ImplVendor), CtxScore(CtxScore) 
{
+}
   };
 
   /// Checks if the variant/multiversion functions are compatible.

Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=373502=373501=373502=diff
==
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Wed Oct  2 11:19:02 2019
@@ -786,6 +786,31 @@ Parser::ParseOMPDeclareSimdClauses(Parse
   LinModifiers, Steps, SourceRange(Loc, EndLoc));
 }
 
+/// Parse optional 'score' '('  ')' ':'.
+static ExprResult parseContextScore(Parser ) {
+  ExprResult ScoreExpr;
+  SmallString<16> Buffer;
+  StringRef SelectorName =
+  P.getPreprocessor().getSpelling(P.getCurToken(), Buffer);
+  OMPDeclareVariantAttr::ScoreType ScoreKind =
+  OMPDeclareVariantAttr::ScoreUnknown;
+  (void)OMPDeclareVariantAttr::ConvertStrToScoreType(SelectorName, ScoreKind);
+  if (ScoreKind == OMPDeclareVariantAttr::ScoreUnknown)
+return ScoreExpr;
+  assert(ScoreKind == OMPDeclareVariantAttr::ScoreSpecified &&
+ "Expected \"score\" clause.");
+  (void)P.ConsumeToken();
+  SourceLocation RLoc;
+  ScoreExpr = P.ParseOpenMPParensExpr(SelectorName, RLoc);
+  // Parse ':'
+  if (P.getCurToken().is(tok::colon))
+(void)P.ConsumeAnyToken();
+  

r373387 - [OPENMP50]Initial codegen for declare variant implementation vendor.

2019-10-01 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Oct  1 13:18:32 2019
New Revision: 373387

URL: http://llvm.org/viewvc/llvm-project?rev=373387=rev
Log:
[OPENMP50]Initial codegen for declare variant implementation vendor.

Initial implementation of global aliases emission for the declare
variant pragma with implementation vendor context selector set.

Added:
cfe/trunk/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=373387=373386=373387=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Oct  1 13:18:32 2019
@@ -1264,6 +1264,51 @@ CGOpenMPRuntime::CGOpenMPRuntime(CodeGen
   loadOffloadInfoMetadata();
 }
 
+static bool tryEmitAlias(CodeGenModule , const GlobalDecl ,
+ const GlobalDecl , llvm::GlobalValue *OrigAddr,
+ bool IsForDefinition) {
+  // Emit at least a definition for the aliasee if the the address of the
+  // original function is requested.
+  if (IsForDefinition || OrigAddr)
+(void)CGM.GetAddrOfGlobal(NewGD);
+  StringRef NewMangledName = CGM.getMangledName(NewGD);
+  llvm::GlobalValue *Addr = CGM.GetGlobalValue(NewMangledName);
+  if (Addr && !Addr->isDeclaration()) {
+const auto *D = cast(OldGD.getDecl());
+const CGFunctionInfo  = CGM.getTypes().arrangeGlobalDeclaration(OldGD);
+llvm::Type *DeclTy = CGM.getTypes().GetFunctionType(FI);
+
+// Create a reference to the named value.  This ensures that it is emitted
+// if a deferred decl.
+llvm::GlobalValue::LinkageTypes LT = CGM.getFunctionLinkage(OldGD);
+
+// Create the new alias itself, but don't set a name yet.
+auto *GA =
+llvm::GlobalAlias::create(DeclTy, 0, LT, "", Addr, ());
+
+if (OrigAddr) {
+  assert(OrigAddr->isDeclaration() && "Expected declaration");
+
+  GA->takeName(OrigAddr);
+  OrigAddr->replaceAllUsesWith(
+  llvm::ConstantExpr::getBitCast(GA, OrigAddr->getType()));
+  OrigAddr->eraseFromParent();
+} else {
+  GA->setName(CGM.getMangledName(OldGD));
+}
+
+// Set attributes which are particular to an alias; this is a
+// specialization of the attributes which may be set on a global function.
+if (D->hasAttr() || D->hasAttr() ||
+D->isWeakImported())
+  GA->setLinkage(llvm::Function::WeakAnyLinkage);
+
+CGM.SetCommonAttributes(OldGD, GA);
+return true;
+  }
+  return false;
+}
+
 void CGOpenMPRuntime::clear() {
   InternalVars.clear();
   // Clean non-target variable declarations possibly used only in debug info.
@@ -1277,6 +1322,14 @@ void CGOpenMPRuntime::clear() {
   continue;
 GV->eraseFromParent();
   }
+  // Emit aliases for the deferred aliasees.
+  for (const auto  : DeferredVariantFunction) {
+StringRef MangledName = CGM.getMangledName(Pair.second.second);
+llvm::GlobalValue *Addr = CGM.GetGlobalValue(MangledName);
+// If not able to emit alias, just emit original declaration.
+(void)tryEmitAlias(CGM, Pair.second.first, Pair.second.second, Addr,
+   /*IsForDefinition=*/false);
+  }
 }
 
 std::string CGOpenMPRuntime::getName(ArrayRef Parts) const {
@@ -11086,6 +11139,80 @@ Address CGOpenMPRuntime::getAddressOfLoc
   return Address(Addr, Align);
 }
 
+/// Checks current context and returns true if it matches the context selector.
+template 
+static bool checkContext(const OMPDeclareVariantAttr *A) {
+  assert(CtxSet != OMPDeclareVariantAttr::CtxSetUnknown &&
+ Ctx != OMPDeclareVariantAttr::CtxUnknown &&
+ "Unknown context selector or context selector set.");
+  return false;
+}
+
+/// Checks for implementation={vendor()} context selector.
+/// \returns true iff ="llvm", false otherwise.
+template <>
+bool checkContext(
+const OMPDeclareVariantAttr *A) {
+  return !A->getImplVendor().compare("llvm");
+}
+
+/// Finds the variant function that matches current context with its context
+/// selector.
+static const FunctionDecl *getDeclareVariantFunction(const FunctionDecl *FD) {
+  if (!FD->hasAttrs() || !FD->hasAttr())
+return FD;
+  // Iterate through all DeclareVariant attributes and check context selectors.
+  SmallVector MatchingAttributes;
+  for (const auto * A : FD->specific_attrs()) {
+switch (A->getCtxSelectorSet()) {
+case OMPDeclareVariantAttr::CtxSetImplementation:
+  switch (A->getCtxSelector()) {
+  case OMPDeclareVariantAttr::CtxVendor:
+if (checkContext(A))
+  MatchingAttributes.push_back(A);
+break;
+  case OMPDeclareVariantAttr::CtxUnknown:
+llvm_unreachable(
+"Unknown context selector in implementation 

r373374 - [OPENMP]Fix PR43330: OpenMP target: Mapping of partial arrays fails.

2019-10-01 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Oct  1 11:18:03 2019
New Revision: 373374

URL: http://llvm.org/viewvc/llvm-project?rev=373374=rev
Log:
[OPENMP]Fix PR43330: OpenMP target: Mapping of partial arrays fails.

Fixed calculation the size of the array sections.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/target_map_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=373374=373373=373374=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Oct  1 11:18:03 2019
@@ -7249,9 +7249,11 @@ private:
 OAE->getBase()->IgnoreParenImpCasts())
 .getCanonicalType();
 
-  // If there is no length associated with the expression, that means we
-  // are using the whole length of the base.
-  if (!OAE->getLength() && OAE->getColonLoc().isValid())
+  // If there is no length associated with the expression and lower bound 
is
+  // not specified too, that means we are using the whole length of the
+  // base.
+  if (!OAE->getLength() && OAE->getColonLoc().isValid() &&
+  !OAE->getLowerBound())
 return CGF.getTypeSize(BaseTy);
 
   llvm::Value *ElemSize;
@@ -7265,13 +7267,30 @@ private:
 
   // If we don't have a length at this point, that is because we have an
   // array section with a single element.
-  if (!OAE->getLength())
+  if (!OAE->getLength() && OAE->getColonLoc().isInvalid())
 return ElemSize;
 
-  llvm::Value *LengthVal = CGF.EmitScalarExpr(OAE->getLength());
-  LengthVal =
-  CGF.Builder.CreateIntCast(LengthVal, CGF.SizeTy, /*isSigned=*/false);
-  return CGF.Builder.CreateNUWMul(LengthVal, ElemSize);
+  if (const Expr *LenExpr = OAE->getLength()) {
+llvm::Value *LengthVal = CGF.EmitScalarExpr(OAE->getLength());
+LengthVal = CGF.EmitScalarConversion(
+LengthVal, OAE->getLength()->getType(),
+CGF.getContext().getSizeType(), OAE->getLength()->getExprLoc());
+return CGF.Builder.CreateNUWMul(LengthVal, ElemSize);
+  }
+  assert(!OAE->getLength() && OAE->getColonLoc().isValid() &&
+ OAE->getLowerBound() && "expected array_section[lb:].");
+  // Size = sizetype - lb * elemtype;
+  llvm::Value *LengthVal = CGF.getTypeSize(BaseTy);
+  llvm::Value *LBVal = CGF.EmitScalarExpr(OAE->getLowerBound());
+  LBVal = CGF.EmitScalarConversion(LBVal, OAE->getLowerBound()->getType(),
+   CGF.getContext().getSizeType(),
+   OAE->getLowerBound()->getExprLoc());
+  LBVal = CGF.Builder.CreateNUWMul(LBVal, ElemSize);
+  llvm::Value *Cmp = CGF.Builder.CreateICmpUGT(LengthVal, LBVal);
+  llvm::Value *TrueVal = CGF.Builder.CreateNUWSub(LengthVal, LBVal);
+  LengthVal = CGF.Builder.CreateSelect(
+  Cmp, TrueVal, llvm::ConstantInt::get(CGF.SizeTy, 0));
+  return LengthVal;
 }
 return CGF.getTypeSize(ExprTy);
   }

Modified: cfe/trunk/test/OpenMP/target_map_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_map_codegen.cpp?rev=373374=373373=373374=diff
==
--- cfe/trunk/test/OpenMP/target_map_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/target_map_codegen.cpp Tue Oct  1 11:18:03 2019
@@ -1323,172 +1323,176 @@ void implicit_maps_template_type_capture
 // SIMD-ONLY18-NOT: {{__kmpc|__tgt}}
 #ifdef CK19
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1510.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1514.region_id = weak 
constant i8 0
 // CK19: [[SIZE00:@.+]] = private {{.*}}constant [1 x i64] [i64 4]
 // CK19: [[MTYPE00:@.+]] = private {{.*}}constant [1 x i64] [i64 32]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1531.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1535.region_id = weak 
constant i8 0
 // CK19: [[SIZE00n:@.+]] = private {{.*}}constant [1 x i64] [i64 4]
 // CK19: [[MTYPE00n:@.+]] = private {{.*}}constant [1 x i64] [i64 32]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1553.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1557.region_id = weak 
constant i8 0
 // CK19: [[SIZE01:@.+]] = private {{.*}}constant [1 x i64] [i64 400]
 // CK19: [[MTYPE01:@.+]] = private {{.*}}constant [1 x i64] [i64 33]
 
-// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1572.region_id = weak 
constant i8 0
+// CK19-LABEL: 
@.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1576.region_id = 

r373348 - [OPENMP]Fix PR43516: Compiler crash with collapse(2) on non-rectangular

2019-10-01 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Oct  1 09:19:10 2019
New Revision: 373348

URL: http://llvm.org/viewvc/llvm-project?rev=373348=rev
Log:
[OPENMP]Fix PR43516: Compiler crash with collapse(2) on non-rectangular
loop.

Missed check if the condition is also dependent when building final
expressions for the collapsed loop directives.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/for_codegen.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=373348=373347=373348=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Oct  1 09:19:10 2019
@@ -6247,13 +6247,21 @@ Expr *OpenMPIterationSpaceChecker::build
 Expr *OpenMPIterationSpaceChecker::buildPreCond(
 Scope *S, Expr *Cond,
 llvm::MapVector ) const {
+  // Do not build a precondition when the condition/initialization is dependent
+  // to prevent pessimistic early loop exit.
+  // TODO: this can be improved by calculating min/max values but not sure that
+  // it will be very effective.
+  if (CondDependOnLC || InitDependOnLC)
+return SemaRef.PerformImplicitConversion(
+SemaRef.ActOnIntegerConstant(SourceLocation(), 1).get(),
+SemaRef.Context.BoolTy, /*Action=*/Sema::AA_Casting,
+/*AllowExplicit=*/true).get();
+
   // Try to build LB  UB, where  is <, >, <=, or >=.
   Sema::TentativeAnalysisScope Trap(SemaRef);
 
-  ExprResult NewLB =
-  InitDependOnLC ? LB : tryBuildCapture(SemaRef, LB, Captures);
-  ExprResult NewUB =
-  CondDependOnLC ? UB : tryBuildCapture(SemaRef, UB, Captures);
+  ExprResult NewLB = tryBuildCapture(SemaRef, LB, Captures);
+  ExprResult NewUB = tryBuildCapture(SemaRef, UB, Captures);
   if (!NewLB.isUsable() || !NewUB.isUsable())
 return nullptr;
 
@@ -7425,7 +7433,7 @@ checkOpenMPLoop(OpenMPDirectiveKind DKin
   Built.DependentCounters[Cnt] = nullptr;
   Built.DependentInits[Cnt] = nullptr;
   Built.FinalsConditions[Cnt] = nullptr;
-  if (IS.IsNonRectangularLB) {
+  if (IS.IsNonRectangularLB || IS.IsNonRectangularUB) {
 Built.DependentCounters[Cnt] =
 Built.Counters[NestedLoopCount - 1 - IS.LoopDependentIdx];
 Built.DependentInits[Cnt] =

Modified: cfe/trunk/test/OpenMP/for_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_codegen.cpp?rev=373348=373347=373348=diff
==
--- cfe/trunk/test/OpenMP/for_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_codegen.cpp Tue Oct  1 09:19:10 2019
@@ -89,23 +89,6 @@ void loop_with_counter_collapse() {
   // CHECK: [[NUM_ITERS_VAL:%.+]] = sub nsw i64 [[MUL]], 1
   // CHECK: store i64 [[NUM_ITERS_VAL]], i64* [[NUM_ITERS:%.+]],
 
-  // Initialization
-  // CHECK: store i32 0, i32* [[I:%.+]],
-  // CHECK: [[I_INIT:%.+]] = load i32, i32* [[I]],
-  // CHECK: store i32 [[I_INIT]], i32* [[J:%.+]],
-
-  // LIFETIME: call void @llvm.lifetime.end
-  // LIFETIME: call void @llvm.lifetime.end
-
-  // Precondition for j counter
-  // CHECK: store i32 0, i32* [[TMP_I:%.+]],
-  // CHECK: [[J_LB_VAL:%.+]] = load i32, i32* [[TMP_I]],
-  // CHECK: [[I_VAL:%.+]] = load i32, i32* [[TMP_I]],
-  // CHECK: [[J_UB_VAL:%.+]] = add nsw i32 4, [[I_VAL]]
-  // CHECK: [[CMP:%.+]] = icmp slt i32 [[J_LB_VAL]], [[J_UB_VAL]]
-  // CHECK: br i1 [[CMP]], label %[[THEN:[^,]+]], label %[[ELSE:[^,]+]]
-
-  // CHECK: [[THEN]]:
   // CHECK: store i64 0, i64* [[LB:%.+]],
   // CHECK: [[NUM_ITERS_VAL:%.+]] = load i64, i64* [[NUM_ITERS]],
   // CHECK: store i64 [[NUM_ITERS_VAL]], i64* [[UB:%.+]],
@@ -633,6 +616,22 @@ void for_with_references() {
 k = cnt;
 }
 
+// CHECK-LABEL: for_with_references_dep_cond
+void for_with_references_dep_cond() {
+// CHECK: [[I:%.+]] = alloca i8,
+// CHECK: [[CNT:%.+]] = alloca i8*,
+// CHECK: [[CNT_PRIV:%.+]] = alloca i8,
+// CHECK: call void @__kmpc_for_static_init_8(
+// CHECK-NOT: load i8, i8* [[CNT]],
+// CHECK: call void @__kmpc_for_static_fini(
+  char i = 0;
+  char  = i;
+#pragma omp for collapse(2)
+  for (cnt = 0; cnt < 2; ++cnt)
+for (int j = 0; j < 4 + cnt; j++)
+k = cnt;
+}
+
 struct Bool {
   Bool(bool b) : b(b) {}
   operator bool() const { return b; }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r373257 - [OPENMP50]Mark declare variant attribute as inheritable.

2019-09-30 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Sep 30 13:39:29 2019
New Revision: 373257

URL: http://llvm.org/viewvc/llvm-project?rev=373257=rev
Log:
[OPENMP50]Mark declare variant attribute as inheritable.

Attribute must be inherited by the redeclarations.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=373257=373256=373257=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon Sep 30 13:39:29 2019
@@ -3281,11 +3281,12 @@ def OMPAllocateDecl : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
-def OMPDeclareVariant : Attr {
+def OMPDeclareVariant : InheritableAttr {
   let Spellings = [Pragma<"omp", "declare variant">];
   let Subjects = SubjectList<[Function]>;
   let SemaHandler = 0;
   let HasCustomParsing = 1;
+  let InheritEvenIfAlreadyPresent = 1;
   let Documentation = [OMPDeclareVariantDocs];
   let Args = [
 ExprArgument<"VariantFuncRef">,

Modified: cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp?rev=373257=373256=373257=diff
==
--- cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp Mon Sep 30 13:39:29 2019
@@ -148,6 +148,8 @@ auto fn_deduced1() { return 0; }
 // CHECK-NEXT: #pragma omp declare variant(SpecialFuncs::bar) 
match(implementation={vendor(llvm)})
 // CHECK-NEXT: void foo1() {
 // CHECK-NEXT: }
+// CHECK-NEXT: #pragma omp declare variant(SpecialFuncs::baz) 
match(implementation={vendor(unknown)})
+// CHECK-NEXT: void xxx();
 // CHECK-NEXT: } s;
 struct SpecialFuncs {
   void vd() {}
@@ -162,8 +164,15 @@ struct SpecialFuncs {
 #pragma omp declare variant(SpecialFuncs::bar) 
match(implementation={vendor(ibm)}, implementation={vendor(llvm)})
 #pragma omp declare variant(SpecialFuncs::baz) 
match(implementation={vendor(unknown)})
   void foo1() {}
+#pragma omp declare variant(SpecialFuncs::baz) 
match(implementation={vendor(unknown)})
+  void xxx();
 } s;
 
+// CHECK:  #pragma omp declare variant(SpecialFuncs::baz) 
match(implementation={vendor(unknown)})
+// CHECK-NEXT: void SpecialFuncs::xxx() {
+// CHECK-NEXT: }
+void SpecialFuncs::xxx() {}
+
 // CHECK:  static void static_f_variant() {
 // CHECK-NEXT: }
 static void static_f_variant() {}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r373243 - [OPENMP50]Do not emit warning for the function with the currently

2019-09-30 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Sep 30 11:24:35 2019
New Revision: 373243

URL: http://llvm.org/viewvc/llvm-project?rev=373243=rev
Log:
[OPENMP50]Do not emit warning for the function with the currently
defined body.

If the function is currently defined, we should not emit a warning that
it might be emitted already because it was not really emitted.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/declare_variant_messages.c
cfe/trunk/test/OpenMP/declare_variant_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=373243=373242=373243=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon Sep 30 11:24:35 2019
@@ -4936,8 +4936,9 @@ Sema::checkOpenMPDeclareVariantFunction(
 << FD->getLocation();
 
   // Check if the function was emitted already.
-  if ((LangOpts.EmitAllDecls && FD->isDefined()) ||
-  Context.DeclMustBeEmitted(FD))
+  const FunctionDecl *Definition;
+  if (!FD->isThisDeclarationADefinition() && FD->isDefined(Definition) &&
+  (LangOpts.EmitAllDecls || Context.DeclMustBeEmitted(Definition)))
 Diag(SR.getBegin(), diag::warn_omp_declare_variant_after_emitted)
 << FD->getLocation();
 

Modified: cfe/trunk/test/OpenMP/declare_variant_messages.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_variant_messages.c?rev=373243=373242=373243=diff
==
--- cfe/trunk/test/OpenMP/declare_variant_messages.c (original)
+++ cfe/trunk/test/OpenMP/declare_variant_messages.c Mon Sep 30 11:24:35 2019
@@ -79,9 +79,13 @@ int bar() {
 // expected-warning@+1 {{'#pragma omp declare variant' cannot be applied for 
function after first usage; the original function might be used}}
 #pragma omp declare variant(after_use_variant) match(xxx={})
 int after_use(void);
-// expected-warning@+1 {{#pragma omp declare variant' cannot be applied to the 
function that was defined already; the original function might be used}}
 #pragma omp declare variant(after_use_variant) match(xxx={})
 int defined(void) { return 0; }
+int defined1(void) { return 0; }
+// expected-warning@+1 {{#pragma omp declare variant' cannot be applied to the 
function that was defined already; the original function might be used}}
+#pragma omp declare variant(after_use_variant) match(xxx={})
+int defined1(void);
+
 
 int diff_cc_variant(void);
 // expected-error@+1 {{function with '#pragma omp declare variant' has a 
different calling convention}}

Modified: cfe/trunk/test/OpenMP/declare_variant_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_variant_messages.cpp?rev=373243=373242=373243=diff
==
--- cfe/trunk/test/OpenMP/declare_variant_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_variant_messages.cpp Mon Sep 30 11:24:35 2019
@@ -172,10 +172,14 @@ auto fn_deduced_variant() { return 0; }
 int fn_deduced();
 
 int fn_deduced_variant1();
-// expected-warning@+1 {{'#pragma omp declare variant' cannot be applied to 
the function that was defined already; the original function might be used}}
 #pragma omp declare variant(fn_deduced_variant1) match(xxx = {})
 auto fn_deduced1() { return 0; }
 
+auto fn_deduced3() { return 0; }
+// expected-warning@+1 {{'#pragma omp declare variant' cannot be applied to 
the function that was defined already; the original function might be used}}
+#pragma omp declare variant(fn_deduced_variant1) match(xxx = {})
+auto fn_deduced3();
+
 auto fn_deduced_variant2() { return 0; }
 // expected-error@+1 {{variant in '#pragma omp declare variant' with type 'int 
()' is incompatible with type 'float (*)()'}}
 #pragma omp declare variant(fn_deduced_variant2) match(xxx = {})


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r373210 - [OPENMP] Fix comment, NFC.

2019-09-30 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Sep 30 07:05:26 2019
New Revision: 373210

URL: http://llvm.org/viewvc/llvm-project?rev=373210=rev
Log:
[OPENMP] Fix comment, NFC.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=373210=373209=373210=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon Sep 30 07:05:26 2019
@@ -170,7 +170,7 @@ private:
   OpenMPClauseKind ClauseKindMode = OMPC_unknown;
   Sema 
   bool ForceCapturing = false;
-  /// true if all the vaiables in the target executable directives must be
+  /// true if all the variables in the target executable directives must be
   /// captured by reference.
   bool ForceCaptureByReferenceInTargetExecutable = false;
   CriticalsWithHintsTy Criticals;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r373010 - [OPENMP50]Emit warnings if the functions was defined/used before marked

2019-09-26 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Sep 26 13:04:15 2019
New Revision: 373010

URL: http://llvm.org/viewvc/llvm-project?rev=373010=rev
Log:
[OPENMP50]Emit warnings if the functions was defined/used before marked
declare variant.

We can use the original function if it was used/emitted already. So,
just use warnings for these cases, not errors.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp
cfe/trunk/test/OpenMP/declare_variant_messages.c
cfe/trunk/test/OpenMP/declare_variant_messages.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=373010=373009=373010=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Sep 26 13:04:15 
2019
@@ -9452,9 +9452,12 @@ def warn_omp_declare_target_after_first_
   InGroup;
 def err_omp_declare_variant_incompat_attributes : Error<
   "'#pragma omp declare variant' is not compatible with any target-specific 
attributes">;
-def err_omp_declare_variant_after_used : Error<
+def warn_omp_declare_variant_after_used : Warning<
   "'#pragma omp declare variant' cannot be applied for function after first "
-  "usage">;
+  "usage; the original function might be used">, InGroup;
+def warn_omp_declare_variant_after_emitted : Warning<
+  "'#pragma omp declare variant' cannot be applied to the function that was 
defined already;"
+  " the original function might be used">, InGroup;
 def err_omp_declare_variant_noproto : Error<
   "function with '#pragma omp declare variant' must have a prototype">;
 def note_omp_declare_variant_specified_here : Note<

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=373010=373009=373010=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Sep 26 13:04:15 2019
@@ -4931,11 +4931,15 @@ Sema::checkOpenMPDeclareVariantFunction(
   }
 
   // Allow #pragma omp declare variant only if the function is not used.
-  if (FD->isUsed(false)) {
-Diag(SR.getBegin(), diag::err_omp_declare_variant_after_used)
+  if (FD->isUsed(false))
+Diag(SR.getBegin(), diag::warn_omp_declare_variant_after_used)
+<< FD->getLocation();
+
+  // Check if the function was emitted already.
+  if ((LangOpts.EmitAllDecls && FD->isDefined()) ||
+  Context.DeclMustBeEmitted(FD))
+Diag(SR.getBegin(), diag::warn_omp_declare_variant_after_emitted)
 << FD->getLocation();
-return None;
-  }
 
   // The VariantRef must point to function.
   if (!VariantRef) {

Modified: cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp?rev=373010=373009=373010=diff
==
--- cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp Thu Sep 26 13:04:15 2019
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++14 -fexceptions 
-fcxx-exceptions %s -ast-print -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++14 -fexceptions 
-fcxx-exceptions %s -ast-print -o - -Wno-source-uses-openmp | FileCheck %s
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -std=c++14 -fexceptions 
-fcxx-exceptions %s -ast-print -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -std=c++14 -fexceptions 
-fcxx-exceptions %s -ast-print -o - -Wno-source-uses-openmp | FileCheck %s
 
 // expected-no-diagnostics
 

Modified: cfe/trunk/test/OpenMP/declare_variant_messages.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_variant_messages.c?rev=373010=373009=373010=diff
==
--- cfe/trunk/test/OpenMP/declare_variant_messages.c (original)
+++ cfe/trunk/test/OpenMP/declare_variant_messages.c Thu Sep 26 13:04:15 2019
@@ -76,9 +76,12 @@ int bar() {
   return after_use();
 }
 
-// expected-error@+1 {{'#pragma omp declare variant' cannot be applied for 
function after first usage}}
+// expected-warning@+1 {{'#pragma omp declare variant' cannot be applied for 
function after first usage; the original function might be used}}
 #pragma omp declare variant(after_use_variant) match(xxx={})
 int after_use(void);
+// expected-warning@+1 {{#pragma omp declare variant' cannot be applied to the 
function that was defined already; the original function might be used}}
+#pragma omp declare variant(after_use_variant) match(xxx={})
+int defined(void) { return 0; }
 
 int 

r372917 - [OPENMP50]Parsing/sema support for 'implementation/vendor' context

2019-09-25 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Sep 25 12:43:37 2019
New Revision: 372917

URL: http://llvm.org/viewvc/llvm-project?rev=372917=rev
Log:
[OPENMP50]Parsing/sema support for 'implementation/vendor' context
selector.

Added basic parsing/semantic support for
'implementation={vendor()}' context selector.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/OpenMP/declare_variant_ast_print.c
cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp
cfe/trunk/test/OpenMP/declare_variant_messages.c
cfe/trunk/test/OpenMP/declare_variant_messages.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=372917=372916=372917=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Sep 25 12:43:37 2019
@@ -3288,18 +3288,51 @@ def OMPDeclareVariant : Attr {
   let HasCustomParsing = 1;
   let Documentation = [OMPDeclareVariantDocs];
   let Args = [
-ExprArgument<"VariantFuncRef">
+ExprArgument<"VariantFuncRef">,
+EnumArgument<"CtxSelectorSet", "CtxSelectorSetType",
+ [ "", "implementation"
+ ],
+ [
+   "CtxSetUnknown", "CtxSetImplementation"
+ ]>,
+EnumArgument<"CtxSelector", "CtxSelectorType",
+ [ "", "vendor"
+ ],
+ [
+   "CtxUnknown", "CtxVendor"
+ ]>,
+StringArgument<"ImplVendor", 1>
   ];
   let AdditionalMembers = [{
 void printPrettyPragma(raw_ostream & OS, const PrintingPolicy )
 const {
+  assert(getCtxSelectorSet() != CtxSetUnknown &&
+ getCtxSelector() != CtxUnknown && "Unknown context selector.");
   if (const Expr *E = getVariantFuncRef()) {
 OS << "(";
 E->printPretty(OS, nullptr, Policy);
 OS << ")";
   }
   // TODO: add printing of real context selectors.
-  OS << " match(unknown={})";
+  OS << " match(";
+  switch (getCtxSelectorSet()) {
+  case CtxSetImplementation:
+OS << "implementation={";
+switch (getCtxSelector()) {
+case CtxVendor:
+  OS << "vendor(";
+  OS << getImplVendor();
+  OS << ")";
+  break;
+case CtxUnknown:
+  llvm_unreachable("Unknown context selector.");
+}
+OS << "}";
+break;
+  case CtxSetUnknown:
+llvm_unreachable("Unknown context selector set.");
+  }
+  OS << ")";
 }
   }];
 }

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=372917=372916=372917=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Wed Sep 25 12:43:37 
2019
@@ -1206,6 +1206,11 @@ def err_omp_declare_variant_no_ctx_selec
   "expected context selector in '%0' clause on 'omp declare variant' 
directive">;
 def err_omp_declare_variant_equal_expected : Error<
   "expected '=' after '%0' context selector set name on 'omp declare variant' 
directive">;
+def warn_omp_declare_variant_cs_name_expected : Warning<
+  "unknown context selector in '%0' context selector set of 'omp declare 
variant' directive, ignored">,
+  InGroup;
+def err_omp_declare_variant_item_expected : Error<
+  "expected %0 in '%1' context selector of '%2' selector set of 'omp declare 
variant' directive">;
 def warn_omp_more_one_device_type_clause : Warning<
   "more than one 'device_type' clause is specified">,
   InGroup;

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=372917=372916=372917=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Wed Sep 25 12:43:37 2019
@@ -197,6 +197,9 @@
 #ifndef OPENMP_DECLARE_VARIANT_CLAUSE
 #define OPENMP_DECLARE_VARIANT_CLAUSE(Name)
 #endif
+#ifndef OPENMP_MATCH_KIND
+#define OPENMP_MATCH_KIND(Name)
+#endif
 
 // OpenMP directives.
 OPENMP_DIRECTIVE(threadprivate)
@@ -965,6 +968,11 @@ OPENMP_DEVICE_TYPE_KIND(any)
 // Clauses allowed for OpenMP directive 'declare variant'.
 OPENMP_DECLARE_VARIANT_CLAUSE(match)
 
+// Context selectors for 'match' clause.
+// TODO: add other context selectors.

r372635 - [OPENMP]Use standard parsing for 'match' clause, NFC.

2019-09-23 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Sep 23 11:13:31 2019
New Revision: 372635

URL: http://llvm.org/viewvc/llvm-project?rev=372635=rev
Log:
[OPENMP]Use standard parsing for 'match' clause, NFC.

Reused standard clauses parsing scheme for parsing/matching 'match'
clause in 'declare variant' directive.

Modified:
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Basic/OpenMPKinds.h
cfe/trunk/lib/AST/ASTTypeTraits.cpp
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=372635=372634=372635=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon Sep 23 11:13:31 2019
@@ -2844,6 +2844,7 @@ bool RecursiveASTVisitor::Trave
   case OMPC_threadprivate:
   case OMPC_uniform:
   case OMPC_device_type:
+  case OMPC_match:
   case OMPC_unknown:
 break;
   }

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=372635=372634=372635=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Mon Sep 23 11:13:31 2019
@@ -194,6 +194,9 @@
 #ifndef OPENMP_DEVICE_TYPE_KIND
 #define OPENMP_DEVICE_TYPE_KIND(Name)
 #endif
+#ifndef OPENMP_DECLARE_VARIANT_CLAUSE
+#define OPENMP_DECLARE_VARIANT_CLAUSE(Name)
+#endif
 
 // OpenMP directives.
 OPENMP_DIRECTIVE(threadprivate)
@@ -959,6 +962,10 @@ OPENMP_DEVICE_TYPE_KIND(host)
 OPENMP_DEVICE_TYPE_KIND(nohost)
 OPENMP_DEVICE_TYPE_KIND(any)
 
+// Clauses allowed for OpenMP directive 'declare variant'.
+OPENMP_DECLARE_VARIANT_CLAUSE(match)
+
+#undef OPENMP_DECLARE_VARIANT_CLAUSE
 #undef OPENMP_DEVICE_TYPE_KIND
 #undef OPENMP_ALLOCATE_CLAUSE
 #undef OPENMP_DECLARE_MAPPER_CLAUSE

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.h?rev=372635=372634=372635=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.h (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.h Mon Sep 23 11:13:31 2019
@@ -36,6 +36,7 @@ enum OpenMPClauseKind {
   OMPC_threadprivate,
   OMPC_uniform,
   OMPC_device_type,
+  OMPC_match,
   OMPC_unknown
 };
 

Modified: cfe/trunk/lib/AST/ASTTypeTraits.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTTypeTraits.cpp?rev=372635=372634=372635=diff
==
--- cfe/trunk/lib/AST/ASTTypeTraits.cpp (original)
+++ cfe/trunk/lib/AST/ASTTypeTraits.cpp Mon Sep 23 11:13:31 2019
@@ -117,6 +117,7 @@ ASTNodeKind ASTNodeKind::getFromNode(con
   case OMPC_threadprivate:
   case OMPC_uniform:
   case OMPC_device_type:
+  case OMPC_match:
   case OMPC_unknown:
 llvm_unreachable("unexpected OpenMP clause kind");
   }

Modified: cfe/trunk/lib/AST/OpenMPClause.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/OpenMPClause.cpp?rev=372635=372634=372635=diff
==
--- cfe/trunk/lib/AST/OpenMPClause.cpp (original)
+++ cfe/trunk/lib/AST/OpenMPClause.cpp Mon Sep 23 11:13:31 2019
@@ -44,6 +44,7 @@ OMPClause::child_range OMPClause::used_c
   case OMPC_threadprivate:
   case OMPC_uniform:
   case OMPC_device_type:
+  case OMPC_match:
   case OMPC_unknown:
 break;
   }
@@ -129,6 +130,7 @@ const OMPClauseWithPreInit *OMPClauseWit
   case OMPC_dynamic_allocators:
   case OMPC_atomic_default_mem_order:
   case OMPC_device_type:
+  case OMPC_match:
 break;
   }
 
@@ -206,6 +208,7 @@ const OMPClauseWithPostUpdate *OMPClause
   case OMPC_dynamic_allocators:
   case OMPC_atomic_default_mem_order:
   case OMPC_device_type:
+  case OMPC_match:
 break;
   }
 

Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=372635=372634=372635=diff
==
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Mon Sep 23 11:13:31 2019
@@ -56,6 +56,7 @@ OpenMPClauseKind clang::getOpenMPClauseK
 #include "clang/Basic/OpenMPKinds.def"
   .Case("uniform", OMPC_uniform)
   .Case("device_type", OMPC_device_type)
+  .Case("match", OMPC_match)
   .Default(OMPC_unknown);
 }
 
@@ -74,6 +75,8 @@ const char *clang::getOpenMPClauseName(O
 

r372623 - [OPENMP]Fix PR43355: DO not emit target calls if only -fopenmp-targets

2019-09-23 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Sep 23 08:53:51 2019
New Revision: 372623

URL: http://llvm.org/viewvc/llvm-project?rev=372623=rev
Log:
[OPENMP]Fix PR43355: DO not emit target calls if only -fopenmp-targets
is not provided.

We should not emit any target-dependent code if only -fopenmp flag is
used and device targets are not provided to prevent compiler crash.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/declare_target_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=372623=372622=372623=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Mon Sep 23 08:53:51 2019
@@ -2815,6 +2815,8 @@ llvm::Function *CGOpenMPRuntime::emitThr
 bool CGOpenMPRuntime::emitDeclareTargetVarDefinition(const VarDecl *VD,
  llvm::GlobalVariable 
*Addr,
  bool PerformInit) {
+  if (CGM.getLangOpts().OMPTargetTriples.empty())
+return false;
   Optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
   if (!Res || *Res == OMPDeclareTargetDeclAttr::MT_Link ||
@@ -9718,6 +9720,8 @@ CGOpenMPRuntime::registerTargetFirstpriv
 
 void CGOpenMPRuntime::registerTargetGlobalVariable(const VarDecl *VD,
llvm::Constant *Addr) {
+  if (CGM.getLangOpts().OMPTargetTriples.empty())
+return;
   llvm::Optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
   if (!Res) {

Modified: cfe/trunk/test/OpenMP/declare_target_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_codegen.cpp?rev=372623=372622=372623=diff
==
--- cfe/trunk/test/OpenMP/declare_target_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_target_codegen.cpp Mon Sep 23 08:53:51 2019
@@ -7,6 +7,15 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc 
-fopenmp-version=50 -DOMP5
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -o - -fopenmp-version=50 -DOMP5 | 
FileCheck %s --check-prefix DEV5
 
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -o - -fopenmp-version=50 -DOMP5 | FileCheck %s --check-prefix 
KMPC-ONLY
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm-bc %s -o %t-ppc-host.bc -fopenmp-version=50 -DOMP5
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - 
-fopenmp-version=50 -DOMP5 | FileCheck %s --check-prefix KMPC-ONLY
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o 
-| FileCheck %s --check-prefix KMPC-ONLY
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc 
-emit-pch -o %t
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc 
-include-pch %t -verify -o - | FileCheck %s --check-prefix KMPC-ONLY
+
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - -fopenmp-version=50 -DOMP5 | FileCheck %s --check-prefix 
SIMD-ONLY
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm-bc %s -o %t-ppc-host.bc -fopenmp-version=50 -DOMP5
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - 
-fopenmp-version=50 -DOMP5 | FileCheck %s --check-prefix SIMD-ONLY
@@ -19,6 +28,7 @@
 // expected-no-diagnostics
 
 // SIMD-ONLY-NOT: {{__kmpc|__tgt}}
+// KMPC-ONLY-NOT: __tgt
 
 // CHECK-NOT: define {{.*}}{{baz1|baz4|maini1|Base|virtual_}}
 // CHECK-DAG: Bake


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r372609 - [OPENMP]Call __kmpc_push_tripcount in task context.

2019-09-23 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Sep 23 07:06:51 2019
New Revision: 372609

URL: http://llvm.org/viewvc/llvm-project?rev=372609=rev
Log:
[OPENMP]Call __kmpc_push_tripcount in task context.

Runtime function __kmpc_push_tripcount better to call inside of the task
context for target regions. Otherwise, the libomptarget is unable to
link the provided tripcount value for nowait target regions and
completely looses this information.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=372609=372608=372609=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Mon Sep 23 07:06:51 2019
@@ -9176,9 +9176,11 @@ void CGOpenMPRuntime::emitUDMapperArrayI
 }
 
 void CGOpenMPRuntime::emitTargetNumIterationsCall(
-CodeGenFunction , const OMPExecutableDirective , const Expr *Device,
-const llvm::function_ref ) {
+CodeGenFunction , const OMPExecutableDirective ,
+llvm::Value *DeviceID,
+llvm::function_ref
+SizeEmitter) {
   OpenMPDirectiveKind Kind = D.getDirectiveKind();
   const OMPExecutableDirective *TD = 
   // Get nested teams distribute kind directive, if any.
@@ -9187,30 +9189,24 @@ void CGOpenMPRuntime::emitTargetNumItera
   if (!TD)
 return;
   const auto *LD = cast(TD);
-  auto & = [LD, , , this](CodeGenFunction ,
+  auto & = [LD, DeviceID, SizeEmitter, this](CodeGenFunction ,
  PrePostActionTy &) {
-llvm::Value *NumIterations = SizeEmitter(CGF, *LD);
-
-// Emit device ID if any.
-llvm::Value *DeviceID;
-if (Device)
-  DeviceID = CGF.Builder.CreateIntCast(CGF.EmitScalarExpr(Device),
-   CGF.Int64Ty, /*isSigned=*/true);
-else
-  DeviceID = CGF.Builder.getInt64(OMP_DEVICEID_UNDEF);
-
-llvm::Value *Args[] = {DeviceID, NumIterations};
-CGF.EmitRuntimeCall(
-createRuntimeFunction(OMPRTL__kmpc_push_target_tripcount), Args);
+if (llvm::Value *NumIterations = SizeEmitter(CGF, *LD)) {
+  llvm::Value *Args[] = {DeviceID, NumIterations};
+  CGF.EmitRuntimeCall(
+  createRuntimeFunction(OMPRTL__kmpc_push_target_tripcount), Args);
+}
   };
   emitInlinedDirective(CGF, OMPD_unknown, CodeGen);
 }
 
-void CGOpenMPRuntime::emitTargetCall(CodeGenFunction ,
- const OMPExecutableDirective ,
- llvm::Function *OutlinedFn,
- llvm::Value *OutlinedFnID,
- const Expr *IfCond, const Expr *Device) {
+void CGOpenMPRuntime::emitTargetCall(
+CodeGenFunction , const OMPExecutableDirective ,
+llvm::Function *OutlinedFn, llvm::Value *OutlinedFnID, const Expr *IfCond,
+const Expr *Device,
+llvm::function_ref
+SizeEmitter) {
   if (!CGF.HaveInsertPoint())
 return;
 
@@ -9229,8 +9225,8 @@ void CGOpenMPRuntime::emitTargetCall(Cod
   llvm::Value *MapTypesArray = nullptr;
   // Fill up the pointer arrays and transfer execution to the device.
   auto & = [this, Device, OutlinedFn, OutlinedFnID, , ,
-, , RequiresOuterTask,
-](CodeGenFunction , PrePostActionTy &) {
+, , RequiresOuterTask, ,
+SizeEmitter](CodeGenFunction , PrePostActionTy &) {
 // On top of the arrays that were filled up, the target offloading call
 // takes as arguments the device id as well as the host pointer. The host
 // pointer is used by the runtime library to identify the current target
@@ -9262,6 +9258,9 @@ void CGOpenMPRuntime::emitTargetCall(Cod
 llvm::Value *NumTeams = emitNumTeamsForTargetDirective(CGF, D);
 llvm::Value *NumThreads = emitNumThreadsForTargetDirective(CGF, D);
 
+// Emit tripcount for the target loop-based directive.
+emitTargetNumIterationsCall(CGF, D, DeviceID, SizeEmitter);
+
 bool HasNowait = D.hasClausesOfKind();
 // The target region is an outlined function launched by the runtime
 // via calls __tgt_target() or __tgt_target_teams().
@@ -11285,12 +11284,13 @@ void CGOpenMPSIMDRuntime::emitTargetOutl
   llvm_unreachable("Not supported in SIMD-only mode");
 }
 
-void CGOpenMPSIMDRuntime::emitTargetCall(CodeGenFunction ,
- 

r372252 - [OPENMP]Fix for PR43349: Crash for privatized loop bound.

2019-09-18 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Sep 18 12:24:07 2019
New Revision: 372252

URL: http://llvm.org/viewvc/llvm-project?rev=372252=rev
Log:
[OPENMP]Fix for PR43349: Crash for privatized loop bound.

If the variable, used in the loop boundaries, is not captured in the
construct, this variable must be considered as undefined if it was
privatized.

Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/parallel_for_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=372252=372251=372252=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Wed Sep 18 12:24:07 2019
@@ -120,11 +120,27 @@ public:
 class OMPLoopScope : public CodeGenFunction::RunCleanupsScope {
   void emitPreInitStmt(CodeGenFunction , const OMPLoopDirective ) {
 CodeGenFunction::OMPMapVars PreCondVars;
+llvm::DenseSet EmittedAsPrivate;
 for (const auto *E : S.counters()) {
   const auto *VD = cast(cast(E)->getDecl());
+  EmittedAsPrivate.insert(VD->getCanonicalDecl());
   (void)PreCondVars.setVarAddr(
   CGF, VD, CGF.CreateMemTemp(VD->getType().getNonReferenceType()));
 }
+// Mark private vars as undefs.
+for (const auto *C : S.getClausesOfKind()) {
+  for (const Expr *IRef : C->varlists()) {
+const auto *OrigVD = cast(cast(IRef)->getDecl());
+if (EmittedAsPrivate.insert(OrigVD->getCanonicalDecl()).second) {
+  (void)PreCondVars.setVarAddr(
+  CGF, OrigVD,
+  Address(llvm::UndefValue::get(
+  
CGF.ConvertTypeForMem(CGF.getContext().getPointerType(
+  OrigVD->getType().getNonReferenceType(,
+  CGF.getContext().getDeclAlign(OrigVD)));
+}
+  }
+}
 (void)PreCondVars.apply(CGF);
 if (const auto *PreInits = cast_or_null(S.getPreInits())) {
   for (const auto *I : PreInits->decls())

Modified: cfe/trunk/test/OpenMP/parallel_for_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_codegen.cpp?rev=372252=372251=372252=diff
==
--- cfe/trunk/test/OpenMP/parallel_for_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_for_codegen.cpp Wed Sep 18 12:24:07 2019
@@ -35,12 +35,14 @@ void with_var_schedule() {
 // CHECK: [[CHUNK:%.+]] = load i64, i64* %
 // CHECK: call void {{.+}} @__kmpc_fork_call({{.+}}, i64 [[CHUNK]])
 
+// CHECK: [[UNDEF_A:%.+]] = load double, double* undef
+// CHECK: fadd double 2.00e+00, [[UNDEF_A]]
 // CHECK: [[CHUNK_VAL:%.+]] = load i8, i8* %
 // CHECK: [[CHUNK_SIZE:%.+]] = sext i8 [[CHUNK_VAL]] to i64
 // CHECK: call void @__kmpc_for_static_init_8u([[IDENT_T_TY]]* [[LOOP_LOC]], 
i32 [[GTID:%[^,]+]], i32 33, i32* [[IS_LAST:%[^,]+]], i64* [[OMP_LB:%[^,]+]], 
i64* [[OMP_UB:%[^,]+]], i64* [[OMP_ST:%[^,]+]], i64 1, i64 [[CHUNK_SIZE]])
 // CHECK: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[LOOP_LOC]], i32 
[[GTID]])
-#pragma omp parallel for schedule(static, char(a))
-  for (unsigned long long i = 1; i < 2; ++i) {
+#pragma omp parallel for schedule(static, char(a)) private(a)
+  for (unsigned long long i = 1; i < 2 + a; ++i) {
   }
 }
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r372235 - [OPENMP5.0]Allow multiple context selectors in the context selector

2019-09-18 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Sep 18 09:24:31 2019
New Revision: 372235

URL: http://llvm.org/viewvc/llvm-project?rev=372235=rev
Log:
[OPENMP5.0]Allow multiple context selectors in the context selector
sets.

According to OpenMP 5.0, context selector set might include several
context selectors, separated with commas. Patch fixes this problem.

Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/OpenMP/declare_variant_ast_print.c
cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp
cfe/trunk/test/OpenMP/declare_variant_messages.c
cfe/trunk/test/OpenMP/declare_variant_messages.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=372235=372234=372235=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Wed Sep 18 09:24:31 2019
@@ -2834,10 +2834,15 @@ private:
   DeclGroupPtrTy ParseOMPDeclareSimdClauses(DeclGroupPtrTy Ptr,
 CachedTokens ,
 SourceLocation Loc);
+  /// Parses OpenMP context selectors and calls \p Callback for each
+  /// successfully parsed context selector.
+  bool
+  parseOpenMPContextSelectors(SourceLocation Loc,
+  llvm::function_ref Callback);
+
   /// Parse clauses for '#pragma omp declare variant'.
-  DeclGroupPtrTy ParseOMPDeclareVariantClauses(DeclGroupPtrTy Ptr,
-   CachedTokens ,
-   SourceLocation Loc);
+  void ParseOMPDeclareVariantClauses(DeclGroupPtrTy Ptr, CachedTokens ,
+ SourceLocation Loc);
   /// Parse clauses for '#pragma omp declare target'.
   DeclGroupPtrTy ParseOMPDeclareTargetClauses();
   /// Parse '#pragma omp end declare target'.

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=372235=372234=372235=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Sep 18 09:24:31 2019
@@ -9529,15 +9529,26 @@ public:
   ArrayRef Alignments, ArrayRef Linears,
   ArrayRef LinModifiers, ArrayRef Steps, SourceRange SR);
 
+  /// Checks '\#pragma omp declare variant' variant function and original
+  /// functions after parsing of the associated method/function.
+  /// \param DG Function declaration to which declare variant directive is
+  /// applied to.
+  /// \param VariantRef Expression that references the variant function, which
+  /// must be used instead of the original one, specified in \p DG.
+  /// \returns None, if the function/variant function are not compatible with
+  /// the pragma,pair of original function/variant ref expression otherwise.
+  Optional>
+  checkOpenMPDeclareVariantFunction(DeclGroupPtrTy DG, Expr *VariantRef,
+SourceRange SR);
+
   /// Called on well-formed '\#pragma omp declare variant' after parsing of
   /// the associated method/function.
-  /// \param DG Function declaration to which declare variant directive is
+  /// \param FD Function declaration to which declare variant directive is
   /// applied to.
   /// \param VariantRef Expression that references the variant function, which
   /// must be used instead of the original one, specified in \p DG.
-  DeclGroupPtrTy ActOnOpenMPDeclareVariantDirective(DeclGroupPtrTy DG,
-Expr *VariantRef,
-SourceRange SR);
+  void ActOnOpenMPDeclareVariantDirective(FunctionDecl *FD, Expr *VariantRef,
+  SourceRange SR);
 
   OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind,
  Expr *Expr,

Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=372235=372234=372235=diff
==
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Wed Sep 18 09:24:31 2019
@@ -788,65 +788,53 @@ Parser::ParseOMPDeclareSimdClauses(Parse
 
 /// Parses clauses for 'declare variant' directive.
 /// clause:
-/// 'match' '('
 ///  '=' '{'  '}'
-/// ')'
-static bool parseDeclareVariantClause(Parser ) {
-  Token Tok = P.getCurToken();
-  // Parse 'match'.
-  if (!Tok.is(tok::identifier) ||
-  P.getPreprocessor().getSpelling(Tok).compare("match")) {
-P.Diag(Tok.getLocation(), 

r372148 - [OPENMP] Rework the test, NFC.

2019-09-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Sep 17 10:44:27 2019
New Revision: 372148

URL: http://llvm.org/viewvc/llvm-project?rev=372148=rev
Log:
[OPENMP] Rework the test, NFC.

Modified:
cfe/trunk/test/OpenMP/parallel_for_codegen.cpp

Modified: cfe/trunk/test/OpenMP/parallel_for_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_codegen.cpp?rev=372148=372147=372148=diff
==
--- cfe/trunk/test/OpenMP/parallel_for_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_for_codegen.cpp Tue Sep 17 10:44:27 2019
@@ -387,14 +387,12 @@ void parallel_for(float *a, const int n)
 // TERM_DEBUG-DAG: [[DBG_LOC_END]] = !DILocation(line: [[@LINE-18]],
 
 #else // OMP5
-// OMP5: [[LOOP_LOC:@.+]] = private unnamed_addr global %struct.ident_t { i32 
0, i32 514, i32 0, i32 0, i8*
-
 // OMP5-LABEL: increment
 int increment () {
 // OMP5: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* 
[[DEFAULT_LOC:[@%].+]])
   #pragma omp for
 // Determine UB = min(UB, GlobalUB)
-// OMP5: call void @__kmpc_for_static_init_4(%struct.ident_t* [[LOOP_LOC]], 
i32 [[GTID]], i32 34, i32* [[IS_LAST:%[^,]+]], i32* [[OMP_LB:%[^,]+]], i32* 
[[OMP_UB:%[^,]+]], i32* [[OMP_ST:%[^,]+]], i32 1, i32 1)
+// OMP5: call void @__kmpc_for_static_init_4(%struct.ident_t* 
[[LOOP_LOC:[@%].+]], i32 [[GTID]], i32 34, i32* [[IS_LAST:%[^,]+]], i32* 
[[OMP_LB:%[^,]+]], i32* [[OMP_UB:%[^,]+]], i32* [[OMP_ST:%[^,]+]], i32 1, i32 1)
 // OMP5-NEXT: [[UB:%.+]] = load i32, i32* [[OMP_UB]]
 // OMP5-NEXT: [[UBCMP:%.+]] = icmp sgt i32 [[UB]], 4
 // OMP5-NEXT: br i1 [[UBCMP]], label [[UB_TRUE:%[^,]+]], label 
[[UB_FALSE:%[^,]+]]


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r372147 - [OPENMP5.0]Introduce attribute for declare variant directive.

2019-09-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Sep 17 10:36:49 2019
New Revision: 372147

URL: http://llvm.org/viewvc/llvm-project?rev=372147=rev
Log:
[OPENMP5.0]Introduce attribute for declare variant directive.

Added attribute for declare variant directive. It will allow to handle
declare variant directive at the codegen and will allow to add extra
checks.

Added:
cfe/trunk/test/OpenMP/declare_variant_ast_print.c
cfe/trunk/test/OpenMP/declare_variant_ast_print.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/OpenMP/declare_variant_messages.c

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=372147=372146=372147=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Sep 17 10:36:49 2019
@@ -3265,6 +3265,29 @@ def OMPAllocateDecl : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
+def OMPDeclareVariant : Attr {
+  let Spellings = [Pragma<"omp", "declare variant">];
+  let Subjects = SubjectList<[Function]>;
+  let SemaHandler = 0;
+  let HasCustomParsing = 1;
+  let Documentation = [OMPDeclareVariantDocs];
+  let Args = [
+ExprArgument<"VariantFuncRef">
+  ];
+  let AdditionalMembers = [{
+void printPrettyPragma(raw_ostream & OS, const PrintingPolicy )
+const {
+  if (const Expr *E = getVariantFuncRef()) {
+OS << "(";
+E->printPretty(OS, nullptr, Policy);
+OS << ")";
+  }
+  // TODO: add printing of real context selectors.
+  OS << " match(unknown={})";
+}
+  }];
+}
+
 def InternalLinkage : InheritableAttr {
   let Spellings = [Clang<"internal_linkage">];
   let Subjects = SubjectList<[Var, Function, CXXRecord]>;

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=372147=372146=372147=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Tue Sep 17 10:36:49 2019
@@ -3208,6 +3208,34 @@ where clause is one of the following:
   }];
 }
 
+def OMPDeclareVariantDocs : Documentation {
+  let Category = DocCatFunction;
+  let Heading = "#pragma omp declare variant";
+  let Content = [{
+The `declare variant` directive declares a specialized variant of a base
+ function and specifies the context in which that specialized variant is used.
+ The declare variant directive is a declarative directive.
+The syntax of the `declare variant` construct is as follows:
+
+  .. code-block:: none
+
+#pragma omp declare variant(variant-func-id) clause new-line
+[#pragma omp declare variant(variant-func-id) clause new-line]
+[...]
+function definition or declaration
+
+where clause is one of the following:
+
+  .. code-block:: none
+
+match(context-selector-specification)
+
+and where `variant-func-id` is the name of a function variant that is either a
+ base language identifier or, for C++, a template-id.
+
+  }];
+}
+
 def NoStackProtectorDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=372147=372146=372147=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Sep 17 10:36:49 
2019
@@ -9429,6 +9429,10 @@ def err_omp_declare_variant_diff : Error
 def err_omp_declare_variant_incompat_types : Error<
   "variant in '#pragma omp declare variant' with type %0 is incompatible with 
type %1"
   >;
+def warn_omp_declare_variant_marked_as_declare_variant : Warning<
+  "variant function in '#pragma omp declare variant' is itself marked as 
'#pragma omp declare variant'"
+  >, InGroup;
+def note_omp_marked_declare_variant_here : Note<"marked as 'declare variant' 
here">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=372147=372146=372147=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Sep 17 10:36:49 2019
@@ -9089,6 +9089,12 @@ private:
  MapT , unsigned Selector = 0,
  

r372130 - [OPENMP]Try to rework the test to pacify the buildbots, NFC.

2019-09-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Sep 17 08:11:52 2019
New Revision: 372130

URL: http://llvm.org/viewvc/llvm-project?rev=372130=rev
Log:
[OPENMP]Try to rework the test to pacify the buildbots, NFC.

Modified:
cfe/trunk/test/OpenMP/parallel_for_codegen.cpp

Modified: cfe/trunk/test/OpenMP/parallel_for_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_codegen.cpp?rev=372130=372129=372130=diff
==
--- cfe/trunk/test/OpenMP/parallel_for_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_for_codegen.cpp Tue Sep 17 08:11:52 2019
@@ -387,15 +387,14 @@ void parallel_for(float *a, const int n)
 // TERM_DEBUG-DAG: [[DBG_LOC_END]] = !DILocation(line: [[@LINE-18]],
 
 #else // OMP5
-// OMP5: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
-// OMP5: [[LOOP_LOC:@.+]] = private unnamed_addr global [[IDENT_T_TY]] { i32 
0, i32 514, i32 0, i32 0, i8*
+// OMP5: [[LOOP_LOC:@.+]] = private unnamed_addr global %struct.ident_t { i32 
0, i32 514, i32 0, i32 0, i8*
 
 // OMP5-LABEL: increment
 int increment () {
-// OMP5: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* 
[[DEFAULT_LOC:[@%].+]])
+// OMP5: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* 
[[DEFAULT_LOC:[@%].+]])
   #pragma omp for
 // Determine UB = min(UB, GlobalUB)
-// OMP5: call void @__kmpc_for_static_init_4([[IDENT_T_TY]]* [[LOOP_LOC]], i32 
[[GTID]], i32 34, i32* [[IS_LAST:%[^,]+]], i32* [[OMP_LB:%[^,]+]], i32* 
[[OMP_UB:%[^,]+]], i32* [[OMP_ST:%[^,]+]], i32 1, i32 1)
+// OMP5: call void @__kmpc_for_static_init_4(%struct.ident_t* [[LOOP_LOC]], 
i32 [[GTID]], i32 34, i32* [[IS_LAST:%[^,]+]], i32* [[OMP_LB:%[^,]+]], i32* 
[[OMP_UB:%[^,]+]], i32* [[OMP_ST:%[^,]+]], i32 1, i32 1)
 // OMP5-NEXT: [[UB:%.+]] = load i32, i32* [[OMP_UB]]
 // OMP5-NEXT: [[UBCMP:%.+]] = icmp sgt i32 [[UB]], 4
 // OMP5-NEXT: br i1 [[UBCMP]], label [[UB_TRUE:%[^,]+]], label 
[[UB_FALSE:%[^,]+]]
@@ -425,7 +424,7 @@ int increment () {
 // OMP5-NEXT: br label %[[LOOP1_HEAD]]
 ;
 // OMP5: [[LOOP1_END]]
-// OMP5: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[LOOP_LOC]], i32 
[[GTID]])
+// OMP5: call void @__kmpc_for_static_fini(%struct.ident_t* [[LOOP_LOC]], i32 
[[GTID]])
 // OMP5: __kmpc_barrier
   return 0;
 // OMP5: ret i32 0
@@ -433,10 +432,10 @@ int increment () {
 
 // OMP5-LABEL: decrement_nowait
 int decrement_nowait () {
-// OMP5: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num([[IDENT_T_TY]]* 
[[DEFAULT_LOC:[@%].+]])
+// OMP5: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* 
[[DEFAULT_LOC:[@%].+]])
   #pragma omp for nowait
 // Determine UB = min(UB, GlobalUB)
-// OMP5: call void @__kmpc_for_static_init_4([[IDENT_T_TY]]* [[LOOP_LOC]], i32 
[[GTID]], i32 34, i32* [[IS_LAST:%[^,]+]], i32* [[OMP_LB:%[^,]+]], i32* 
[[OMP_UB:%[^,]+]], i32* [[OMP_ST:%[^,]+]], i32 1, i32 1)
+// OMP5: call void @__kmpc_for_static_init_4(%struct.ident_t* [[LOOP_LOC]], 
i32 [[GTID]], i32 34, i32* [[IS_LAST:%[^,]+]], i32* [[OMP_LB:%[^,]+]], i32* 
[[OMP_UB:%[^,]+]], i32* [[OMP_ST:%[^,]+]], i32 1, i32 1)
 // OMP5-NEXT: [[UB:%.+]] = load i32, i32* [[OMP_UB]]
 // OMP5-NEXT: [[UBCMP:%.+]] = icmp sgt i32 [[UB]], 4
 // OMP5-NEXT: br i1 [[UBCMP]], label [[UB_TRUE:%[^,]+]], label 
[[UB_FALSE:%[^,]+]]
@@ -465,7 +464,7 @@ int decrement_nowait () {
 // OMP5-NEXT: br label %[[LOOP1_HEAD]]
 ;
 // OMP5: [[LOOP1_END]]
-// OMP5: call void @__kmpc_for_static_fini([[IDENT_T_TY]]* [[LOOP_LOC]], i32 
[[GTID]])
+// OMP5: call void @__kmpc_for_static_fini(%struct.ident_t* [[LOOP_LOC]], i32 
[[GTID]])
 // OMP5-NOT: __kmpc_barrier
   return 0;
 // OMP5: ret i32 0


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r372055 - [OPENMP] Fix the test, NFC

2019-09-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Sep 16 17:08:50 2019
New Revision: 372055

URL: http://llvm.org/viewvc/llvm-project?rev=372055=rev
Log:
[OPENMP] Fix the test, NFC

Modified:
cfe/trunk/test/OpenMP/parallel_for_codegen.cpp

Modified: cfe/trunk/test/OpenMP/parallel_for_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_codegen.cpp?rev=372055=372054=372055=diff
==
--- cfe/trunk/test/OpenMP/parallel_for_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_for_codegen.cpp Mon Sep 16 17:08:50 2019
@@ -15,7 +15,9 @@
 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -DOMP5 -x c++ -triple 
x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | 
FileCheck --check-prefix=OMP5 %s
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -x c++ -std=c++11 
-triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -x c++ -triple 
x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t 
-verify %s -emit-llvm -o - | FileCheck --check-prefix=OMP5 %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -std=c++11 -triple 
x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -DOMP5 -x c++ 
-triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - 
| FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -DOMP5 -x c++ -std=c++11 
-triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -DOMP5 -x c++ -triple 
x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t 
-verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 #ifndef HEADER
 #define HEADER
 
@@ -385,8 +387,8 @@ void parallel_for(float *a, const int n)
 // TERM_DEBUG-DAG: [[DBG_LOC_END]] = !DILocation(line: [[@LINE-18]],
 
 #else // OMP5
-// OMP5-DAG: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
-// OMP5-DAG: [[LOOP_LOC:@.+]] = private unnamed_addr global [[IDENT_T_TY]] { 
i32 0, i32 514, i32 0, i32 0, i8*
+// OMP5: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
+// OMP5: [[LOOP_LOC:@.+]] = private unnamed_addr global [[IDENT_T_TY]] { i32 
0, i32 514, i32 0, i32 0, i8*
 
 // OMP5-LABEL: increment
 int increment () {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r372040 - [OPENMP]Fix the test, NFC.

2019-09-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Sep 16 15:17:10 2019
New Revision: 372040

URL: http://llvm.org/viewvc/llvm-project?rev=372040=rev
Log:
[OPENMP]Fix the test, NFC.

Modified:
cfe/trunk/test/OpenMP/parallel_for_codegen.cpp

Modified: cfe/trunk/test/OpenMP/parallel_for_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_codegen.cpp?rev=372040=372039=372040=diff
==
--- cfe/trunk/test/OpenMP/parallel_for_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_for_codegen.cpp Mon Sep 16 15:17:10 2019
@@ -19,6 +19,7 @@
 #ifndef HEADER
 #define HEADER
 
+#ifndef OMP5
 // CHECK-DAG: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
 // CHECK-DAG: [[LOOP_LOC:@.+]] = private unnamed_addr global [[IDENT_T_TY]] { 
i32 0, i32 514, i32 0, i32 0, i8*
 
@@ -383,7 +384,7 @@ void parallel_for(float *a, const int n)
 // TERM_DEBUG-DAG: [[DBG_LOC_START]] = !DILocation(line: [[@LINE-4]],
 // TERM_DEBUG-DAG: [[DBG_LOC_END]] = !DILocation(line: [[@LINE-18]],
 
-#ifdef OMP5
+#else // OMP5
 // OMP5-DAG: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* }
 // OMP5-DAG: [[LOOP_LOC:@.+]] = private unnamed_addr global [[IDENT_T_TY]] { 
i32 0, i32 514, i32 0, i32 0, i8*
 
@@ -467,7 +468,7 @@ int decrement_nowait () {
   return 0;
 // OMP5: ret i32 0
 }
-#endif
+#endif // OMP5
 
 #endif // HEADER
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r372011 - [OPENMP]Fix parsing/sema for function templates with declare simd.

2019-09-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Sep 16 10:06:31 2019
New Revision: 372011

URL: http://llvm.org/viewvc/llvm-project?rev=372011=rev
Log:
[OPENMP]Fix parsing/sema for function templates with declare simd.

Need to return original declaration group with FunctionTemplateDecl, not
the inner FunctionDecl, to correctly handle parsing of directives with
the templates parameters.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/declare_simd_ast_print.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=372011=372010=372011=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon Sep 16 10:06:31 2019
@@ -4889,7 +4889,7 @@ Sema::DeclGroupPtrTy Sema::ActOnOpenMPDe
   const_cast(LinModifiers.data()), LinModifiers.size(),
   NewSteps.data(), NewSteps.size(), SR);
   ADecl->addAttr(NewAttr);
-  return ConvertDeclToDeclGroup(ADecl);
+  return DG;
 }
 
 Sema::DeclGroupPtrTy

Modified: cfe/trunk/test/OpenMP/declare_simd_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_simd_ast_print.cpp?rev=372011=372010=372011=diff
==
--- cfe/trunk/test/OpenMP/declare_simd_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_simd_ast_print.cpp Mon Sep 16 10:06:31 2019
@@ -21,6 +21,15 @@ void add_1(float *d) __attribute__((cold
 // CHECK-NEXT: void add_1(float *d) __attribute__((cold));
 //
 
+#pragma omp declare simd aligned(hp, hp2:V)
+#pragma omp declare simd aligned(hp, hp2:V)
+template  void h(C *hp, C *hp2, C *hq, C *lin) {
+}
+// CHECK-NEXT: #pragma omp declare simd aligned(hp: V) aligned(hp2: V)
+// CHECK-NEXT: #pragma omp declare simd aligned(hp: V) aligned(hp2: V)
+// CHECK-NEXT: template  void h(C *hp, C *hp2, C *hq, C *lin) {
+// CHECK-NEXT: }
+
 #pragma omp declare simd aligned(hp, hp2)
 template  void h(C *hp, C *hp2, C *hq, C *lin) {
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371892 - [OPENMP5.0]Add basic support for declare variant directive.

2019-09-13 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Sep 13 13:18:17 2019
New Revision: 371892

URL: http://llvm.org/viewvc/llvm-project?rev=371892=rev
Log:
[OPENMP5.0]Add basic support for declare variant directive.

Added basic support for declare variant directive and its match clause
with user context selector.

Added:
cfe/trunk/test/OpenMP/declare_variant_messages.c
cfe/trunk/test/OpenMP/declare_variant_messages.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=371892=371891=371892=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Sep 13 13:18:17 
2019
@@ -201,6 +201,7 @@ def err_invalid_token_after_declarator_s
   "invalid %0 at end of declaration; did you mean '='?">;
 def err_expected_statement : Error<"expected statement">;
 def err_expected_lparen_after : Error<"expected '(' after '%0'">;
+def err_expected_lbrace_after : Error<"expected '{' after '%0'">;
 def err_expected_rparen_after : Error<"expected ')' after '%0'">;
 def err_expected_punc : Error<"expected ')' or ',' after '%0'">;
 def err_expected_less_after : Error<"expected '<' after '%0'">;
@@ -1177,8 +1178,8 @@ def err_omp_expected_identifier_for_crit
   "expected identifier specifying the name of the 'omp critical' directive">;
 def err_omp_expected_reduction_identifier : Error<
   "expected identifier or one of the following operators: '+', '-', '*', '&', 
'|', '^', '&&', or '||'">;
-def err_omp_decl_in_declare_simd : Error<
-  "function declaration is expected after 'declare simd' directive">;
+def err_omp_decl_in_declare_simd_variant : Error<
+  "function declaration is expected after 'declare %select{simd|variant}0' 
directive">;
 def err_omp_unknown_map_type : Error<
   "incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 
'release', or 'delete'">;
 def err_omp_unknown_map_type_modifier : Error<
@@ -1199,6 +1200,12 @@ def err_omp_mapper_illegal_identifier :
   "illegal OpenMP user-defined mapper identifier">;
 def err_omp_mapper_expected_declarator : Error<
   "expected declarator on 'omp declare mapper' directive">;
+def err_omp_declare_variant_wrong_clause : Error<
+  "expected '%0' clause on 'omp declare variant' directive">;
+def err_omp_declare_variant_no_ctx_selector : Error<
+  "expected context selector in '%0' clause on 'omp declare variant' 
directive">;
+def err_omp_declare_variant_equal_expected : Error<
+  "expected '=' after '%0' context selector set name on 'omp declare variant' 
directive">;
 def warn_omp_more_one_device_type_clause : Warning<
   "more than one 'device_type' clause is specified">,
   InGroup;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=371892=371891=371892=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Sep 13 13:18:17 
2019
@@ -9213,10 +9213,10 @@ def err_omp_single_copyprivate_with_nowa
   "the 'copyprivate' clause must not be used with the 'nowait' clause">;
 def note_omp_nowait_clause_here : Note<
   "'nowait' clause is here">;
-def err_omp_single_decl_in_declare_simd : Error<
-  "single declaration is expected after 'declare simd' directive">;
+def err_omp_single_decl_in_declare_simd_variant : Error<
+  "single declaration is expected after 'declare %select{simd|variant}0' 
directive">;
 def err_omp_function_expected : Error<
-  "'#pragma omp declare simd' can only be applied to functions">;
+  "'#pragma omp declare %select{simd|variant}0' can only be applied to 
functions">;
 def err_omp_wrong_cancel_region : Error<
   "one of 'for', 'parallel', 'sections' or 'taskgroup' is expected">;
 def err_omp_parent_cancel_region_nowait : Error<
@@ -9408,6 +9408,27 @@ def note_omp_marked_device_type_here : N
 def warn_omp_declare_target_after_first_use : Warning<
   "declaration marked as declare target after first use, it may lead to 
incorrect results">,
   InGroup;
+def err_omp_declare_variant_incompat_attributes : Error<
+  "'#pragma omp declare variant' is not compatible with any target-specific 
attributes">;
+def 

r371627 - [OPENMP]Updated status page, NFC.

2019-09-11 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Sep 11 07:44:30 2019
New Revision: 371627

URL: http://llvm.org/viewvc/llvm-project?rev=371627=rev
Log:
[OPENMP]Updated status page, NFC.

Modified:
cfe/trunk/docs/OpenMPSupport.rst

Modified: cfe/trunk/docs/OpenMPSupport.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/OpenMPSupport.rst?rev=371627=371626=371627=diff
==
--- cfe/trunk/docs/OpenMPSupport.rst (original)
+++ cfe/trunk/docs/OpenMPSupport.rst Wed Sep 11 07:44:30 2019
@@ -149,7 +149,7 @@ implementation.
 
+--+--+--+---+
 | loop extension   | collapse imperfectly nested loop  
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+
-| loop extension   | collapse non-rectangular nested loop  
   | :part:`worked on`| 
  |
+| loop extension   | collapse non-rectangular nested loop  
   | :good:`done` | 
  |
 
+--+--+--+---+
 | loop extension   | C++ range-base for loop   
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+
@@ -233,7 +233,7 @@ implementation.
 
+--+--+--+---+
 | device extension | map(replicate) or map(local) when requires 
unified_shared_me | :part:`worked on`| D55719,D55892
 |
 
+--+--+--+---+
-| device extension | teams construct on the host device
   | :part:`worked on`| 
  |
+| device extension | teams construct on the host device
   | :part:`worked on`| Clang part is done, r371553.
  |
 
+--+--+--+---+
 | atomic extension | hints for the atomic construct
   | :part:`worked on`| D51233  
  |
 
+--+--+--+---+
@@ -251,7 +251,7 @@ implementation.
 
+--+--+--+---+
 | misc extension   | conditional modifier for lastprivate clause   
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+
-| misc extension   | user-defined function variants
   | :none:`unclaimed`| 
  |
+| misc extension   | user-defined function variants
   | :part:`worked on`| D67294, D64095  
  |
 

r371553 - [OPENMP5.0]Allow teams directive outside of the target directives.

2019-09-10 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Sep 10 13:19:58 2019
New Revision: 371553

URL: http://llvm.org/viewvc/llvm-project?rev=371553=rev
Log:
[OPENMP5.0]Allow teams directive outside of the target directives.

According to OpenMP 5.0, teams directives are allowed not only in the
target context, but also in the implicit parallel regions.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/teams_ast_print.cpp
cfe/trunk/test/OpenMP/teams_codegen.cpp
cfe/trunk/test/OpenMP/teams_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=371553=371552=371553=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Sep 10 13:19:58 2019
@@ -3876,7 +3876,10 @@ static bool checkNestingOfRegions(Sema &
   // OpenMP [2.16, Nesting of Regions]
   // If specified, a teams construct must be contained within a target
   // construct.
-  NestingProhibited = ParentRegion != OMPD_target;
+  NestingProhibited =
+  (SemaRef.LangOpts.OpenMP <= 45 && ParentRegion != OMPD_target) ||
+  (SemaRef.LangOpts.OpenMP >= 50 && ParentRegion != OMPD_unknown &&
+   ParentRegion != OMPD_target);
   OrphanSeen = ParentRegion == OMPD_unknown;
   Recommend = ShouldBeInTargetRegion;
 }

Modified: cfe/trunk/test/OpenMP/teams_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_ast_print.cpp?rev=371553=371552=371553=diff
==
--- cfe/trunk/test/OpenMP/teams_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/teams_ast_print.cpp Tue Sep 10 13:19:58 2019
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify 
%s -ast-print | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -DOMP5 -ast-print %s | 
FileCheck %s --check-prefix=CHECK --check-prefix=OMP5
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -x c++ -std=c++11 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -std=c++11 -include-pch 
%t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix=CHECK 
--check-prefix=OMP5
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
@@ -37,6 +40,10 @@ T tmain(T argc, T *argv) {
   T b = argc, c, d, e, f, g;
   static T a;
   S s;
+#ifdef OMP5
+#pragma omp teams
+  a=2;
+#endif // OMP5
 #pragma omp target
 #pragma omp teams
   a=2;
@@ -53,6 +60,8 @@ T tmain(T argc, T *argv) {
 // CHECK-NEXT: T b = argc, c, d, e, f, g;
 // CHECK-NEXT: static T a;
 // CHECK-NEXT: S s;
+// OMP5-NEXT:  #pragma omp teams
+// OMP5-NEXT:  a = 2;
 // CHECK-NEXT: #pragma omp target
 // CHECK-NEXT: #pragma omp teams{{$}}
 // CHECK-NEXT: a = 2;
@@ -66,6 +75,8 @@ T tmain(T argc, T *argv) {
 // CHECK-NEXT: int b = argc, c, d, e, f, g;
 // CHECK-NEXT: static int a;
 // CHECK-NEXT: S s;
+// OMP5-NEXT:  #pragma omp teams
+// OMP5-NEXT:  a = 2;
 // CHECK-NEXT: #pragma omp target
 // CHECK-NEXT: #pragma omp teams
 // CHECK-NEXT: a = 2;
@@ -79,6 +90,8 @@ T tmain(T argc, T *argv) {
 // CHECK-NEXT: long b = argc, c, d, e, f, g;
 // CHECK-NEXT: static long a;
 // CHECK-NEXT: S s;
+// OMP5-NEXT:  #pragma omp teams
+// OMP5-NEXT:  a = 2;
 // CHECK-NEXT: #pragma omp target
 // CHECK-NEXT: #pragma omp teams
 // CHECK-NEXT: a = 2;

Modified: cfe/trunk/test/OpenMP/teams_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_codegen.cpp?rev=371553=371552=371553=diff
==
--- cfe/trunk/test/OpenMP/teams_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/teams_codegen.cpp Tue Sep 10 13:19:58 2019
@@ -394,4 +394,31 @@ int main (int argc, char **argv) {
 // CK5-NEXT: }
 
 #endif // CK5
+
+// Test host codegen.
+// RUN: %clang_cc1 -DCK6 -verify -fopenmp -fopenmp-version=50 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck %s --check-prefix CK6 --check-prefix CK6-64
+// RUN: %clang_cc1 -DCK6 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 
-triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK6 -fopenmp-version=50 -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 CK6 --check-prefix CK6-64
+// RUN: %clang_cc1 -DCK6 -verify -fopenmp -fopenmp-version=50 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | 
FileCheck %s 

r371548 - Fix for PR43175: compiler crash when trying to emit noncapturable

2019-09-10 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Sep 10 12:16:56 2019
New Revision: 371548

URL: http://llvm.org/viewvc/llvm-project?rev=371548=rev
Log:
Fix for PR43175: compiler crash when trying to emit noncapturable
constant.

If the constexpr variable is partially initialized, the initializer can
be emitted as the structure, not as an array, because of some early
optimizations. The llvm variable gets the type from this constant and,
thus, gets the type which is pointer to struct rather than pointer to an
array. We need to convert this type to be truely array, otherwise it may
lead to the compiler crash when trying to emit array subscript
expression.

Added:
cfe/trunk/test/OpenMP/constexpr_partial_array.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=371548=371547=371548=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Sep 10 12:16:56 2019
@@ -2539,6 +2539,11 @@ LValue CodeGenFunction::EmitDeclRefLValu
 // Spill the constant value to a global.
 Addr = CGM.createUnnamedGlobalFrom(*VD, Val,
getContext().getDeclAlign(VD));
+llvm::Type *VarTy = getTypes().ConvertTypeForMem(VD->getType());
+auto *PTy = llvm::PointerType::get(
+VarTy, getContext().getTargetAddressSpace(VD->getType()));
+if (PTy != Addr.getType())
+  Addr = Builder.CreatePointerBitCastOrAddrSpaceCast(Addr, PTy);
   } else {
 // Should we be using the alignment of the constant pointer we emitted?
 CharUnits Alignment =

Added: cfe/trunk/test/OpenMP/constexpr_partial_array.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/constexpr_partial_array.cpp?rev=371548=auto
==
--- cfe/trunk/test/OpenMP/constexpr_partial_array.cpp (added)
+++ cfe/trunk/test/OpenMP/constexpr_partial_array.cpp Tue Sep 10 12:16:56 2019
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -verify -triple x86_64-pc-windows-msvc19.22.27905 
-emit-llvm -o - -fopenmp %s | FileCheck %s
+// expected-no-diagnostics
+
+// CHECK: [[C_VAR_VAL:@.+]] = private unnamed_addr constant <{ i8, [26 x i8] 
}> <{ i8 1, [26 x i8] zeroinitializer }>,
+char a;
+bool b() {
+  static constexpr bool c[27]{1};
+  // CHECK: getelementptr inbounds [27 x i8], [27 x i8]* bitcast (<{ i8, [26 x 
i8] }>* [[C_VAR_VAL]] to [27 x i8]*),
+  return c[a];
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r370214 - [OPENMP][Analysis] Add analysis of the map clauses.

2019-08-28 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Aug 28 07:55:08 2019
New Revision: 370214

URL: http://llvm.org/viewvc/llvm-project?rev=370214=rev
Log:
[OPENMP][Analysis] Add analysis of the map clauses.

Summary:
Added basic analysis of map clauses. Only map clauses with to and tofrom
map type must be analyzed since all other map types (alloc, delete, etc.) do 
not require to use the value of the initial variable, instead they create the 
new copy of the variable.

Reviewers: NoQ

Subscribers: guansong, cfe-commits, kkwli0, caomhin

Tags: #clang

Differential Revision: https://reviews.llvm.org/D8

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/test/Analysis/cfg-openmp.cpp
cfe/trunk/test/OpenMP/target_data_messages.c
cfe/trunk/test/OpenMP/target_enter_data_map_messages.c
cfe/trunk/test/OpenMP/target_map_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_map_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_map_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_map_messages.cpp
cfe/trunk/test/OpenMP/target_simd_map_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_map_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_map_messages.cpp
cfe/trunk/test/OpenMP/target_teams_map_messages.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=370214=370213=370214=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Wed Aug 28 07:55:08 2019
@@ -5025,12 +5025,17 @@ public:
   }
 
   child_range used_children() {
+if (MapType == OMPC_MAP_to || MapType == OMPC_MAP_tofrom)
+  return child_range(reinterpret_cast(varlist_begin()),
+ reinterpret_cast(varlist_end()));
 return child_range(child_iterator(), child_iterator());
   }
   const_child_range used_children() const {
-return const_child_range(const_child_iterator(), const_child_iterator());
+auto Children = const_cast(this)->used_children();
+return const_child_range(Children.begin(), Children.end());
   }
 
+
   static bool classof(const OMPClause *T) {
 return T->getClauseKind() == OMPC_map;
   }

Modified: cfe/trunk/test/Analysis/cfg-openmp.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cfg-openmp.cpp?rev=370214=370213=370214=diff
==
--- cfe/trunk/test/Analysis/cfg-openmp.cpp (original)
+++ cfe/trunk/test/Analysis/cfg-openmp.cpp Wed Aug 28 07:55:08 2019
@@ -9,7 +9,8 @@ void xxx(int argc) {
 // CHECK-NEXT:   4: int rd;
 // CHECK-NEXT:   5: int lin;
 // CHECK-NEXT:   6: int step;
-  int x, cond, fp, rd, lin, step;
+// CHECK-NEXT:   7: int map;
+  int x, cond, fp, rd, lin, step, map;
 // CHECK-NEXT:   [[#ATOM:]]: x
 // CHECK-NEXT:   [[#ATOM+1]]: [B1.[[#ATOM]]] (ImplicitCastExpr, 
LValueToRValue, int)
 // CHECK-NEXT:   [[#ATOM+2]]: argc
@@ -219,10 +220,10 @@ void xxx(int argc) {
   : argc) if(cond) firstprivate(fp) reduction(-:rd)
   argc = x;
 // CHECK-NEXT:  [[#TPF:]]:
-// CHECK-SAME:  [B1.[[#TPF+13]]]
-// CHECK-NEXT:  [[#TPF+1]]: [B1.[[#TPF+13]]] (ImplicitCastExpr, 
LValueToRValue, int)
-// CHECK-NEXT:  [[#TPF+2]]: [B1.[[#TPF+12]]]
-// CHECK-NEXT:  [[#TPF+3]]: [B1.[[#TPF+12]]] = [B1.[[#TPF+1]]]
+// CHECK-SAME:  [B1.[[#TPF+14]]]
+// CHECK-NEXT:  [[#TPF+1]]: [B1.[[#TPF+14]]] (ImplicitCastExpr, 
LValueToRValue, int)
+// CHECK-NEXT:  [[#TPF+2]]: [B1.[[#TPF+13]]]
+// CHECK-NEXT:  [[#TPF+3]]: [B1.[[#TPF+13]]] = [B1.[[#TPF+1]]]
 // CHECK-NEXT:  [[#TPF+4]]: cond
 // CHECK-NEXT:  [[#TPF+5]]: [B1.[[#TPF+4]]] (ImplicitCastExpr, LValueToRValue, 
int)
 // CHECK-NEXT:  [[#TPF+6]]: [B1.[[#TPF+5]]] (ImplicitCastExpr, 
IntegralToBoolean, _Bool)
@@ -231,19 +232,20 @@ void xxx(int argc) {
 // CHECK-NEXT:  [[#TPF+9]]: lin
 // CHECK-NEXT:  [[#TPF+10]]: step
 // CHECK-NEXT:  [[#TPF+11]]: [B1.[[#TPF+10]]] (ImplicitCastExpr, 
LValueToRValue, int)
-// CHECK-NEXT:  [[#TPF+12]]: argc
-// CHECK-NEXT:  [[#TPF+13]]: x
-// CHECK-NEXT:  [[#TPF+14]]: #pragma omp target parallel for if(parallel: 
cond) firstprivate(fp) reduction(max: rd) linear(lin: step)
+// CHECK-NEXT:  [[#TPF+12]]: map
+// CHECK-NEXT:  [[#TPF+13]]: argc
+// CHECK-NEXT:  [[#TPF+14]]: x
+// CHECK-NEXT:  [[#TPF+15]]: #pragma omp target parallel for if(parallel: 
cond) firstprivate(fp) reduction(max: rd) linear(lin: step) map(tofrom: map)
 // CHECK-NEXT:for (int i = 0; i < 10; ++i)
 // CHECK-NEXT:[B1.[[#TPF+3]]];
-#pragma omp target parallel for if(parallel:cond) firstprivate(fp) 
reduction(max:rd) linear(lin: step)
+#pragma omp target parallel for if(parallel:cond) 

r369946 - [OPENMP][NVPTX]Fix critical region codegen.

2019-08-26 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Aug 26 12:07:48 2019
New Revision: 369946

URL: http://llvm.org/viewvc/llvm-project?rev=369946=rev
Log:
[OPENMP][NVPTX]Fix critical region codegen.

Summary:
Previously critical regions were emitted with the barrier making it a
worksharing construct though it is not. Also, it leads to incorrect
behavior in Cuda9+. Patch fixes this problem.

Reviewers: ABataev, jdoerfert

Subscribers: jholewinski, guansong, cfe-commits, grokos

Tags: #clang

Differential Revision: https://reviews.llvm.org/D66673

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=369946=369945=369946=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Mon Aug 26 12:07:48 2019
@@ -107,6 +107,10 @@ enum OpenMPRTLFunctionNVPTX {
   /// Call to void __kmpc_barrier_simple_spmd(ident_t *loc, kmp_int32
   /// global_tid);
   OMPRTL__kmpc_barrier_simple_spmd,
+  /// Call to int32_t __kmpc_warp_active_thread_mask(void);
+  OMPRTL_NVPTX__kmpc_warp_active_thread_mask,
+  /// Call to void __kmpc_syncwarp(int32_t Mask);
+  OMPRTL_NVPTX__kmpc_syncwarp,
 };
 
 /// Pre(post)-action for different OpenMP constructs specialized for NVPTX.
@@ -1794,6 +1798,20 @@ CGOpenMPRuntimeNVPTX::createNVPTXRuntime
 ->addFnAttr(llvm::Attribute::Convergent);
 break;
   }
+  case OMPRTL_NVPTX__kmpc_warp_active_thread_mask: {
+// Build int32_t __kmpc_warp_active_thread_mask(void);
+auto *FnTy =
+llvm::FunctionType::get(CGM.Int32Ty, llvm::None, /*isVarArg=*/false);
+RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_warp_active_thread_mask");
+break;
+  }
+  case OMPRTL_NVPTX__kmpc_syncwarp: {
+// Build void __kmpc_syncwarp(kmp_int32 Mask);
+auto *FnTy =
+llvm::FunctionType::get(CGM.VoidTy, CGM.Int32Ty, /*isVarArg=*/false);
+RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_syncwarp");
+break;
+  }
   }
   return RTLFn;
 }
@@ -2700,6 +2718,9 @@ void CGOpenMPRuntimeNVPTX::emitCriticalR
   llvm::BasicBlock *BodyBB = CGF.createBasicBlock("omp.critical.body");
   llvm::BasicBlock *ExitBB = CGF.createBasicBlock("omp.critical.exit");
 
+  // Get the mask of active threads in the warp.
+  llvm::Value *Mask = CGF.EmitRuntimeCall(
+  createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_warp_active_thread_mask));
   // Fetch team-local id of the thread.
   llvm::Value *ThreadID = getNVPTXThreadID(CGF);
 
@@ -2740,8 +2761,9 @@ void CGOpenMPRuntimeNVPTX::emitCriticalR
   // Block waits for all threads in current team to finish then increments the
   // counter variable and returns to the loop.
   CGF.EmitBlock(SyncBB);
-  emitBarrierCall(CGF, Loc, OMPD_unknown, /*EmitChecks=*/false,
-  /*ForceSimpleCall=*/true);
+  // Reconverge active threads in the warp.
+  (void)CGF.EmitRuntimeCall(
+  createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_syncwarp), Mask);
 
   llvm::Value *IncCounterVal =
   CGF.Builder.CreateNSWAdd(CounterVal, CGF.Builder.getInt32(1));

Modified: cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp?rev=369946=369945=369946=diff
==
--- cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp Mon Aug 26 12:07:48 2019
@@ -343,6 +343,7 @@ int bar(int n){
 
 // CHECK-LABEL: define internal void @{{.+}}(i32* noalias %{{.+}}, i32* 
noalias %{{.+}}, i32* dereferenceable{{.*}})
 // CHECK:  [[CC:%.+]] = alloca i32,
+// CHECK:  [[MASK:%.+]] = call i32 @__kmpc_warp_active_thread_mask()
 // CHECK:  [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
 // CHECK:  [[NUM_THREADS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK:  store i32 0, i32* [[CC]],
@@ -362,7 +363,7 @@ int bar(int n){
 // CHECK:  store i32
 // CHECK:  call void @__kmpc_end_critical(
 
-// CHECK:  call void @__kmpc_barrier(%struct.ident_t* @{{.+}}, i32 %{{.+}})
+// CHECK:  call void @__kmpc_syncwarp(i32 [[MASK]])
 // CHECK:  [[NEW_CC_VAL:%.+]] = add nsw i32 [[CC_VAL]], 1
 // CHECK:  store i32 [[NEW_CC_VAL]], i32* [[CC]],
 // CHECK:  br label


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r369801 - [OPENMP5]Use nonmonotonic modifier by default for non-static and

2019-08-23 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Aug 23 12:52:05 2019
New Revision: 369801

URL: http://llvm.org/viewvc/llvm-project?rev=369801=rev
Log:
[OPENMP5]Use nonmonotonic modifier by default for non-static and
non-ordered loops.

According to OpenMP 5.0, 2.9.2 Worksharing-Loop Construct, Desription, If the 
static schedule kind is specified or if the ordered clause is specified, and if 
the nonmonotonic modifier is not specified, the effect is as if the monotonic 
modifier is specified. Otherwise, unless the monotonic modifier is specified, 
the effect is as if the nonmonotonic modifier is specified.
The first part of this requirement is implemented in runtime. Patch adds
support for the second, nonmonotonic, part of this requirement.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/for_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=369801=369800=369801=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Aug 23 12:52:05 2019
@@ -3509,7 +3509,7 @@ bool CGOpenMPRuntime::isDynamic(OpenMPSc
   return Schedule != OMP_sch_static;
 }
 
-static int addMonoNonMonoModifier(OpenMPSchedType Schedule,
+static int addMonoNonMonoModifier(CodeGenModule , OpenMPSchedType Schedule,
   OpenMPScheduleClauseModifier M1,
   OpenMPScheduleClauseModifier M2) {
   int Modifier = 0;
@@ -3543,6 +3543,18 @@ static int addMonoNonMonoModifier(OpenMP
   case OMPC_SCHEDULE_MODIFIER_unknown:
 break;
   }
+  // OpenMP 5.0, 2.9.2 Worksharing-Loop Construct, Desription.
+  // If the static schedule kind is specified or if the ordered clause is
+  // specified, and if the nonmonotonic modifier is not specified, the effect 
is
+  // as if the monotonic modifier is specified. Otherwise, unless the monotonic
+  // modifier is specified, the effect is as if the nonmonotonic modifier is
+  // specified.
+  if (CGM.getLangOpts().OpenMP >= 50 && Modifier == 0) {
+if (!(Schedule == OMP_sch_static_chunked || Schedule == OMP_sch_static ||
+  Schedule == OMP_sch_static_balanced_chunked ||
+  Schedule == OMP_ord_static_chunked || Schedule == OMP_ord_static))
+  Modifier = OMP_sch_modifier_nonmonotonic;
+  }
   return Schedule | Modifier;
 }
 
@@ -3567,13 +3579,14 @@ void CGOpenMPRuntime::emitForDispatchIni
   llvm::Value *Chunk = DispatchValues.Chunk ? DispatchValues.Chunk
 : CGF.Builder.getIntN(IVSize, 1);
   llvm::Value *Args[] = {
-  emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
+  emitUpdateLocation(CGF, Loc),
+  getThreadID(CGF, Loc),
   CGF.Builder.getInt32(addMonoNonMonoModifier(
-  Schedule, ScheduleKind.M1, ScheduleKind.M2)), // Schedule type
-  DispatchValues.LB,// Lower
-  DispatchValues.UB,// Upper
-  CGF.Builder.getIntN(IVSize, 1),   // Stride
-  Chunk // Chunk
+  CGM, Schedule, ScheduleKind.M1, ScheduleKind.M2)), // Schedule type
+  DispatchValues.LB, // Lower
+  DispatchValues.UB, // Upper
+  CGF.Builder.getIntN(IVSize, 1),// Stride
+  Chunk  // Chunk
   };
   CGF.EmitRuntimeCall(createDispatchInitFunction(IVSize, IVSigned), Args);
 }
@@ -3615,7 +3628,7 @@ static void emitForStaticInitCall(
   llvm::Value *Args[] = {
   UpdateLocation,
   ThreadId,
-  CGF.Builder.getInt32(addMonoNonMonoModifier(Schedule, M1,
+  CGF.Builder.getInt32(addMonoNonMonoModifier(CGF.CGM, Schedule, M1,
   M2)), // Schedule type
   Values.IL.getPointer(),   // 
   Values.LB.getPointer(),   // 

Modified: cfe/trunk/test/OpenMP/for_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_codegen.cpp?rev=369801=369800=369801=diff
==
--- cfe/trunk/test/OpenMP/for_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_codegen.cpp Fri Aug 23 12:52:05 2019
@@ -1,10 +1,14 @@
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -fexceptions -fcxx-exceptions -o - 
-fsanitize-address-use-after-scope | FileCheck %s --check-prefix=CHECK 
--check-prefix=LIFETIME
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -fexceptions -fcxx-exceptions -o - 
-fsanitize-address-use-after-scope | FileCheck %s --check-prefix=CHECK 
--check-prefix=LIFETIME --check-prefix=OMP45
+// 

r369775 - [OPENMP5.0]Add support for device_type clause in declare target

2019-08-23 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Aug 23 09:11:14 2019
New Revision: 369775

URL: http://llvm.org/viewvc/llvm-project?rev=369775=rev
Log:
[OPENMP5.0]Add support for device_type clause in declare target
construct.

OpenMP 5.0 introduced new clause for declare target directive, device_type 
clause, which may accept values host, nohost, and any. Host means
that the function must be emitted only for the host, nohost - only for
the device, and any - for both, device and the host.

Modified:
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Basic/OpenMPKinds.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ASTTypeTraits.cpp
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/test/OpenMP/declare_target_ast_print.cpp
cfe/trunk/test/OpenMP/declare_target_codegen.cpp
cfe/trunk/test/OpenMP/declare_target_messages.cpp
cfe/trunk/test/OpenMP/nvptx_allocate_messages.cpp
cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c
cfe/trunk/test/OpenMP/target_vla_messages.cpp

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=369775=369774=369775=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Fri Aug 23 09:11:14 2019
@@ -2843,6 +2843,7 @@ bool RecursiveASTVisitor::Trave
 #include "clang/Basic/OpenMPKinds.def"
   case OMPC_threadprivate:
   case OMPC_uniform:
+  case OMPC_device_type:
   case OMPC_unknown:
 break;
   }

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=369775=369774=369775=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Fri Aug 23 09:11:14 2019
@@ -3207,11 +3207,16 @@ def OMPDeclareTargetDecl : InheritableAt
   let Args = [
 EnumArgument<"MapType", "MapTypeTy",
  [ "to", "link" ],
- [ "MT_To", "MT_Link" ]>
+ [ "MT_To", "MT_Link" ]>,
+EnumArgument<"DevType", "DevTypeTy",
+ [ "host", "nohost", "any" ],
+ [ "DT_Host", "DT_NoHost", "DT_Any" ]>
   ];
   let AdditionalMembers = [{
 void printPrettyPragma(raw_ostream , const PrintingPolicy ) 
const {
   // Use fake syntax because it is for testing and debugging purpose only.
+  if (getDevType() != DT_Any)
+OS << " device_type(" << ConvertDevTypeTyToStr(getDevType()) << ")";
   if (getMapType() != MT_To)
 OS << ' ' << ConvertMapTypeTyToStr(getMapType());
 }
@@ -3224,6 +3229,14 @@ def OMPDeclareTargetDecl : InheritableAt
 
   return llvm::None;
 }
+static llvm::Optional getDeviceType(const ValueDecl *VD) {
+  if (!VD->hasAttrs())
+return llvm::None;
+  if (const auto *Attr = VD->getAttr())
+return Attr->getDevType();
+
+  return llvm::None;
+}
   }];
 }
 

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=369775=369774=369775=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Fri Aug 23 09:11:14 2019
@@ -3176,6 +3176,27 @@ The syntax of the declare target directi
 #pragma omp declare target new-line
 declarations-definition-seq
 #pragma omp end declare target new-line
+
+or
+
+  .. code-block:: c
+
+#pragma omp declare target (extended-list) new-line
+
+or
+
+  .. code-block:: c
+
+#pragma omp declare target clause[ [,] clause ... ] new-line
+
+where clause is one of the following:
+
+
+  .. code-block:: c
+
+ to(extended-list)
+ link(list)
+ device_type(host | nohost | any)
   }];
 }
 

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=369775=369774=369775=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)

r369668 - [OPENMP]Generalization of handling of declare target attribute.

2019-08-22 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Aug 22 09:48:26 2019
New Revision: 369668

URL: http://llvm.org/viewvc/llvm-project?rev=369668=rev
Log:
[OPENMP]Generalization of handling of declare target attribute.

Used OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration instead of
direct checking of the OMPDeclareTargetDeclAttr attribute.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=369668=369667=369668=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Aug 22 09:48:26 2019
@@ -6799,7 +6799,7 @@ NamedDecl *Sema::ActOnVariableDeclarator
 if (EmitTLSUnsupportedError &&
 ((getLangOpts().CUDA && DeclAttrsMatchCUDAMode(getLangOpts(), NewVD)) 
||
  (getLangOpts().OpenMPIsDevice &&
-  NewVD->hasAttr(
+  OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(NewVD
   Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(),
diag::err_thread_unsupported);
 // CUDA B.2.5: "__shared__ and __constant__ variables have implied static

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=369668=369667=369668=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Aug 22 09:48:26 2019
@@ -15418,7 +15418,7 @@ static void checkDeclInTargetContext(Sou
 static bool checkValueDeclInTarget(SourceLocation SL, SourceRange SR,
Sema , DSAStackTy *Stack,
ValueDecl *VD) {
-  return VD->hasAttr() ||
+  return OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD) ||
  checkTypeMappable(SL, SR, SemaRef, Stack, VD->getType(),
/*FullCheck=*/false);
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r369432 - [OPENMP]Fix delayed diagnostics for standalone declare target directive.

2019-08-20 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Aug 20 12:50:13 2019
New Revision: 369432

URL: http://llvm.org/viewvc/llvm-project?rev=369432=rev
Log:
[OPENMP]Fix delayed diagnostics for standalone declare target directive.

If the function is marked as declare target in a standalone directive,
the delayed diagnostics is not emitted. Patch fixes this problem.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c
cfe/trunk/test/OpenMP/nvptx_va_arg_delayed_diags.c

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=369432=369431=369432=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Aug 20 12:50:13 2019
@@ -8997,7 +8997,8 @@ private:
   void popOpenMPFunctionRegion(const sema::FunctionScopeInfo *OldFSI);
 
   /// Check whether we're allowed to call Callee from the current function.
-  void checkOpenMPDeviceFunction(SourceLocation Loc, FunctionDecl *Callee);
+  void checkOpenMPDeviceFunction(SourceLocation Loc, FunctionDecl *Callee,
+ bool CheckForDelayedContext = true);
 
   /// Check if the expression is allowed to be used in expressions for the
   /// OpenMP devices.

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=369432=369431=369432=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Tue Aug 20 12:50:13 2019
@@ -1383,7 +1383,7 @@ static void emitCallStackNotes(Sema ,
 
 // Emit any deferred diagnostics for FD and erase them from the map in which
 // they're stored.
-static void emitDeferredDiags(Sema , FunctionDecl *FD) {
+static void emitDeferredDiags(Sema , FunctionDecl *FD, bool ShowCallStack) {
   auto It = S.DeviceDeferredDiags.find(FD);
   if (It == S.DeviceDeferredDiags.end())
 return;
@@ -1402,7 +1402,7 @@ static void emitDeferredDiags(Sema , F
   // FIXME: Should this be called after every warning/error emitted in the loop
   // above, instead of just once per function?  That would be consistent with
   // how we handle immediate errors, but it also seems like a bit much.
-  if (HasWarningOrError)
+  if (HasWarningOrError && ShowCallStack)
 emitCallStackNotes(S, FD);
 }
 
@@ -1505,7 +1505,7 @@ void Sema::markKnownEmitted(
 assert(!IsKnownEmitted(S, C.Callee) &&
"Worklist should not contain known-emitted functions.");
 S.DeviceKnownEmittedFns[C.Callee] = {C.Caller, C.Loc};
-emitDeferredDiags(S, C.Callee);
+emitDeferredDiags(S, C.Callee, C.Caller);
 
 // If this is a template instantiation, explore its callgraph as well:
 // Non-dependent calls are part of the template's callgraph, while 
dependent

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=369432=369431=369432=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Aug 20 12:50:13 2019
@@ -1576,7 +1576,8 @@ Sema::DeviceDiagBuilder Sema::diagIfOpen
Loc, DiagID, getCurFunctionDecl(), *this);
 }
 
-void Sema::checkOpenMPDeviceFunction(SourceLocation Loc, FunctionDecl *Callee) 
{
+void Sema::checkOpenMPDeviceFunction(SourceLocation Loc, FunctionDecl *Callee,
+ bool CheckForDelayedContext) {
   assert(LangOpts.OpenMP && LangOpts.OpenMPIsDevice &&
  "Expected OpenMP device compilation.");
   assert(Callee && "Callee may not be null.");
@@ -1584,9 +1585,13 @@ void Sema::checkOpenMPDeviceFunction(Sou
 
   // If the caller is known-emitted, mark the callee as known-emitted.
   // Otherwise, mark the call in our call graph so we can traverse it later.
-  if (!isOpenMPDeviceDelayedContext(*this) ||
+  if ((CheckForDelayedContext && !isOpenMPDeviceDelayedContext(*this)) ||
+  (!Caller && !CheckForDelayedContext) ||
   (Caller && isKnownEmitted(*this, Caller)))
-markKnownEmitted(*this, Caller, Callee, Loc, isKnownEmitted);
+markKnownEmitted(*this, Caller, Callee, Loc,
+ [CheckForDelayedContext](Sema , FunctionDecl *FD) {
+   return CheckForDelayedContext && isKnownEmitted(S, FD);
+ });
   else if (Caller)
 DeviceCallGraph[Caller].insert({Callee, Loc});
 }
@@ -15406,15 +15411,17 @@ void Sema::checkDeclIsAllowedInOpenMPTar
   }
   if (const auto *FTD = dyn_cast(D))
 D = FTD->getTemplatedDecl();
-  if (const auto *FD = dyn_cast(D)) {
+  if (auto *FD = dyn_cast(D)) {
 llvm::Optional Res =
 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(FD);
-

r369418 - Fix name of the error message, NFC.

2019-08-20 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Aug 20 10:50:13 2019
New Revision: 369418

URL: http://llvm.org/viewvc/llvm-project?rev=369418=rev
Log:
Fix name of the error message, NFC.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=369418=369417=369418=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Aug 20 10:50:13 
2019
@@ -9329,7 +9329,7 @@ def err_omp_wrong_dependency_iterator_ty
   "expected an integer or a pointer type of the outer loop counter '%0' for 
non-rectangular nests">;
 def err_omp_unsupported_type : Error <
   "host requires %0 bit size %1 type support, but device '%2' does not support 
it">;
-def omp_lambda_capture_in_declare_target_not_to : Error<
+def err_omp_lambda_capture_in_declare_target_not_to : Error<
   "variable captured in declare target region must appear in a to clause">;
 } // end of OpenMP category
 

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=369418=369417=369418=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Aug 20 10:50:13 2019
@@ -15365,7 +15365,7 @@ static void checkDeclInTargetContext(Sou
   // directive, all variables that are captured by the lambda
   // expression must also appear in a to clause.
   SemaRef.Diag(VD->getLocation(),
-   diag::omp_lambda_capture_in_declare_target_not_to);
+   diag::err_omp_lambda_capture_in_declare_target_not_to);
   SemaRef.Diag(SL, diag::note_var_explicitly_captured_here)
   << VD << 0 << SR;
   return;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r369146 - [OPENMP5.0]Diagnose global variables in lambda not marked as declare

2019-08-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Aug 16 13:15:02 2019
New Revision: 369146

URL: http://llvm.org/viewvc/llvm-project?rev=369146=rev
Log:
[OPENMP5.0]Diagnose global variables in lambda not marked as declare
target.

According to OpenMP 5.0, if a lambda declaration and definition appears between 
a declare target directive and the matching end declare target directive, all 
variables that are captured by the lambda expression must also appear in a to 
clause.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/declare_target_messages.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=369146=369145=369146=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Aug 16 13:15:02 
2019
@@ -9318,6 +9318,8 @@ def err_omp_wrong_dependency_iterator_ty
   "expected an integer or a pointer type of the outer loop counter '%0' for 
non-rectangular nests">;
 def err_omp_unsupported_type : Error <
   "host requires %0 bit size %1 type support, but device '%2' does not support 
it">;
+def omp_lambda_capture_in_declare_target_not_to : Error<
+  "variable captured in declare target region must appear in a to clause">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=369146=369145=369146=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Aug 16 13:15:02 2019
@@ -1796,7 +1796,8 @@ VarDecl *Sema::isOpenMPCapturedDecl(Valu
 if (isInOpenMPDeclareTargetContext()) {
   // Try to mark variable as declare target if it is used in capturing
   // regions.
-  if (!OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
+  if (LangOpts.OpenMP <= 45 &&
+  !OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
 checkDeclIsAllowedInOpenMPTarget(nullptr, VD);
   return nullptr;
 } else if (isInOpenMPTargetExecutionDirective()) {
@@ -15349,7 +15350,28 @@ static void checkDeclInTargetContext(Sou
   if (!D || !isa(D))
 return;
   auto *VD = cast(D);
-  if (OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD))
+  Optional MapTy =
+  OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
+  if (SemaRef.LangOpts.OpenMP >= 50 &&
+  (SemaRef.getCurLambda(/*IgnoreNonLambdaCapturingScope=*/true) ||
+   SemaRef.getCurBlock() || SemaRef.getCurCapturedRegion()) &&
+  VD->hasGlobalStorage()) {
+llvm::Optional MapTy =
+OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
+if (!MapTy || *MapTy != OMPDeclareTargetDeclAttr::MT_To) {
+  // OpenMP 5.0, 2.12.7 declare target Directive, Restrictions
+  // If a lambda declaration and definition appears between a
+  // declare target directive and the matching end declare target
+  // directive, all variables that are captured by the lambda
+  // expression must also appear in a to clause.
+  SemaRef.Diag(VD->getLocation(),
+   diag::omp_lambda_capture_in_declare_target_not_to);
+  SemaRef.Diag(SL, diag::note_var_explicitly_captured_here)
+  << VD << 0 << SR;
+  return;
+}
+  }
+  if (MapTy.hasValue())
 return;
   SemaRef.Diag(VD->getLocation(), diag::warn_omp_not_in_target_context);
   SemaRef.Diag(SL, diag::note_used_here) << SR;

Modified: cfe/trunk/test/OpenMP/declare_target_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_messages.cpp?rev=369146=369145=369146=diff
==
--- cfe/trunk/test/OpenMP/declare_target_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_target_messages.cpp Fri Aug 16 13:15:02 2019
@@ -1,10 +1,11 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp 
-fnoopenmp-use-tls -ferror-limit 100 -o - %s
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp5 
-fopenmp -fopenmp-version=50 -fnoopenmp-use-tls -ferror-limit 100 -o - %s
 
 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp-simd 
-fnoopenmp-use-tls -ferror-limit 100 -o - %s
 
 #pragma omp end declare target // expected-error {{unexpected OpenMP directive 
'#pragma omp end declare target'}}
 
-int a, b;
+int a, b, z; // omp5-error {{variable captured in declare target region must 
appear in a to clause}}
 __thread int t; // expected-note {{defined as threadprivate or thread local}}
 
 #pragma omp declare target . // expected-error {{expected '(' after 'declare 
target'}}
@@ -65,11 

r369044 - Mark the test as unsupported on darwin, NFC.

2019-08-15 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Aug 15 13:31:47 2019
New Revision: 369044

URL: http://llvm.org/viewvc/llvm-project?rev=369044=rev
Log:
Mark the test as unsupported on darwin, NFC.

The bundler may fail on darwin, mark the test as not compatible.

Modified:
cfe/trunk/test/Driver/clang-offload-bundler.c

Modified: cfe/trunk/test/Driver/clang-offload-bundler.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-offload-bundler.c?rev=369044=369043=369044=diff
==
--- cfe/trunk/test/Driver/clang-offload-bundler.c (original)
+++ cfe/trunk/test/Driver/clang-offload-bundler.c Thu Aug 15 13:31:47 2019
@@ -1,7 +1,7 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: powerpc-registered-target
 // REQUIRES: shell
-// UNSUPPORTED: ms-sdk
+// UNSUPPORTED: ms-sdk, darwin
 
 //
 // Generate all the types of files we can bundle.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D66296: [BUNDLER]Improve the test, NFC.

2019-08-15 Thread Alexey Bataev via cfe-commits
Will fix this shortly.

-
Best regards,
Alexey Bataev

15.08.2019 16:23, Azhar Mohammed пишет:
> Seeing this now:
>
> fatal error: error in backend: Global variable '' has an invalid
> section specifier
> '__CLANG_OFFLOAD_BUNDLE__host-x86_64-apple-darwin17.6.0': mach-o
> section specifier requires a segment whose length is between 1 and 16
> characters. clang-10: error: clang frontend command failed with exit
> code 70 (use -v to see invocation) clang version 10.0.0
> (http://labmaster3.local/git/llvm-project.git00782a4b68c71b9fb80b403b13f9ec67f07a87a4)
> Target: x86_64-apple-darwin17.6.0 Thread model: posix InstalledDir:
> /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/bin
> clang-10: note: diagnostic msg: PLEASE submit a bug report to
> https://bugs.llvm.org/and include the crash backtrace, preprocessed
> source, and associated run script. clang-10: note: diagnostic msg:
> Error generating preprocessed source(s) - no preprocessable inputs.
> error: incremental linking by external tool failed.
> http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/1196/consoleFull#-2382751928254eaf0-7326-4999-85b0-388101f2d404
>
>
>
>> On Aug 15, 2019, at 12:00 PM, Alexey Bataev via Phabricator via
>> llvm-commits > > wrote:
>>
>> ABataev added a comment.
>>
>> In D66296#1632003 ,
>> @azharudd wrote:
>>
>>> Looks like this is failing on Darwin:
>>>
>>> http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/1193/consoleFull#-2382751928254eaf0-7326-4999-85b0-388101f2d404
>>>
>>>  
>>> /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/clang/test/Driver/clang-offload-bundler.c:120:15:
>>> error: CK-TEXTLL: expected string not found in input
>>>  // CK-TEXTLL: @A = dso_local global i32 0
>>>                ^
>>>  
>>> /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/tools/clang/test/Driver/Output/clang-offload-bundler.c.tmp.bundle3.ll:3:1:
>>> note: scanning from here
>>>  ; ModuleID =
>>> '/Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/llvm-project/clang/test/Driver/clang-offload-bundler.c'
>>>  ^
>>>  
>>> /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-incremental/clang-build/tools/clang/test/Driver/Output/clang-offload-bundler.c.tmp.bundle3.ll:8:1:
>>> note: possible intended match here
>>>  @A = global i32 0, align 4
>>>
>>
>>
>> Committed the fix already
>>
>>
>> Repository:
>>  rL LLVM
>>
>> CHANGES SINCE LAST ACTION
>>  https://reviews.llvm.org/D66296/new/
>>
>> https://reviews.llvm.org/D66296
>>
>>
>>
>> ___
>> llvm-commits mailing list
>> llvm-comm...@lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>


signature.asc
Description: OpenPGP digital signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r369028 - Fix the test, NFC.

2019-08-15 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Aug 15 10:53:49 2019
New Revision: 369028

URL: http://llvm.org/viewvc/llvm-project?rev=369028=rev
Log:
Fix the test, NFC.

Modified:
cfe/trunk/test/Driver/clang-offload-bundler.c

Modified: cfe/trunk/test/Driver/clang-offload-bundler.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-offload-bundler.c?rev=369028=369027=369028=diff
==
--- cfe/trunk/test/Driver/clang-offload-bundler.c (original)
+++ cfe/trunk/test/Driver/clang-offload-bundler.c Thu Aug 15 10:53:49 2019
@@ -117,7 +117,7 @@
 // CK-TEXTI: // __CLANG_OFFLOAD_BUNDLEEND__ openmp-x86_64-pc-linux-gnu
 
 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLESTART__ host-[[HOST:.+]]
-// CK-TEXTLL: @A = dso_local global i32 0
+// CK-TEXTLL: @A = {{.*}}global i32 0
 // CK-TEXTLL: define {{.*}}@test_func()
 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLEEND__ host-[[HOST]]
 // CK-TEXTLL: ; __CLANG_OFFLOAD_BUNDLESTART__ 
openmp-powerpc64le-ibm-linux-gnu


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r369019 - [Driver][Bundler] Improve bundling of object files.

2019-08-15 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Aug 15 10:15:35 2019
New Revision: 369019

URL: http://llvm.org/viewvc/llvm-project?rev=369019=rev
Log:
[Driver][Bundler] Improve bundling of object files.

Summary:
Previously, object files were bundled using partial linking. It resulted
in the following structure of the bundled objects:
```

clang-offload-bundle
__CLANG_OFFLOAD_BUNDLE__

```
But when we tried to unbundle object files, it worked correctly only for
the target objects. The host object remains bundled. It produced a lot of
junk sections in the host object files and in some cases may caused
incorrect linking.

Patch improves bundling of the object files. After this patch the
bundled object looks like this:

```

clang-offload-bundle
__CLANG_OFFLOAD_BUNDLE__

__CLANG_OFFLOAD_BUNDLE__

```

With this structure we are able to unbundle the host object files too so
that after unbundling they are the same as were before.
The host section is bundled twice. The bundled section is used to
unbundle the original host section.

Reviewers: yaxunl, tra, jlebar, hfinkel, jdoerfert

Subscribers: caomhin, kkwli0, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D65819

Modified:
cfe/trunk/test/Driver/clang-offload-bundler.c
cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Modified: cfe/trunk/test/Driver/clang-offload-bundler.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-offload-bundler.c?rev=369019=369018=369019=diff
==
--- cfe/trunk/test/Driver/clang-offload-bundler.c (original)
+++ cfe/trunk/test/Driver/clang-offload-bundler.c Thu Aug 15 10:15:35 2019
@@ -231,18 +231,18 @@
 
 // RUN: clang-offload-bundler -type=o 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -inputs=%t.o,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.o -### -dump-temporary-files 
2>&1 \
 // RUN: | FileCheck %s --check-prefix CK-OBJ-CMD
-// CK-OBJ-CMD: private constant [1 x i8] zeroinitializer, section 
"__CLANG_OFFLOAD_BUNDLE__host-[[HOST:.+]]"
+// CK-OBJ-CMD: private constant [{{[0-9]+}} x i8] c"{{.+}}", section 
"__CLANG_OFFLOAD_BUNDLE__host-[[HOST:.+]]"
 // CK-OBJ-CMD: private constant [{{[0-9]+}} x i8] c"Content of device file 
1{{.+}}", section "__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu"
 // CK-OBJ-CMD: private constant [{{[0-9]+}} x i8] c"Content of device file 
2{{.+}}", section "__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu"
 // CK-OBJ-CMD: clang{{(.exe)?}}" "-r" "-target" "[[HOST]]" "-o" "{{.+}}.o" 
"{{.+}}.o" "{{.+}}.bc" "-nostdlib"
 
 // RUN: clang-offload-bundler -type=o 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -inputs=%t.o,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.o
 // RUN: clang-offload-bundler -type=o 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -outputs=%t.res.o,%t.res.tgt1,%t.res.tgt2 -inputs=%t.bundle3.o -unbundle
-// RUN: diff %t.bundle3.o %t.res.o
+// RUN: diff %t.o %t.res.o
 // RUN: diff %t.tgt1 %t.res.tgt1
 // RUN: diff %t.tgt2 %t.res.tgt2
 // RUN: clang-offload-bundler -type=o 
-targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu
 -outputs=%t.res.tgt1,%t.res.o,%t.res.tgt2 -inputs=%t.bundle3.o -unbundle
-// RUN: diff %t.bundle3.o %t.res.o
+// RUN: diff %t.o %t.res.o
 // RUN: diff %t.tgt1 %t.res.tgt1
 // RUN: diff %t.tgt2 %t.res.tgt2
 

Modified: cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp?rev=369019=369018=369019=diff
==
--- cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp (original)
+++ cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Thu Aug 15 
10:15:35 2019
@@ -370,13 +370,9 @@ public:
 /// designated name.
 ///
 /// In order to bundle we create an IR file with the content of each section 
and
-/// use incremental linking to produce the resulting object. We also add 
section
-/// with a single byte to state the name of the component the main object file
-/// (the one we are bundling into) refers to.
+/// use incremental linking to produce the resulting object.
 ///
-/// To unbundle, we use just copy the contents of the designated section. If 
the
-/// requested bundle refer to the main object file, we just copy it with no
-/// changes.
+/// To unbundle, we just copy the contents of the designated section.
 class ObjectFileHandler final : public FileHandler {
 
   /// The object file we are currently dealing with.
@@ -471,10 +467,7 @@ public:
   return;
 }
 
-if (Content->size() < 2)
-  OS.write(Input.getBufferStart(), Input.getBufferSize());
-else
-  OS.write(Content->data(), Content->size());
+OS.write(Content->data(), Content->size());
   }
 
   

r369015 - [BUNDLER]Improve the test, NFC.

2019-08-15 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Aug 15 09:28:24 2019
New Revision: 369015

URL: http://llvm.org/viewvc/llvm-project?rev=369015=rev
Log:
[BUNDLER]Improve the test, NFC.

Summary:
Make the test more portable and do not rely on the pre-bundled object
file.

Reviewers: Hahnfeld, hfinkel, jdoerfert

Subscribers: caomhin, kkwli0, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D66296

Removed:
cfe/trunk/test/Driver/clang-offload-bundler.c.o
Modified:
cfe/trunk/test/Driver/clang-offload-bundler.c

Modified: cfe/trunk/test/Driver/clang-offload-bundler.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-offload-bundler.c?rev=369015=369014=369015=diff
==
--- cfe/trunk/test/Driver/clang-offload-bundler.c (original)
+++ cfe/trunk/test/Driver/clang-offload-bundler.c Thu Aug 15 09:28:24 2019
@@ -1,16 +1,18 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: powerpc-registered-target
+// REQUIRES: shell
+// UNSUPPORTED: ms-sdk
 
 //
 // Generate all the types of files we can bundle.
 //
-// RUN: %clang -O0 -target powerpc64le-ibm-linux-gnu %s -E -o %t.i
-// RUN: %clangxx -O0 -target powerpc64le-ibm-linux-gnu -x c++ %s -E -o %t.ii
-// RUN: %clang -O0 -target powerpc64le-ibm-linux-gnu %s -S -emit-llvm -o %t.ll
-// RUN: %clang -O0 -target powerpc64le-ibm-linux-gnu %s -c -emit-llvm -o %t.bc
-// RUN: %clang -O0 -target powerpc64le-ibm-linux-gnu %s -S -o %t.s
-// RUN: %clang -O0 -target powerpc64le-ibm-linux-gnu %s -c -o %t.o
-// RUN: %clang -O0 -target powerpc64le-ibm-linux-gnu %s -emit-ast -o %t.ast
+// RUN: %clang -O0 -target %itanium_abi_triple %s -E -o %t.i
+// RUN: %clangxx -O0 -target %itanium_abi_triple -x c++ %s -E -o %t.ii
+// RUN: %clang -O0 -target %itanium_abi_triple %s -S -emit-llvm -o %t.ll
+// RUN: %clang -O0 -target %itanium_abi_triple %s -c -emit-llvm -o %t.bc
+// RUN: %clang -O0 -target %itanium_abi_triple %s -S -o %t.s
+// RUN: %clang -O0 -target %itanium_abi_triple %s -c -o %t.o
+// RUN: %clang -O0 -target %itanium_abi_triple %s -emit-ast -o %t.ast
 
 //
 // Generate an empty file to help with the checks of empty files.
@@ -50,27 +52,27 @@
 //
 // Check errors.
 //
-// RUN: not clang-offload-bundler -type=i 
-targets=host-powerpc64le-ibm-linux-gnu,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -inputs=%t.i,%t.tgt1,%t.tgt2 -outputs=%t.bundle.i -unbundle 2>&1 | FileCheck 
%s --check-prefix CK-ERR1
+// RUN: not clang-offload-bundler -type=i 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -inputs=%t.i,%t.tgt1,%t.tgt2 -outputs=%t.bundle.i -unbundle 2>&1 | FileCheck 
%s --check-prefix CK-ERR1
 // CK-ERR1: error: only one input file supported in unbundling mode.
 // CK-ERR1: error: number of output files and targets should match in 
unbundling mode.
 
-// RUN: not clang-offload-bundler -type=i 
-targets=host-powerpc64le-ibm-linux-gnu,openmp-powerpc64le-ibm-linux-gnu 
-inputs=%t.i,%t.tgt1,%t.tgt2 -outputs=%t.bundle.i 2>&1 | FileCheck %s 
--check-prefix CK-ERR2
-// RUN: not clang-offload-bundler -type=i 
-targets=host-powerpc64le-ibm-linux-gnu,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -inputs=%t.i,%t.tgt1 -outputs=%t.bundle.i 2>&1 | FileCheck %s --check-prefix 
CK-ERR2
+// RUN: not clang-offload-bundler -type=i 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu 
-inputs=%t.i,%t.tgt1,%t.tgt2 -outputs=%t.bundle.i 2>&1 | FileCheck %s 
--check-prefix CK-ERR2
+// RUN: not clang-offload-bundler -type=i 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -inputs=%t.i,%t.tgt1 -outputs=%t.bundle.i 2>&1 | FileCheck %s --check-prefix 
CK-ERR2
 // CK-ERR2: error: number of input files and targets should match in bundling 
mode.
 
-// RUN: not clang-offload-bundler -type=i 
-targets=host-powerpc64le-ibm-linux-gnu,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -outputs=%t.i,%t.tgt1,%t.tgt2 -inputs=%t.bundle.i 2>&1 | FileCheck %s 
--check-prefix CK-ERR3
+// RUN: not clang-offload-bundler -type=i 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -outputs=%t.i,%t.tgt1,%t.tgt2 -inputs=%t.bundle.i 2>&1 | FileCheck %s 
--check-prefix CK-ERR3
 // CK-ERR3: error: only one output file supported in bundling mode.
 // CK-ERR3: error: number of input files and targets should match in bundling 
mode.
 
-// RUN: not clang-offload-bundler -type=i 
-targets=host-powerpc64le-ibm-linux-gnu,openmp-powerpc64le-ibm-linux-gnu 
-outputs=%t.i,%t.tgt1,%t.tgt2 -inputs=%t.bundle.i -unbundle 2>&1 | FileCheck %s 
--check-prefix CK-ERR4
-// RUN: not clang-offload-bundler -type=i 
-targets=host-powerpc64le-ibm-linux-gnu,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -outputs=%t.i,%t.tgt1 -inputs=%t.bundle.i -unbundle 2>&1 | FileCheck %s 
--check-prefix CK-ERR4
+// RUN: not clang-offload-bundler -type=i 

r368903 - [OPENMP]Support for non-rectangular loops.

2019-08-14 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Aug 14 12:30:06 2019
New Revision: 368903

URL: http://llvm.org/viewvc/llvm-project?rev=368903=rev
Log:
[OPENMP]Support for non-rectangular loops.

Added basic support for non-rectangular loops. It requires an additional
analysis of min/max boundaries for non-rectangular loops. Since only
linear dependency is allowed, we can do this analysis.

Modified:
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/lib/AST/StmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/OpenMP/for_codegen.cpp
cfe/trunk/test/OpenMP/for_loop_messages.cpp
cfe/trunk/test/OpenMP/parallel_messages.cpp

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=368903=368902=368903=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Wed Aug 14 12:30:06 2019
@@ -448,7 +448,8 @@ class OMPLoopDirective : public OMPExecu
 PreInitsOffset = 8,
 // The '...End' enumerators do not correspond to child expressions - they
 // specify the offset to the end (and start of the following counters/
-// updates/finals arrays).
+// updates/finals/dependent_counters/dependent_inits/finals_conditions
+// arrays).
 DefaultEnd = 9,
 // The following 8 exprs are used by worksharing and distribute loops only.
 IsLastIterVariableOffset = 9,
@@ -474,7 +475,8 @@ class OMPLoopDirective : public OMPExecu
 CombinedNextUpperBoundOffset = 27,
 CombinedDistConditionOffset = 28,
 CombinedParForInDistConditionOffset = 29,
-// Offset to the end (and start of the following counters/updates/finals
+// Offset to the end (and start of the following
+// 
counters/updates/finals/dependent_counters/dependent_inits/finals_conditions
 // arrays) for combined distribute loop directives.
 CombinedDistributeEnd = 30,
   };
@@ -517,6 +519,30 @@ class OMPLoopDirective : public OMPExecu
 return MutableArrayRef(Storage, CollapsedNum);
   }
 
+  /// Get the dependent counters storage.
+  MutableArrayRef getDependentCounters() {
+Expr **Storage = reinterpret_cast(
+&*std::next(child_begin(),
+getArraysOffset(getDirectiveKind()) + 5 * CollapsedNum));
+return MutableArrayRef(Storage, CollapsedNum);
+  }
+
+  /// Get the dependent inits storage.
+  MutableArrayRef getDependentInits() {
+Expr **Storage = reinterpret_cast(
+&*std::next(child_begin(),
+getArraysOffset(getDirectiveKind()) + 6 * CollapsedNum));
+return MutableArrayRef(Storage, CollapsedNum);
+  }
+
+  /// Get the finals conditions storage.
+  MutableArrayRef getFinalsConditions() {
+Expr **Storage = reinterpret_cast(
+&*std::next(child_begin(),
+getArraysOffset(getDirectiveKind()) + 7 * CollapsedNum));
+return MutableArrayRef(Storage, CollapsedNum);
+  }
+
 protected:
   /// Build instance of loop directive of class \a Kind.
   ///
@@ -551,9 +577,10 @@ protected:
   /// Children number.
   static unsigned numLoopChildren(unsigned CollapsedNum,
   OpenMPDirectiveKind Kind) {
-return getArraysOffset(Kind) + 5 * CollapsedNum; // Counters,
- // PrivateCounters, Inits,
- // Updates and Finals
+return getArraysOffset(Kind) +
+   8 * CollapsedNum; // Counters, PrivateCounters, Inits,
+ // Updates, Finals, DependentCounters,
+ // DependentInits, FinalsConditions.
   }
 
   void setIterationVariable(Expr *IV) {
@@ -703,6 +730,9 @@ protected:
   void setInits(ArrayRef A);
   void setUpdates(ArrayRef A);
   void setFinals(ArrayRef A);
+  void setDependentCounters(ArrayRef A);
+  void setDependentInits(ArrayRef A);
+  void setFinalsConditions(ArrayRef A);
 
 public:
   /// The expressions built to support OpenMP loops in combined/composite
@@ -798,6 +828,15 @@ public:
 SmallVector Updates;
 /// Final loop counter values for GodeGen.
 SmallVector Finals;
+/// List of counters required for the generation of the non-rectangular
+/// loops.
+SmallVector DependentCounters;
+/// List of initializers required for the generation of the non-rectangular
+/// loops.
+SmallVector DependentInits;
+/// List of final conditions required for the generation of the
+/// non-rectangular loops.
+SmallVector FinalsConditions;
 /// Init statement for all captured expressions.
 Stmt *PreInits;
 
@@ -813,7 +852,9 @@ public:
 }
 
 /// Initialize all the fields to null.
-/// \param Size Number of elements in the 

Re: [PATCH] D65819: [Driver][Bundler] Improve bundling of object files.

2019-08-14 Thread Alexey Bataev via cfe-commits
I said this before that most probably this is the bug in partial linking, made 
by ld. But clang-offload-bundler is also nit quite correct here since the 
original host code is actually not unbundled. I'll fix the patch later today to 
keep the partial linking for the host object, but really unbundle it when 
required.

Best regards,
Alexey Bataev

> 14 авг. 2019 г., в 5:48, Jonas Hahnfeld via Phabricator 
>  написал(а):
> 
> Hahnfeld added a comment.
> 
> Okay, so I wasn't happy with the current explanations because I don't like 
> "fixing" an issue without understanding the problem. Here's a small 
> reproducer:
> 
>  $  cat main.cpp 
>  #include "test.h"
> 
>  int main(int argc, char *argv[]) {
>m[1] = 2;
>return 0;
>  }
>  $ cat test.h 
>  #include 
>  #include 
> 
>  template 
>  struct B {
>static std::vector v;
> 
>virtual void f() {
>  v.push_back(1);
>}
>  };
> 
>  struct C : public B {
>C() { }
>  };
> 
>  template 
>  std::vector B::v;
> 
>  extern std::map m;
>  $ cat test.cpp 
>  #include "test.h"
> 
>  std::map m;
> 
> Compiling with `clang++ -c main.cpp`, `clang++ -c test.cpp`, `clang++ main.o 
> test.o -o main` works fine and the resulting executable doesn't crash.
> Now if instead partially linking `test.o` like `ld -r test.o -o test.o.ld-r` 
> and then linking the executable with `clang++ main.o test.o.ld-r -o 
> main.ld-r` outputs a binary that crashes at execution because the constructor 
> of `std::map m` is not called.
> 
> Digging in the object files reveals the reason:
> 
>  $ readelf -S test.o | grep -n1 .init_array
>  281-   0008   WAG   0 0 8
>  282:  [138] .init_array   INIT_ARRAY     09d0
>  283-   0008   WAG   0 0 8
>  284:  [139] .rela.init_array  RELA   2460
>  285-   0018  0018   G  150   138 8
>  286:  [140] .init_array   INIT_ARRAY     09d8
>  287-   0008    WA   0 0 8
>  288:  [141] .rela.init_array  RELA   2478
>  289-   0018  0018  150   140 8
>  $ readelf -S test.o.ld-r | grep -n1 .init_array
>  279-   0078     A   0 0 4
>  280:  [137] .init_array   INIT_ARRAY     1270
>  281-   0010  0008 WAG   0 0 8
>  282:  [138] .rela.init_array  RELA   3b10
>  283-   0030  0018  IG  147   137 8
> 
> I haven't further looked into the contents of the sections, but I'd guess 
> that the first `.init_array` in `test.o` contains the constructor for 
> `template  std::vector B::v`. Because it might need to be 
> merged with other TUs (in this case, it's also present in `main.o`) it is 
> marked with a group flag (`G`). The second `.init_array` in `test.o` is 
> probably the constructor for `std::map m` and not marked with a 
> group, but `ld -r` merges these two sections into one `.init_array`, now with 
> a group. So when linking with `main.o` which also contains a constructor for 
> `template  std::vector B::v`, the linker drops the call 
> to the constructor of `std::map m`:
> 
>  $ readelf -S main | grep -n1 .init_array
>  43-   0160     A   0 0 4
>  44:  [19] .init_array   INIT_ARRAY   6d98  5d98
>  45-   0018  0008  WA   0 0 8
>  $ readelf -S main.ld-r | grep -n1 .init_array
>  43-   0160     A   0 0 4
>  44:  [19] .init_array   INIT_ARRAY   6da0  5da0
>  45-   0010  0008  WA   0 0 8
> 
> (note the difference in size of the two `.init_array` sections!)
> 
> Further notes:
> 
> - Obviously, linking in a different order like `clang++ test.o.ld-r main.o -o 
> main.ld-r2` also results in a working executable, but that's not really a 
> solution.
> - Calling `ld -Ur` doesn't change anything:
> 
>  $ ld -Ur test.o -o test.o.ld-Ur
>  $ md5sum test.o.ld-*
>  a4d5cead3209ef191d5c05de63e398de  test.o.ld-r
>  a4d5cead3209ef191d5c05de63e398de  test.o.ld-Ur
> 
> ---
> 
> Long story short: This very much looks like a bug in `ld` when using partial 
> linking. So the best thing that Clang can do to (kind of) workaround this 
> problem is ensuring that bundling + unbundling results in the bitwise-same 
> host object file. However, I think we should still use partial linking for 
> easy access to the host object file, even if we don't extract it from there 
> (other tools using it from there have to blame `ld -r`, not 
> `clang-offload-bundler`, that the partially linked object file doesn't 
> correctly call global initializers).
> 
> 
> Repository:
>  rC 

Re: r368739 - Don't use std::errc

2019-08-13 Thread Alexey Bataev via cfe-commits
Sorry, forgot to change the description. Been busy switching to the newer 
version of the compiler.

Best regards,
Alexey Bataev

13 авг. 2019 г., в 21:32, Nico Weber 
mailto:tha...@chromium.org>> написал(а):

From the review: This is for gcc 4.8 compat, not for the other reasons 
mentioned in the CL description.

On Tue, Aug 13, 2019 at 3:31 PM Alexey Bataev via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: abataev
Date: Tue Aug 13 12:32:36 2019
New Revision: 368739

URL: http://llvm.org/viewvc/llvm-project?rev=368739=rev
Log:
Don't use std::errc

Summary:
As noted on Errc.h:

// * std::errc is just marked with is_error_condition_enum. This means that
//   common patters like AnErrorCode == errc::no_such_file_or_directory take
//   4 virtual calls instead of two comparisons.

And on some libstdc++ those virtual functions conclude that


int main() {
  std::error_code foo = 
std::make_error_code(std::errc::no_such_file_or_directory);
  return foo == std::errc::no_such_file_or_directory;
}
-

should exit with 0.

Reviewers: thakis, rnk, jfb

Reviewed By: thakis

Subscribers: lebedev.ri, dexonsmith, xbolva00, cfe-commits, caomhin

Tags: #clang

Differential Revision: https://reviews.llvm.org/D66143

Modified:
cfe/trunk/lib/Lex/HeaderSearch.cpp

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=368739=368738=368739=diff
==
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Tue Aug 13 12:32:36 2019
@@ -30,6 +30,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Capacity.h"
+#include "llvm/Support/Errc.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -315,9 +316,9 @@ const FileEntry *HeaderSearch::getFileAn
 // For rare, surprising errors (e.g. "out of file handles"), diag the EC
 // message.
 std::error_code EC = File.getError();
-if (EC != std::errc::no_such_file_or_directory &&
-EC != std::errc::invalid_argument && EC != std::errc::is_a_directory &&
-EC != std::errc::not_a_directory) {
+if (EC != llvm::errc::no_such_file_or_directory &&
+EC != llvm::errc::invalid_argument &&
+EC != llvm::errc::is_a_directory && EC != llvm::errc::not_a_directory) 
{
   Diags.Report(IncludeLoc, diag::err_cannot_open_file)
   << FileName << EC.message();
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org<mailto:cfe-commits@lists.llvm.org>
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r368739 - Don't use std::errc

2019-08-13 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Aug 13 12:32:36 2019
New Revision: 368739

URL: http://llvm.org/viewvc/llvm-project?rev=368739=rev
Log:
Don't use std::errc

Summary:
As noted on Errc.h:

// * std::errc is just marked with is_error_condition_enum. This means that
//   common patters like AnErrorCode == errc::no_such_file_or_directory take
//   4 virtual calls instead of two comparisons.

And on some libstdc++ those virtual functions conclude that


int main() {
  std::error_code foo = 
std::make_error_code(std::errc::no_such_file_or_directory);
  return foo == std::errc::no_such_file_or_directory;
}
-

should exit with 0.

Reviewers: thakis, rnk, jfb

Reviewed By: thakis

Subscribers: lebedev.ri, dexonsmith, xbolva00, cfe-commits, caomhin

Tags: #clang

Differential Revision: https://reviews.llvm.org/D66143

Modified:
cfe/trunk/lib/Lex/HeaderSearch.cpp

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=368739=368738=368739=diff
==
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Tue Aug 13 12:32:36 2019
@@ -30,6 +30,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Capacity.h"
+#include "llvm/Support/Errc.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -315,9 +316,9 @@ const FileEntry *HeaderSearch::getFileAn
 // For rare, surprising errors (e.g. "out of file handles"), diag the EC
 // message.
 std::error_code EC = File.getError();
-if (EC != std::errc::no_such_file_or_directory &&
-EC != std::errc::invalid_argument && EC != std::errc::is_a_directory &&
-EC != std::errc::not_a_directory) {
+if (EC != llvm::errc::no_such_file_or_directory &&
+EC != llvm::errc::invalid_argument &&
+EC != llvm::errc::is_a_directory && EC != llvm::errc::not_a_directory) 
{
   Diags.Report(IncludeLoc, diag::err_cannot_open_file)
   << FileName << EC.message();
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r368295 - [OPENMP]Add support for analysis of linear variables and step.

2019-08-08 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Aug  8 06:42:45 2019
New Revision: 368295

URL: http://llvm.org/viewvc/llvm-project?rev=368295=rev
Log:
[OPENMP]Add support for analysis of linear variables and step.

Summary:
Added support for basic analysis of the linear variables and linear step
expression. Linear loop iteration variables must be excluded from this
analysis, only non-loop iteration variables must be analyzed.

Reviewers: NoQ

Subscribers: guansong, cfe-commits, caomhin, kkwli0

Tags: #clang

Differential Revision: https://reviews.llvm.org/D65461

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/Analysis/cfg-openmp.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/distribute_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/for_linear_messages.cpp
cfe/trunk/test/OpenMP/for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_linear_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/simd_linear_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_linear_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/target_simd_linear_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/taskloop_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_linear_messages.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=368295=368294=368295=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Thu Aug  8 06:42:45 2019
@@ -3216,6 +3216,14 @@ class OMPLinearClause final
 return llvm::makeArrayRef(getUpdates().end(), varlist_size());
   }
 
+  /// Gets the list of used expressions for linear variables.
+  MutableArrayRef getUsedExprs() {
+return MutableArrayRef(getFinals().end() + 2, varlist_size() + 1);
+  }
+  ArrayRef getUsedExprs() const {
+return llvm::makeArrayRef(getFinals().end() + 2, varlist_size() + 1);
+  }
+
   /// Sets the list of the copies of original linear variables.
   /// \param PL List of expressions.
   void setPrivates(ArrayRef PL);
@@ -3295,6 +3303,9 @@ public:
   /// \param FL List of expressions.
   void setFinals(ArrayRef FL);
 
+  /// Sets the list of used expressions for the linear clause.
+  void setUsedExprs(ArrayRef UE);
+
   using privates_iterator = MutableArrayRef::iterator;
   using privates_const_iterator = ArrayRef::iterator;
   using privates_range = llvm::iterator_range;
@@ -3347,6 +3358,21 @@ public:
 return finals_const_range(getFinals().begin(), getFinals().end());
   }
 
+  using used_expressions_iterator = MutableArrayRef::iterator;
+  using used_expressions_const_iterator = ArrayRef::iterator;
+  using used_expressions_range =
+  llvm::iterator_range;
+  using used_expressions_const_range =
+  llvm::iterator_range;
+
+  used_expressions_range used_expressions() {
+return finals_range(getUsedExprs().begin(), getUsedExprs().end());
+  }
+
+  used_expressions_const_range used_expressions() const {
+return finals_const_range(getUsedExprs().begin(), getUsedExprs().end());
+  }
+
   child_range children() {
 return child_range(reinterpret_cast(varlist_begin()),
reinterpret_cast(varlist_end()));
@@ -3357,11 +3383,11 @@ public:
 return const_child_range(Children.begin(), Children.end());
   }
 
-  child_range used_children() {
-return child_range(child_iterator(), child_iterator());
-  }
+  child_range used_children();
+
   const_child_range used_children() const {
-return const_child_range(const_child_iterator(), const_child_iterator());
+auto Children = const_cast(this)->used_children();
+return const_child_range(Children.begin(), Children.end());
   }
 
   static bool classof(const OMPClause *T) {

Modified: cfe/trunk/lib/AST/OpenMPClause.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/OpenMPClause.cpp?rev=368295=368294=368295=diff
==
--- cfe/trunk/lib/AST/OpenMPClause.cpp (original)
+++ cfe/trunk/lib/AST/OpenMPClause.cpp Thu Aug  8 06:42:45 2019
@@ -429,15 +429,23 @@ void OMPLinearClause::setFinals(ArrayRef
   std::copy(FL.begin(), FL.end(), getUpdates().end());
 }
 
+void OMPLinearClause::setUsedExprs(ArrayRef UE) {
+  assert(
+  UE.size() == varlist_size() + 1 &&
+  

r368172 - [OPENMP]Set default version to OpenMP 4.5.

2019-08-07 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Aug  7 07:39:17 2019
New Revision: 368172

URL: http://llvm.org/viewvc/llvm-project?rev=368172=rev
Log:
[OPENMP]Set default version to OpenMP 4.5.

Since clang fully supports OpenMP 4.5, set the default version to 4.5
instead of 3.1.

Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/OpenMP/driver.c
cfe/trunk/test/OpenMP/parallel_default_messages.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=368172=368171=368172=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Aug  7 07:39:17 2019
@@ -2894,8 +2894,8 @@ static void ParseLangArgs(LangOptions 
 }
   }
 
-  // Check if -fopenmp is specified.
-  Opts.OpenMP = Args.hasArg(options::OPT_fopenmp) ? 1 : 0;
+  // Check if -fopenmp is specified and set default version to 4.5.
+  Opts.OpenMP = Args.hasArg(options::OPT_fopenmp) ? 45 : 0;
   // Check if -fopenmp-simd is specified.
   bool IsSimdSpecified =
   Args.hasFlag(options::OPT_fopenmp_simd, options::OPT_fno_openmp_simd,

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=368172=368171=368172=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed Aug  7 07:39:17 2019
@@ -1032,18 +1032,18 @@ static void InitializePredefinedMacros(c
 switch (LangOpts.OpenMP) {
 case 0:
   break;
+case 31:
+  Builder.defineMacro("_OPENMP", "201107");
+  break;
 case 40:
   Builder.defineMacro("_OPENMP", "201307");
   break;
-case 45:
-  Builder.defineMacro("_OPENMP", "201511");
-  break;
 case 50:
   Builder.defineMacro("_OPENMP", "201811");
   break;
 default:
-  // Default version is OpenMP 3.1
-  Builder.defineMacro("_OPENMP", "201107");
+  // Default version is OpenMP 4.5
+  Builder.defineMacro("_OPENMP", "201511");
   break;
 }
   }

Modified: cfe/trunk/test/OpenMP/driver.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/driver.c?rev=368172=368171=368172=diff
==
--- cfe/trunk/test/OpenMP/driver.c (original)
+++ cfe/trunk/test/OpenMP/driver.c Wed Aug  7 07:39:17 2019
@@ -15,9 +15,12 @@
 // RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=1 | FileCheck 
--check-prefix=CHECK-DEFAULT-VERSION %s
 // RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=0 | FileCheck 
--check-prefix=CHECK-DEFAULT-VERSION %s
 // RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=100 | FileCheck 
--check-prefix=CHECK-DEFAULT-VERSION %s
-// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=31 | FileCheck 
--check-prefix=CHECK-DEFAULT-VERSION %s
+// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=45 | FileCheck 
--check-prefix=CHECK-DEFAULT-VERSION %s
 
-// CHECK-DEFAULT-VERSION: #define _OPENMP 201107
+// CHECK-DEFAULT-VERSION: #define _OPENMP 201511
+
+// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=31 | FileCheck 
--check-prefix=CHECK-31-VERSION %s
+// CHECK-31-VERSION: #define _OPENMP 201107
 
 // RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=40 | FileCheck 
--check-prefix=CHECK-40-VERSION %s
 // CHECK-40-VERSION: #define _OPENMP 201307

Modified: cfe/trunk/test/OpenMP/parallel_default_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_default_messages.cpp?rev=368172=368171=368172=diff
==
--- cfe/trunk/test/OpenMP/parallel_default_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_default_messages.cpp Wed Aug  7 07:39:17 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,ge40 -fopenmp -ferror-limit 100 -o - %s 
-Wuninitialized
 // RUN: %clang_cc1 -verify=expected,ge40 -fopenmp-simd -ferror-limit 100 -o - 
%s -Wuninitialized
 // RUN: %clang_cc1 -verify=expected,ge40 -fopenmp-version=50 -fopenmp 
-ferror-limit 100 -o - %s -Wuninitialized
 // RUN: %clang_cc1 -verify=expected,ge40 -fopenmp-version=40 -fopenmp 
-ferror-limit 100 -o - %s -Wuninitialized


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r368170 - [OPENMP]Add standard macro value _OPENMP for OpenMP 5.0.

2019-08-07 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Aug  7 07:02:11 2019
New Revision: 368170

URL: http://llvm.org/viewvc/llvm-project?rev=368170=rev
Log:
[OPENMP]Add standard macro value _OPENMP for OpenMP 5.0.

According to the OpenMP standard, compiler must define _OPENMP macro,
which has value in format mm, where  is the year of the standard
and mm is the month of the standard. For OpenMP 5.0 this value must be
set to 201811.

Modified:
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/OpenMP/driver.c
cfe/trunk/test/OpenMP/predefined_macro.c

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=368170=368169=368170=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed Aug  7 07:02:11 2019
@@ -1038,6 +1038,9 @@ static void InitializePredefinedMacros(c
 case 45:
   Builder.defineMacro("_OPENMP", "201511");
   break;
+case 50:
+  Builder.defineMacro("_OPENMP", "201811");
+  break;
 default:
   // Default version is OpenMP 3.1
   Builder.defineMacro("_OPENMP", "201107");

Modified: cfe/trunk/test/OpenMP/driver.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/driver.c?rev=368170=368169=368170=diff
==
--- cfe/trunk/test/OpenMP/driver.c (original)
+++ cfe/trunk/test/OpenMP/driver.c Wed Aug  7 07:02:11 2019
@@ -28,6 +28,9 @@
 // CHECK-45-VERSION: #define _OPENMP 201511
 // CHECK-45-VERSION2: #define _OPENMP 201511
 
+// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=50 | FileCheck 
--check-prefix=CHECK-50-VERSION %s
+// CHECK-50-VERSION: #define _OPENMP 201811
+
 // RUN: %clang %s -c -E -dM -fopenmp-version=1 | FileCheck 
--check-prefix=CHECK-VERSION %s
 // RUN: %clang %s -c -E -dM -fopenmp-version=31 | FileCheck 
--check-prefix=CHECK-VERSION %s
 // RUN: %clang %s -c -E -dM -fopenmp-version=40 | FileCheck 
--check-prefix=CHECK-VERSION %s

Modified: cfe/trunk/test/OpenMP/predefined_macro.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/predefined_macro.c?rev=368170=368169=368170=diff
==
--- cfe/trunk/test/OpenMP/predefined_macro.c (original)
+++ cfe/trunk/test/OpenMP/predefined_macro.c Wed Aug  7 07:02:11 2019
@@ -3,6 +3,7 @@
 
 // RUN: %clang_cc1 -fopenmp-simd -verify -o - %s
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -verify -o - %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -verify -o - %s
 // expected-no-diagnostics
 #ifdef FOPENMP
 // -fopenmp option is specified


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r367116 - [OPENMP]Add support for analysis of reduction variables.

2019-07-26 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Jul 26 07:50:05 2019
New Revision: 367116

URL: http://llvm.org/viewvc/llvm-project?rev=367116=rev
Log:
[OPENMP]Add support for analysis of reduction variables.

Summary:
Reduction variables are the variables, for which the private copies
must be created in the OpenMP regions. Then they are initialized with
the predefined values depending on the reduction operation. After exit
from the OpenMP region the original variable is updated using the
reduction value and the value of the original reduction variable.

Reviewers: NoQ

Subscribers: guansong, jdoerfert, caomhin, kkwli0, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D65106

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/test/Analysis/cfg-openmp.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/distribute_simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/for_reduction_messages.cpp
cfe/trunk/test/OpenMP/for_simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_reduction_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/parallel_reduction_messages.cpp
cfe/trunk/test/OpenMP/parallel_sections_reduction_messages.cpp
cfe/trunk/test/OpenMP/sections_reduction_messages.cpp
cfe/trunk/test/OpenMP/simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_reduction_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_reduction_messages.cpp
cfe/trunk/test/OpenMP/target_reduction_messages.cpp
cfe/trunk/test/OpenMP/target_simd_reduction_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_reduction_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_reduction_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/target_teams_reduction_messages.cpp
cfe/trunk/test/OpenMP/taskloop_reduction_messages.cpp
cfe/trunk/test/OpenMP/taskloop_simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_reduction_messages.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_reduction_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/teams_reduction_messages.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=367116=367115=367116=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Fri Jul 26 07:50:05 2019
@@ -2618,10 +2618,12 @@ public:
   }
 
   child_range used_children() {
-return child_range(child_iterator(), child_iterator());
+return child_range(reinterpret_cast(varlist_begin()),
+   reinterpret_cast(varlist_end()));
   }
   const_child_range used_children() const {
-return const_child_range(const_child_iterator(), const_child_iterator());
+auto Children = const_cast(this)->used_children();
+return const_child_range(Children.begin(), Children.end());
   }
 
   static bool classof(const OMPClause *T) {

Modified: cfe/trunk/test/Analysis/cfg-openmp.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cfg-openmp.cpp?rev=367116=367115=367116=diff
==
--- cfe/trunk/test/Analysis/cfg-openmp.cpp (original)
+++ cfe/trunk/test/Analysis/cfg-openmp.cpp Fri Jul 26 07:50:05 2019
@@ -6,7 +6,8 @@ void xxx(int argc) {
 // CHECK-NEXT:   1: int x;
 // CHECK-NEXT:   2: int cond;
 // CHECK-NEXT:   3: int fp;
-  int x, cond, fp;
+// CHECK-NEXT:   4: int rd;
+  int x, cond, fp, rd;
 // CHECK-NEXT:   [[#ATOM:]]: x
 // CHECK-NEXT:   [[#ATOM+1]]: [B1.[[#ATOM]]] (ImplicitCastExpr, 
LValueToRValue, int)
 // CHECK-NEXT:   [[#ATOM+2]]: argc
@@ -31,10 +32,11 @@ void xxx(int argc) {
 // CHECK-NEXT:  [[#DPF+5]]: [B1.[[#DPF+4]]] (ImplicitCastExpr, LValueToRValue, 
int)
 // CHECK-NEXT:  [[#DPF+6]]: [B1.[[#DPF+5]]] (ImplicitCastExpr, 
IntegralToBoolean, _Bool)
 // CHECK-NEXT:  [[#DPF+7]]: fp
-// CHECK-NEXT:  [[#DPF+8]]: #pragma omp distribute parallel for if(parallel: 
cond) firstprivate(fp)
+// CHECK-NEXT:  [[#DPF+8]]: rd
+// CHECK-NEXT:  [[#DPF+9]]: #pragma omp distribute parallel for if(parallel: 
cond) firstprivate(fp) reduction(+: rd)
 // CHECK-NEXT:for (int i = 0; i < 10; ++i)
 // CHECK-NEXT:[B1.[[#DPF+3]]];
-#pragma omp distribute parallel for if(parallel:cond) firstprivate(fp)
+#pragma omp 

r366702 - [OPENMP][MSVC]Enable /openmp[:experimental] to compile OpenMP.

2019-07-22 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Jul 22 09:49:59 2019
New Revision: 366702

URL: http://llvm.org/viewvc/llvm-project?rev=366702=rev
Log:
[OPENMP][MSVC]Enable /openmp[:experimental] to compile OpenMP.

Mapped /openmp[:experimental] to -fopenmp option and /openmp- option to
-fno-openmp

Modified:
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/test/Driver/fopenmp.c

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=366702=366701=366702=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Mon Jul 22 09:49:59 2019
@@ -254,7 +254,13 @@ def _SLASH_Zp_flag : CLFlag<"Zp">,
   Alias, AliasArgs<["1"]>;
 def _SLASH_Zs : CLFlag<"Zs">, HelpText<"Syntax-check only">,
   Alias;
-
+def _SLASH_openmp_ : CLFlag<"openmp-">,
+  HelpText<"Disable OpenMP support">, Alias;
+def _SLASH_openmp : CLFlag<"openmp">, HelpText<"Enable OpenMP support">,
+  Alias;
+def _SLASH_openmp_experimental : CLFlag<"openmp:experimental">,
+  HelpText<"Enable OpenMP support with experimental SIMD support">,
+  Alias;
 
 // Non-aliases:
 
@@ -381,7 +387,6 @@ def _SLASH_FS : CLIgnoredFlag<"FS">;
 def _SLASH_JMC : CLIgnoredFlag<"JMC">;
 def _SLASH_kernel_ : CLIgnoredFlag<"kernel-">;
 def _SLASH_nologo : CLIgnoredFlag<"nologo">;
-def _SLASH_openmp_ : CLIgnoredFlag<"openmp-">;
 def _SLASH_permissive_ : CLIgnoredFlag<"permissive-">;
 def _SLASH_RTC : CLIgnoredJoined<"RTC">;
 def _SLASH_sdl : CLIgnoredFlag<"sdl">;
@@ -436,8 +441,6 @@ def _SLASH_hotpatch : CLFlag<"hotpatch">
 def _SLASH_kernel : CLFlag<"kernel">;
 def _SLASH_LN : CLFlag<"LN">;
 def _SLASH_MP : CLJoined<"MP">;
-def _SLASH_openmp : CLFlag<"openmp">;
-def _SLASH_openmp_experimental : CLFlag<"openmp:experimental">;
 def _SLASH_Qfast_transcendentals : CLFlag<"Qfast_transcendentals">;
 def _SLASH_QIfist : CLFlag<"QIfist">;
 def _SLASH_Qimprecise_fwaits : CLFlag<"Qimprecise_fwaits">;

Modified: cfe/trunk/test/Driver/fopenmp.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fopenmp.c?rev=366702=366701=366702=diff
==
--- cfe/trunk/test/Driver/fopenmp.c (original)
+++ cfe/trunk/test/Driver/fopenmp.c Mon Jul 22 09:49:59 2019
@@ -13,6 +13,10 @@
 // RUN: %clang -target x86_64-windows-gnu -fopenmp=libomp -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-CC1-OPENMP
 // RUN: %clang -target x86_64-windows-gnu -fopenmp=libgomp -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-CC1-NO-OPENMP
 // RUN: %clang -target x86_64-windows-gnu -fopenmp=libiomp5 -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-CC1-OPENMP
+// RUN: %clang -target x86_64-windows-gnu -fopenmp=libiomp5 -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-CC1-OPENMP
+// RUN: %clang_cl --target=x86_64-windows-msvc /openmp -### -- %s 2>&1 | 
FileCheck --check-prefix=CHECK-CC1-OPENMP %s
+// RUN: %clang_cl --target=i686-windows-msvc /openmp:experimental -### -- %s 
2>&1 | FileCheck --check-prefix=CHECK-CC1-OPENMP %s
+// RUN: %clang_cl --target=x86_64-windows-msvc /openmp- -### -- %s 2>&1 | 
FileCheck --check-prefix=CHECK-CC1-NO-OPENMP %s
 //
 // CHECK-CC1-OPENMP: "-cc1"
 // CHECK-CC1-OPENMP: "-fopenmp"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366689 - [OPENMP]Add support for analysis of firstprivate variables.

2019-07-22 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Jul 22 06:51:07 2019
New Revision: 366689

URL: http://llvm.org/viewvc/llvm-project?rev=366689=rev
Log:
[OPENMP]Add support for analysis of firstprivate variables.

Summary:
Firstprivate variables are the variables, for which the private copies
must be created in the OpenMP regions and must be initialized with the
original values. Thus, we must report if the uninitialized variable is
used as firstprivate.

Reviewers: NoQ

Subscribers: guansong, jdoerfert, caomhin, kkwli0, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64765

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/test/Analysis/cfg-openmp.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/parallel_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/parallel_sections_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_teams_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/task_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/taskloop_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/taskloop_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_firstprivate_messages.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_firstprivate_messages.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_firstprivate_messages.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=366689=366688=366689=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Mon Jul 22 06:51:07 2019
@@ -2099,10 +2099,12 @@ public:
   }
 
   child_range used_children() {
-return child_range(child_iterator(), child_iterator());
+return child_range(reinterpret_cast(varlist_begin()),
+   reinterpret_cast(varlist_end()));
   }
   const_child_range used_children() const {
-return const_child_range(const_child_iterator(), const_child_iterator());
+auto Children = const_cast(this)->used_children();
+return const_child_range(Children.begin(), Children.end());
   }
 
   static bool classof(const OMPClause *T) {

Modified: cfe/trunk/test/Analysis/cfg-openmp.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cfg-openmp.cpp?rev=366689=366688=366689=diff
==
--- cfe/trunk/test/Analysis/cfg-openmp.cpp (original)
+++ cfe/trunk/test/Analysis/cfg-openmp.cpp Mon Jul 22 06:51:07 2019
@@ -5,7 +5,8 @@ void xxx(int argc) {
 // CHECK:[B1]
 // CHECK-NEXT:   1: int x;
 // CHECK-NEXT:   2: int cond;
-  int x, cond;
+// CHECK-NEXT:   3: int fp;
+  int x, cond, fp;
 // CHECK-NEXT:   [[#ATOM:]]: x
 // CHECK-NEXT:   [[#ATOM+1]]: [B1.[[#ATOM]]] (ImplicitCastExpr, 
LValueToRValue, int)
 // CHECK-NEXT:   [[#ATOM+2]]: argc
@@ -29,10 +30,11 @@ void xxx(int argc) {
 // CHECK-NEXT:  [[#DPF+4]]: cond
 // CHECK-NEXT:  [[#DPF+5]]: [B1.[[#DPF+4]]] (ImplicitCastExpr, LValueToRValue, 
int)
 // CHECK-NEXT:  [[#DPF+6]]: [B1.[[#DPF+5]]] (ImplicitCastExpr, 
IntegralToBoolean, _Bool)
-// CHECK-NEXT:  [[#DPF+7]]: #pragma omp distribute parallel for if(parallel: 
cond)
+// CHECK-NEXT:  [[#DPF+7]]: fp
+// CHECK-NEXT:  [[#DPF+8]]: #pragma omp distribute parallel for if(parallel: 
cond) firstprivate(fp)
 // CHECK-NEXT:for (int i = 0; i < 10; ++i)
 // CHECK-NEXT:[B1.[[#DPF+3]]];
-#pragma omp distribute parallel for if(parallel:cond)
+#pragma omp distribute parallel for if(parallel:cond) firstprivate(fp)
   for (int i = 0; i < 10; ++i)
 argc = x;
 // CHECK-NEXT:  [[#DPFS:]]: x
@@ -42,10 +44,11 @@ void xxx(int argc) {
 // CHECK-NEXT:  [[#DPFS+4]]: cond
 // CHECK-NEXT:  [[#DPFS+5]]: [B1.[[#DPFS+4]]] (ImplicitCastExpr, 
LValueToRValue, int)
 // CHECK-NEXT:  

r366483 - [OPENMP]Fix sharing of threadprivate variables with TLS support.

2019-07-18 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jul 18 12:40:24 2019
New Revision: 366483

URL: http://llvm.org/viewvc/llvm-project?rev=366483=rev
Log:
[OPENMP]Fix sharing of threadprivate variables with TLS support.

If the threadprivate variable is used in the copyin clause on inner
parallel directive with TLS support, we capture this variable in all
outer OpenMP scopes. It leads to the fact that in all scopes we're
working with the original variable, not the threadprivate copies.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=366483=366482=366483=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Jul 18 12:40:24 2019
@@ -1882,6 +1882,13 @@ bool Sema::isOpenMPPrivateDecl(const Val
 !isOpenMPSimdDirective(DSAStack->getCurrentDirective()))
   return true;
   }
+  if (const auto *VD = dyn_cast(D)) {
+if (DSAStack->isThreadPrivate(const_cast(VD)) &&
+DSAStack->isForceVarCapturing() &&
+!DSAStack->hasExplicitDSA(
+D, [](OpenMPClauseKind K) { return K == OMPC_copyin; }, Level))
+  return true;
+  }
   return DSAStack->hasExplicitDSA(
  D, [](OpenMPClauseKind K) { return K == OMPC_private; }, Level) ||
  (DSAStack->isClauseParsingMode() &&

Modified: cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp?rev=366483=366482=366483=diff
==
--- cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp Thu Jul 18 12:40:24 2019
@@ -19,6 +19,7 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DLAMBDA -triple 
x86_64-linux -emit-llvm %s -o - | FileCheck -check-prefix=TLS-LAMBDA %s
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -fblocks -DBLOCKS -triple 
x86_64-linux -emit-llvm %s -o - | FileCheck -check-prefix=TLS-BLOCKS %s
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DARRAY -triple 
x86_64-linux-gnu -emit-llvm %s -o - | FileCheck -check-prefix=TLS-ARRAY %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -DNESTED -triple x86_64-linux 
-emit-llvm %s -o - | FileCheck %s -check-prefix=NESTED
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-linux 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-linux 
-emit-pch -o %t %s
@@ -28,7 +29,7 @@
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -std=c++11 -DARRAY -triple 
x86_64-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
 // SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
 // expected-no-diagnostics
-#ifndef ARRAY
+#if !defined(ARRAY) && !defined(NESTED)
 #ifndef HEADER
 #define HEADER
 
@@ -493,7 +494,7 @@ int main() {
 // TLS-CHECK: ret void
 
 #endif
-#else
+#elif defined(ARRAY)
 // ARRAY-LABEL: array_func
 // TLS-ARRAY-LABEL: array_func
 
@@ -522,6 +523,24 @@ void array_func() {
 #pragma omp parallel copyin(a, s)
   ;
 }
-#endif
-
+#elif defined(NESTED)
+int t;
+#pragma omp threadprivate(t)
+// NESTED: foo
+void foo() {
+  // NESTED: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) 
@__kmpc_fork_call(%struct.ident_t* @{{.+}}, i32 0, void (i32*, i32*, ...)* 
bitcast (void (i32*, i32*)* [[OUTLINED:@.+]] to void (i32*, i32*, ...)*))
+#pragma omp parallel
+#pragma omp parallel copyin(t)
+  ++t;
+}
+// NESTED: define {{.*}}void [[OUTLINED]](
+// NESTED: [[T:%.+]] = call i32* [[THRP_T:@.+]]()
+// NESTED:  call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) 
@__kmpc_fork_call(%struct.ident_t* @{{.+}}, i32 1, void (i32*, i32*, ...)* 
bitcast (void (i32*, i32*, i32*)* [[OUTLINED1:@.+]] to void (i32*, i32*, 
...)*), i32* [[T]])
+
+// NESTED: define {{.*}}void [[OUTLINED1]](
+// NESTED: [[T_MASTER:%.+]] = load i32*, i32** %
+// NESTED: [[T:%.+]] = call i32* [[THRP_T]]()
+// NESTED: [[T_MASTER_VAL:%.+]] = load i32, i32* [[T_MASTER]],
+// NESTED: store i32 [[T_MASTER_VAL]], i32* [[T]],
+#endif // NESTED
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366474 - [OPENMP]Provide correct data sharing attributes for loop control

2019-07-18 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jul 18 10:49:13 2019
New Revision: 366474

URL: http://llvm.org/viewvc/llvm-project?rev=366474=rev
Log:
[OPENMP]Provide correct data sharing attributes for loop control
variables.

Loop control variables are private in loop-based constructs and we shall
take this into account when generate the code for inner constructs.
Currently, those variables are reported as shared in many cases. Moved
the analysis of the data-sharing attributes of the loop control variable
to an early semantic stage to correctly handle their attributes.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/distribute_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/distribute_simd_misc_messages.c
cfe/trunk/test/OpenMP/for_misc_messages.c
cfe/trunk/test/OpenMP/for_simd_misc_messages.c
cfe/trunk/test/OpenMP/parallel_for_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_misc_messages.c
cfe/trunk/test/OpenMP/parallel_for_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/simd_misc_messages.c
cfe/trunk/test/OpenMP/target_parallel_for_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_misc_messages.c
cfe/trunk/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_misc_messages.c
cfe/trunk/test/OpenMP/target_simd_firstprivate_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_misc_messages.c
cfe/trunk/test/OpenMP/target_teams_distribute_simd_misc_messages.c
cfe/trunk/test/OpenMP/task_codegen.c
cfe/trunk/test/OpenMP/taskloop_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/taskloop_simd_firstprivate_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=366474=366473=366474=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Jul 18 10:49:13 2019
@@ -139,6 +139,7 @@ private:
 /// clause, false otherwise.
 llvm::Optional> OrderedRegion;
 unsigned AssociatedLoops = 1;
+bool HasMutipleLoops = false;
 const Decl *PossiblyLoopCounter = nullptr;
 bool NowaitRegion = false;
 bool CancelRegion = false;
@@ -678,12 +679,19 @@ public:
   /// Set collapse value for the region.
   void setAssociatedLoops(unsigned Val) {
 getTopOfStack().AssociatedLoops = Val;
+if (Val > 1)
+  getTopOfStack().HasMutipleLoops = true;
   }
   /// Return collapse value for region.
   unsigned getAssociatedLoops() const {
 const SharingMapTy *Top = getTopOfStackOrNull();
 return Top ? Top->AssociatedLoops : 0;
   }
+  /// Returns true if the construct is associated with multiple loops.
+  bool hasMutipleLoops() const {
+const SharingMapTy *Top = getTopOfStackOrNull();
+return Top ? Top->HasMutipleLoops : false;
+  }
 
   /// Marks current target region as one with closely nested teams
   /// region.
@@ -5604,13 +5612,14 @@ void Sema::ActOnOpenMPLoopInitialization
 if (!ISC.checkAndSetInit(Init, /*EmitDiags=*/false)) {
   if (ValueDecl *D = ISC.getLoopDecl()) {
 auto *VD = dyn_cast(D);
+DeclRefExpr *PrivateRef = nullptr;
 if (!VD) {
   if (VarDecl *Private = isOpenMPCapturedDecl(D)) {
 VD = Private;
   } else {
-DeclRefExpr *Ref = buildCapture(*this, D, ISC.getLoopDeclRefExpr(),
-/*WithInit=*/false);
-VD = cast(Ref->getDecl());
+PrivateRef = buildCapture(*this, D, ISC.getLoopDeclRefExpr(),
+  /*WithInit=*/false);
+VD = cast(PrivateRef->getDecl());
   }
 }
 DSAStack->addLoopControlVariable(D, VD);
@@ -5623,6 +5632,49 @@ void Sema::ActOnOpenMPLoopInitialization
  Var->getType().getNonLValueExprType(Context),
  ForLoc, /*RefersToCapture=*/true));
 }
+OpenMPDirectiveKind DKind = DSAStack->getCurrentDirective();
+// OpenMP [2.14.1.1, Data-sharing Attribute Rules for Variables
+// Referenced in a Construct, C/C++]. The loop iteration variable in 
the
+// associated for-loop of a simd construct with just one associated
+// for-loop may be listed in a linear clause with a 
constant-linear-step
+// that is the increment of the associated for-loop. The loop iteration
+// variable(s) in the associated for-loop(s) of a for or parallel for
+// construct may be listed in a private or lastprivate clause.
+DSAStackTy::DSAVarData DVar =
+DSAStack->getTopDSA(D, /*FromParent=*/false);
+// 

r366437 - [OPENMP][NVPTX]Mark barrier functions calls as convergent.

2019-07-18 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jul 18 06:49:24 2019
New Revision: 366437

URL: http://llvm.org/viewvc/llvm-project?rev=366437=rev
Log:
[OPENMP][NVPTX]Mark barrier functions calls as convergent.

Added convergent attribute to the barrier functions calls for correct
optimizations.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=366437=366436=366437=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Thu Jul 18 06:49:24 2019
@@ -2669,8 +2669,9 @@ void CGOpenMPRuntimeNVPTX::syncCTAThread
   llvm::ConstantPointerNull::get(
   cast(getIdentTyPointerTy())),
   llvm::ConstantInt::get(CGF.Int32Ty, /*V=*/0, /*isSigned=*/true)};
-  CGF.EmitRuntimeCall(
+  llvm::CallInst *Call = CGF.EmitRuntimeCall(
   createNVPTXRuntimeFunction(OMPRTL__kmpc_barrier_simple_spmd), Args);
+  Call->setConvergent();
 }
 
 void CGOpenMPRuntimeNVPTX::emitBarrierCall(CodeGenFunction ,
@@ -2684,7 +2685,9 @@ void CGOpenMPRuntimeNVPTX::emitBarrierCa
   unsigned Flags = getDefaultFlagsForBarriers(Kind);
   llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc, Flags),
  getThreadID(CGF, Loc)};
-  CGF.EmitRuntimeCall(createNVPTXRuntimeFunction(OMPRTL__kmpc_barrier), Args);
+  llvm::CallInst *Call = CGF.EmitRuntimeCall(
+  createNVPTXRuntimeFunction(OMPRTL__kmpc_barrier), Args);
+  Call->setConvergent();
 }
 
 void CGOpenMPRuntimeNVPTX::emitCriticalRegion(

Modified: cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp?rev=366437=366436=366437=diff
==
--- cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp Thu Jul 18 06:49:24 2019
@@ -88,7 +88,7 @@ int bar(int n){
 // CHECK: br label {{%?}}[[AWAIT_WORK:.+]]
 //
 // CHECK: [[AWAIT_WORK]]
-// CHECK: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i32 0)
+// CHECK: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i32 0) 
#[[#BARRIER_ATTRS:]]
 // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]]
 // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
 // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
@@ -318,10 +318,10 @@ int bar(int n){
 // CHECK: define internal void [[PARALLEL_FN4]](
 // CHECK: [[A:%.+]] = alloca i[[SZ:32|64]],
 // CHECK: store i[[SZ]] 45, i[[SZ]]* %a,
-// CHECK: call void @__kmpc_barrier(%struct.ident_t* @{{.+}}, i32 %{{.+}})
+// CHECK: call void @__kmpc_barrier(%struct.ident_t* @{{.+}}, i32 %{{.+}}) 
#[[#BARRIER_ATTRS]]
 // CHECK: ret void
 
-// CHECK: declare void @__kmpc_barrier(%struct.ident_t*, i32) 
#[[BARRIER_ATTRS:.+]]
+// CHECK: declare void @__kmpc_barrier(%struct.ident_t*, i32) 
#[[#BARRIER_ATTRS]]
 
 // CHECK-LABEL: define {{.*}}void 
{{@__omp_offloading_.+template.+l55}}_worker()
 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l55}}(
@@ -367,6 +367,6 @@ int bar(int n){
 // CHECK:  store i32 [[NEW_CC_VAL]], i32* [[CC]],
 // CHECK:  br label
 
-// CHECK: attributes #[[BARRIER_ATTRS]] = {{.*}} convergent {{.*}}
+// CHECK: attributes #[[#BARRIER_ATTRS]] = {{.*}} convergent {{.*}}
 
 #endif


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366357 - [OPENMP]Fix PR42632: crash on the analysis of the OpenMP constructs.

2019-07-17 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Jul 17 11:03:39 2019
New Revision: 366357

URL: http://llvm.org/viewvc/llvm-project?rev=366357=rev
Log:
[OPENMP]Fix PR42632: crash on the analysis of the OpenMP constructs.

Fixed processing of the CapturedStmt children to fix the crash of the
OpenMP constructs during analysis.

Modified:
cfe/trunk/lib/AST/ParentMap.cpp
cfe/trunk/test/Analysis/openmp-unsupported.c

Modified: cfe/trunk/lib/AST/ParentMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ParentMap.cpp?rev=366357=366356=366357=diff
==
--- cfe/trunk/lib/AST/ParentMap.cpp (original)
+++ cfe/trunk/lib/AST/ParentMap.cpp Wed Jul 17 11:03:39 2019
@@ -83,6 +83,18 @@ static void BuildParentMap(MapTy& M, Stm
 }
 break;
   }
+  case Stmt::CapturedStmtClass:
+for (Stmt *SubStmt : S->children()) {
+  if (SubStmt) {
+M[SubStmt] = S;
+BuildParentMap(M, SubStmt, OVMode);
+  }
+}
+if (Stmt *SubStmt = cast(S)->getCapturedStmt()) {
+  M[SubStmt] = S;
+  BuildParentMap(M, SubStmt, OVMode);
+}
+break;
   default:
 for (Stmt *SubStmt : S->children()) {
   if (SubStmt) {

Modified: cfe/trunk/test/Analysis/openmp-unsupported.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/openmp-unsupported.c?rev=366357=366356=366357=diff
==
--- cfe/trunk/test/Analysis/openmp-unsupported.c (original)
+++ cfe/trunk/test/Analysis/openmp-unsupported.c Wed Jul 17 11:03:39 2019
@@ -4,4 +4,8 @@
 void openmp_parallel_crash_test() {
 #pragma omp parallel
   ;
+#pragma omp parallel for
+  for (int i = 0; i < 8; ++i)
+for (int j = 0, k = 0; j < 8; ++j)
+  ;
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366211 - [OPENMP]Add support for analysis of if clauses.

2019-07-16 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jul 16 07:51:46 2019
New Revision: 366211

URL: http://llvm.org/viewvc/llvm-project?rev=366211=rev
Log:
[OPENMP]Add support for analysis of if clauses.

Summary:
Added support for analysis of if clauses in the OpenMP directives to be
able to check for the use of uninitialized variables.

Reviewers: NoQ

Subscribers: guansong, jfb, jdoerfert, caomhin, kkwli0, cfe-commits

Tags: clang

Differential Revision: https://reviews.llvm.org/D64646

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/test/Analysis/cfg-openmp.cpp
cfe/trunk/test/OpenMP/cancel_if_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_if_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_if_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_if_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_if_messages.cpp
cfe/trunk/test/OpenMP/parallel_if_messages.cpp
cfe/trunk/test/OpenMP/parallel_sections_if_messages.cpp
cfe/trunk/test/OpenMP/target_data_if_messages.cpp
cfe/trunk/test/OpenMP/target_enter_data_if_messages.cpp
cfe/trunk/test/OpenMP/target_exit_data_if_messages.cpp
cfe/trunk/test/OpenMP/target_if_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_if_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_if_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_if_messages.cpp
cfe/trunk/test/OpenMP/target_simd_if_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_if_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_if_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_if_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_if_messages.cpp
cfe/trunk/test/OpenMP/target_teams_if_messages.cpp
cfe/trunk/test/OpenMP/target_update_if_messages.cpp
cfe/trunk/test/OpenMP/task_if_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_if_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_if_messages.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=366211=366210=366211=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Tue Jul 16 07:51:46 2019
@@ -501,11 +501,10 @@ public:
 return const_child_range(,  + 1);
   }
 
-  child_range used_children() {
-return child_range(child_iterator(), child_iterator());
-  }
+  child_range used_children();
   const_child_range used_children() const {
-return const_child_range(const_child_iterator(), const_child_iterator());
+auto Children = const_cast(this)->used_children();
+return const_child_range(Children.begin(), Children.end());
   }
 
   static bool classof(const OMPClause *T) {

Modified: cfe/trunk/lib/AST/OpenMPClause.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/OpenMPClause.cpp?rev=366211=366210=366211=diff
==
--- cfe/trunk/lib/AST/OpenMPClause.cpp (original)
+++ cfe/trunk/lib/AST/OpenMPClause.cpp Tue Jul 16 07:51:46 2019
@@ -209,6 +209,25 @@ const OMPClauseWithPostUpdate *OMPClause
   return nullptr;
 }
 
+/// Gets the address of the original, non-captured, expression used in the
+/// clause as the preinitializer.
+static Stmt **getAddrOfExprAsWritten(Stmt *S) {
+  if (!S)
+return nullptr;
+  if (auto *DS = dyn_cast(S)) {
+assert(DS->isSingleDecl() && "Only single expression must be captured.");
+if (auto *OED = dyn_cast(DS->getSingleDecl()))
+  return OED->getInitAddress();
+  }
+  return nullptr;
+}
+
+OMPClause::child_range OMPIfClause::used_children() {
+  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
+return child_range(C, C + 1);
+  return child_range(,  + 1);
+}
+
 OMPOrderedClause *OMPOrderedClause::Create(const ASTContext , Expr *Num,
unsigned NumLoops,
SourceLocation StartLoc,

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=366211=366210=366211=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Tue Jul 16 07:51:46 2019
@@ -4746,8 +4746,9 @@ CFGBlock *CFGBuilder::VisitOMPExecutable
 
   // Reverse the elements to process them in natural order. Iterators are not
   // bidirectional, so we need to create temp vector.
-  for (Stmt *S : llvm::reverse(llvm::to_vector<8>(
-   OMPExecutableDirective::used_clauses_children(D->clauses() {
+  SmallVector Used(
+  

r366068 - [OPENMP]Add support for analysis of if clauses.

2019-07-15 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Jul 15 07:46:23 2019
New Revision: 366068

URL: http://llvm.org/viewvc/llvm-project?rev=366068=rev
Log:
[OPENMP]Add support for analysis of if clauses.

Summary:
Added support for analysis of if clauses in the OpenMP directives to be
able to check for the use of uninitialized variables.

Reviewers: NoQ

Subscribers: guansong, jfb, jdoerfert, caomhin, kkwli0, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64646

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/test/Analysis/cfg-openmp.cpp
cfe/trunk/test/OpenMP/cancel_if_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_if_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_if_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_if_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_if_messages.cpp
cfe/trunk/test/OpenMP/parallel_if_messages.cpp
cfe/trunk/test/OpenMP/parallel_sections_if_messages.cpp
cfe/trunk/test/OpenMP/target_data_if_messages.cpp
cfe/trunk/test/OpenMP/target_enter_data_if_messages.cpp
cfe/trunk/test/OpenMP/target_exit_data_if_messages.cpp
cfe/trunk/test/OpenMP/target_if_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_if_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_if_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_if_messages.cpp
cfe/trunk/test/OpenMP/target_simd_if_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_if_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_if_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_if_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_if_messages.cpp
cfe/trunk/test/OpenMP/target_teams_if_messages.cpp
cfe/trunk/test/OpenMP/target_update_if_messages.cpp
cfe/trunk/test/OpenMP/task_if_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_if_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_if_messages.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=366068=366067=366068=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Mon Jul 15 07:46:23 2019
@@ -501,11 +501,10 @@ public:
 return const_child_range(,  + 1);
   }
 
-  child_range used_children() {
-return child_range(child_iterator(), child_iterator());
-  }
+  child_range used_children();
   const_child_range used_children() const {
-return const_child_range(const_child_iterator(), const_child_iterator());
+auto Children = const_cast(this)->used_children();
+return const_child_range(Children.begin(), Children.end());
   }
 
   static bool classof(const OMPClause *T) {

Modified: cfe/trunk/lib/AST/OpenMPClause.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/OpenMPClause.cpp?rev=366068=366067=366068=diff
==
--- cfe/trunk/lib/AST/OpenMPClause.cpp (original)
+++ cfe/trunk/lib/AST/OpenMPClause.cpp Mon Jul 15 07:46:23 2019
@@ -209,6 +209,25 @@ const OMPClauseWithPostUpdate *OMPClause
   return nullptr;
 }
 
+/// Gets the address of the original, non-captured, expression used in the
+/// clause as the preinitializer.
+static Stmt **getAddrOfExprAsWritten(Stmt *S) {
+  if (!S)
+return nullptr;
+  if (auto *DS = dyn_cast(S)) {
+assert(DS->isSingleDecl() && "Only single expression must be captured.");
+if (auto *OED = dyn_cast(DS->getSingleDecl()))
+  return OED->getInitAddress();
+  }
+  return nullptr;
+}
+
+OMPClause::child_range OMPIfClause::used_children() {
+  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
+return child_range(C, C + 1);
+  return child_range(,  + 1);
+}
+
 OMPOrderedClause *OMPOrderedClause::Create(const ASTContext , Expr *Num,
unsigned NumLoops,
SourceLocation StartLoc,

Modified: cfe/trunk/test/Analysis/cfg-openmp.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cfg-openmp.cpp?rev=366068=366067=366068=diff
==
--- cfe/trunk/test/Analysis/cfg-openmp.cpp (original)
+++ cfe/trunk/test/Analysis/cfg-openmp.cpp Mon Jul 15 07:46:23 2019
@@ -1,340 +1,402 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG %s 2>&1 -fopenmp | 
FileCheck %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG %s 2>&1 -fopenmp 
-fopenmp-version=45 | FileCheck %s
 
 // CHECK-LABEL:  void xxx(int argc)
 void xxx(int argc) {
 // CHECK:[B1]
 // CHECK-NEXT:   1: int x;
-  int x;
-// CHECK-NEXT:   2: x
-// CHECK-NEXT:   3: [B1.2] 

r365821 - [OPENMP]Improve handling of analysis of unsupported VLAs in reductions.

2019-07-11 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jul 11 13:35:31 2019
New Revision: 365821

URL: http://llvm.org/viewvc/llvm-project?rev=365821=rev
Log:
[OPENMP]Improve handling of analysis of unsupported VLAs in reductions.

Fixed the processing of the unsupported VLAs in the reduction clauses.
Used targetDiag if the diagnostics can be delayed and emit it
immediately if the target does not support VLAs and we're parsing target
directive with the reduction clauses.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/target_vla_messages.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=365821=365820=365821=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Jul 11 13:35:31 2019
@@ -9132,12 +9132,6 @@ public:
   }
   /// Return true inside OpenMP target region.
   bool isInOpenMPTargetExecutionDirective() const;
-  /// Return true if (un)supported features for the current target should be
-  /// diagnosed if OpenMP (offloading) is enabled.
-  bool shouldDiagnoseTargetSupportFromOpenMP() const {
-return !getLangOpts().OpenMPIsDevice || isInOpenMPDeclareTargetContext() ||
-  isInOpenMPTargetExecutionDirective();
-  }
 
   /// Return the number of captured regions created for an OpenMP directive.
   static int getOpenMPCaptureLevels(OpenMPDirectiveKind Kind);

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=365821=365820=365821=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Jul 11 13:35:31 2019
@@ -12140,10 +12140,14 @@ static bool actOnOMPReductionKindClause(
 if ((OASE && !ConstantLengthOASE) ||
 (!OASE && !ASE &&
  D->getType().getNonReferenceType()->isVariablyModifiedType())) {
-  if (!Context.getTargetInfo().isVLASupported() &&
-  S.shouldDiagnoseTargetSupportFromOpenMP()) {
-S.Diag(ELoc, diag::err_omp_reduction_vla_unsupported) << !!OASE;
-S.Diag(ELoc, diag::note_vla_unsupported);
+  if (!Context.getTargetInfo().isVLASupported()) {
+if (isOpenMPTargetExecutionDirective(Stack->getCurrentDirective())) {
+  S.Diag(ELoc, diag::err_omp_reduction_vla_unsupported) << !!OASE;
+  S.Diag(ELoc, diag::note_vla_unsupported);
+} else {
+  S.targetDiag(ELoc, diag::err_omp_reduction_vla_unsupported) << 
!!OASE;
+  S.targetDiag(ELoc, diag::note_vla_unsupported);
+}
 continue;
   }
   // For arrays/array sections only:

Modified: cfe/trunk/test/OpenMP/target_vla_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_vla_messages.cpp?rev=365821=365820=365821=diff
==
--- cfe/trunk/test/OpenMP/target_vla_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/target_vla_messages.cpp Thu Jul 11 13:35:31 2019
@@ -206,4 +206,10 @@ void for_reduction(int arg) {
 #pragma omp parallel
 #pragma omp for reduction(+: vla[0:arg])
   for (int i = 0; i < arg; i++) ;
+#ifdef NO_VLA
+  // expected-error@+3 {{cannot generate code for reduction on array section, 
which requires a variable length array}}
+  // expected-note@+2 {{variable length arrays are not supported for the 
current target}}
+#endif
+#pragma omp target reduction(+ : vla[0:arg])
+  for (int i = 0; i < arg; i++) ;
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r365786 - [OPENMP]Initial fix PR42392: Improve -Wuninitialized warnings for OpenMP programs.

2019-07-11 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jul 11 07:54:17 2019
New Revision: 365786

URL: http://llvm.org/viewvc/llvm-project?rev=365786=rev
Log:
[OPENMP]Initial fix PR42392: Improve -Wuninitialized warnings for OpenMP 
programs.

Summary:
Some OpenMP clauses rely on the values of the variables. If the variable
is not initialized and used in OpenMP clauses that depend on the
variables values, it should be reported that the uninitialized variable
is used in the OpenMP clause expression.
This patch adds initial processing for uninitialized variables in OpenMP
constructs. Currently, it checks for use of the uninitialized variables
in the structured blocks.

Reviewers: NoQ, Szelethus, dcoughlin, xazax.hun, a.sidorin, george.karpenkov, 
szepet

Subscribers: rnkovacs, guansong, jfb, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64356

Added:
cfe/trunk/test/Analysis/cfg-openmp.cpp
Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/lib/Analysis/UninitializedValues.cpp
cfe/trunk/test/OpenMP/atomic_messages.c
cfe/trunk/test/OpenMP/critical_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_misc_messages.c
cfe/trunk/test/OpenMP/distribute_simd_misc_messages.c
cfe/trunk/test/OpenMP/for_misc_messages.c
cfe/trunk/test/OpenMP/for_simd_misc_messages.c
cfe/trunk/test/OpenMP/master_messages.cpp
cfe/trunk/test/OpenMP/ordered_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_messages.cpp
cfe/trunk/test/OpenMP/parallel_messages.cpp
cfe/trunk/test/OpenMP/parallel_sections_messages.cpp
cfe/trunk/test/OpenMP/sections_misc_messages.c
cfe/trunk/test/OpenMP/simd_misc_messages.c
cfe/trunk/test/OpenMP/single_misc_messages.c
cfe/trunk/test/OpenMP/target_depend_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_messages.cpp
cfe/trunk/test/OpenMP/target_simd_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_messages.cpp
cfe/trunk/test/OpenMP/target_teams_messages.cpp
cfe/trunk/test/OpenMP/target_update_messages.cpp
cfe/trunk/test/OpenMP/task_messages.cpp
cfe/trunk/test/OpenMP/taskgroup_messages.cpp
cfe/trunk/test/OpenMP/taskloop_misc_messages.c
cfe/trunk/test/OpenMP/taskloop_simd_misc_messages.c
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_messages.cpp
cfe/trunk/test/OpenMP/teams_messages.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=365786=365785=365786=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Thu Jul 11 07:54:17 2019
@@ -90,6 +90,15 @@ public:
 return const_child_range(Children.begin(), Children.end());
   }
 
+  /// Get the iterator range for the expressions used in the clauses. Used
+  /// expressions include only the children that must be evaluated at the
+  /// runtime before entering the construct.
+  child_range used_children();
+  const_child_range used_children() const {
+auto Children = const_cast(this)->children();
+return const_child_range(Children.begin(), Children.end());
+  }
+
   static bool classof(const OMPClause *) { return true; }
 };
 
@@ -294,6 +303,13 @@ public:
 return const_child_range(,  + 1);
   }
 
+  child_range used_children() {
+return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
 return T->getClauseKind() == OMPC_allocator;
   }
@@ -384,6 +400,13 @@ public:
 return const_child_range(Children.begin(), Children.end());
   }
 
+  child_range used_children() {
+return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   static bool classof(const OMPClause *T) {
 return T->getClauseKind() == OMPC_allocate;
   }
@@ -478,6 +501,13 @@ public:
 return const_child_range(,  + 1);
   }
 
+  child_range used_children() {
+return 

r365777 - Added mapping for pointers captured in Lambdas in OpenMP target regions,

2019-07-11 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jul 11 06:54:26 2019
New Revision: 365777

URL: http://llvm.org/viewvc/llvm-project?rev=365777=rev
Log:
Added mapping for pointers captured in Lambdas in OpenMP target regions,
by David Truby.

Summary:
This adds a zero length array section mapping for each pointer captured by a 
lambda that is used in a target region, as per section 2.19.7.1 of the OpenMP 5 
specification.

Reviewers: ABataev

Reviewed By: ABataev

Subscribers: guansong, jdoerfert, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64558

Added:
cfe/trunk/test/OpenMP/nvptx_lambda_pointer_capturing.cpp
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=365777=365776=365777=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Jul 11 06:54:26 2019
@@ -8093,20 +8093,30 @@ public:
   OMP_MAP_MEMBER_OF | OMP_MAP_IMPLICIT);
 }
 for (const LambdaCapture  : RD->captures()) {
-  if (LC.getCaptureKind() != LCK_ByRef)
+  if (!LC.capturesVariable())
 continue;
   const VarDecl *VD = LC.getCapturedVar();
+  if (LC.getCaptureKind() != LCK_ByRef && !VD->getType()->isPointerType())
+continue;
   auto It = Captures.find(VD);
   assert(It != Captures.end() && "Found lambda capture without field.");
   LValue VarLVal = CGF.EmitLValueForFieldInitialization(VDLVal, 
It->second);
-  LValue VarLValVal = CGF.EmitLValueForField(VDLVal, It->second);
-  LambdaPointers.try_emplace(VarLVal.getPointer(), VDLVal.getPointer());
-  BasePointers.push_back(VarLVal.getPointer());
-  Pointers.push_back(VarLValVal.getPointer());
-  Sizes.push_back(CGF.Builder.CreateIntCast(
-  CGF.getTypeSize(
-  VD->getType().getCanonicalType().getNonReferenceType()),
-  CGF.Int64Ty, /*isSigned=*/true));
+  if (LC.getCaptureKind() == LCK_ByRef) {
+LValue VarLValVal = CGF.EmitLValueForField(VDLVal, It->second);
+LambdaPointers.try_emplace(VarLVal.getPointer(), VDLVal.getPointer());
+BasePointers.push_back(VarLVal.getPointer());
+Pointers.push_back(VarLValVal.getPointer());
+Sizes.push_back(CGF.Builder.CreateIntCast(
+CGF.getTypeSize(
+VD->getType().getCanonicalType().getNonReferenceType()),
+CGF.Int64Ty, /*isSigned=*/true));
+  } else {
+RValue VarRVal = CGF.EmitLoadOfLValue(VarLVal, RD->getLocation());
+LambdaPointers.try_emplace(VarLVal.getPointer(), VDLVal.getPointer());
+BasePointers.push_back(VarLVal.getPointer());
+Pointers.push_back(VarRVal.getScalarVal());
+Sizes.push_back(llvm::ConstantInt::get(CGF.Int64Ty, 0));
+  }
   Types.push_back(OMP_MAP_PTR_AND_OBJ | OMP_MAP_LITERAL |
   OMP_MAP_MEMBER_OF | OMP_MAP_IMPLICIT);
 }

Added: cfe/trunk/test/OpenMP/nvptx_lambda_pointer_capturing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_lambda_pointer_capturing.cpp?rev=365777=auto
==
--- cfe/trunk/test/OpenMP/nvptx_lambda_pointer_capturing.cpp (added)
+++ cfe/trunk/test/OpenMP/nvptx_lambda_pointer_capturing.cpp Thu Jul 11 
06:54:26 2019
@@ -0,0 +1,125 @@
+// Test host codegen only.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -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 CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | 
FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK: [[ANON_T:%.+]] = type { i32*, i32* }
+// CHECK-DAG: [[SIZES_TEMPLATE:@.+]] = private {{.+}} constant [5 x 
i[[PTRSZ:32|64]]] [i{{32|64}} 4, i{{32|64}} 4, i{{32|64}} {{8|16}}, i{{32|64}} 
0, 

r365691 - [OPENMP]Remove not used check line from the test, NFC.

2019-07-10 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Jul 10 12:30:25 2019
New Revision: 365691

URL: http://llvm.org/viewvc/llvm-project?rev=365691=rev
Log:
[OPENMP]Remove not used check line from the test, NFC.

Modified:
cfe/trunk/test/OpenMP/sections_lastprivate_codegen.cpp

Modified: cfe/trunk/test/OpenMP/sections_lastprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/sections_lastprivate_codegen.cpp?rev=365691=365690=365691=diff
==
--- cfe/trunk/test/OpenMP/sections_lastprivate_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/sections_lastprivate_codegen.cpp Wed Jul 10 12:30:25 
2019
@@ -27,7 +27,6 @@ struct S {
 volatile int g = 1212;
 
 // CHECK: [[S_FLOAT_TY:%.+]] = type { float }
-// CHECK [[CAP_MAIN_TY:%.+]] = type { i{{[0-9]+}}*, [2 x i{{[0-9]+}}]*, [2 x 
[[S_FLOAT_TY]]]*, [[S_FLOAT_TY]]*, i{{[0-9]+}}* }
 // CHECK: [[S_INT_TY:%.+]] = type { i32 }
 // CHECK-DAG: [[SECTIONS_BARRIER_LOC:@.+]] = private unnamed_addr global 
%{{.+}} { i32 0, i32 194, i32 0, i32 0, i8*
 // CHECK-DAG: [[X:@.+]] = global double 0.0


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r365485 - [OPENMP]Fix the float point semantics handling on the device.

2019-07-09 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jul  9 07:09:53 2019
New Revision: 365485

URL: http://llvm.org/viewvc/llvm-project?rev=365485=rev
Log:
[OPENMP]Fix the float point semantics handling on the device.

The device should use the same float point representation as the host.
Previous patch fixed the handling of the sizes of the float point types,
but did not fixed the fp semantics. This patch makes target device to
use the host fp semantics. this is required for the correct data
transfer between host and device and correct codegen.

Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c
cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=365485=365484=365485=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Jul  9 07:09:53 2019
@@ -1524,8 +1524,16 @@ const llvm::fltSemantics ::ge
 return Target->getHalfFormat();
   case BuiltinType::Float:  return Target->getFloatFormat();
   case BuiltinType::Double: return Target->getDoubleFormat();
-  case BuiltinType::LongDouble: return Target->getLongDoubleFormat();
-  case BuiltinType::Float128:   return Target->getFloat128Format();
+  case BuiltinType::LongDouble:
+if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice &&
+>getLongDoubleFormat() != >getLongDoubleFormat())
+  return AuxTarget->getLongDoubleFormat();
+return Target->getLongDoubleFormat();
+  case BuiltinType::Float128:
+if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice &&
+>getFloat128Format() != >getFloat128Format())
+  return AuxTarget->getFloat128Format();
+return Target->getFloat128Format();
   }
 }
 

Modified: cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c?rev=365485=365484=365485=diff
==
--- cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c (original)
+++ cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c Tue Jul  9 07:09:53 2019
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fopenmp -x c -triple i386-unknown-unknown 
-fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -x c -triple nvptx-unknown-unknown 
-fopenmp-targets=nvptx-nvidia-cuda %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only -Wuninitialized
-// RUN: %clang_cc1 -verify -DDIAGS -DIMMEDIATE -fopenmp -x c -triple 
nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only -Wuninitialized
-// RUN: %clang_cc1 -verify -DDIAGS -DDELAYED -fopenmp -x c -triple 
nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only -Wuninitialized
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple nvptx-unknown-unknown 
-aux-triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only 
-Wuninitialized
+// RUN: %clang_cc1 -verify -DDIAGS -DIMMEDIATE -fopenmp -x c -triple 
nvptx-unknown-unknown -aux-triple i386-unknown-unknown 
-fopenmp-targets=nvptx-nvidia-cuda %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only -Wuninitialized
+// RUN: %clang_cc1 -verify -DDIAGS -DDELAYED -fopenmp -x c -triple 
nvptx-unknown-unknown -aux-triple i386-unknown-unknown 
-fopenmp-targets=nvptx-nvidia-cuda %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only -Wuninitialized
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 

Modified: cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp?rev=365485=365484=365485=diff
==
--- cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp Tue Jul  9 
07:09:53 2019
@@ -1,11 +1,11 @@
 // Test target codegen - host bc file has to be created first.
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-aux-triple x86_64-unknown-linux -fopenmp-targets=nvptx64-nvidia-cuda 
-aux-triple x86_64-unknown-linux -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-aux-triple x86_64-unknown-linux -fopenmp-targets=nvptx64-nvidia-cuda 
-emit-llvm %s 

r365374 - [OPENMP]Improve error message for device unsupported types.

2019-07-08 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Jul  8 12:21:54 2019
New Revision: 365374

URL: http://llvm.org/viewvc/llvm-project?rev=365374=rev
Log:
[OPENMP]Improve error message for device unsupported types.

Provide more data to the user in the error message about unsupported
type for device compilation.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nvptx_unsupported_type_messages.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=365374=365373=365374=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jul  8 12:21:54 
2019
@@ -9269,6 +9269,8 @@ def err_omp_invariant_or_linear_dependen
   "expected loop invariant expression or ' * %0 + ' 
kind of expression">;
 def err_omp_wrong_dependency_iterator_type : Error<
   "expected an integer or a pointer type of the outer loop counter '%0' for 
non-rectangular nests">;
+def err_omp_unsupported_type : Error <
+  "host requires %0 bit size %1 type support, but device '%2' does not support 
it">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=365374=365373=365374=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon Jul  8 12:21:54 2019
@@ -1593,8 +1593,9 @@ void Sema::checkOpenMPDeviceExpr(const E
!Context.getTargetInfo().hasFloat128Type()) ||
   (Ty->isIntegerType() && Context.getTypeSize(Ty) == 128 &&
!Context.getTargetInfo().hasInt128Type()))
-targetDiag(E->getExprLoc(), diag::err_type_unsupported)
-<< Ty << E->getSourceRange();
+targetDiag(E->getExprLoc(), diag::err_omp_unsupported_type)
+<< static_cast(Context.getTypeSize(Ty)) << Ty
+<< Context.getTargetInfo().getTriple().str() << E->getSourceRange();
 }
 
 bool Sema::isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level) const {

Modified: cfe/trunk/test/OpenMP/nvptx_unsupported_type_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_unsupported_type_messages.cpp?rev=365374=365373=365374=diff
==
--- cfe/trunk/test/OpenMP/nvptx_unsupported_type_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_unsupported_type_messages.cpp Mon Jul  8 
12:21:54 2019
@@ -14,9 +14,9 @@ struct T {
   char c;
   T() : a(12), f(15) {}
 #ifndef _ARCH_PPC
-// expected-error@+4 {{'__float128' is not supported on this target}}
+// expected-error@+4 {{host requires 128 bit size '__float128' type support, 
but device 'nvptx64-unknown-unknown' does not support it}}
 #else
-// expected-error@+2 {{'long double' is not supported on this target}}
+// expected-error@+2 {{host requires 128 bit size 'long double' type support, 
but device 'nvptx64-unknown-unknown' does not support it}}
 #endif
   T +(T ) { f += b.a; return *this;}
 };


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r364820 - [OPENMP]Fix handling of lambda captures in target regions.

2019-07-01 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Jul  1 10:46:52 2019
New Revision: 364820

URL: http://llvm.org/viewvc/llvm-project?rev=364820=rev
Log:
[OPENMP]Fix handling of lambda captures in target regions.

Previously, lambda captures were processed in the function called during
capturing the variables. It leads to the recursive functions calls and
may result in the compiler crash.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nvptx_lambda_capturing.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=364820=364819=364820=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Jul  1 10:46:52 2019
@@ -8969,6 +8969,10 @@ private:
  SourceRange SrcRange = SourceRange());
 
 public:
+  /// Function tries to capture lambda's captured variables in the OpenMP 
region
+  /// before the original lambda is captured.
+  void tryCaptureOpenMPLambdas(ValueDecl *V);
+
   /// Return true if the provided declaration \a VD should be captured by
   /// reference.
   /// \param Level Relative level of nested OpenMP construct for that the check

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=364820=364819=364820=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jul  1 10:46:52 2019
@@ -15210,6 +15210,8 @@ MarkVarDeclODRUsed(VarDecl *Var, SourceL
   old = Loc;
   }
   QualType CaptureType, DeclRefType;
+  if (SemaRef.LangOpts.OpenMP)
+SemaRef.tryCaptureOpenMPLambdas(Var);
   SemaRef.tryCaptureVariable(Var, Loc, Sema::TryCapture_Implicit,
 /*EllipsisLoc*/ SourceLocation(),
 /*BuildAndDiagnose*/ true,

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=364820=364819=364820=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon Jul  1 10:46:52 2019
@@ -1726,12 +1726,10 @@ bool Sema::isOpenMPCapturedByRef(const V
 
   if (IsByRef && Ty.getNonReferenceType()->isScalarType()) {
 IsByRef =
-((DSAStack->isForceCaptureByReferenceInTargetExecutable() &&
-  !Ty->isAnyPointerType()) ||
- !DSAStack->hasExplicitDSA(
- D,
- [](OpenMPClauseKind K) -> bool { return K == OMPC_firstprivate; },
- Level, /*NotLastprivate=*/true)) &&
+!DSAStack->hasExplicitDSA(
+D,
+[](OpenMPClauseKind K) -> bool { return K == OMPC_firstprivate; },
+Level, /*NotLastprivate=*/true) &&
 // If the variable is artificial and must be captured by value - try to
 // capture by value.
 !(isa(D) && !D->hasAttr() &&
@@ -1801,53 +1799,6 @@ VarDecl *Sema::isOpenMPCapturedDecl(Valu
   return VD;
 }
   }
-  // Capture variables captured by reference in lambdas for target-based
-  // directives.
-  // FIXME: Triggering capture from here is completely inappropriate.
-  if (VD && !DSAStack->isClauseParsingMode()) {
-if (const auto *RD = VD->getType()
- .getCanonicalType()
- .getNonReferenceType()
- ->getAsCXXRecordDecl()) {
-  bool SavedForceCaptureByReferenceInTargetExecutable =
-  DSAStack->isForceCaptureByReferenceInTargetExecutable();
-  DSAStack->setForceCaptureByReferenceInTargetExecutable(/*V=*/true);
-  InParentDirectiveRAII.disable();
-  if (RD->isLambda()) {
-llvm::DenseMap Captures;
-FieldDecl *ThisCapture;
-RD->getCaptureFields(Captures, ThisCapture);
-for (const LambdaCapture  : RD->captures()) {
-  if (LC.getCaptureKind() == LCK_ByRef) {
-VarDecl *VD = LC.getCapturedVar();
-DeclContext *VDC = VD->getDeclContext();
-if (!VDC->Encloses(CurContext))
-  continue;
-DSAStackTy::DSAVarData DVarPrivate =
-DSAStack->getTopDSA(VD, /*FromParent=*/false);
-// Do not capture already captured variables.
-if (!OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD) &&
-DVarPrivate.CKind == OMPC_unknown &&
-!DSAStack->checkMappableExprComponentListsForDecl(
-D, /*CurrentRegionOnly=*/true,
-[](OMPClauseMappableExprCommon::
-   MappableExprComponentListRef,
-   OpenMPClauseKind) { return true; }))
-  MarkVariableReferenced(LC.getLocation(), 

r364683 - [OPENMP]Improve analysis of implicit captures.

2019-06-28 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Jun 28 13:45:14 2019
New Revision: 364683

URL: http://llvm.org/viewvc/llvm-project?rev=364683=rev
Log:
[OPENMP]Improve analysis of implicit captures.

If the variable is used in the OpenMP region implicitly, we need to
check the data-sharing attributes for such variables and generate
implicit clauses for them. Patch improves analysis of such variables for
better handling of data-sharing rules.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_default_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
cfe/trunk/test/OpenMP/nvptx_lambda_capturing.cpp
cfe/trunk/test/OpenMP/target_parallel_for_default_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_default_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_lastprivate_messages.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_lastprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_reduction_messages.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_aligned_messages.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_messages.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_lastprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_reduction_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_aligned_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_lastprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_linear_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/teams_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/teams_reduction_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=364683=364682=364683=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Jun 28 13:45:14 2019
@@ -2636,24 +2636,7 @@ class DSAAttrChecker final : public Stmt
 // Check implicitly captured variables.
 if (!S->hasAssociatedStmt() || !S->getAssociatedStmt())
   return;
-for (const CapturedStmt::Capture  :
- S->getInnermostCapturedStmt()->captures()) {
-  if (!Cap.capturesVariable())
-continue;
-  VarDecl *VD = Cap.getCapturedVar();
-  // Do not try to map the variable if it or its sub-component was mapped
-  // already.
-  if (isOpenMPTargetExecutionDirective(Stack->getCurrentDirective()) &&
-  Stack->checkMappableExprComponentListsForDecl(
-  VD, /*CurrentRegionOnly=*/true,
-  [](OMPClauseMappableExprCommon::MappableExprComponentListRef,
- OpenMPClauseKind) { return true; }))
-continue;
-  DeclRefExpr *DRE = buildDeclRefExpr(
-  SemaRef, VD, VD->getType().getNonLValueExprType(SemaRef.Context),
-  Cap.getLocation(), /*RefersToCapture=*/true);
-  Visit(DRE);
-}
+visitSubCaptures(S->getInnermostCapturedStmt());
   }
 
 public:
@@ -2669,7 +2652,10 @@ public:
 Visit(CED->getInit());
 return;
   }
-  }
+  } else if (VD->isImplicit() || isa(VD))
+// Do not analyze internal variables and do not enclose them into
+// implicit clauses.
+return;
   VD = VD->getCanonicalDecl();
   // Skip internally declared variables.
   if (VD->hasLocalStorage() && CS && !CS->capturesVariable(VD))
@@ -2921,6 +2907,25 @@ public:
 }
   }
 
+  void visitSubCaptures(CapturedStmt *S) {
+for (const CapturedStmt::Capture  : S->captures()) {
+  if (!Cap.capturesVariable() && !Cap.capturesVariableByCopy())
+continue;
+  VarDecl *VD = Cap.getCapturedVar();
+  // Do not try to map the variable if it or its sub-component was mapped
+  // already.
+  if (isOpenMPTargetExecutionDirective(Stack->getCurrentDirective()) &&
+  Stack->checkMappableExprComponentListsForDecl(
+  VD, /*CurrentRegionOnly=*/true,
+  [](OMPClauseMappableExprCommon::MappableExprComponentListRef,
+ OpenMPClauseKind) { return true; }))
+continue;
+  DeclRefExpr *DRE = buildDeclRefExpr(
+  SemaRef, VD, VD->getType().getNonLValueExprType(SemaRef.Context),
+  Cap.getLocation(), /*RefersToCapture=*/true);
+  Visit(DRE);
+}
+  

r364655 - [OPENMP]Fix top DSA for static members.

2019-06-28 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Jun 28 09:16:00 2019
New Revision: 364655

URL: http://llvm.org/viewvc/llvm-project?rev=364655=rev
Log:
[OPENMP]Fix top DSA for static members.

Fixed handling of the data-sharing attributes for static members when
requesting top most attribute. Previously, it might return the incorrect
attributes for static members if they were overriden in the outer
constructs.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/simd_loop_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=364655=364654=364655=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Jun 28 09:16:00 2019
@@ -1354,16 +1354,28 @@ const DSAStackTy::DSAVarData DSAStackTy:
   // in a Construct, C/C++, predetermined, p.7]
   //  Variables with static storage duration that are declared in a scope
   //  inside the construct are shared.
-  auto & = [](OpenMPDirectiveKind) { return true; };
   if (VD && VD->isStaticDataMember()) {
-DSAVarData DVarTemp = hasDSA(D, isOpenMPPrivate, MatchesAlways, 
FromParent);
-if (DVarTemp.CKind != OMPC_unknown && DVarTemp.RefExpr)
+// Check for explicitly specified attributes.
+const_iterator I = begin();
+const_iterator EndI = end();
+if (FromParent && I != EndI)
+  ++I;
+auto It = I->SharingMap.find(D);
+if (It != I->SharingMap.end()) {
+  const DSAInfo  = It->getSecond();
+  DVar.RefExpr = Data.RefExpr.getPointer();
+  DVar.PrivateCopy = Data.PrivateCopy;
+  DVar.CKind = Data.Attributes;
+  DVar.ImplicitDSALoc = I->DefaultAttrLoc;
+  DVar.DKind = I->Directive;
   return DVar;
+}
 
 DVar.CKind = OMPC_shared;
 return DVar;
   }
 
+  auto & = [](OpenMPDirectiveKind) { return true; };
   // The predetermined shared attribute for const-qualified types having no
   // mutable members was removed after OpenMP 3.1.
   if (SemaRef.LangOpts.OpenMP <= 31) {

Modified: cfe/trunk/test/OpenMP/simd_loop_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/simd_loop_messages.cpp?rev=364655=364654=364655=diff
==
--- cfe/trunk/test/OpenMP/simd_loop_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/simd_loop_messages.cpp Fri Jun 28 09:16:00 2019
@@ -9,6 +9,7 @@ static int sii;
 static int globalii;
 
 struct S {
+  // expected-note@+1 {{static data member is predetermined as shared}}
   static int ssi;
 };
 
@@ -21,6 +22,10 @@ int test_iteration_spaces() {
 #pragma omp simd linear(S::ssi)
   for (S::ssi = 0; S::ssi < 10; ++S::ssi)
 ;
+// expected-error@+1 {{shared variable cannot be private}}
+#pragma omp simd private(S::ssi)
+  for (S::ssi = 0; S::ssi < 10; ++S::ssi)
+;
 #pragma omp simd // no messages expected
   for (S::ssi = 0; S::ssi < 10; ++S::ssi)
 ;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r364650 - [OPENMP]Fix DSA for loop iteration variables in simd loops.

2019-06-28 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Jun 28 08:16:37 2019
New Revision: 364650

URL: http://llvm.org/viewvc/llvm-project?rev=364650=rev
Log:
[OPENMP]Fix DSA for loop iteration variables in simd loops.

According to the OpenMP 5.0 standard, the loop iteration variable in the 
associated
for-loop of a simd construct with just one associated for-loop may be
listed in a private, lastprivate, or linear clause with a linear-step
that is the increment of the associated for-loop. Also, the loop
teration variables in the associated for-loops of a simd construct with
multiple associated for-loops may be listed in a private or lastprivate
clause.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/simd_loop_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=364650=364649=364650=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Jun 28 08:16:37 2019
@@ -5697,7 +5697,9 @@ static bool checkOpenMPIterationSpace(
 ? ((NestedLoopCount == 1) ? OMPC_linear : OMPC_lastprivate)
 : OMPC_private;
 if (((isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-  DVar.CKind != PredeterminedCKind && DVar.RefExpr) ||
+  DVar.CKind != PredeterminedCKind && DVar.RefExpr &&
+  (SemaRef.getLangOpts().OpenMP <= 45 ||
+   (DVar.CKind != OMPC_lastprivate && DVar.CKind != OMPC_private))) ||
  ((isOpenMPWorksharingDirective(DKind) || DKind == OMPD_taskloop ||
isOpenMPDistributeDirective(DKind)) &&
   !isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&

Modified: cfe/trunk/test/OpenMP/simd_loop_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/simd_loop_messages.cpp?rev=364650=364649=364650=diff
==
--- cfe/trunk/test/OpenMP/simd_loop_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/simd_loop_messages.cpp Fri Jun 28 08:16:37 2019
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -fopenmp -x c++ -std=c++11 -fexceptions 
-fcxx-exceptions -verify %s
 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -x c++ -std=c++11 -fexceptions 
-fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fopenmp -x c++ -std=c++11 -fexceptions 
-fcxx-exceptions -verify %s -fopenmp-version=50 -DOMP50
+// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -x c++ -std=c++11 -fexceptions 
-fcxx-exceptions -verify %s -fopenmp-version=50 -DOMP50
 
 static int sii;
 // expected-note@+1 {{defined as threadprivate or thread local}}
@@ -239,12 +241,22 @@ int test_iteration_spaces() {
   for (ii = 0; (ii < 10); (ii-=0))
 c[ii] = a[ii];
 
-  // expected-note@+2  {{defined as private}}
-  // expected-error@+2 {{loop iteration variable in the associated loop of 
'omp simd' directive may not be private, predetermined as linear}}
+#ifndef OMP50
+  // expected-note@+3  {{defined as private}}
+  // expected-error@+3 {{loop iteration variable in the associated loop of 
'omp simd' directive may not be private, predetermined as linear}}
+#endif // OMP50
   #pragma omp simd private(ii)
   for (ii = 0; ii < 10; ii++)
 c[ii] = a[ii];
 
+#ifndef OMP50
+  // expected-note@+3  {{defined as lastprivate}}
+  // expected-error@+3 {{loop iteration variable in the associated loop of 
'omp simd' directive may not be lastprivate, predetermined as linear}}
+#endif // OMP50
+  #pragma omp simd lastprivate(ii)
+  for (ii = 0; ii < 10; ii++)
+c[ii] = a[ii];
+
   // expected-error@+1 {{unexpected OpenMP clause 'shared' in directive 
'#pragma omp simd'}}
   #pragma omp simd shared(ii)
   for (ii = 0; ii < 10; ii++)


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r364647 - [OPENMP]Fix checks for DSA in simd constructs.

2019-06-28 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Jun 28 07:59:25 2019
New Revision: 364647

URL: http://llvm.org/viewvc/llvm-project?rev=364647=rev
Log:
[OPENMP]Fix checks for DSA in simd constructs.

The errors for incorrectly specified data-sharing attributes for simd
constructs must be emitted only for the explicitly provided clauses, not
the predetermined ones.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/simd_loop_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=364647=364646=364647=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Jun 28 07:59:25 2019
@@ -5697,12 +5697,12 @@ static bool checkOpenMPIterationSpace(
 ? ((NestedLoopCount == 1) ? OMPC_linear : OMPC_lastprivate)
 : OMPC_private;
 if (((isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-  DVar.CKind != PredeterminedCKind) ||
+  DVar.CKind != PredeterminedCKind && DVar.RefExpr) ||
  ((isOpenMPWorksharingDirective(DKind) || DKind == OMPD_taskloop ||
isOpenMPDistributeDirective(DKind)) &&
   !isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
   DVar.CKind != OMPC_private && DVar.CKind != OMPC_lastprivate)) &&
-(DVar.CKind != OMPC_private || DVar.RefExpr != nullptr)) {
+(DVar.CKind != OMPC_private || DVar.RefExpr)) {
   SemaRef.Diag(Init->getBeginLoc(), diag::err_omp_loop_var_dsa)
   << getOpenMPClauseName(DVar.CKind) << getOpenMPDirectiveName(DKind)
   << getOpenMPClauseName(PredeterminedCKind);

Modified: cfe/trunk/test/OpenMP/simd_loop_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/simd_loop_messages.cpp?rev=364647=364646=364647=diff
==
--- cfe/trunk/test/OpenMP/simd_loop_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/simd_loop_messages.cpp Fri Jun 28 07:59:25 2019
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -fsyntax-only -fopenmp -x c++ -std=c++11 -fexceptions 
-fcxx-exceptions -verify %s
-
 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -x c++ -std=c++11 -fexceptions 
-fcxx-exceptions -verify %s
 
 static int sii;
@@ -7,12 +6,22 @@ static int sii;
 #pragma omp threadprivate(sii)
 static int globalii;
 
+struct S {
+  static int ssi;
+};
+
 int test_iteration_spaces() {
   const int N = 100;
   float a[N], b[N], c[N];
   int ii, jj, kk;
   float fii;
   double dii;
+#pragma omp simd linear(S::ssi)
+  for (S::ssi = 0; S::ssi < 10; ++S::ssi)
+;
+#pragma omp simd // no messages expected
+  for (S::ssi = 0; S::ssi < 10; ++S::ssi)
+;
   #pragma omp simd
   for (int i = 0; i < 10; i+=1) {
 c[i] = a[i] + b[i];


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r364575 - [OPENMP]Generate correctly implicit flags for mapped data.

2019-06-27 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Jun 27 11:53:07 2019
New Revision: 364575

URL: http://llvm.org/viewvc/llvm-project?rev=364575=rev
Log:
[OPENMP]Generate correctly implicit flags for mapped data.

Implicit flag must not be emitted for explicitly specified firstprivate
variables, but for implicitly captured sizes of the VLAs.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/nvptx_lambda_capturing.cpp
cfe/trunk/test/OpenMP/target_codegen.cpp
cfe/trunk/test/OpenMP/target_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/target_map_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_codegen.cpp
cfe/trunk/test/OpenMP/target_simd_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=364575=364574=364575=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Jun 27 11:53:07 2019
@@ -7155,7 +7155,9 @@ private:
   CodeGenFunction 
 
   /// Set of all first private variables in the current directive.
-  llvm::SmallPtrSet FirstPrivateDecls;
+  /// bool data is set to true if the variable is implicitly marked as
+  /// firstprivate, false otherwise.
+  llvm::DenseMap, bool> FirstPrivateDecls;
 
   /// Map between device pointer declarations and their expression components.
   /// The key value for declarations in 'this' is null.
@@ -7836,8 +7838,8 @@ public:
 // Extract firstprivate clause information.
 for (const auto *C : Dir.getClausesOfKind())
   for (const auto *D : C->varlists())
-FirstPrivateDecls.insert(
-
cast(cast(D)->getDecl())->getCanonicalDecl());
+FirstPrivateDecls.try_emplace(
+cast(cast(D)->getDecl()), C->isImplicit());
 // Extract device pointer clause information.
 for (const auto *C : Dir.getClausesOfKind())
   for (auto L : C->component_lists())
@@ -8354,6 +8356,7 @@ public:
   MapValuesArrayTy ,
   MapValuesArrayTy ,
   MapFlagsArrayTy ) const {
+bool IsImplicit = true;
 // Do the default mapping.
 if (CI.capturesThis()) {
   CurBasePointers.push_back(CV);
@@ -8379,6 +8382,10 @@ public:
 CurMapTypes.push_back(OMP_MAP_NONE);
 CurSizes.push_back(llvm::Constant::getNullValue(CGF.Int64Ty));
   }
+  const VarDecl *VD = CI.getCapturedVar();
+  auto I = FirstPrivateDecls.find(VD);
+  if (I != FirstPrivateDecls.end())
+IsImplicit = I->getSecond();
 } else {
   assert(CI.capturesVariable() && "Expected captured reference.");
   const auto *PtrTy = cast(RI.getType().getTypePtr());
@@ -8390,7 +8397,8 @@ public:
   // type, the default is 'tofrom'.
   CurMapTypes.push_back(getMapModifiersForPrivateClauses(CI));
   const VarDecl *VD = CI.getCapturedVar();
-  if (FirstPrivateDecls.count(VD) &&
+  auto I = FirstPrivateDecls.find(VD);
+  if (I != FirstPrivateDecls.end() &&
   VD->getType().isConstant(CGF.getContext())) {
 llvm::Constant *Addr =
 CGF.CGM.getOpenMPRuntime().registerTargetFirstprivateCopy(CGF, VD);
@@ -8404,7 +8412,7 @@ public:
 CurPointers.push_back(Addr);
   } else {
 CurBasePointers.push_back(CV);
-if (FirstPrivateDecls.count(VD) && ElementType->isAnyPointerType()) {
+if (I != FirstPrivateDecls.end() && ElementType->isAnyPointerType()) {
   Address PtrAddr = CGF.EmitLoadOfReference(CGF.MakeAddrLValue(
   CV, ElementType, CGF.getContext().getDeclAlign(VD),
   AlignmentSource::Decl));
@@ -8413,12 +8421,15 @@ public:
   CurPointers.push_back(CV);
 }
   }
+  if (I != FirstPrivateDecls.end())
+IsImplicit = I->getSecond();
 }
 // Every default map produces a single argument which is a target 
parameter.
 CurMapTypes.back() |= OMP_MAP_TARGET_PARAM;
 
 // Add flag stating this is an implicit map.
-CurMapTypes.back() |= OMP_MAP_IMPLICIT;
+if (IsImplicit)
+  CurMapTypes.back() |= OMP_MAP_IMPLICIT;
   }
 };
 } // anonymous namespace
@@ -8884,7 +8895,8 @@ void CGOpenMPRuntime::emitTargetCall(Cod
 CGF.getTypeSize(RI->getType()), CGF.Int64Ty, /*isSigned=*/true));
 // Copy to the device as an argument. No need to retrieve it.
 CurMapTypes.push_back(MappableExprsHandler::OMP_MAP_LITERAL |
-  MappableExprsHandler::OMP_MAP_TARGET_PARAM);
+  

r364189 - [OPENMP]Relax the test checks to pacify 32bit buildbots, NFC.

2019-06-24 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Jun 24 08:30:20 2019
New Revision: 364189

URL: http://llvm.org/viewvc/llvm-project?rev=364189=rev
Log:
[OPENMP]Relax the test checks to pacify 32bit buildbots, NFC.

Modified:
cfe/trunk/test/OpenMP/parallel_codegen.cpp

Modified: cfe/trunk/test/OpenMP/parallel_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_codegen.cpp?rev=364189=364188=364189=diff
==
--- cfe/trunk/test/OpenMP/parallel_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_codegen.cpp Mon Jun 24 08:30:20 2019
@@ -94,7 +94,7 @@ int main (int argc, char **argv) {
 
 // CHECK:   define linkonce_odr {{[a-z\_\b]*[ ]?i32}} [[TMAIN]](i8** %argc)
 // CHECK:   store i8** %argc, i8*** [[ARGC_ADDR:%.+]],
-// CHECK:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void 
(i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, i64)* [[OMP_OUTLINED:@.+]] 
to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], i64 %{{.+}})
+// CHECK:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void 
(i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, i{{64|32}})* 
[[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], 
i{{64|32}} %{{.+}})
 // CHECK-NEXT:  ret i32 0
 // CHECK-NEXT:  }
 // CHECK-DEBUG:   define linkonce_odr i32 [[TMAIN]](i8** %argc)
@@ -109,7 +109,7 @@ int main (int argc, char **argv) {
 // CHECK-DEBUG-NEXT:  ret i32 0
 // CHECK-DEBUG-NEXT:  }
 
-// CHECK:   define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias 
%.global_tid., i32* noalias %.bound_tid., i8*** dereferenceable({{4|8}}) %argc, 
i64 %{{.+}})
+// CHECK:   define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias 
%.global_tid., i32* noalias %.bound_tid., i8*** dereferenceable({{4|8}}) %argc, 
i{{64|32}} %{{.+}})
 // CHECK:   store i8*** %argc, i8 [[ARGC_PTR_ADDR:%.+]],
 // CHECK:   [[ARGC_REF:%.+]] = load i8***, i8 [[ARGC_PTR_ADDR]]
 // CHECK:   [[ARGC:%.+]] = load i8**, i8*** [[ARGC_REF]]


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r364080 - [OPENMP]Fix PR42068: Vla type is not captured.

2019-06-24 Thread Alexey Bataev via cfe-commits
Thanks, will fix this ASAP.

Best regards,
Alexey Bataev

> 24 июня 2019 г., в 1:37, Yvan Roux  написал(а):
> 
> Hi Alexey,
> 
> This commit broke ARM bots, logs are availabale here:
> 
> http://lab.llvm.org:8011/builders/clang-cmake-armv8-quick/builds/13627/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Aparallel_codegen.cpp
> 
> Thanks,
> Yvan
> 
> On Fri, 21 Jun 2019 at 19:25, Alexey Bataev via cfe-commits
>  wrote:
>> 
>> Author: abataev
>> Date: Fri Jun 21 10:28:41 2019
>> New Revision: 364080
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=364080=rev
>> Log:
>> [OPENMP]Fix PR42068: Vla type is not captured.
>> 
>> If the variably modified type is declared outside of the captured region
>> and then used in the cast expression along with array subscript
>> expression, the type is not captured and it leads to the compiler crash.
>> 
>> Modified:
>>cfe/trunk/lib/Sema/SemaExpr.cpp
>>cfe/trunk/test/OpenMP/parallel_codegen.cpp
>> 
>> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=364080=364079=364080=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jun 21 10:28:41 2019
>> @@ -4737,6 +4737,33 @@ Sema::CreateBuiltinArraySubscriptExpr(Ex
>>   assert(VK == VK_RValue || LangOpts.CPlusPlus ||
>>  !ResultType.isCForbiddenLValueType());
>> 
>> +  if (LHSExp->IgnoreParenImpCasts()->getType()->isVariablyModifiedType() &&
>> +  FunctionScopes.size() > 1) {
>> +if (auto *TT =
>> +LHSExp->IgnoreParenImpCasts()->getType()->getAs()) 
>> {
>> +  for (auto I = FunctionScopes.rbegin(),
>> +E = std::prev(FunctionScopes.rend());
>> +   I != E; ++I) {
>> +auto *CSI = dyn_cast(*I);
>> +if (CSI == nullptr)
>> +  break;
>> +DeclContext *DC = nullptr;
>> +if (auto *LSI = dyn_cast(CSI))
>> +  DC = LSI->CallOperator;
>> +else if (auto *CRSI = dyn_cast(CSI))
>> +  DC = CRSI->TheCapturedDecl;
>> +else if (auto *BSI = dyn_cast(CSI))
>> +  DC = BSI->TheDecl;
>> +if (DC) {
>> +  if (DC->containsDecl(TT->getDecl()))
>> +break;
>> +  captureVariablyModifiedType(
>> +  Context, LHSExp->IgnoreParenImpCasts()->getType(), CSI);
>> +}
>> +  }
>> +}
>> +  }
>> +
>>   return new (Context)
>>   ArraySubscriptExpr(LHSExp, RHSExp, ResultType, VK, OK, RLoc);
>> }
>> 
>> Modified: cfe/trunk/test/OpenMP/parallel_codegen.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_codegen.cpp?rev=364080=364079=364080=diff
>> ==
>> --- cfe/trunk/test/OpenMP/parallel_codegen.cpp (original)
>> +++ cfe/trunk/test/OpenMP/parallel_codegen.cpp Fri Jun 21 10:28:41 2019
>> @@ -15,16 +15,20 @@
>> // CHECK-DEBUG-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* }
>> // CHECK-DEBUG-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] 
>> c";unknown;unknown;0;0;;\00"
>> // CHECK-DEBUG-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr global 
>> %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds 
>> ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
>> -// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x 
>> i8] c";{{.*}}parallel_codegen.cpp;main;[[@LINE+15]];1;;\00"
>> -// CHECK-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}} x 
>> i8] c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+7]];1;;\00"
>> +// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x 
>> i8] c";{{.*}}parallel_codegen.cpp;main;[[@LINE+19]];1;;\00"
>> +// CHECK-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}} x 
>> i8] c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+8]];1;;\00"
>> 
>> template 
>> void foo(T argc) {}
>> 
>> template 
>> int tmain(T argc) {
>> +  typedef double (*chunk_t)[argc[0][0]];
>> #pragma omp parallel
>> +  {
>>   foo(argc);
>> +  chunk_t var;(void)var[0][0];
>> +  }
>>   return 0;
>> }
>> 
>> @@ -90,7 +94,7 @@ int main (int argc, char **argv) {
>> 
>> // CH

r364080 - [OPENMP]Fix PR42068: Vla type is not captured.

2019-06-21 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Jun 21 10:28:41 2019
New Revision: 364080

URL: http://llvm.org/viewvc/llvm-project?rev=364080=rev
Log:
[OPENMP]Fix PR42068: Vla type is not captured.

If the variably modified type is declared outside of the captured region
and then used in the cast expression along with array subscript
expression, the type is not captured and it leads to the compiler crash.

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/OpenMP/parallel_codegen.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=364080=364079=364080=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jun 21 10:28:41 2019
@@ -4737,6 +4737,33 @@ Sema::CreateBuiltinArraySubscriptExpr(Ex
   assert(VK == VK_RValue || LangOpts.CPlusPlus ||
  !ResultType.isCForbiddenLValueType());
 
+  if (LHSExp->IgnoreParenImpCasts()->getType()->isVariablyModifiedType() &&
+  FunctionScopes.size() > 1) {
+if (auto *TT =
+LHSExp->IgnoreParenImpCasts()->getType()->getAs()) {
+  for (auto I = FunctionScopes.rbegin(),
+E = std::prev(FunctionScopes.rend());
+   I != E; ++I) {
+auto *CSI = dyn_cast(*I);
+if (CSI == nullptr)
+  break;
+DeclContext *DC = nullptr;
+if (auto *LSI = dyn_cast(CSI))
+  DC = LSI->CallOperator;
+else if (auto *CRSI = dyn_cast(CSI))
+  DC = CRSI->TheCapturedDecl;
+else if (auto *BSI = dyn_cast(CSI))
+  DC = BSI->TheDecl;
+if (DC) {
+  if (DC->containsDecl(TT->getDecl()))
+break;
+  captureVariablyModifiedType(
+  Context, LHSExp->IgnoreParenImpCasts()->getType(), CSI);
+}
+  }
+}
+  }
+
   return new (Context)
   ArraySubscriptExpr(LHSExp, RHSExp, ResultType, VK, OK, RLoc);
 }

Modified: cfe/trunk/test/OpenMP/parallel_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_codegen.cpp?rev=364080=364079=364080=diff
==
--- cfe/trunk/test/OpenMP/parallel_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_codegen.cpp Fri Jun 21 10:28:41 2019
@@ -15,16 +15,20 @@
 // CHECK-DEBUG-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* }
 // CHECK-DEBUG-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] 
c";unknown;unknown;0;0;;\00"
 // CHECK-DEBUG-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr global 
%struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x 
i8], [23 x i8]* [[STR]], i32 0, i32 0) }
-// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;main;[[@LINE+15]];1;;\00"
-// CHECK-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+7]];1;;\00"
+// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;main;[[@LINE+19]];1;;\00"
+// CHECK-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+8]];1;;\00"
 
 template 
 void foo(T argc) {}
 
 template 
 int tmain(T argc) {
+  typedef double (*chunk_t)[argc[0][0]];
 #pragma omp parallel
+  {
   foo(argc);
+  chunk_t var;(void)var[0][0];
+  }
   return 0;
 }
 
@@ -90,7 +94,7 @@ int main (int argc, char **argv) {
 
 // CHECK:   define linkonce_odr {{[a-z\_\b]*[ ]?i32}} [[TMAIN]](i8** %argc)
 // CHECK:   store i8** %argc, i8*** [[ARGC_ADDR:%.+]],
-// CHECK-NEXT:  call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 1, void 
(i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***)* [[OMP_OUTLINED:@.+]] to 
void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]])
+// CHECK:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void 
(i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, i64)* [[OMP_OUTLINED:@.+]] 
to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], i64 %{{.+}})
 // CHECK-NEXT:  ret i32 0
 // CHECK-NEXT:  }
 // CHECK-DEBUG:   define linkonce_odr i32 [[TMAIN]](i8** %argc)
@@ -101,23 +105,23 @@ int main (int argc, char **argv) {
 // CHECK-DEBUG-NEXT:  store i8** %argc, i8*** [[ARGC_ADDR:%.+]],
 // CHECK-DEBUG:  [[KMPC_LOC_PSOURCE_REF:%.+]] = getelementptr inbounds 
%struct.ident_t, %struct.ident_t* [[LOC_2_ADDR]], i32 0, i32 4
 // CHECK-DEBUG-NEXT:  store i8* getelementptr inbounds ([{{.+}} x i8], [{{.+}} 
x i8]* [[LOC2]], i32 0, i32 0), i8** [[KMPC_LOC_PSOURCE_REF]]
-// CHECK-DEBUG-NEXT:  call void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[LOC_2_ADDR]], i32 1, void 
(i32*, i32*, ...)* bitcast (void (i32*, i32*, 

r364061 - [OPENMP]Fix PR42159: do not capture threadprivate variables.

2019-06-21 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Jun 21 08:08:30 2019
New Revision: 364061

URL: http://llvm.org/viewvc/llvm-project?rev=364061=rev
Log:
[OPENMP]Fix PR42159: do not capture threadprivate variables.

The threadprivate variables should not be captured in the outlined
regions, otherwise it leads to the compiler crash.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=364061=364060=364061=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Jun 21 08:08:30 2019
@@ -1866,11 +1866,14 @@ VarDecl *Sema::isOpenMPCapturedDecl(Valu
 DSAStack->getTopDSA(D, DSAStack->isClauseParsingMode());
 if (DVarPrivate.CKind != OMPC_unknown && 
isOpenMPPrivate(DVarPrivate.CKind))
   return VD ? VD : cast(DVarPrivate.PrivateCopy->getDecl());
+// Threadprivate variables must not be captured.
+if (isOpenMPThreadPrivate(DVarPrivate.CKind))
+  return nullptr;
+// The variable is not private or it is the variable in the directive with
+// default(none) clause and not used in any clause.
 DVarPrivate = DSAStack->hasDSA(D, isOpenMPPrivate,
[](OpenMPDirectiveKind) { return true; },
DSAStack->isClauseParsingMode());
-// The variable is not private or it is the variable in the directive with
-// default(none) clause and not used in any clause.
 if (DVarPrivate.CKind != OMPC_unknown ||
 (VD && DSAStack->getDefaultDSA() == DSA_none))
   return VD ? VD : cast(DVarPrivate.PrivateCopy->getDecl());

Modified: cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp?rev=364061=364060=364061=diff
==
--- cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp Fri Jun 21 08:08:30 2019
@@ -239,8 +239,8 @@ int main() {
 vec[0] = t_var;
 s_arr[0] = var;
   }
-#pragma omp parallel copyin(t_var)
-  {}
+#pragma omp parallel copyin(t_var) default(none)
+  ++t_var;
   return tmain();
 #endif
 }
@@ -363,6 +363,7 @@ int main() {
 // TLS-CHECK: [[DONE]]
 
 // CHECK: call {{.*}}void @__kmpc_barrier(%{{.+}}* [[IMPLICIT_BARRIER_LOC]], 
i32 [[GTID]])
+// CHECK: add nsw i32 %{{.+}}, 1
 // CHECK: ret void
 
 // TLS-CHECK: [[GTID_ADDR:%.+]] = load i32*, i32** [[GTID_ADDR_ADDR]],


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r363734 - [OPENMP]Use host's mangling for 128 bit float types on the device.

2019-06-18 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jun 18 13:29:06 2019
New Revision: 363734

URL: http://llvm.org/viewvc/llvm-project?rev=363734=rev
Log:
[OPENMP]Use host's mangling for 128 bit float types on the device.

Device have to use the same mangling as the host for 128bit float types. 
Otherwise, the codegen for the device is unable to find the parent function 
when it tries to generate the outlined function for the target region and it 
leads to incorrect compilation and crash at the runtime.

Modified:
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=363734=363733=363734=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Tue Jun 18 13:29:06 2019
@@ -2607,17 +2607,33 @@ void CXXNameMangler::mangleType(const Bu
   case BuiltinType::Double:
 Out << 'd';
 break;
-  case BuiltinType::LongDouble:
-Out << (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble()
-? 'g'
-: 'e');
+  case BuiltinType::LongDouble: {
+bool UseFloat128Mangling =
+getASTContext().getTargetInfo().useFloat128ManglingForLongDouble();
+if (getASTContext().getLangOpts().OpenMP &&
+getASTContext().getLangOpts().OpenMPIsDevice) {
+  UseFloat128Mangling = getASTContext()
+.getAuxTargetInfo()
+->useFloat128ManglingForLongDouble();
+}
+Out << (UseFloat128Mangling ? 'g' : 'e');
 break;
-  case BuiltinType::Float128:
-if (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble())
+  }
+  case BuiltinType::Float128: {
+bool UseFloat128Mangling =
+getASTContext().getTargetInfo().useFloat128ManglingForLongDouble();
+if (getASTContext().getLangOpts().OpenMP &&
+getASTContext().getLangOpts().OpenMPIsDevice) {
+  UseFloat128Mangling = getASTContext()
+.getAuxTargetInfo()
+->useFloat128ManglingForLongDouble();
+}
+if (UseFloat128Mangling)
   Out << "U10__float128"; // Match the GCC mangling
 else
   Out << 'g';
 break;
+  }
   case BuiltinType::NullPtr:
 Out << "Dn";
 break;

Modified: cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp?rev=363734=363733=363734=diff
==
--- cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp Tue Jun 18 
13:29:06 2019
@@ -8,13 +8,15 @@
 // CHECK-DAG: [[T:%.+]] = type {{.+}}, fp128,
 // CHECK-DAG: [[T1:%.+]] = type {{.+}}, i128, i128,
 
-struct T {
-  char a;
 #ifndef _ARCH_PPC
-  __float128 f;
+typedef __float128 BIGTYPE;
 #else
-  long double f;
+typedef long double BIGTYPE;
 #endif
+
+struct T {
+  char a;
+  BIGTYPE f;
   char c;
   T() : a(12), f(15) {}
   T +(T ) { f += b.a; return *this;}
@@ -68,3 +70,12 @@ void baz1() {
   T1 t = bar1();
 }
 #pragma omp end declare target
+
+BIGTYPE foo(BIGTYPE f) {
+#pragma omp target map(f)
+  f = 1;
+  return f;
+}
+
+// CHECK: define weak void 
@__omp_offloading_{{.+}}foo{{.+}}_l75([[BIGTYPE:.+]]*
+// CHECK: store [[BIGTYPE]] 0xL3FFF, [[BIGTYPE]]* %


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r363720 - [OPENMP][NVPTX]Correct codegen for 128 bit long double.

2019-06-18 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jun 18 12:04:27 2019
New Revision: 363720

URL: http://llvm.org/viewvc/llvm-project?rev=363720=rev
Log:
[OPENMP][NVPTX]Correct codegen for 128 bit long double.

If the host uses 128 bit long doubles, the compiler should generate correct 
code for NVPTX devices. If the return type has 128 bit long doubles, in LLVM IR 
this type must be coerced to int array instead.

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=363720=363719=363720=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue Jun 18 12:04:27 2019
@@ -6330,7 +6330,9 @@ private:
 static bool isUnsupportedType(ASTContext , QualType T) {
   if (!Context.getTargetInfo().hasFloat16Type() && T->isFloat16Type())
 return true;
-  if (!Context.getTargetInfo().hasFloat128Type() && T->isFloat128Type())
+  if (!Context.getTargetInfo().hasFloat128Type() &&
+  (T->isFloat128Type() ||
+   (T->isRealFloatingType() && Context.getTypeSize(T) == 128)))
 return true;
   if (!Context.getTargetInfo().hasInt128Type() && T->isIntegerType() &&
   Context.getTypeSize(T) > 64)

Modified: cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp?rev=363720=363719=363720=diff
==
--- cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp Tue Jun 18 
12:04:27 2019
@@ -1,6 +1,8 @@
 // Test target codegen - host bc file has to be created first.
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -aux-triple x86_64-unknown-linux 
-emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | 
FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-aux-triple x86_64-unknown-linux -fopenmp-targets=nvptx64-nvidia-cuda 
-aux-triple x86_64-unknown-linux -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple 
powerpc64le-unknown-linux-gnu -fopenmp-targets=nvptx64-nvidia-cuda 
-emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-aux-triple powerpc64le-unknown-linux-gnu -fopenmp-targets=nvptx64-nvidia-cuda 
-aux-triple x86_64-unknown-linux -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s
 // expected-no-diagnostics
 
 // CHECK-DAG: [[T:%.+]] = type {{.+}}, fp128,
@@ -8,7 +10,11 @@
 
 struct T {
   char a;
+#ifndef _ARCH_PPC
   __float128 f;
+#else
+  long double f;
+#endif
   char c;
   T() : a(12), f(15) {}
   T +(T ) { f += b.a; return *this;}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   5   6   7   8   9   10   >