[LLVMdev] Runtime performance of Value::printAsOperand

Kostas Ferles kferles at gmail.com
Mon Jan 12 06:37:19 PST 2015


Hi all,

I am one of the developers of llvm-datalog
<https://github.com/plast-lab/llvm-datalog>, a static analysis tool for
LLVM bitcode based on Datalog.

The first phase of our tool is to create some CSV files (for our Datalog
schema) while traversing a bitcode file. During that phase, our
implementation makes use of the Value::printAsOperand method to print
operands from several LLVM bitcode instructions to the CSV file. But this
approach doesn't scale and the problem seems to be the
Value::printAsOperand method, based on some profiling that we performed
afterwards.

After studying the source code, I think that the problem is the "slow path"
of this method, which constructs a TypePrinting object from scratch, every
time this path is triggered. As far as I can tell, each time this slow path
is taken, it invokes methods (e.g., TypeFinder::run) that perform many
*Module-wide* calculations that are redundant (except for the first time
they are performed). This whole process accounts for most of our tool's
execution time.

So, my question is: Is there any faster way to perform the same task? Note
that we would like to keep our tool as an LLVM client, rather than relying
on any internal API.

Cheers,
Kostas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150112/810a1537/attachment.html>


More information about the llvm-dev mailing list