I realize my previous message may have been a bit abrupt, without much proper
explanations, though it is a serious application!
Currently, the feedback of LLVM regarding the optimizations performed is an
optional list of optimization names, through the detailed pass statistics.
Though of high relevance to a user familiar with optimizing compilers, for
unfamiliar users it might be overwhelming: one will have to “google” every
single name to learn about the different techniques.
Even for most expert users, which have not had a glimpse at LLVM source code,
it is fairly hard to guest whether some specific sequence of instructions will
be optimized as expected. docs/Passes.html clearly states the behaviour of each
optimization, but nothing guarantees that it will behave as expected. There
should be a closer feedback to was is actually done.
I am thinking about a user-friendly feedback of the optimizations performed.
It would not be meant as an exhaustive feedback as the detailed pass
statistics, but rather pick one or two optimizations done during the previous
compilation, and explain them.
As an example:
cc --feedback test.c
test.c:xx:x: info: Value Propagation: All operands being constant, ‘2560’ was directly assigned to ‘a’
test.c:xx:x: info: Value Propagation: Impossible to proceed here, because…
test.c:xx:x: info: MemCpy Optimization: The consecutive sequence of 6 stores was merged in a single memcpy
test.c:xx:x: info: Combine redundant instructions: As integers are stored in binary format, ‘* 8’ was replaced by ‘<< 3’
As a difference with the pass statistics, here the messages would form a set,
and the system would remember those already displayed and decrease their
frequency of occurence between compilations. All messages would cite the pass
name for search in the docs, explain what triggered the optimization, and
describe the consequence. Actually I think the messages could be a little
lengthier than the example (2-3 lines) to make proper explanations.
As for the work plan, it would consist in:
_ Enumerating all possible messages in the messages set.
_ Implementing a function receiving feedback from each optimization unit and
choosing whether to display it: info_printf(enum INFO_INDEX, const char*, …);
_ Write a formatting guide for adding messages in the set.
I would very much appreciate you feedback on this proposal!