|
| 1 | +; RUN: llc < %s -march=bpfel -mattr=+alu32 -verify-machineinstrs | FileCheck %s |
| 2 | +; RUN: llc < %s -march=bpfeb -mattr=+alu32 -verify-machineinstrs | FileCheck %s |
| 3 | +; |
| 4 | +; Source Code: |
| 5 | +; struct t { |
| 6 | +; unsigned char a; |
| 7 | +; unsigned char b; |
| 8 | +; unsigned char c; |
| 9 | +; }; |
| 10 | +; extern void foo(void *); |
| 11 | +; int test() { |
| 12 | +; struct t v = { |
| 13 | +; .b = 2, |
| 14 | +; }; |
| 15 | +; foo(&v); |
| 16 | +; return 0; |
| 17 | +; } |
| 18 | +; Compilation flag: |
| 19 | +; clang -target bpf -O2 -S -emit-llvm t.c |
| 20 | + |
| 21 | +%struct.t = type { i8, i8, i8 } |
| 22 | + |
| 23 | +@__const.test.v = private unnamed_addr constant %struct.t { i8 0, i8 2, i8 0 }, align 1 |
| 24 | + |
| 25 | +; Function Attrs: nounwind |
| 26 | +define dso_local i32 @test() local_unnamed_addr { |
| 27 | +entry: |
| 28 | + %v1 = alloca [3 x i8], align 1 |
| 29 | + %v1.sub = getelementptr inbounds [3 x i8], [3 x i8]* %v1, i64 0, i64 0 |
| 30 | + call void @llvm.lifetime.start.p0i8(i64 3, i8* nonnull %v1.sub) |
| 31 | + call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 1 dereferenceable(3) %v1.sub, i8* nonnull align 1 dereferenceable(3) getelementptr inbounds (%struct.t, %struct.t* @__const.test.v, i64 0, i32 0), i64 3, i1 false) |
| 32 | + call void @foo(i8* nonnull %v1.sub) |
| 33 | + call void @llvm.lifetime.end.p0i8(i64 3, i8* nonnull %v1.sub) |
| 34 | + ret i32 0 |
| 35 | +} |
| 36 | +; CHECK-NOT: w{{[0-9]+}} = *(u16 *) |
| 37 | +; CHECK-NOT: w{{[0-9]+}} = *(u8 *) |
| 38 | +; CHECK: *(u16 *)(r10 - 4) = w{{[0-9]+}} |
| 39 | +; CHECK: *(u8 *)(r10 - 2) = w{{[0-9]+}} |
| 40 | + |
| 41 | +; Function Attrs: argmemonly nounwind willreturn |
| 42 | +declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) |
| 43 | + |
| 44 | +; Function Attrs: argmemonly nounwind willreturn |
| 45 | +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) |
| 46 | + |
| 47 | +declare dso_local void @foo(i8*) local_unnamed_addr |
| 48 | + |
| 49 | +; Function Attrs: argmemonly nounwind willreturn |
| 50 | +declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) |
0 commit comments