llvm-project/clang/test/CodeGenSYCL/debug-info-kernel-variables.cpp
Stephen Tozer 094572701d
[RemoveDIs] Print IR with debug records by default (#91724)
This patch makes the final major change of the RemoveDIs project, changing the
default IR output from debug intrinsics to debug records. This is expected to
break a large number of tests: every single one that tests for uses or
declarations of debug intrinsics and does not explicitly disable writing
records. 

If this patch has broken your downstream tests (or upstream tests on a
configuration I wasn't able to run):
1. If you need to immediately unblock a build, pass
`--write-experimental-debuginfo=false` to LLVM's option processing for all
failing tests (remember to use `-mllvm` for clang/flang to forward arguments to
LLVM).
2. For most test failures, the changes are trivial and mechanical, enough that
they can be done by script; see the migration guide for a guide on how to do
this: https://llvm.org/docs/RemoveDIsDebugInfo.html#test-updates
3. If any tests fail for reasons other than FileCheck check lines that need
updating, such as assertion failures, that is most likely a real bug with this
patch and should be reported as such.

For more information, see the recent PSA:
https://discourse.llvm.org/t/psa-ir-output-changing-from-debug-intrinsics-to-debug-records/79578
2024-06-14 15:07:27 +01:00

61 lines
2.1 KiB
C++

// RUN: %clang_cc1 %s -o - -O0 -emit-llvm \
// RUN: -triple spir64-unknown-unknown \
// RUN: -aux-triple x86_64-unknown-linux-gnu \
// RUN: -fsycl-is-device \
// RUN: -finclude-default-header \
// RUN: -debug-info-kind=limited -gno-column-info \
// RUN: | FileCheck %s
//
// In spir functions, validate the llvm.dbg.declare intrinsics created for
// parameters and locals refer to the stack allocation in the alloca address
// space.
//
#define KERNEL __attribute__((sycl_kernel))
template <typename KernelName, typename KernelType>
KERNEL void parallel_for(const KernelType &KernelFunc) {
KernelFunc();
}
void my_kernel(int my_param) {
int my_local = 0;
my_local = my_param;
}
int my_host() {
parallel_for<class K>([=]() { my_kernel(42); });
return 0;
}
// CHECK: define {{.*}}spir_func void @_Z9my_kerneli(
// CHECK-SAME i32 %my_param
// CHECK-SAME: !dbg [[MY_KERNEL:![0-9]+]]
// CHECK-SAME: {
// CHECK: %my_param.addr = alloca i32, align 4
// CHECK: %my_local = alloca i32, align 4
// CHECK: #dbg_declare(
// CHECK-SAME: ptr %my_param.addr,
// CHECK-SAME: [[MY_PARAM:![0-9]+]],
// CHECK-SAME: !DIExpression(DW_OP_constu, 4, DW_OP_swap, DW_OP_xderef)
// CHECK-SAME: )
// CHECK: #dbg_declare(
// CHECK-SAME: ptr %my_local,
// CHECK-SAME: [[MY_LOCAL:![0-9]+]],
// CHECK-SAME: !DIExpression(DW_OP_constu, 4, DW_OP_swap, DW_OP_xderef)
// CHECK-SAME: )
// CHECK: }
// CHECK: [[MY_KERNEL]] = distinct !DISubprogram(
// CHECK-SAME: name: "my_kernel"
// CHECK-SAME: )
// CHECK: [[MY_PARAM]] = !DILocalVariable(
// CHECK-SAME: name: "my_param"
// CHECK-SAME: arg: 1
// CHECK-SAME: scope: [[MY_KERNEL]]
// CHECK-SAME: )
// CHECK: [[MY_LOCAL]] = !DILocalVariable(
// CHECK-SAME: name: "my_local"
// CHECK-SAME: scope: [[MY_KERNEL]]
// CHECK-SAME: )