[PATCH] D17212: [ThinLTO] Support for call graph in per-module and combined summary.
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 10 09:14:19 PST 2016
tejohnson updated this revision to Diff 50287.
tejohnson added a comment.
Fixes to findRefEdges discussed in review and IRC
Two main changes to findRefEdges:
1. Use worklist iteration instead of recursion
The reason is that when we invoke with an Instruction, it will iterate
into other instructions in the function when it encounters a use of
a local variable defined in another instruction. Ultimately we are
analyzing all instructions in the function, and we prevent duplicate
work by sharing the Visited set across all instructions in the function.
However, using a worklist approach is more efficient for large functions
where with recursion we may end up recursing many times (using much
stack).
2. More accurate detection and skipping of callsite references
The prior solution would miss the non-call reference to foo in the
following case:
foo((void *)foo);
since we were skipping all GVs that matched the callee GV.
Additionally, as noted in 1) we may traverse through local variables
defined on other instructions. Those other instructions may be calls
which return a value. We want to make sure we don't count calls in other
instructions encountered this way as non-call refs. Depending on the
order of traversal (e.g. a use on a phi encountered before the call
instruction), we can't count on the call being in the visited set.
Finally, doing the checking for callsites here avoids the need for
WriteFunction to special case call instructions, which has its own set
of issues. For example, one solution considered was for call
instructions to invoke findRefEdges on each of its data_ops(). This
means findRefEdges would need to distinguish between a GV user that was
passed in being either a reference (if it was a call instruction
operand) or a global variable for which we want to analyze initializers
(i.e. called from WriteModuleLevelReferences).
Finally, enhanced the new test quite a bit to check for the various
cases I encountered when fixing findRefEdges.
http://reviews.llvm.org/D17212
Files:
include/llvm/Bitcode/LLVMBitCodes.h
include/llvm/Bitcode/ReaderWriter.h
include/llvm/IR/FunctionInfo.h
include/llvm/Object/FunctionIndexObjectFile.h
include/llvm/ProfileData/ProfileCommon.h
lib/Bitcode/Reader/BitcodeReader.cpp
lib/Bitcode/Writer/BitcodeWriter.cpp
lib/Bitcode/Writer/LLVMBuild.txt
lib/IR/FunctionInfo.cpp
lib/Object/FunctionIndexObjectFile.cpp
lib/Transforms/IPO/FunctionImport.cpp
test/Bitcode/Inputs/thinlto-function-summary-callgraph-pgo.ll
test/Bitcode/Inputs/thinlto-function-summary-callgraph.ll
test/Bitcode/thinlto-function-summary-callgraph-pgo.ll
test/Bitcode/thinlto-function-summary-callgraph.ll
test/Bitcode/thinlto-function-summary-refgraph.ll
test/Bitcode/thinlto-function-summary.ll
test/Bitcode/thinlto-summary-linkage-types.ll
test/tools/gold/X86/thinlto.ll
test/tools/llvm-lto/thinlto.ll
tools/gold/gold-plugin.cpp
tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
tools/llvm-lto/llvm-lto.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17212.50287.patch
Type: text/x-patch
Size: 108318 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160310/3bf1e702/attachment-0001.bin>
More information about the llvm-commits
mailing list