[llvm] [llvm] Avoid out-of-order evaluation in DebugInfo (PR #125116)

Elvin Wang via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 31 16:11:20 PST 2025


elvinw-intel wrote:

We also added the [culprit IR](https://github.com/intel/intel-graphics-compiler/commit/757f50a78138d310f1d1f23655851fa4eae062b3) that can reproduce the issue on [godbolt llvm](https://godbolt.org/noscript/llvm) 's opt14 and opt15, with arg `--strip-nonlinetable-debuginfo`

invalid output:
```
# Compilation provided by Compiler Explorer at https://godbolt.org/
source_filename = "/app/example.ll"

define void @main() {
  ret void, !dbg !5
}

!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!2, !3}
!llvm.ident = !{!4}

!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.7 (tags/RELEASE_370/final)", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly)
!1 = !DIFile(filename: "no filename", directory: "")
!2 = !{i32 2, !"Dwarf Version", i32 4}
!3 = !{i32 2, !"Debug Info Version", i32 3}
!4 = !{!"clang version 3.7 (tags/RELEASE_370/final)"}
!5 = !DILocation(line: 604, column: 1, scope: null) ## it is invalid for scope to be null
```

correct output:
```
# Compilation provided by Compiler Explorer at https://godbolt.org/
source_filename = "/app/example.ll"

define void @main() !dbg !5 {
  ret void, !dbg !8
}

!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!2, !3}
!llvm.ident = !{!4}

!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.7 (tags/RELEASE_370/final)", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly)
!1 = !DIFile(filename: "no filename", directory: "")
!2 = !{i32 2, !"Dwarf Version", i32 4}
!3 = !{i32 2, !"Debug Info Version", i32 3}
!4 = !{!"clang version 3.7 (tags/RELEASE_370/final)"}
!5 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 581, type: !6, scopeLine: 582, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0)
!6 = !DISubroutineType(types: !7)
!7 = !{}
!8 = !DILocation(line: 604, column: 1, scope: !5)
```



https://github.com/llvm/llvm-project/pull/125116


More information about the llvm-commits mailing list