Gokul-G
6/19/2017 - 11:50 AM

swiftc -emit-ir main.swift

swiftc -emit-ir main.swift

; ModuleID = '-'
source_filename = "-"
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.9"

%Si = type <{ i64 }>
%struct._SwiftEmptyArrayStorage = type { %struct.HeapObject, %struct._SwiftArrayBodyStorage }
%struct.HeapObject = type { %struct.HeapMetadata*, %struct.StrongRefCount, %struct.WeakRefCount }
%struct.HeapMetadata = type opaque
%struct.StrongRefCount = type { i32 }
%struct.WeakRefCount = type { i32 }
%struct._SwiftArrayBodyStorage = type { i64, i64 }
%swift.type = type { i64 }
%swift.protocol = type { i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i32, i32, i16, i16, i32 }
%swift.bridge = type opaque
%Any = type { [24 x i8], %swift.type* }

@_Tv4main6resultSi = hidden global %Si zeroinitializer, align 8
@_swiftEmptyArrayStorage = external global %struct._SwiftEmptyArrayStorage, align 8
@_TMLP_ = linkonce_odr hidden global %swift.type* null, align 8
@_swift_getExistentialTypeMetadata = external global %swift.type* (i64, %swift.protocol**)*
@_TMSi = external global %swift.type, align 8
@__swift_reflection_version = linkonce_odr hidden constant i16 1
@llvm.used = appending global [1 x i8*] [i8* bitcast (i16* @__swift_reflection_version to i8*)], section "llvm.metadata", align 8

define i32 @main(i32, i8**) #0 {
entry:
  %2 = bitcast i8** %1 to i8*
  %3 = call i64 @_TF4main3addFTSiSi_Si(i64 1, i64 2)
  store i64 %3, i64* getelementptr inbounds (%Si, %Si* @_Tv4main6resultSi, i32 0, i32 0), align 8
  %4 = call %swift.type* @_TMaP_() #5
  %5 = call { %swift.bridge*, i8* } @_TFs27_allocateUninitializedArrayurFBwTGSax_Bp_(i64 1, %swift.type* %4)
  %6 = extractvalue { %swift.bridge*, i8* } %5, 0
  %7 = extractvalue { %swift.bridge*, i8* } %5, 1
  %8 = bitcast i8* %7 to %Any*
  %9 = getelementptr inbounds %Any, %Any* %8, i32 0, i32 1
  store %swift.type* @_TMSi, %swift.type** %9, align 8
  %10 = getelementptr inbounds %Any, %Any* %8, i32 0, i32 0
  %object = bitcast [24 x i8]* %10 to %Si*
  %11 = load i64, i64* getelementptr inbounds (%Si, %Si* @_Tv4main6resultSi, i32 0, i32 0), align 8
  %object._value = getelementptr inbounds %Si, %Si* %object, i32 0, i32 0
  store i64 %11, i64* %object._value, align 8
  %12 = call { i64, i64, i64 } @_TIFs5printFTGSaP__9separatorSS10terminatorSS_T_A0_()
  %13 = extractvalue { i64, i64, i64 } %12, 0
  %14 = extractvalue { i64, i64, i64 } %12, 1
  %15 = extractvalue { i64, i64, i64 } %12, 2
  %16 = call { i64, i64, i64 } @_TIFs5printFTGSaP__9separatorSS10terminatorSS_T_A1_()
  %17 = extractvalue { i64, i64, i64 } %16, 0
  %18 = extractvalue { i64, i64, i64 } %16, 1
  %19 = extractvalue { i64, i64, i64 } %16, 2
  call void @_TFs5printFTGSaP__9separatorSS10terminatorSS_T_(%swift.bridge* %6, i64 %13, i64 %14, i64 %15, i64 %17, i64 %18, i64 %19)
  ret i32 0
}

define hidden i64 @_TF4main3addFTSiSi_Si(i64, i64) #0 {
entry:
  %2 = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %0, i64 %1)
  %3 = extractvalue { i64, i1 } %2, 0
  %4 = extractvalue { i64, i1 } %2, 1
  br i1 %4, label %6, label %5

; <label>:5:                                      ; preds = %entry
  ret i64 %3

; <label>:6:                                      ; preds = %entry
  call void @llvm.trap()
  unreachable
}

; Function Attrs: noinline
declare void @_TFs5printFTGSaP__9separatorSS10terminatorSS_T_(%swift.bridge*, i64, i64, i64, i64, i64, i64) #1

declare { %swift.bridge*, i8* } @_TFs27_allocateUninitializedArrayurFBwTGSax_Bp_(i64, %swift.type*) #0

; Function Attrs: nounwind readnone
define linkonce_odr hidden %swift.type* @_TMaP_() #2 {
entry:
  %protocols = alloca [0 x %swift.protocol*], align 8
  %0 = load %swift.type*, %swift.type** @_TMLP_, align 8
  %1 = icmp eq %swift.type* %0, null
  br i1 %1, label %cacheIsNull, label %cont

cacheIsNull:                                      ; preds = %entry
  %2 = bitcast [0 x %swift.protocol*]* %protocols to i8*
  call void @llvm.lifetime.start(i64 0, i8* %2)
  %3 = bitcast [0 x %swift.protocol*]* %protocols to %swift.protocol**
  %4 = call %swift.type* @swift_rt_swift_getExistentialTypeMetadata(i64 0, %swift.protocol** %3) #7
  %5 = bitcast %swift.protocol** %3 to i8*
  call void @llvm.lifetime.end(i64 0, i8* %5)
  store atomic %swift.type* %4, %swift.type** @_TMLP_ release, align 8
  br label %cont

cont:                                             ; preds = %cacheIsNull, %entry
  %6 = phi %swift.type* [ %0, %entry ], [ %4, %cacheIsNull ]
  ret %swift.type* %6
}

; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.start(i64, i8* nocapture) #3

; Function Attrs: noinline nounwind
define linkonce_odr hidden %swift.type* @swift_rt_swift_getExistentialTypeMetadata(i64, %swift.protocol**) #4 {
entry:
  %load = load %swift.type* (i64, %swift.protocol**)*, %swift.type* (i64, %swift.protocol**)** @_swift_getExistentialTypeMetadata
  %2 = tail call %swift.type* %load(i64 %0, %swift.protocol** %1)
  ret %swift.type* %2
}

; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.end(i64, i8* nocapture) #3

; Function Attrs: noinline
declare { i64, i64, i64 } @_TIFs5printFTGSaP__9separatorSS10terminatorSS_T_A0_() #1

; Function Attrs: noinline
declare { i64, i64, i64 } @_TIFs5printFTGSaP__9separatorSS10terminatorSS_T_A1_() #1

; Function Attrs: nounwind readnone
declare { i64, i1 } @llvm.sadd.with.overflow.i64(i64, i64) #5

; Function Attrs: noreturn nounwind
declare void @llvm.trap() #6

attributes #0 = { "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "target-cpu"="core2" "target-features"="+ssse3,+cx16,+fxsr,+mmx,+x87,+sse,+sse2,+sse3" }
attributes #1 = { noinline "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "target-cpu"="core2" "target-features"="+ssse3,+cx16,+fxsr,+mmx,+x87,+sse,+sse2,+sse3" }
attributes #2 = { nounwind readnone "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "target-cpu"="core2" "target-features"="+ssse3,+cx16,+fxsr,+mmx,+x87,+sse,+sse2,+sse3" }
attributes #3 = { argmemonly nounwind }
attributes #4 = { noinline nounwind }
attributes #5 = { nounwind readnone }
attributes #6 = { noreturn nounwind }
attributes #7 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !9, !10}

!0 = !{i32 1, !"Objective-C Version", i32 2}
!1 = !{i32 1, !"Objective-C Image Info Version", i32 0}
!2 = !{i32 1, !"Objective-C Image Info Section", !"__DATA, __objc_imageinfo, regular, no_dead_strip"}
!3 = !{i32 4, !"Objective-C Garbage Collection", i32 1024}
!4 = !{i32 1, !"Objective-C Class Properties", i32 64}
!5 = !{i32 6, !"Linker Options", !6}
!6 = !{!7, !8}
!7 = !{!"-lswiftCore"}
!8 = !{!"-lobjc"}
!9 = !{i32 1, !"PIC Level", i32 2}
!10 = !{i32 1, !"Swift Version", i32 4}