Prologue & Epilogue Help

Prologue & Epilogue Help

Portrait de srimks

Hello,

I have a GNU-syntax Inline asm code with Prologue & Epilogue as below -

---
void Apple( const State now,
Real crd[MAX_ATOMS][SPACE],
const Real v[MAX_TORS][SPACE],
const int tlist[MAX_TORS][MAX_ATOMS],
const int ntor )
{
asm(
"pushq %rbp \n\t"
"movq %rsp, %rbp \n\t"
"subq $88, %rsp \n\t"
"movq %rdi, %r9 \n\t"
"movq %rdx, %r8 \n\t"
"movslq %ecx, %r10 \n\t"
"xorl %edi, %edi \n\t"
"xorl %ecx, %ecx \n\t"
"xorl %eax, %eax \n\t"
"testq %r10, %r10 \n\t"
"jle B9 \n\t"
...........................................................................
.........................................................................
..........................................................................
...........................................................................
.........................and epilogue as......................

"B9: \n\t"
"addq $88, %rsp \n\t"
"popq %rbp \n\t"
);
}
---

The .S of original C/C++ code prologue and epilogue is as -

--------
# parameter 1(now): 96 + %rsp
# parameter 2(crd): %rdi
# parameter 3(v): %rsi
# parameter 4(tlist): %rdx
# parameter 5(ntor): %ecx
..B1.1: # Preds ..B1.0
..___tag_value__Z7Apple5statePA3_fPA3_KfPA2048_Kii.2: #
..LN1:
.file 1 "Apple.cc"
.loc 1 62
subq $88, %rsp #62.1
..___tag_value__Z7Apple5statePA3_fPA3_KfPA2048_Kii.4: #
movq %rdi, %r9 #62.1
movq %rdx, %r8 #62.1
movslq %ecx, %r10 #62.1
..LN3:
.loc 1 71
xorl %edi, %edi #71.10
xorl %ecx, %ecx #
xorl %eax, %eax #
..LN5:
testq %r10, %r10 #71.22
jle ..B1.9 # Prob 10% #71.22

...........................................................................................................................
...........................................................................................................................
...........................................................................................................................
......................................and epilogue as..........................................................

..B1.9: # Preds ..B1.8 ..B1.1
..LN201:
.loc 1 117
addq $88, %rsp #117.1
..___tag_value__Z7Apple5statePA3_fPA3_KfPA2048_Kii.22: #
ret #117.1
.align 16,0x90
..___tag_value__Z7Apple5statePA3_fPA3_KfPA2048_Kii.24: #
# LOE
# mark_end;
--------

The execution happens fine with above Inline asm code within C/C++ multi-file package as this being simply a replacement of C/C++ API.

But, while performing debugging using GDB by setting a breakpoint both at main and Apple function, after executing the run command the GDB simply comes to the end/epilogue of Apple Inline asm function as below -
---

Breakpoint 2, B9 () at Apple.cc:231
231 }
(gdb)
---

I had also tried modifying the prologue and epilogue with not having above 2 instructions of "pushq %rbp \n\t" and "movq %rsp, %rbp \n\t" of prologue and replacing epiogue of above for "POPQ" with -

"ret \n\t"
"lea (%rsi), %rsi \n\t" -

---

and the GDB reaches the epilogue with a message (Cannot find bounds of current function) with "n" as below -

---
Breakpoint 2, Apple (now=
{T = {x = 28.924999237060547, y = 0, z = 0}, Q = {nx = 0.56170293475662758, ny = -0.21650691003279879, nz = 0.79850771504966789, ang = 2.3272057794698973, w = 0.39603380416958645, x = 0.51577581754005919, y = -0.19880442421690808, z = 0.73321847556347952, qmag = 0}, tor = {2.3977115154266357, -0.026788234710693359, 1.4494588375091553, -0.5426480770111084, -0.2055518627166748, -0.22304439544677734, 0 }, ntor = 6, hasEnergy = 0, e = {total = 0, intra = 0, inter = 0, FE = 0}}, crd=0x7fbffdf3b8, v=0x7fbffdea38, tlist=0x7fbff85660, ntor=6) at Apple.cc:61
61 asm(
(gdb) n
0x0000000000401b18 in ?? ()
(gdb)
Cannot find bounds of current function
(gdb)
---

I am sure, am missing something for having proper Prologue & Epilogue call.

Looking for some correction and clue.

The code which is a part of multi C/C++ file package has been compiled, linked and executed sucessfully using -g -O3 with ICC-v11.0 on Linux x86_64.

~BR

1 contribution / 0 nouveau(x)
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.