[RfC] adding new outputs to -save-temps


I’m interested in adding two new outputs to -save-temps:

  • Unoptimized .ll
  • Optimized .ll

It’s already possible to produce these outputs manually by invoking clang
several times with different flag combinations (-emit-llvm -S for optimized IR, add
-Xclang -disable-llvm-passes for unoptimized IR), but I think it would be
interesting to have these generated automatically by -save-temps as a debugging

My current plan is to add two new actions in the driver whenever -save-temps is
specified, so that their outputs are preserved by -save-temps just like any other
intermediate step. I have uploaded an initial patch at https://reviews.llvm.org/D33108,
but I have a couple of questions about it:

  1. the new actions would have TY_LLVM_IR as their output type, which causes an
    error when building for multiple architectures because outputs of that type
    cannot be lipo’d. I have no idea about lipo, is this some kind of fundamental
    limitation or something that can be fixed or worked around?

  2. The comment [0] right above the code that triggers that error says “we could
    remove this oddity by just changing the output names to include the arch”, but
    looking at the multiarch save-temps tests [1] all the temporary files produced
    seem to have arch suffixes in their names already. Is this comment outdated or
    am I interpreting it wrong?

All comments welcome.


[0] https://github.com/llvm-mirror/clang/blob/master/lib/Driver/Driver.cpp#L1390-L1394
[1] https://github.com/llvm-mirror/clang/blob/master/test/Driver/save-temps.c#L30-L43