Skip to content

Commit ee0b853

Browse files
committed
[PTX] Remove demoting comments
1 parent f359c70 commit ee0b853

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/cleanup/ptx.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Accepted `cleanup_opts` and their default values:
1212
- `demangle=true`: demangle names within the code
1313
- `keep_loop_comments=false`: keep loop comments generated by the LLVM backend
1414
- `keep_block_comments=false`: keep code block comments generated by the LLVM backend
15+
- `keep_demoting_comments=false`: keep variable demoting comments generated by the LLVM backend
1516
- `indent_calls=true`: re-indent `call` instructions to be more recognizable and readable
1617
- `align_preds=8`: align instruction guards (e.g. `@p1`) such that the instruction is placed at the n-th column.
1718
"""
@@ -39,6 +40,13 @@ function cleanup_code(::Val{:ptx}, c, dbinfo, cleanup_opts)
3940
r"^\/\/ %.+\R"m => "", # when the whole line is a comment like such, remove the newline as well
4041
)
4142
end
43+
if !get(cleanup_opts, :keep_demoting_comments, false)
44+
# Those comments indicate that a variable type was demoted to a smaller/more generic one.
45+
push!(extra_patterns,
46+
r"^\/\/ .+? has been demoted\R"m => "",
47+
r"^\s*\/\/ demoted variable\R"m => "",
48+
)
49+
end
4250
if (align_preds = get(cleanup_opts, :align_preds, 8); align_preds > 0)
4351
# Align guard predicates such that the beginning of the instruction is at the
4452
# `align_preds`-th column.

src/cleanup/sass.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ function cleanup_code(::Val{:sass}, c, dbinfo, cleanup_opts)
3434
c = replace(c, extra_patterns...)
3535

3636
# SASS output uses 8 spaces as indent, but there is still some tabs in some places.
37-
return replace(c, replace_tabs(8))
37+
return replace(c, replace_tabs(8))
3838
end

test/cleanup.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ end
200200
@test is_removed("// -- Begin function", ptx_sample, cleaned_ptx)
201201
@test is_removed("// -- End function", ptx_sample, cleaned_ptx)
202202
@test is_removed(r"// %L\d+", ptx_sample, cleaned_ptx)
203+
@test is_removed("// shmem has been demoted", ptx_sample, cleaned_ptx)
204+
@test is_removed("// demoted variable", ptx_sample, cleaned_ptx)
203205

204206
# Demangling
205207
@test is_removed("14gpu_reverse_ka", ptx_sample, cleaned_ptx)
@@ -355,7 +357,8 @@ end
355357
end
356358

357359

358-
# TODO
359-
@testset "AGX" begin end
360+
@testset "AGX" begin
361+
# TODO
362+
end
360363

361364
end

0 commit comments

Comments
 (0)