Skip to content

Commit f6f0d5e

Browse files
committed
Fix kernel return type in DISubroutineType debug metadata
1 parent 2357413 commit f6f0d5e

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

numba_cuda/numba/cuda/compiler.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,8 @@ def kernel_fixup(kernel, debug):
880880
kernel.return_value = ir.ReturnValue(kernel, ir.VoidType())
881881
kernel.args = kernel.args[1:]
882882

883-
# If debug metadata is present, remove the return value from it
883+
# If debug metadata is present, fix the return type to void by replacing
884+
# the first element of the types tuple with null (representing void).
884885

885886
if kernel_metadata := getattr(kernel, "metadata", None):
886887
if dbg_metadata := kernel_metadata.get("dbg", None):
@@ -890,7 +891,8 @@ def kernel_fixup(kernel, debug):
890891
for tm_name, tm_value in type_metadata.operands:
891892
if tm_name == "types":
892893
types = tm_value
893-
types.operands = types.operands[1:]
894+
null_metadata = ir.Constant(ir.MetaDataType(), None)
895+
types.operands = (null_metadata,) + types.operands[1:]
894896
if config.DUMP_LLVM:
895897
types._clear_string_cache()
896898

numba_cuda/numba/cuda/tests/cudapy/test_debuginfo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ def f(x, y):
291291
mdnode_id = match.group(1)
292292

293293
# extract the metadata node ids from the flexible node of types
294-
pat = rf"!{mdnode_id}\s+=\s+!{{\s+!(\d+),\s+!(\d+)\s+}}"
294+
# The first element is null (void return type), followed by param types
295+
pat = rf"!{mdnode_id}\s+=\s+!{{\s+null,\s+!(\d+),\s+!(\d+)\s+}}"
295296
match = re.compile(pat).search(llvm_ir)
296297
self.assertIsNotNone(match, msg=llvm_ir)
297298
mdnode_id1 = match.group(1)

0 commit comments

Comments
 (0)