Skip to content

Instantly share code, notes, and snippets.

View tomaka's full-sized avatar

Pierre Krieger tomaka

  • Freelance
  • Berlin, Germany
View GitHub Profile
; ModuleID = 'test.0.rs'
target datalayout = "e-p:32:32-i64:64-v128:32:128-n32-S128"
target triple = "asmjs-unknown-emscripten"
%str_slice = type { i8*, i32 }
%"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"*, i32 } }
%"2.core::option::Option<usize>" = type { i32, [0 x i32], [1 x i32] }
%"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::fmt::ArgumentV1" = type { %"2.core::fmt::Void"*, i8 (%"2.core::fmt::Void"*, %"2.core::fmt::Formatter"*)* }
%"2.core::fmt::Void" = type {}
; ModuleID = 'test.0.rs'
target datalayout = "e-p:32:32-i64:64-v128:32:128-n32-S128"
target triple = "asmjs-unknown-emscripten"
%"1.std::ffi::c_str::CStr" = type { i8 }
%"2.core::raw::Slice<u8>" = type { i8*, i32 }
@const3150 = internal unnamed_addr constant i32 1, align 4
@byte_str3151 = internal unnamed_addr constant [4 x i8] c"foo\00", align 1
@const3152 = internal unnamed_addr constant { i8*, i32 } { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @byte_str3151, i32 0, i32 0), i32 4 }, align 4
; ModuleID = 'test.0.rs'
target datalayout = "e-p:32:32-i64:64-v128:32:128-n32-S128"
target triple = "asmjs-unknown-emscripten"
%"1.std::ffi::c_str::CStr" = type { i8 }
%"2.core::raw::Slice<u8>" = type { i8*, i32 }
@const3150 = internal unnamed_addr constant i32 1, align 4
@byte_str3151 = internal unnamed_addr constant [4 x i8] c"foo\00", align 1
@const3152 = internal unnamed_addr constant { i8*, i32 } { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @byte_str3151, i32 0, i32 0), i32 4 }, align 4
function __ZN5hello20h898a0b35c963e11dgaaE() {
var $$sreg$field = 0, $$sreg$field2 = 0, $$sreg$index1 = 0, $0 = 0, $1 = 0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $f = 0, $v = 0, label = 0, sp = 0;
sp = STACKTOP;
STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort();
$0 = sp;
$f = sp + 16|0;
$v = sp + 8|0;
$$sreg$field = HEAP32[$0>>2]|0;
$$sreg$index1 = ((($0)) + 4|0);
$$sreg$field2 = HEAP32[$$sreg$index1>>2]|0;
function __ZN5hello20h00209f75792421a9gaaE() {
var $$sreg$field = 0, $$sreg$field2 = 0, $$sreg$index1 = 0, $0 = 0, $1 = 0, $2 = 0, $f = 0, $v = 0, label = 0, sp = 0;
sp = STACKTOP;
STACKTOP = STACKTOP + 32|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort();
$0 = sp;
$f = sp + 16|0;
$v = sp + 8|0;
__ZN5slice14from_raw_parts21h14897924922607837926E($0,(-559038737),6);
$$sreg$field = HEAP32[$0>>2]|0;
$$sreg$index1 = ((($0)) + 4|0);
; Function Attrs: noinline uwtable
define internal i8* @_ZN5hello20h898a0b35c963e11dgaaE() unnamed_addr #0 {
entry-block:
%f = alloca { %"1.std::ffi::c_str::CStr"*, i32 }
%v = alloca { i8*, i32 }
%0 = call { %"1.std::ffi::c_str::CStr"*, i32 } @_ZN3ffi5c_str4CStr8from_ptr20hcd4af70afe08fc0cKOeE(i8* inttoptr (i32 -559038737 to i8*))
%1 = extractvalue { %"1.std::ffi::c_str::CStr"*, i32 } %0, 0
%2 = getelementptr inbounds { %"1.std::ffi::c_str::CStr"*, i32 }, { %"1.std::ffi::c_str::CStr"*, i32 }* %f, i32 0, i32 0
store %"1.std::ffi::c_str::CStr"* %1, %"1.std::ffi::c_str::CStr"** %2
%3 = extractvalue { %"1.std::ffi::c_str::CStr"*, i32 } %0, 1
function __ZN5hello20h898a0b35c963e11dgaaE() {
var $$sreg$field = 0, $$sreg$field2 = 0, $$sreg$index1 = 0, $0 = 0, $1 = 0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $6 = 0, $f = 0, $v = 0, label = 0, sp = 0;
sp = STACKTOP;
STACKTOP = STACKTOP + 32|0;
$0 = sp;
$f = sp + 16|0;
$v = sp + 8|0;
__ZN3ffi5c_str4CStr8from_ptr20hcd4af70afe08fc0cKOeE(($0|0),((-559038737)|0));
$$sreg$field = HEAP32[$0>>2]|0;
$$sreg$index1 = ((($0)) + 4|0);
extern crate libc;
use std::os::raw::c_char;
use std::mem;
use std::slice;
pub struct CStr {
inner: [c_char]
}
*** IR Dump After Expand out variables with struct types ***
; Function Attrs: noinline uwtable
define internal fastcc i8* @_ZN5hello20h950a00b68330e9b8haaE() unnamed_addr #0 {
entry-block:
%0 = alloca i8, i32 8, align 16
%.bc = bitcast i8* %0 to { i8*, i32 }*
call void @_ZN3get20h05af50f9733c2d54haaE({ i8*, i32 }* %.bc)
%.sreg.index = getelementptr { i8*, i32 }, { i8*, i32 }* %.bc, i32 0, i32 0
%.sreg.field = load i8*, i8** %.sreg.index, align 16
%.sreg.index1 = getelementptr { i8*, i32 }, { i8*, i32 }* %.bc, i32 0, i32 1
; ModuleID = 'test.0.rs'
target datalayout = "e-p:32:32-i64:64-v128:32:128-n32-S128"
target triple = "asmjs-unknown-emscripten"
; Function Attrs: noinline uwtable
define i8* @_ZN5hello20he76161cf814e3896haaE() unnamed_addr #0 {
entry-block:
%0 = tail call { i8*, i32 } @_ZN3get20h05af50f9733c2d54haaE()
%1 = extractvalue { i8*, i32 } %0, 0
ret i8* %1