OSDN Git Service

Add cfi instr for CFA calculation when movpc is expanded to call and pop
authorPetar Jovanovic <petar.jovanovic@imgtec.com>
Thu, 5 Nov 2015 17:19:59 +0000 (17:19 +0000)
committerPetar Jovanovic <petar.jovanovic@imgtec.com>
Thu, 5 Nov 2015 17:19:59 +0000 (17:19 +0000)
commit00e29ad54f83e459f1f1cc5d0c2c0e77b7a84c3e
tree0d906dc14ed3e271670597bb8828f22cf133ec80
parentf2841629064fa4562a5f26f86dd586eddd303d35
Add cfi instr for CFA calculation when movpc is expanded to call and pop

This fixes the issue of wrong CFA calculation in the following case:

0x08048400 <+0>: push   %ebx
0x08048401 <+1>: sub    $0x8,%esp
0x08048404 <+4>: **call   0x8048409 <test+9>**
0x08048409 <+9>: **pop    %eax**
0x0804840a <+10>: add    $0x1bf7,%eax
0x08048410 <+16>: mov    %eax,%ebx
0x08048412 <+18>: call   0x80483f0 <bar>
0x08048417 <+23>: add    $0x8,%esp
0x0804841a <+26>: pop    %ebx
0x0804841b <+27>: ret

The highlighted instructions are a product of movpc instruction. The call
instruction changes the stack pointer, and pop instruction restores its
value. However, the rule for computing CFA is not updated and is wrong on
the pop instruction. So, e.g. backtrace in gdb does not work when on the pop
instruction. This adds cfi instructions for both call and pop instructions.

cfi_adjust_cfa_offset** instruction is used with the appropriate offset for
setting the rules to calculate CFA correctly.

Patch by Violeta Vukobrat.

Differential Revision: http://reviews.llvm.org/D14021

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252176 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86MCInstLower.cpp
test/CodeGen/X86/movpc32-check.ll [new file with mode: 0644]