Skip to content

Instantly share code, notes, and snippets.

@bluss
Last active December 16, 2016 22:40
Show Gist options
  • Save bluss/581396dd75d101abb658e40379b49dcc to your computer and use it in GitHub Desktop.
Save bluss/581396dd75d101abb658e40379b49dcc to your computer and use it in GitHub Desktop.
; ModuleID = 'id_result.cgu-0.rs'
source_filename = "id_result.cgu-0.rs"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%"core::result::Result<u64, i64>" = type { i64, [0 x i64], [1 x i64] }
; Function Attrs: uwtable
define void @id_result(%"core::result::Result<u64, i64>"* noalias nocapture sret dereferenceable(16), %"core::result::Result<u64, i64>"* noalias nocapture dereferenceable(16)) unnamed_addr #0 {
entry-block:
br label %start
start: ; preds = %entry-block
%2 = getelementptr inbounds %"core::result::Result<u64, i64>", %"core::result::Result<u64, i64>"* %1, i32 0, i32 0
%3 = load i64, i64* %2, !range !0
switch i64 %3, label %unreachable [
i64 0, label %bb1
i64 1, label %bb2
]
bb1: ; preds = %start
%4 = bitcast %"core::result::Result<u64, i64>"* %1 to { i64, i64 }*
%5 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %4, i32 0, i32 1
%6 = load i64, i64* %5
%7 = getelementptr inbounds %"core::result::Result<u64, i64>", %"core::result::Result<u64, i64>"* %0, i32 0, i32 0
store i64 0, i64* %7
%8 = bitcast %"core::result::Result<u64, i64>"* %0 to { i64, i64 }*
%9 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %8, i32 0, i32 1
store i64 %6, i64* %9
br label %bb3
bb2: ; preds = %start
%10 = bitcast %"core::result::Result<u64, i64>"* %1 to { i64, i64 }*
%11 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %10, i32 0, i32 1
%12 = load i64, i64* %11
%13 = getelementptr inbounds %"core::result::Result<u64, i64>", %"core::result::Result<u64, i64>"* %0, i32 0, i32 0
store i64 1, i64* %13
%14 = bitcast %"core::result::Result<u64, i64>"* %0 to { i64, i64 }*
%15 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %14, i32 0, i32 1
store i64 %12, i64* %15
br label %bb3
bb3: ; preds = %bb1, %bb2
ret void
unreachable: ; preds = %start
unreachable
}
attributes #0 = { uwtable }
!0 = !{i64 0, i64 2}
; ModuleID = 'id_result.cgu-0.rs'
source_filename = "id_result.cgu-0.rs"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%"core::result::Result<u64, i64>" = type { i64, [0 x i64], [1 x i64] }
; Function Attrs: uwtable
define void @id_result(%"core::result::Result<u64, i64>"* noalias nocapture sret dereferenceable(16), %"core::result::Result<u64, i64>"* noalias nocapture dereferenceable(16)) unnamed_addr #0 {
entry-block:
br label %start
start: ; preds = %entry-block
%2 = getelementptr inbounds %"core::result::Result<u64, i64>", %"core::result::Result<u64, i64>"* %1, i32 0, i32 0
%3 = load i64, i64* %2, !range !0
switch i64 %3, label %unreachable [
i64 0, label %bb1
i64 1, label %bb2
]
bb1: ; preds = %start
%4 = bitcast %"core::result::Result<u64, i64>"* %1 to { i64, i64 }*
%5 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %4, i32 0, i32 1
%6 = load i64, i64* %5
%7 = getelementptr inbounds %"core::result::Result<u64, i64>", %"core::result::Result<u64, i64>"* %0, i32 0, i32 0
store i64 0, i64* %7
%8 = bitcast %"core::result::Result<u64, i64>"* %0 to { i64, i64 }*
%9 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %8, i32 0, i32 1
store i64 %6, i64* %9
br label %bb3
bb2: ; preds = %start
%10 = bitcast %"core::result::Result<u64, i64>"* %1 to { i64, i64 }*
%11 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %10, i32 0, i32 1
%12 = load i64, i64* %11
%13 = getelementptr inbounds %"core::result::Result<u64, i64>", %"core::result::Result<u64, i64>"* %0, i32 0, i32 0
store i64 1, i64* %13
%14 = bitcast %"core::result::Result<u64, i64>"* %0 to { i64, i64 }*
%15 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %14, i32 0, i32 1
store i64 %12, i64* %15
br label %bb3
bb3: ; preds = %bb1, %bb2
ret void
unreachable: ; preds = %start
unreachable
}
attributes #0 = { uwtable }
!0 = !{i64 0, i64 2}
#![crate_type="lib"]
#[no_mangle]
pub fn id_result(a: Result<u64, i64>) -> Result<u64, i64> {
match a {
Ok(x) => Ok(x),
Err(y) => Err(y),
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment