It is possible to use the LLVM IR generator API to programmatically build the IR for
sum.ll (created at the
-O0 optimization level, that is, without optimizations). In this section, you will see how to do it step by step. First, take a look at which header files are needed:
#include <llvm/ADT/SmallVector.h>: This is used to make the
SmallVector<>template available, a data structure to aid us in building efficient vectors when the number of elements is not large. Check http://llvm.org/docs/ProgrammersManual.html for help on LLVM data structures.
#include <llvm/Analysis/Verifier.h>: The verifier pass is an important analysis that checks whether your LLVM module is well formed with respect to the IR rules.