Skip to content

Commit 4a508c6

Browse files
jiel-nvgmarkall
andauthored
Emit correct kernel arguments debug metadata types when NUMBA_DUMP_LLVM is on (#136)
After shifting out the return value type from the operands of 'types' field of the 'DISubroutineType' metadata node, compiler needs to clear the cached string representation of the corresponding MDValue object if NUMBA_DUMP_LLVM is on. Because at that moment, the cached string has already been filled with the tuple before kernel_fixup() which has the return value type and continue being used when printing out the LLVM IR. This change fixes #135 * Add a test for issue#135 Enriches an existing test by adding a variation, i.e. turn NUMBA_DUMP_LLVM on. * Use the output capturing to prevent dumping to stdout. --------- Co-authored-by: Graham Markall <[email protected]>
1 parent edbc318 commit 4a508c6

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

numba_cuda/numba/cuda/compiler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,8 @@ def kernel_fixup(kernel, debug):
427427
if tm_name == 'types':
428428
types = tm_value
429429
types.operands = types.operands[1:]
430+
if config.DUMP_LLVM:
431+
types._clear_string_cache()
430432

431433
# Mark as a kernel for NVVM
432434

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from numba.tests.support import override_config
1+
from numba.tests.support import (override_config, captured_stdout)
22
from numba.cuda.testing import skip_on_cudasim
33
from numba import cuda
44
from numba.core import types
@@ -268,7 +268,7 @@ def kernel(x, y):
268268
three_device_fns(kernel_debug=False, leaf_debug=True)
269269
three_device_fns(kernel_debug=False, leaf_debug=False)
270270

271-
def test_kernel_args_types(self):
271+
def _test_kernel_args_types(self):
272272
sig = (types.int32, types.int32)
273273

274274
@cuda.jit("void(int32, int32)", debug=True, opt=False)
@@ -298,6 +298,15 @@ def f(x, y):
298298
match = re.compile(pat).search(llvm_ir)
299299
self.assertIsNotNone(match, msg=llvm_ir)
300300

301+
def test_kernel_args_types(self):
302+
self._test_kernel_args_types()
303+
304+
def test_kernel_args_types_dump(self):
305+
# see issue#135
306+
with override_config('DUMP_LLVM', 1):
307+
with captured_stdout():
308+
self._test_kernel_args_types()
309+
301310

302311
if __name__ == '__main__':
303312
unittest.main()

0 commit comments

Comments
 (0)