title: How to make the LLVM Opt tool to report which analysis passes successfully used by each optimization -O1, -O2, etc?
body: <p>I wonder if it is possible to make the LLVM <code>opt</code> tool to report in detail which optimization passes are successfully used during each optimization level like <code>-O1</code>,<code>-O2</code>, etc.</p>
  <p>For example, here is the naive bitcode of the file <code>foo.bc</code>:</p>
  <pre><code>define dso_local i32 @main() #0 {
    %1 = alloca i32, align 4
    %2 = alloca i32, align 4
    %3 = alloca i32, align 4
    store i32 0, i32* %1, align 4
    store i32 1, i32* %2, align 4
    store i32 1, i32* %3, align 4
    %4 = load i32, i32* %2, align 4
    ret i32 %4
  }
  </code></pre>
  <p>And here is the bitcode obtained after running <code>opt -O1 foo.bc -o foo.opt.bc</code></p>
  <pre><code>; Function Attrs: noinline norecurse nounwind readnone uwtable
  define dso_local i32 @main() local_unnamed_addr #0 {
    ret i32 1
  }
  </code></pre>
  <p>How can I obtain information about passes applied by LLVM <code>opt</code> in the above optimization?</p>
  <p>I tried to use several flags of <code>opt</code> of LLVM 10.0, such as <code>--pass-remarks-filter</code>, <code>--debugify-each</code>, <code>--verify-each</code>, <code>--lto-pass-remarks-filter</code>, etc but none of them work.</p>
  <p>Does anyone know how to get such kind of information?</p>