Skip to content
This repository was archived by the owner on Sep 2, 2018. It is now read-only.

Commit b705c4b

Browse files
author
Dylan McKay
committed
[AVR] Add test for issue #1
1 parent 2597ce5 commit b705c4b

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
; RUN: llc < %s -march=avr | FileCheck %s
2+
3+
; This tests how LLVM handles IR which puts very high
4+
; presure on the PTRREGS class for the register allocator.
5+
;
6+
; This causes a problem because we only have one small register
7+
; class for loading and storing from pointers - 'PTRREGS'.
8+
; One of these registers is also used for the frame pointer, meaning
9+
; that we only ever have two registers available for these operations.
10+
;
11+
; There is an existing bug filed for this issue - PR14879.
12+
;
13+
; LLVM should be able to handle this elegantly, because PTRREGS is a
14+
; subset of DREGS, so we should be able to do cross-class copies in
15+
; order to complete register allocation.
16+
;
17+
; The specific failure:
18+
; LLVM ERROR: ran out of registers during register allocation
19+
;
20+
; It has been assembled from the following c code:
21+
;
22+
; struct ss
23+
; {
24+
; int a;
25+
; int b;
26+
; int c;
27+
; };
28+
;
29+
; void loop(struct ss *x, struct ss **y, int z)
30+
; {
31+
; int i;
32+
; for (i=0; i<z; ++i)
33+
; {
34+
; x->c += y[i]->b;
35+
; }
36+
; }
37+
38+
%struct.ss = type { i16, i16, i16 }
39+
40+
; CHECK-LABEL: loop
41+
define void @loop(%struct.ss* %x, %struct.ss** %y, i16 %z) {
42+
entry:
43+
%x.addr = alloca %struct.ss*, align 2
44+
%y.addr = alloca %struct.ss**, align 2
45+
%z.addr = alloca i16, align 2
46+
%i = alloca i16, align 2
47+
store %struct.ss* %x, %struct.ss** %x.addr, align 2
48+
store %struct.ss** %y, %struct.ss*** %y.addr, align 2
49+
store i16 %z, i16* %z.addr, align 2
50+
store i16 0, i16* %i, align 2
51+
br label %for.cond
52+
53+
for.cond: ; preds = %for.inc, %entry
54+
%0 = load i16, i16* %i, align 2
55+
%1 = load i16, i16* %z.addr, align 2
56+
%cmp = icmp slt i16 %0, %1
57+
br i1 %cmp, label %for.body, label %for.end
58+
59+
for.body: ; preds = %for.cond
60+
%2 = load i16, i16* %i, align 2
61+
%3 = load %struct.ss**, %struct.ss*** %y.addr, align 2
62+
%arrayidx = getelementptr inbounds %struct.ss*, %struct.ss** %3, i16 %2
63+
%4 = load %struct.ss*, %struct.ss** %arrayidx, align 2
64+
%b = getelementptr inbounds %struct.ss, %struct.ss* %4, i32 0, i32 1
65+
%5 = load i16, i16* %b, align 2
66+
%6 = load %struct.ss*, %struct.ss** %x.addr, align 2
67+
%c = getelementptr inbounds %struct.ss, %struct.ss* %6, i32 0, i32 2
68+
%7 = load i16, i16* %c, align 2
69+
%add = add nsw i16 %7, %5
70+
store i16 %add, i16* %c, align 2
71+
br label %for.inc
72+
73+
for.inc: ; preds = %for.body
74+
%8 = load i16, i16* %i, align 2
75+
%inc = add nsw i16 %8, 1
76+
store i16 %inc, i16* %i, align 2
77+
br label %for.cond
78+
79+
for.end: ; preds = %for.cond
80+
ret void
81+
}
82+

0 commit comments

Comments
 (0)