Page MenuHomePhabricator

[OpenMPIRBuilder] Add support for generating kmpc_for_static_fini
AcceptedPublic

Authored by kiranchandramohan on Dec 10 2019, 6:26 AM.

Details

Reviewers
jdoerfert
Summary

Add support for generating kmpc_for_static_fini in the OpenMP IRBuilder
This is one of the steps required for being able to generate code for omp for/do loops.

Diff Detail

Event Timeline

jdoerfert accepted this revision.Dec 10 2019, 9:18 AM

LGTM, two comments (one below one inlined). For the record: Later we should not expose these low level calls but for now it makes sense to move the code like this.

Please clang format the patch, we should keep the file clang formatted from the very beginning.

llvm/include/llvm/Frontend/OpenMPConstants.h
81

Nit: Can we reformat these comments, please.

This revision is now accepted and ready to land.Dec 10 2019, 9:18 AM

Are you planning to address the minor comments and upstream this?

reverse ping

After rebasing, I see some crashes in the tests. That is why i did not submit. I will have a look again and see what is the issue.

I see the same crash without my change when enabling openmp-irbuilder in for_codegen.cpp tests. Command and stack trace below.

Is it OK to submit the change without enabling these tests now? I can rebase and make another patch for review without any tests.

/home/kircha02/pristine/llvm-project/build/bin/clang -cc1 -internal-isystem /home/kircha02/pristine/llvm-project/build/lib/clang/11.0.0/include -nostdsysteminc -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -emit-llvm /home/kircha02/pristine/llvm-project/clang/test/OpenMP/for_codegen.cpp -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope

Stack dump:
0. Program arguments: /home/kircha02/pristine/llvm-project/build/bin/clang -cc1 -internal-isystem /home/kircha02/pristine/llvm-project/build/lib/clang/11.0.0/include -nostdsysteminc -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -emit-llvm /home/kircha02/pristine/llvm-project/clang/test/OpenMP/for_codegen.cpp -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope

  1. /home/kircha02/pristine/llvm-project/clang/test/OpenMP/for_codegen.cpp:560:1: current parser token 'char'
  2. /home/kircha02/pristine/llvm-project/clang/test/OpenMP/for_codegen.cpp:541:6: LLVM IR generation of declaration 'parallel_for'
  3. /home/kircha02/pristine/llvm-project/clang/test/OpenMP/for_codegen.cpp:541:6: Generating code for declaration 'parallel_for'
 #0 0x0000ffff97cc52e4 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/kircha02/pristine/llvm-project/llvm/lib/Support/Unix/Signals.inc:564:22
 #1 0x0000ffff97cc538c PrintStackTraceSignalHandler(void*) /home/kircha02/pristine/llvm-project/llvm/lib/Support/Unix/Signals.inc:625:1
 #2 0x0000ffff97cc3664 llvm::sys::RunSignalHandlers() /home/kircha02/pristine/llvm-project/llvm/lib/Support/Signals.cpp:68:20
 #3 0x0000ffff97cc4cb8 SignalHandler(int) /home/kircha02/pristine/llvm-project/llvm/lib/Support/Unix/Signals.inc:406:1
 #4 0x0000ffff9e19e66c  0x66c llvm::CodeExtractor::findAllocas(llvm::CodeExtractorAnalysisCache const&, llvm::SetVector<llvm::Value*, std::vector<llvm::Value*, std::allocator<llvm::Value*> >, llvm::DenseSet<llvm::Value*, llvm::DenseMapInfo<llvm::Value*> > >&, llvm::SetVector<llvm::Value*, std::vector<llvm::Value*, std::allocator<llvm::Value*> >, llvm::DenseSet<llvm::Value*, llvm::DenseMapInfo<llvm::Value*> > >&, llvm::BasicBlock*&) const
 #5 0x0000ffff9e19e66c /home/kircha02/pristine/llvm-project/llvm/lib/Transforms/Utils/CodeExtractor.cpp:492:48
 #6 0x0000ffff9e19e66c llvm::OpenMPIRBuilder::CreateParallel(llvm::OpenMPIRBuilder::LocationDescription const&, llvm::function_ref<void (llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint, llvm::BasicBlock&)>, llvm::function_ref<llvm::IRBuilderBase::InsertPoint (llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint, llvm::Value&, llvm::Value*&)>, std::function<void (llvm::IRBuilderBase::InsertPoint)>, llvm::Value*, llvm::Value*, llvm::omp::ProcBindKind, bool) /home/kircha02/pristine/llvm-project/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:623:30
 #7 0x0000ffff97454798 clang::CodeGen::CodeGenFunction::EmitOMPParallelDirective(clang::OMPParallelDirective const&) /home/kircha02/pristine/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp:1485:22
 #8 0x0000ffff929045d4 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) /home/kircha02/pristine/llvm-project/clang/lib/CodeGen/CGStmt.cpp:195:5
 #9 0x0000ffff95e83624 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) /home/kircha02/pristine/llvm-project/clang/lib/CodeGen/CGStmt.cpp:416:3
#10 0x0000ffff95e631a0 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) /home/kircha02/pristine/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1168:1
#11 0x0000ffff95e63bd0 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) /home/kircha02/pristine/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1330:21
#12 0x0000ffff95ee497c clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) /home/kircha02/pristine/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:4487:3
#13 0x0000ffff95ee5348 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) /home/kircha02/pristine/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:2861:47
#14 0x0000ffff95f05348 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) /home/kircha02/pristine/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:2614:5
#15 0x0000ffff95eff9c8 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.localalias) /home/kircha02/pristine/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:5295:37
#16 0x0000ffff95efeba4 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) /home/kircha02/pristine/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp:169:7
#17 0x0000ffff95f083bc clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) /home/kircha02/pristine/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:216:7
#18 0x0000ffff96090b28 clang::ParseAST(clang::Sema&, bool, bool) /home/kircha02/pristine/llvm-project/clang/lib/Parse/ParseAST.cpp:162:49
#19 0x0000ffff95ed4428 clang::ASTFrontendAction::ExecuteAction() /home/kircha02/pristine/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1047:11
#20 0x0000ffff900a7e24 clang::CodeGenAction::ExecuteAction() /home/kircha02/pristine/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1180:1
#21 0x0000ffff950f10ec clang::FrontendAction::Execute() /home/kircha02/pristine/llvm-project/clang/lib/Frontend/FrontendAction.cpp:944:38
#22 0x0000ffff95ed1148 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/kircha02/pristine/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:973:42
#23 0x0000ffff950f0b30 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/kircha02/pristine/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:282:38
#24 0x0000ffff9507da34 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/kircha02/pristine/llvm-project/clang/tools/driver/cc1_main.cpp:240:40
#25 0x0000ffff94d03088 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) /home/kircha02/pristine/llvm-project/clang/tools/driver/driver.cpp:330:20
#26 0x0000000000450714 main /home/kircha02/pristine/llvm-project/clang/tools/driver/driver.cpp:407:26
#27 0x0000000000445da8 __libc_start_main /build/glibc-BeHOFw/glibc-2.23/csu/libc-start.c:325:0