Skip to content

Commit

Permalink
Add accuracy test
Browse files Browse the repository at this point in the history
  • Loading branch information
driazati committed Dec 5, 2022
1 parent 382db98 commit 4a5c1a2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/python/tir/test_debug_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ def find_span(m):


def test_llvm_ir_debug_info():
"""
Check that the right amount of debug locations are present
"""
MyModule = _module()
with tvm.transform.PassContext(opt_level=3, config={"tir.enable_debug": True}):
runtime_module = tvm.build(MyModule, target="llvm")
Expand All @@ -94,5 +97,28 @@ def test_llvm_ir_debug_info():
assert len(locations) == 34


def test_llvm_ir_debug_accuracy():
"""
Check that the debug location on an assert is correct
"""
MyModule = _module()
with tvm.transform.PassContext(opt_level=3, config={"tir.enable_debug": True}):
runtime_module = tvm.build(MyModule, target="llvm")
source = runtime_module.get_source()
locations = find_di_locations(source)

# Find the 'assert' from MyModule
debug_dir_match = re.search(
r"tail call void %0\(i8\* getelementptr inbounds .* !dbg !(\d+)\n", source
)

# Extract out the debug directive line
directive_idx = debug_dir_match.groups()[0]

# Check that it matches the expected line number (in main.tir)
debug_line_no = int(locations[directive_idx])
assert debug_line_no == 42


if __name__ == "__main__":
tvm.testing.main()

0 comments on commit 4a5c1a2

Please sign in to comment.