llvm.org GIT mirror llvm / 0776fac
Merging r249718: ------------------------------------------------------------------------ r249718 | ast | 2015-10-08 11:52:40 -0700 (Thu, 08 Oct 2015) | 16 lines [bpf] Do not expand UNDEF SDNode during insn selection lowering o Before this patch, BPF backend will expand UNDEF node to i64 constant 0. o For second pass of dag combiner, legalizer will run through each to-be-processed dag node. o If any new SDNode is generated and has an undef operand, dag combiner will put undef node, newly-generated constant-0 node, and any node which uses these nodes in the working list. o During this process, it is possible undef operand is generated again, and this will form an infinite loop for dag combiner pass2. o This patch allows UNDEF to be a legal type. Signed-off-by: Yonghong Song <yhs@plumgrid.com> Signed-off-by: Alexei Starovoitov <ast@plumgrid.com> ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_37@251177 91177308-0d34-0410-b5e6-96231b3b80d8 Alexei Starovoitov 3 years ago
4 changed file(s) with 69 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
129129 // tablegen selection should be handled here.
130130 switch (Opcode) {
131131 default: break;
132
133 case ISD::UNDEF: {
134 errs() << "BUG: "; Node->dump(CurDAG); errs() << '\n';
135 report_fatal_error("shouldn't see UNDEF during Select");
136 break;
137 }
138
139132 case ISD::INTRINSIC_W_CHAIN: {
140133 unsigned IntNo = cast(Node->getOperand(1))->getZExtValue();
141134 switch (IntNo) {
128128 setOperationAction(ISD::SUBC, MVT::i64, Expand);
129129 setOperationAction(ISD::SUBE, MVT::i64, Expand);
130130
131 // no UNDEF allowed
132 setOperationAction(ISD::UNDEF, MVT::i64, Expand);
133
134131 setOperationAction(ISD::ROTR, MVT::i64, Expand);
135132 setOperationAction(ISD::ROTL, MVT::i64, Expand);
136133 setOperationAction(ISD::SHL_PARTS, MVT::i64, Expand);
310310 ; CHECK-LABEL: bpf_prog2:
311311 ; CHECK: ldabs_h r0, r6.data + 12 # encoding: [0x28,0x00,0x00,0x00,0x0c,0x00,0x00,0x00]
312312 ; CHECK: ldabs_h r0, r6.data + 16 # encoding: [0x28,0x00,0x00,0x00,0x10,0x00,0x00,0x00]
313 ; CHECK-NOT: implicit
313 ; CHECK: implicit-def: R
314314 ; CHECK: ld_64 r1
315315 ; CHECK-NOT: ori
316316 ; CHECK: call 1 # encoding: [0x85,0x00,0x00,0x00,0x01,0x00,0x00,0x00]
0 ; RUN: llc < %s -march=bpf | FileCheck %s
1
2 %struct.bpf_map_def = type { i32, i32, i32, i32 }
3 %struct.__sk_buff = type opaque
4 %struct.routing_key_2 = type { [6 x i8] }
5
6 @routing = global %struct.bpf_map_def { i32 1, i32 6, i32 12, i32 1024 }, section "maps", align 4
7 @routing_miss_0 = global %struct.bpf_map_def { i32 1, i32 1, i32 12, i32 1 }, section "maps", align 4
8 @test1 = global %struct.bpf_map_def { i32 2, i32 4, i32 8, i32 1024 }, section "maps", align 4
9 @test1_miss_4 = global %struct.bpf_map_def { i32 2, i32 1, i32 8, i32 1 }, section "maps", align 4
10 @_license = global [4 x i8] c"GPL\00", section "license", align 1
11 @llvm.used = appending global [6 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @_license, i32 0, i32 0), i8* bitcast (i32 (%struct.__sk_buff*)* @ebpf_filter to i8*), i8* bitcast (%struct.bpf_map_def* @routing to i8*), i8* bitcast (%struct.bpf_map_def* @routing_miss_0 to i8*), i8* bitcast (%struct.bpf_map_def* @test1 to i8*), i8* bitcast (%struct.bpf_map_def* @test1_miss_4 to i8*)], section "llvm.metadata"
12
13 ; Function Attrs: nounwind uwtable
14 define i32 @ebpf_filter(%struct.__sk_buff* nocapture readnone %ebpf_packet) #0 section "socket1" {
15 %key = alloca %struct.routing_key_2, align 1
16 %1 = getelementptr inbounds %struct.routing_key_2, %struct.routing_key_2* %key, i64 0, i32 0, i64 0
17 ; CHECK: mov r1, 5
18 ; CHECK: stb -8(r10), r1
19 store i8 5, i8* %1, align 1
20 %2 = getelementptr inbounds %struct.routing_key_2, %struct.routing_key_2* %key, i64 0, i32 0, i64 1
21 ; CHECK: mov r1, 6
22 ; CHECK: stb -7(r10), r1
23 store i8 6, i8* %2, align 1
24 %3 = getelementptr inbounds %struct.routing_key_2, %struct.routing_key_2* %key, i64 0, i32 0, i64 2
25 ; CHECK: mov r1, 7
26 ; CHECK: stb -6(r10), r1
27 store i8 7, i8* %3, align 1
28 %4 = getelementptr inbounds %struct.routing_key_2, %struct.routing_key_2* %key, i64 0, i32 0, i64 3
29 ; CHECK: mov r1, 8
30 ; CHECK: stb -5(r10), r1
31 store i8 8, i8* %4, align 1
32 %5 = getelementptr inbounds %struct.routing_key_2, %struct.routing_key_2* %key, i64 0, i32 0, i64 4
33 ; CHECK: mov r1, 9
34 ; CHECK: stb -4(r10), r1
35 store i8 9, i8* %5, align 1
36 %6 = getelementptr inbounds %struct.routing_key_2, %struct.routing_key_2* %key, i64 0, i32 0, i64 5
37 ; CHECK: mov r1, 10
38 ; CHECK: stb -3(r10), r1
39 store i8 10, i8* %6, align 1
40 %7 = getelementptr inbounds %struct.routing_key_2, %struct.routing_key_2* %key, i64 1, i32 0, i64 0
41 ; CHECK: mov r1, r10
42 ; CHECK: addi r1, -2
43 ; CHECK: mov r2, 0
44 ; CHECK: sth 6(r1), r2
45 ; CHECK: sth 4(r1), r2
46 ; CHECK: sth 2(r1), r2
47 ; CHECK: sth 24(r10), r2
48 ; CHECK: sth 22(r10), r2
49 ; CHECK: sth 20(r10), r2
50 ; CHECK: sth 18(r10), r2
51 ; CHECK: sth 16(r10), r2
52 ; CHECK: sth 14(r10), r2
53 ; CHECK: sth 12(r10), r2
54 ; CHECK: sth 10(r10), r2
55 ; CHECK: sth 8(r10), r2
56 ; CHECK: sth 6(r10), r2
57 ; CHECK: sth -2(r10), r2
58 ; CHECK: sth 26(r10), r2
59 call void @llvm.memset.p0i8.i64(i8* %7, i8 0, i64 30, i32 1, i1 false)
60 %8 = call i32 (%struct.bpf_map_def*, %struct.routing_key_2*, ...) bitcast (i32 (...)* @bpf_map_lookup_elem to i32 (%struct.bpf_map_def*, %struct.routing_key_2*, ...)*)(%struct.bpf_map_def* nonnull @routing, %struct.routing_key_2* nonnull %key) #3
61 ret i32 undef
62 }
63
64 ; Function Attrs: nounwind argmemonly
65 declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) #1
66
67 declare i32 @bpf_map_lookup_elem(...) #2