[llvm] [ExtendLifetimes] Implement llvm.fake.use to extend variable lifetimes (PR #86149)

Orlando Cazalet-Hyams via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 6 05:18:43 PDT 2024


OCHyams wrote:

>> I said
>> Does the script handle exprloc DW_AT_locations (i.e., single location that implicitly covers the scope with no explicit range)?
>
>@SLTozer said
> No, although I think that shouldn't be possible? I think we only emit that for constants or declares.

It's definitely possible:
```
$ cat test.ll
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-unknown"

define i32 @f(i32 %a) !dbg !4 {
entry:
  tail call void @llvm.dbg.value(metadata i32 %a, metadata !8, metadata !DIExpression()), !dbg !10
  ret i32 0, !dbg !10
}

declare void @llvm.dbg.value(metadata, metadata, metadata)

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

!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
!1 = !DIFile(filename: "test.ll", directory: "/")
!2 = !{i32 1}
!3 = !{i32 2, !"Debug Info Version", i32 3}
!4 = distinct !DISubprogram(name: "f", linkageName: "f", scope: null, file: !1, line: 1, type: !5, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !7)
!5 = !DISubroutineType(types: !6)
!6 = !{}
!7 = !{!8}
!8 = !DILocalVariable(name: "1", scope: !4, file: !1, line: 1, type: !9)
!9 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
!10 = !DILocation(line: 1, column: 1, scope: !4)
```
```
$ llc test2.ll --filetype=obj -o - | llvm-dwarfdump -
<...>
0x00000043:     DW_TAG_variable
                  DW_AT_location        (DW_OP_reg5 RDI)
                  DW_AT_name    ("1")
                  DW_AT_decl_file       ("/test.ll")
                  DW_AT_decl_line       (1)
                  DW_AT_type    (0x00000051 "ty32")
 ```

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


More information about the llvm-commits mailing list