Issue 179706
Summary Clang emits invalid DebugInfo / IR when `#line 0` is used to start a new scope
Labels clang, debuginfo
Assignees
Reporter felipepiovezan
    ```
void a() {
# 0
  ({ 0; });
}
```

Compile with `clang -g -O test.c -o /tmp/out.ll -emit-llvm -c`:

```
cannot have column info without line info
!18 = distinct !DILexicalBlock(scope: !13, file: !1, column: 4)
fatal error: error in backend: Broken module found, compilation aborted!
```

This is an IR verifier error, so you will only see this if you either A) build with asserts, or B) also pass the flag `-fverify-intermediate-code`.

You can see that there is no guards against line zero here:

```
frame #0: 0x000000010c24a06c clang-21`llvm::DIBuilder::createLexicalBlock(this=0x00000007c5134010, 
Scope=0x00000007c5409190, File=0x00000007c50c55f0, Line=0, Col=57) at DIBuilder.cpp:1073:38
   1069 DILexicalBlock *DIBuilder::createLexicalBlock(DIScope *Scope, DIFile *File,
   1070 unsigned Line, unsigned Col) {
   1071 // Make these distinct, to avoid merging two lexical blocks on the same
 1072   // file/line/column.
-> 1073   return DILexicalBlock::getDistinct(VMContext, getNonCompileUnitScope(Scope),
 1074                                      File, Line, Col);
   1075 }
```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to