Skip to content

Instantly share code, notes, and snippets.

@glandium
Created March 23, 2018 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glandium/b7bd384139b6a58fb68c03bc420a566f to your computer and use it in GitHub Desktop.
Save glandium/b7bd384139b6a58fb68c03bc420a566f to your computer and use it in GitHub Desktop.
; ModuleID = 'testor0-9c9d9e3b33a06dc7e3cd9cbd93f9c9d.rs'
source_filename = "testor0-9c9d9e3b33a06dc7e3cd9cbd93f9c9d.rs"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%"core::option::Option<usize>" = type { [2 x i64] }
%"core::result::Result<usize, core::option::NoneError>" = type { [2 x i64] }
%"unwind::libunwind::_Unwind_Exception" = type { [0 x i64], i64, [0 x i64], void (i32, %"unwind::libunwind::_Unwind_Exception"*)*, [0 x i64], [6 x i64], [0 x i64] }
%"unwind::libunwind::_Unwind_Context" = type { [0 x i8] }
@str.2 = internal constant [9 x i8] c"85af342b1"
; testor::parse_hex
; Function Attrs: noinline uwtable
define internal fastcc void @_ZN6testor9parse_hex17h3af8dfc46349cc2dE(%"core::option::Option<usize>"* noalias nocapture dereferenceable(16)) unnamed_addr #0 personality i32 (i32, i32, i64, %"unwind::libunwind::_Unwind_Exception"*, %"unwind::libunwind::_Unwind_Context"*)* @rust_eh_personality {
start:
%_30 = alloca %"core::result::Result<usize, core::option::NoneError>", align 8
%1 = bitcast %"core::result::Result<usize, core::option::NoneError>"* %_30 to i8*
%2 = getelementptr inbounds %"core::result::Result<usize, core::option::NoneError>", %"core::result::Result<usize, core::option::NoneError>"* %_30, i64 0, i32 0, i64 0
%3 = getelementptr inbounds %"core::result::Result<usize, core::option::NoneError>", %"core::result::Result<usize, core::option::NoneError>"* %_30, i64 0, i32 0, i64 1
br label %"_ZN5alloc5slice29_$LT$impl$u20$$u5b$T$u5d$$GT$11split_first17h88f6fd10d9762355E.exit.lr.ph"
"_ZN5alloc5slice29_$LT$impl$u20$$u5b$T$u5d$$GT$11split_first17h88f6fd10d9762355E.exit.lr.ph": ; preds = %start, %bb23
%s.sroa.0.0.ph48 = phi [0 x i8]* [ bitcast ([9 x i8]* @str.2 to [0 x i8]*), %start ], [ %7, %bb23 ]
%s.sroa.6.0.ph47 = phi i64 [ 9, %start ], [ %5, %bb23 ]
%result.sroa.0.0.ph46 = phi i64 [ 0, %start ], [ 1, %bb23 ]
%result.sroa.7.0.ph45 = phi i64 [ undef, %start ], [ %24, %bb23 ]
br label %"_ZN5alloc5slice29_$LT$impl$u20$$u5b$T$u5d$$GT$11split_first17h88f6fd10d9762355E.exit"
bb1: ; preds = %bb14
%4 = icmp eq i64 %5, 0
br i1 %4, label %bb15.loopexit, label %"_ZN5alloc5slice29_$LT$impl$u20$$u5b$T$u5d$$GT$11split_first17h88f6fd10d9762355E.exit"
"_ZN5alloc5slice29_$LT$impl$u20$$u5b$T$u5d$$GT$11split_first17h88f6fd10d9762355E.exit": ; preds = %"_ZN5alloc5slice29_$LT$impl$u20$$u5b$T$u5d$$GT$11split_first17h88f6fd10d9762355E.exit.lr.ph", %bb1
%s.sroa.0.035 = phi [0 x i8]* [ %s.sroa.0.0.ph48, %"_ZN5alloc5slice29_$LT$impl$u20$$u5b$T$u5d$$GT$11split_first17h88f6fd10d9762355E.exit.lr.ph" ], [ %7, %bb1 ]
%s.sroa.6.034 = phi i64 [ %s.sroa.6.0.ph47, %"_ZN5alloc5slice29_$LT$impl$u20$$u5b$T$u5d$$GT$11split_first17h88f6fd10d9762355E.exit.lr.ph" ], [ %5, %bb1 ]
%result.sroa.0.033 = phi i64 [ %result.sroa.0.0.ph46, %"_ZN5alloc5slice29_$LT$impl$u20$$u5b$T$u5d$$GT$11split_first17h88f6fd10d9762355E.exit.lr.ph" ], [ 1, %bb1 ]
%result.sroa.7.032 = phi i64 [ %result.sroa.7.0.ph45, %"_ZN5alloc5slice29_$LT$impl$u20$$u5b$T$u5d$$GT$11split_first17h88f6fd10d9762355E.exit.lr.ph" ], [ %15, %bb1 ]
%5 = add i64 %s.sroa.6.034, -1
%not. = icmp eq [0 x i8]* %s.sroa.0.035, null
br i1 %not., label %bb15.loopexit, label %bb4
bb4: ; preds = %"_ZN5alloc5slice29_$LT$impl$u20$$u5b$T$u5d$$GT$11split_first17h88f6fd10d9762355E.exit"
%6 = getelementptr inbounds [0 x i8], [0 x i8]* %s.sroa.0.035, i64 0, i64 1
%7 = bitcast i8* %6 to [0 x i8]*
%8 = getelementptr inbounds [0 x i8], [0 x i8]* %s.sroa.0.035, i64 0, i64 0
%9 = load i8, i8* %8, align 1
%.off = add i8 %9, -48
%10 = icmp ult i8 %.off, 10
br i1 %10, label %bb14, label %bb9
bb6: ; preds = %bb9
%11 = add i8 %9, -87
br label %bb14
bb7: ; preds = %bb11
%12 = add i8 %9, -55
br label %bb14
bb9: ; preds = %bb4
%.off1 = add i8 %9, -97
%13 = icmp ult i8 %.off1, 6
br i1 %13, label %bb6, label %bb11
bb11: ; preds = %bb9
%.off2 = add i8 %9, -65
%14 = icmp ult i8 %.off2, 6
br i1 %14, label %bb7, label %bb15.loopexit
bb14: ; preds = %bb4, %bb7, %bb6
%d.0 = phi i8 [ %11, %bb6 ], [ %12, %bb7 ], [ %.off, %bb4 ]
%switch = icmp eq i64 %result.sroa.0.033, 1
%15 = zext i8 %d.0 to i64
br i1 %switch, label %bb18, label %bb1
bb15.loopexit: ; preds = %bb1, %"_ZN5alloc5slice29_$LT$impl$u20$$u5b$T$u5d$$GT$11split_first17h88f6fd10d9762355E.exit", %bb11
%result.sroa.7.0.lcssa.ph = phi i64 [ %15, %bb1 ], [ %result.sroa.7.032, %"_ZN5alloc5slice29_$LT$impl$u20$$u5b$T$u5d$$GT$11split_first17h88f6fd10d9762355E.exit" ], [ %result.sroa.7.032, %bb11 ]
%result.sroa.0.0.lcssa.ph = phi i64 [ 1, %bb1 ], [ %result.sroa.0.033, %"_ZN5alloc5slice29_$LT$impl$u20$$u5b$T$u5d$$GT$11split_first17h88f6fd10d9762355E.exit" ], [ %result.sroa.0.033, %bb11 ]
br label %bb15
bb15.loopexit66: ; preds = %bb23
br label %bb15
bb15: ; preds = %bb15.loopexit66, %bb15.loopexit
%result.sroa.7.0.lcssa = phi i64 [ %result.sroa.7.0.lcssa.ph, %bb15.loopexit ], [ %24, %bb15.loopexit66 ]
%result.sroa.0.0.lcssa = phi i64 [ %result.sroa.0.0.lcssa.ph, %bb15.loopexit ], [ 1, %bb15.loopexit66 ]
%_43.sroa.0.0..sroa_idx = getelementptr inbounds %"core::option::Option<usize>", %"core::option::Option<usize>"* %0, i64 0, i32 0, i64 0
store i64 %result.sroa.0.0.lcssa, i64* %_43.sroa.0.0..sroa_idx, align 8
%_43.sroa.4.0..sroa_idx16 = getelementptr inbounds %"core::option::Option<usize>", %"core::option::Option<usize>"* %0, i64 0, i32 0, i64 1
store i64 %result.sroa.7.0.lcssa, i64* %_43.sroa.4.0..sroa_idx16, align 8
br label %bb27
bb18: ; preds = %bb14
call void @llvm.lifetime.start(i64 16, i8* nonnull %1)
%16 = tail call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %result.sroa.7.032, i64 16) #5
%17 = extractvalue { i64, i1 } %16, 1
br i1 %17, label %"_ZN69_$LT$core..option..Option$LT$T$GT$$u20$as$u20$core..ops..try..Try$GT$11into_result17h897d17c22d2262abE.exit", label %bb4.i
bb4.i: ; preds = %bb18
%18 = extractvalue { i64, i1 } %16, 0
%19 = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %18, i64 %15) #5
%20 = extractvalue { i64, i1 } %19, 1
br i1 %20, label %"_ZN69_$LT$core..option..Option$LT$T$GT$$u20$as$u20$core..ops..try..Try$GT$11into_result17h897d17c22d2262abE.exit", label %bb4.i.i
bb4.i.i: ; preds = %bb4.i
%21 = extractvalue { i64, i1 } %19, 0
store i64 0, i64* %2, align 8, !alias.scope !1, !noalias !6
br label %"_ZN69_$LT$core..option..Option$LT$T$GT$$u20$as$u20$core..ops..try..Try$GT$11into_result17h897d17c22d2262abE.exit"
"_ZN69_$LT$core..option..Option$LT$T$GT$$u20$as$u20$core..ops..try..Try$GT$11into_result17h897d17c22d2262abE.exit": ; preds = %bb4.i, %bb18, %bb4.i.i
%.sink2.i.i = phi i64 [ 1, %bb4.i.i ], [ 0, %bb18 ], [ 0, %bb4.i ]
%.sink.i.i = phi i64 [ %21, %bb4.i.i ], [ 1, %bb18 ], [ 1, %bb4.i ]
%22 = getelementptr inbounds %"core::result::Result<usize, core::option::NoneError>", %"core::result::Result<usize, core::option::NoneError>"* %_30, i64 0, i32 0, i64 %.sink2.i.i
store i64 %.sink.i.i, i64* %22, align 8, !alias.scope !1, !noalias !6
%23 = load i64, i64* %2, align 8, !range !8
%switch3 = icmp eq i64 %23, 1
br i1 %switch3, label %bb24, label %bb23
bb23: ; preds = %"_ZN69_$LT$core..option..Option$LT$T$GT$$u20$as$u20$core..ops..try..Try$GT$11into_result17h897d17c22d2262abE.exit"
%24 = load i64, i64* %3, align 8
call void @llvm.lifetime.end(i64 16, i8* nonnull %1)
%25 = icmp eq i64 %5, 0
br i1 %25, label %bb15.loopexit66, label %"_ZN5alloc5slice29_$LT$impl$u20$$u5b$T$u5d$$GT$11split_first17h88f6fd10d9762355E.exit.lr.ph"
bb24: ; preds = %"_ZN69_$LT$core..option..Option$LT$T$GT$$u20$as$u20$core..ops..try..Try$GT$11into_result17h897d17c22d2262abE.exit"
%26 = getelementptr inbounds %"core::option::Option<usize>", %"core::option::Option<usize>"* %0, i64 0, i32 0, i64 0
store i64 0, i64* %26, align 8, !alias.scope !9
call void @llvm.lifetime.end(i64 16, i8* nonnull %1)
br label %bb27
bb27: ; preds = %bb15, %bb24
ret void
}
; testor::main
; Function Attrs: uwtable
define internal void @_ZN6testor4main17h9dbf4c61ddbcebf9E() unnamed_addr #1 personality i32 (i32, i32, i64, %"unwind::libunwind::_Unwind_Exception"*, %"unwind::libunwind::_Unwind_Context"*)* @rust_eh_personality {
start:
%_13 = alloca %"core::option::Option<usize>", align 8
%0 = bitcast %"core::option::Option<usize>"* %_13 to i8*
%1 = getelementptr inbounds %"core::option::Option<usize>", %"core::option::Option<usize>"* %_13, i64 0, i32 0, i64 0
br label %bb2
bb2: ; preds = %bb6, %start
%iter.sroa.0.0 = phi i32 [ 1, %start ], [ %.iter.sroa.0.0, %bb6 ]
%2 = icmp slt i32 %iter.sroa.0.0, 10000000
br i1 %2, label %bb6, label %bb7
bb6: ; preds = %bb2
%.iter.sroa.0.0 = add i32 %iter.sroa.0.0, 1
call void @llvm.lifetime.start(i64 16, i8* nonnull %0)
; call testor::parse_hex
call fastcc void @_ZN6testor9parse_hex17h3af8dfc46349cc2dE(%"core::option::Option<usize>"* noalias nocapture nonnull dereferenceable(16) %_13)
%3 = load i64, i64* %1, align 8, !range !8
%cond = icmp eq i64 %3, 1
call void @llvm.lifetime.end(i64 16, i8* nonnull %0)
br i1 %cond, label %bb2, label %bb7
bb7: ; preds = %bb2, %bb6
ret void
}
; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.start(i64, i8* nocapture) #2
; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.end(i64, i8* nocapture) #2
declare i32 @rust_eh_personality(i32, i32, i64, %"unwind::libunwind::_Unwind_Exception"*, %"unwind::libunwind::_Unwind_Context"*) unnamed_addr #3
; Function Attrs: nounwind readnone
declare { i64, i1 } @llvm.uadd.with.overflow.i64(i64, i64) #4
; Function Attrs: nounwind readnone
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #4
define i32 @main(i32, i8**) unnamed_addr {
top:
%2 = sext i32 %0 to i64
; call std::rt::lang_start
%3 = tail call i64 @_ZN3std2rt10lang_start17h34ece5dce85a6f55E(void ()* @_ZN6testor4main17h9dbf4c61ddbcebf9E, i64 %2, i8** %1)
%4 = trunc i64 %3 to i32
ret i32 %4
}
; std::rt::lang_start
declare i64 @_ZN3std2rt10lang_start17h34ece5dce85a6f55E(void ()* nonnull, i64, i8**) unnamed_addr #3
attributes #0 = { noinline uwtable "probe-stack"="__rust_probestack" }
attributes #1 = { uwtable "probe-stack"="__rust_probestack" }
attributes #2 = { argmemonly nounwind }
attributes #3 = { "probe-stack"="__rust_probestack" }
attributes #4 = { nounwind readnone }
attributes #5 = { nounwind }
!llvm.module.flags = !{!0}
!0 = !{i32 1, !"PIE Level", i32 2}
!1 = !{!2, !4}
!2 = distinct !{!2, !3, !"_ZN38_$LT$core..option..Option$LT$T$GT$$GT$5ok_or17h29e7af4a09480ff7E: argument 0"}
!3 = distinct !{!3, !"_ZN38_$LT$core..option..Option$LT$T$GT$$GT$5ok_or17h29e7af4a09480ff7E"}
!4 = distinct !{!4, !5, !"_ZN69_$LT$core..option..Option$LT$T$GT$$u20$as$u20$core..ops..try..Try$GT$11into_result17h897d17c22d2262abE: argument 0"}
!5 = distinct !{!5, !"_ZN69_$LT$core..option..Option$LT$T$GT$$u20$as$u20$core..ops..try..Try$GT$11into_result17h897d17c22d2262abE"}
!6 = !{!7}
!7 = distinct !{!7, !5, !"_ZN69_$LT$core..option..Option$LT$T$GT$$u20$as$u20$core..ops..try..Try$GT$11into_result17h897d17c22d2262abE: %self"}
!8 = !{i64 0, i64 2}
!9 = !{!10}
!10 = distinct !{!10, !11, !"_ZN69_$LT$core..option..Option$LT$T$GT$$u20$as$u20$core..ops..try..Try$GT$10from_error17h51e52208273e2471E: argument 0"}
!11 = distinct !{!11, !"_ZN69_$LT$core..option..Option$LT$T$GT$$u20$as$u20$core..ops..try..Try$GT$10from_error17h51e52208273e2471E"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment