1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00
llvm-mirror/test/CodeGen/BPF/remove_truncate_5.ll
Yonghong Song 419f317716 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
2018-02-15 17:06:45 +00:00

54 lines
1.5 KiB
LLVM

; 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 }