diff options
| author | Akira Hatanaka <ahatanaka@mips.com> | 2013-09-28 00:12:32 +0000 |
|---|---|---|
| committer | Akira Hatanaka <ahatanaka@mips.com> | 2013-09-28 00:12:32 +0000 |
| commit | af4211ad940025c2a1eb8b25d20196c1c1362d88 (patch) | |
| tree | cbe47d337f4e356f0062dd0291424b1aee61c2db /llvm/test/CodeGen | |
| parent | d6ffae91d535402b240128467bbcc5b09bd948aa (diff) | |
| download | bcm5719-llvm-af4211ad940025c2a1eb8b25d20196c1c1362d88.tar.gz bcm5719-llvm-af4211ad940025c2a1eb8b25d20196c1c1362d88.zip | |
[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.
llvm-svn: 191591
Diffstat (limited to 'llvm/test/CodeGen')
| -rw-r--r-- | llvm/test/CodeGen/Mips/brdelayslot.ll | 11 | ||||
| -rw-r--r-- | llvm/test/CodeGen/Mips/i64arg.ll | 10 | ||||
| -rw-r--r-- | llvm/test/CodeGen/Mips/largeimmprinting.ll | 4 | ||||
| -rw-r--r-- | llvm/test/CodeGen/Mips/lazy-binding.ll | 41 |
4 files changed, 57 insertions, 9 deletions
diff --git a/llvm/test/CodeGen/Mips/brdelayslot.ll b/llvm/test/CodeGen/Mips/brdelayslot.ll index 869ecd9a839..68341c1ba25 100644 --- a/llvm/test/CodeGen/Mips/brdelayslot.ll +++ b/llvm/test/CodeGen/Mips/brdelayslot.ll @@ -160,7 +160,14 @@ for.end: ; preds = %for.body, %entry ; ; SUCCBB-LABEL: succbbs_br1: ; SUCCBB: beqz ${{[0-9]+}}, $BB -; SUCCBB-NEXT: lw $25, %call16(foo100) +; SUCCBB-NEXT: lw ${{[0-9]+}}, %got(foo101)(${{[0-9]+}}) + +define internal fastcc void @foo101() { +entry: + tail call void @foo100() + tail call void @foo100() + ret void +} define void @succbbs_br1(i32 %a) { entry: @@ -168,7 +175,7 @@ entry: br i1 %tobool, label %if.end, label %if.then if.then: ; preds = %entry - tail call void @foo100() #1 + tail call fastcc void @foo101() br label %if.end if.end: ; preds = %entry, %if.then diff --git a/llvm/test/CodeGen/Mips/i64arg.ll b/llvm/test/CodeGen/Mips/i64arg.ll index 0b16424d94c..b038ad5bf74 100644 --- a/llvm/test/CodeGen/Mips/i64arg.ll +++ b/llvm/test/CodeGen/Mips/i64arg.ll @@ -9,11 +9,11 @@ entry: ; CHECK: lw $25, %call16(ff1) ; CHECK: jalr tail call void @ff1(i32 %i, i64 1085102592623924856) nounwind -; CHECK: lw $25, %call16(ff2) -; CHECK: lw $[[R2:[0-9]+]], 80($sp) -; CHECK: lw $[[R3:[0-9]+]], 84($sp) -; CHECK: move $4, $[[R2]] -; CHECK: move $5, $[[R3]] +; CHECK-DAG: lw $25, %call16(ff2) +; CHECK-DAG: lw $[[R2:[0-9]+]], 80($sp) +; CHECK-DAG: lw $[[R3:[0-9]+]], 84($sp) +; CHECK-DAG: move $4, $[[R2]] +; CHECK-DAG: move $5, $[[R3]] ; CHECK: jalr $25 tail call void @ff2(i64 %ll, double 3.000000e+00) nounwind %sub = add nsw i32 %i, -1 diff --git a/llvm/test/CodeGen/Mips/largeimmprinting.ll b/llvm/test/CodeGen/Mips/largeimmprinting.ll index 1e96346d1dd..09fee3d9063 100644 --- a/llvm/test/CodeGen/Mips/largeimmprinting.ll +++ b/llvm/test/CodeGen/Mips/largeimmprinting.ll @@ -18,11 +18,11 @@ entry: ; 64: dsll $[[R0]], $[[R0]], 48 ; 64: daddiu $[[R0]], $[[R0]], -1 ; 64: dsll $[[R0]], $[[R0]], 16 -; 64: daddiu $[[R0]], $[[R0]], -48 +; 64: daddiu $[[R0]], $[[R0]], -32 ; 64: daddu $sp, $sp, $[[R0]] ; 64: lui $[[R1:[0-9]+]], 1 ; 64: daddu $[[R1]], $sp, $[[R1]] -; 64: sd $ra, 40($[[R1]]) +; 64: sd $ra, 24($[[R1]]) %agg.tmp = alloca %struct.S1, align 1 %tmp = getelementptr inbounds %struct.S1* %agg.tmp, i32 0, i32 0, i32 0 diff --git a/llvm/test/CodeGen/Mips/lazy-binding.ll b/llvm/test/CodeGen/Mips/lazy-binding.ll new file mode 100644 index 00000000000..839155adad9 --- /dev/null +++ b/llvm/test/CodeGen/Mips/lazy-binding.ll @@ -0,0 +1,41 @@ +; RUN: llc -march=mipsel < %s | FileCheck %s + +; CHECK-LABEL: foo6: +; CHECK: %while.body +; CHECK: lw $25, %call16(foo2)(${{[0-9]+}}) +; CHECK: jalr $25 +; CHECK: %while.end + +define void @foo6(i32 %n) { +entry: + %tobool1 = icmp eq i32 %n, 0 + br i1 %tobool1, label %while.end, label %while.body + +while.body: ; preds = %entry, %while.body + %n.addr.02 = phi i32 [ %dec, %while.body ], [ %n, %entry ] + %dec = add nsw i32 %n.addr.02, -1 + tail call void @foo2() + %tobool = icmp eq i32 %dec, 0 + br i1 %tobool, label %while.end, label %while.body + +while.end: ; preds = %while.body, %entry + ret void +} + +declare void @foo2() + +; CHECK-LABEL: foo1: +; CHECK: lw $25, %call16(foo2)(${{[0-9]+}}) +; CHECK: jalr $25 +; CHECK: lw $25, %call16(foo2)(${{[0-9]+}}) +; CHECK: jalr $25 +; CHECK: lw $25, %call16(foo2)(${{[0-9]+}}) +; CHECK: jalr $25 + +define void @foo1() { +entry: + tail call void @foo2() + tail call void @foo2() + tail call void @foo2() + ret void +} |

