This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Use irbuilder as default for masked and master construct
ClosedPublic

Authored by cchen on Apr 20 2021, 10:58 AM.

Details

Summary

Use irbuilder as default and remove redundant Clang codegen for masked construct and master construct.

Diff Detail

Event Timeline

cchen created this revision.Apr 20 2021, 10:58 AM
cchen requested review of this revision.Apr 20 2021, 10:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2021, 10:58 AM
jdoerfert accepted this revision.Apr 20 2021, 11:33 AM

LGTM, thanks

This revision is now accepted and ready to land.Apr 20 2021, 11:33 AM

Patch description is empty.

cchen planned changes to this revision.Apr 20 2021, 1:22 PM
This comment was removed by cchen.
cchen added a comment.Apr 20 2021, 1:37 PM

I mark this patch as "plan changed" since the assert message indicates that something wrong in IRBuilder or Codegen, however, main branch also have the same issue so I think this patch does not trigger the issue.

cchen edited the summary of this revision. (Show Details)Apr 20 2021, 1:38 PM

I mark this patch as "plan changed" since the assert message indicates that something wrong in IRBuilder or Codegen, however, main branch also have the same issue so I think this patch does not trigger the issue.

what assertion?

cchen added a comment.Apr 21 2021, 9:42 AM

what assertion?

$ ":" "RUN: at line 1"
$ "/mnt/disks/ssd0/agent/llvm-project/build/./bin/clang" "-fopenmp" "-pthread" "-fno-experimental-isel" "-I" "/mnt/disks/ssd0/agent/llvm-project/openmp/runtime/test" "-I" "/mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/runtime/src" "-L" "/mnt/disks/ssd0/agent/llvm-project/build/lib" "-I" "/mnt/disks/ssd0/agent/llvm-project/openmp/runtime/test/ompt" "/mnt/disks/ssd0/agent/llvm-project/openmp/runtime/test/tasking/kmp_detach_tasks_t1.c" "-o" "/mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/runtime/test/tasking/Output/kmp_detach_tasks_t1.c.tmp" "-lm" "-latomic"
# command stderr:
clang-13: /mnt/disks/ssd0/agent/llvm-project/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:135: llvm::Function *llvm::OpenMPIRBuilder::getOrCreateRuntimeFunctionPtr(llvm::omp::RuntimeFunction): Assertion `Fn && "Failed to create OpenMP runtime function pointer"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /mnt/disks/ssd0/agent/llvm-project/build/bin/clang-13 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -main-file-name kmp_detach_tasks_t1.c -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/runtime/test/tasking -resource-dir /mnt/disks/ssd0/agent/llvm-project/build/lib/clang/13.0.0 -I /mnt/disks/ssd0/agent/llvm-project/openmp/runtime/test -I /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/runtime/src -I /mnt/disks/ssd0/agent/llvm-project/openmp/runtime/test/ompt -internal-isystem /mnt/disks/ssd0/agent/llvm-project/build/lib/clang/13.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/runtime/test/tasking -ferror-limit 19 -fopenmp -fopenmp-cuda-parallel-target-regions -pthread -fgnuc-version=4.2.1 -mllvm -global-isel=0 -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/kmp_detach_tasks_t1-bbb4b6.o -x c /mnt/disks/ssd0/agent/llvm-project/openmp/runtime/test/tasking/kmp_detach_tasks_t1.c
1.	<eof> parser at end of file
2.	Per-file LLVM IR generation
3.	/mnt/disks/ssd0/agent/llvm-project/openmp/runtime/test/tasking/kmp_detach_tasks_t1.c:76:5: Generating code for declaration 'main'
4.	/mnt/disks/ssd0/agent/llvm-project/openmp/runtime/test/tasking/kmp_detach_tasks_t1.c:84:3: LLVM IR generation of compound statement ('{}')
 #0 0x0000000005899d83 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /mnt/disks/ssd0/agent/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:13
 #1 0x0000000005897ace llvm::sys::RunSignalHandlers() /mnt/disks/ssd0/agent/llvm-project/llvm/lib/Support/Signals.cpp:77:18
 #2 0x000000000589a24f SignalHandler(int) /mnt/disks/ssd0/agent/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #3 0x00007fe786916140 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14140)
 #4 0x00007fe7863eedb1 raise (/lib/x86_64-linux-gnu/libc.so.6+0x3bdb1)
 #5 0x00007fe7863d8537 abort (/lib/x86_64-linux-gnu/libc.so.6+0x25537)
 #6 0x00007fe7863d840f (/lib/x86_64-linux-gnu/libc.so.6+0x2540f)
 #7 0x00007fe7863e75b2 (/lib/x86_64-linux-gnu/libc.so.6+0x345b2)
 #8 0x00000000080dcc3e doit /mnt/disks/ssd0/agent/llvm-project/llvm/include/llvm/Support/Casting.h:104:5
 #9 0x00000000080dcc3e doit /mnt/disks/ssd0/agent/llvm-project/llvm/include/llvm/Support/Casting.h:131:12
#10 0x00000000080dcc3e doit /mnt/disks/ssd0/agent/llvm-project/llvm/include/llvm/Support/Casting.h:121:12
#11 0x00000000080dcc3e isa<llvm::FunctionType, llvm::Type *> /mnt/disks/ssd0/agent/llvm-project/llvm/include/llvm/Support/Casting.h:142:10
#12 0x00000000080dcc3e cast<llvm::FunctionType, llvm::Type> /mnt/disks/ssd0/agent/llvm-project/llvm/include/llvm/Support/Casting.h:269:3
#13 0x00000000080dcc3e getFunctionType /mnt/disks/ssd0/agent/llvm-project/llvm/include/llvm/IR/Function.h:166:12
#14 0x00000000080dcc3e FunctionCallee<llvm::Function, llvm::FunctionType *(llvm::Function::*)() const> /mnt/disks/ssd0/agent/llvm-project/llvm/include/llvm/IR/DerivedTypes.h:170:23
#15 0x00000000080dcc3e llvm::OpenMPIRBuilder::getOrCreateThreadID(llvm::Value*) /mnt/disks/ssd0/agent/llvm-project/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:330:7
#16 0x00000000080e0002 llvm::OpenMPIRBuilder::createMaster(llvm::OpenMPIRBuilder::LocationDescription const&, llvm::function_ref<void (llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint, llvm::BasicBlock&)>, std::function<void (llvm::IRBuilderBase::InsertPoint)>) /mnt/disks/ssd0/agent/llvm-project/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:892:19
#17 0x0000000005d64ab8 isSet /mnt/disks/ssd0/agent/llvm-project/llvm/include/llvm/IR/IRBuilder.h:264:40
#18 0x0000000005d64ab8 restoreIP /mnt/disks/ssd0/agent/llvm-project/llvm/include/llvm/IR/IRBuilder.h:284:12
#19 0x0000000005d64ab8 clang::CodeGen::CodeGenFunction::EmitOMPMasterDirective(clang::OMPMasterDirective const&) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp:3888:11
#20 0x0000000005d2167a clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CGStmt.cpp:0:5
#21 0x0000000005d2cc30 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CGStmt.cpp:458:22
#22 0x0000000005d2bccf clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CGStmt.cpp:444:10
#23 0x0000000005d21b0a clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CGStmt.cpp:0:5
#24 0x0000000005d212fb clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CGStmt.cpp:57:7
#25 0x0000000005d78fa2 operator() /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp:1765:37
#26 0x0000000005d78fa2 void clang::CodeGen::RegionCodeGenTy::CallbackFn<clang::CodeGen::CodeGenFunction::EmitOMPParallelDirective(clang::OMPParallelDirective const&)::$_21>(long, clang::CodeGen::CodeGenFunction&, clang::CodeGen::PrePostActionTy&) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.h:80:12
#27 0x0000000005cb8546 ForceCleanup /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CodeGenFunction.h:868:28
#28 0x0000000005cb8546 ~RunCleanupsScope /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CodeGenFunction.h:852:9
#29 0x0000000005cb8546 operator() /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.cpp:602:1
#30 0x0000000005cb8546 (anonymous namespace)::CGOpenMPRegionInfo::EmitBody(clang::CodeGen::CodeGenFunction&, clang::Stmt const*) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.cpp:1052:3
#31 0x0000000005d4e972 clang::CodeGen::CodeGenFunction::GenerateOpenMPCapturedStmtFunction(clang::CapturedStmt const&, clang::SourceLocation) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp:0:21
#32 0x0000000005c81651 emitParallelOrTeamsOutlinedFunction(clang::CodeGen::CodeGenModule&, clang::OMPExecutableDirective const&, clang::CapturedStmt const*, clang::VarDecl const*, llvm::omp::Directive, llvm::StringRef, clang::CodeGen::RegionCodeGenTy const&) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.cpp:1283:14
#33 0x0000000005c8145f clang::CodeGen::CGOpenMPRuntime::emitParallelOutlinedFunction(clang::OMPExecutableDirective const&, clang::VarDecl const*, llvm::omp::Directive, clang::CodeGen::RegionCodeGenTy const&) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.cpp:1290:10
#34 0x0000000005d58857 emitCommonOMPParallelDirective(clang::CodeGen::CodeGenFunction&, clang::OMPExecutableDirective const&, llvm::omp::Directive, clang::CodeGen::RegionCodeGenTy const&, llvm::function_ref<void (clang::CodeGen::CodeGenFunction&, clang::OMPExecutableDirective const&, llvm::SmallVectorImpl<llvm::Value*>&)> const&) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp:0:34
#35 0x0000000005d58114 clang::CodeGen::CodeGenFunction::EmitOMPParallelDirective(clang::OMPParallelDirective const&) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp:1772:5
#36 0x0000000005d2194c clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CGStmt.cpp:0:5
#37 0x0000000005d2cc30 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CGStmt.cpp:458:22
#38 0x0000000005c399ec clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1199:7
#39 0x0000000005c3a5a2 getLangOpts /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CodeGenFunction.h:1925:51
#40 0x0000000005c3a5a2 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1371:7
#41 0x0000000005bcb73e clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:4780:3
#42 0x0000000005bc383c clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:0:12
#43 0x0000000005bb5fac __normal_iterator /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_iterator.h:954:20
#44 0x0000000005bb5fac begin /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_vector.h:821:16
#45 0x0000000005bb5fac empty /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_vector.h:1008:16
#46 0x0000000005bb5fac clang::CodeGen::CodeGenModule::EmitDeferred() /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:2400:26
#47 0x0000000005bb4999 clang::CodeGen::CodeGenModule::Release() /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:478:3
#48 0x00000000062904a4 (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp:271:11
#49 0x000000000628dc86 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /mnt/disks/ssd0/agent/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:291:13
#50 0x0000000007261be3 __normal_iterator /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_iterator.h:954:20
#51 0x0000000007261be3 begin /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_vector.h:812:16
#52 0x0000000007261be3 finalize<std::vector<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> >, std::allocator<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> > > > > /mnt/disks/ssd0/agent/llvm-project/clang/include/clang/Sema/TemplateInstCallback.h:54:16
#53 0x0000000007261be3 clang::ParseAST(clang::Sema&, bool, bool) /mnt/disks/ssd0/agent/llvm-project/clang/lib/Parse/ParseAST.cpp:178:3
#54 0x00000000061d6043 clang::FrontendAction::Execute() /mnt/disks/ssd0/agent/llvm-project/clang/lib/Frontend/FrontendAction.cpp:953:10
#55 0x00000000061076f3 getPtr /mnt/disks/ssd0/agent/llvm-project/llvm/include/llvm/Support/Error.h:274:42
#56 0x00000000061076f3 operator bool /mnt/disks/ssd0/agent/llvm-project/llvm/include/llvm/Support/Error.h:236:16
#57 0x00000000061076f3 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /mnt/disks/ssd0/agent/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:960:23
#58 0x0000000006287f72 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /mnt/disks/ssd0/agent/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278:25
#59 0x000000000372fd62 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /mnt/disks/ssd0/agent/llvm-project/clang/tools/driver/cc1_main.cpp:246:15
#60 0x000000000372dc02 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) /mnt/disks/ssd0/agent/llvm-project/clang/tools/driver/driver.cpp:338:12
#61 0x000000000372d8a4 main /mnt/disks/ssd0/agent/llvm-project/clang/tools/driver/driver.cpp:415:12
#62 0x00007fe7863d9cca __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26cca)
#63 0x000000000372a80a _start (/mnt/disks/ssd0/agent/llvm-project/build/bin/clang-13+0x372a80a)

I tested without this patch an hour ago and still got this assertion error.

This revision is now accepted and ready to land.Apr 26 2021, 2:10 PM
This revision was landed with ongoing or failed builds.Sep 17 2021, 2:01 PM
This revision was automatically updated to reflect the committed changes.