[PATCH] D60713: [IR] Add DISuprogram and DIE for func decl of an external

Djordje Todorovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 31 05:37:02 PDT 2019


djtodoro added a comment.

@aprantl , @dexonsmith Thanks for your comments!

Now, we avoid the sp flag and a unique sp is attached on to a declaration needed for call site debug info.
Please see the following example.

---------------------------------------------

For the **test1.c**:

` ...

  extern int fn1 (int a);
  
  int fn2(int arg) {
    ...
    arg = fn1(s);
    printf("\n");

...`

**LLVM IR will look like**:

...
 !0 = distinct !DICompileUnit(...,retainedTypes: !3)
 !1 = !DIFile(filename: "test1.c", directory: "/dir")
 ...
 !3 = !{!4, !8}
 !4 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 3, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
 ...
 !8 = !DISubprogram(name: "printf", scope: !9, file: !9, line: 361, type: !10, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
 !9 = !DIFile(filename: "path_to/include/stdio.h", directory: "")
 ...

---------------------------------------------------------

For the **test2.c**:

` ...

  extern int fn1 (int a);
  
  int fn3(int arg3) {
    ...
    arg3 = fn1(k);
    printf("\n");

...`

**LLVM IR will look like**:

...
 !0 = distinct !DICompileUnit(...,retainedTypes: !3)
 !1 = !DIFile(filename: "test2.c", directory: "/dir")
 ...
 !3 = !{!4, !8}
 !4 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 3, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
 ...
 !8 = !DISubprogram(name: "printf", scope: !9, file: !9, line: 361, type: !10, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
 !9 = !DIFile(filename: "path_to/include/stdio.h", directory: "")
 ...

---------------------------------------------------------

**By linking the llvm files together we will have**:

...
 !0 = distinct !DICompileUnit(...,retainedTypes: !3)
 !1 = !DIFile(filename: "test1.c", directory: "/dir")
 ...
 !3 = !{!4, !8}
 !4 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 3, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
 ...
 !8 = !DISubprogram(name: "printf", scope: !9, file: !9, line: 361, type: !10, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
 !9 = !DIFile(filename: "path_to/include/stdio.h", directory: "")
 ...
!15 = distinct !DICompileUnit(..., retainedTypes: !17)
!16 = !DIFile(filename: "test2.c", directory: "/dir")
!17 = !{!18, !8}
!18 = !DISubprogram(name: "fn1", scope: !16, file: !16, line: 3, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
...


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60713/new/

https://reviews.llvm.org/D60713





More information about the llvm-commits mailing list