Skip to content

Instantly share code, notes, and snippets.

@crlf0710
Created April 3, 2019 16:59
Show Gist options
  • Save crlf0710/ecd261d989a85f2d8917c1fbf8acfc6f to your computer and use it in GitHub Desktop.
Save crlf0710/ecd261d989a85f2d8917c1fbf8acfc6f to your computer and use it in GitHub Desktop.
Rust unsized_locals codegen issue on gnu x32.
; ModuleID = 'a.3a1fbbbh-cgu.0'
source_filename = "a.3a1fbbbh-cgu.0"
target datalayout = "e-m:e-p:32:32-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnux32"
@vtable.0 = private unnamed_addr constant { void (i32*)*, i32, i32, i32 (i32*)* } { void (i32*)* @_ZN4core3ptr18real_drop_in_place17hbeb95fb5bcd2320eE, i32 4, i32 4, i32 (i32*)* @"_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17heb625444409ca88cE" }, align 4
; <usize as core::default::Default>::default
; Function Attrs: inlinehint nounwind
define internal i32 @"_ZN48_$LT$usize$u20$as$u20$core..default..Default$GT$7default17h194d800cf4bc33ceE"() unnamed_addr #0 {
start:
ret i32 0
}
; core::num::NonZeroUsize::new_unchecked
; Function Attrs: inlinehint nounwind
define internal i32 @_ZN4core3num12NonZeroUsize13new_unchecked17h95c0007fef9eac85E(i32 %n) unnamed_addr #0 {
start:
%_0 = alloca i32, align 4
store i32 %n, i32* %_0, align 4
%0 = load i32, i32* %_0, align 4, !range !0
ret i32 %0
}
; core::num::NonZeroUsize::get
; Function Attrs: inlinehint nounwind
define internal i32 @_ZN4core3num12NonZeroUsize3get17h7f0c0e3714854edfE(i32 %self) unnamed_addr #0 {
start:
ret i32 %self
}
; core::ops::function::FnOnce::call_once{{vtable.shim}}
; Function Attrs: nounwind
define internal i32 @"_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17heb625444409ca88cE"(i32* %arg0) unnamed_addr #1 {
start:
%arg1 = alloca {}, align 1
%0 = load i32, i32* %arg0, align 4
; call a::r::{{closure}}
%1 = call i32 @"_ZN1a1r28_$u7b$$u7b$closure$u7d$$u7d$17hd0af2746d5774f0fE"(i32 %0)
br label %bb1
bb1: ; preds = %start
ret i32 %1
}
; core::ptr::Unique<T>::as_ptr
; Function Attrs: nounwind
define { {}*, [3 x i32]* } @"_ZN4core3ptr15Unique$LT$T$GT$6as_ptr17h43db0369844649afE"(i8* nonnull %self.0, i32* noalias readonly align 4 dereferenceable(12) %self.1) unnamed_addr #1 {
start:
%0 = bitcast i8* %self.0 to {}*
%1 = bitcast i32* %self.1 to [3 x i32]*
%2 = insertvalue { {}*, [3 x i32]* } undef, {}* %0, 0
%3 = insertvalue { {}*, [3 x i32]* } %2, [3 x i32]* %1, 1
ret { {}*, [3 x i32]* } %3
}
; core::ptr::real_drop_in_place
; Function Attrs: nounwind
define internal void @_ZN4core3ptr18real_drop_in_place17hbeb95fb5bcd2320eE(i32* align 4 dereferenceable(4) %arg0) unnamed_addr #1 {
start:
ret void
}
; core::ptr::<impl *mut T>::is_null
; Function Attrs: inlinehint nounwind
define zeroext i1 @"_ZN4core3ptr31_$LT$impl$u20$$BP$mut$u20$T$GT$7is_null17hd1eeeb989e58f69aE"(i8* %self) unnamed_addr #0 {
start:
; call core::ptr::null_mut
%0 = call i8* @_ZN4core3ptr8null_mut17hf28e6800ae2dbba5E()
br label %bb1
bb1: ; preds = %start
%1 = icmp eq i8* %self, %0
ret i1 %1
}
; core::ptr::null_mut
; Function Attrs: inlinehint nounwind
define i8* @_ZN4core3ptr8null_mut17hf28e6800ae2dbba5E() unnamed_addr #0 {
start:
ret i8* null
}
; core::alloc::Layout::from_size_align_unchecked
; Function Attrs: inlinehint nounwind
define internal { i32, i32 } @_ZN4core5alloc6Layout25from_size_align_unchecked17h97eaca5fc803fffcE(i32 %size, i32 %align) unnamed_addr #0 {
start:
%_0 = alloca { i32, i32 }, align 4
; call core::num::NonZeroUsize::new_unchecked
%0 = call i32 @_ZN4core3num12NonZeroUsize13new_unchecked17h95c0007fef9eac85E(i32 %align), !range !0
br label %bb1
bb1: ; preds = %start
%1 = bitcast { i32, i32 }* %_0 to i32*
store i32 %size, i32* %1, align 4
%2 = getelementptr inbounds { i32, i32 }, { i32, i32 }* %_0, i32 0, i32 1
store i32 %0, i32* %2, align 4
%3 = getelementptr inbounds { i32, i32 }, { i32, i32 }* %_0, i32 0, i32 0
%4 = load i32, i32* %3, align 4
%5 = getelementptr inbounds { i32, i32 }, { i32, i32 }* %_0, i32 0, i32 1
%6 = load i32, i32* %5, align 4, !range !0
%7 = insertvalue { i32, i32 } undef, i32 %4, 0
%8 = insertvalue { i32, i32 } %7, i32 %6, 1
ret { i32, i32 } %8
}
; core::alloc::Layout::size
; Function Attrs: inlinehint nounwind
define internal i32 @_ZN4core5alloc6Layout4size17h2907e9c3d2107a23E({ i32, i32 }* noalias readonly align 4 dereferenceable(8) %self) unnamed_addr #0 {
start:
%0 = bitcast { i32, i32 }* %self to i32*
%1 = load i32, i32* %0, align 4
ret i32 %1
}
; core::alloc::Layout::align
; Function Attrs: inlinehint nounwind
define internal i32 @_ZN4core5alloc6Layout5align17h241d0cc88d38cb2bE({ i32, i32 }* noalias readonly align 4 dereferenceable(8) %self) unnamed_addr #0 {
start:
%0 = getelementptr inbounds { i32, i32 }, { i32, i32 }* %self, i32 0, i32 1
%1 = load i32, i32* %0, align 4, !range !0
; call core::num::NonZeroUsize::get
%2 = call i32 @_ZN4core3num12NonZeroUsize3get17h7f0c0e3714854edfE(i32 %1)
br label %bb1
bb1: ; preds = %start
ret i32 %2
}
; alloc::alloc::exchange_malloc
; Function Attrs: inlinehint nounwind
define internal i8* @_ZN5alloc5alloc15exchange_malloc17hf24c4ee29004a6fcE(i32 %size, i32 %align) unnamed_addr #0 {
start:
%_0 = alloca i8*, align 4
%0 = icmp eq i32 %size, 0
br i1 %0, label %bb1, label %bb2
bb1: ; preds = %start
%1 = inttoptr i32 %align to i8*
store i8* %1, i8** %_0, align 4
br label %bb8
bb2: ; preds = %start
; call core::alloc::Layout::from_size_align_unchecked
%2 = call { i32, i32 } @_ZN4core5alloc6Layout25from_size_align_unchecked17h97eaca5fc803fffcE(i32 %size, i32 %align)
%3 = extractvalue { i32, i32 } %2, 0
%4 = extractvalue { i32, i32 } %2, 1
br label %bb3
bb3: ; preds = %bb2
; call alloc::alloc::alloc
%5 = call i8* @_ZN5alloc5alloc5alloc17h2fc42158a210b3d8E(i32 %3, i32 %4)
br label %bb4
bb4: ; preds = %bb3
; call core::ptr::<impl *mut T>::is_null
%6 = call zeroext i1 @"_ZN4core3ptr31_$LT$impl$u20$$BP$mut$u20$T$GT$7is_null17hd1eeeb989e58f69aE"(i8* %5)
br label %bb5
bb5: ; preds = %bb4
%7 = xor i1 %6, true
br i1 %7, label %bb6, label %bb7
bb6: ; preds = %bb5
store i8* %5, i8** %_0, align 4
br label %bb8
bb7: ; preds = %bb5
; call alloc::alloc::handle_alloc_error
call void @_ZN5alloc5alloc18handle_alloc_error17hf51d0392ce94e89cE(i32 %3, i32 %4)
unreachable
bb8: ; preds = %bb6, %bb1
%8 = load i8*, i8** %_0, align 4
ret i8* %8
}
; alloc::alloc::alloc
; Function Attrs: inlinehint nounwind
define internal i8* @_ZN5alloc5alloc5alloc17h2fc42158a210b3d8E(i32, i32) unnamed_addr #0 {
start:
%layout = alloca { i32, i32 }, align 4
%2 = getelementptr inbounds { i32, i32 }, { i32, i32 }* %layout, i32 0, i32 0
store i32 %0, i32* %2, align 4
%3 = getelementptr inbounds { i32, i32 }, { i32, i32 }* %layout, i32 0, i32 1
store i32 %1, i32* %3, align 4
; call core::alloc::Layout::size
%4 = call i32 @_ZN4core5alloc6Layout4size17h2907e9c3d2107a23E({ i32, i32 }* noalias readonly align 4 dereferenceable(8) %layout)
br label %bb1
bb1: ; preds = %start
; call core::alloc::Layout::align
%5 = call i32 @_ZN4core5alloc6Layout5align17h241d0cc88d38cb2bE({ i32, i32 }* noalias readonly align 4 dereferenceable(8) %layout)
br label %bb2
bb2: ; preds = %bb1
%6 = call i8* @__rust_alloc(i32 %4, i32 %5)
br label %bb3
bb3: ; preds = %bb2
ret i8* %6
}
; alloc::alloc::dealloc
; Function Attrs: inlinehint nounwind
define internal void @_ZN5alloc5alloc7dealloc17h7b1ae14897a19b97E(i8* %ptr, i32, i32) unnamed_addr #0 {
start:
%layout = alloca { i32, i32 }, align 4
%2 = getelementptr inbounds { i32, i32 }, { i32, i32 }* %layout, i32 0, i32 0
store i32 %0, i32* %2, align 4
%3 = getelementptr inbounds { i32, i32 }, { i32, i32 }* %layout, i32 0, i32 1
store i32 %1, i32* %3, align 4
; call core::alloc::Layout::size
%4 = call i32 @_ZN4core5alloc6Layout4size17h2907e9c3d2107a23E({ i32, i32 }* noalias readonly align 4 dereferenceable(8) %layout)
br label %bb1
bb1: ; preds = %start
; call core::alloc::Layout::align
%5 = call i32 @_ZN4core5alloc6Layout5align17h241d0cc88d38cb2bE({ i32, i32 }* noalias readonly align 4 dereferenceable(8) %layout)
br label %bb2
bb2: ; preds = %bb1
call void @__rust_dealloc(i8* %ptr, i32 %4, i32 %5)
br label %bb3
bb3: ; preds = %bb2
ret void
}
; alloc::alloc::box_free
; Function Attrs: inlinehint nounwind
define void @_ZN5alloc5alloc8box_free17hf1f8850d845906a6E(i8* nonnull %ptr.0, i32* noalias readonly align 4 dereferenceable(12) %ptr.1) unnamed_addr #0 {
start:
%tmp_ret1 = alloca i32, align 4
%tmp_ret = alloca i32, align 4
; call core::ptr::Unique<T>::as_ptr
%0 = call { {}*, [3 x i32]* } @"_ZN4core3ptr15Unique$LT$T$GT$6as_ptr17h43db0369844649afE"(i8* nonnull %ptr.0, i32* noalias readonly align 4 dereferenceable(12) %ptr.1)
%1 = extractvalue { {}*, [3 x i32]* } %0, 0
%2 = extractvalue { {}*, [3 x i32]* } %0, 1
br label %bb1
bb1: ; preds = %start
%3 = bitcast [3 x i32]* %2 to i32*
%4 = getelementptr inbounds i32, i32* %3, i32 1
%5 = load i32, i32* %4, align 4, !invariant.load !1
%6 = bitcast [3 x i32]* %2 to i32*
%7 = getelementptr inbounds i32, i32* %6, i32 2
%8 = load i32, i32* %7, align 4, !invariant.load !1
store i32 %5, i32* %tmp_ret, align 4
%9 = load i32, i32* %tmp_ret, align 4
br label %bb2
bb2: ; preds = %bb1
%10 = bitcast [3 x i32]* %2 to i32*
%11 = getelementptr inbounds i32, i32* %10, i32 1
%12 = load i32, i32* %11, align 4, !invariant.load !1
%13 = bitcast [3 x i32]* %2 to i32*
%14 = getelementptr inbounds i32, i32* %13, i32 2
%15 = load i32, i32* %14, align 4, !invariant.load !1
store i32 %15, i32* %tmp_ret1, align 4
%16 = load i32, i32* %tmp_ret1, align 4
br label %bb3
bb3: ; preds = %bb2
%17 = icmp ne i32 %9, 0
br i1 %17, label %bb4, label %bb7
bb4: ; preds = %bb3
; call core::alloc::Layout::from_size_align_unchecked
%18 = call { i32, i32 } @_ZN4core5alloc6Layout25from_size_align_unchecked17h97eaca5fc803fffcE(i32 %9, i32 %16)
%19 = extractvalue { i32, i32 } %18, 0
%20 = extractvalue { i32, i32 } %18, 1
br label %bb5
bb5: ; preds = %bb4
%21 = bitcast {}* %1 to i8*
; call alloc::alloc::dealloc
call void @_ZN5alloc5alloc7dealloc17h7b1ae14897a19b97E(i8* %21, i32 %19, i32 %20)
br label %bb6
bb6: ; preds = %bb5
br label %bb7
bb7: ; preds = %bb6, %bb3
ret void
}
; a::call_it
; Function Attrs: nounwind
define i32 @_ZN1a7call_it17hd7d40a264ff9d9f3E({}* noalias nonnull align 1, [3 x i32]* noalias readonly align 4 dereferenceable(12)) unnamed_addr #1 {
start:
%_3 = alloca {}, align 1
%_2 = alloca { {}*, [3 x i32]* }, align 4
%f = alloca { {}*, [3 x i32]* }, align 4
%2 = getelementptr inbounds { {}*, [3 x i32]* }, { {}*, [3 x i32]* }* %f, i32 0, i32 0
store {}* %0, {}** %2, align 4
%3 = getelementptr inbounds { {}*, [3 x i32]* }, { {}*, [3 x i32]* }* %f, i32 0, i32 1
store [3 x i32]* %1, [3 x i32]** %3, align 4
%4 = getelementptr inbounds { {}*, [3 x i32]* }, { {}*, [3 x i32]* }* %f, i32 0, i32 0
%5 = load {}*, {}** %4, align 4, !nonnull !1
%6 = getelementptr inbounds { {}*, [3 x i32]* }, { {}*, [3 x i32]* }* %f, i32 0, i32 1
%7 = load [3 x i32]*, [3 x i32]** %6, align 4, !nonnull !1
%8 = bitcast [3 x i32]* %7 to i32*
%9 = getelementptr inbounds i32, i32* %8, i32 1
%10 = load i32, i32* %9, align 4, !invariant.load !1
%11 = bitcast [3 x i32]* %7 to i32*
%12 = getelementptr inbounds i32, i32* %11, i32 2
%13 = load i32, i32* %12, align 4, !invariant.load !1
%unsized_tmp = alloca i8, i32 %10, align 16
%14 = bitcast {}* %5 to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %unsized_tmp, i8* align 1 %14, i32 %10, i1 false)
%15 = getelementptr inbounds { {}*, [3 x i32]* }, { {}*, [3 x i32]* }* %_2, i32 0, i32 0
%16 = bitcast {}** %15 to i8**
store i8* %unsized_tmp, i8** %16, align 4
%17 = getelementptr inbounds { {}*, [3 x i32]* }, { {}*, [3 x i32]* }* %_2, i32 0, i32 1
store [3 x i32]* %7, [3 x i32]** %17, align 4
%18 = getelementptr inbounds { {}*, [3 x i32]* }, { {}*, [3 x i32]* }* %_2, i32 0, i32 0
%19 = load {}*, {}** %18, align 4
%20 = getelementptr inbounds { {}*, [3 x i32]* }, { {}*, [3 x i32]* }* %_2, i32 0, i32 1
%21 = load [3 x i32]*, [3 x i32]** %20, align 4, !nonnull !1
%22 = bitcast [3 x i32]* %21 to i32 ({}*)**
%23 = getelementptr inbounds i32 ({}*)*, i32 ({}*)** %22, i32 3
%24 = load i32 ({}*)*, i32 ({}*)** %23, align 4, !invariant.load !1, !nonnull !1
%25 = call i32 %24({}* %19)
br label %bb1
bb1: ; preds = %start
%26 = bitcast { {}*, [3 x i32]* }* %f to { i8*, i32* }*
%27 = getelementptr inbounds { i8*, i32* }, { i8*, i32* }* %26, i32 0, i32 0
%28 = load i8*, i8** %27, align 4, !nonnull !1
%29 = getelementptr inbounds { i8*, i32* }, { i8*, i32* }* %26, i32 0, i32 1
%30 = load i32*, i32** %29, align 4, !nonnull !1
; call alloc::alloc::box_free
call void @_ZN5alloc5alloc8box_free17hf1f8850d845906a6E(i8* nonnull %28, i32* noalias readonly align 4 dereferenceable(12) %30)
br label %bb2
bb2: ; preds = %bb1
ret i32 %25
}
; a::r
; Function Attrs: nounwind
define i32 @_ZN1a1r17h34450e4e73dc82bbE() unnamed_addr #1 {
start:
%_4 = alloca i32, align 4
; call <usize as core::default::Default>::default
%0 = call i32 @"_ZN48_$LT$usize$u20$as$u20$core..default..Default$GT$7default17h194d800cf4bc33ceE"()
br label %bb1
bb1: ; preds = %start
store i32 %0, i32* %_4, align 4
%1 = load i32, i32* %_4, align 4
; call alloc::alloc::exchange_malloc
%2 = call i8* @_ZN5alloc5alloc15exchange_malloc17hf24c4ee29004a6fcE(i32 4, i32 4) #4
%3 = bitcast i8* %2 to i32*
store i32 %1, i32* %3, align 4
br label %bb2
bb2: ; preds = %bb1
%4 = bitcast i32* %3 to {}*
; call a::call_it
%5 = call i32 @_ZN1a7call_it17hd7d40a264ff9d9f3E({}* noalias nonnull align 1 %4, [3 x i32]* noalias readonly align 4 dereferenceable(12) bitcast ({ void (i32*)*, i32, i32, i32 (i32*)* }* @vtable.0 to [3 x i32]*))
br label %bb3
bb3: ; preds = %bb2
ret i32 %5
}
; a::r::{{closure}}
; Function Attrs: nounwind
define internal i32 @"_ZN1a1r28_$u7b$$u7b$closure$u7d$$u7d$17hd0af2746d5774f0fE"(i32 %arg0) unnamed_addr #1 {
start:
ret i32 %arg0
}
; alloc::alloc::handle_alloc_error
; Function Attrs: noreturn nounwind
declare void @_ZN5alloc5alloc18handle_alloc_error17hf51d0392ce94e89cE(i32, i32) unnamed_addr #2
; Function Attrs: nounwind
declare noalias i8* @__rust_alloc(i32, i32) unnamed_addr #1
; Function Attrs: nounwind
declare void @__rust_dealloc(i8*, i32, i32) unnamed_addr #1
; Function Attrs: argmemonly nounwind
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i1) #3
attributes #0 = { inlinehint nounwind "probe-stack"="__rust_probestack" "target-cpu"="x86-64" }
attributes #1 = { nounwind "probe-stack"="__rust_probestack" "target-cpu"="x86-64" }
attributes #2 = { noreturn nounwind "probe-stack"="__rust_probestack" "target-cpu"="x86-64" }
attributes #3 = { argmemonly nounwind }
attributes #4 = { nounwind }
!0 = !{i32 1, i32 0}
!1 = !{}
// WARNING: This output format is intended for human consumers only
// and is subject to change without notice. Knock yourself out.
fn call_it(_1: std::boxed::Box<dyn std::ops::FnOnce() -> T>) -> T {
let mut _0: T; // return place
let mut _2: dyn std::ops::FnOnce() -> T;
let mut _3: ();
let mut _4: ();
bb0: {
StorageLive(_2); // bb0[0]: scope 0 at a.rs:4:5: 4:6
_2 = move (*_1); // bb0[1]: scope 0 at a.rs:4:5: 4:6
StorageLive(_3); // bb0[2]: scope 0 at a.rs:4:5: 4:8
_0 = const std::ops::FnOnce::call_once(move _2, move _3) -> bb1; // bb0[3]: scope 0 at a.rs:4:5: 4:8
// ty::Const
// + ty: extern "rust-call" fn(dyn std::ops::FnOnce() -> T, ()) -> <dyn std::ops::FnOnce() -> T as std::ops::FnOnce<()>>::Output {<dyn std::ops::FnOnce() -> T as std::ops::FnOnce<()>>::call_once}
// + val: Scalar(Bits { size: 0, bits: 0 })
// mir::Constant
// + span: a.rs:4:5: 4:6
// + ty: extern "rust-call" fn(dyn std::ops::FnOnce() -> T, ()) -> <dyn std::ops::FnOnce() -> T as std::ops::FnOnce<()>>::Output {<dyn std::ops::FnOnce() -> T as std::ops::FnOnce<()>>::call_once}
// + literal: Const { ty: extern "rust-call" fn(dyn std::ops::FnOnce() -> T, ()) -> <dyn std::ops::FnOnce() -> T as std::ops::FnOnce<()>>::Output {<dyn std::ops::FnOnce() -> T as std::ops::FnOnce<()>>::call_once}, val: Scalar(Bits { size: 0, bits: 0 }) }
}
bb1: {
StorageDead(_3); // bb1[0]: scope 0 at a.rs:4:7: 4:8
StorageDead(_2); // bb1[1]: scope 0 at a.rs:4:7: 4:8
_4 = const alloc::alloc::box_free(move (_1.0: std::ptr::Unique<dyn std::ops::FnOnce() -> T>)) -> bb2; // bb1[2]: scope 0 at a.rs:5:1: 5:2
// ty::Const
// + ty: unsafe fn(std::ptr::Unique<dyn std::ops::FnOnce() -> T>) {alloc::alloc::box_free::<dyn std::ops::FnOnce() -> T>}
// + val: Scalar(Bits { size: 0, bits: 0 })
// mir::Constant
// + span: a.rs:5:1: 5:2
// + ty: unsafe fn(std::ptr::Unique<dyn std::ops::FnOnce() -> T>) {alloc::alloc::box_free::<dyn std::ops::FnOnce() -> T>}
// + literal: Const { ty: unsafe fn(std::ptr::Unique<dyn std::ops::FnOnce() -> T>) {alloc::alloc::box_free::<dyn std::ops::FnOnce() -> T>}, val: Scalar(Bits { size: 0, bits: 0 }) }
}
bb2: {
return; // bb2[0]: scope 0 at a.rs:5:2: 5:2
}
}
fn r::{{closure}}#0(_1: [closure@a.rs:12:19: 12:28 s:usize]) -> usize {
let mut _0: usize; // return place
bb0: {
_0 = (_1.0: usize); // bb0[0]: scope 0 at a.rs:12:27: 12:28
return; // bb0[1]: scope 0 at a.rs:12:28: 12:28
}
}
fn r() -> usize {
let mut _0: usize; // return place
scope 1 {
}
scope 2 {
let _1: usize; // "s" in scope 2 at a.rs:11:6: 11:7
}
let mut _2: std::boxed::Box<dyn std::ops::FnOnce() -> usize>;
let mut _3: std::boxed::Box<[closure@a.rs:12:19: 12:28 s:usize]>;
let mut _4: [closure@a.rs:12:19: 12:28 s:usize];
bb0: {
StorageLive(_1); // bb0[0]: scope 0 at a.rs:11:6: 11:7
_1 = const std::default::Default::default() -> bb1; // bb0[1]: scope 0 at a.rs:11:10: 11:22
// ty::Const
// + ty: fn() -> usize {<usize as std::default::Default>::default}
// + val: Scalar(Bits { size: 0, bits: 0 })
// mir::Constant
// + span: a.rs:11:10: 11:20
// + ty: fn() -> usize {<usize as std::default::Default>::default}
// + literal: Const { ty: fn() -> usize {<usize as std::default::Default>::default}, val: Scalar(Bits { size: 0, bits: 0 }) }
}
bb1: {
StorageLive(_2); // bb1[0]: scope 1 at a.rs:12:10: 12:29
StorageLive(_3); // bb1[1]: scope 1 at a.rs:12:10: 12:29
StorageLive(_4); // bb1[2]: scope 1 at a.rs:12:19: 12:28
(_4.0: usize) = _1; // bb1[3]: scope 1 at a.rs:12:19: 12:28
_3 = const std::boxed::Box::<T>::new(move _4) -> bb2; // bb1[4]: scope 1 at a.rs:12:10: 12:29
// ty::Const
// + ty: fn([closure@a.rs:12:19: 12:28 s:usize]) -> std::boxed::Box<[closure@a.rs:12:19: 12:28 s:usize]> {std::boxed::Box::<[closure@a.rs:12:19: 12:28 s:usize]>::new}
// + val: Scalar(Bits { size: 0, bits: 0 })
// mir::Constant
// + span: a.rs:12:10: 12:18
// + ty: fn([closure@a.rs:12:19: 12:28 s:usize]) -> std::boxed::Box<[closure@a.rs:12:19: 12:28 s:usize]> {std::boxed::Box::<[closure@a.rs:12:19: 12:28 s:usize]>::new}
// + user_ty: UserType(0)
// + literal: Const { ty: fn([closure@a.rs:12:19: 12:28 s:usize]) -> std::boxed::Box<[closure@a.rs:12:19: 12:28 s:usize]> {std::boxed::Box::<[closure@a.rs:12:19: 12:28 s:usize]>::new}, val: Scalar(Bits { size: 0, bits: 0 }) }
}
bb2: {
_2 = move _3 as std::boxed::Box<dyn std::ops::FnOnce() -> usize> (Unsize); // bb2[0]: scope 1 at a.rs:12:10: 12:29
StorageDead(_3); // bb2[1]: scope 1 at a.rs:12:28: 12:29
StorageDead(_4); // bb2[2]: scope 1 at a.rs:12:28: 12:29
_0 = const call_it(move _2) -> bb3; // bb2[3]: scope 1 at a.rs:12:2: 12:30
// ty::Const
// + ty: fn(std::boxed::Box<(dyn std::ops::FnOnce() -> usize + 'static)>) -> usize {call_it::<usize>}
// + val: Scalar(Bits { size: 0, bits: 0 })
// mir::Constant
// + span: a.rs:12:2: 12:9
// + ty: fn(std::boxed::Box<(dyn std::ops::FnOnce() -> usize + 'static)>) -> usize {call_it::<usize>}
// + literal: Const { ty: fn(std::boxed::Box<(dyn std::ops::FnOnce() -> usize + 'static)>) -> usize {call_it::<usize>}, val: Scalar(Bits { size: 0, bits: 0 }) }
}
bb3: {
StorageDead(_2); // bb3[0]: scope 1 at a.rs:12:29: 12:30
StorageDead(_1); // bb3[1]: scope 0 at a.rs:13:1: 13:2
return; // bb3[2]: scope 0 at a.rs:13:2: 13:2
}
}
#![feature(unsized_locals)]
pub fn call_it<T>(f: Box<dyn FnOnce() -> T>) -> T {
f()
}
//pub struct S;
pub type S = usize;
pub fn r() -> S {
let s = S::default();
call_it(Box::new(move || s))
}
; ModuleID = 'a.3a1fbbbh-cgu.0'
source_filename = "a.3a1fbbbh-cgu.0"
target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
target triple = "i686-unknown-linux-gnu"
@vtable.0 = private unnamed_addr constant { void (i32*)*, i32, i32, i32 (i32*)* } { void (i32*)* @_ZN4core3ptr18real_drop_in_place17hce3b5b68fb81762cE, i32 4, i32 4, i32 (i32*)* @"_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17hd94193ddf2aa195dE" }, align 4
; <usize as core::default::Default>::default
; Function Attrs: inlinehint nounwind nonlazybind
define internal i32 @"_ZN48_$LT$usize$u20$as$u20$core..default..Default$GT$7default17hce92caa9320ceba0E"() unnamed_addr #0 {
start:
ret i32 0
}
; core::num::NonZeroUsize::new_unchecked
; Function Attrs: inlinehint nounwind nonlazybind
define internal i32 @_ZN4core3num12NonZeroUsize13new_unchecked17h5fdd91a608589b9aE(i32 %n) unnamed_addr #0 {
start:
%_0 = alloca i32, align 4
store i32 %n, i32* %_0, align 4
%0 = load i32, i32* %_0, align 4, !range !1
ret i32 %0
}
; core::num::NonZeroUsize::get
; Function Attrs: inlinehint nounwind nonlazybind
define internal i32 @_ZN4core3num12NonZeroUsize3get17h3d7a5f87975b80a5E(i32 %self) unnamed_addr #0 {
start:
ret i32 %self
}
; core::ops::function::FnOnce::call_once{{vtable.shim}}
; Function Attrs: nounwind nonlazybind
define internal i32 @"_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17hd94193ddf2aa195dE"(i32* %arg0) unnamed_addr #1 {
start:
%arg1 = alloca {}, align 1
%0 = load i32, i32* %arg0, align 4
; call a::r::{{closure}}
%1 = call i32 @"_ZN1a1r28_$u7b$$u7b$closure$u7d$$u7d$17hd0af2746d5774f0fE"(i32 %0)
br label %bb1
bb1: ; preds = %start
ret i32 %1
}
; core::ptr::Unique<T>::as_ptr
; Function Attrs: nounwind nonlazybind
define { {}*, [3 x i32]* } @"_ZN4core3ptr15Unique$LT$T$GT$6as_ptr17hbb256c64bb64ccb1E"(i8* nonnull %self.0, i32* noalias readonly align 4 dereferenceable(12) %self.1) unnamed_addr #1 {
start:
%0 = bitcast i8* %self.0 to {}*
%1 = bitcast i32* %self.1 to [3 x i32]*
%2 = insertvalue { {}*, [3 x i32]* } undef, {}* %0, 0
%3 = insertvalue { {}*, [3 x i32]* } %2, [3 x i32]* %1, 1
ret { {}*, [3 x i32]* } %3
}
; core::ptr::real_drop_in_place
; Function Attrs: nounwind nonlazybind
define internal void @_ZN4core3ptr18real_drop_in_place17hce3b5b68fb81762cE(i32* align 4 dereferenceable(4) %arg0) unnamed_addr #1 {
start:
ret void
}
; core::ptr::<impl *mut T>::is_null
; Function Attrs: inlinehint nounwind nonlazybind
define zeroext i1 @"_ZN4core3ptr31_$LT$impl$u20$$BP$mut$u20$T$GT$7is_null17he7c692cdab113fd5E"(i8* %self) unnamed_addr #0 {
start:
; call core::ptr::null_mut
%0 = call i8* @_ZN4core3ptr8null_mut17h715b1dde6bb64089E()
br label %bb1
bb1: ; preds = %start
%1 = icmp eq i8* %self, %0
ret i1 %1
}
; core::ptr::null_mut
; Function Attrs: inlinehint nounwind nonlazybind
define i8* @_ZN4core3ptr8null_mut17h715b1dde6bb64089E() unnamed_addr #0 {
start:
ret i8* null
}
; core::alloc::Layout::from_size_align_unchecked
; Function Attrs: inlinehint nounwind nonlazybind
define internal { i32, i32 } @_ZN4core5alloc6Layout25from_size_align_unchecked17h0a3fdb1291aaa49bE(i32 %size, i32 %align) unnamed_addr #0 {
start:
%_0 = alloca { i32, i32 }, align 4
; call core::num::NonZeroUsize::new_unchecked
%0 = call i32 @_ZN4core3num12NonZeroUsize13new_unchecked17h5fdd91a608589b9aE(i32 %align), !range !1
br label %bb1
bb1: ; preds = %start
%1 = bitcast { i32, i32 }* %_0 to i32*
store i32 %size, i32* %1, align 4
%2 = getelementptr inbounds { i32, i32 }, { i32, i32 }* %_0, i32 0, i32 1
store i32 %0, i32* %2, align 4
%3 = getelementptr inbounds { i32, i32 }, { i32, i32 }* %_0, i32 0, i32 0
%4 = load i32, i32* %3, align 4
%5 = getelementptr inbounds { i32, i32 }, { i32, i32 }* %_0, i32 0, i32 1
%6 = load i32, i32* %5, align 4, !range !1
%7 = insertvalue { i32, i32 } undef, i32 %4, 0
%8 = insertvalue { i32, i32 } %7, i32 %6, 1
ret { i32, i32 } %8
}
; core::alloc::Layout::size
; Function Attrs: inlinehint nounwind nonlazybind
define internal i32 @_ZN4core5alloc6Layout4size17h684df4f3f3abd41aE({ i32, i32 }* noalias readonly align 4 dereferenceable(8) %self) unnamed_addr #0 {
start:
%0 = bitcast { i32, i32 }* %self to i32*
%1 = load i32, i32* %0, align 4
ret i32 %1
}
; core::alloc::Layout::align
; Function Attrs: inlinehint nounwind nonlazybind
define internal i32 @_ZN4core5alloc6Layout5align17hac7b142d54441a6eE({ i32, i32 }* noalias readonly align 4 dereferenceable(8) %self) unnamed_addr #0 {
start:
%0 = getelementptr inbounds { i32, i32 }, { i32, i32 }* %self, i32 0, i32 1
%1 = load i32, i32* %0, align 4, !range !1
; call core::num::NonZeroUsize::get
%2 = call i32 @_ZN4core3num12NonZeroUsize3get17h3d7a5f87975b80a5E(i32 %1)
br label %bb1
bb1: ; preds = %start
ret i32 %2
}
; alloc::alloc::exchange_malloc
; Function Attrs: inlinehint nounwind nonlazybind
define internal i8* @_ZN5alloc5alloc15exchange_malloc17h7f167f2d5c0549abE(i32 %size, i32 %align) unnamed_addr #0 {
start:
%_0 = alloca i8*, align 4
%0 = icmp eq i32 %size, 0
br i1 %0, label %bb1, label %bb2
bb1: ; preds = %start
%1 = inttoptr i32 %align to i8*
store i8* %1, i8** %_0, align 4
br label %bb8
bb2: ; preds = %start
; call core::alloc::Layout::from_size_align_unchecked
%2 = call { i32, i32 } @_ZN4core5alloc6Layout25from_size_align_unchecked17h0a3fdb1291aaa49bE(i32 %size, i32 %align)
%3 = extractvalue { i32, i32 } %2, 0
%4 = extractvalue { i32, i32 } %2, 1
br label %bb3
bb3: ; preds = %bb2
; call alloc::alloc::alloc
%5 = call i8* @_ZN5alloc5alloc5alloc17h11a1673507d0469fE(i32 %3, i32 %4)
br label %bb4
bb4: ; preds = %bb3
; call core::ptr::<impl *mut T>::is_null
%6 = call zeroext i1 @"_ZN4core3ptr31_$LT$impl$u20$$BP$mut$u20$T$GT$7is_null17he7c692cdab113fd5E"(i8* %5)
br label %bb5
bb5: ; preds = %bb4
%7 = xor i1 %6, true
br i1 %7, label %bb6, label %bb7
bb6: ; preds = %bb5
store i8* %5, i8** %_0, align 4
br label %bb8
bb7: ; preds = %bb5
; call alloc::alloc::handle_alloc_error
call void @_ZN5alloc5alloc18handle_alloc_error17h7c360287e355713dE(i32 %3, i32 %4)
unreachable
bb8: ; preds = %bb6, %bb1
%8 = load i8*, i8** %_0, align 4
ret i8* %8
}
; alloc::alloc::alloc
; Function Attrs: inlinehint nounwind nonlazybind
define internal i8* @_ZN5alloc5alloc5alloc17h11a1673507d0469fE(i32, i32) unnamed_addr #0 {
start:
%layout = alloca { i32, i32 }, align 4
%2 = getelementptr inbounds { i32, i32 }, { i32, i32 }* %layout, i32 0, i32 0
store i32 %0, i32* %2, align 4
%3 = getelementptr inbounds { i32, i32 }, { i32, i32 }* %layout, i32 0, i32 1
store i32 %1, i32* %3, align 4
; call core::alloc::Layout::size
%4 = call i32 @_ZN4core5alloc6Layout4size17h684df4f3f3abd41aE({ i32, i32 }* noalias readonly align 4 dereferenceable(8) %layout)
br label %bb1
bb1: ; preds = %start
; call core::alloc::Layout::align
%5 = call i32 @_ZN4core5alloc6Layout5align17hac7b142d54441a6eE({ i32, i32 }* noalias readonly align 4 dereferenceable(8) %layout)
br label %bb2
bb2: ; preds = %bb1
%6 = call i8* @__rust_alloc(i32 %4, i32 %5)
br label %bb3
bb3: ; preds = %bb2
ret i8* %6
}
; alloc::alloc::dealloc
; Function Attrs: inlinehint nounwind nonlazybind
define internal void @_ZN5alloc5alloc7dealloc17hb7c190bcb20a1e73E(i8* %ptr, i32, i32) unnamed_addr #0 {
start:
%layout = alloca { i32, i32 }, align 4
%2 = getelementptr inbounds { i32, i32 }, { i32, i32 }* %layout, i32 0, i32 0
store i32 %0, i32* %2, align 4
%3 = getelementptr inbounds { i32, i32 }, { i32, i32 }* %layout, i32 0, i32 1
store i32 %1, i32* %3, align 4
; call core::alloc::Layout::size
%4 = call i32 @_ZN4core5alloc6Layout4size17h684df4f3f3abd41aE({ i32, i32 }* noalias readonly align 4 dereferenceable(8) %layout)
br label %bb1
bb1: ; preds = %start
; call core::alloc::Layout::align
%5 = call i32 @_ZN4core5alloc6Layout5align17hac7b142d54441a6eE({ i32, i32 }* noalias readonly align 4 dereferenceable(8) %layout)
br label %bb2
bb2: ; preds = %bb1
call void @__rust_dealloc(i8* %ptr, i32 %4, i32 %5)
br label %bb3
bb3: ; preds = %bb2
ret void
}
; alloc::alloc::box_free
; Function Attrs: inlinehint nounwind nonlazybind
define void @_ZN5alloc5alloc8box_free17h5abb739fd75ad3e7E(i8* nonnull %ptr.0, i32* noalias readonly align 4 dereferenceable(12) %ptr.1) unnamed_addr #0 {
start:
%tmp_ret1 = alloca i32, align 4
%tmp_ret = alloca i32, align 4
; call core::ptr::Unique<T>::as_ptr
%0 = call { {}*, [3 x i32]* } @"_ZN4core3ptr15Unique$LT$T$GT$6as_ptr17hbb256c64bb64ccb1E"(i8* nonnull %ptr.0, i32* noalias readonly align 4 dereferenceable(12) %ptr.1)
%1 = extractvalue { {}*, [3 x i32]* } %0, 0
%2 = extractvalue { {}*, [3 x i32]* } %0, 1
br label %bb1
bb1: ; preds = %start
%3 = bitcast [3 x i32]* %2 to i32*
%4 = getelementptr inbounds i32, i32* %3, i32 1
%5 = load i32, i32* %4, align 4, !invariant.load !2
%6 = bitcast [3 x i32]* %2 to i32*
%7 = getelementptr inbounds i32, i32* %6, i32 2
%8 = load i32, i32* %7, align 4, !invariant.load !2
store i32 %5, i32* %tmp_ret, align 4
%9 = load i32, i32* %tmp_ret, align 4
br label %bb2
bb2: ; preds = %bb1
%10 = bitcast [3 x i32]* %2 to i32*
%11 = getelementptr inbounds i32, i32* %10, i32 1
%12 = load i32, i32* %11, align 4, !invariant.load !2
%13 = bitcast [3 x i32]* %2 to i32*
%14 = getelementptr inbounds i32, i32* %13, i32 2
%15 = load i32, i32* %14, align 4, !invariant.load !2
store i32 %15, i32* %tmp_ret1, align 4
%16 = load i32, i32* %tmp_ret1, align 4
br label %bb3
bb3: ; preds = %bb2
%17 = icmp ne i32 %9, 0
br i1 %17, label %bb4, label %bb7
bb4: ; preds = %bb3
; call core::alloc::Layout::from_size_align_unchecked
%18 = call { i32, i32 } @_ZN4core5alloc6Layout25from_size_align_unchecked17h0a3fdb1291aaa49bE(i32 %9, i32 %16)
%19 = extractvalue { i32, i32 } %18, 0
%20 = extractvalue { i32, i32 } %18, 1
br label %bb5
bb5: ; preds = %bb4
%21 = bitcast {}* %1 to i8*
; call alloc::alloc::dealloc
call void @_ZN5alloc5alloc7dealloc17hb7c190bcb20a1e73E(i8* %21, i32 %19, i32 %20)
br label %bb6
bb6: ; preds = %bb5
br label %bb7
bb7: ; preds = %bb6, %bb3
ret void
}
; a::call_it
; Function Attrs: nounwind nonlazybind
define i32 @_ZN1a7call_it17h019ea9632e867edaE({}* noalias nonnull align 1, [3 x i32]* noalias readonly align 4 dereferenceable(12)) unnamed_addr #1 {
start:
%_3 = alloca {}, align 1
%_2 = alloca { {}*, [3 x i32]* }, align 4
%f = alloca { {}*, [3 x i32]* }, align 4
%2 = getelementptr inbounds { {}*, [3 x i32]* }, { {}*, [3 x i32]* }* %f, i32 0, i32 0
store {}* %0, {}** %2, align 4
%3 = getelementptr inbounds { {}*, [3 x i32]* }, { {}*, [3 x i32]* }* %f, i32 0, i32 1
store [3 x i32]* %1, [3 x i32]** %3, align 4
%4 = getelementptr inbounds { {}*, [3 x i32]* }, { {}*, [3 x i32]* }* %f, i32 0, i32 0
%5 = load {}*, {}** %4, align 4, !nonnull !2
%6 = getelementptr inbounds { {}*, [3 x i32]* }, { {}*, [3 x i32]* }* %f, i32 0, i32 1
%7 = load [3 x i32]*, [3 x i32]** %6, align 4, !nonnull !2
%8 = bitcast [3 x i32]* %7 to i32*
%9 = getelementptr inbounds i32, i32* %8, i32 1
%10 = load i32, i32* %9, align 4, !invariant.load !2
%11 = bitcast [3 x i32]* %7 to i32*
%12 = getelementptr inbounds i32, i32* %11, i32 2
%13 = load i32, i32* %12, align 4, !invariant.load !2
%unsized_tmp = alloca i8, i32 %10, align 16
%14 = bitcast {}* %5 to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %unsized_tmp, i8* align 1 %14, i32 %10, i1 false)
%15 = getelementptr inbounds { {}*, [3 x i32]* }, { {}*, [3 x i32]* }* %_2, i32 0, i32 0
%16 = bitcast {}** %15 to i8**
store i8* %unsized_tmp, i8** %16, align 4
%17 = getelementptr inbounds { {}*, [3 x i32]* }, { {}*, [3 x i32]* }* %_2, i32 0, i32 1
store [3 x i32]* %7, [3 x i32]** %17, align 4
%18 = getelementptr inbounds { {}*, [3 x i32]* }, { {}*, [3 x i32]* }* %_2, i32 0, i32 0
%19 = load {}*, {}** %18, align 4
%20 = getelementptr inbounds { {}*, [3 x i32]* }, { {}*, [3 x i32]* }* %_2, i32 0, i32 1
%21 = load [3 x i32]*, [3 x i32]** %20, align 4, !nonnull !2
%22 = bitcast [3 x i32]* %21 to i32 ({}*)**
%23 = getelementptr inbounds i32 ({}*)*, i32 ({}*)** %22, i32 3
%24 = load i32 ({}*)*, i32 ({}*)** %23, align 4, !invariant.load !2, !nonnull !2
%25 = call i32 %24({}* %19)
br label %bb1
bb1: ; preds = %start
%26 = bitcast { {}*, [3 x i32]* }* %f to { i8*, i32* }*
%27 = getelementptr inbounds { i8*, i32* }, { i8*, i32* }* %26, i32 0, i32 0
%28 = load i8*, i8** %27, align 4, !nonnull !2
%29 = getelementptr inbounds { i8*, i32* }, { i8*, i32* }* %26, i32 0, i32 1
%30 = load i32*, i32** %29, align 4, !nonnull !2
; call alloc::alloc::box_free
call void @_ZN5alloc5alloc8box_free17h5abb739fd75ad3e7E(i8* nonnull %28, i32* noalias readonly align 4 dereferenceable(12) %30)
br label %bb2
bb2: ; preds = %bb1
ret i32 %25
}
; a::r
; Function Attrs: nounwind nonlazybind
define i32 @_ZN1a1r17h34450e4e73dc82bbE() unnamed_addr #1 {
start:
%_4 = alloca i32, align 4
; call <usize as core::default::Default>::default
%0 = call i32 @"_ZN48_$LT$usize$u20$as$u20$core..default..Default$GT$7default17hce92caa9320ceba0E"()
br label %bb1
bb1: ; preds = %start
store i32 %0, i32* %_4, align 4
%1 = load i32, i32* %_4, align 4
; call alloc::alloc::exchange_malloc
%2 = call i8* @_ZN5alloc5alloc15exchange_malloc17h7f167f2d5c0549abE(i32 4, i32 4) #4
%3 = bitcast i8* %2 to i32*
store i32 %1, i32* %3, align 4
br label %bb2
bb2: ; preds = %bb1
%4 = bitcast i32* %3 to {}*
; call a::call_it
%5 = call i32 @_ZN1a7call_it17h019ea9632e867edaE({}* noalias nonnull align 1 %4, [3 x i32]* noalias readonly align 4 dereferenceable(12) bitcast ({ void (i32*)*, i32, i32, i32 (i32*)* }* @vtable.0 to [3 x i32]*))
br label %bb3
bb3: ; preds = %bb2
ret i32 %5
}
; a::r::{{closure}}
; Function Attrs: nounwind nonlazybind
define internal i32 @"_ZN1a1r28_$u7b$$u7b$closure$u7d$$u7d$17hd0af2746d5774f0fE"(i32 %arg0) unnamed_addr #1 {
start:
ret i32 %arg0
}
; alloc::alloc::handle_alloc_error
; Function Attrs: noreturn nounwind nonlazybind
declare void @_ZN5alloc5alloc18handle_alloc_error17h7c360287e355713dE(i32, i32) unnamed_addr #2
; Function Attrs: nounwind nonlazybind
declare noalias i8* @__rust_alloc(i32, i32) unnamed_addr #1
; Function Attrs: nounwind nonlazybind
declare void @__rust_dealloc(i8*, i32, i32) unnamed_addr #1
; Function Attrs: argmemonly nounwind
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i1) #3
attributes #0 = { inlinehint nounwind nonlazybind "probe-stack"="__rust_probestack" "target-cpu"="pentium4" }
attributes #1 = { nounwind nonlazybind "probe-stack"="__rust_probestack" "target-cpu"="pentium4" }
attributes #2 = { noreturn nounwind nonlazybind "probe-stack"="__rust_probestack" "target-cpu"="pentium4" }
attributes #3 = { argmemonly nounwind }
attributes #4 = { nounwind }
!llvm.module.flags = !{!0}
!0 = !{i32 2, !"RtLibUseGOT", i32 1}
!1 = !{i32 1, i32 0}
!2 = !{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment