Run optimization pipeline with O3 for host but O0 for target


we are working on a special purpose target with a limited set of instructions. Due to this we need to ensure that no optimization passes are run before the code emission pipeline of that target. It should however be allowed to use the -O3 flag in order to optimize the IR for the host.

With the legacy pass manager we used the TargetMachine::adjustPassManager(PassManagerBuilder& builder) function within our device target machine and set builder.OptLevel = 0;. This resulted in the desired behavior. With the new pass manager this option seems to be gone.

So far we could not figure out a solution without using the legacy pass manager. Does anyone have an idea how to solve this problem?


Depends on your offloading toolchain, for OpenMP you should be able to use -Xopenmp-target -O0, though I have not tested it. I thought CUDA and HIP have something similar but I can’t find it right now.

1 Like

We in fact use OpenMP. -Xopenmp-target -O0 seems to work in our case and is exactly what we needed. Thanks a lot!

1 Like