mirror of
https://github.com/vosen/ZLUDA.git
synced 2025-04-28 21:47:57 +03:00
LLVM unit tests: just use the stack
This commit is contained in:
parent
3968c35658
commit
5a15204910
1 changed files with 5 additions and 10 deletions
|
@ -24,10 +24,10 @@
|
||||||
// shows it fails inside amdgpu-isel. You can get a little bit furthr with "-mllvm -global-isel",
|
// shows it fails inside amdgpu-isel. You can get a little bit furthr with "-mllvm -global-isel",
|
||||||
// but it will too fail similarly, but with "unable to legalize instruction"
|
// but it will too fail similarly, but with "unable to legalize instruction"
|
||||||
|
|
||||||
use std::alloc::{alloc, dealloc, handle_alloc_error, Layout};
|
|
||||||
use std::array::TryFromSliceError;
|
use std::array::TryFromSliceError;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use std::ffi::{CStr, NulError};
|
use std::ffi::{CStr, NulError};
|
||||||
|
use std::mem;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::{i8, ptr};
|
use std::{i8, ptr};
|
||||||
|
|
||||||
|
@ -153,16 +153,11 @@ pub struct MemoryBuffer(LLVMMemoryBufferRef);
|
||||||
impl MemoryBuffer {
|
impl MemoryBuffer {
|
||||||
pub fn print_as_asm(&self) -> &str {
|
pub fn print_as_asm(&self) -> &str {
|
||||||
unsafe {
|
unsafe {
|
||||||
let layout = Layout::new::<LLVMModuleRef>();
|
let mut module: LLVMModuleRef = mem::zeroed();
|
||||||
let p_module = alloc(layout);
|
|
||||||
if p_module.is_null() {
|
|
||||||
handle_alloc_error(layout);
|
|
||||||
}
|
|
||||||
let context = Context::new();
|
let context = Context::new();
|
||||||
LLVMParseBitcodeInContext2(context.0, self.0, p_module as *mut LLVMModuleRef);
|
LLVMParseBitcodeInContext2(context.0, self.0, &mut module);
|
||||||
let asm = LLVMPrintModuleToString(*(p_module as *mut LLVMModuleRef));
|
let asm = LLVMPrintModuleToString(module);
|
||||||
LLVMDisposeModule(*(p_module as *mut LLVMModuleRef));
|
LLVMDisposeModule(module);
|
||||||
dealloc(p_module, layout);
|
|
||||||
let asm = CStr::from_ptr(asm);
|
let asm = CStr::from_ptr(asm);
|
||||||
asm.to_str().unwrap().trim()
|
asm.to_str().unwrap().trim()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue