Skip to content

Commit b90ea9b

Browse files
committed
[SYCL] Attach SourceLocation to kernel body to enable coverage gen
to process the kernel (in NativeCPU). This also requires setting the debug location temporarily to the kernel arg location so that the expected file is picked up by the SourceLocToDebugLoc function used by SYCLOptReportHandler.
1 parent 55d31e7 commit b90ea9b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,9 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn,
17861786
if (SyclOptReport.HasOptReportInfo(FD)) {
17871787
llvm::OptimizationRemarkEmitter ORE(Fn);
17881788
for (auto ORI : llvm::enumerate(SyclOptReport.GetInfo(FD))) {
1789+
// Temporarily apply arg location to ensure SourceLocToDebugLoc
1790+
// picks up the expected file.
1791+
ApplyDebugLocation tmp_raii(*this, ORI.value().KernelArgLoc);
17891792
llvm::DiagnosticLocation DL =
17901793
SourceLocToDebugLoc(ORI.value().KernelArgLoc);
17911794
StringRef NameInDesc = ORI.value().KernelArgDescName;

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3600,10 +3600,10 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
36003600

36013601
BodyStmts.insert(BodyStmts.end(), FinalizeStmts.begin(),
36023602
FinalizeStmts.end());
3603-
SourceLocation LL =
3604-
CallOperator ? CallOperator->getBeginLoc() : SourceLocation();
3605-
SourceLocation LR =
3606-
CallOperator ? CallOperator->getEndLoc() : SourceLocation();
3603+
3604+
const auto *LDcl = NewBody;
3605+
SourceLocation LL = LDcl ? LDcl->getBeginLoc() : SourceLocation();
3606+
SourceLocation LR = LDcl ? LDcl->getEndLoc() : SourceLocation();
36073607

36083608
return CompoundStmt::Create(SemaSYCLRef.getASTContext(), BodyStmts,
36093609
FPOptionsOverride(), LL, LR);

0 commit comments

Comments
 (0)