I am studying Compilers course, compilation of program follows below steps
From the point of view of the clang
compiler, you can not see each and every output that is generated by the compiler. This is because clang works in a different way compared to other compilers.
Lexical analysis
The tokens can be emitted through:
clang test.c -Xclang -dump-tokens
clang test.c -Xclang -dump-raw-tokens
Intermediate code generation
The byte code can be emitted through: clang test.c -S -emit-llvm
Semantic analysis
The semantic analysis is simultaneously performed while the AST is being generated. The AST can be emitted through:
clang test.c -Xclang -ast-dump
clang test.c -Xclang -ast-view (this generates a graph for the textual AST)
Code optimization
You can query code optimizations through printing the optimization pipeline as it is applied to the c-code:
clang test.c -S -mllvm -print-after-all
Target code generation
The generated code (i.e. the assembly output) can be viewed through:
clang test.c -S
Bonus
You can also see the complete pipeline that clang invokes for a program. For example, the pipeline for emitting an object file can be viewd through:
clang -ccc-print-phases test.c -c
The output generated on the terminal is:
0: input, "test.c", c
1: preprocessor, {0}, cpp-output
2: compiler, {1}, ir
3: backend, {2}, assembler
4: assembler, {3}, object