[PATCH] D67283: [GCOV] Skip artificial functions from being emitted

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 4 11:17:12 PST 2019


aganea added inline comments.


================
Comment at: lib/Transforms/Instrumentation/GCOVProfiling.cpp:731-732
 
           // Artificial lines such as calls to the global constructors.
           if (Loc.getLine() == 0 || Loc.isImplicitCode())
             continue;
----------------
dblaikie wrote:
> rnk wrote:
> > Artificial lines here are skipped. If gcov is running, it means that we have an artificial function which contains non-artificial debug locations, otherwise functionHasLines would return false. Do you think we should just add this guard to the other addLine call maybe?
> > 
> > + at nlewycky @dblaikie, since they show up in the blame at rL210239, which added this check.
> It's... errr... been a while?
> 
> I'm not sure I'll be much more use than a blind/fresh reading of the code/commit history here. But if it's useful to have a second set of eyes (mine) - I might need more words (just rephrasing your question, @rnk with some more words to help me understand what's happening here/being proposed)
@dblaikie : Code such as:
```
int foo() { return 1; }
int XXX = foo();
```
Generates a ``dynamic initializer for 'XXX'`. The change in D66328 now marks the generated function as artificial, and only the call to `foo()` has a line location:
```
define internal void @"??__EXXX@@YAXXZ"() #1 !dbg !12 {
entry:
  %call = call i32 @"?foo@@YAHXZ"(), !dbg !13
  store i32 %call, i32* @"?XXX@@3HA", align 4, !dbg !15
  ret void, !dbg !13
}
```
and
```
!12 = distinct !DISubprogram(name: "`dynamic initializer for 'XXX'", scope: !1, file: !1, type: !10, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, retainedNodes: !2)
!13 = !DILocation(line: 8, column: 11, scope: !14)
!14 = !DILexicalBlockFile(scope: !12, file: !9, discriminator: 0)
!15 = !DILocation(line: 0, scope: !12)
```
Which, before this patch, caused instrumentation to fail.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67283





More information about the llvm-commits mailing list