SlideShare a Scribd company logo
1 of 43
LLVM back-end for C#
@EgorBo
Senior Software Engineer at Microsoft
LLVMJIT/AOTRoslyn
Mono-LLVM: quick intro
2
C# IL (.dll) mini IR LLVM IR MIR
F#
LLVM: C# to MC
3
int MyAdd(int a, int b)
{
return a + b;
}
.method private hidebysig static
int32 MyAdd (
int32 a,
int32 b
) cil managed
{
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: add
IL_0003: ret
}
Roslyn
LLVM: C# to MC
4
define monocc i32 @"Program:MyAdd (int,int)"
(i32 %arg_a, i32 %arg_b) {
BB0:
br label %BB3
BB3:
br label %BB2
BB2:
%t22 = add i32 %arg_a, %arg_b
br label %BB1
BB1:
ret i32 %t22
}
.method private hidebysig static
int32 MyAdd (
int32 a,
int32 b
) cil managed
{
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: add
IL_0003: ret
}
mini
LLVM: C# to MC
5
define monocc i32 @"Program:MyAdd (int,int)"
(i32 %arg_a, i32 %arg_b) {
BB0:
br label %BB3
BB3:
br label %BB2
BB2:
%t22 = add i32 %arg_a, %arg_b
br label %BB1
BB1:
ret i32 %t22
}
.method private hidebysig static
int32 MyAdd (
int32 a,
int32 b
) cil managed
{
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: add
IL_0003: ret
}
mini
(simplifycfg)
LLVM: C# to MC
6
define monocc i32 @"Program:MyAdd (int,int)"(i32 %arg_a, i32 %arg_b) #0
{
BB0:
%t22 = add i32 %arg_a, %arg_b
ret i32 %t22
}
lea eax, [rdi + rsi]
ret
llc
(I am skipping the machine IR part)
LLVM: C# to MC
7
void MySet(byte* array, int len, byte val)
{
for (int i = 0; i < len; i++)
array[i] = val;
}
define monocc void @"MySet"(i8* %arg_array,
i32 %arg_len, i32 %arg_val) #0 {
BB0:
br label %BB3
BB3:
br label %BB2
BB2:
br label %BB4
BB4:
%0 = phi i32 [ 0, %BB2 ], [ %t32, %BB5 ]
%1 = icmp slt i32 %0, %arg_len
br i1 %1, label %BB5, label %BB6
BB6:
br label %BB1
BB5:
%t23 = sext i32 %0 to i64
%3 = getelementptr i8, i8* %arg_array, i64 %t23
%4 = trunc i32 %arg_val to i8
store i8 %4, i8* %3
%t32 = add i32 %0, 1
br label %BB4
BB1:
ret void
}
mini
8
define monocc void @"MySet"(i8* %arg_array,
i32 %arg_len, i32 %arg_val) #0 {
BB0:
br label %BB3
BB3:
br label %BB2
BB2:
br label %BB4
BB4:
%0 = phi i32 [ 0, %BB2 ], [ %t32, %BB5 ]
%1 = icmp slt i32 %0, %arg_len
br i1 %1, label %BB5, label %BB6
BB6:
br label %BB1
BB5:
%t23 = sext i32 %0 to i64
%3 = getelementptr i8, i8* %arg_array, i64 %t23
%4 = trunc i32 %arg_val to i8
store i8 %4, i8* %3
%t32 = add i32 %0, 1
br label %BB4
BB1:
ret void
}
opt
define monocc void @"MySet"(i8* %arg_array,
i32 %arg_len, i32 %arg_val) #0 {
BB0:
%0 = icmp sgt i32 %arg_len, 0
br i1 %0, label %BB5.lr.ph, label %BB1
BB5.lr.ph:
%1 = trunc i32 %arg_val to i8
%2 = zext i32 %arg_len to i64
call void @llvm.memset.p0i8.i64(i8* %arg_array, i8 %1, i64 %2…)
br label %BB1
BB1:
ret void
}
LLVM needs hints from front-ends
9
• Alias-analysis (`noalias`, TBAA, etc)
• PGO-data and @llvm.expect (branch-weights)
• Use GEPs where possible instead of `ptrtoint+add+inttoptr`
• Language specific order of optimization passes (maybe even custom passes)
• Alignment hints
• FaultMaps and implicit null-checks
• Use LLVM intrinsics where needed (libcalls, HW intrinsics, etc)
• Don’t forget about Fast-Math!
• NIT: Nullability, Escape analysis, etc
10
AA is important!
LLVM: ffast-math
11
float result = (x / 10) + 1 + 1;
CoreCLR, Mono, C++ -O2 Mono-LLVM (--llvm --ffast-math)
vfmadd132sd xmm0, xmm1, QWORD PTR .LC0[rip]vdivsd xmm0, xmm0, QWORD PTR .LC0[rip]
vaddsd xmm0, xmm0, xmm1
vaddsd xmm0, xmm0, xmm1
float result = (x / 10) + 2;
float result = (x * 0.1) + 2;
float result = fmadd(x, 0.1, 2);
1
2
3
4
LLVM: ffast-math
12
• No NaNs (NOTE: some apps rely on NaN values, e.g. WPF)
• No Infs
• No Signed Zeros (e.g. Math.Max(-0.0, 0.0) will return -0.0)
• Approximate functions
• Recognize FMA patterns (a * b + c)
• Reassociation transformations (x + c1 + c2 => x + (c1 + c2))
C# Math/MathF are LLVM intrinsics!
13
static float Foo(float x)
{
return MathF.Sqrt(x) * MathF.Sqrt(x);
}
define float @"Foo“ (float %arg_x) {
BB0:
br label %BB3
BB3:
br label %BB2
BB2:
%t19 = call fast float @llvm.sqrt.f32(float %arg_x)
%t21 = call fast float @llvm.sqrt.f32(float %arg_x)
%t22 = fmul fast float %t19, %t21
br label %BB1
BB1:
ret float %t22
}
declare float @llvm.sqrt.f32(float)
Emit
LLVM IR
C# Math/MathF are LLVM intrinsics!
14
define float @"Foo“ (float %arg_x) {
BB0:
br label %BB3
BB3:
br label %BB2
BB2:
%t19 = call fast float @llvm.sqrt.f32(float %arg_x)
%t21 = call fast float @llvm.sqrt.f32(float %arg_x)
%t22 = fmul fast float %t19, %t21
br label %BB1
BB1:
ret float %t22
}
declare float @llvm.sqrt.f32(float)
define float @"Foo“ (float %arg_x) {
BB0:
ret float %arg_x
}
opt
C# Math/MathF are LLVM intrinsics!
15
Math.Abs(X) * Math.Abs(X) => X * X
Math.Sin(X) / Math.Cos(X) => Math.Tan(X)
Math.Sqrt(X) * Math.Sqrt(X) => X
Math.Sin(-X) => -Math.Sin(X)
MathF.Pow(X, 0.5f) => MathF.Sqrt(X)
MathF.Pow(X, 2) => X * X
MathF.Pow(X, 4) => (X * X) * (X * X)
Significant boost in some FP benchmarks:
16
(CPU without FMA)
One of those benchmarks (Lorenz equations):
17
Don’t forget to feed the LLVM!
with some PGO data for better codegen
18
19static int Max(int x, int y)
{
return x > y ? x : y;
}
!0 = !{!"branch_weights", i32 1000, i32 1}
Default With profile data (PGO)
mov eax, esi
cmp edi, esi
cmovge eax, edi
ret
define i32 @Max(i32 %0, i32 %1) {
%3 = icmp sgt i32 %0, %1
%4 = select i1 %3, i32 %0, i32 %1
ret i32 %4
}
define i32 @Max(i32 %0, i32 %1) {
%3 = icmp sgt i32 %0, %1 !prof 0
%4 = select i1 %3, i32 %0, i32 %1
ret i32 %4
}
mov eax, edi
cmp edi, esi
jle .LBB1_1
ret
.LBB1_1:
mov eax, esi
ret
20
21
PGO and switch
char* format(char format)
{
switch (format)
{
case 'G’:
return defaultFormat();
case 'X’:
return hexFormat();
case 'f’:
return floatFormat();
case 'p’:
return percentFormat();
}
return defaultFormat();
}
format(int): # @format(int)
cmp edi, 101
jg .LBB0_4
cmp edi, 71
je .LBB0_8
cmp edi, 88
jne .LBB0_8
jmp hexFormat() # TAILCALL
.LBB0_4:
cmp edi, 102
je .LBB0_9
cmp edi, 112
jne .LBB0_8
jmp percentFormat() # TAILCALL
.LBB0_8:
jmp defaultFormat() # TAILCALL
.LBB0_9:
jmp floatFormat() # TAILCALL
22
PGO and switch
char* format(char format)
{
switch (__builtin_expect(format, 'X'))
{
case 'G’:
return defaultFormat();
case 'X’:
return hexFormat();
case 'f’:
return floatFormat();
case 'p’:
return percentFormat();
}
return defaultFormat();
}
format(int): # @format(int)
movsxd rax, edi
cmp rax, 88
jne .LBB0_2
jmp hexFormat() # TAILCALL
.LBB0_2:
cmp rax, 112
je .LBB0_6
cmp rax, 102
je .LBB0_7
cmp rax, 71
jmp defaultFormat() # TAILCALL
.LBB0_6:
jmp percentFormat() # TAILCALL
.LBB0_7:
jmp floatFormat() # TAILCALL
23
PGO and Guarded Devirtualization
static void Foo(IAnimal animal)
{
animal.MakeSound();
}
static void Foo(IAnimal animal)
{
if (animal is Dog dog)
dog.Bark();
else
animal.MakeSound();
}
Mono-LLVM
24
• We use github.com/dotnet/llvm-project fork
• Currently target LLVM 6 but on our way to LLVM 9
• We currently use LLVM for:
• AOT (opt + llc)
• JIT (legacy::PassManager, ORCv1)
Mono-LLVM
25
• `opt –O2` is only for C++
• We have a lot of additional checks: null-checks, bound-checks
• We have to insert safe-points (-place-safepoints) for non-preemptive mode
void MyMethod(byte* array, int len, byte val)
{
if (unlikely(gcRequested))
performGC();
for (int i = 0; i < len; i++)
{
if (unlikely(gcRequested))
performGC();
array[i] = val;
}
if (unlikely(gcRequested))
performGC();
}
How do we use optimizations?
26
• LLVM AOT:
opt -O2 –place-safepoints
• LLVM JIT:
PassManager with a small subset of the most useful passes in a specific order:
-simplifycfg
-sroa
-lower-expect
-instcombine
-licm
-simplifycfg
-lcssa
-indvars
-loop-deletion
-gvn
-memcpyopt
-sccp
-bdce
-instcombine
-dse
-simplifycfg
`opt –O2`: These pass pipelines make a good starting
point for an optimizing compiler for any language, but they
have been carefully tuned for C and C++, not your target
language.
LLVM: tons of optimizations
28
Null-checks, Bound-checks 29
static int Test(int[] array)
{
return array[42];
}
Null-checks, Bound-checks 30
static int Test(int[] array)
{
if (array == null) ThrowNRE();
return array[42];
}
Null-checks, Bound-checks 31
static int Test(int[] array)
{
if (array == null) ThrowNRE();
if ((uint)array.Length <= 42) ThrowOBE();
return array[42];
}
Null-checks, Bound-checks 32
static int Test(int[] array)
{
if (array == null) ThrowNRE();
if ((uint)array.Length <= 42) ThrowOBE();
return array[42];
}
push rax
cmp DWORD PTR [rdi+0x18],0x0
je 1d <Test__int___+0x1d>
mov eax,DWORD PTR [rdi+0x20]
pop rcx
ret
movabs rax,0x1f1f030
mov edi,0xcc
call QWORD PTR [rax]
movabs rax,0x1f1f040
mov edi,0xa6
call QWORD PTR [rax]
InductiveRangeCheckElimination Pass
33
public static void Zero1000Elements(int[] array)
{
for (int i = 0; i < 1000; i++)
array[i] = 0; // bound checks will be inserted here
}
“If you language uses range checks, consider using the
IRCE pass. It is not currently part of the standard pass
order.”
InductiveRangeCheckElimination Pass
34
public static void Zero1000Elements(int[] array)
{
int limit = Math.Min(array.Length, 1000);
for (int i = 0; i < limit; i++)
array[i] = 0; // bound checks are not needed here!
for (int i = limit; i < 1000; i++)
array[i] = 0; // bound checks are needed here
// so at least we could "zero" first `limit` elements without bound checks
}
InductiveRangeCheckElimination Pass
35
public static void Zero1000Elements(int[] array)
{
int limit = Math.Min(array.Length, 1000);
for (int i = 0; i < limit - 3; i += 4)
{
array[i] = 0;
array[i+1] = 0;
array[i+2] = 0;
array[i+3] = 0;
}
for (int i = limit; i < 1000; i++)
array[i] = 0; // bound checks are needed here
// so at least we could "zero" first `limit` elements without bound checks
}
Now we can even unroll the first loop!
System.Runtime.Intrinsics.* 36
static uint Foo(uint x)
{
return Lzcnt.LeadingZeroCount(x);
}
define i32 @Foo(i32 %x)
{
%0 = call i32 @llvm.ctlz.i32(i32 %x, i1 true)
ret i32 %0
}
; x86 with lzcnt
lzcnt eax, edi
ret
; Arm64 (AArch64)
cls w0, w0
ret
System.Runtime.Intrinsics.* 37
int MySum(int[] array)
{
fixed (int* ptr = array)
{
var sum = Vector128<int>.Zero;
for (int i = 0; i < array.Length; i += 4)
{
sum = Sse2.Add(sum, Sse2.LoadVector128(ptr + i));
}
sum = Ssse3.HorizontalAdd(sum, sum);
sum = Ssse3.HorizontalAdd(sum, sum);
return sum.ToScalar();
}
}
G_M55440_IG07: ;; bbWeight=4
movsxd r8, ecx
vpaddd xmm0, xmm0, xmmword ptr [rax+4*r8]
add ecx, 4
cmp edx, ecx
jg SHORT G_M55440_IG07
G_M55440_IG08:
vphaddd xmm0, xmm0, xmm0
vphaddd xmm0, xmm0, xmm0
vmovapd xmmword ptr [rsp+20H], xmm0
mov eax, dword ptr [rsp+20H]
38
[Benchmark]
public bool IsNaN(float value)
{
bool result = false;
for (int i = 0; i < 1000000; i++)
{
result &= float.IsNaN(value);
value += 1.0f;
}
return result;
}
[Benchmark]
public bool IsNaN(float value)
{
return false;
}
What’s wrong with this benchmark?
Pros & Cons
39
• Pros:
• Tons of optimizations, frontends aren’t required to emit optimized IR.
• High MC quality and performance, especially for AArch64!
• A lot of smart people and huge companies invest into LLVM:
• Apple, Google, Samsung, Intel, Microsoft, etc.
• Cons:
• Deadly slow to compile and optimize stuff. LLVM JIT is an oxymoron
(unless it’s used in a tiered compilation)
• LLVM JIT adds 30-50mb to your application
• Not super friendly for managed languages (Precise GC, “movable”
pointers, etc)
Tiered JIT
40
Any AOT
code
around?
Take AOT code
Is it hot ?
Tier0 JIT
ReJIT to Tier1
YES NO
YES
Function
Run
NO
Optimizations… optimizations everywhere!
41
SSA form
Const/Copy prop
BC Removal
Import IL
Insert Bound checks
Inlining
Import C#
Const/Copy prop
Minor peephole opts
Convert to LLVM IR
Loop-related opts
Etc…
Including inlining!
Simplify CFG
SROA
InstCombine
Machine IR opts
Register allocation
Etc…
Roslyn Mono LLVM PassManager DAG, MC, RA
Runtimes for C# (IL):
• .NET Framework 4.x
• JIT
• AOT (Fragile NGEN)
• CoreCLR
• JIT (Tiered)
• AOT (ReadyToRun – R2R)
• Mono
• JIT
• (Full)AOT
• LLVM (AOT, FullAOT, JIT)
• Interpreter
• CoreRT
• Unity IL2CPP
• Unity Burst
Q&Atwitter: EgorBo
blog: EgorBo.com
EgorBo
Senior Software Engineer at Microsoft

More Related Content

What's hot

Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?Andrey Akinshin
 
Travel management
Travel managementTravel management
Travel management1Parimal2
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTsKevlin Henney
 
Network lap pgms 7th semester
Network lap pgms 7th semesterNetwork lap pgms 7th semester
Network lap pgms 7th semesterDOSONKA Group
 
Being functional in PHP (PHPDay Italy 2016)
Being functional in PHP (PHPDay Italy 2016)Being functional in PHP (PHPDay Italy 2016)
Being functional in PHP (PHPDay Italy 2016)David de Boer
 
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...ssuserd6b1fd
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2Amit Kapoor
 
C aptitude scribd
C aptitude scribdC aptitude scribd
C aptitude scribdAmit Kapoor
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...ssuserd6b1fd
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 5 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 5 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 5 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 5 of 5 by...ssuserd6b1fd
 
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!..."A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...akaptur
 
How to not write a boring test in Golang
How to not write a boring test in GolangHow to not write a boring test in Golang
How to not write a boring test in GolangDan Tran
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...ssuserd6b1fd
 
C aptitude.2doc
C aptitude.2docC aptitude.2doc
C aptitude.2docSrikanth
 
Bytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreterBytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreterakaptur
 

What's hot (20)

c programming
c programmingc programming
c programming
 
Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?
 
Travel management
Travel managementTravel management
Travel management
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
 
Network lap pgms 7th semester
Network lap pgms 7th semesterNetwork lap pgms 7th semester
Network lap pgms 7th semester
 
Being functional in PHP (PHPDay Italy 2016)
Being functional in PHP (PHPDay Italy 2016)Being functional in PHP (PHPDay Italy 2016)
Being functional in PHP (PHPDay Italy 2016)
 
pointers 1
pointers 1pointers 1
pointers 1
 
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2
 
c programming
c programmingc programming
c programming
 
C aptitude scribd
C aptitude scribdC aptitude scribd
C aptitude scribd
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 5 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 5 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 5 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 5 of 5 by...
 
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!..."A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
 
How to not write a boring test in Golang
How to not write a boring test in GolangHow to not write a boring test in Golang
How to not write a boring test in Golang
 
Computer Programming- Lecture 4
Computer Programming- Lecture 4Computer Programming- Lecture 4
Computer Programming- Lecture 4
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 2 of 5 by...
 
Captitude 2doc-100627004318-phpapp01
Captitude 2doc-100627004318-phpapp01Captitude 2doc-100627004318-phpapp01
Captitude 2doc-100627004318-phpapp01
 
C aptitude.2doc
C aptitude.2docC aptitude.2doc
C aptitude.2doc
 
Bytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreterBytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreter
 

Similar to Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019

C++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptxC++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptxssuser3cbb4c
 
Chapter Eight(3)
Chapter Eight(3)Chapter Eight(3)
Chapter Eight(3)bolovv
 
Part II: LLVM Intermediate Representation
Part II: LLVM Intermediate RepresentationPart II: LLVM Intermediate Representation
Part II: LLVM Intermediate RepresentationWei-Ren Chen
 
Load-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADLoad-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADDharmalingam Ganesan
 
Windbg랑 친해지기
Windbg랑 친해지기Windbg랑 친해지기
Windbg랑 친해지기Ji Hun Kim
 
How to add an optimization for C# to RyuJIT
How to add an optimization for C# to RyuJITHow to add an optimization for C# to RyuJIT
How to add an optimization for C# to RyuJITEgor Bogatov
 
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPythonByterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPythonakaptur
 
Basic c++ 11/14 for python programmers
Basic c++ 11/14 for python programmersBasic c++ 11/14 for python programmers
Basic c++ 11/14 for python programmersJen Yee Hong
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)Saifur Rahman
 
ITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
ITGM #9 - Коварный CodeType, или от segfault'а к работающему кодуITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
ITGM #9 - Коварный CodeType, или от segfault'а к работающему кодуdelimitry
 
Reverse Engineering Dojo: Enhancing Assembly Reading Skills
Reverse Engineering Dojo: Enhancing Assembly Reading SkillsReverse Engineering Dojo: Enhancing Assembly Reading Skills
Reverse Engineering Dojo: Enhancing Assembly Reading SkillsAsuka Nakajima
 
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate CompilersFunctional Thursday
 
Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performanceDuoyi Wu
 
MuVM: Higher Order Mutation Analysis Virtual Machine for C
MuVM: Higher Order Mutation Analysis Virtual Machine for CMuVM: Higher Order Mutation Analysis Virtual Machine for C
MuVM: Higher Order Mutation Analysis Virtual Machine for CSusumu Tokumoto
 
Getting started cpp full
Getting started cpp   fullGetting started cpp   full
Getting started cpp fullVõ Hòa
 
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)changehee lee
 

Similar to Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019 (20)

C++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptxC++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptx
 
Chapter Eight(3)
Chapter Eight(3)Chapter Eight(3)
Chapter Eight(3)
 
Part II: LLVM Intermediate Representation
Part II: LLVM Intermediate RepresentationPart II: LLVM Intermediate Representation
Part II: LLVM Intermediate Representation
 
Boosting Developer Productivity with Clang
Boosting Developer Productivity with ClangBoosting Developer Productivity with Clang
Boosting Developer Productivity with Clang
 
Load-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADLoad-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOAD
 
GCC
GCCGCC
GCC
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Windbg랑 친해지기
Windbg랑 친해지기Windbg랑 친해지기
Windbg랑 친해지기
 
How to add an optimization for C# to RyuJIT
How to add an optimization for C# to RyuJITHow to add an optimization for C# to RyuJIT
How to add an optimization for C# to RyuJIT
 
Faster Python, FOSDEM
Faster Python, FOSDEMFaster Python, FOSDEM
Faster Python, FOSDEM
 
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPythonByterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
 
Basic c++ 11/14 for python programmers
Basic c++ 11/14 for python programmersBasic c++ 11/14 for python programmers
Basic c++ 11/14 for python programmers
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)
 
ITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
ITGM #9 - Коварный CodeType, или от segfault'а к работающему кодуITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
ITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
 
Reverse Engineering Dojo: Enhancing Assembly Reading Skills
Reverse Engineering Dojo: Enhancing Assembly Reading SkillsReverse Engineering Dojo: Enhancing Assembly Reading Skills
Reverse Engineering Dojo: Enhancing Assembly Reading Skills
 
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
 
Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performance
 
MuVM: Higher Order Mutation Analysis Virtual Machine for C
MuVM: Higher Order Mutation Analysis Virtual Machine for CMuVM: Higher Order Mutation Analysis Virtual Machine for C
MuVM: Higher Order Mutation Analysis Virtual Machine for C
 
Getting started cpp full
Getting started cpp   fullGetting started cpp   full
Getting started cpp full
 
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
개발 과정 최적화 하기 내부툴로 더욱 강력한 개발하기 Stephen kennedy _(11시40분_103호)
 

More from corehard_by

C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...corehard_by
 
C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...
C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...
C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...corehard_by
 
C++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений Охотников
C++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений ОхотниковC++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений Охотников
C++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений Охотниковcorehard_by
 
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титов
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр ТитовC++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титов
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титовcorehard_by
 
C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...
C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...
C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...corehard_by
 
C++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья Шишков
C++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья ШишковC++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья Шишков
C++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья Шишковcorehard_by
 
C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...
C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...
C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...corehard_by
 
C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...
C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...
C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...corehard_by
 
C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...
C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...
C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...corehard_by
 
C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...
C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...
C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...corehard_by
 
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...corehard_by
 
C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...
C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...
C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...corehard_by
 
C++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел Филонов
C++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел ФилоновC++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел Филонов
C++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел Филоновcorehard_by
 
C++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan Čukić
C++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan ČukićC++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan Čukić
C++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan Čukićcorehard_by
 
C++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia Kazakova
C++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia KazakovaC++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia Kazakova
C++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia Kazakovacorehard_by
 
C++ CoreHard Autumn 2018. Полезный constexpr - Антон Полухин
C++ CoreHard Autumn 2018. Полезный constexpr - Антон ПолухинC++ CoreHard Autumn 2018. Полезный constexpr - Антон Полухин
C++ CoreHard Autumn 2018. Полезный constexpr - Антон Полухинcorehard_by
 
C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...
C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...
C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...corehard_by
 
Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019
Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019
Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019corehard_by
 
Как помочь и как помешать компилятору. Андрей Олейников ➠ CoreHard Autumn 2019
Как помочь и как помешать компилятору. Андрей Олейников ➠  CoreHard Autumn 2019Как помочь и как помешать компилятору. Андрей Олейников ➠  CoreHard Autumn 2019
Как помочь и как помешать компилятору. Андрей Олейников ➠ CoreHard Autumn 2019corehard_by
 
Автоматизируй это. Кирилл Тихонов ➠ CoreHard Autumn 2019
Автоматизируй это. Кирилл Тихонов ➠  CoreHard Autumn 2019Автоматизируй это. Кирилл Тихонов ➠  CoreHard Autumn 2019
Автоматизируй это. Кирилл Тихонов ➠ CoreHard Autumn 2019corehard_by
 

More from corehard_by (20)

C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
C++ CoreHard Autumn 2018. Создание пакетов для открытых библиотек через conan...
 
C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...
C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...
C++ CoreHard Autumn 2018. Что должен знать каждый C++ программист или Как про...
 
C++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений Охотников
C++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений ОхотниковC++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений Охотников
C++ CoreHard Autumn 2018. Actors vs CSP vs Tasks vs ... - Евгений Охотников
 
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титов
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр ТитовC++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титов
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титов
 
C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...
C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...
C++ CoreHard Autumn 2018. Информационная безопасность и разработка ПО - Евген...
 
C++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья Шишков
C++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья ШишковC++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья Шишков
C++ CoreHard Autumn 2018. Заглядываем под капот «Поясов по C++» - Илья Шишков
 
C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...
C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...
C++ CoreHard Autumn 2018. Ускорение сборки C++ проектов, способы и последстви...
 
C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...
C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...
C++ CoreHard Autumn 2018. Метаклассы: воплощаем мечты в реальность - Сергей С...
 
C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...
C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...
C++ CoreHard Autumn 2018. Что не умеет оптимизировать компилятор - Александр ...
 
C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...
C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...
C++ CoreHard Autumn 2018. Кодогенерация C++ кроссплатформенно. Продолжение - ...
 
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
 
C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...
C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...
C++ CoreHard Autumn 2018. Обработка списков на C++ в функциональном стиле - В...
 
C++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел Филонов
C++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел ФилоновC++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел Филонов
C++ Corehard Autumn 2018. Обучаем на Python, применяем на C++ - Павел Филонов
 
C++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan Čukić
C++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan ČukićC++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan Čukić
C++ CoreHard Autumn 2018. Asynchronous programming with ranges - Ivan Čukić
 
C++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia Kazakova
C++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia KazakovaC++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia Kazakova
C++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia Kazakova
 
C++ CoreHard Autumn 2018. Полезный constexpr - Антон Полухин
C++ CoreHard Autumn 2018. Полезный constexpr - Антон ПолухинC++ CoreHard Autumn 2018. Полезный constexpr - Антон Полухин
C++ CoreHard Autumn 2018. Полезный constexpr - Антон Полухин
 
C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...
C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...
C++ CoreHard Autumn 2018. Text Formatting For a Future Range-Based Standard L...
 
Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019
Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019
Исключительная модель памяти. Алексей Ткаченко ➠ CoreHard Autumn 2019
 
Как помочь и как помешать компилятору. Андрей Олейников ➠ CoreHard Autumn 2019
Как помочь и как помешать компилятору. Андрей Олейников ➠  CoreHard Autumn 2019Как помочь и как помешать компилятору. Андрей Олейников ➠  CoreHard Autumn 2019
Как помочь и как помешать компилятору. Андрей Олейников ➠ CoreHard Autumn 2019
 
Автоматизируй это. Кирилл Тихонов ➠ CoreHard Autumn 2019
Автоматизируй это. Кирилл Тихонов ➠  CoreHard Autumn 2019Автоматизируй это. Кирилл Тихонов ➠  CoreHard Autumn 2019
Автоматизируй это. Кирилл Тихонов ➠ CoreHard Autumn 2019
 

Recently uploaded

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 

Recently uploaded (20)

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 

Как работает LLVM бэкенд в C#. Егор Богатов ➠ CoreHard Autumn 2019

  • 1. LLVM back-end for C# @EgorBo Senior Software Engineer at Microsoft
  • 2. LLVMJIT/AOTRoslyn Mono-LLVM: quick intro 2 C# IL (.dll) mini IR LLVM IR MIR F#
  • 3. LLVM: C# to MC 3 int MyAdd(int a, int b) { return a + b; } .method private hidebysig static int32 MyAdd ( int32 a, int32 b ) cil managed { IL_0000: ldarg.0 IL_0001: ldarg.1 IL_0002: add IL_0003: ret } Roslyn
  • 4. LLVM: C# to MC 4 define monocc i32 @"Program:MyAdd (int,int)" (i32 %arg_a, i32 %arg_b) { BB0: br label %BB3 BB3: br label %BB2 BB2: %t22 = add i32 %arg_a, %arg_b br label %BB1 BB1: ret i32 %t22 } .method private hidebysig static int32 MyAdd ( int32 a, int32 b ) cil managed { IL_0000: ldarg.0 IL_0001: ldarg.1 IL_0002: add IL_0003: ret } mini
  • 5. LLVM: C# to MC 5 define monocc i32 @"Program:MyAdd (int,int)" (i32 %arg_a, i32 %arg_b) { BB0: br label %BB3 BB3: br label %BB2 BB2: %t22 = add i32 %arg_a, %arg_b br label %BB1 BB1: ret i32 %t22 } .method private hidebysig static int32 MyAdd ( int32 a, int32 b ) cil managed { IL_0000: ldarg.0 IL_0001: ldarg.1 IL_0002: add IL_0003: ret } mini (simplifycfg)
  • 6. LLVM: C# to MC 6 define monocc i32 @"Program:MyAdd (int,int)"(i32 %arg_a, i32 %arg_b) #0 { BB0: %t22 = add i32 %arg_a, %arg_b ret i32 %t22 } lea eax, [rdi + rsi] ret llc (I am skipping the machine IR part)
  • 7. LLVM: C# to MC 7 void MySet(byte* array, int len, byte val) { for (int i = 0; i < len; i++) array[i] = val; } define monocc void @"MySet"(i8* %arg_array, i32 %arg_len, i32 %arg_val) #0 { BB0: br label %BB3 BB3: br label %BB2 BB2: br label %BB4 BB4: %0 = phi i32 [ 0, %BB2 ], [ %t32, %BB5 ] %1 = icmp slt i32 %0, %arg_len br i1 %1, label %BB5, label %BB6 BB6: br label %BB1 BB5: %t23 = sext i32 %0 to i64 %3 = getelementptr i8, i8* %arg_array, i64 %t23 %4 = trunc i32 %arg_val to i8 store i8 %4, i8* %3 %t32 = add i32 %0, 1 br label %BB4 BB1: ret void } mini
  • 8. 8 define monocc void @"MySet"(i8* %arg_array, i32 %arg_len, i32 %arg_val) #0 { BB0: br label %BB3 BB3: br label %BB2 BB2: br label %BB4 BB4: %0 = phi i32 [ 0, %BB2 ], [ %t32, %BB5 ] %1 = icmp slt i32 %0, %arg_len br i1 %1, label %BB5, label %BB6 BB6: br label %BB1 BB5: %t23 = sext i32 %0 to i64 %3 = getelementptr i8, i8* %arg_array, i64 %t23 %4 = trunc i32 %arg_val to i8 store i8 %4, i8* %3 %t32 = add i32 %0, 1 br label %BB4 BB1: ret void } opt define monocc void @"MySet"(i8* %arg_array, i32 %arg_len, i32 %arg_val) #0 { BB0: %0 = icmp sgt i32 %arg_len, 0 br i1 %0, label %BB5.lr.ph, label %BB1 BB5.lr.ph: %1 = trunc i32 %arg_val to i8 %2 = zext i32 %arg_len to i64 call void @llvm.memset.p0i8.i64(i8* %arg_array, i8 %1, i64 %2…) br label %BB1 BB1: ret void }
  • 9. LLVM needs hints from front-ends 9 • Alias-analysis (`noalias`, TBAA, etc) • PGO-data and @llvm.expect (branch-weights) • Use GEPs where possible instead of `ptrtoint+add+inttoptr` • Language specific order of optimization passes (maybe even custom passes) • Alignment hints • FaultMaps and implicit null-checks • Use LLVM intrinsics where needed (libcalls, HW intrinsics, etc) • Don’t forget about Fast-Math! • NIT: Nullability, Escape analysis, etc
  • 11. LLVM: ffast-math 11 float result = (x / 10) + 1 + 1; CoreCLR, Mono, C++ -O2 Mono-LLVM (--llvm --ffast-math) vfmadd132sd xmm0, xmm1, QWORD PTR .LC0[rip]vdivsd xmm0, xmm0, QWORD PTR .LC0[rip] vaddsd xmm0, xmm0, xmm1 vaddsd xmm0, xmm0, xmm1 float result = (x / 10) + 2; float result = (x * 0.1) + 2; float result = fmadd(x, 0.1, 2); 1 2 3 4
  • 12. LLVM: ffast-math 12 • No NaNs (NOTE: some apps rely on NaN values, e.g. WPF) • No Infs • No Signed Zeros (e.g. Math.Max(-0.0, 0.0) will return -0.0) • Approximate functions • Recognize FMA patterns (a * b + c) • Reassociation transformations (x + c1 + c2 => x + (c1 + c2))
  • 13. C# Math/MathF are LLVM intrinsics! 13 static float Foo(float x) { return MathF.Sqrt(x) * MathF.Sqrt(x); } define float @"Foo“ (float %arg_x) { BB0: br label %BB3 BB3: br label %BB2 BB2: %t19 = call fast float @llvm.sqrt.f32(float %arg_x) %t21 = call fast float @llvm.sqrt.f32(float %arg_x) %t22 = fmul fast float %t19, %t21 br label %BB1 BB1: ret float %t22 } declare float @llvm.sqrt.f32(float) Emit LLVM IR
  • 14. C# Math/MathF are LLVM intrinsics! 14 define float @"Foo“ (float %arg_x) { BB0: br label %BB3 BB3: br label %BB2 BB2: %t19 = call fast float @llvm.sqrt.f32(float %arg_x) %t21 = call fast float @llvm.sqrt.f32(float %arg_x) %t22 = fmul fast float %t19, %t21 br label %BB1 BB1: ret float %t22 } declare float @llvm.sqrt.f32(float) define float @"Foo“ (float %arg_x) { BB0: ret float %arg_x } opt
  • 15. C# Math/MathF are LLVM intrinsics! 15 Math.Abs(X) * Math.Abs(X) => X * X Math.Sin(X) / Math.Cos(X) => Math.Tan(X) Math.Sqrt(X) * Math.Sqrt(X) => X Math.Sin(-X) => -Math.Sin(X) MathF.Pow(X, 0.5f) => MathF.Sqrt(X) MathF.Pow(X, 2) => X * X MathF.Pow(X, 4) => (X * X) * (X * X)
  • 16. Significant boost in some FP benchmarks: 16 (CPU without FMA)
  • 17. One of those benchmarks (Lorenz equations): 17
  • 18. Don’t forget to feed the LLVM! with some PGO data for better codegen 18
  • 19. 19static int Max(int x, int y) { return x > y ? x : y; } !0 = !{!"branch_weights", i32 1000, i32 1} Default With profile data (PGO) mov eax, esi cmp edi, esi cmovge eax, edi ret define i32 @Max(i32 %0, i32 %1) { %3 = icmp sgt i32 %0, %1 %4 = select i1 %3, i32 %0, i32 %1 ret i32 %4 } define i32 @Max(i32 %0, i32 %1) { %3 = icmp sgt i32 %0, %1 !prof 0 %4 = select i1 %3, i32 %0, i32 %1 ret i32 %4 } mov eax, edi cmp edi, esi jle .LBB1_1 ret .LBB1_1: mov eax, esi ret
  • 20. 20
  • 21. 21 PGO and switch char* format(char format) { switch (format) { case 'G’: return defaultFormat(); case 'X’: return hexFormat(); case 'f’: return floatFormat(); case 'p’: return percentFormat(); } return defaultFormat(); } format(int): # @format(int) cmp edi, 101 jg .LBB0_4 cmp edi, 71 je .LBB0_8 cmp edi, 88 jne .LBB0_8 jmp hexFormat() # TAILCALL .LBB0_4: cmp edi, 102 je .LBB0_9 cmp edi, 112 jne .LBB0_8 jmp percentFormat() # TAILCALL .LBB0_8: jmp defaultFormat() # TAILCALL .LBB0_9: jmp floatFormat() # TAILCALL
  • 22. 22 PGO and switch char* format(char format) { switch (__builtin_expect(format, 'X')) { case 'G’: return defaultFormat(); case 'X’: return hexFormat(); case 'f’: return floatFormat(); case 'p’: return percentFormat(); } return defaultFormat(); } format(int): # @format(int) movsxd rax, edi cmp rax, 88 jne .LBB0_2 jmp hexFormat() # TAILCALL .LBB0_2: cmp rax, 112 je .LBB0_6 cmp rax, 102 je .LBB0_7 cmp rax, 71 jmp defaultFormat() # TAILCALL .LBB0_6: jmp percentFormat() # TAILCALL .LBB0_7: jmp floatFormat() # TAILCALL
  • 23. 23 PGO and Guarded Devirtualization static void Foo(IAnimal animal) { animal.MakeSound(); } static void Foo(IAnimal animal) { if (animal is Dog dog) dog.Bark(); else animal.MakeSound(); }
  • 24. Mono-LLVM 24 • We use github.com/dotnet/llvm-project fork • Currently target LLVM 6 but on our way to LLVM 9 • We currently use LLVM for: • AOT (opt + llc) • JIT (legacy::PassManager, ORCv1)
  • 25. Mono-LLVM 25 • `opt –O2` is only for C++ • We have a lot of additional checks: null-checks, bound-checks • We have to insert safe-points (-place-safepoints) for non-preemptive mode void MyMethod(byte* array, int len, byte val) { if (unlikely(gcRequested)) performGC(); for (int i = 0; i < len; i++) { if (unlikely(gcRequested)) performGC(); array[i] = val; } if (unlikely(gcRequested)) performGC(); }
  • 26. How do we use optimizations? 26 • LLVM AOT: opt -O2 –place-safepoints • LLVM JIT: PassManager with a small subset of the most useful passes in a specific order: -simplifycfg -sroa -lower-expect -instcombine -licm -simplifycfg -lcssa -indvars -loop-deletion -gvn -memcpyopt -sccp -bdce -instcombine -dse -simplifycfg `opt –O2`: These pass pipelines make a good starting point for an optimizing compiler for any language, but they have been carefully tuned for C and C++, not your target language.
  • 27.
  • 28. LLVM: tons of optimizations 28
  • 29. Null-checks, Bound-checks 29 static int Test(int[] array) { return array[42]; }
  • 30. Null-checks, Bound-checks 30 static int Test(int[] array) { if (array == null) ThrowNRE(); return array[42]; }
  • 31. Null-checks, Bound-checks 31 static int Test(int[] array) { if (array == null) ThrowNRE(); if ((uint)array.Length <= 42) ThrowOBE(); return array[42]; }
  • 32. Null-checks, Bound-checks 32 static int Test(int[] array) { if (array == null) ThrowNRE(); if ((uint)array.Length <= 42) ThrowOBE(); return array[42]; } push rax cmp DWORD PTR [rdi+0x18],0x0 je 1d <Test__int___+0x1d> mov eax,DWORD PTR [rdi+0x20] pop rcx ret movabs rax,0x1f1f030 mov edi,0xcc call QWORD PTR [rax] movabs rax,0x1f1f040 mov edi,0xa6 call QWORD PTR [rax]
  • 33. InductiveRangeCheckElimination Pass 33 public static void Zero1000Elements(int[] array) { for (int i = 0; i < 1000; i++) array[i] = 0; // bound checks will be inserted here } “If you language uses range checks, consider using the IRCE pass. It is not currently part of the standard pass order.”
  • 34. InductiveRangeCheckElimination Pass 34 public static void Zero1000Elements(int[] array) { int limit = Math.Min(array.Length, 1000); for (int i = 0; i < limit; i++) array[i] = 0; // bound checks are not needed here! for (int i = limit; i < 1000; i++) array[i] = 0; // bound checks are needed here // so at least we could "zero" first `limit` elements without bound checks }
  • 35. InductiveRangeCheckElimination Pass 35 public static void Zero1000Elements(int[] array) { int limit = Math.Min(array.Length, 1000); for (int i = 0; i < limit - 3; i += 4) { array[i] = 0; array[i+1] = 0; array[i+2] = 0; array[i+3] = 0; } for (int i = limit; i < 1000; i++) array[i] = 0; // bound checks are needed here // so at least we could "zero" first `limit` elements without bound checks } Now we can even unroll the first loop!
  • 36. System.Runtime.Intrinsics.* 36 static uint Foo(uint x) { return Lzcnt.LeadingZeroCount(x); } define i32 @Foo(i32 %x) { %0 = call i32 @llvm.ctlz.i32(i32 %x, i1 true) ret i32 %0 } ; x86 with lzcnt lzcnt eax, edi ret ; Arm64 (AArch64) cls w0, w0 ret
  • 37. System.Runtime.Intrinsics.* 37 int MySum(int[] array) { fixed (int* ptr = array) { var sum = Vector128<int>.Zero; for (int i = 0; i < array.Length; i += 4) { sum = Sse2.Add(sum, Sse2.LoadVector128(ptr + i)); } sum = Ssse3.HorizontalAdd(sum, sum); sum = Ssse3.HorizontalAdd(sum, sum); return sum.ToScalar(); } } G_M55440_IG07: ;; bbWeight=4 movsxd r8, ecx vpaddd xmm0, xmm0, xmmword ptr [rax+4*r8] add ecx, 4 cmp edx, ecx jg SHORT G_M55440_IG07 G_M55440_IG08: vphaddd xmm0, xmm0, xmm0 vphaddd xmm0, xmm0, xmm0 vmovapd xmmword ptr [rsp+20H], xmm0 mov eax, dword ptr [rsp+20H]
  • 38. 38 [Benchmark] public bool IsNaN(float value) { bool result = false; for (int i = 0; i < 1000000; i++) { result &= float.IsNaN(value); value += 1.0f; } return result; } [Benchmark] public bool IsNaN(float value) { return false; } What’s wrong with this benchmark?
  • 39. Pros & Cons 39 • Pros: • Tons of optimizations, frontends aren’t required to emit optimized IR. • High MC quality and performance, especially for AArch64! • A lot of smart people and huge companies invest into LLVM: • Apple, Google, Samsung, Intel, Microsoft, etc. • Cons: • Deadly slow to compile and optimize stuff. LLVM JIT is an oxymoron (unless it’s used in a tiered compilation) • LLVM JIT adds 30-50mb to your application • Not super friendly for managed languages (Precise GC, “movable” pointers, etc)
  • 40. Tiered JIT 40 Any AOT code around? Take AOT code Is it hot ? Tier0 JIT ReJIT to Tier1 YES NO YES Function Run NO
  • 41. Optimizations… optimizations everywhere! 41 SSA form Const/Copy prop BC Removal Import IL Insert Bound checks Inlining Import C# Const/Copy prop Minor peephole opts Convert to LLVM IR Loop-related opts Etc… Including inlining! Simplify CFG SROA InstCombine Machine IR opts Register allocation Etc… Roslyn Mono LLVM PassManager DAG, MC, RA
  • 42. Runtimes for C# (IL): • .NET Framework 4.x • JIT • AOT (Fragile NGEN) • CoreCLR • JIT (Tiered) • AOT (ReadyToRun – R2R) • Mono • JIT • (Full)AOT • LLVM (AOT, FullAOT, JIT) • Interpreter • CoreRT • Unity IL2CPP • Unity Burst
  • 43. Q&Atwitter: EgorBo blog: EgorBo.com EgorBo Senior Software Engineer at Microsoft