[llvm-dev] Where to find the list of passes run by clang/opt with -O3

Martin J. O'Riordan via llvm-dev llvm-dev at lists.llvm.org
Tue Sep 5 13:24:21 PDT 2017

I had asked a similar question earlier this year regarding which passes are involved at a particular optimisation level (lists.llvm.org/pipermail/llvm-dev/2017-June/114543.html), and the most helpful suggestion I received was to invoke the compiler with the following options:

  -O3 -mllvm -debug-pass=Structure

So I ran the compiler with each of '-O0' .. '-O3' to get the answer I was looking for.

I don't know how to generally disable a particular pass from the command line with LLVM v4.0, but the pass you want to disable identifies itself as:

  Loop Strength Reduction

and can be disabled with the option (see 'lib/CodeGen/TargetPassConfig.cpp'):

  -mllvm -disable-lsr

I haven't yet started working with LLVM v5.0 and the new pass manager though so this may already be an obsolete suggestion.

All the best,


-----Original Message-----
From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of Davide Italiano via llvm-dev
Sent: 05 September 2017 20:54
To: Nitish Srivastava <nks45 at cornell.edu>
Cc: llvm-dev <llvm-dev at lists.llvm.org>
Subject: Re: [llvm-dev] Where to find the list of passes run by clang/opt with -O3

On Tue, Sep 5, 2017 at 12:51 PM, Davide Italiano <davide at freebsd.org> wrote:
> On Tue, Sep 5, 2017 at 8:16 AM, Nitish Srivastava via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>> Hi,
>>   I am trying to locate the passes run by clang/opt when it is passed the option -O3. Can someone point me where to look at? Eventually, I want to turn off just the LoopStrengthReduction pass in the -O3 set of default passes.

Also, the easiest hack to turn off LSR is that of probably just commenting out the line that adds the pass in PassManagerBuilder.cpp.
If you use `opt` + the new pass manager there's a flag for testing to specify a custom pipeline, but that will be more work.


"There are no solved problems; there are only problems that are more or less solved" -- Henri Poincare _______________________________________________
LLVM Developers mailing list
llvm-dev at lists.llvm.org

More information about the llvm-dev mailing list