[PATCH] D110864: [llvm-profgen] Update test case to check branch count against outline function

Lei Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 5 17:13:36 PDT 2021


wlei added a comment.

In D110864#3040437 <https://reviews.llvm.org/D110864#3040437>, @wenlei wrote:

>> For llvm-profgen side, If it gets an outlined function with suffixes, currently we only generate a zero total count and non-zero head count FunctionSample like "foo.cold:0:100".
>
> This seems like an inconsistent state, and it would also confuse profile similarity check depending on whether we have split/outline or not.
>
>> For compiler side, If the outlined function is generated before the SampleLoader, the compiler will consume it, otherwise it will ignore it.
>
> Where do we attribute the body samples for the funclet? If that's with the main body (instead of function), we won't be able to consume the funclet profile for splitting before sample loader.
>
> Though I think most split/outline happens after sample loader, and it's cleaner if we attribute all counts to the original function, then left to the split/outline to decide how to split the counts.

I see, yeah, see the code below, if I understand correctly, the pre-sample-loader funclet won't have profile matched(always missing profile). We use `findFunctionSamples` which check `DILocation2SampleMap` for the Inst's profile. However, for every function,  the `DILocation2SampleMap` will be reset to empty. So for a funclet, it can't find the loc from it's master function's `DILocation2SampleMap`, it will just return null.

  bool SampleProfileLoader::runOnFunction(Function &F, ModuleAnalysisManager *AM) {
    DILocation2SampleMap.clear();
    ...
  }

  template <typename BT>
  const FunctionSamples *SampleProfileLoaderBaseImpl<BT>::findFunctionSamples(
      const InstructionT &Inst) const {
    const DILocation *DIL = Inst.getDebugLoc();
    auto it = DILocation2SampleMap.try_emplace(DIL, nullptr);
    ...
    return it.first->second;
  }




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

https://reviews.llvm.org/D110864



More information about the llvm-commits mailing list