Vote count:
0
I noticed that llvm.read_register()
could read the value of stack pointer, as well as llvm.write_register()
could set the value of stack pointer. I add main function to the stackpointer.ll
which could be found in the llvm src:
;stackpointer.ll
define i32 @get_stack() nounwind {
%sp = call i32 @llvm.read_register.i32(metadata !0)
ret i32 %sp
}
declare i32 @llvm.read_register.i32(metadata) nounwind
!0 = metadata !{metadata !"sp\00"}
define i32 @main() {
%1 = call i32 @get_stack()
ret i32 %1
}
I tested on an armv7 board running ubuntu 11.04:
lli stackpointer.ll
then, I get a stack dump:
ARMCodeEmitter::emitPseudoInstruction
UNREACHABLE executed at ARMCodeEmitter.cpp:847!
Stack dump:
0. Program arguments: lli stackpointer.ll
1. Running pass 'ARM Machine Code Emitter' on function '@main'
Aborted
I also tried llc:
llc stackpointer.ll -o stackpointer.s
The error messege:
Can't get register for value!
UNREACHABLE executed at ARMCodeEmitter.cpp:1183!
Stack dump:
0. Program arguments: llc stackpointer.ll -o stackpointer.s
1. Running pass 'Function Pass Manager' on moulude 'stackpointer.ll'
2. Running pass 'ARM Instruction Selection' on function '@get_stack'
Aborted
I also tried on x86-64 platform, it didn't work. What is the correct way to use these intrinsics?
asked 1 min ago
how to use llvm intrinsics @llvm.read_register?
Aucun commentaire:
Enregistrer un commentaire