Skip to content

Commit a691817

Browse files
authored
[SYCL] [NATIVECPU] Fix debug info handling (#11291)
This fixes a bug that lead to invalid debug info being generated for Native CPU
1 parent a11618a commit a691817

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

llvm/lib/SYCLLowerIR/PrepareSYCLNativeCPU.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ PreservedAnalyses PrepareSYCLNativeCPUPass::run(Module &M,
306306
auto *NewI = CallInst::Create(ReplaceFunc->getFunctionType(), ReplaceFunc,
307307
{Arg, getStateArg(I->getFunction())},
308308
"ncpu_call", I);
309+
if (I->getMetadata("dbg"))
310+
NewI->setDebugLoc(I->getDebugLoc());
309311
I->replaceAllUsesWith(NewI);
310312
ToRemove.push_back(I);
311313
}

sycl/test/native_cpu/multiple_tu.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
//RUN: %clangxx -fsycl -fsycl-targets=native_cpu %S/Inputs/plusone.cpp -c -o %t_plusone.o
55
//RUN: %clangxx -fsycl -fsycl-targets=native_cpu %t_plusone.o %t_main.o %t_init.o -o %t
66
//RUN: env ONEAPI_DEVICE_SELECTOR=native_cpu:cpu %t
7+
8+
// Re-run test with -g
9+
//RUN: %clangxx -fsycl -fsycl-targets=native_cpu -g %s -c -o %t_main-debug.o
10+
//RUN: %clangxx -fsycl -fsycl-targets=native_cpu -g %S/Inputs/init.cpp -c -o %t_init-debug.o
11+
//RUN: %clangxx -fsycl -fsycl-targets=native_cpu -g %S/Inputs/plusone.cpp -c -o %t_plusone-debug.o
12+
//RUN: %clangxx -fsycl -fsycl-targets=native_cpu -g %t_plusone-debug.o %t_main-debug.o %t_init-debug.o -o %t-debug
13+
//RUN: env ONEAPI_DEVICE_SELECTOR=native_cpu:cpu %t-debug
714
#include "Inputs/common.h"
815
#include <iostream>
916

sycl/test/native_cpu/vector-add.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// RUN: %clangxx -fsycl -fsycl-targets=native_cpu %s -o %t
33
// RUN: env ONEAPI_DEVICE_SELECTOR="native_cpu:cpu" %t
44

5+
// Same test but with -g
6+
// RUN: %clangxx -fsycl -fsycl-targets=native_cpu %s -g -o %t-debug
7+
// RUN: env ONEAPI_DEVICE_SELECTOR="native_cpu:cpu" %t-debug
8+
59
#include <sycl/sycl.hpp>
610

711
#include <array>

0 commit comments

Comments
 (0)