Hi LLVMdevs,
I am trying to get the runtime values of variables (parameters and local
variables) in a function running in JIT mode.
I generated intrinsic calls to obtain the values of some variables as shown in
the definition below.
define void @foo(i32 %arg1) {
entry:
%X = alloca i32, !dbg !3
store i32 21, i32* %X, !dbg !3
%Y = alloca i32, !dbg !3
store i32 22, i32* %Y, !dbg !3
call void @llvm.dbg.value(metadata !{i32 %arg1}, i64 0, metadata !5), !dbg !7
call void @llvm.dbg.value(metadata !{i32* %X}, i64 0, metadata !8), !dbg !7
call void @llvm.dbg.value(metadata !{i32* %Y}, i64 0, metadata !10), !dbg !7
%Z = alloca i32, !dbg !3
store i32 23, i32* %Z, !dbg !3
%0 = load i32* %X, !dbg !3
store i32 %0, i32* %Z, !dbg !3
%1 = load i32* %Y, !dbg !11
store i32 %1, i32* %X, !dbg !11
%2 = add i32 %0, %1, !dbg !12
store i32 %2, i32* %X, !dbg !12
%3 = load i32* %X, !dbg !13
call void @intDisp(i32 %3), !dbg !13
ret void, !dbg !13
}
However, running the function generates an error "UNREACHABLE executed!
Stack dump:
0.Running pass 'X86 Machine Code Emitter' on function '@foo'
Aborted" . Could you please help resolve the problem. I guess I may be
doing
the wrong thing somewhere.
The assembly code generated for the function is:
BB#0: derived from LLVM BB %entry
%RSP<def> = SUB64ri8 %RSP, 24, %EFLAGS<imp-def,dead>; dbg:l8.cpp:1:1
PROLOG_LABEL <MCSym=.Ltmp0>; dbg:l8.cpp:1:1
DBG_VALUE %EDI, 0, !"arg1"; dbg:l8.cpp:3:1
MOV32mi %RSP, 1, %reg0, 20, %reg0, 21; mem:ST4[%X] dbg:l8.cpp:1:1
MOV32mi %RSP, 1, %reg0, 16, %reg0, 22; mem:ST4[%Y] dbg:l8.cpp:1:1
MOV32mi %RSP, 1, %reg0, 12, %reg0, 23; mem:ST4[%Z] dbg:l8.cpp:1:1
%EDI<def> = MOV32rm %RSP, 1, %reg0, 20, %reg0; mem:LD4[%X] dbg:l8.cpp:1:1
MOV32mr %RSP, 1, %reg0, 12, %reg0, %EDI; mem:ST4[%Z] dbg:l8.cpp:1:1
%EAX<def> = MOV32rm %RSP, 1, %reg0, 16, %reg0; mem:LD4[%Y] dbg:l8.cpp:5:1
MOV32mr %RSP, 1, %reg0, 20, %reg0, %EAX; mem:ST4[%X] dbg:l8.cpp:5:1
%EDI<def> = ADD32rr %EDI, %EAX<kill>, %EFLAGS<imp-def,dead>;
dbg:l8.cpp:6:1
MOV32mr %RSP, 1, %reg0, 20, %reg0, %EDI; mem:ST4[%X] dbg:l8.cpp:6:1
%RAX<def> = MOV64ri <ga:@intDisp>; dbg:l8.cpp:7:1
CALL64r %RAX<kill>, %EDI<kill>, %RAX<imp-def,dead>,
%RDI<imp-def,dead>,
%RSP<imp-use>, ...; dbg:l8.cpp:7:1
%RSP<def> = ADD64ri8 %RSP, 24, %EFLAGS<imp-def,dead>; dbg:l8.cpp:7:1
RET; dbg:l8.cpp:7:1
My other questions are:
1. What is the correct way to obtain the runtime values of variables in an
abstract form after register allocation?
2. I would like to prevent the generation of the DBG_VALUE instruction but still
be able to obtain the value (e.g., %EDI above) by saving the register
code/name?
3. I would like to generate a label and take its address.
Thank for your help.
Best regards,
Nurudeen.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20101109/09f6b4c6/attachment.html>