Created
June 24, 2018 18:20
-
-
Save rrika/a0d7cc5b0e11ca5147f7e5c638b578bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate llvm_sys; | |
use std::ffi::CStr; | |
use llvm_sys::core::*; | |
use llvm_sys::bit_reader::*; | |
fn main() { | |
unsafe { | |
let mut llvm_module = std::mem::uninitialized(); | |
let mut buffer = std::mem::uninitialized(); | |
let mut message = std::mem::uninitialized(); | |
LLVMCreateMemoryBufferWithContentsOfFile(b"./test.bc\0" as *const u8 as *const i8, &mut buffer, &mut message); | |
LLVMParseBitcode2(buffer, &mut llvm_module); | |
let mut fun = LLVMGetFirstFunction(llvm_module); | |
while !fun.is_null() { | |
let name = LLVMGetValueName(fun); | |
println!("fn {}", CStr::from_ptr(name).to_string_lossy()); | |
fun = LLVMGetNextFunction(fun); | |
} | |
LLVMDisposeModule(llvm_module); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment