Skip to content

Instantly share code, notes, and snippets.

@minglotus-6
Created December 7, 2021 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minglotus-6/cae98ad58f7ae6cac8dd848e75c2bde9 to your computer and use it in GitHub Desktop.
Save minglotus-6/cae98ad58f7ae6cac8dd848e75c2bde9 to your computer and use it in GitHub Desktop.
source_filename = "tail_struct.cpp"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%struct.RetVal = type { i32, i32 }
; Function Attrs: mustprogress uwtable
define dso_local i64 @_Z5ParsebPF6RetValvE(i1 zeroext %test, i64 ()* %p) #0 {
entry:
%retval = alloca %struct.RetVal, align 4
%test.addr = alloca i8, align 1
%p.addr = alloca i64 ()*, align 8
%frombool = zext i1 %test to i8
store i8 %frombool, i8* %test.addr, align 1, !tbaa !3
store i64 ()* %p, i64 ()** %p.addr, align 8, !tbaa !7
%0 = load i8, i8* %test.addr, align 1, !tbaa !3, !range !9
%tobool = trunc i8 %0 to i1
br i1 %tobool, label %if.then, label %if.end
if.then: ; preds = %entry
%x = getelementptr inbounds %struct.RetVal, %struct.RetVal* %retval, i32 0, i32 0
store i32 0, i32* %x, align 4, !tbaa !10
%y = getelementptr inbounds %struct.RetVal, %struct.RetVal* %retval, i32 0, i32 1
store i32 0, i32* %y, align 4, !tbaa !13
br label %return
if.end: ; preds = %entry
%1 = load i64 ()*, i64 ()** %p.addr, align 8, !tbaa !7
%call = call i64 %1()
%2 = bitcast %struct.RetVal* %retval to i64*
store i64 %call, i64* %2, align 4
br label %return
return: ; preds = %if.end, %if.then
%3 = bitcast %struct.RetVal* %retval to i64*
%4 = load i64, i64* %3, align 4
ret i64 %4
}
attributes #0 = { mustprogress uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.module.flags = !{!0, !1}
!llvm.ident = !{!2}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"uwtable", i32 1}
!2 = !{!"clang version 14.0.0 (https://github.com/llvm/llvm-project.git 738734f655d3a13dbc2a2dd851a7e907ddcf3fb8)"}
!3 = !{!4, !4, i64 0}
!4 = !{!"bool", !5, i64 0}
!5 = !{!"omnipotent char", !6, i64 0}
!6 = !{!"Simple C++ TBAA"}
!7 = !{!8, !8, i64 0}
!8 = !{!"any pointer", !5, i64 0}
!9 = !{i8 0, i8 2}
!10 = !{!11, !12, i64 0}
!11 = !{!"_ZTS6RetVal", !12, i64 0, !12, i64 4}
!12 = !{!"int", !5, i64 0}
!13 = !{!11, !12, i64 4}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment