[PATCH] Fix MipsLongBranch pass to work when the code has inline assembly.
Sasa Stankovic
Sasa.Stankovic at imgtec.com
Wed Apr 16 09:36:37 PDT 2014
I reordered instructions in the long branch to avoid the bug in GAS. When first of the symbols in %hi(label1 - label2) and %lo(label1 - label2) is defined before the two instructions, and the other symbol is defined between the two instructions, then GAS can sometime (for label1 - label2 close to -32768) wrongly calculate %hi(label1 - label2), by adding +1 when it is not needed. To avoid this, instead of
$longbr:
addiu $sp, $sp, -8
sw $ra, 0($sp)
bal $baltgt
lui $at, %hi($tgt - $baltgt)
$baltgt:
addiu $at, $at, %lo($tgt - $baltgt)
addu $at, $ra, $at
lw $ra, 0($sp)
jr $at
addiu $sp, $sp, 8
$fallthrough:
the following sequence is used for long branch:
$longbr:
addiu $sp, $sp, -8
sw $ra, 0($sp)
lui $at, %hi($tgt - $baltgt)
bal $baltgt
addiu $at, $at, %lo($tgt - $baltgt)
$baltgt:
addu $at, $ra, $at
lw $ra, 0($sp)
jr $at
addiu $sp, $sp, 8
$fallthrough:
Hi mseaborn, dsanders,
http://reviews.llvm.org/D3089
CHANGE SINCE LAST DIFF
http://reviews.llvm.org/D3089?vs=8305&id=8578#toc
Files:
lib/Target/Mips/Mips64InstrInfo.td
lib/Target/Mips/MipsAsmPrinter.cpp
lib/Target/Mips/MipsAsmPrinter.h
lib/Target/Mips/MipsInstrInfo.h
lib/Target/Mips/MipsInstrInfo.td
lib/Target/Mips/MipsLongBranch.cpp
lib/Target/Mips/MipsMCInstLower.cpp
lib/Target/Mips/MipsMCInstLower.h
test/CodeGen/Mips/longbranch.ll
test/CodeGen/Mips/micromips-long-branch.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3089.8.patch
Type: text/x-patch
Size: 519120 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140416/4af89aef/attachment.bin>
More information about the llvm-commits
mailing list