Skip to content

Instantly share code, notes, and snippets.

@filipnavara
Created August 27, 2019 19:57
Show Gist options
  • Save filipnavara/4c89ced279f89083f2fd1d6bf3292b06 to your computer and use it in GitHub Desktop.
Save filipnavara/4c89ced279f89083f2fd1d6bf3292b06 to your computer and use it in GitHub Desktop.
*** Unoptimized LLVM IR for System.Number:TryInt32ToHexStr ***
; Function Attrs: uwtable
define monocc i8 @"System.Number:TryInt32ToHexStr (int,char,int,System.Span`1<char>,int&)"(i32 %arg_value, i32 %arg_hexBase, i32 %arg_digits, i64 %arg_destination, i64, i64* %arg_charsWritten) #0 {
BB0:
%1 = alloca %"System.Span`1<char>", align 8
%2 = alloca %"System.Span`1<char>", align 8
%3 = alloca %"System.Span`1<char>", align 8
%4 = bitcast %"System.Span`1<char>"* %1 to i64*
%5 = getelementptr i64, i64* %4, i32 0
store i64 %arg_destination, i64* %5
%6 = bitcast %"System.Span`1<char>"* %1 to i64*
%7 = getelementptr i64, i64* %6, i32 1
store i64 %0, i64* %7
%8 = load volatile i64, i64* inttoptr (i64 4321543032 to i64*)
%9 = icmp eq i64 %8, 0
%10 = call i1 @llvm.expect.i1(i1 %9, i1 true)
br i1 %10, label %CONT_BB2, label %POLL_BB1
POLL_BB1: ; preds = %BB0
%11 = load void ()*, void ()** @mono_threads_state_poll
call coldcc void %11()
br label %CONT_BB2
CONT_BB2: ; preds = %POLL_BB1, %BB0
br label %BB3
BB3: ; preds = %CONT_BB2
br label %BB2
BB2: ; preds = %BB3
%12 = icmp sge i32 %arg_digits, 1
br i1 %12, label %BB4, label %BB5
BB4: ; preds = %BB5, %BB2
%13 = phi i32 [ %arg_digits, %BB2 ], [ 1, %BB5 ]
%t33 = zext i32 %arg_value to i64
br label %BB11
BB5: ; preds = %BB2
br label %BB4
BB11: ; preds = %BB4
%t41 = or i64 %t33, 1
br label %BB16
BB16: ; preds = %BB11
br i1 false, label %BB18, label %BB19
BB18: ; preds = %BB16
%t48 = lshr i64 %t41, 32
%14 = trunc i64 %t48 to i32
%t288 = lshr i32 %14, 0
%15 = icmp ne i32 %t288, 0
br i1 %15, label %BB20, label %BB21
BB19: ; preds = %BB16
%16 = call i64 @llvm.ctlz.i64(i64 %t41)
%17 = trunc i64 %16 to i32
%t39 = sext i32 %17 to i64
%18 = trunc i64 %t39 to i32
br label %BB15
BB20: ; preds = %BB18
br label %BB53
BB21: ; preds = %BB18
%19 = trunc i64 %t41 to i32
%t55 = lshr i32 %19, 0
br label %BB25
BB53: ; preds = %BB20
br i1 false, label %BB55, label %BB56
BB55: ; preds = %BB53
%20 = icmp ne i32 %t288, 0
br i1 %20, label %BB57, label %BB58
BB56: ; preds = %BB53
%21 = call i32 @llvm.ctlz.i32(i32 %t288)
br label %BB52
BB57: ; preds = %BB55
%22 = load i32 (i32)*, i32 (i32)** @tramp_3132
%23 = notail call monocc i32 %22(i32 %t288)
%t296 = sub i32 31, %23
br label %BB52
BB58: ; preds = %BB55
br label %BB52
BB52: ; preds = %BB56, %BB58, %BB57
%24 = phi i32 [ %21, %BB56 ], [ 32, %BB58 ], [ %t296, %BB57 ]
br label %BB15
BB15: ; preds = %BB19, %BB24, %BB52
%25 = phi i32 [ %18, %BB19 ], [ %t290, %BB24 ], [ %24, %BB52 ]
%t181 = sub i32 64, %25
%t183 = add i32 %t181, 3
%t186 = ashr i32 %t183, 2
%26 = icmp sge i32 %13, %t186
%t22 = select i1 %26, i32 %13, i32 %t186
%27 = bitcast %"System.Span`1<char>"* %1 to i32*
%28 = getelementptr i32, i32* %27, i32 2
%t190 = load i32, i32* %28
%29 = icmp sle i32 %t22, %t190
br i1 %29, label %BB6, label %BB7
BB6: ; preds = %BB15
%30 = bitcast i64* %arg_charsWritten to i32*
%31 = getelementptr i32, i32* %30, i32 0
store i32 %t22, i32* %31
%32 = bitcast %"System.Span`1<char>"* %1 to i8*
%33 = bitcast %"System.Span`1<char>"* %2 to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %33, i8* %32, i32 16, i32 0, i1 false)
%34 = bitcast %"System.Span`1<char>"* %2 to i64*
%t24 = load i64, i64* %34
%t207 = sext i32 %t22 to i64
%t209 = shl i64 %t207, 1
%t216 = add i64 %t24, %t209
%35 = inttoptr i64 %t216 to i64*
br label %BB86
BB7: ; preds = %BB15
%36 = bitcast i64* %arg_charsWritten to i32*
%37 = getelementptr i32, i32* %36, i32 0
store i32 0, i32* %37
br label %BB1
BB86: ; preds = %BB6
br label %BB88
BB88: ; preds = %BB92, %BB86
%38 = phi i32 [ %13, %BB86 ], [ %t256, %BB92 ]
%39 = phi i32 [ %arg_value, %BB86 ], [ %t284, %BB92 ]
%40 = phi i64* [ %35, %BB86 ], [ %49, %BB92 ]
%t256 = sub i32 %38, 1
%41 = icmp sge i32 %t256, 0
br i1 %41, label %BB89, label %BB93
BB89: ; preds = %BB93, %BB88
%42 = load volatile i64, i64* inttoptr (i64 4321543032 to i64*)
%43 = icmp eq i64 %42, 0
%44 = call i1 @llvm.expect.i1(i1 %43, i1 true)
br i1 %44, label %CONT_BB4, label %POLL_BB3
BB93: ; preds = %BB88
%45 = icmp ne i32 %39, 0
br i1 %45, label %BB89, label %BB94
POLL_BB3: ; preds = %BB89
%46 = load void ()*, void ()** @mono_threads_state_poll.1
call coldcc void %46()
br label %CONT_BB4
CONT_BB4: ; preds = %POLL_BB3, %BB89
%t222 = and i32 %39, 15
%47 = trunc i32 %t222 to i8
%t279 = zext i8 %47 to i32
%48 = ptrtoint i64* %40 to i64
%t228 = sub i64 %48, 2
%49 = inttoptr i64 %t228 to i64*
%50 = icmp slt i32 %t279, 10
br i1 %50, label %BB90, label %BB91
BB90: ; preds = %CONT_BB4
br label %BB92
BB91: ; preds = %CONT_BB4
br label %BB92
BB92: ; preds = %BB91, %BB90
%51 = phi i32 [ %arg_hexBase, %BB91 ], [ 48, %BB90 ]
%52 = phi i32 [ %t279, %BB91 ], [ %t279, %BB90 ]
%53 = phi i64 [ %t228, %BB91 ], [ %t228, %BB90 ]
%t248 = add i32 %52, %51
%54 = inttoptr i64 %53 to i16*
%55 = getelementptr i16, i16* %54, i32 0
%56 = trunc i32 %t248 to i16
store i16 %56, i16* %55
%t284 = lshr i32 %39, 4
br label %BB88
BB94: ; preds = %BB93
br label %BB1
BB1: ; preds = %BB7, %BB94
%57 = phi i32 [ 0, %BB7 ], [ 1, %BB94 ]
%58 = trunc i32 %57 to i8
ret i8 %58
BB25: ; preds = %BB21
br i1 false, label %BB27, label %BB28
BB27: ; preds = %BB25
%59 = icmp ne i32 %t55, 0
br i1 %59, label %BB29, label %BB30
BB28: ; preds = %BB25
%60 = call i32 @llvm.ctlz.i32(i32 %t55)
br label %BB24
BB29: ; preds = %BB27
%61 = load i32 (i32)*, i32 (i32)** @tramp_3132
%62 = notail call monocc i32 %61(i32 %t55)
%t292 = sub i32 31, %62
br label %BB24
BB30: ; preds = %BB27
br label %BB24
BB24: ; preds = %BB28, %BB30, %BB29
%63 = phi i32 [ %60, %BB28 ], [ 32, %BB30 ], [ %t292, %BB29 ]
%t290 = add i32 32, %63
br label %BB15
}
***
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment