Skip to content

Instantly share code, notes, and snippets.

@tomaka
Created February 15, 2016 07:30
Show Gist options
  • Select an option

  • Save tomaka/4114125846c3a11ff729 to your computer and use it in GitHub Desktop.

Select an option

Save tomaka/4114125846c3a11ff729 to your computer and use it in GitHub Desktop.
; 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 Attrs: uwtable
define void @_ZN5hello20h8f5050ffa9929cf1gaaE({ i8*, i32 }* noalias nocapture sret dereferenceable(8)) unnamed_addr #0 {
entry-block:
%f = alloca { %"1.std::ffi::c_str::CStr"*, i32 }
%1 = alloca i8*
%2 = load i8*, i8** getelementptr inbounds ({ i8*, i32 }, { i8*, i32 }* @const3152, i32 0, i32 0)
%3 = load i32, i32* getelementptr inbounds ({ i8*, i32 }, { i8*, i32 }* @const3152, i32 0, i32 1)
%4 = call i8* @"_ZN5slice12_$u5b$T$u5d$6as_ptr20h1947962932139993735E"(i8* noalias nonnull readonly %2, i32 %3)
store i8* %4, i8** %1, align 4
%5 = load i8*, i8** %1, align 4
%6 = call { %"1.std::ffi::c_str::CStr"*, i32 } @_ZN3ffi5c_str4CStr8from_ptr20hcd4af70afe08fc0cKOeE(i8* %5)
%7 = extractvalue { %"1.std::ffi::c_str::CStr"*, i32 } %6, 0
%8 = 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"* %7, %"1.std::ffi::c_str::CStr"** %8
%9 = extractvalue { %"1.std::ffi::c_str::CStr"*, i32 } %6, 1
%10 = getelementptr inbounds { %"1.std::ffi::c_str::CStr"*, i32 }, { %"1.std::ffi::c_str::CStr"*, i32 }* %f, i32 0, i32 1
store i32 %9, i32* %10
%11 = bitcast { i8*, i32 }* %0 to { %"1.std::ffi::c_str::CStr"*, i32 }*
%12 = getelementptr inbounds { %"1.std::ffi::c_str::CStr"*, i32 }, { %"1.std::ffi::c_str::CStr"*, i32 }* %f, i32 0, i32 0
%13 = load %"1.std::ffi::c_str::CStr"*, %"1.std::ffi::c_str::CStr"** %12
%14 = getelementptr inbounds { %"1.std::ffi::c_str::CStr"*, i32 }, { %"1.std::ffi::c_str::CStr"*, i32 }* %f, i32 0, i32 1
%15 = load i32, i32* %14
%16 = getelementptr inbounds { %"1.std::ffi::c_str::CStr"*, i32 }, { %"1.std::ffi::c_str::CStr"*, i32 }* %11, i32 0, i32 0
store %"1.std::ffi::c_str::CStr"* %13, %"1.std::ffi::c_str::CStr"** %16
%17 = getelementptr inbounds { %"1.std::ffi::c_str::CStr"*, i32 }, { %"1.std::ffi::c_str::CStr"*, i32 }* %11, i32 0, i32 1
store i32 %15, i32* %17
ret void
}
declare { %"1.std::ffi::c_str::CStr"*, i32 } @_ZN3ffi5c_str4CStr8from_ptr20hcd4af70afe08fc0cKOeE(i8*) unnamed_addr
; Function Attrs: inlinehint uwtable
define internal i8* @"_ZN5slice12_$u5b$T$u5d$6as_ptr20h1947962932139993735E"(i8* noalias nonnull readonly, i32) unnamed_addr #1 {
entry-block:
%self = alloca { i8*, i32 }
%2 = getelementptr inbounds { i8*, i32 }, { i8*, i32 }* %self, i32 0, i32 0
store i8* %0, i8** %2
%3 = getelementptr inbounds { i8*, i32 }, { i8*, i32 }* %self, i32 0, i32 1
store i32 %1, i32* %3
%4 = getelementptr inbounds { i8*, i32 }, { i8*, i32 }* %self, i32 0, i32 0
%5 = load i8*, i8** %4
%6 = getelementptr inbounds { i8*, i32 }, { i8*, i32 }* %self, i32 0, i32 1
%7 = load i32, i32* %6
%8 = call i8* @"_ZN5slice21_$u5b$T$u5d$.SliceExt6as_ptr21h11401706528773544360E"(i8* noalias nonnull readonly %5, i32 %7)
ret i8* %8
}
; Function Attrs: inlinehint uwtable
define internal i8* @"_ZN5slice21_$u5b$T$u5d$.SliceExt6as_ptr21h11401706528773544360E"(i8* noalias nonnull readonly, i32) unnamed_addr #1 {
entry-block:
%self = alloca { i8*, i32 }
%2 = alloca %"2.core::raw::Slice<u8>"
%3 = getelementptr inbounds { i8*, i32 }, { i8*, i32 }* %self, i32 0, i32 0
store i8* %0, i8** %3
%4 = getelementptr inbounds { i8*, i32 }, { i8*, i32 }* %self, i32 0, i32 1
store i32 %1, i32* %4
%5 = getelementptr inbounds { i8*, i32 }, { i8*, i32 }* %self, i32 0, i32 0
%6 = load i8*, i8** %5
%7 = getelementptr inbounds { i8*, i32 }, { i8*, i32 }* %self, i32 0, i32 1
%8 = load i32, i32* %7
call void @_ZN3raw4Repr4repr20h9469474131478971448E(%"2.core::raw::Slice<u8>"* noalias nocapture sret dereferenceable(8) %2, i8* noalias nonnull readonly %6, i32 %8)
%9 = getelementptr inbounds %"2.core::raw::Slice<u8>", %"2.core::raw::Slice<u8>"* %2, i32 0, i32 0
%10 = load i8*, i8** %9, align 4
ret i8* %10
}
; Function Attrs: inlinehint uwtable
define internal void @_ZN3raw4Repr4repr20h9469474131478971448E(%"2.core::raw::Slice<u8>"* noalias nocapture sret dereferenceable(8), i8* noalias nonnull readonly, i32) unnamed_addr #1 {
entry-block:
%self = alloca { i8*, i32 }
%3 = getelementptr inbounds { i8*, i32 }, { i8*, i32 }* %self, i32 0, i32 0
store i8* %1, i8** %3
%4 = getelementptr inbounds { i8*, i32 }, { i8*, i32 }* %self, i32 0, i32 1
store i32 %2, i32* %4
call void @_ZN3mem14transmute_copy20h1602560601263993975E(%"2.core::raw::Slice<u8>"* noalias nocapture sret dereferenceable(8) %0, { i8*, i32 }* noalias readonly dereferenceable(8) %self)
ret void
}
; Function Attrs: inlinehint uwtable
define internal void @_ZN3mem14transmute_copy20h1602560601263993975E(%"2.core::raw::Slice<u8>"* noalias nocapture sret dereferenceable(8), { i8*, i32 }* noalias readonly dereferenceable(8)) unnamed_addr #1 {
entry-block:
%src.i = alloca %"2.core::raw::Slice<u8>"*
%tmp.i = alloca %"2.core::raw::Slice<u8>"
%src = alloca { i8*, i32 }*
store { i8*, i32 }* %1, { i8*, i32 }** %src, align 4
%2 = load { i8*, i32 }*, { i8*, i32 }** %src, align 4
%3 = bitcast { i8*, i32 }* %2 to %"2.core::raw::Slice<u8>"*
store %"2.core::raw::Slice<u8>"* %3, %"2.core::raw::Slice<u8>"** %src.i, align 4, !noalias !0
call void @_ZN3mem13uninitialized21h11400850547360195153E(%"2.core::raw::Slice<u8>"* noalias nocapture sret dereferenceable(8) %tmp.i), !noalias !0
%4 = load %"2.core::raw::Slice<u8>"*, %"2.core::raw::Slice<u8>"** %src.i, align 4, !noalias !0
%5 = bitcast %"2.core::raw::Slice<u8>"* %tmp.i to i8*
%6 = bitcast %"2.core::raw::Slice<u8>"* %4 to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %5, i8* %6, i32 8, i32 4, i1 false), !noalias !0
%7 = bitcast %"2.core::raw::Slice<u8>"* %tmp.i to i8*
%8 = bitcast %"2.core::raw::Slice<u8>"* %0 to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %8, i8* %7, i32 8, i32 4, i1 false)
ret void
}
; Function Attrs: inlinehint uwtable
define internal void @_ZN3mem13uninitialized21h11400850547360195153E(%"2.core::raw::Slice<u8>"* noalias nocapture sret dereferenceable(8)) unnamed_addr #1 {
entry-block:
ret void
}
; Function Attrs: argmemonly nounwind
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i32, i1) #2
attributes #0 = { uwtable }
attributes #1 = { inlinehint uwtable }
attributes #2 = { argmemonly nounwind }
!0 = !{!1}
!1 = distinct !{!1, !2, !"_ZN3ptr4read20h6988394661068156792E: argument 0"}
!2 = distinct !{!2, !"_ZN3ptr4read20h6988394661068156792E"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment