1 ; RUN: llvm-as -f %s -o - | llc
4 ;; From: test/Programs/SingleSource/richards_benchmark.c
5 ;; Function: struct task *handlerfn(struct packet *pkt)
7 ;; Error: PreSelection puts the arguments of the Phi just before
8 ;; the Phi instead of in predecessor blocks. This later
9 ;; causes llc to produces an invalid register <NULL VALUE>
10 ;; for the phi arguments.
12 ;; PreSelection Output:
13 ;; *** LLVM code after pre-selection for function handlerfn:
16 ;; %struct..task* %handlerfn(%struct..packet*) {
17 ;; ; <label>:0 ; No predecessors!
18 ;; setne %struct..packet* %0, null ; <bool>:0 [#uses=1]
19 ;; br bool %0, label %1, label %2
21 ;; ; <label>:1 ; preds = %0
24 ;; ; <label>:2 ; preds = %0, %1
25 ;; %addrOfGlobal = getelementptr int* %v2, long 0 ; <int*> [#uses=1]
26 ;; %addrOfGlobal1 = getelementptr int* %v1, long 0 ; <int*> [#uses=1]
27 ;; phi int* [ %addrOfGlobal, %1 ], [ %addrOfGlobal1, %0 ] ; <int*>:0 [#uses=1]
28 ;; cast int* %0 to %struct..packet* ; <%struct..packet*>:1 [#uses=1]
29 ;; call void %append( %struct..packet* %0, %struct..packet* %1 )
30 ;; ret %struct..task* null
32 ;; llc: ../../../include/llvm/CodeGen/MachineInstr.h:294: int MachineOperand::getAllocatedRegNum() const: Assertion `hasAllocatedReg()' failed.
36 target endian = little
37 target pointersize = 32
38 %struct..packet = type { %struct..packet*, int, int, int, [4 x sbyte] }
39 %struct..task = type { %struct..task*, int, int, %struct..packet*, int, %struct..task* (%struct..packet*)*, int, int }
40 %v1 = external global int
41 %v2 = external global int
43 implementation ; Functions:
45 %struct..task* %handlerfn(%struct..packet* %pkt.2) {
46 entry: ; No predecessors!
47 %tmp.1 = setne %struct..packet* %pkt.2, null
48 br bool %tmp.1, label %cond_false, label %cond_continue
50 cond_false: ; preds = %entry
51 br label %cond_continue
53 cond_continue: ; preds = %entry, %cond_false
54 %mem_tmp.0 = phi int* [ %v2, %cond_false ], [ %v1, %entry ]
55 %tmp.12 = cast int* %mem_tmp.0 to %struct..packet*
56 call void %append( %struct..packet* %pkt.2, %struct..packet* %tmp.12 )
57 ret %struct..task* null
60 declare void %append(%struct..packet*, %struct..packet*)