pythonic
pythonic

Reputation: 21665

How to disable an optimization in LLVM

I am compiling code with clang with -O4 optimization. However, I want to disable inlining of functions. I have my own LLVM pass that injects some code to the generated code. After my pass, I want to enable the inlining of functions. How can I do that.

Upvotes: 8

Views: 7164

Answers (2)

vkorchagin
vkorchagin

Reputation: 656

If you are hacking clang, you can change passes order in file clang/lib/CodeGen/BackendUtil.cpp. You should insert your pass before inlining in method CreatePasses().

Upvotes: 4

bames53
bames53

Reputation: 88225

You can use opt which says it can run passes in any order.

clang -c main.cpp -O0 -emit-llvm | opt -load yourplugin -yourpass -inline

Upvotes: 7

Related Questions