Clang Optimizations Visibility
  2022-12-10

to view the optimization steps done by the compiler use the following compiler flags: -fsave-optimization-record -foptimization-record-file=optfile.yaml they will generate optfile.yaml in the current directory that contains the needed information. now you need to clone the llvm repo if you didn't already do it. run ~/git/llvm/llvm/tools/opt-viewer/opt-viewer.py optfile.yaml. it will generate a html directory containg an index.html file. open the file in your browser and you have the optimization information that gives you some visibility of what happens to your code. what is missing is the following: i don't know what are the optimization passes that are based on undefined behavior, what are _all_ the optimization passes and opt-viewer does not produce assembly code that can be seen in the browser. however the assembly part is not that bad, what i want to focus on is the first problem, i.e. the optimization passes that based on undefined beavior. for the moment i want to patch the compiler with some warnings for those respective passes.