2017-02-23 02:47:41 +08:00
|
|
|
# RUN: llc -O0 %s -o - -march=avr | FileCheck %s
|
2016-12-08 16:54:41 +08:00
|
|
|
|
|
|
|
# This test checks the expansion of the 16-bit 'LDDWRdPtrQ' pseudo instruction.
|
|
|
|
|
|
|
|
--- |
|
|
|
|
target triple = "avr--"
|
|
|
|
define void @test_lddwrdptrq() {
|
|
|
|
entry:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
...
|
|
|
|
|
|
|
|
---
|
|
|
|
name: test_lddwrdptrq
|
2017-02-06 04:25:34 +08:00
|
|
|
tracksRegLiveness: true
|
2016-12-08 16:54:41 +08:00
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
|
|
|
|
|
|
|
; CHECK-LABEL: test_lddwrdptrq
|
|
|
|
|
[AVR] Disallow the LDDWRdPtrQ instruction with Z as the destination
This is an AVR-specific workaround for a limitation of the register
allocator that only exposes itself on targets with high register
contention like AVR, which only has three pointer registers.
The three pointer registers are X, Y, and Z.
In most nontrivial functions, Y is reserved for the frame pointer,
as per the calling convention. This leaves X and Z. Some instructions,
such as LPM ("load program memory"), are only defined for the Z
register. Sometimes this just leaves X.
When the backend generates a LDDWRdPtrQ instruction with Z as the
destination pointer, it usually trips up the register allocator
with this error message:
LLVM ERROR: ran out of registers during register allocation
This patch is a hacky workaround. We ban the LDDWRdPtrQ instruction
from ever using the Z register as an operand. This gives the
register allocator a bit more space to allocate, fixing the
regalloc exhaustion error.
Here is a description from the patch author Peter Nimmervoll
As far as I understand the problem occurs when LDDWRdPtrQ uses
the ptrdispregs register class as target register. This should work, but
the allocator can't deal with this for some reason. So from my testing,
it seams like (and I might be totally wrong on this) the allocator reserves
the Z register for the ICALL instruction and then the register class
ptrdispregs only has 1 register left and we can't use Y for source and
destination. Removing the Z register from DREGS fixes the problem but
removing Y register does not.
More information about the bug can be found on the avr-rust issue
tracker at https://github.com/avr-rust/rust/issues/37.
A bug has raised to track the removal of this workaround and a proper
fix; PR39553 at https://bugs.llvm.org/show_bug.cgi?id=39553.
Patch by Peter Nimmervoll
llvm-svn: 346114
2018-11-05 13:00:44 +08:00
|
|
|
; CHECK: ldd r28, Z+10
|
|
|
|
; CHECK-NEXT: ldd r29, Z+11
|
2016-12-08 16:54:41 +08:00
|
|
|
|
[AVR] Disallow the LDDWRdPtrQ instruction with Z as the destination
This is an AVR-specific workaround for a limitation of the register
allocator that only exposes itself on targets with high register
contention like AVR, which only has three pointer registers.
The three pointer registers are X, Y, and Z.
In most nontrivial functions, Y is reserved for the frame pointer,
as per the calling convention. This leaves X and Z. Some instructions,
such as LPM ("load program memory"), are only defined for the Z
register. Sometimes this just leaves X.
When the backend generates a LDDWRdPtrQ instruction with Z as the
destination pointer, it usually trips up the register allocator
with this error message:
LLVM ERROR: ran out of registers during register allocation
This patch is a hacky workaround. We ban the LDDWRdPtrQ instruction
from ever using the Z register as an operand. This gives the
register allocator a bit more space to allocate, fixing the
regalloc exhaustion error.
Here is a description from the patch author Peter Nimmervoll
As far as I understand the problem occurs when LDDWRdPtrQ uses
the ptrdispregs register class as target register. This should work, but
the allocator can't deal with this for some reason. So from my testing,
it seams like (and I might be totally wrong on this) the allocator reserves
the Z register for the ICALL instruction and then the register class
ptrdispregs only has 1 register left and we can't use Y for source and
destination. Removing the Z register from DREGS fixes the problem but
removing Y register does not.
More information about the bug can be found on the avr-rust issue
tracker at https://github.com/avr-rust/rust/issues/37.
A bug has raised to track the removal of this workaround and a proper
fix; PR39553 at https://bugs.llvm.org/show_bug.cgi?id=39553.
Patch by Peter Nimmervoll
llvm-svn: 346114
2018-11-05 13:00:44 +08:00
|
|
|
early-clobber $r29r28 = LDDWRdPtrQ undef $r31r30, 10
|
2016-12-08 16:54:41 +08:00
|
|
|
...
|