Skip to content

Instantly share code, notes, and snippets.

@garriguv
Created July 17, 2015 14:10
Show Gist options
  • Select an option

  • Save garriguv/4d2721f7abe321af9db5 to your computer and use it in GitHub Desktop.

Select an option

Save garriguv/4d2721f7abe321af9db5 to your computer and use it in GitHub Desktop.
crystal crash
; ModuleID = 'main_module'
%String = type { i32, i32, i32, i8 }
%"Array(Int32)" = type { i32, i32, i32, i32* }
%Fiber = type { i32, i8*, %"(( -> Nil) | ( -> Void))", i8*, i8*, i8*, %Fiber*, %Fiber* }
%"(( -> Nil) | ( -> Void))" = type { i32, [2 x i64] }
%"Array(Pointer(Void))" = type { i32, i32, i32, i8** }
%"->" = type { i8*, i8* }
%"Array(Fiber)" = type { i32, i32, i32, %Fiber** }
%"Event::Base" = type { i8* }
%FileDescriptorIO = type { i32, i1, i1, i1, i1, i32, %"Slice(UInt8)", i32, %"Array(Fiber)"*, %"Array(Fiber)"*, i8*, i8* }
%"Slice(UInt8)" = type { i8*, i32 }
%"Array(String)" = type { i32, i32, i32, %String** }
%"Hash(Int32, (Int32 -> Void))" = type { i32, i32, %"Hash(K, V)::Entry(Int32, (Int32 -> Void))"**, i32, i32, i1, %"Hash(K, V)::Entry(Int32, (Int32 -> Void))"*, %"Hash(K, V)::Entry(Int32, (Int32 -> Void))"* }
%"Hash(K, V)::Entry(Int32, (Int32 -> Void))" = type { i32, i32, %"->", %"Hash(K, V)::Entry(Int32, (Int32 -> Void))"*, %"Hash(K, V)::Entry(Int32, (Int32 -> Void))"*, %"Hash(K, V)::Entry(Int32, (Int32 -> Void))"* }
%"Array(Base+)" = type { i32, i32, i32, i32** }
%"Slice(Pointer(UInt8))" = type { i8**, i32 }
%LightLeaf = type { i32 }
%"struct.LibABI::UnwindException" = type { i64, i64, i64, i64, i64, i32 }
%"String::Builder" = type { i32, i8*, i32, i32, i1 }
%ArgumentError = type { i32, %String*, i1, %"Array(String)"* }
%IndexOutOfBounds = type { i32, %String*, i1, %"Array(String)"* }
%Exception = type { i32, %String*, i1, %"Array(String)"* }
%DivisionByZero = type { i32, %String*, i1, %"Array(String)"* }
%"(Nil | Void)" = type { i32, [1 x i64] }
%"struct.LibC::TimeVal" = type { i64, i32 }
%Errno = type { i32, %String*, i1, %"Array(String)"*, i32 }
%"IO::Error" = type { i32, %String*, i1, %"Array(String)"* }
%"(Nil | Int32)" = type { i32, [1 x i64] }
%landing_pad = type { i8*, i32 }
%"{String}" = type { %String* }
%"Array(SturdyBranch)" = type { i32, i32, i32, %SturdyBranch** }
%SturdyBranch = type { i32 }
%"Array(NotSoSturdyBranch)" = type { i32, i32, i32, %NotSoSturdyBranch** }
%NotSoSturdyBranch = type { i32 }
@finalize = private constant { i32, i32, i32, [9 x i8] } { i32 1, i32 8, i32 8, [9 x i8] c"finalize\00" }
@to_s = private constant { i32, i32, i32, [5 x i8] } { i32 1, i32 4, i32 4, [5 x i8] c"to_s\00" }
@inspect = private constant { i32, i32, i32, [8 x i8] } { i32 1, i32 7, i32 7, [8 x i8] c"inspect\00" }
@symbol_table = global [3 x %String*] [%String* bitcast ({ i32, i32, i32, [9 x i8] }* @finalize to %String*), %String* bitcast ({ i32, i32, i32, [5 x i8] }* @to_s to %String*), %String* bitcast ({ i32, i32, i32, [8 x i8] }* @inspect to %String*)]
@ARGC_UNSAFE = global i32 0
@ARGV_UNSAFE = global i8** null
@"LibC::PROT_READ" = constant i32 1
@"LibC::PROT_WRITE" = constant i32 2
@"LibC::MAP_PRIVATE" = constant i32 2
@"LibC::MAP_ANON" = constant i32 4096
@"Unwind::REG_IP" = constant i32 -1
@str = private constant { i32, i32, i32, [8 x i8] } { i32 1, i32 7, i32 7, [8 x i8] c"pthread\00" }
@str1 = private constant { i32, i32, i32, [3 x i8] } { i32 1, i32 2, i32 2, [3 x i8] c"gc\00" }
@"Int::DIGITS_DOWNCASE" = constant %String* bitcast ({ i32, i32, i32, [37 x i8] }* @str2 to %String*)
@str2 = private constant { i32, i32, i32, [37 x i8] } { i32 1, i32 36, i32 36, [37 x i8] c"0123456789abcdefghijklmnopqrstuvwxyz\00" }
@"Int::DIGITS_UPCASE" = constant %String* bitcast ({ i32, i32, i32, [37 x i8] }* @str3 to %String*)
@str3 = private constant { i32, i32, i32, [37 x i8] } { i32 1, i32 36, i32 36, [37 x i8] c"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\00" }
@"String::TYPE_ID" = constant i32 1
@"String::HEADER_SIZE" = constant i32 trunc (i64 mul nuw (i64 ptrtoint (i32* getelementptr (i32* null, i32 1) to i64), i64 3) to i32)
@"LibC::FCNTL::F_GETFL" = constant i32 3
@"LibC::FCNTL::F_SETFL" = constant i32 4
@"LibC::O_NONBLOCK" = constant i32 4
@"BufferedIOMixin::BUFFER_SIZE" = constant i32 8192
@"Hash(K, V)::HASH_PRIMES" = global %"Array(Int32)"* null
@str4 = private constant { i32, i32, i32, [3 x i8] } { i32 1, i32 2, i32 2, [3 x i8] c" +\00" }
@str5 = private constant { i32, i32, i32, [3 x i8] } { i32 1, i32 2, i32 2, [3 x i8] c" [\00" }
@str6 = private constant { i32, i32, i32, [2 x i8] } { i32 1, i32 1, i32 1, [2 x i8] c"]\00" }
@"LibC::ClockT" = constant i32 383
@str7 = private constant { i32, i32, i32, [5 x i8] } { i32 1, i32 4, i32 4, [5 x i8] c"pcre\00" }
@str8 = private constant { i32, i32, i32, [38 x i8] } { i32 1, i32 37, i32 37, [38 x i8] c"passing a closure to C is not allowed\00" }
@pcre_malloc = external global i8* (i32)*
@pcre_free = external global void (i8*)*
@"LibABI::UA_SEARCH_PHASE" = constant i32 1
@"LibABI::UA_HANDLER_FRAME" = constant i32 4
@"LibABI::URC_HANDLER_FOUND" = constant i32 6
@"LibABI::URC_INSTALL_CONTEXT" = constant i32 7
@"LibABI::URC_CONTINUE_UNWIND" = constant i32 8
@"LibABI::EH_REGISTER_0" = constant i32 0
@"LibABI::EH_REGISTER_1" = constant i32 1
@"Errno::EAGAIN" = constant i32 35
@str9 = private constant { i32, i32, i32, [4 x i8] } { i32 1, i32 3, i32 3, [4 x i8] c"pcl\00" }
@"Fiber::STACK_SIZE" = constant i32 8388608
@"Fiber::first_fiber" = global %Fiber* null
@"Fiber::last_fiber" = global %Fiber* null
@"Fiber::stack_pool" = global %"Array(Pointer(Void))"* null
@"Fiber::prev_push_other_roots" = global %"->" zeroinitializer
@"Fiber::root" = global %Fiber* null
@str10 = private constant { i32, i32, i32, [6 x i8] } { i32 1, i32 5, i32 5, [6 x i8] c"event\00" }
@"LibEvent2::EventLoopFlags::None" = constant i32 0
@"LibEvent2::EventFlags::Read" = constant i32 2
@"LibEvent2::EventFlags::Write" = constant i32 4
@"LibEvent2::EventFlags::Persist" = constant i32 16
@"LibEvent2::EventFlags::ET" = constant i32 32
@"LibEvent2::EventFlags::None" = constant i32 0
@"Scheduler::runnables" = global %"Array(Fiber)"* null
@"Scheduler::eb" = global %"Event::Base" zeroinitializer
@"Fiber::rescheduler" = global %"->" zeroinitializer
@"Scheduler::loop_fiber" = global %Fiber* null
@"Signal::PIPE" = constant i32 13
@STDOUT = global %FileDescriptorIO* null
@ARGV = global %"Array(String)"* null
@"AtExitHandlers::handlers" = global i1 false
@"Signal::handlers" = global %"Hash(Int32, (Int32 -> Void))"* null
@str11 = private constant { i32, i32, i32, [31 x i8] } { i32 1, i32 30, i32 30, [31 x i8] c"sleep seconds must be positive\00" }
@str12 = private constant { i32, i32, i32, [22 x i8] } { i32 1, i32 21, i32 21, [22 x i8] c"Unhandled exception: \00" }
define internal %"Array(Base+)"* @__crystal_main(i32 %argc, i8** %argv) {
alloca:
%__temp_297 = alloca %Fiber*
%array = alloca %"Array(Base+)"*
%__temp_295 = alloca %"Array(Int32)"*
%__temp_296 = alloca i32*
%0 = alloca %"->"
%1 = alloca %"->"
%2 = alloca %"->"
%3 = alloca %"->"
%4 = alloca %"->"
%5 = alloca %"->"
%6 = alloca %"Event::Base"
%7 = alloca %"->"
%8 = alloca %"->"
%f = alloca %FileDescriptorIO*
%9 = alloca %"Slice(Pointer(UInt8))"
%c_str = alloca i8*
%ary = alloca %"Array(String)"*
%e = alloca i8*
%i = alloca i32
%i1 = alloca i32
%10 = alloca %"->"
entry: ; No predecessors!
store i32 %argc, i32* @ARGC_UNSAFE
store i8** %argv, i8*** @ARGV_UNSAFE
%11 = call %"Array(Int32)"* @"*Array(Int32)::new<Array(Int32):Class, Int32>:Array(Int32)"(i32 302, i32 29)
store %"Array(Int32)"* %11, %"Array(Int32)"** %__temp_295
%12 = load %"Array(Int32)"** %__temp_295
%13 = call i32 @"*Array(Int32)@Array(T)#length=<Array(Int32), Int32>:Int32"(%"Array(Int32)"* %12, i32 29)
%14 = load %"Array(Int32)"** %__temp_295
%15 = call i32* @"*Array(Int32)@Array(T)#buffer<Array(Int32)>:Pointer(Int32)"(%"Array(Int32)"* %14)
store i32* %15, i32** %__temp_296
%16 = load i32** %__temp_296
%17 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %16, i32 0, i32 11)
%18 = load i32** %__temp_296
%19 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %18, i32 1, i32 19)
%20 = load i32** %__temp_296
%21 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %20, i32 2, i32 37)
%22 = load i32** %__temp_296
%23 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %22, i32 3, i32 67)
%24 = load i32** %__temp_296
%25 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %24, i32 4, i32 131)
%26 = load i32** %__temp_296
%27 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %26, i32 5, i32 283)
%28 = load i32** %__temp_296
%29 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %28, i32 6, i32 521)
%30 = load i32** %__temp_296
%31 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %30, i32 7, i32 1033)
%32 = load i32** %__temp_296
%33 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %32, i32 8, i32 2053)
%34 = load i32** %__temp_296
%35 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %34, i32 9, i32 4099)
%36 = load i32** %__temp_296
%37 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %36, i32 10, i32 8219)
%38 = load i32** %__temp_296
%39 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %38, i32 11, i32 16427)
%40 = load i32** %__temp_296
%41 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %40, i32 12, i32 32771)
%42 = load i32** %__temp_296
%43 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %42, i32 13, i32 65581)
%44 = load i32** %__temp_296
%45 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %44, i32 14, i32 131101)
%46 = load i32** %__temp_296
%47 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %46, i32 15, i32 262147)
%48 = load i32** %__temp_296
%49 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %48, i32 16, i32 524309)
%50 = load i32** %__temp_296
%51 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %50, i32 17, i32 1048583)
%52 = load i32** %__temp_296
%53 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %52, i32 18, i32 2097169)
%54 = load i32** %__temp_296
%55 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %54, i32 19, i32 4194319)
%56 = load i32** %__temp_296
%57 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %56, i32 20, i32 8388617)
%58 = load i32** %__temp_296
%59 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %58, i32 21, i32 16777259)
%60 = load i32** %__temp_296
%61 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %60, i32 22, i32 33554467)
%62 = load i32** %__temp_296
%63 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %62, i32 23, i32 67108879)
%64 = load i32** %__temp_296
%65 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %64, i32 24, i32 134217757)
%66 = load i32** %__temp_296
%67 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %66, i32 25, i32 268435459)
%68 = load i32** %__temp_296
%69 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %68, i32 26, i32 536870923)
%70 = load i32** %__temp_296
%71 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %70, i32 27, i32 1073741909)
%72 = load i32** %__temp_296
%73 = call i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32* %72, i32 28, i32 0)
%74 = load %"Array(Int32)"** %__temp_295
store %"Array(Int32)"* %74, %"Array(Int32)"** @"Hash(K, V)::HASH_PRIMES"
%75 = getelementptr inbounds %"->"* %0, i32 0, i32 0
store i8* bitcast (i8* (i32)* @"*GC::malloc<UInt32>:Pointer(Void)" to i8*), i8** %75
%76 = getelementptr inbounds %"->"* %0, i32 0, i32 1
store i8* null, i8** %76
%77 = load %"->"* %0
%78 = call i8* @"~check_fun_is_not_closure"(%"->" %77)
%79 = bitcast i8* %78 to i8* (i32)*
store i8* (i32)* %79, i8* (i32)** @pcre_malloc
%80 = bitcast i8* (i32)* %79 to i8*
%81 = getelementptr inbounds %"->"* %1, i32 0, i32 0
store i8* %80, i8** %81
%82 = getelementptr inbounds %"->"* %1, i32 0, i32 1
store i8* null, i8** %82
%83 = load %"->"* %1
%84 = getelementptr inbounds %"->"* %2, i32 0, i32 0
store i8* bitcast (void (i8*)* @"*GC::free<Pointer(Void)>:Void" to i8*), i8** %84
%85 = getelementptr inbounds %"->"* %2, i32 0, i32 1
store i8* null, i8** %85
%86 = load %"->"* %2
%87 = call i8* @"~check_fun_is_not_closure"(%"->" %86)
%88 = bitcast i8* %87 to void (i8*)*
store void (i8*)* %88, void (i8*)** @pcre_free
%89 = bitcast void (i8*)* %88 to i8*
%90 = getelementptr inbounds %"->"* %3, i32 0, i32 0
store i8* %89, i8** %90
%91 = getelementptr inbounds %"->"* %3, i32 0, i32 1
store i8* null, i8** %91
%92 = load %"->"* %3
store %Fiber* null, %Fiber** @"Fiber::first_fiber"
store %Fiber* null, %Fiber** @"Fiber::last_fiber"
%93 = call %"Array(Pointer(Void))"* @"*Array(Pointer(Void))::new<Array(Pointer(Void)):Class>:Array(Pointer(Void))"(i32 300)
store %"Array(Pointer(Void))"* %93, %"Array(Pointer(Void))"** @"Fiber::stack_pool"
%94 = call void ()* ()* @GC_get_push_other_roots()
%95 = bitcast void ()* %94 to i8*
%96 = getelementptr inbounds %"->"* %4, i32 0, i32 0
store i8* %95, i8** %96
%97 = getelementptr inbounds %"->"* %4, i32 0, i32 1
store i8* null, i8** %97
%98 = load %"->"* %4
store %"->" %98, %"->"* @"Fiber::prev_push_other_roots"
%99 = getelementptr inbounds %"->"* %5, i32 0, i32 0
store i8* bitcast (i1 ()* @"~fun_literal_1" to i8*), i8** %99
%100 = getelementptr inbounds %"->"* %5, i32 0, i32 1
store i8* null, i8** %100
%101 = load %"->"* %5
%102 = call i8* @"~check_fun_is_not_closure"(%"->" %101)
%103 = bitcast i8* %102 to void ()*
call void @GC_set_push_other_roots(void ()* %103)
%104 = call i32 @co_thread_init()
%105 = call %Fiber* @"*Fiber::new:Fiber"()
store %Fiber* %105, %Fiber** @"Fiber::root"
%106 = call %"Array(Fiber)"* @"*Array(Fiber)::new<Array(Fiber):Class>:Array(Fiber)"(i32 301)
store %"Array(Fiber)"* %106, %"Array(Fiber)"** @"Scheduler::runnables"
%107 = call %"Event::Base" @"*Event::Base::new:Event::Base"()
store %"Event::Base" %107, %"Event::Base"* %6
%108 = load %"Event::Base"* %6
store %"Event::Base" %108, %"Event::Base"* @"Scheduler::eb"
%109 = getelementptr inbounds %"->"* %7, i32 0, i32 0
store i8* bitcast (void ()* @"~fun_literal_4" to i8*), i8** %109
%110 = getelementptr inbounds %"->"* %7, i32 0, i32 1
store i8* null, i8** %110
%111 = load %"->"* %7
%112 = call %Fiber* @"*Fiber::new<&( -> Void)>:Fiber"(%"->" %111)
store %Fiber* %112, %Fiber** @"Scheduler::loop_fiber"
%113 = getelementptr inbounds %"->"* %8, i32 0, i32 0
store i8* bitcast (void ()* @"~fun_literal_5" to i8*), i8** %113
%114 = getelementptr inbounds %"->"* %8, i32 0, i32 1
store i8* null, i8** %114
%115 = load %"->"* %8
%116 = call %"->" @"*Fiber::rescheduler=<( -> Void)>:( -> Void)"(%"->" %115)
%117 = call i32 @isatty(i32 1)
%118 = icmp eq i32 %117, 0
%119 = call %FileDescriptorIO* @"*FileDescriptorIO::new<Int32, Bool, Bool>:FileDescriptorIO"(i32 1, i1 %118, i1 false)
store %FileDescriptorIO* %119, %FileDescriptorIO** %f
%120 = load %FileDescriptorIO** %f
%121 = call i1 @"*FileDescriptorIO#flush_on_newline=<FileDescriptorIO, Bool>:Bool"(%FileDescriptorIO* %120, i1 true)
store %FileDescriptorIO* %119, %FileDescriptorIO** @STDOUT
%122 = load i8*** @ARGV_UNSAFE
%123 = call i8** @"*Pointer(Pointer(UInt8))@Pointer(T)#+<Pointer(Pointer(UInt8)), Int32>:Pointer(Pointer(UInt8))"(i8** %122, i32 1)
%124 = load i32* @ARGC_UNSAFE
%125 = sub i32 %124, 1
%126 = call %"Slice(Pointer(UInt8))" @"*Pointer(Pointer(UInt8))@Pointer(T)#to_slice<Pointer(Pointer(UInt8)), Int32>:Slice(Pointer(UInt8))"(i8** %123, i32 %125)
store %"Slice(Pointer(UInt8))" %126, %"Slice(Pointer(UInt8))"* %9
%127 = call %"Array(String)"* @"*Array(String)::new<Array(String):Class>:Array(String)"(i32 299)
store %"Array(String)"* %127, %"Array(String)"** %ary
%128 = call i32 @"*Slice(Pointer(UInt8))@Slice(T)#length<Slice(Pointer(UInt8))>:Int32"(%"Slice(Pointer(UInt8))"* %9)
%129 = xor i32 %128, %128
store i32 %129, i32* %i1
br label %while
while: ; preds = %body, %entry
%130 = load i32* %i1
%131 = icmp slt i32 %130, %128
br i1 %131, label %body, label %exit
body: ; preds = %while
%132 = load i32* %i1
store i32 %132, i32* %i
%133 = getelementptr inbounds %"Slice(Pointer(UInt8))"* %9, i32 0, i32 0
%134 = load i8*** %133
%135 = load i32* %i
%136 = call i8* @"*Pointer(Pointer(UInt8))@Pointer(T)#[]<Pointer(Pointer(UInt8)), Int32>:Pointer(UInt8)"(i8** %134, i32 %135)
store i8* %136, i8** %e
%137 = load %"Array(String)"** %ary
%138 = load i8** %e
store i8* %138, i8** %c_str
%139 = load i8** %c_str
%140 = call %String* @"*String::new<Pointer(UInt8)>:String"(i8* %139)
%141 = call %"Array(String)"* @"*Array(String)@Array(T)#<<<Array(String), String>:Array(String)"(%"Array(String)"* %137, %String* %140)
%142 = load i32* %i1
%143 = add i32 %142, 1
store i32 %143, i32* %i1
br label %while
exit: ; preds = %while
%144 = load %"Array(String)"** %ary
store %"Array(String)"* %144, %"Array(String)"** @ARGV
store i1 false, i1* @"AtExitHandlers::handlers"
call void @"*Signal#ignore<Signal>:Void"(i32 13)
%145 = getelementptr inbounds %"->"* %10, i32 0, i32 0
store i8* bitcast (void ()* @"~fun_literal_10" to i8*), i8** %145
%146 = getelementptr inbounds %"->"* %10, i32 0, i32 1
store i8* null, i8** %146
%147 = load %"->"* %10
%148 = call %Fiber* @"*Fiber::new<&( -> Void)>:Fiber"(%"->" %147)
store %Fiber* %148, %Fiber** %__temp_297
%149 = load %Fiber** %__temp_297
%150 = call %"Array(Fiber)"* @"*Scheduler::enqueue<Fiber>:Array(Fiber)"(%Fiber* %149)
%151 = call %"Array(Base+)"* @"*Array(Base+)::new<Array(Base+):Class>:Array(Base+)"(i32 303)
store %"Array(Base+)"* %151, %"Array(Base+)"** %array
%152 = load %"Array(Base+)"** %array
%153 = call %LightLeaf* @"*LightLeaf::new:LightLeaf"()
%154 = call %"Array(Base+)"* @"*Array(Base+)@Array(T)#<<<Array(Base+), LightLeaf>:Array(Base+)"(%"Array(Base+)"* %152, %LightLeaf* %153)
%155 = load %"Array(Base+)"** %array
}
declare i32 @printf(i8*, ...)
declare i8* @__crystal_malloc(i32)
declare i8* @__crystal_realloc(i8*, i32)
; Function Attrs: noreturn
declare void @__crystal_raise(%"struct.LibABI::UnwindException"*) #0
declare i8* @__crystal_malloc_atomic(i32)
define %"Array(String)"* @"*caller:Array(String)"() {
alloca:
%cursor = alloca [140 x i64]
%context = alloca [128 x i64]
%cursor_ptr = alloca [140 x i64]*
%context_ptr = alloca [128 x i64]*
%fname_size = alloca i32
%fname_buffer = alloca i8*
%backtrace = alloca %"Array(String)"*
%pc = alloca i64
%offset = alloca i64
%fname = alloca %String*
%0 = alloca i64
%1 = alloca i64
br label %entry
entry: ; preds = %alloca
store [140 x i64]* %cursor, [140 x i64]** %cursor_ptr
store [128 x i64]* %context, [128 x i64]** %context_ptr
%2 = load [128 x i64]** %context_ptr
%3 = call i32 @unw_getcontext([128 x i64]* %2)
%4 = load [140 x i64]** %cursor_ptr
%5 = load [128 x i64]** %context_ptr
%6 = call i32 @unw_init_local([140 x i64]* %4, [128 x i64]* %5)
store i32 64, i32* %fname_size
%7 = load i32* %fname_size
%8 = call i8* @"*Pointer(UInt8)::malloc<Pointer(UInt8):Class, Int32>:Pointer(UInt8)"(i32 396, i32 %7)
store i8* %8, i8** %fname_buffer
%9 = call %"Array(String)"* @"*Array(String)::new<Array(String):Class>:Array(String)"(i32 299)
store %"Array(String)"* %9, %"Array(String)"** %backtrace
br label %while
while: ; preds = %exit3, %entry
%10 = load [140 x i64]** %cursor_ptr
%11 = call i32 @unw_step([140 x i64]* %10)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %body, label %exit
body: ; preds = %while
%13 = load [140 x i64]** %cursor_ptr
%14 = call i32 @unw_get_reg([140 x i64]* %13, i32 -1, i64* %0)
%15 = load i64* %0
store i64 %15, i64* %pc
br label %while1
exit: ; preds = %while
%16 = load %"Array(String)"** %backtrace
ret %"Array(String)"* %16
while1: ; preds = %else, %body
br i1 true, label %body2, label %exit3
body2: ; preds = %while1
%17 = load [140 x i64]** %cursor_ptr
%18 = load i8** %fname_buffer
%19 = load i32* %fname_size
%20 = call i32 @unw_get_proc_name([140 x i64]* %17, i8* %18, i32 %19, i64* %1)
%21 = load i64* %1
store i64 %21, i64* %offset
%22 = load i8** %fname_buffer
%23 = call %String* @"*String::new<Pointer(UInt8)>:String"(i8* %22)
store %String* %23, %String** %fname
%24 = load %String** %fname
%25 = call i32 @"*String#length<String>:Int32"(%String* %24)
%26 = load i32* %fname_size
%27 = sub i32 %26, 1
%28 = icmp slt i32 %25, %27
br i1 %28, label %then, label %else
exit3: ; preds = %then, %while1
%29 = load %"Array(String)"** %backtrace
%30 = call %"String::Builder"* @"*String::Builder::new:String::Builder"()
%31 = load %String** %fname
%32 = call %"String::Builder"* @"*String::Builder@IO#<<<String::Builder, String>:String::Builder"(%"String::Builder"* %30, %String* %31)
%33 = call %"String::Builder"* @"*String::Builder@IO#<<<String::Builder, String>:String::Builder"(%"String::Builder"* %32, %String* bitcast ({ i32, i32, i32, [3 x i8] }* @str4 to %String*))
%34 = load i64* %offset
%35 = call %"String::Builder"* @"*String::Builder@IO#<<<String::Builder, UInt64>:String::Builder"(%"String::Builder"* %33, i64 %34)
%36 = call %"String::Builder"* @"*String::Builder@IO#<<<String::Builder, String>:String::Builder"(%"String::Builder"* %35, %String* bitcast ({ i32, i32, i32, [3 x i8] }* @str5 to %String*))
%37 = load i64* %pc
%38 = call %"String::Builder"* @"*String::Builder@IO#<<<String::Builder, UInt64>:String::Builder"(%"String::Builder"* %36, i64 %37)
%39 = call %"String::Builder"* @"*String::Builder@IO#<<<String::Builder, String>:String::Builder"(%"String::Builder"* %38, %String* bitcast ({ i32, i32, i32, [2 x i8] }* @str6 to %String*))
%40 = call %String* @"*String::Builder#to_s<String::Builder>:String"(%"String::Builder"* %39)
%41 = call %"Array(String)"* @"*Array(String)@Array(T)#<<<Array(String), String>:Array(String)"(%"Array(String)"* %29, %String* %40)
br label %while
then: ; preds = %body2
br label %exit3
else: ; preds = %body2
%42 = load i32* %fname_size
%43 = add i32 %42, 64
store i32 %43, i32* %fname_size
%44 = load i8** %fname_buffer
%45 = load i32* %fname_size
%46 = call i8* @"*Pointer(UInt8)@Pointer(T)#realloc<Pointer(UInt8), Int32>:Pointer(UInt8)"(i8* %44, i32 %45)
store i8* %46, i8** %fname_buffer
br label %while1
}
declare i32 @unw_getcontext([128 x i64]*)
declare i32 @unw_init_local([140 x i64]*, [128 x i64]*)
; Function Attrs: noreturn
define void @"*raise<ArgumentError>:NoReturn"(%ArgumentError* %ex) #0 {
alloca:
%unwind_ex = alloca %"struct.LibABI::UnwindException"*
br label %entry
entry: ; preds = %alloca
%0 = call %"struct.LibABI::UnwindException"* @"*Pointer(LibABI::UnwindException)::malloc<Pointer(LibABI::UnwindException):Class>:Pointer(LibABI::UnwindException)"(i32 415)
store %"struct.LibABI::UnwindException"* %0, %"struct.LibABI::UnwindException"** %unwind_ex
%1 = load %"struct.LibABI::UnwindException"** %unwind_ex
%2 = call i64 @"*UInt64::zero:UInt64"()
%3 = getelementptr inbounds %"struct.LibABI::UnwindException"* %1, i32 0, i32 0
store i64 %2, i64* %3
%4 = load %"struct.LibABI::UnwindException"** %unwind_ex
%5 = call i64 @"*UInt64::zero:UInt64"()
%6 = getelementptr inbounds %"struct.LibABI::UnwindException"* %4, i32 0, i32 1
store i64 %5, i64* %6
%7 = load %"struct.LibABI::UnwindException"** %unwind_ex
%8 = ptrtoint %ArgumentError* %ex to i64
%9 = getelementptr inbounds %"struct.LibABI::UnwindException"* %7, i32 0, i32 4
store i64 %8, i64* %9
%10 = load %"struct.LibABI::UnwindException"** %unwind_ex
%11 = getelementptr inbounds %"struct.LibABI::UnwindException"* %10, i32 0, i32 5
store i32 12, i32* %11
%12 = load %"struct.LibABI::UnwindException"** %unwind_ex
call void @__crystal_raise(%"struct.LibABI::UnwindException"* %12)
unreachable
}
declare %"struct.LibABI::UnwindException"* @"*Pointer(LibABI::UnwindException)::malloc<Pointer(LibABI::UnwindException):Class>:Pointer(LibABI::UnwindException)"(i32)
declare i64 @"*UInt64::zero:UInt64"()
declare i8* @"*Pointer(UInt8)::malloc<Pointer(UInt8):Class, Int32>:Pointer(UInt8)"(i32, i32)
declare %"Array(String)"* @"*Array(String)::new<Array(String):Class>:Array(String)"(i32)
declare i32 @unw_step([140 x i64]*)
declare i32 @unw_get_reg([140 x i64]*, i32, i64*)
declare i32 @unw_get_proc_name([140 x i64]*, i8*, i32, i64*)
declare i32 @strlen(i8*)
; Function Attrs: nounwind
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i32, i1 zeroext) #1
declare %String* @"*String::new<Pointer(UInt8)>:String"(i8*)
declare i32 @"*String#length<String>:Int32"(%String*)
declare i8* @"*Pointer(UInt8)@Pointer(T)#realloc<Pointer(UInt8), Int32>:Pointer(UInt8)"(i8*, i32)
declare %"String::Builder"* @"*String::Builder::new:String::Builder"()
; Function Attrs: noreturn
define void @"*raise<IndexOutOfBounds>:NoReturn"(%IndexOutOfBounds* %ex) #0 {
alloca:
%unwind_ex = alloca %"struct.LibABI::UnwindException"*
br label %entry
entry: ; preds = %alloca
%0 = call %"struct.LibABI::UnwindException"* @"*Pointer(LibABI::UnwindException)::malloc<Pointer(LibABI::UnwindException):Class>:Pointer(LibABI::UnwindException)"(i32 415)
store %"struct.LibABI::UnwindException"* %0, %"struct.LibABI::UnwindException"** %unwind_ex
%1 = load %"struct.LibABI::UnwindException"** %unwind_ex
%2 = call i64 @"*UInt64::zero:UInt64"()
%3 = getelementptr inbounds %"struct.LibABI::UnwindException"* %1, i32 0, i32 0
store i64 %2, i64* %3
%4 = load %"struct.LibABI::UnwindException"** %unwind_ex
%5 = call i64 @"*UInt64::zero:UInt64"()
%6 = getelementptr inbounds %"struct.LibABI::UnwindException"* %4, i32 0, i32 1
store i64 %5, i64* %6
%7 = load %"struct.LibABI::UnwindException"** %unwind_ex
%8 = ptrtoint %IndexOutOfBounds* %ex to i64
%9 = getelementptr inbounds %"struct.LibABI::UnwindException"* %7, i32 0, i32 4
store i64 %8, i64* %9
%10 = load %"struct.LibABI::UnwindException"** %unwind_ex
%11 = getelementptr inbounds %"struct.LibABI::UnwindException"* %10, i32 0, i32 5
store i32 11, i32* %11
%12 = load %"struct.LibABI::UnwindException"** %unwind_ex
call void @__crystal_raise(%"struct.LibABI::UnwindException"* %12)
unreachable
}
declare %"String::Builder"* @"*String::Builder@IO#<<<String::Builder, String>:String::Builder"(%"String::Builder"*, %String*)
; Function Attrs: noreturn
define void @"*raise<String>:NoReturn"(%String* %message) #0 {
entry:
%0 = call %Exception* @"*Exception::new<String>:Exception"(%String* %message)
call void @"*raise<Exception>:NoReturn"(%Exception* %0)
unreachable
}
declare %Exception* @"*Exception::new<String>:Exception"(%String*)
; Function Attrs: noreturn
define void @"*raise<Exception>:NoReturn"(%Exception* %ex) #0 {
alloca:
%unwind_ex = alloca %"struct.LibABI::UnwindException"*
br label %entry
entry: ; preds = %alloca
%0 = call %"struct.LibABI::UnwindException"* @"*Pointer(LibABI::UnwindException)::malloc<Pointer(LibABI::UnwindException):Class>:Pointer(LibABI::UnwindException)"(i32 415)
store %"struct.LibABI::UnwindException"* %0, %"struct.LibABI::UnwindException"** %unwind_ex
%1 = load %"struct.LibABI::UnwindException"** %unwind_ex
%2 = call i64 @"*UInt64::zero:UInt64"()
%3 = getelementptr inbounds %"struct.LibABI::UnwindException"* %1, i32 0, i32 0
store i64 %2, i64* %3
%4 = load %"struct.LibABI::UnwindException"** %unwind_ex
%5 = call i64 @"*UInt64::zero:UInt64"()
%6 = getelementptr inbounds %"struct.LibABI::UnwindException"* %4, i32 0, i32 1
store i64 %5, i64* %6
%7 = load %"struct.LibABI::UnwindException"** %unwind_ex
%8 = ptrtoint %Exception* %ex to i64
%9 = getelementptr inbounds %"struct.LibABI::UnwindException"* %7, i32 0, i32 4
store i64 %8, i64* %9
%10 = load %"struct.LibABI::UnwindException"** %unwind_ex
%11 = getelementptr inbounds %"struct.LibABI::UnwindException"* %10, i32 0, i32 5
store i32 23, i32* %11
%12 = load %"struct.LibABI::UnwindException"** %unwind_ex
call void @__crystal_raise(%"struct.LibABI::UnwindException"* %12)
unreachable
}
; Function Attrs: noreturn
define void @"*raise<DivisionByZero>:NoReturn"(%DivisionByZero* %ex) #0 {
alloca:
%unwind_ex = alloca %"struct.LibABI::UnwindException"*
br label %entry
entry: ; preds = %alloca
%0 = call %"struct.LibABI::UnwindException"* @"*Pointer(LibABI::UnwindException)::malloc<Pointer(LibABI::UnwindException):Class>:Pointer(LibABI::UnwindException)"(i32 415)
store %"struct.LibABI::UnwindException"* %0, %"struct.LibABI::UnwindException"** %unwind_ex
%1 = load %"struct.LibABI::UnwindException"** %unwind_ex
%2 = call i64 @"*UInt64::zero:UInt64"()
%3 = getelementptr inbounds %"struct.LibABI::UnwindException"* %1, i32 0, i32 0
store i64 %2, i64* %3
%4 = load %"struct.LibABI::UnwindException"** %unwind_ex
%5 = call i64 @"*UInt64::zero:UInt64"()
%6 = getelementptr inbounds %"struct.LibABI::UnwindException"* %4, i32 0, i32 1
store i64 %5, i64* %6
%7 = load %"struct.LibABI::UnwindException"** %unwind_ex
%8 = ptrtoint %DivisionByZero* %ex to i64
%9 = getelementptr inbounds %"struct.LibABI::UnwindException"* %7, i32 0, i32 4
store i64 %8, i64* %9
%10 = load %"struct.LibABI::UnwindException"** %unwind_ex
%11 = getelementptr inbounds %"struct.LibABI::UnwindException"* %10, i32 0, i32 5
store i32 16, i32* %11
%12 = load %"struct.LibABI::UnwindException"** %unwind_ex
call void @__crystal_raise(%"struct.LibABI::UnwindException"* %12)
unreachable
}
declare %"String::Builder"* @"*String::Builder@IO#<<<String::Builder, UInt64>:String::Builder"(%"String::Builder"*, i64)
declare %String* @"*String::Builder#to_s<String::Builder>:String"(%"String::Builder"*)
declare %"Array(String)"* @"*Array(String)@Array(T)#<<<Array(String), String>:Array(String)"(%"Array(String)"*, %String*)
declare %"Array(Int32)"* @"*Array(Int32)::new<Array(Int32):Class, Int32>:Array(Int32)"(i32, i32)
declare i32 @"*Array(Int32)@Array(T)#length=<Array(Int32), Int32>:Int32"(%"Array(Int32)"*, i32)
declare i32* @"*Array(Int32)@Array(T)#buffer<Array(Int32)>:Pointer(Int32)"(%"Array(Int32)"*)
declare i32 @"*Pointer(Int32)@Pointer(T)#[]=<Pointer(Int32), Int32, Int32>:Int32"(i32*, i32, i32)
declare i8* @"*GC::malloc<UInt32>:Pointer(Void)"(i32)
define i8* @"~check_fun_is_not_closure"(%"->") {
entry:
%1 = extractvalue %"->" %0, 0
%2 = extractvalue %"->" %0, 1
%3 = icmp eq i8* %2, null
br i1 %3, label %ctx_is_null, label %ctx_is_not_null
ctx_is_null: ; preds = %entry
ret i8* %1
ctx_is_not_null: ; preds = %entry
call void @"*raise<String>:NoReturn"(%String* bitcast ({ i32, i32, i32, [38 x i8] }* @str8 to %String*))
unreachable
}
declare void @GC_free(i8*)
declare void @"*GC::free<Pointer(Void)>:Void"(i8*)
declare i32 @__crystal_personality(i32, i32, i64, %"struct.LibABI::UnwindException"*, i8*)
declare i64 @__crystal_get_exception(%"struct.LibABI::UnwindException"*)
declare void @__crystal_raise_string(i8*)
; Function Attrs: noinline
declare i8* @get_stack_top() #2
declare %"Array(Pointer(Void))"* @"*Array(Pointer(Void))::new<Array(Pointer(Void)):Class>:Array(Pointer(Void))"(i32)
declare void ()* @GC_get_push_other_roots()
define i1 @"~fun_literal_1"() {
alloca:
%fiber = alloca %Fiber*
br label %entry
entry: ; preds = %alloca
%0 = load %"->"* @"Fiber::prev_push_other_roots"
%1 = extractvalue %"->" %0, 0
%2 = extractvalue %"->" %0, 1
%3 = icmp eq i8* %2, null
br i1 %3, label %ctx_is_null, label %ctx_is_not_null
ctx_is_null: ; preds = %entry
%4 = bitcast i8* %1 to void ()*
call void %4()
br label %exit
ctx_is_not_null: ; preds = %entry
%5 = bitcast i8* %1 to void (i8*)*
call void %5(i8* %2)
br label %exit
exit: ; preds = %ctx_is_not_null, %ctx_is_null
%6 = load %Fiber** @"Fiber::first_fiber"
store %Fiber* %6, %Fiber** %fiber
br label %while
while: ; preds = %body, %exit
%7 = load %Fiber** %fiber
%8 = ptrtoint %Fiber* %7 to i32
%9 = icmp ne i32 %8, 0
br i1 %9, label %body, label %exit1
body: ; preds = %while
%10 = load %Fiber** %fiber
call void @"*Fiber#push_gc_roots<Fiber>:Void"(%Fiber* %10)
%11 = load %Fiber** %fiber
%12 = call %Fiber* @"*Fiber#next_fiber<Fiber>:Fiber?"(%Fiber* %11)
store %Fiber* %12, %Fiber** %fiber
br label %while
exit1: ; preds = %while
ret i1 false
}
declare void @GC_push_all_eager(i8*, i8*)
declare void @"*Fiber#push_gc_roots<Fiber>:Void"(%Fiber*)
declare %Fiber* @"*Fiber#next_fiber<Fiber>:Fiber?"(%Fiber*)
declare void @GC_set_push_other_roots(void ()*)
declare i32 @co_thread_init()
declare i8* @co_current()
define i1 @"~fun_literal_2"() {
entry:
ret i1 false
}
declare i8* @co_set_data(i8*, i8*)
declare %Fiber* @"*Fiber::new:Fiber"()
declare %"Array(Fiber)"* @"*Array(Fiber)::new<Array(Fiber):Class>:Array(Fiber)"(i32)
declare i8* @event_base_new()
declare %"Event::Base" @"*Event::Base::new:Event::Base"()
; Function Attrs: nounwind
declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1 zeroext) #1
declare i8* @mmap(i8*, i64, i32, i32, i32, i32)
define %"(Nil | Void)" @"~fun_literal_3"(i8* %fiber) {
alloca:
%0 = alloca %"(Nil | Void)"
br label %entry
entry: ; preds = %alloca
%1 = bitcast i8* %fiber to %Fiber*
%2 = call %"(Nil | Void)" @"*Fiber#run<Fiber>:(Nil | Void)"(%Fiber* %1)
store %"(Nil | Void)" %2, %"(Nil | Void)"* %0
%3 = load %"(Nil | Void)"* %0
ret %"(Nil | Void)" %3
}
declare %"(Nil | Void)" @"*Fiber#run<Fiber>:(Nil | Void)"(%Fiber*)
declare i8* @co_create(void (i8*)*, i8*, i8*, i32)
declare %Fiber* @"*Fiber::new<&( -> Void)>:Fiber"(%"->")
define void @"~fun_literal_4"() {
entry:
%0 = call i32 @"*Event::Base#run_loop<Event::Base>:Int32"(%"Event::Base"* @"Scheduler::eb")
ret void
}
declare i32 @event_base_loop(i8*, i32)
declare i32 @"*Event::Base#run_loop<Event::Base>:Int32"(%"Event::Base"*)
define void @"~fun_literal_5"() {
entry:
call void @"*Scheduler::reschedule:Void"()
ret void
}
declare i8* @co_get_data(i8*)
declare void @co_call(i8*)
declare void @"*Scheduler::reschedule:Void"()
declare %"->" @"*Fiber::rescheduler=<( -> Void)>:( -> Void)"(%"->")
declare i32 @isatty(i32)
declare i32 @fcntl(i32, i32, ...)
define %"(Nil | Void)" @"~fun_literal_6"(i32 %s, i32 %flags, i8* %data) {
alloca:
%fd_io = alloca %FileDescriptorIO*
%0 = alloca %"(Nil | Void)"
%1 = alloca %"(Nil | Void)"
br label %entry
entry: ; preds = %alloca
%2 = bitcast i8* %data to %FileDescriptorIO*
store %FileDescriptorIO* %2, %FileDescriptorIO** %fd_io
%3 = call i1 @"*LibEvent2::EventFlags@Enum#includes?<LibEvent2::EventFlags, LibEvent2::EventFlags>:Bool"(i32 %flags, i32 2)
br i1 %3, label %then, label %else
then: ; preds = %entry
%4 = load %FileDescriptorIO** %fd_io
%5 = call %"(Nil | Void)" @"*FileDescriptorIO#resume_read<FileDescriptorIO>:(Nil | Void)"(%FileDescriptorIO* %4)
br label %exit
else: ; preds = %entry
br label %exit
exit: ; preds = %else, %then
%6 = call i1 @"*LibEvent2::EventFlags@Enum#includes?<LibEvent2::EventFlags, LibEvent2::EventFlags>:Bool"(i32 %flags, i32 4)
br i1 %6, label %then1, label %else2
then1: ; preds = %exit
%7 = load %FileDescriptorIO** %fd_io
%8 = call %"(Nil | Void)" @"*FileDescriptorIO#resume_write<FileDescriptorIO>:(Nil | Void)"(%FileDescriptorIO* %7)
store %"(Nil | Void)" %8, %"(Nil | Void)"* %0
br label %exit3
else2: ; preds = %exit
%9 = getelementptr inbounds %"(Nil | Void)"* %1, i32 0, i32 0
store i32 0, i32* %9
%10 = getelementptr inbounds %"(Nil | Void)"* %1, i32 0, i32 1
store [1 x i64] zeroinitializer, [1 x i64]* %10
br label %exit3
exit3: ; preds = %else2, %then1
%11 = phi %"(Nil | Void)"* [ %0, %then1 ], [ %1, %else2 ]
%12 = load %"(Nil | Void)"* %11
ret %"(Nil | Void)" %12
}
declare i1 @"*LibEvent2::EventFlags@Enum#includes?<LibEvent2::EventFlags, LibEvent2::EventFlags>:Bool"(i32, i32)
declare %"(Nil | Void)" @"*FileDescriptorIO#resume_read<FileDescriptorIO>:(Nil | Void)"(%FileDescriptorIO*)
declare %"(Nil | Void)" @"*FileDescriptorIO#resume_write<FileDescriptorIO>:(Nil | Void)"(%FileDescriptorIO*)
declare i8* @event_new(i8*, i32, i32, void (i32, i32, i8*)*, i8*)
declare i32 @event_add(i8*, %"struct.LibC::TimeVal"*)
define %"(Nil | Void)" @"~fun_literal_7"(i8* %obj, i8* %data) {
alloca:
%same_object = alloca %FileDescriptorIO*
%0 = alloca %"(Nil | Void)"
br label %entry
entry: ; preds = %alloca
%1 = bitcast i8* %obj to %FileDescriptorIO*
store %FileDescriptorIO* %1, %FileDescriptorIO** %same_object
%2 = load %FileDescriptorIO** %same_object
%3 = call %"(Nil | Void)" @"*FileDescriptorIO#finalize<FileDescriptorIO>:(Nil | Void)"(%FileDescriptorIO* %2)
store %"(Nil | Void)" %3, %"(Nil | Void)"* %0
%4 = load %"(Nil | Void)"* %0
ret %"(Nil | Void)" %4
}
declare i64 @write(i32, i8*, i64)
define %"(Nil | Void)" @"~fun_literal_8"(i32 %s, i32 %flags, i8* %data) {
alloca:
%fd_io = alloca %FileDescriptorIO*
%0 = alloca %"(Nil | Void)"
%1 = alloca %"(Nil | Void)"
br label %entry
entry: ; preds = %alloca
%2 = bitcast i8* %data to %FileDescriptorIO*
store %FileDescriptorIO* %2, %FileDescriptorIO** %fd_io
%3 = call i1 @"*LibEvent2::EventFlags@Enum#includes?<LibEvent2::EventFlags, LibEvent2::EventFlags>:Bool"(i32 %flags, i32 4)
br i1 %3, label %then, label %else
then: ; preds = %entry
%4 = load %FileDescriptorIO** %fd_io
%5 = call %"(Nil | Void)" @"*FileDescriptorIO#resume_write<FileDescriptorIO>:(Nil | Void)"(%FileDescriptorIO* %4)
store %"(Nil | Void)" %5, %"(Nil | Void)"* %0
br label %exit
else: ; preds = %entry
%6 = getelementptr inbounds %"(Nil | Void)"* %1, i32 0, i32 0
store i32 0, i32* %6
%7 = getelementptr inbounds %"(Nil | Void)"* %1, i32 0, i32 1
store [1 x i64] zeroinitializer, [1 x i64]* %7
br label %exit
exit: ; preds = %else, %then
%8 = phi %"(Nil | Void)"* [ %0, %then ], [ %1, %else ]
%9 = load %"(Nil | Void)"* %8
ret %"(Nil | Void)" %9
}
declare void @event_free(i8*)
declare i8* @strerror(i32)
; Function Attrs: noreturn
define void @"*raise<Errno>:NoReturn"(%Errno* %ex) #0 {
alloca:
%unwind_ex = alloca %"struct.LibABI::UnwindException"*
br label %entry
entry: ; preds = %alloca
%0 = call %"struct.LibABI::UnwindException"* @"*Pointer(LibABI::UnwindException)::malloc<Pointer(LibABI::UnwindException):Class>:Pointer(LibABI::UnwindException)"(i32 415)
store %"struct.LibABI::UnwindException"* %0, %"struct.LibABI::UnwindException"** %unwind_ex
%1 = load %"struct.LibABI::UnwindException"** %unwind_ex
%2 = call i64 @"*UInt64::zero:UInt64"()
%3 = getelementptr inbounds %"struct.LibABI::UnwindException"* %1, i32 0, i32 0
store i64 %2, i64* %3
%4 = load %"struct.LibABI::UnwindException"** %unwind_ex
%5 = call i64 @"*UInt64::zero:UInt64"()
%6 = getelementptr inbounds %"struct.LibABI::UnwindException"* %4, i32 0, i32 1
store i64 %5, i64* %6
%7 = load %"struct.LibABI::UnwindException"** %unwind_ex
%8 = ptrtoint %Errno* %ex to i64
%9 = getelementptr inbounds %"struct.LibABI::UnwindException"* %7, i32 0, i32 4
store i64 %8, i64* %9
%10 = load %"struct.LibABI::UnwindException"** %unwind_ex
%11 = getelementptr inbounds %"struct.LibABI::UnwindException"* %10, i32 0, i32 5
store i32 21, i32* %11
%12 = load %"struct.LibABI::UnwindException"** %unwind_ex
call void @__crystal_raise(%"struct.LibABI::UnwindException"* %12)
unreachable
}
; Function Attrs: noreturn
define void @"*raise<IO::Error>:NoReturn"(%"IO::Error"* %ex) #0 {
alloca:
%unwind_ex = alloca %"struct.LibABI::UnwindException"*
br label %entry
entry: ; preds = %alloca
%0 = call %"struct.LibABI::UnwindException"* @"*Pointer(LibABI::UnwindException)::malloc<Pointer(LibABI::UnwindException):Class>:Pointer(LibABI::UnwindException)"(i32 415)
store %"struct.LibABI::UnwindException"* %0, %"struct.LibABI::UnwindException"** %unwind_ex
%1 = load %"struct.LibABI::UnwindException"** %unwind_ex
%2 = call i64 @"*UInt64::zero:UInt64"()
%3 = getelementptr inbounds %"struct.LibABI::UnwindException"* %1, i32 0, i32 0
store i64 %2, i64* %3
%4 = load %"struct.LibABI::UnwindException"** %unwind_ex
%5 = call i64 @"*UInt64::zero:UInt64"()
%6 = getelementptr inbounds %"struct.LibABI::UnwindException"* %4, i32 0, i32 1
store i64 %5, i64* %6
%7 = load %"struct.LibABI::UnwindException"** %unwind_ex
%8 = ptrtoint %"IO::Error"* %ex to i64
%9 = getelementptr inbounds %"struct.LibABI::UnwindException"* %7, i32 0, i32 4
store i64 %8, i64* %9
%10 = load %"struct.LibABI::UnwindException"** %unwind_ex
%11 = getelementptr inbounds %"struct.LibABI::UnwindException"* %10, i32 0, i32 5
store i32 19, i32* %11
%12 = load %"struct.LibABI::UnwindException"** %unwind_ex
call void @__crystal_raise(%"struct.LibABI::UnwindException"* %12)
unreachable
}
declare i32 @close(i32)
declare %"(Nil | Void)" @"*FileDescriptorIO#finalize<FileDescriptorIO>:(Nil | Void)"(%FileDescriptorIO*)
declare void @GC_register_finalizer_ignore_self(i8*, void (i8*, i8*)*, i8*, %"->"*, i8**)
declare %FileDescriptorIO* @"*FileDescriptorIO::new<Int32, Bool, Bool>:FileDescriptorIO"(i32, i1, i1)
declare i1 @"*FileDescriptorIO#flush_on_newline=<FileDescriptorIO, Bool>:Bool"(%FileDescriptorIO*, i1)
declare i8** @"*Pointer(Pointer(UInt8))@Pointer(T)#+<Pointer(Pointer(UInt8)), Int32>:Pointer(Pointer(UInt8))"(i8**, i32)
declare %"Slice(Pointer(UInt8))" @"*Pointer(Pointer(UInt8))@Pointer(T)#to_slice<Pointer(Pointer(UInt8)), Int32>:Slice(Pointer(UInt8))"(i8**, i32)
declare i32 @"*Slice(Pointer(UInt8))@Slice(T)#length<Slice(Pointer(UInt8))>:Int32"(%"Slice(Pointer(UInt8))"*)
declare i8* @"*Pointer(Pointer(UInt8))@Pointer(T)#[]<Pointer(Pointer(UInt8)), Int32>:Pointer(UInt8)"(i8**, i32)
define %"(Nil | Void)" @"~fun_literal_9"(i32 %num) {
alloca:
%__arg0 = alloca %"->"
%0 = alloca %"(Nil | Void)"
%__arg08 = alloca %"->"
%1 = alloca %"(Nil | Void)"
br label %entry
entry: ; preds = %alloca
%2 = load %"Hash(Int32, (Int32 -> Void))"** @"Signal::handlers"
%3 = ptrtoint %"Hash(Int32, (Int32 -> Void))"* %2 to i32
%4 = icmp eq i32 %3, 0
%5 = select i1 %4, i32 0, i32 74
%6 = icmp eq i32 0, %5
br i1 %6, label %current_def, label %next_def
current_def: ; preds = %entry
call void @"*Nil#not_nil!<Nil>:NoReturn"(i1 false)
unreachable
next_def: ; preds = %entry
%7 = icmp eq i32 74, %5
br i1 %7, label %current_def1, label %next_def2
current_def1: ; preds = %next_def
%8 = call %"Hash(Int32, (Int32 -> Void))"* @"*Hash(Int32, (Int32 -> Void))@Object#not_nil!<Hash(Int32, (Int32 -> Void))>:Hash(Int32, (Int32 -> Void))"(%"Hash(Int32, (Int32 -> Void))"* %2)
br label %exit
next_def2: ; preds = %next_def
unreachable
exit: ; preds = %current_def1
%9 = phi %"Hash(Int32, (Int32 -> Void))"* [ %8, %current_def1 ]
%10 = call %"->" @"*Hash(Int32, (Int32 -> Void))@Hash(K, V)#[]?<Hash(Int32, (Int32 -> Void)), Int32>:((Int32 -> Void))?"(%"Hash(Int32, (Int32 -> Void))"* %9, i32 %num)
%11 = extractvalue %"->" %10, 0
%12 = ptrtoint i8* %11 to i32
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i32 0, i32 276
%15 = icmp eq i32 0, %14
br i1 %15, label %current_def3, label %next_def4
current_def3: ; preds = %exit
%16 = getelementptr inbounds %"(Nil | Void)"* %0, i32 0, i32 0
store i32 0, i32* %16
%17 = getelementptr inbounds %"(Nil | Void)"* %0, i32 0, i32 1
store [1 x i64] zeroinitializer, [1 x i64]* %17
br label %exit5
next_def4: ; preds = %exit
%18 = icmp eq i32 276, %14
br i1 %18, label %current_def6, label %next_def7
exit5: ; preds = %exit9, %current_def3
%19 = phi %"(Nil | Void)"* [ %0, %current_def3 ], [ %1, %exit9 ]
%20 = load %"(Nil | Void)"* %19
ret %"(Nil | Void)" %20
current_def6: ; preds = %next_def4
store %"->" %10, %"->"* %__arg08
%21 = load %"->"* %__arg08
%22 = extractvalue %"->" %21, 0
%23 = extractvalue %"->" %21, 1
%24 = icmp eq i8* %23, null
br i1 %24, label %ctx_is_null, label %ctx_is_not_null
next_def7: ; preds = %next_def4
unreachable
ctx_is_null: ; preds = %current_def6
%25 = bitcast i8* %22 to void (i32)*
call void %25(i32 %num)
br label %exit9
ctx_is_not_null: ; preds = %current_def6
%26 = bitcast i8* %22 to void (i8*, i32)*
call void %26(i8* %23, i32 %num)
br label %exit9
exit9: ; preds = %ctx_is_not_null, %ctx_is_null
%27 = getelementptr inbounds %"(Nil | Void)"* %1, i32 0, i32 0
store i32 511, i32* %27
br label %exit5
}
declare void @"*Nil#not_nil!<Nil>:NoReturn"(i1)
declare %"Hash(Int32, (Int32 -> Void))"* @"*Hash(Int32, (Int32 -> Void))@Object#not_nil!<Hash(Int32, (Int32 -> Void))>:Hash(Int32, (Int32 -> Void))"(%"Hash(Int32, (Int32 -> Void))"*)
declare %"->" @"*Hash(Int32, (Int32 -> Void))@Hash(K, V)#[]?<Hash(Int32, (Int32 -> Void)), Int32>:((Int32 -> Void))?"(%"Hash(Int32, (Int32 -> Void))"*, i32)
declare void @signal(i32, void (i32)*)
declare void @"*Signal#ignore<Signal>:Void"(i32)
define void @"~fun_literal_10"() {
alloca:
%__temp_299 = alloca i32*
%0 = alloca %"(Nil | Int32)"
%1 = alloca %"(Nil | Int32)"
br label %entry
entry: ; preds = %alloca
br label %while
catch: ; preds = %invoke_out, %body
%2 = landingpad %landing_pad personality i32 (i32, i32, i64, %"struct.LibABI::UnwindException"*, i8*)* @__crystal_personality
cleanup
%3 = extractvalue %landing_pad %2, 0
%4 = extractvalue %landing_pad %2, 1
br label %this_rescue
while: ; preds = %invoke_out1, %entry
br i1 true, label %body, label %exit
body: ; preds = %while
invoke void @"*sleep<Int32>:Void"(i32 5)
to label %invoke_out unwind label %catch
exit: ; preds = %while
unreachable
invoke_out: ; preds = %body
%5 = invoke %"(Nil | Int32)" @"*Fiber::stack_pool_collect:(Nil | Int32)"()
to label %invoke_out1 unwind label %catch
invoke_out1: ; preds = %invoke_out
store %"(Nil | Int32)" %5, %"(Nil | Int32)"* %0
br label %while
this_rescue: ; preds = %catch
%6 = bitcast i8* %3 to %"struct.LibABI::UnwindException"*
%7 = call i64 @__crystal_get_exception(%"struct.LibABI::UnwindException"* %6)
%8 = inttoptr i64 %7 to i32*
store i32* %8, i32** %__temp_299
%9 = call %"String::Builder"* @"*String::Builder::new:String::Builder"()
%10 = call %"String::Builder"* @"*String::Builder@IO#<<<String::Builder, String>:String::Builder"(%"String::Builder"* %9, %String* bitcast ({ i32, i32, i32, [22 x i8] }* @str12 to %String*))
%11 = load i32** %__temp_299
%12 = call %"String::Builder"* @"*String::Builder@IO#<<<String::Builder, Exception+>:String::Builder"(%"String::Builder"* %10, i32* %11)
%13 = call %String* @"*String::Builder#to_s<String::Builder>:String"(%"String::Builder"* %12)
%14 = call %"(Nil | Int32)" @"*puts<String>:(Nil | Int32)"(%String* %13)
store %"(Nil | Int32)" %14, %"(Nil | Int32)"* %1
br label %exit2
next_rescue: ; No predecessors!
%15 = bitcast i8* %3 to %"struct.LibABI::UnwindException"*
call void @__crystal_raise(%"struct.LibABI::UnwindException"* %15)
unreachable
exit2: ; preds = %this_rescue
%16 = phi %"(Nil | Int32)"* [ %1, %this_rescue ]
ret void
}
define void @"*sleep<Int32>:Void"(i32 %seconds) {
entry:
%0 = icmp slt i32 %seconds, 0
br i1 %0, label %then, label %else
then: ; preds = %entry
%1 = call %ArgumentError* @"*ArgumentError::new<String>:ArgumentError"(%String* bitcast ({ i32, i32, i32, [31 x i8] }* @str11 to %String*))
call void @"*raise<ArgumentError>:NoReturn"(%ArgumentError* %1)
unreachable
else: ; preds = %entry
%2 = call i32 @"*Scheduler::sleep<Int32>:Int32"(i32 %seconds)
call void @"*Scheduler::reschedule:Void"()
ret void
}
declare %ArgumentError* @"*ArgumentError::new<String>:ArgumentError"(%String*)
define void @"~fun_literal_11"(i32 %s, i32 %flags, i8* %data) {
alloca:
%fiber = alloca %Fiber*
br label %entry
entry: ; preds = %alloca
%0 = bitcast i8* %data to %Fiber*
store %Fiber* %0, %Fiber** %fiber
%1 = load %Fiber** %fiber
call void @"*Fiber#resume<Fiber>:Void"(%Fiber* %1)
ret void
}
declare void @"*Fiber#resume<Fiber>:Void"(%Fiber*)
declare i32 @"*Scheduler::sleep<Int32>:Int32"(i32)
declare void @munmap(i8*, i64)
declare %"(Nil | Int32)" @"*Fiber::stack_pool_collect:(Nil | Int32)"()
declare %"String::Builder"* @"*String::Builder@IO#<<<String::Builder, Exception+>:String::Builder"(%"String::Builder"*, i32*)
define %"(Nil | Int32)" @"*puts<String>:(Nil | Int32)"(%String* %_arg0) {
alloca:
%objects = alloca %"{String}"
%0 = alloca %"{String}"
%1 = alloca %"(Nil | Int32)"
br label %entry
entry: ; preds = %alloca
%2 = getelementptr inbounds %"{String}"* %0, i32 0, i32 0
store %String* %_arg0, %String** %2
%3 = load %"{String}"* %0
store %"{String}" %3, %"{String}"* %objects
%4 = load %FileDescriptorIO** @STDOUT
%5 = getelementptr inbounds %"{String}"* %objects, i32 0, i32 0
%6 = load %String** %5
%7 = call %"(Nil | Int32)" @"*FileDescriptorIO@IO#puts<FileDescriptorIO, String>:(Nil | Int32)"(%FileDescriptorIO* %4, %String* %6)
store %"(Nil | Int32)" %7, %"(Nil | Int32)"* %1
%8 = load %"(Nil | Int32)"* %1
ret %"(Nil | Int32)" %8
}
declare %"(Nil | Int32)" @"*FileDescriptorIO@IO#puts<FileDescriptorIO, String>:(Nil | Int32)"(%FileDescriptorIO*, %String*)
declare %"Array(Fiber)"* @"*Scheduler::enqueue<Fiber>:Array(Fiber)"(%Fiber*)
declare i32 @main(i32, i8**)
declare %"Array(Base+)"* @"*Array(Base+)::new<Array(Base+):Class>:Array(Base+)"(i32)
declare %LightLeaf* @"*LightLeaf::new:LightLeaf"()
declare %"Array(Base+)"* @"*Array(Base+)@Array(T)#<<<Array(Base+), LightLeaf>:Array(Base+)"(%"Array(Base+)"*, %LightLeaf*)
define %"Array(Base+)"* @"*create_branch_array:Array(Base+)"() {
alloca:
%__temp_301 = alloca %"Array(SturdyBranch)"*
%__temp_302 = alloca %SturdyBranch**
%__temp_303 = alloca %"Array(NotSoSturdyBranch)"*
%__temp_304 = alloca %NotSoSturdyBranch**
entry: ; No predecessors!
%0 = load %"Array(String)"** @ARGV
%1 = call i32 @"*Array(String)@Array(T)#length<Array(String)>:Int32"(%"Array(String)"* %0)
%2 = icmp sgt i32 %1, 0
br i1 %2, label %then, label %else
then: ; preds = %entry
%3 = call %"Array(SturdyBranch)"* @"*Array(SturdyBranch)::new<Array(SturdyBranch):Class, Int32>:Array(SturdyBranch)"(i32 304, i32 1)
store %"Array(SturdyBranch)"* %3, %"Array(SturdyBranch)"** %__temp_301
%4 = load %"Array(SturdyBranch)"** %__temp_301
%5 = call i32 @"*Array(SturdyBranch)@Array(T)#length=<Array(SturdyBranch), Int32>:Int32"(%"Array(SturdyBranch)"* %4, i32 1)
%6 = load %"Array(SturdyBranch)"** %__temp_301
%7 = call %SturdyBranch** @"*Array(SturdyBranch)@Array(T)#buffer<Array(SturdyBranch)>:Pointer(SturdyBranch)"(%"Array(SturdyBranch)"* %6)
store %SturdyBranch** %7, %SturdyBranch*** %__temp_302
%8 = load %SturdyBranch*** %__temp_302
%9 = call %SturdyBranch* @"*SturdyBranch::new:SturdyBranch"()
%10 = call %SturdyBranch* @"*Pointer(SturdyBranch)@Pointer(T)#[]=<Pointer(SturdyBranch), Int32, SturdyBranch>:SturdyBranch"(%SturdyBranch** %8, i32 0, %SturdyBranch* %9)
%11 = load %"Array(SturdyBranch)"** %__temp_301
else: ; preds = %entry
}
declare i32 @"*Array(String)@Array(T)#length<Array(String)>:Int32"(%"Array(String)"*)
declare %"Array(SturdyBranch)"* @"*Array(SturdyBranch)::new<Array(SturdyBranch):Class, Int32>:Array(SturdyBranch)"(i32, i32)
declare i32 @"*Array(SturdyBranch)@Array(T)#length=<Array(SturdyBranch), Int32>:Int32"(%"Array(SturdyBranch)"*, i32)
declare %SturdyBranch** @"*Array(SturdyBranch)@Array(T)#buffer<Array(SturdyBranch)>:Pointer(SturdyBranch)"(%"Array(SturdyBranch)"*)
declare %SturdyBranch* @"*SturdyBranch::new:SturdyBranch"()
declare %SturdyBranch* @"*Pointer(SturdyBranch)@Pointer(T)#[]=<Pointer(SturdyBranch), Int32, SturdyBranch>:SturdyBranch"(%SturdyBranch**, i32, %SturdyBranch*)
attributes #0 = { noreturn }
attributes #1 = { nounwind }
attributes #2 = { noinline }
Bug: trying to upcast Array(Base+) <- Array(SturdyBranch)
*raise<String>:NoReturn +70 [4378185494]
*Crystal::CodeGenVisitor#upcast<Crystal::CodeGenVisitor, LLVM::Value, Crystal::Type+, Crystal::Type+>:LLVM::Value +2060 [4381320572]
*Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::ASTNode+, Crystal::CodeGenVisitor>:Nil +5319 [4381272583]
*Crystal::CodeGenVisitor#codegen_if_branch<Crystal::CodeGenVisitor, Crystal::CodeGenVisitor::Phi, Crystal::ASTNode+, LLVM::BasicBlock, Bool>:(Nil | LLVM::Value) +55 [4381345703]
*Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::ASTNode+, Crystal::CodeGenVisitor>:Nil +6147 [4381273411]
*Crystal::CodeGenVisitor#codegen_fun<Crystal::CodeGenVisitor, String, Crystal::Def+, Crystal::Type+, Bool, LLVM::Module, Bool, Bool>:LLVM::Function +1652 [4381328308]
*Crystal::CodeGenVisitor#target_def_fun<Crystal::CodeGenVisitor, Crystal::Def+, Crystal::Type+>:LLVM::Function +2154 [4381323658]
*Crystal::CodeGenVisitor#visit<Crystal::CodeGenVisitor, Crystal::Call>:Bool +2220 [4381360604]
*Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::ASTNode+, Crystal::CodeGenVisitor>:Nil +1102 [4381268366]
*Crystal::CodeGenVisitor#prepare_call_args_non_external<Crystal::CodeGenVisitor, Crystal::Call, Crystal::Def+, Crystal::Type+>:{Array(LLVM::Value), Bool} +686 [4381379166]
*Crystal::CodeGenVisitor#visit<Crystal::CodeGenVisitor, Crystal::Call>:Bool +272 [4381358656]
*Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::ASTNode+, Crystal::CodeGenVisitor>:Nil +1102 [4381268366]
*Crystal::CodeGenVisitor#visit<Crystal::CodeGenVisitor, Crystal::Assign>:(Nil | Bool) +291 [4381339523]
*Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::ASTNode+, Crystal::CodeGenVisitor>:Nil +2130 [4381269394]
*Crystal::Program#build<Crystal::Program, Crystal::Expressions, (Nil | String | Bool | Array(String)), Bool, LLVM::Module, Bool>:Hash(String, LLVM::Module) +185 [4381147833]
*Crystal::Compiler#build<Crystal::Compiler, Crystal::Program, Crystal::Expressions, Array(Crystal::Compiler::Source), String>:(Nil | Int32 | Bool) +3584 [4381133184]
*Crystal::Compiler#compile<Crystal::Compiler, Array(Crystal::Compiler::Source), String>:Crystal::Compiler::Result +5228 [4380456636]
*Crystal::Command::run<Array(String)>:(Nil | Bool | FileDescriptorIO+ | Crystal::Compiler::Result | Array(Crystal::Init::View+:Class)) +1053 [4384017485]
main +17014 [4384016150]
Error: you've found a bug in the Crystal compiler. Please open an issue: https://github.com/manastech/crystal/issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment