[llvm-dev] Problem using BlockFrequencyInfo's getBlockProfileCount (original) (raw)

Teresa Johnson via llvm-dev llvm-dev at lists.llvm.org
Mon Jan 14 07:11:27 PST 2019


On Sun, Jan 13, 2019 at 9:24 AM Dennis Fischer via llvm-dev < llvm-dev at lists.llvm.org> wrote:

Hey,

I am trying to use the BlockFrequencyInfoWrapperPass to obtain hotness information in my LLVM pass. Attached is a minimal example of code which creates a SIGSEGV. The pass calls AU.addRequired(); in getAnalysisUsage(..). The problem exists with changed and unchanged IR. The binary is instrumented like this: clang input.bc -fprofile-generate -o output The binary runs with selected inputs and the profiles are merged: llvm-profdata merge input.profraw -output=output.prof Then opt runs with arguments: opt input.bc -o output.bc -load mypass.so -block-freq -pgo-instr-use -pgo-test-profile-file=output.prof -profile-sample-accurate -mypass Is this a bug or am can someone provide an example on how to use BlockFrequencyInfo correctly?

Example code: for (auto& F : M) { if (F.isDeclaration()) { continue; } auto& bfiPass = getAnalysis(F); llvm::BlockFrequencyInfo* BFI = &bfiPass.getBFI(); //Works - shows all info I want BFI->print(llvm::dbgs());

I don't know offhand why your code below is segfaulting, but note that BFI->print() will dereference the F pointer just as *getFunction below will. I would look in the debugger to see what the value of F is during print() since it seems to be ok there, and then see if you can figure out where it is changing if it is returning a bad value below. Teresa

for (const llvm::BasicBlock& B : F) { //Fails with SIGSEGV -> *getFunction() returns 0xa dbgs() << BFI->getBlockProfileCount(&B).getValueOr(0) << "\n"; } }

lib/Analysis/BlockFrequencyInfo.cpp#L211 return BFI->getBlockProfileCount(*getFunction(), BB);


LLVM Developers mailing list llvm-dev at lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

-- Teresa Johnson | Software Engineer | tejohnson at google.com | -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190114/711530e0/attachment.html>



More information about the llvm-dev mailing list