-
Notifications
You must be signed in to change notification settings - Fork 262
Open
Description
Describe the Bug
I'm trying to use inkwell to inspect some LLVM IR.
To Reproduce
use std::path::Path;
use inkwell::{context::Context, memory_buffer::MemoryBuffer, values::InstructionOpcode};
fn main() {
// Read the IR file into a memory buffer
let memory_buffer = MemoryBuffer::create_from_file(Path::new("/tmp/test.ll")).unwrap();
let context = Context::create();
// Parse the IR into a module
let module = context
.create_module_from_ir(memory_buffer).unwrap();
let main = module.get_function("main").unwrap();
for bb in main.get_basic_blocks() {
for instruction in bb.get_instructions() {
eprintln!("Instruction: {:?}", instruction);
if instruction.get_opcode() == InstructionOpcode::Call {
eprintln!("Looking at {} operands", instruction.get_num_operands());
for (i, operand) in instruction.get_operands().enumerate() {
eprintln!("Operand {i}: {:?}", operand);
}
}
}
}
}I have applied this to the LLVM IR for the following file:
#include <fcntl.h>
#include <unistd.h>
int main() {
int fd = open("/tmp/test.txt", O_RDONLY);
if (fd >= 0) {
char buffer[256];
read(fd, buffer, sizeof(buffer));
close(fd);
}
return 0;
}In the first call, this panics with
internal error: entered unreachable code: The given type is not a basic type.
Expected Behavior
I expected to be able to look at all the operands of the call.
LLVM Version (please complete the following information):
- LLVM Version: [e.g. 6.0] llvm18-1
- Inkwell Branch Used: 0.7.1
Desktop (please complete the following information):
- OS: [e.g. Ubuntu 16.04, Windows 10] macOS 12.7.6.
Reactions are currently unavailable