Untested code

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 13 07:58:47 PDT 2016


On Wed, Apr 13, 2016 at 12:02 AM, Rafael EspĂ­ndola
<rafael.espindola at gmail.com> wrote:
> I think now there is only one if left untested (see the attached patch) :-)

Attached patch adds test case and tries to fix the problem.

_gp_disp designates offset between start of function and 'gp' pointer into GOT.
Usually you can see the following code in the beginning of a function:

lui    $t0, %hi(_gp_disp)
addi   $t0, $t0, %lo(_gp_disp)

When you calculate result of %hi(_gp_disp), you use %hi(_gp - P)
expression. For the first instruction "_gp - P" gives the distance
between the function and _gp. But for the second instruction you have
to add four byte offset %hi(_gp - P + 4). Code in the trunk
incorrectly calculates %lo(_gp_disp) as an absolute expression
%lo(_gp).

I am not sure that the fix is ideal. So I would appreciate any
suggestions / objections.

-- 
Simon Atanasyan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: _gp_disp.patch
Type: application/octet-stream
Size: 2965 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160413/567f92bd/attachment.obj>


More information about the llvm-commits mailing list