HomePhabricator

[mips] Fix expanding `lw/sw $reg1, symbol($reg2)` instruction

Description

[mips] Fix expanding lw/sw $reg1, symbol($reg2) instruction

When a "base" in the lw/sw $reg1, symbol($reg2) instruction is
a register and generated code is position independent, backend
does not add the "base" value to the symbol address.

lw     $reg1, %got(symbol)($gp)
lw/sw  $reg1, 0($reg1)

This patch fixes the bug and adds the missed addu instruction by
passing BaseReg into the loadAndAddSymbolAddress routine and handles
the case when the BaseReg is the zero register to escape redundant
move reg, reg instruction:

lw     $reg1, %got(symbol)($gp)
addu   $reg1, $reg1, $reg2
lw/sw  $reg1, 0($reg1)

Differential Revision: https://reviews.llvm.org/D66894

Details

Committed
atanasyanThu, Aug 29, 6:19 AM
Differential Revision
D66894: [mips] Fix expanding `lw/sw $reg1, symbol($reg2)` instruction
Parents
rL370352: ReleaseNotes: matching wide stores (r362472)
Branches
Unknown
Tags
Unknown