r208077 - [OPENMP] Initial codegen for '#pragma omp parallel'

Alexey Bataev a.bataev at hotmail.com
Wed May 14 03:48:26 PDT 2014


Hi Jay,
Fixed in revision 208768

Best regards,
Alexey Bataev
=============
Software Engineer
Intel Compiler Team
Intel Corp.

14 Май 2014 г. 14:00:08, Jay Foad писал:
> On 6 May 2014 11:08, Alexey Bataev <a.bataev at hotmail.com> wrote:
>> Author: abataev
>> Date: Tue May  6 05:08:46 2014
>> New Revision: 208077
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=208077&view=rev
>> Log:
>> [OPENMP] Initial codegen for '#pragma omp parallel'
>>
>> Added:
>>      cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp   (with props)
>>      cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h   (with props)
>>      cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp   (with props)
>>      cfe/trunk/test/OpenMP/parallel_codegen.cpp   (with props)
>> Modified:
>>      cfe/trunk/include/clang/AST/Decl.h
>>      cfe/trunk/include/clang/Sema/Sema.h
>>      cfe/trunk/lib/CodeGen/CGException.cpp
>>      cfe/trunk/lib/CodeGen/CGStmt.cpp
>>      cfe/trunk/lib/CodeGen/CMakeLists.txt
>>      cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>>      cfe/trunk/lib/CodeGen/CodeGenFunction.h
>>      cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>>      cfe/trunk/lib/CodeGen/CodeGenModule.h
>>      cfe/trunk/lib/Parse/ParseOpenMP.cpp
>>      cfe/trunk/lib/Sema/SemaOpenMP.cpp
>>      cfe/trunk/lib/Sema/SemaStmt.cpp
>>      cfe/trunk/lib/Sema/TreeTransform.h
>>      cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>>      cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
>
>> Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=208077&r1=208076&r2=208077&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaStmt.cpp Tue May  6 05:08:46 2014
>> @@ -3322,20 +3322,9 @@ Sema::CreateCapturedStmtRecordDecl(Captu
>>     RD->setImplicit();
>>     RD->startDefinition();
>>
>> +  assert(NumParams > 0 && "CapturedStmt requires context parameter");
>>     CD = CapturedDecl::Create(Context, CurContext, NumParams);
>>     DC->addDecl(CD);
>> -
>> -  // Build the context parameter
>> -  assert(NumParams > 0 && "CapturedStmt requires context parameter");
>> -  DC = CapturedDecl::castToDeclContext(CD);
>> -  IdentifierInfo *VarName = &Context.Idents.get("__context");
>> -  QualType ParamType = Context.getPointerType(Context.getTagDeclType(RD));
>> -  ImplicitParamDecl *Param
>> -    = ImplicitParamDecl::Create(Context, DC, Loc, VarName, ParamType);
>> -  DC->addDecl(Param);
>> -
>> -  CD->setContextParam(Param);
>> -
>>     return RD;
>>   }
>>
>> @@ -3367,9 +3356,62 @@ static void buildCapturedStmtCaptureList
>>   void Sema::ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
>>                                       CapturedRegionKind Kind,
>>                                       unsigned NumParams) {
>> -  CapturedDecl *CD = 0;
>> +  CapturedDecl *CD = nullptr;
>>     RecordDecl *RD = CreateCapturedStmtRecordDecl(CD, Loc, NumParams);
>>
>> +  // Build the context parameter
>> +  DeclContext *DC = CapturedDecl::castToDeclContext(CD);
>> +  IdentifierInfo *ParamName = &Context.Idents.get("__context");
>> +  QualType ParamType = Context.getPointerType(Context.getTagDeclType(RD));
>> +  ImplicitParamDecl *Param
>> +    = ImplicitParamDecl::Create(Context, DC, Loc, ParamName, ParamType);
>> +  DC->addDecl(Param);
>> +
>> +  CD->setContextParam(0, Param);
>> +
>> +  // Enter the capturing scope for this captured region.
>> +  PushCapturedRegionScope(CurScope, CD, RD, Kind);
>> +
>> +  if (CurScope)
>> +    PushDeclContext(CurScope, CD);
>> +  else
>> +    CurContext = CD;
>> +
>> +  PushExpressionEvaluationContext(PotentiallyEvaluated);
>> +}
>> +
>> +void Sema::ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope,
>> +                                    CapturedRegionKind Kind,
>> +                                    ArrayRef<CapturedParamNameType> Params) {
>> +  CapturedDecl *CD = nullptr;
>> +  RecordDecl *RD = CreateCapturedStmtRecordDecl(CD, Loc, Params.size());
>> +
>> +  // Build the context parameter
>> +  DeclContext *DC = CapturedDecl::castToDeclContext(CD);
>> +  bool ContextIsFound = false;
>> +  unsigned ParamNum = 0;
>> +  for (ArrayRef<CapturedParamNameType>::iterator I = Params.begin(),
>> +                                                 E = Params.end();
>> +       I != E; ++I, ++ParamNum) {
>> +    if (I->second.isNull()) {
>> +      assert(!ContextIsFound &&
>> +             "null type has been found already for '__context' parameter");
>> +      IdentifierInfo *ParamName = &Context.Idents.get("__context");
>> +      QualType ParamType = Context.getPointerType(Context.getTagDeclType(RD));
>> +      ImplicitParamDecl *Param
>> +        = ImplicitParamDecl::Create(Context, DC, Loc, ParamName, ParamType);
>> +      DC->addDecl(Param);
>> +      CD->setContextParam(ParamNum, Param);
>> +      ContextIsFound = true;
>> +    } else {
>> +      IdentifierInfo *ParamName = &Context.Idents.get(I->first);
>> +      ImplicitParamDecl *Param
>> +        = ImplicitParamDecl::Create(Context, DC, Loc, ParamName, I->second);
>> +      DC->addDecl(Param);
>> +      CD->setParam(ParamNum, Param);
>> +    }
>> +  }
>> +  assert(ContextIsFound && "no null type for '__context' parameter");
>
> In a Release build, built with GCC, I get:
>
> /home/jay/svn/llvm-project/llvm/trunk/tools/clang/lib/Sema/SemaStmt.cpp:3391:8:
> warning: variable ‘ContextIsFound’ set but not used
> [-Wunused-but-set-variable]
>     bool ContextIsFound = false;
>          ^
>
> Jay.




More information about the cfe-commits mailing list