-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[OMPIRBuilder] Don't generate DISubprogram for outlined function. #138149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4982,6 +4982,20 @@ static LogicalResult | |
convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder, | ||
LLVM::ModuleTranslation &moduleTranslation) { | ||
auto targetOp = cast<omp::TargetOp>(opInst); | ||
// The current debug location already has the DISubprogram for the outlined | ||
// function that will be created for the target op. We save it here so that | ||
// we can set it on the outlined function. | ||
llvm::DebugLoc OutlinedFnLoc = builder.getCurrentDebugLocation(); | ||
// During the handling of target op, we will generate instructions in the | ||
// parent function like call to oulined function or branch to new BasicBlock. | ||
// We set the debug location here to parent function so that those get the | ||
// correct debug locations. For outlined functions, the normal MLIR op | ||
// conversion will automatically pick the correct location. | ||
llvm::BasicBlock *parentBB = builder.GetInsertBlock(); | ||
if (parentBB && !parentBB->empty()) | ||
builder.SetCurrentDebugLocation(parentBB->back().getDebugLoc()); | ||
else | ||
builder.SetCurrentDebugLocation(llvm::DebugLoc()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand it correctly, this will use the debug information from the last instruction introduced in this block (i.e. the last thing added while translating the previous MLIR op). But then it will not do so if Looking at the comment above, would it make sense to perhaps get the debug information from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My idea was that for empty basic block, an empty location will be set. But it occurred to me that it will cause Verifier failure in certain cases. I have now changed the way debug location is set and added a testcase to cover it. |
||
if (failed(checkImplementationStatus(opInst))) | ||
abidh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return failure(); | ||
|
||
|
@@ -5078,6 +5092,9 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder, | |
assert(llvmParentFn && llvmOutlinedFn && | ||
"Both parent and outlined functions must exist at this point"); | ||
|
||
if (OutlinedFnLoc && llvmParentFn->getSubprogram()) | ||
llvmOutlinedFn->setSubprogram(OutlinedFnLoc->getScope()->getSubprogram()); | ||
|
||
if (auto attr = llvmParentFn->getFnAttribute("target-cpu"); | ||
attr.isStringAttribute()) | ||
llvmOutlinedFn->addFnAttr(attr); | ||
|
Uh oh!
There was an error while loading. Please reload this page.