Skip to content

Commit 1122e0c

Browse files
authored
[SYCLomatic][ASM] Remove debug purpose instruction "brkpt" (#2702)
Signed-off-by: chenwei.sun <chenwei.sun@intel.com>
1 parent c5eaad0 commit 1122e0c

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

clang/lib/DPCT/RulesAsm/AsmMigration.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2841,6 +2841,23 @@ class SYCLGen : public SYCLGenBase {
28412841

28422842
return SYCLGenError();
28432843
}
2844+
2845+
bool handle_brkpt(const InlineAsmInstruction *Inst) override {
2846+
2847+
if (Inst->getNumInputOperands() != 0)
2848+
return SYCLGenError();
2849+
2850+
auto CommonStr = llvm::Twine("")
2851+
.concat("\"")
2852+
.concat(GAS->getAsmString()->getString())
2853+
.concat("\"")
2854+
.str();
2855+
2856+
report(Diagnostics::FUNC_CALL_REMOVED, true, CommonStr,
2857+
"this instruction is typically used for debugging. You may need to "
2858+
"rewrite the code.");
2859+
return SYCLGenSuccess();
2860+
}
28442861
};
28452862

28462863
/// Clean the special character in identifier.

clang/lib/DPCT/SrcAPI/APINames_ASM.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ ENTRY("bfind", "bfind", false, NO_FLAG, P1, "Comment")
4949
ENTRY("bmsk", "bmsk", false, NO_FLAG, P1, "Comment")
5050
ENTRY("bra", "bra", false, NO_FLAG, P1, "Comment")
5151
ENTRY("brev", "brev", true, NO_FLAG, P1, "Successful")
52-
ENTRY("brkpt", "brkpt", false, NO_FLAG, P1, "Comment")
52+
ENTRY("brkpt", "brkpt", true, NO_FLAG, P1, "Comment")
5353
ENTRY("brx", "brx", false, NO_FLAG, P1, "Comment")
5454
ENTRY("call", "call", false, NO_FLAG, P1, "Comment")
5555
ENTRY("clz", "clz", true, NO_FLAG, P1, "Successful")

clang/test/dpct/asm/brkpt.cu

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// UNSUPPORTED: cuda-8.0, cuda-9.0, cuda-9.1, cuda-9.2, cuda-10.0, cuda-10.1, cuda-10.2
2+
// UNSUPPORTED: v8.0, v9.0, v9.1, v9.2, v10.0, v10.1, v10.2
3+
// RUN: dpct --format-range=none -out-root %T/brkpt %s --cuda-include-path="%cuda-path/include" -- -std=c++14 -x cuda --cuda-host-only
4+
// RUN: FileCheck %s --match-full-lines --input-file %T/brkpt/brkpt.dp.cpp
5+
// RUN: %if build_lit %{icpx -c -fsycl %T/brkpt/brkpt.dp.cpp -o %T/brkpt/brkpt.dp.o %}
6+
7+
// clang-format off
8+
#include <cstdint>
9+
#include <cuda_runtime.h>
10+
11+
// CHECK:inline void cp_async_wait_all() {
12+
// CHECK-NEXT: /*
13+
// CHECK-NEXT: DPCT1026:{{[0-9]+}}: The call to "brkpt;" was removed because this instruction is typically used for debugging. You may need to rewrite the code.
14+
// CHECK-NEXT: */
15+
// CHECK-NEXT: // PTX breakpoint instruction
16+
// CHECK-NEXT:}
17+
__device__ inline void cp_async_wait_all() {
18+
asm("brkpt;"); // PTX breakpoint instruction
19+
}
20+
21+
// clang-format on

0 commit comments

Comments
 (0)