This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Add Passing in Original Declaration Names To Mapper API
ClosedPublic

Authored by jhuber6 on Oct 20 2020, 8:50 AM.

Details

Summary

This patch adds support for passing in the original delcaration name in the source file to the libomptarget runtime. This will allow the runtime to provide more intelligent debugging messages. This patch takes the original expression parsed from the OpenMP map / update clause and provides a textual representation if it was explicitly mapped, otherwise it takes the name of the variable declaration as a fallback. The information in passed to the runtime in a global array of strings that matches the existing ident_t source location strings using ";name;filename;column;row;;"

Diff Detail

Event Timeline

jhuber6 created this revision.Oct 20 2020, 8:50 AM
jhuber6 requested review of this revision.Oct 20 2020, 8:50 AM

Initial version. This fails a few tests and needs additional test cases for the additional functionality as well as support inside the runtime library.

jhuber6 updated this revision to Diff 299452.Oct 20 2020, 1:19 PM

Fixed failing tests and added a new Clang test.

jhuber6 updated this revision to Diff 300083.Oct 22 2020, 12:53 PM

Updating test

Looks generally good. We seem to have way to many places dealing with the mapping stuff but that is not your fault. One thing I found weird though:

clang/lib/CodeGen/CGOpenMPRuntime.cpp
8083

Why iterations and not the range loop? also below

8367

same as above

jhuber6 updated this revision to Diff 300828.Oct 26 2020, 4:31 PM

Changing to use the range iterators. There was a reason I did it like that initially but forgot to change it back.

jdoerfert accepted this revision.Oct 27 2020, 10:42 AM

Nit: Add '.' add the end of comments and make them sentences.

LGTM.

This revision is now accepted and ready to land.Oct 27 2020, 10:42 AM
This revision was landed with ongoing or failed builds.Oct 27 2020, 1:11 PM
This revision was automatically updated to reflect the committed changes.

This patch caused segment fault in D90099 where the map variable info pointer is nullptr but it is deferenced.

This patch caused segment fault in D90099 where the map variable info pointer is nullptr but it is deferenced.

Was it this one, or was it D90172. This patch only changes the code generation in Clang so I don't think it references the generated mapping pointers. It's possible I forget to check the status of the pointer somewhere in the RTL.

This patch caused segment fault in D90099 where the map variable info pointer is nullptr but it is deferenced.

Was it this one, or was it D90172. This patch only changes the code generation in Clang so I don't think it references the generated mapping pointers. It's possible I forget to check the status of the pointer somewhere in the RTL.

The dereference is in the Clang. I happened to have a full log:

$ clang -cc1 -DCK1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm $HOME/Documents/vscode/llvm-project/clang/test/OpenMP/target_exit_data_codegen.cpp -o target_exit_data_codegen.ll
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: clang -cc1 -DCK1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm /home/shiltian/Documents/vscode/llvm-project/clang/test/OpenMP/target_exit_data_codegen.cpp -o target_exit_data_codegen.ll
1.      <eof> parser at end of file
2.      Per-file LLVM IR generation
3.      /home/shiltian/Documents/vscode/llvm-project/clang/test/OpenMP/target_exit_data_codegen.cpp:48:6: Generating code for declaration 'foo'
 #0 0x000055b62a4406ec llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x1f3d6ec)
 #1 0x000055b62a43e3c4 llvm::sys::RunSignalHandlers() (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x1f3b3c4)
 #2 0x000055b62a43e533 SignalHandler(int) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x1f3b533)
 #3 0x00007f0bb92d98a0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
 #4 0x000055b629ce8dbc llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, llvm::Twine const&) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x17e5dbc)
 #5 0x000055b629cc48c2 llvm::IRBuilderBase::CreateCall(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, llvm::Twine const&, llvm::MDNode*) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x17c18c2)
 #6 0x000055b62a95d7e1 clang::CodeGen::CodeGenFunction::EmitRuntimeCall(llvm::FunctionCallee, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x245a7e1)
 #7 0x000055b62aa7756b void clang::CodeGen::RegionCodeGenTy::CallbackFn<clang::CodeGen::CGOpenMPRuntime::emitTargetDataStandAloneCall(clang::CodeGen::CodeGenFunction&, clang::OMPExecutableDirective const&, clang::Expr const*, clang::Expr const*)::'lambda'(clang::CodeGen::CodeGenFunction&, clang::CodeGen::PrePostActionTy&)>(long, clang::CodeGen::CodeGenFunction&, clang::CodeGen::PrePostActionTy&) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x257456b)
 #8 0x000055b62aa735b0 clang::CodeGen::RegionCodeGenTy::operator()(clang::CodeGen::CodeGenFunction&) const (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x25705b0)
 #9 0x000055b62a74bd59 clang::CodeGen::CodeGenFunction::EmitOMPTargetTaskBasedDirective(clang::OMPExecutableDirective const&, clang::CodeGen::RegionCodeGenTy const&, clang::CodeGen::CodeGenFunction::OMPTargetDataInfo&)::'lambda3'(clang::CodeGen::CodeGenFunction&, clang::CodeGen::PrePostActionTy&)::operator()(clang::CodeGen::CodeGenFunction&, clang::CodeGen::PrePostActionTy&) const (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x2248d59)
#10 0x000055b62aa7361f clang::CodeGen::RegionCodeGenTy::operator()(clang::CodeGen::CodeGenFunction&) const (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x257061f)
#11 0x000055b62aa738af (anonymous namespace)::CGOpenMPRegionInfo::EmitBody(clang::CodeGen::CodeGenFunction&, clang::Stmt const*) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x25708af)
#12 0x000055b62a72f42e clang::CodeGen::CodeGenFunction::GenerateCapturedStmtFunction(clang::CapturedStmt const&) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x222c42e)
#13 0x000055b62aab4708 clang::CodeGen::CGOpenMPRuntime::emitTaskOutlinedFunction(clang::OMPExecutableDirective const&, clang::VarDecl const*, clang::VarDecl const*, clang::VarDecl const*, llvm::omp::Directive, clang::CodeGen::RegionCodeGenTy const&, bool, unsigned int&) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x25b1708)
#14 0x000055b62a74d469 clang::CodeGen::CodeGenFunction::EmitOMPTargetTaskBasedDirective(clang::OMPExecutableDirective const&, clang::CodeGen::RegionCodeGenTy const&, clang::CodeGen::CodeGenFunction::OMPTargetDataInfo&) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x224a469)
#15 0x000055b62aac0c70 clang::CodeGen::CGOpenMPRuntime::emitTargetDataStandAloneCall(clang::CodeGen::CodeGenFunction&, clang::OMPExecutableDirective const&, clang::Expr const*, clang::Expr const*)::'lambda0'(clang::CodeGen::CodeGenFunction&, clang::CodeGen::PrePostActionTy&)::operator()(clang::CodeGen::CodeGenFunction&, clang::CodeGen::PrePostActionTy&) const (.isra.2413) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x25bdc70)
#16 0x000055b62aa735b0 clang::CodeGen::RegionCodeGenTy::operator()(clang::CodeGen::CodeGenFunction&) const (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x25705b0)
#17 0x000055b62aa745c8 clang::CodeGen::CGOpenMPRuntime::emitIfClause(clang::CodeGen::CodeGenFunction&, clang::Expr const*, clang::CodeGen::RegionCodeGenTy const&, clang::CodeGen::RegionCodeGenTy const&) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x25715c8)
#18 0x000055b62aa74b1d clang::CodeGen::CGOpenMPRuntime::emitTargetDataStandAloneCall(clang::CodeGen::CodeGenFunction&, clang::OMPExecutableDirective const&, clang::Expr const*, clang::Expr const*) (.part.1404) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x2571b1d)
#19 0x000055b62a74c7db clang::CodeGen::CodeGenFunction::EmitOMPTargetExitDataDirective(clang::OMPTargetExitDataDirective const&) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x22497db)
#20 0x000055b62a7301cd clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x222d1cd)
#21 0x000055b62a73048c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x222d48c)
#22 0x000055b62a77bccb clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x2278ccb)
#23 0x000055b62a78bffd clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x2288ffd)
#24 0x000055b62a7d5723 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x22d2723)
#25 0x000055b62a7d30c5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x22d00c5)
#26 0x000055b62a7da877 clang::CodeGen::CodeGenModule::EmitDeferred() (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x22d7877)
#27 0x000055b62a7dad6c clang::CodeGen::CodeGenModule::Release() (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x22d7d6c)
#28 0x000055b62b2c3737 (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x2dc0737)
#29 0x000055b62b2c1f35 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x2dbef35)
#30 0x000055b62bf051e9 clang::ParseAST(clang::Sema&, bool, bool) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x3a021e9)
#31 0x000055b62b2c0e90 clang::CodeGenAction::ExecuteAction() (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x2dbde90)
#32 0x000055b62ac95729 clang::FrontendAction::Execute() (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x2792729)
#33 0x000055b62ac4f75a clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x274c75a)
#34 0x000055b62ad5fc26 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0x285cc26)
#35 0x000055b629189d7c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0xc86d7c)
#36 0x000055b629184879 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0xc81879)
#37 0x000055b6290ff094 main (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0xbfc094)
#38 0x00007f0bb7f6db97 __libc_start_main /build/glibc-2ORdQG/glibc-2.27/csu/../csu/libc-start.c:344:0
#39 0x000055b6291843da _start (/home/shiltian/Documents/deploy/llvm/release/bin/clang-12+0xc813da)
[1]    25935 segmentation fault (core dumped)  clang -cc1 -DCK1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu
jhuber6 updated this revision to Diff 305207.Nov 13 2020, 10:18 AM

Rebasing on master after D91370 fixed the tests. I could not reproduce your crash @ye-lou . This passed all the Clang checks and I didn't change anything in the code, could you check if this still doesn't work for you?

jhuber6 updated this revision to Diff 306112.Nov 18 2020, 8:03 AM
jhuber6 edited reviewers, added: tianshilei1992; removed: ye-luo.

Rebasing. Sorry I got it confused, @tianshilei1992 you said you had a crash using this patch, I haven't encountered any errors on my machine. Could you verify that this doesn't cause any issues for you?

Rebasing. Sorry I got it confused, @tianshilei1992 you said you had a crash using this patch, I haven't encountered any errors on my machine. Could you verify that this doesn't cause any issues for you?

If all Clang cases can pass, I think it should work. My patch has already been merged.

jhuber6 updated this revision to Diff 306138.Nov 18 2020, 9:23 AM

Fixing test that got changed.

This revision was landed with ongoing or failed builds.Nov 18 2020, 12:28 PM