[mips] Make sure loads from lazy-binding entries do not get CSE'd or hoisted out
authorAkira Hatanaka <ahatanaka@mips.com>
Sat, 28 Sep 2013 00:12:32 +0000 (00:12 +0000)
committerAkira Hatanaka <ahatanaka@mips.com>
Sat, 28 Sep 2013 00:12:32 +0000 (00:12 +0000)
commit6ff59a16a05d43fdda587ce600b5b42a63cf3d33
tree4a9693eab502c4dbff8219cf9e17ea009803e7e6
parente5f32cf3207da58359a6e3aeeb5b01205645f710
[mips] Make sure loads from lazy-binding entries do not get CSE'd or hoisted out
of loops.

Previously, two consecutive calls to function "func" would result in the
following sequence of instructions:

1. load $16, %got(func)($gp) // load address of lazy-binding stub.
2. move $25, $16
3. jalr $25                  // jump to lazy-binding stub.
4. nop
5. move $25, $16
6. jalr $25                  // jump to lazy-binding stub again.

With this patch, the second call directly jumps to func's address, bypassing
the lazy-binding resolution routine:

1. load $25, %got(func)($gp) // load address of lazy-binding stub.
2. jalr $25                  // jump to lazy-binding stub.
3. nop
4. load $25, %got(func)($gp) // load resolved address of func.
5. jalr $25                  // directly jump to func.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191591 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/Mips/Mips16ISelLowering.cpp
lib/Target/Mips/MipsDelaySlotFiller.cpp
lib/Target/Mips/MipsISelLowering.cpp
lib/Target/Mips/MipsISelLowering.h
test/CodeGen/Mips/brdelayslot.ll
test/CodeGen/Mips/i64arg.ll
test/CodeGen/Mips/largeimmprinting.ll
test/CodeGen/Mips/lazy-binding.ll [new file with mode: 0644]