Remove dangling empty braces in PTX (#7960)

After directive filtering, there will be dangling `{}` spanning two
lines. This PR attempts to remove them.

For example, 
```
.section    .debug_abbrev
{
.b8 1
}
.section    .debug_info
{
.b32 70
.b32 .debug_abbrev
}
```

The above assembly used to become the following text after filtering
directive

```
{
}
{
}
```
This commit is contained in:
Shawn Zhong
2025-07-30 08:40:00 -07:00
committed by GitHub
parent 227595d83e
commit f92b6f388a
2 changed files with 31 additions and 0 deletions

View File

@@ -209,6 +209,28 @@ vprintf,
expect(lines[7]).toBe('}');
});
});
describe('Directive filter', () => {
it('should remove directives when directive filter is enabled', () => {
const input = `
.file 1 "/tmp/compiler-explorer-compilerk2brih/example.py"
.section .debug_abbrev
{
.b8 1
}
.section .debug_info
{
.b32 70
.b32 .debug_abbrev
}
.section .debug_macinfo { }
`;
const result = parser.processAsm(input, {directives: true});
const lines = result.asm.map(line => line.text);
expect(lines.length).toBe(1);
expect(lines[0]).toBe('');
});
});
});
describe('MlirAsmParser tests', () => {