Clang optimization options with out dead code elimination?

Hi,

We use clang 8+. Does clang have options (not -O0) that do not remove dead code when clang optimize the code?

We have a old project, now migrating to Clang. It works well with -O0, but failed when use -O1 to -O3.

Thanks,

Guofeng

There are lots of reasons a program might fail to do what’s desired when optimized - dead code is only one of them, any reason to believe that’s the issue at hand? But no, LLVM doesn’t really have any support for that.

You might try running your program using the various sanitizersn (address, memory, undefined behavior sanitizer) to help identify if there are bugs that could be fixed.