Add make rules to build LLVM IR from C/C++ sources.


Add make rules to build LLVM IR from C/C++ sources.

As a foundation for future work with LLVM's Intermediate Representation (IR),
add new suffix rules that can be used to build .llo (text) or .bco (bitcode)
files from C or C++ sources. This compilation step uses the same CFLAGS, etc.,
as are used for building .o files, with the exception of optimization flags.
Many of the things we would like to do with IR (e.g., instrumentation) work
better with unoptimized code, so our approach is to build .c->.bco without
optimization and then apply the optimization in post-analysis,
post-instrumentation linking.

The overall result of these changes is:

  • one can "make foo.llo" or "make foo.bco" wherever "make foo.o" was supported
  • new make variables IR_CFLAGS and IR_CXXFLAGS are available to inspect the flags that are used by Clang to generate the IR

These new rules are added unconditionally to our non-POSIX suffix rule set,
since we cannot inspect COMPILER_TYPE in Future changes that depend
on these rules (e.g., building IR versions of binaries from
should use COMPILER_TYPE to determine when we can expect IR rules to succeed.

Reviewed by: emaste, imp
Approved by: rwatson (mentor)
Sponsored by: DARPA, AFRL
Differential Revision:


jonathanOct 20 2016, 3:14 PM
Differential Revision
D4339: Add suffix rules for LLVM IR and bitcode.
rS307675: Remove trailing whitespace from r307674