Created
May 14, 2015 19:41
-
-
Save niconii/7db70c771960b4ad3f36 to your computer and use it in GitHub Desktop.
Iterator chain vs. while loop comparison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2,3c2,3 | |
< .file "fulliter.0.rs" | |
< .section .text._ZN4main20h34b4fa9d2be136ebeaaE,"ax",@progbits | |
--- | |
> .file "while.0.rs" | |
> .section .text._ZN4main20h3118530cba082203eaaE,"ax",@progbits | |
5,6c5,6 | |
< .type _ZN4main20h34b4fa9d2be136ebeaaE,@function | |
< _ZN4main20h34b4fa9d2be136ebeaaE: | |
--- | |
> .type _ZN4main20h3118530cba082203eaaE,@function | |
> _ZN4main20h3118530cba082203eaaE: | |
17a18 | |
> movq $0, 64(%rsp) | |
22d22 | |
< leal 1(%rax), %ecx | |
26c26 | |
< leal 2(%rax), %edx | |
--- | |
> leal 1(%rax), %ecx | |
30c30 | |
< leal 3(%rax), %ecx | |
--- | |
> leal 2(%rax), %ecx | |
32c32 | |
< cvtsi2sdl %edx, %xmm1 | |
--- | |
> cvtsi2sdl %ecx, %xmm1 | |
34c34 | |
< leal 4(%rax), %edx | |
--- | |
> leal 3(%rax), %ecx | |
38c38 | |
< leal 5(%rax), %ecx | |
--- | |
> leal 4(%rax), %ecx | |
40c40 | |
< cvtsi2sdl %edx, %xmm1 | |
--- | |
> cvtsi2sdl %ecx, %xmm1 | |
42c42 | |
< leal 6(%rax), %edx | |
--- | |
> leal 5(%rax), %ecx | |
46c46 | |
< leal 7(%rax), %ecx | |
--- | |
> leal 6(%rax), %ecx | |
48c48 | |
< cvtsi2sdl %edx, %xmm1 | |
--- | |
> cvtsi2sdl %ecx, %xmm1 | |
50c50 | |
< addl $8, %eax | |
--- | |
> leal 7(%rax), %ecx | |
53a54 | |
> addl $8, %eax | |
61c62 | |
< movups _ZN4main15__STATIC_FMTSTR20h8ce82c07f6971712SaaE(%rip), %xmm0 | |
--- | |
> movups _ZN4main15__STATIC_FMTSTR20h2631fad4cf02b14aNaaE(%rip), %xmm0 | |
73c74 | |
< .size _ZN4main20h34b4fa9d2be136ebeaaE, .Ltmp1-_ZN4main20h34b4fa9d2be136ebeaaE | |
--- | |
> .size _ZN4main20h3118530cba082203eaaE, .Ltmp1-_ZN4main20h3118530cba082203eaaE | |
84c85 | |
< leaq _ZN4main20h34b4fa9d2be136ebeaaE(%rip), %rdi | |
--- | |
> leaq _ZN4main20h3118530cba082203eaaE(%rip), %rdi | |
92,94c93,95 | |
< .type str1197,@object | |
< .section .rodata.str1197,"a",@progbits | |
< str1197: | |
--- | |
> .type str1063,@object | |
> .section .rodata.str1063,"a",@progbits | |
> str1063: | |
96c97 | |
< .size str1197, 5 | |
--- | |
> .size str1063, 5 | |
98,100c99,101 | |
< .type str1198,@object | |
< .section .rodata.str1198,"a",@progbits | |
< str1198: | |
--- | |
> .type str1064,@object | |
> .section .rodata.str1064,"a",@progbits | |
> str1064: | |
102c103 | |
< .size str1198, 1 | |
--- | |
> .size str1064, 1 | |
104,105c105,106 | |
< .type ref1199,@object | |
< .section .data.rel.ro.local.ref1199,"aw",@progbits | |
--- | |
> .type ref1065,@object | |
> .section .data.rel.ro.local.ref1065,"aw",@progbits | |
107,108c108,109 | |
< ref1199: | |
< .quad str1197 | |
--- | |
> ref1065: | |
> .quad str1063 | |
110c111 | |
< .quad str1198 | |
--- | |
> .quad str1064 | |
112c113 | |
< .size ref1199, 32 | |
--- | |
> .size ref1065, 32 | |
114,115c115,116 | |
< .type _ZN4main15__STATIC_FMTSTR20h8ce82c07f6971712SaaE,@object | |
< .section .data.rel.ro.local._ZN4main15__STATIC_FMTSTR20h8ce82c07f6971712SaaE,"aw",@progbits | |
--- | |
> .type _ZN4main15__STATIC_FMTSTR20h2631fad4cf02b14aNaaE,@object | |
> .section .data.rel.ro.local._ZN4main15__STATIC_FMTSTR20h2631fad4cf02b14aNaaE,"aw",@progbits | |
117,118c118,119 | |
< _ZN4main15__STATIC_FMTSTR20h8ce82c07f6971712SaaE: | |
< .quad ref1199 | |
--- | |
> _ZN4main15__STATIC_FMTSTR20h2631fad4cf02b14aNaaE: | |
> .quad ref1065 | |
120c121 | |
< .size _ZN4main15__STATIC_FMTSTR20h8ce82c07f6971712SaaE, 16 | |
--- | |
> .size _ZN4main15__STATIC_FMTSTR20h2631fad4cf02b14aNaaE, 16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ModuleID = 'fulliter.0.rs' | |
target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128" | |
target triple = "x86_64-unknown-linux-gnu" | |
%str_slice = type { i8*, i64 } | |
%"2.core::fmt::Arguments" = type { { %str_slice*, i64 }, %"2.core::option::Option<&'static [core::fmt::rt::v1::Argument]>", { %"2.core::fmt::ArgumentV1"*, i64 } } | |
%"2.core::option::Option<&'static [core::fmt::rt::v1::Argument]>" = type { { %"2.core::fmt::rt::v1::Argument"*, i64 } } | |
%"2.core::fmt::rt::v1::Argument" = type { %"2.core::fmt::rt::v1::Position", %"2.core::fmt::rt::v1::FormatSpec" } | |
%"2.core::fmt::rt::v1::Position" = type { i64, [0 x i64], [1 x i64] } | |
%"2.core::fmt::rt::v1::FormatSpec" = type { i32, i8, i32, %"2.core::fmt::rt::v1::Count", %"2.core::fmt::rt::v1::Count" } | |
%"2.core::fmt::rt::v1::Count" = type { i64, [0 x i64], [1 x i64] } | |
%"2.core::fmt::ArgumentV1" = type { %"2.core::fmt::Void"*, i8 (%"2.core::fmt::Void"*, %"2.core::fmt::Formatter"*)* } | |
%"2.core::fmt::Void" = type {} | |
%"2.core::fmt::Formatter" = type { i32, i32, i8, %"2.core::option::Option<usize>", %"2.core::option::Option<usize>", { i8*, void (i8*)** }, %"2.core::slice::Iter<core::fmt::ArgumentV1>", { %"2.core::fmt::ArgumentV1"*, i64 } } | |
%"2.core::option::Option<usize>" = type { i64, [0 x i64], [1 x i64] } | |
%"2.core::slice::Iter<core::fmt::ArgumentV1>" = type { %"2.core::fmt::ArgumentV1"*, %"2.core::fmt::ArgumentV1"*, %"2.core::marker::PhantomData<&'static core::fmt::ArgumentV1>" } | |
%"2.core::marker::PhantomData<&'static core::fmt::ArgumentV1>" = type {} | |
@str1197 = internal constant [5 x i8] c"Sum: " | |
@str1198 = internal constant [1 x i8] c"\0A" | |
@ref1199 = internal unnamed_addr constant [2 x %str_slice] [%str_slice { i8* getelementptr inbounds ([5 x i8]* @str1197, i32 0, i32 0), i64 5 }, %str_slice { i8* getelementptr inbounds ([1 x i8]* @str1198, i32 0, i32 0), i64 1 }] | |
@_ZN4main15__STATIC_FMTSTR20h8ce82c07f6971712SaaE = internal unnamed_addr constant { %str_slice*, i64 } { %str_slice* getelementptr inbounds ([2 x %str_slice]* @ref1199, i32 0, i32 0), i64 2 } | |
; Function Attrs: uwtable | |
define internal void @_ZN4main20h34b4fa9d2be136ebeaaE() unnamed_addr #0 { | |
entry-block: | |
%sum = alloca double, align 8 | |
%0 = alloca %"2.core::fmt::Arguments", align 8 | |
%1 = alloca [1 x %"2.core::fmt::ArgumentV1"], align 8 | |
%2 = bitcast double* %sum to i8* | |
call void @llvm.lifetime.start(i64 8, i8* %2) | |
br label %match_case.i | |
match_case.i: ; preds = %match_case.i, %entry-block | |
%accum.04.i = phi double [ 0.000000e+00, %entry-block ], [ %19, %match_case.i ] | |
%3 = phi i32 [ 0, %entry-block ], [ %18, %match_case.i ] | |
%4 = add nuw nsw i32 %3, 1 | |
%phitmp.i.i = sitofp i32 %3 to double | |
%5 = fadd double %accum.04.i, %phitmp.i.i | |
%6 = add nuw nsw i32 %4, 1 | |
%phitmp.i.i.1 = sitofp i32 %4 to double | |
%7 = fadd double %5, %phitmp.i.i.1 | |
%8 = add nuw nsw i32 %6, 1 | |
%phitmp.i.i.2 = sitofp i32 %6 to double | |
%9 = fadd double %7, %phitmp.i.i.2 | |
%10 = add nuw nsw i32 %8, 1 | |
%phitmp.i.i.3 = sitofp i32 %8 to double | |
%11 = fadd double %9, %phitmp.i.i.3 | |
%12 = add nuw nsw i32 %10, 1 | |
%phitmp.i.i.4 = sitofp i32 %10 to double | |
%13 = fadd double %11, %phitmp.i.i.4 | |
%14 = add nuw nsw i32 %12, 1 | |
%phitmp.i.i.5 = sitofp i32 %12 to double | |
%15 = fadd double %13, %phitmp.i.i.5 | |
%16 = add nuw nsw i32 %14, 1 | |
%phitmp.i.i.6 = sitofp i32 %14 to double | |
%17 = fadd double %15, %phitmp.i.i.6 | |
%18 = add nuw nsw i32 %16, 1 | |
%phitmp.i.i.7 = sitofp i32 %16 to double | |
%19 = fadd double %17, %phitmp.i.i.7 | |
%exitcond.i.7 = icmp eq i32 %18, 100000000 | |
br i1 %exitcond.i.7, label %_ZN4iter8Iterator4fold21h16132946566178862456E.exit, label %match_case.i | |
_ZN4iter8Iterator4fold21h16132946566178862456E.exit: ; preds = %match_case.i | |
%.lcssa = phi double [ %19, %match_case.i ] | |
store double %.lcssa, double* %sum, align 8 | |
%20 = bitcast %"2.core::fmt::Arguments"* %0 to i8* | |
call void @llvm.lifetime.start(i64 48, i8* %20) | |
%21 = bitcast [1 x %"2.core::fmt::ArgumentV1"]* %1 to i8* | |
call void @llvm.lifetime.start(i64 16, i8* %21) | |
%22 = getelementptr inbounds [1 x %"2.core::fmt::ArgumentV1"]* %1, i64 0, i64 0 | |
%23 = getelementptr inbounds [1 x %"2.core::fmt::ArgumentV1"]* %1, i64 0, i64 0, i32 1 | |
store i8 (%"2.core::fmt::Void"*, %"2.core::fmt::Formatter"*)* bitcast (i8 (double*, %"2.core::fmt::Formatter"*)* @_ZN3fmt11f64.Display3fmt20hfda565c93058390eARJE to i8 (%"2.core::fmt::Void"*, %"2.core::fmt::Formatter"*)*), i8 (%"2.core::fmt::Void"*, %"2.core::fmt::Formatter"*)** %23, align 8, !alias.scope !0, !noalias !3 | |
%24 = bitcast [1 x %"2.core::fmt::ArgumentV1"]* %1 to double** | |
store double* %sum, double** %24, align 8, !alias.scope !0, !noalias !3 | |
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %20, i8* bitcast ({ %str_slice*, i64 }* @_ZN4main15__STATIC_FMTSTR20h8ce82c07f6971712SaaE to i8*), i64 16, i32 8, i1 false) #3, !alias.scope !5, !noalias !9 | |
%25 = getelementptr inbounds %"2.core::fmt::Arguments"* %0, i64 0, i32 1 | |
%26 = bitcast %"2.core::option::Option<&'static [core::fmt::rt::v1::Argument]>"* %25 to i8* | |
call void @llvm.memset.p0i8.i64(i8* %26, i8 0, i64 16, i32 8, i1 false) #3, !alias.scope !11, !noalias !12 | |
%27 = getelementptr inbounds %"2.core::fmt::Arguments"* %0, i64 0, i32 2, i32 0 | |
store %"2.core::fmt::ArgumentV1"* %22, %"2.core::fmt::ArgumentV1"** %27, align 8 | |
%28 = getelementptr inbounds %"2.core::fmt::Arguments"* %0, i64 0, i32 2, i32 1 | |
store i64 1, i64* %28, align 8 | |
call void @_ZN2io5stdio6_print20h64960a4013ef06515TgE(%"2.core::fmt::Arguments"* noalias nocapture dereferenceable(48) %0) | |
call void @llvm.lifetime.end(i64 48, i8* %20) | |
call void @llvm.lifetime.end(i64 16, i8* %21) | |
call void @llvm.lifetime.end(i64 8, i8* %2) | |
ret void | |
} | |
; Function Attrs: nounwind | |
declare void @llvm.lifetime.start(i64, i8* nocapture) unnamed_addr #1 | |
; Function Attrs: nounwind | |
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) unnamed_addr #1 | |
; Function Attrs: nounwind | |
declare void @llvm.lifetime.end(i64, i8* nocapture) unnamed_addr #1 | |
declare void @_ZN2io5stdio6_print20h64960a4013ef06515TgE(%"2.core::fmt::Arguments"* noalias nocapture dereferenceable(48)) unnamed_addr #2 | |
declare i8 @_ZN3fmt11f64.Display3fmt20hfda565c93058390eARJE(double* noalias readonly dereferenceable(8), %"2.core::fmt::Formatter"* noalias dereferenceable(96)) unnamed_addr #2 | |
define i64 @main(i64, i8**) unnamed_addr #2 { | |
top: | |
%2 = tail call i64 @_ZN2rt10lang_start20h787996d0ae650185OlwE(i8* bitcast (void ()* @_ZN4main20h34b4fa9d2be136ebeaaE to i8*), i64 %0, i8** %1) | |
ret i64 %2 | |
} | |
declare i64 @_ZN2rt10lang_start20h787996d0ae650185OlwE(i8*, i64, i8**) unnamed_addr #2 | |
; Function Attrs: nounwind | |
declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) #3 | |
attributes #0 = { uwtable "split-stack" } | |
attributes #1 = { nounwind "split-stack" } | |
attributes #2 = { "split-stack" } | |
attributes #3 = { nounwind } | |
!0 = !{!1} | |
!1 = distinct !{!1, !2, !"_ZN3fmt24ArgumentV1$LT$$u27$a$GT$3new20h2345393963723667609E: argument 0"} | |
!2 = distinct !{!2, !"_ZN3fmt24ArgumentV1$LT$$u27$a$GT$3new20h2345393963723667609E"} | |
!3 = !{!4} | |
!4 = distinct !{!4, !2, !"_ZN3fmt24ArgumentV1$LT$$u27$a$GT$3new20h2345393963723667609E: argument 1"} | |
!5 = !{!6, !8} | |
!6 = distinct !{!6, !7, !"_ZN3fmt23Arguments$LT$$u27$a$GT$6new_v120h4f5ff6b205ba2f42q8IE: argument 0"} | |
!7 = distinct !{!7, !"_ZN3fmt23Arguments$LT$$u27$a$GT$6new_v120h4f5ff6b205ba2f42q8IE"} | |
!8 = distinct !{!8, !7, !"_ZN3fmt23Arguments$LT$$u27$a$GT$6new_v120h4f5ff6b205ba2f42q8IE: argument 1"} | |
!9 = !{!10} | |
!10 = distinct !{!10, !7, !"_ZN3fmt23Arguments$LT$$u27$a$GT$6new_v120h4f5ff6b205ba2f42q8IE: argument 2"} | |
!11 = !{!6} | |
!12 = !{!8, !10} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let sum = (0..100_000_000).map(|x| x as f64).fold(0.0, |acc, n| acc + n); | |
println!("Sum: {}", sum); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.text | |
.file "fulliter.0.rs" | |
.section .text._ZN4main20h34b4fa9d2be136ebeaaE,"ax",@progbits | |
.align 16, 0x90 | |
.type _ZN4main20h34b4fa9d2be136ebeaaE,@function | |
_ZN4main20h34b4fa9d2be136ebeaaE: | |
.cfi_startproc | |
cmpq %fs:112, %rsp | |
ja .LBB0_2 | |
movabsq $72, %r10 | |
movabsq $0, %r11 | |
callq __morestack | |
retq | |
.LBB0_2: | |
subq $72, %rsp | |
.Ltmp0: | |
.cfi_def_cfa_offset 80 | |
xorl %eax, %eax | |
xorps %xmm0, %xmm0 | |
.align 16, 0x90 | |
.LBB0_3: | |
leal 1(%rax), %ecx | |
xorps %xmm1, %xmm1 | |
cvtsi2sdl %eax, %xmm1 | |
addsd %xmm0, %xmm1 | |
leal 2(%rax), %edx | |
xorps %xmm0, %xmm0 | |
cvtsi2sdl %ecx, %xmm0 | |
addsd %xmm1, %xmm0 | |
leal 3(%rax), %ecx | |
xorps %xmm1, %xmm1 | |
cvtsi2sdl %edx, %xmm1 | |
addsd %xmm0, %xmm1 | |
leal 4(%rax), %edx | |
xorps %xmm0, %xmm0 | |
cvtsi2sdl %ecx, %xmm0 | |
addsd %xmm1, %xmm0 | |
leal 5(%rax), %ecx | |
xorps %xmm1, %xmm1 | |
cvtsi2sdl %edx, %xmm1 | |
addsd %xmm0, %xmm1 | |
leal 6(%rax), %edx | |
xorps %xmm0, %xmm0 | |
cvtsi2sdl %ecx, %xmm0 | |
addsd %xmm1, %xmm0 | |
leal 7(%rax), %ecx | |
xorps %xmm1, %xmm1 | |
cvtsi2sdl %edx, %xmm1 | |
addsd %xmm0, %xmm1 | |
addl $8, %eax | |
xorps %xmm0, %xmm0 | |
cvtsi2sdl %ecx, %xmm0 | |
addsd %xmm1, %xmm0 | |
cmpl $100000000, %eax | |
jne .LBB0_3 | |
movsd %xmm0, 64(%rsp) | |
movq _ZN3fmt11f64.Display3fmt20hfda565c93058390eARJE@GOTPCREL(%rip), %rax | |
movq %rax, 8(%rsp) | |
leaq 64(%rsp), %rax | |
movq %rax, (%rsp) | |
movups _ZN4main15__STATIC_FMTSTR20h8ce82c07f6971712SaaE(%rip), %xmm0 | |
movaps %xmm0, 16(%rsp) | |
xorps %xmm0, %xmm0 | |
movaps %xmm0, 32(%rsp) | |
leaq (%rsp), %rax | |
movq %rax, 48(%rsp) | |
movq $1, 56(%rsp) | |
leaq 16(%rsp), %rdi | |
callq _ZN2io5stdio6_print20h64960a4013ef06515TgE@PLT | |
addq $72, %rsp | |
retq | |
.Ltmp1: | |
.size _ZN4main20h34b4fa9d2be136ebeaaE, .Ltmp1-_ZN4main20h34b4fa9d2be136ebeaaE | |
.cfi_endproc | |
.section .text.main,"ax",@progbits | |
.globl main | |
.align 16, 0x90 | |
.type main,@function | |
main: | |
.cfi_startproc | |
movq %rsi, %rax | |
movq %rdi, %rcx | |
leaq _ZN4main20h34b4fa9d2be136ebeaaE(%rip), %rdi | |
movq %rcx, %rsi | |
movq %rax, %rdx | |
jmp _ZN2rt10lang_start20h787996d0ae650185OlwE@PLT | |
.Ltmp2: | |
.size main, .Ltmp2-main | |
.cfi_endproc | |
.type str1197,@object | |
.section .rodata.str1197,"a",@progbits | |
str1197: | |
.ascii "Sum: " | |
.size str1197, 5 | |
.type str1198,@object | |
.section .rodata.str1198,"a",@progbits | |
str1198: | |
.byte 10 | |
.size str1198, 1 | |
.type ref1199,@object | |
.section .data.rel.ro.local.ref1199,"aw",@progbits | |
.align 16 | |
ref1199: | |
.quad str1197 | |
.quad 5 | |
.quad str1198 | |
.quad 1 | |
.size ref1199, 32 | |
.type _ZN4main15__STATIC_FMTSTR20h8ce82c07f6971712SaaE,@object | |
.section .data.rel.ro.local._ZN4main15__STATIC_FMTSTR20h8ce82c07f6971712SaaE,"aw",@progbits | |
.align 8 | |
_ZN4main15__STATIC_FMTSTR20h8ce82c07f6971712SaaE: | |
.quad ref1199 | |
.quad 2 | |
.size _ZN4main15__STATIC_FMTSTR20h8ce82c07f6971712SaaE, 16 | |
.section ".note.GNU-stack","",@progbits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ModuleID = 'while.0.rs' | |
target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128" | |
target triple = "x86_64-unknown-linux-gnu" | |
%str_slice = type { i8*, i64 } | |
%"2.core::fmt::Arguments" = type { { %str_slice*, i64 }, %"2.core::option::Option<&'static [core::fmt::rt::v1::Argument]>", { %"2.core::fmt::ArgumentV1"*, i64 } } | |
%"2.core::option::Option<&'static [core::fmt::rt::v1::Argument]>" = type { { %"2.core::fmt::rt::v1::Argument"*, i64 } } | |
%"2.core::fmt::rt::v1::Argument" = type { %"2.core::fmt::rt::v1::Position", %"2.core::fmt::rt::v1::FormatSpec" } | |
%"2.core::fmt::rt::v1::Position" = type { i64, [0 x i64], [1 x i64] } | |
%"2.core::fmt::rt::v1::FormatSpec" = type { i32, i8, i32, %"2.core::fmt::rt::v1::Count", %"2.core::fmt::rt::v1::Count" } | |
%"2.core::fmt::rt::v1::Count" = type { i64, [0 x i64], [1 x i64] } | |
%"2.core::fmt::ArgumentV1" = type { %"2.core::fmt::Void"*, i8 (%"2.core::fmt::Void"*, %"2.core::fmt::Formatter"*)* } | |
%"2.core::fmt::Void" = type {} | |
%"2.core::fmt::Formatter" = type { i32, i32, i8, %"2.core::option::Option<usize>", %"2.core::option::Option<usize>", { i8*, void (i8*)** }, %"2.core::slice::Iter<core::fmt::ArgumentV1>", { %"2.core::fmt::ArgumentV1"*, i64 } } | |
%"2.core::option::Option<usize>" = type { i64, [0 x i64], [1 x i64] } | |
%"2.core::slice::Iter<core::fmt::ArgumentV1>" = type { %"2.core::fmt::ArgumentV1"*, %"2.core::fmt::ArgumentV1"*, %"2.core::marker::PhantomData<&'static core::fmt::ArgumentV1>" } | |
%"2.core::marker::PhantomData<&'static core::fmt::ArgumentV1>" = type {} | |
@str1063 = internal constant [5 x i8] c"Sum: " | |
@str1064 = internal constant [1 x i8] c"\0A" | |
@ref1065 = internal unnamed_addr constant [2 x %str_slice] [%str_slice { i8* getelementptr inbounds ([5 x i8]* @str1063, i32 0, i32 0), i64 5 }, %str_slice { i8* getelementptr inbounds ([1 x i8]* @str1064, i32 0, i32 0), i64 1 }] | |
@_ZN4main15__STATIC_FMTSTR20h2631fad4cf02b14aNaaE = internal unnamed_addr constant { %str_slice*, i64 } { %str_slice* getelementptr inbounds ([2 x %str_slice]* @ref1065, i32 0, i32 0), i64 2 } | |
; Function Attrs: uwtable | |
define internal void @_ZN4main20h3118530cba082203eaaE() unnamed_addr #0 { | |
entry-block: | |
%sum = alloca double, align 8 | |
%0 = alloca %"2.core::fmt::Arguments", align 8 | |
%1 = alloca [1 x %"2.core::fmt::ArgumentV1"], align 8 | |
%2 = bitcast double* %sum to i8* | |
call void @llvm.lifetime.start(i64 8, i8* %2) | |
store double 0.000000e+00, double* %sum, align 8 | |
br label %while_body | |
while_exit: ; preds = %while_body | |
%.lcssa = phi double [ %35, %while_body ] | |
store double %.lcssa, double* %sum, align 8 | |
%3 = bitcast %"2.core::fmt::Arguments"* %0 to i8* | |
call void @llvm.lifetime.start(i64 48, i8* %3) | |
%4 = bitcast [1 x %"2.core::fmt::ArgumentV1"]* %1 to i8* | |
call void @llvm.lifetime.start(i64 16, i8* %4) | |
%5 = getelementptr inbounds [1 x %"2.core::fmt::ArgumentV1"]* %1, i64 0, i64 0 | |
%6 = getelementptr inbounds [1 x %"2.core::fmt::ArgumentV1"]* %1, i64 0, i64 0, i32 1 | |
store i8 (%"2.core::fmt::Void"*, %"2.core::fmt::Formatter"*)* bitcast (i8 (double*, %"2.core::fmt::Formatter"*)* @_ZN3fmt11f64.Display3fmt20hfda565c93058390eARJE to i8 (%"2.core::fmt::Void"*, %"2.core::fmt::Formatter"*)*), i8 (%"2.core::fmt::Void"*, %"2.core::fmt::Formatter"*)** %6, align 8, !alias.scope !0, !noalias !3 | |
%7 = bitcast [1 x %"2.core::fmt::ArgumentV1"]* %1 to double** | |
store double* %sum, double** %7, align 8, !alias.scope !0, !noalias !3 | |
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %3, i8* bitcast ({ %str_slice*, i64 }* @_ZN4main15__STATIC_FMTSTR20h2631fad4cf02b14aNaaE to i8*), i64 16, i32 8, i1 false) #3, !alias.scope !5, !noalias !9 | |
%8 = getelementptr inbounds %"2.core::fmt::Arguments"* %0, i64 0, i32 1 | |
%9 = bitcast %"2.core::option::Option<&'static [core::fmt::rt::v1::Argument]>"* %8 to i8* | |
call void @llvm.memset.p0i8.i64(i8* %9, i8 0, i64 16, i32 8, i1 false) #3, !alias.scope !11, !noalias !12 | |
%10 = getelementptr inbounds %"2.core::fmt::Arguments"* %0, i64 0, i32 2, i32 0 | |
store %"2.core::fmt::ArgumentV1"* %5, %"2.core::fmt::ArgumentV1"** %10, align 8 | |
%11 = getelementptr inbounds %"2.core::fmt::Arguments"* %0, i64 0, i32 2, i32 1 | |
store i64 1, i64* %11, align 8 | |
call void @_ZN2io5stdio6_print20h64960a4013ef06515TgE(%"2.core::fmt::Arguments"* noalias nocapture dereferenceable(48) %0) | |
call void @llvm.lifetime.end(i64 48, i8* %3) | |
call void @llvm.lifetime.end(i64 16, i8* %4) | |
call void @llvm.lifetime.end(i64 8, i8* %2) | |
ret void | |
while_body: ; preds = %while_body, %entry-block | |
%12 = phi double [ 0.000000e+00, %entry-block ], [ %35, %while_body ] | |
%i.01 = phi i32 [ 0, %entry-block ], [ %36, %while_body ] | |
%13 = sitofp i32 %i.01 to double | |
%14 = fadd double %13, %12 | |
%15 = add nuw nsw i32 %i.01, 1 | |
%16 = sitofp i32 %15 to double | |
%17 = fadd double %16, %14 | |
%18 = add nuw nsw i32 %15, 1 | |
%19 = sitofp i32 %18 to double | |
%20 = fadd double %19, %17 | |
%21 = add nuw nsw i32 %18, 1 | |
%22 = sitofp i32 %21 to double | |
%23 = fadd double %22, %20 | |
%24 = add nuw nsw i32 %21, 1 | |
%25 = sitofp i32 %24 to double | |
%26 = fadd double %25, %23 | |
%27 = add nuw nsw i32 %24, 1 | |
%28 = sitofp i32 %27 to double | |
%29 = fadd double %28, %26 | |
%30 = add nuw nsw i32 %27, 1 | |
%31 = sitofp i32 %30 to double | |
%32 = fadd double %31, %29 | |
%33 = add nuw nsw i32 %30, 1 | |
%34 = sitofp i32 %33 to double | |
%35 = fadd double %34, %32 | |
%36 = add nuw nsw i32 %33, 1 | |
%exitcond.7 = icmp eq i32 %36, 100000000 | |
br i1 %exitcond.7, label %while_exit, label %while_body | |
} | |
; Function Attrs: nounwind | |
declare void @llvm.lifetime.start(i64, i8* nocapture) unnamed_addr #1 | |
declare void @_ZN2io5stdio6_print20h64960a4013ef06515TgE(%"2.core::fmt::Arguments"* noalias nocapture dereferenceable(48)) unnamed_addr #2 | |
; Function Attrs: nounwind | |
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) unnamed_addr #1 | |
; Function Attrs: nounwind | |
declare void @llvm.lifetime.end(i64, i8* nocapture) unnamed_addr #1 | |
declare i8 @_ZN3fmt11f64.Display3fmt20hfda565c93058390eARJE(double* noalias readonly dereferenceable(8), %"2.core::fmt::Formatter"* noalias dereferenceable(96)) unnamed_addr #2 | |
define i64 @main(i64, i8**) unnamed_addr #2 { | |
top: | |
%2 = tail call i64 @_ZN2rt10lang_start20h787996d0ae650185OlwE(i8* bitcast (void ()* @_ZN4main20h3118530cba082203eaaE to i8*), i64 %0, i8** %1) | |
ret i64 %2 | |
} | |
declare i64 @_ZN2rt10lang_start20h787996d0ae650185OlwE(i8*, i64, i8**) unnamed_addr #2 | |
; Function Attrs: nounwind | |
declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) #3 | |
attributes #0 = { uwtable "split-stack" } | |
attributes #1 = { nounwind "split-stack" } | |
attributes #2 = { "split-stack" } | |
attributes #3 = { nounwind } | |
!0 = !{!1} | |
!1 = distinct !{!1, !2, !"_ZN3fmt24ArgumentV1$LT$$u27$a$GT$3new21h12120103399187833025E: argument 0"} | |
!2 = distinct !{!2, !"_ZN3fmt24ArgumentV1$LT$$u27$a$GT$3new21h12120103399187833025E"} | |
!3 = !{!4} | |
!4 = distinct !{!4, !2, !"_ZN3fmt24ArgumentV1$LT$$u27$a$GT$3new21h12120103399187833025E: argument 1"} | |
!5 = !{!6, !8} | |
!6 = distinct !{!6, !7, !"_ZN3fmt23Arguments$LT$$u27$a$GT$6new_v120h4f5ff6b205ba2f42q8IE: argument 0"} | |
!7 = distinct !{!7, !"_ZN3fmt23Arguments$LT$$u27$a$GT$6new_v120h4f5ff6b205ba2f42q8IE"} | |
!8 = distinct !{!8, !7, !"_ZN3fmt23Arguments$LT$$u27$a$GT$6new_v120h4f5ff6b205ba2f42q8IE: argument 1"} | |
!9 = !{!10} | |
!10 = distinct !{!10, !7, !"_ZN3fmt23Arguments$LT$$u27$a$GT$6new_v120h4f5ff6b205ba2f42q8IE: argument 2"} | |
!11 = !{!6} | |
!12 = !{!8, !10} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let mut sum = 0.0; | |
let mut i = 0; | |
while i < 100_000_000 { | |
sum += i as f64; | |
i += 1; | |
} | |
println!("Sum: {}", sum); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.text | |
.file "while.0.rs" | |
.section .text._ZN4main20h3118530cba082203eaaE,"ax",@progbits | |
.align 16, 0x90 | |
.type _ZN4main20h3118530cba082203eaaE,@function | |
_ZN4main20h3118530cba082203eaaE: | |
.cfi_startproc | |
cmpq %fs:112, %rsp | |
ja .LBB0_2 | |
movabsq $72, %r10 | |
movabsq $0, %r11 | |
callq __morestack | |
retq | |
.LBB0_2: | |
subq $72, %rsp | |
.Ltmp0: | |
.cfi_def_cfa_offset 80 | |
movq $0, 64(%rsp) | |
xorl %eax, %eax | |
xorps %xmm0, %xmm0 | |
.align 16, 0x90 | |
.LBB0_3: | |
xorps %xmm1, %xmm1 | |
cvtsi2sdl %eax, %xmm1 | |
addsd %xmm0, %xmm1 | |
leal 1(%rax), %ecx | |
xorps %xmm0, %xmm0 | |
cvtsi2sdl %ecx, %xmm0 | |
addsd %xmm1, %xmm0 | |
leal 2(%rax), %ecx | |
xorps %xmm1, %xmm1 | |
cvtsi2sdl %ecx, %xmm1 | |
addsd %xmm0, %xmm1 | |
leal 3(%rax), %ecx | |
xorps %xmm0, %xmm0 | |
cvtsi2sdl %ecx, %xmm0 | |
addsd %xmm1, %xmm0 | |
leal 4(%rax), %ecx | |
xorps %xmm1, %xmm1 | |
cvtsi2sdl %ecx, %xmm1 | |
addsd %xmm0, %xmm1 | |
leal 5(%rax), %ecx | |
xorps %xmm0, %xmm0 | |
cvtsi2sdl %ecx, %xmm0 | |
addsd %xmm1, %xmm0 | |
leal 6(%rax), %ecx | |
xorps %xmm1, %xmm1 | |
cvtsi2sdl %ecx, %xmm1 | |
addsd %xmm0, %xmm1 | |
leal 7(%rax), %ecx | |
xorps %xmm0, %xmm0 | |
cvtsi2sdl %ecx, %xmm0 | |
addsd %xmm1, %xmm0 | |
addl $8, %eax | |
cmpl $100000000, %eax | |
jne .LBB0_3 | |
movsd %xmm0, 64(%rsp) | |
movq _ZN3fmt11f64.Display3fmt20hfda565c93058390eARJE@GOTPCREL(%rip), %rax | |
movq %rax, 8(%rsp) | |
leaq 64(%rsp), %rax | |
movq %rax, (%rsp) | |
movups _ZN4main15__STATIC_FMTSTR20h2631fad4cf02b14aNaaE(%rip), %xmm0 | |
movaps %xmm0, 16(%rsp) | |
xorps %xmm0, %xmm0 | |
movaps %xmm0, 32(%rsp) | |
leaq (%rsp), %rax | |
movq %rax, 48(%rsp) | |
movq $1, 56(%rsp) | |
leaq 16(%rsp), %rdi | |
callq _ZN2io5stdio6_print20h64960a4013ef06515TgE@PLT | |
addq $72, %rsp | |
retq | |
.Ltmp1: | |
.size _ZN4main20h3118530cba082203eaaE, .Ltmp1-_ZN4main20h3118530cba082203eaaE | |
.cfi_endproc | |
.section .text.main,"ax",@progbits | |
.globl main | |
.align 16, 0x90 | |
.type main,@function | |
main: | |
.cfi_startproc | |
movq %rsi, %rax | |
movq %rdi, %rcx | |
leaq _ZN4main20h3118530cba082203eaaE(%rip), %rdi | |
movq %rcx, %rsi | |
movq %rax, %rdx | |
jmp _ZN2rt10lang_start20h787996d0ae650185OlwE@PLT | |
.Ltmp2: | |
.size main, .Ltmp2-main | |
.cfi_endproc | |
.type str1063,@object | |
.section .rodata.str1063,"a",@progbits | |
str1063: | |
.ascii "Sum: " | |
.size str1063, 5 | |
.type str1064,@object | |
.section .rodata.str1064,"a",@progbits | |
str1064: | |
.byte 10 | |
.size str1064, 1 | |
.type ref1065,@object | |
.section .data.rel.ro.local.ref1065,"aw",@progbits | |
.align 16 | |
ref1065: | |
.quad str1063 | |
.quad 5 | |
.quad str1064 | |
.quad 1 | |
.size ref1065, 32 | |
.type _ZN4main15__STATIC_FMTSTR20h2631fad4cf02b14aNaaE,@object | |
.section .data.rel.ro.local._ZN4main15__STATIC_FMTSTR20h2631fad4cf02b14aNaaE,"aw",@progbits | |
.align 8 | |
_ZN4main15__STATIC_FMTSTR20h2631fad4cf02b14aNaaE: | |
.quad ref1065 | |
.quad 2 | |
.size _ZN4main15__STATIC_FMTSTR20h2631fad4cf02b14aNaaE, 16 | |
.section ".note.GNU-stack","",@progbits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment