Skip to content

Instantly share code, notes, and snippets.

@nikomatsakis
Created December 13, 2019 13:45
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save nikomatsakis/0fde1684114f5b86847b4d4fb211c24f to your computer and use it in GitHub Desktop.
; ModuleID = '31e3415mrsire8w'
source_filename = "31e3415mrsire8w"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%"core::fmt::Arguments" = type { [0 x i64], { [0 x { [0 x i8]*, i64 }]*, i64 }, [0 x i64], { i64*, i64 }, [0 x i64], { [0 x { i8*, i8* }]*, i64 }, [0 x i64] }
%"unwind::libunwind::_Unwind_Exception" = type { [0 x i64], i64, [0 x i64], void (i32, %"unwind::libunwind::_Unwind_Exception"*)*, [0 x i64], [6 x i64], [0 x i64] }
%"unwind::libunwind::_Unwind_Context" = type { [0 x i8] }
%"core::fmt::Formatter" = type { [0 x i64], { i64, i64 }, [0 x i64], { i64, i64 }, [0 x i64], { {}*, [3 x i64]* }, [0 x i64], { i64*, i64* }, [0 x i64], { [0 x { i8*, i8* }]*, i64 }, [0 x i32], i32, [0 x i32], i32, [0 x i8], i8, [7 x i8] }
@0 = private unnamed_addr constant <{ [20 x i8] }> <{ [20 x i8] c"double_input: input=" }>, align 1
@1 = private unnamed_addr constant <{ [1 x i8] }> <{ [1 x i8] c"\0A" }>, align 1
@2 = private unnamed_addr constant <{ i8*, [8 x i8], i8*, [8 x i8] }> <{ i8* getelementptr inbounds (<{ [20 x i8] }>, <{ [20 x i8] }>* @0, i32 0, i32 0, i32 0), [8 x i8] c"\14\00\00\00\00\00\00\00", i8* getelementptr inbounds (<{ [1 x i8] }>, <{ [1 x i8] }>* @1, i32 0, i32 0, i32 0), [8 x i8] c"\01\00\00\00\00\00\00\00" }>, align 8
@__rustc_debug_gdb_scripts_section__ = linkonce_odr unnamed_addr constant [34 x i8] c"\01gdb_load_rust_pretty_printers.py\00", section ".debug_gdb_scripts", align 1
; Function Attrs: nonlazybind uwtable
define i32 @double_input(i32) unnamed_addr #0 personality i32 (i32, i32, i64, %"unwind::libunwind::_Unwind_Exception"*, %"unwind::libunwind::_Unwind_Context"*)* @rust_eh_personality !dbg !6 {
start:
%1 = alloca { i8*, i32 }, align 8
%arg0 = alloca i32*, align 8
%_11 = alloca i32*, align 8
%_10 = alloca [1 x { i8*, i8* }], align 8
%_3 = alloca %"core::fmt::Arguments", align 8
%input = alloca i32, align 4
store i32 %0, i32* %input, align 4
call void @llvm.dbg.declare(metadata i32* %input, metadata !11, metadata !DIExpression()), !dbg !12
call void @llvm.dbg.declare(metadata i32** %arg0, metadata !13, metadata !DIExpression()), !dbg !18
store i32* %input, i32** %_11, align 8, !dbg !19
%2 = load i32*, i32** %_11, align 8, !dbg !19, !nonnull !5
store i32* %2, i32** %arg0, align 8, !dbg !19
%_15 = load i32*, i32** %arg0, align 8, !dbg !18, !nonnull !5
; call core::fmt::ArgumentV1::new
%3 = call { i8*, i8* } @_ZN4core3fmt10ArgumentV13new17hb188fa77122933d4E(i32* noalias readonly align 4 dereferenceable(4) %_15, i1 (i32*, %"core::fmt::Formatter"*)* nonnull @"_ZN4core3fmt3num3imp52_$LT$impl$u20$core..fmt..Display$u20$for$u20$i32$GT$3fmt17h1c4f30b9a8bff4a9E"), !dbg !18
%4 = extractvalue { i8*, i8* } %3, 0, !dbg !18
%5 = extractvalue { i8*, i8* } %3, 1, !dbg !18
br label %bb1, !dbg !18
bb1: ; preds = %start
%6 = bitcast [1 x { i8*, i8* }]* %_10 to { i8*, i8* }*, !dbg !18
%7 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %6, i32 0, i32 0, !dbg !18
store i8* %4, i8** %7, align 8, !dbg !18
%8 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %6, i32 0, i32 1, !dbg !18
store i8* %5, i8** %8, align 8, !dbg !18
%_7.0 = bitcast [1 x { i8*, i8* }]* %_10 to [0 x { i8*, i8* }]*, !dbg !19
; call core::fmt::Arguments::new_v1
call void @_ZN4core3fmt9Arguments6new_v117h43ee6b91c8df4b5dE(%"core::fmt::Arguments"* noalias nocapture sret dereferenceable(48) %_3, [0 x { [0 x i8]*, i64 }]* noalias nonnull readonly align 8 bitcast (<{ i8*, [8 x i8], i8*, [8 x i8] }>* @2 to [0 x { [0 x i8]*, i64 }]*), i64 2, [0 x { i8*, i8* }]* noalias nonnull readonly align 8 %_7.0, i64 1), !dbg !19
br label %bb2, !dbg !19
bb2: ; preds = %bb1
; call std::io::stdio::_print
call void @_ZN3std2io5stdio6_print17hd892a99a5c39f575E(%"core::fmt::Arguments"* noalias nocapture dereferenceable(48) %_3), !dbg !19
br label %bb3, !dbg !19
bb3: ; preds = %bb2
%_17 = load i32, i32* %input, align 4, !dbg !20
%9 = invoke i32 @triple_input(i32 %_17)
to label %bb4 unwind label %cleanup, !dbg !22
bb4: ; preds = %bb3
ret i32 %9, !dbg !23
bb5: ; preds = %cleanup
call void @llvm.trap(), !dbg !24
unreachable, !dbg !24
cleanup: ; preds = %bb3
%10 = landingpad { i8*, i32 }
cleanup
%11 = extractvalue { i8*, i32 } %10, 0
%12 = extractvalue { i8*, i32 } %10, 1
%13 = getelementptr inbounds { i8*, i32 }, { i8*, i32 }* %1, i32 0, i32 0
store i8* %11, i8** %13, align 8
%14 = getelementptr inbounds { i8*, i32 }, { i8*, i32 }* %1, i32 0, i32 1
store i32 %12, i32* %14, align 8
br label %bb5
}
; Function Attrs: nonlazybind uwtable
declare i32 @rust_eh_personality(i32, i32, i64, %"unwind::libunwind::_Unwind_Exception"*, %"unwind::libunwind::_Unwind_Context"*) unnamed_addr #0
; Function Attrs: nounwind readnone speculatable
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
; core::fmt::num::imp::<impl core::fmt::Display for i32>::fmt
; Function Attrs: nonlazybind uwtable
declare zeroext i1 @"_ZN4core3fmt3num3imp52_$LT$impl$u20$core..fmt..Display$u20$for$u20$i32$GT$3fmt17h1c4f30b9a8bff4a9E"(i32* noalias readonly align 4 dereferenceable(4), %"core::fmt::Formatter"* align 8 dereferenceable(96)) unnamed_addr #0
; core::fmt::ArgumentV1::new
; Function Attrs: nonlazybind uwtable
declare { i8*, i8* } @_ZN4core3fmt10ArgumentV13new17hb188fa77122933d4E(i32* noalias readonly align 4 dereferenceable(4), i1 (i32*, %"core::fmt::Formatter"*)* nonnull) unnamed_addr #0
; core::fmt::Arguments::new_v1
; Function Attrs: inlinehint nonlazybind uwtable
declare hidden void @_ZN4core3fmt9Arguments6new_v117h43ee6b91c8df4b5dE(%"core::fmt::Arguments"* noalias nocapture sret dereferenceable(48), [0 x { [0 x i8]*, i64 }]* noalias nonnull readonly align 8, i64, [0 x { i8*, i8* }]* noalias nonnull readonly align 8, i64) unnamed_addr #2
; std::io::stdio::_print
; Function Attrs: nonlazybind uwtable
declare void @_ZN3std2io5stdio6_print17hd892a99a5c39f575E(%"core::fmt::Arguments"* noalias nocapture dereferenceable(48)) unnamed_addr #0
; Function Attrs: nonlazybind uwtable
declare i32 @triple_input(i32) unnamed_addr #0
; Function Attrs: cold noreturn nounwind
declare void @llvm.trap() #3
attributes #0 = { nonlazybind uwtable "probe-stack"="__rust_probestack" "target-cpu"="x86-64" }
attributes #1 = { nounwind readnone speculatable }
attributes #2 = { inlinehint nonlazybind uwtable "probe-stack"="__rust_probestack" "target-cpu"="x86-64" }
attributes #3 = { cold noreturn nounwind }
!llvm.module.flags = !{!0, !1, !2}
!llvm.dbg.cu = !{!3}
!0 = !{i32 7, !"PIC Level", i32 2}
!1 = !{i32 2, !"RtLibUseGOT", i32 1}
!2 = !{i32 2, !"Debug Info Version", i32 3}
!3 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !4, producer: "clang LLVM (rustc version 1.41.0-dev)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !5)
!4 = !DIFile(filename: "src/lib.rs", directory: "/home/nmatsakis/versioned/rust-ffi-examples/cpp-to-rust")
!5 = !{}
!6 = distinct !DISubprogram(name: "double_input", linkageName: "double_input", scope: !7, file: !4, line: 8, type: !8, scopeLine: 8, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !3, templateParams: !5, retainedNodes: !5)
!7 = !DINamespace(name: "double_input", scope: null)
!8 = !DISubroutineType(types: !9)
!9 = !{!10, !10}
!10 = !DIBasicType(name: "i32", size: 32, encoding: DW_ATE_signed)
!11 = !DILocalVariable(name: "input", arg: 1, scope: !6, file: !4, line: 8, type: !10)
!12 = !DILocation(line: 8, column: 27, scope: !6)
!13 = !DILocalVariable(name: "arg0", scope: !14, file: !4, line: 9, type: !17, align: 8)
!14 = !DILexicalBlockFile(scope: !15, file: !4, discriminator: 0)
!15 = distinct !DILexicalBlock(scope: !6, file: !16, line: 2, column: 28)
!16 = !DIFile(filename: "<::std::macros::println macros>", directory: "/home/nmatsakis/versioned/rust-ffi-examples/cpp-to-rust")
!17 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "&i32", baseType: !10, size: 64, align: 64)
!18 = !DILocation(line: 9, column: 4, scope: !14)
!19 = !DILocation(line: 9, column: 4, scope: !6)
!20 = !DILocation(line: 10, column: 26, scope: !21)
!21 = distinct !DILexicalBlock(scope: !6, file: !4, line: 10, column: 4)
!22 = !DILocation(line: 10, column: 13, scope: !21)
!23 = !DILocation(line: 11, column: 1, scope: !6)
!24 = !DILocation(line: 8, scope: !6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment