How to see what flags get activated by "-O1"?

As the title says it, I am compiling a program using -O1 and my code is showing some weird behaviour. I am interested if there’s a way to dump all the optimization flags that get activated by -O1 so that I could maybe activate them myself one by one and check which one causes the unwanted behaviour.

-O1 is the optimisation flag. It’s not like GCC where -On is just an alias for a whole bunch of -ffoo -fbar -fbaz things.

1 Like

Thank you very much for that info. Is there then a way to see a list of optimisations that my code goes through when using that flag? Or is there a description of said optimisation process?

If not, then do you know by any chance the part of the source code that handles this so I could take a closer look? That would be greatly appreciated.

1 Like

you can add -mllvm -debug-pass=Arguments to the clang invocation it will show the pass pipeline.

1 Like