Optimized LLVM IR (mono/mono#16448)
authorEgor Bogatov <egorbo@gmail.com>
Mon, 26 Aug 2019 11:36:04 +0000 (14:36 +0300)
committermonojenkins <jo.shields+jenkins@xamarin.com>
Mon, 26 Aug 2019 11:36:04 +0000 (07:36 -0400)
commite91166203bdadfa664683e39a71f939c10ef4441
treea17a8fc5d57ad1e25a58b327bba5f58f8eb6efcb
parentc0e4ccb5e7aef648c3797ffce22570a8f0914ad4
Optimized LLVM IR (mono/mono#16448)

LLVM JIT: dump IR after optimizations

```csharp
[MethodImpl(MethodImplOptions.NoInlining)]
static int Test(int a, int b, int c) => a * b + a * c;
```
`MONO_VERBOSE_METHOD="Test"` now prints both unoptimized and optimized IR:
```llvm
*** Unoptimized LLVM IR for P:Test ***

; Function Attrs: noinline uwtable
define monocc i32 @"P:Test (int,int,int)"(i32 %arg_a, i32 %arg_b, i32 %arg_c) mono/mono#0 {
BB0:
  br label %BB3

BB3:                                              ; preds = %BB0
  br label %BB2

BB2:                                              ; preds = %BB3
  %t22 = mul i32 %arg_a, %arg_b
  %t25 = mul i32 %arg_a, %arg_c
  %t27 = add i32 %t22, %t25
  br label %BB1

BB1:                                              ; preds = %BB2
  ret i32 %t27
}
***

*** Optimized LLVM IR for P:Test ***

; Function Attrs: noinline uwtable
define monocc i32 @"P:Test (int,int,int)"(i32 %arg_a, i32 %arg_b, i32 %arg_c) mono/mono#0 {
BB0:
  %t251 = add i32 %arg_b, %arg_c
  %t27 = mul i32 %t251, %arg_a
  ret i32 %t27
}
***
```

Commit migrated from https://github.com/mono/mono/commit/6aaec2fe9b0c57dcd03967160d8c67bebcd91fae
src/mono/mono/mini/mini-llvm.c