Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
code:
function Base.getindex{K}(t::TreapNode{K}, index::Int)
1 <= index <= t.size || throw(KeyError(key))
while t.left.size != index - 1
if index <= t.left.size
t = t.left
else
index = index - t.left.size - 1
t = t.right
end
end
t.key
end
code_llvm:
define i64 @julia_getindex1293(%jl_value_t*, i64) {
top:
%2 = alloca [4 x %jl_value_t*], align 8
%.sub = getelementptr inbounds [4 x %jl_value_t*]* %2, i64 0, i64 0
%3 = getelementptr [4 x %jl_value_t*]* %2, i64 0, i64 2, !dbg !3926
store %jl_value_t* inttoptr (i64 4 to %jl_value_t*), %jl_value_t** %.sub, align 8
%4 = load %jl_value_t*** @jl_pgcstack, align 8, !dbg !3926
%5 = getelementptr [4 x %jl_value_t*]* %2, i64 0, i64 1, !dbg !3926
%.c = bitcast %jl_value_t** %4 to %jl_value_t*, !dbg !3926
store %jl_value_t* %.c, %jl_value_t** %5, align 8, !dbg !3926
store %jl_value_t** %.sub, %jl_value_t*** @jl_pgcstack, align 8, !dbg !3926
%6 = getelementptr [4 x %jl_value_t*]* %2, i64 0, i64 3
store %jl_value_t* null, %jl_value_t** %6, align 8
store %jl_value_t* %0, %jl_value_t** %3, align 8, !dbg !3926
%7 = icmp slt i64 %1, 1, !dbg !3927
br i1 %7, label %L4, label %L1, !dbg !3927
L1: ; preds = %top
%8 = getelementptr %jl_value_t* %0, i64 2, !dbg !3927
%9 = bitcast %jl_value_t* %8 to i64*, !dbg !3927
%10 = load i64* %9, align 8, !dbg !3927, !tbaa %jtbaa_user
%phitmp = icmp slt i64 %10, %1, !dbg !3927
br i1 %phitmp, label %L4, label %L5, !dbg !3927
L4: ; preds = %top, %L1
%11 = load %jl_value_t** inttoptr (i64 4451939232 to %jl_value_t**), align 32, !dbg !3927
%12 = icmp eq %jl_value_t* %11, null, !dbg !3927
br i1 %12, label %err, label %ok, !dbg !3927
err: ; preds = %L4
call void @jl_undefined_var_error(%jl_value_t* inttoptr (i64 4311813920 to %jl_value_t*)), !dbg !3927
unreachable
ok: ; preds = %L4
store %jl_value_t* %11, %jl_value_t** %6, align 8, !dbg !3927
%13 = call %jl_value_t* @jl_apply_generic(%jl_value_t* inttoptr (i64 4366144512 to %jl_value_t*), %jl_value_t** %6, i32 1), !dbg !3927
call void @jl_throw_with_superfluous_argument(%jl_value_t* %13, i32 80), !dbg !3927
unreachable
L5: ; preds = %L1
%14 = getelementptr inbounds %jl_value_t* %0, i64 4, i32 0, !dbg !3930
%15 = load %jl_value_t** %14, align 8, !dbg !3930
%16 = icmp eq %jl_value_t* %15, null, !dbg !3930
br i1 %16, label %fail, label %pass, !dbg !3930
fail: ; preds = %L5
%17 = load %jl_value_t** @jl_undefref_exception, align 8, !dbg !3930, !tbaa %jtbaa_const
call void @jl_throw_with_superfluous_argument(%jl_value_t* %17, i32 81), !dbg !3930
unreachable, !dbg !3930
pass: ; preds = %L5
%18 = getelementptr %jl_value_t* %15, i64 2, !dbg !3930
%19 = bitcast %jl_value_t* %18 to i64*, !dbg !3930
%20 = load i64* %19, align 8, !dbg !3930, !tbaa %jtbaa_user
%21 = add i64 %1, -1, !dbg !3930
%22 = icmp eq i64 %20, %21, !dbg !3930
br i1 %22, label %L23, label %L7, !dbg !3930
L7: ; preds = %pass, %pass22
%23 = phi %jl_value_t* [ %storemerge, %pass22 ], [ %0, %pass ]
%index.0 = phi i64 [ %index.1, %pass22 ], [ %1, %pass ]
%24 = getelementptr inbounds %jl_value_t* %23, i64 4, i32 0, !dbg !3932
%25 = load %jl_value_t** %24, align 8, !dbg !3932
%26 = icmp eq %jl_value_t* %25, null, !dbg !3932
br i1 %26, label %fail9, label %pass10, !dbg !3932
fail9: ; preds = %L7
%27 = load %jl_value_t** @jl_undefref_exception, align 8, !dbg !3932, !tbaa %jtbaa_const
call void @jl_throw_with_superfluous_argument(%jl_value_t* %27, i32 82), !dbg !3932
unreachable, !dbg !3932
pass10: ; preds = %L7
%28 = getelementptr %jl_value_t* %25, i64 2, !dbg !3932
%29 = bitcast %jl_value_t* %28 to i64*, !dbg !3932
%30 = load i64* %29, align 8, !dbg !3932, !tbaa %jtbaa_user
%31 = icmp sgt i64 %index.0, %30, !dbg !3932
br i1 %31, label %pass16, label %L19, !dbg !3932
pass16: ; preds = %pass10
%32 = getelementptr inbounds %jl_value_t* %23, i64 5, i32 0, !dbg !3933
%33 = load %jl_value_t** %32, align 8, !dbg !3933
%34 = icmp eq %jl_value_t* %33, null, !dbg !3933
br i1 %34, label %fail17, label %pass18, !dbg !3933
fail17: ; preds = %pass16
%35 = load %jl_value_t** @jl_undefref_exception, align 8, !dbg !3933, !tbaa %jtbaa_const
call void @jl_throw_with_superfluous_argument(%jl_value_t* %35, i32 86), !dbg !3933
unreachable, !dbg !3933
pass18: ; preds = %pass16
%36 = add i64 %index.0, -1, !dbg !3934
%37 = sub i64 %36, %30, !dbg !3934
br label %L19, !dbg !3933
L19: ; preds = %pass10, %pass18
%storemerge = phi %jl_value_t* [ %33, %pass18 ], [ %25, %pass10 ]
%index.1 = phi i64 [ %37, %pass18 ], [ %index.0, %pass10 ]
store %jl_value_t* %storemerge, %jl_value_t** %3, align 8, !dbg !3935
%38 = getelementptr inbounds %jl_value_t* %storemerge, i64 4, i32 0, !dbg !3933
%39 = load %jl_value_t** %38, align 8, !dbg !3933
%40 = icmp eq %jl_value_t* %39, null, !dbg !3933
br i1 %40, label %fail21, label %pass22, !dbg !3933
fail21: ; preds = %L19
%41 = load %jl_value_t** @jl_undefref_exception, align 8, !dbg !3933, !tbaa %jtbaa_const
call void @jl_throw_with_superfluous_argument(%jl_value_t* %41, i32 86), !dbg !3933
unreachable, !dbg !3933
pass22: ; preds = %L19
%42 = getelementptr %jl_value_t* %39, i64 2, !dbg !3933
%43 = bitcast %jl_value_t* %42 to i64*, !dbg !3933
%44 = load i64* %43, align 8, !dbg !3933, !tbaa %jtbaa_user
%45 = add i64 %index.1, -1, !dbg !3933
%46 = icmp eq i64 %44, %45, !dbg !3933
br i1 %46, label %L23, label %L7, !dbg !3933
L23: ; preds = %pass22, %pass
%47 = phi %jl_value_t* [ %0, %pass ], [ %storemerge, %pass22 ]
%48 = getelementptr %jl_value_t* %47, i64 3, !dbg !3936
%49 = bitcast %jl_value_t* %48 to i64*, !dbg !3936
%50 = load i64* %49, align 8, !dbg !3936, !tbaa %jtbaa_user
%51 = load %jl_value_t** %5, align 8, !dbg !3936
%52 = getelementptr inbounds %jl_value_t* %51, i64 0, i32 0, !dbg !3936
store %jl_value_t** %52, %jl_value_t*** @jl_pgcstack, align 8, !dbg !3936
ret i64 %50, !dbg !3936
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.