Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable an optimization in LLVM

Tags:

c++

c

llvm

clang

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.

like image 938
pythonic Avatar asked Jul 31 '12 20:07

pythonic


People also ask

How do I disable clang optimization?

The -fno-inline-functions will disable this optimization. Inline functions which are explicitly or implicitly marked inline.

What is LLVM optimization?

DESCRIPTION. The opt command is the modular LLVM optimizer and analyzer. It takes LLVM source files as input, runs the specified optimizations or analyses on it, and then outputs the optimized file.

Does LLVM optimize?

LLVM currently does not optimize well loads and stores of large aggregate types (i.e. structs and arrays). As an alternative, consider loading individual fields from memory. Aggregates that are smaller than the largest (performant) load or store instruction supported by the targeted hardware are well supported.

How do I disable GCC optimization?

Use the command-line option -O0 (-[capital o][zero]) to disable optimization, and -S to get assembly file.


1 Answers

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
like image 133
bames53 Avatar answered Sep 28 '22 04:09

bames53