Skip to content

Instantly share code, notes, and snippets.

@angerman
Created July 28, 2016 14:13
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 angerman/ab3b6027b6409df9d1db8260eca6dd4a to your computer and use it in GitHub Desktop.
Save angerman/ab3b6027b6409df9d1db8260eca6dd4a to your computer and use it in GitHub Desktop.
Haskellish disassembly of an LLVM module.
Module
Version 1
Triple
Datalayout
Globals
0 : @.str :: [16 x i8]*
1 : @.str.1 :: [13 x i8]*
2 : @str :: [12 x i8]*
3 : \main :: ((i32, i8**) -> i32)*
4 : \printf :: ((i8*, ...) -> i32)*
5 : \puts :: ((i8*) -> i32)*
6 : const "hello world %s\n\0" :: [16 x i8]
7 : const "hello world\n\0" :: [13 x i8]
8 : const "hello world\0" :: [12 x i8]
Fn Decls
0 : \printf :: ((i8*, ...) -> i32)*
1 : \puts :: ((i8*) -> i32)*
Functions
0 : \main :: ((i32, i8**) -> i32)*
Constants
0 : const 2 :: i32
1 : const 1 :: i64
2 : const null :: i64
3 : const (getElemenentPointer inbounds (@:: [16 x i8]* !! const null :: i64 !! const null :: i64) :: [16 x i8]) :: i8*
4 : const (getElemenentPointer inbounds (@:: [12 x i8]* !! const null :: i64 !! const null :: i64) :: [12 x i8]) :: i8*
5 : const null :: i32
Blocks
0 : ref 0 <- (arg :: i32) ICMP_SGT (const 2 :: i32) :: i1
br (ref 0 :: i1) 1 2
1 : ref 1 <- getElementPointer inbounds arg :: i8** !! const 1 :: i64
ref 2 <- load (ref 1 :: i8**) :: i8*
ref 3 <- f(const (getElemenentPointer inbounds (@:: [16 x i8]* !! const null :: i64 !! const null :: i64) :: [16 x i8]) :: i8*, ref 2 :: i8*) :: i32
br 3
2 : ref 4 <- f(const (getElemenentPointer inbounds (@:: [12 x i8]* !! const null :: i64 !! const null :: i64) :: [12 x i8]) :: i8*) :: i32
br 3
3 : ret (const null :: i32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment