llvm-project/llvm/test/tools/llvm-profgen/Inputs
wlei 0f53df864e [CSSPGO][llvm-profgen] Fix external address issues of perf reader (return to external addr part)
Before we have an issue with artificial LBR whose source is a return, recalling that "an internal code(A) can return to external address, then from the external address call a new internal code(B), making an artificial branch that looks like a return from A to B can confuse the unwinder". We just ignore the LBRs after this artificial LBR which can miss some samples. This change aims at fixing this by correctly unwinding them instead of ignoring them.

List some typical scenarios covered by this change.

1)  multiple sequential call back happen in external address, e.g.

```
[ext, call, foo] [foo, return, ext] [ext, call, bar]
```
Unwinder should avoid having foo return from bar. Wrong call stack is like [foo, bar]

2) the call stack before and after external call should be correctly unwinded.
```
 {call stack1}                                            {call stack2}
 [foo, call, ext]  [ext, call, bar]  [bar, return, ext]  [ext, return, foo ]
```
call stack 1 should be the same to call stack2. Both shouldn't be truncated

3) call stack should be truncated after call into external code since we can't do inlining with external code.

```
 [foo, call, ext]  [ext, call, bar]  [bar, call, baz] [baz, return, bar ] [bar, return, ext]
```
the call stack of code in baz should not include foo.

### Implementation:

We leverage artificial frame to fix #2 and #3: when we got a return artificial LBR, push an extra artificial frame to the stack. when we pop frame, check if the parent is an artificial frame to pop(fix #2). Therefore, call/ return artificial LBR is just the same as regular LBR which can keep the call stack.

While recording context on the trie, artificial frame is used as a tag indicating that we should truncate the call stack(fix #3).

To differentiate #1 and #2, we leverage `getCallAddrFromFrameAddr`.  Normally the target of the return should be the next inst of a call inst and `getCallAddrFromFrameAddr` will return the address of call inst. Otherwise, getCallAddrFromFrameAddr will return to 0 which is the case of #1.

Reviewed By: hoy, wenlei

Differential Revision: https://reviews.llvm.org/D115550
2021-12-14 16:40:54 -08:00
..
artificial-branch.perfscript [llvm-profgen] Ignore the whole trace with the leading external branch 2021-10-13 16:52:29 -07:00
callback-external-addr.perfbin [CSSPGO][llvm-profgen] Fix external address issues of perf reader (return to external addr part) 2021-12-14 16:40:54 -08:00
callback-external-addr.perfscript [CSSPGO][llvm-profgen] Fix external address issues of perf reader (return to external addr part) 2021-12-14 16:40:54 -08:00
cold-profile-trimming.raw.prof [llvm-profgen] Trim cold function profiles for non-CS AutoFDO 2021-12-08 12:20:50 -08:00
coroutine.perfbin [llvm-profgen] Ignore branch count against outline function 2021-10-07 14:03:34 -07:00
coroutine.perfscript [llvm-profgen] Ignore branch count against outline function 2021-10-07 14:03:34 -07:00
cs-interrupt.perfscript
cs-invalid-ret-addr.perfscript [CSSPGO][llvm-profgen] Truncate stack samples with invalid return address. 2021-09-14 21:56:22 -07:00
cs-preinline-cost.perfbin [CSSPGO] Track and use context-sensitive post-optimization function size to drive global pre-inliner in llvm-profgen 2021-08-18 22:50:57 -07:00
cs-preinline-cost.perfscript [CSSPGO] Track and use context-sensitive post-optimization function size to drive global pre-inliner in llvm-profgen 2021-08-18 22:50:57 -07:00
external-address.perfscript [CSSPGO][llvm-profgen] Fix external address issues of perf reader (leading external LBR part) 2021-12-14 16:40:53 -08:00
fs-discriminator.perfbin [FS-AFDO][llvm-profgen] Generate profile with FS-AFDO discriminator 2021-11-30 15:57:59 -08:00
fs-discriminator.raw.prof [FS-AFDO][llvm-profgen] Generate profile with FS-AFDO discriminator 2021-11-30 15:57:59 -08:00
func-split.perfbin [llvm-profgen] Ignore branch count against outline function 2021-10-07 14:03:34 -07:00
func-split.perfscript [llvm-profgen] Ignore branch count against outline function 2021-10-07 14:03:34 -07:00
inline-cs-noprobe.perfbin
inline-cs-noprobe.perfscript [CSSPGO][llvm-profgen] Fix external address issues of perf reader (leading external LBR part) 2021-12-14 16:40:53 -08:00
inline-cs-pseudoprobe.perfbin
inline-cs-pseudoprobe.perfscript
inline-noprobe.perfbin [AutoFDO][llvm-profgen] Profile generation for LBR(non-CS) sample 2021-09-24 13:55:34 -07:00
inline-noprobe.perfscript [AutoFDO][llvm-profgen] Profile generation for LBR(non-CS) sample 2021-09-24 13:55:34 -07:00
inline-noprobe2.perfbin [AutoFDO][llvm-profgen] Profile generation for LBR(non-CS) sample 2021-09-24 13:55:34 -07:00
inline-noprobe2.perfscript [AutoFDO][llvm-profgen] Profile generation for LBR(non-CS) sample 2021-09-24 13:55:34 -07:00
multi-load-segs.perfbin
multi-load-segs.perfscript
noinline-cs-noprobe.aggperfscript
noinline-cs-noprobe.perfbin
noinline-cs-noprobe.perfscript
noinline-cs-pseudoprobe.aggperfscript
noinline-cs-pseudoprobe.perfbin
noinline-cs-pseudoprobe.perfscript
noprobe.aggperfscript [llvm-profgen] Support LBR only perf script 2021-08-31 13:28:17 -07:00
noprobe.mmap.perfscript [llvm-profgen] Support LBR only perf script 2021-08-31 13:28:17 -07:00
noprobe.perfbin [llvm-profgen] Support LBR only perf script 2021-08-31 13:28:17 -07:00
noprobe.perfscript [llvm-profgen] Ignore invalid perf line in LBR record 2021-09-24 13:44:57 -07:00
out-of-bounds.raw.prof [llvm-profgen] Fix index out of bounds error while using ip.advance 2021-11-05 18:38:40 -07:00
profile-density-cs.raw.prof [llvm-profgen] Compute and show profile density 2021-11-29 23:54:31 -08:00
profile-density.raw.prof [llvm-profgen] Compute and show profile density 2021-11-29 23:54:31 -08:00
recursion-compression-noprobe.perfbin
recursion-compression-noprobe.perfscript
recursion-compression-pseudoprobe-nommap.perfscript
recursion-compression-pseudoprobe.perfbin
recursion-compression-pseudoprobe.perfscript
symbolize.ll
symbolize.perfbin
truncated-pseudoprobe.ll
truncated-pseudoprobe.perfbin
truncated-pseudoprobe.perfscript
unique-linkage-name-dwarf.perfbin
unique-linkage-name-dwarf.perfscript
unique-linkage-name-probe.perfbin
unique-linkage-name-probe.perfscript