summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2018-02-15 17:06:45 +0000
committerYonghong Song <yhs@fb.com>2018-02-15 17:06:45 +0000
commit920df52a93099860be81e7087773e96e99a49616 (patch)
tree6c50106f6796693f8b2ee951b37f2abcf0b01b86 /llvm/test
parent8a9eff6b873ab29b0432754bbed9c1c4c7e51156 (diff)
downloadbcm5719-llvm-920df52a93099860be81e7087773e96e99a49616.tar.gz
bcm5719-llvm-920df52a93099860be81e7087773e96e99a49616.zip
bpf: fix a bug in dag2dag optimization for loads from readonly section
The reference '&' is missing in the function parameter. If there are back-to-back optimizations in terms of dag node list like below: t29: i64,ch = load<LD4[bitcast (%struct.test_t* @test.t to i8*)+12](dereferenceable), zext from i32> t3, t43, undef:i64 t34: i64,ch = load<LD4[bitcast (%struct.test_t* @test.t to i8*)](dereferenceable), zext from i32> t3, t41, undef:i64 The bug will trigger a segfault for the added test case remove_truncate_5.ll: LLVMSymbolizer: error reading file: No such file or directory #0 0x000000000241c4d9 (llc+0x241c4d9) #1 0x000000000241c56a (llc+0x241c56a) #2 0x000000000241aa50 (llc+0x241aa50) ... #22 0x0000000000fd5edf (llc+0xfd5edf) #23 0x00007f0fe03bec05 __libc_start_main (/lib64/libc.so.6+0x21c05) #24 0x0000000000fd3e69 (llc+0xfd3e69) ... Segmentation fault Signed-off-by: Yonghong Song <yhs@fb.com> llvm-svn: 325267
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/CodeGen/BPF/remove_truncate_5.ll53
1 files changed, 53 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/BPF/remove_truncate_5.ll b/llvm/test/CodeGen/BPF/remove_truncate_5.ll
new file mode 100644
index 00000000000..294f93dab9d
--- /dev/null
+++ b/llvm/test/CodeGen/BPF/remove_truncate_5.ll
@@ -0,0 +1,53 @@
+; RUN: llc < %s -march=bpfel | FileCheck -check-prefixes=CHECK %s
+
+; Source code:
+; struct test_t {
+; int a;
+; char b;
+; int c;
+; char d;
+; };
+; void foo(void *);
+; void test() {
+; struct test_t t = {.a = 5};
+; foo(&t);
+; }
+
+%struct.test_t = type { i32, i8, i32, i8 }
+
+@test.t = private unnamed_addr constant %struct.test_t { i32 5, i8 0, i32 0, i8 0 }, align 4
+
+; Function Attrs: nounwind
+define dso_local void @test() local_unnamed_addr #0 {
+; CHECK-LABEL: test:
+ %1 = alloca %struct.test_t, align 4
+ %2 = bitcast %struct.test_t* %1 to i8*
+ call void @llvm.lifetime.start.p0i8(i64 16, i8* nonnull %2) #3
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 4 %2, i8* align 4 bitcast (%struct.test_t* @test.t to i8*), i64 16, i1 false)
+; CHECK: r1 = 0
+; CHECK: r1 <<= 32
+; CHECK: r2 = r1
+; CHECK: r2 |= 0
+; CHECK: *(u64 *)(r10 - 8) = r2
+; CHECK: r1 |= 5
+; CHECK: *(u64 *)(r10 - 16) = r1
+ call void @foo(i8* nonnull %2) #3
+; CHECK: call foo
+ call void @llvm.lifetime.end.p0i8(i64 16, i8* nonnull %2) #3
+ ret void
+}
+
+; Function Attrs: argmemonly nounwind
+declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
+
+; Function Attrs: argmemonly nounwind
+declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i1) #1
+
+declare dso_local void @foo(i8*) local_unnamed_addr
+
+; Function Attrs: argmemonly nounwind
+declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
+
+attributes #0 = { nounwind }
+attributes #1 = { argmemonly nounwind }
+attributes #3 = { nounwind }
OpenPOWER on IntegriCloud