brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · 81306c6 Raw
90 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -passes=dse -S %s | FileCheck %s3 4declare void @use_pointer(ptr)5 6; Out-of-bounds stores can be considered killing any other stores to the same7; object in the same BB, because they are UB and guaranteed to execute. Note8; that cases in which the BB is exited through unwinding are handled separately9; by DSE and the unwinding call will be considered as clobber.10define i32 @test_out_of_bounds_store_local(i1 %c) {11; CHECK-LABEL: @test_out_of_bounds_store_local(12; CHECK-NEXT:    [[D:%.*]] = alloca [1 x i32], align 413; CHECK-NEXT:    [[ARRAYIDX_1:%.*]] = getelementptr inbounds [1 x i32], ptr [[D]], i64 0, i64 114; CHECK-NEXT:    store i32 20, ptr [[ARRAYIDX_1]], align 415; CHECK-NEXT:    call void @use_pointer(ptr [[D]])16; CHECK-NEXT:    ret i32 017;18  %d = alloca [1 x i32], align 419  store i32 10, ptr %d, align 420  %arrayidx.1 = getelementptr inbounds [1 x i32], ptr %d, i64 0, i64 121  store i32 20, ptr %arrayidx.1, align 422  call void @use_pointer(ptr %d)23  ret i32 024}25 26; Similar to @test_out_of_bounds_store_local, but with multiple in-bounds27; stores to a larger object, followed by an out-of-bounds store.28; FIXME: the 2 inbounds stores could be removed by applying the same29; reasoning as for @test_out_of_bounds_store_local.30define i32 @test_out_of_bounds_store_local_larger_object(i1 %c) {31; CHECK-LABEL: @test_out_of_bounds_store_local_larger_object(32; CHECK-NEXT:    [[D:%.*]] = alloca [2 x i32], align 433; CHECK-NEXT:    store i32 10, ptr [[D]], align 434; CHECK-NEXT:    [[ARRAYIDX_1:%.*]] = getelementptr inbounds [2 x i32], ptr [[D]], i64 0, i64 135; CHECK-NEXT:    store i32 20, ptr [[ARRAYIDX_1]], align 436; CHECK-NEXT:    [[ARRAYIDX_2:%.*]] = getelementptr inbounds [2 x i32], ptr [[D]], i64 0, i64 237; CHECK-NEXT:    store i32 30, ptr [[ARRAYIDX_2]], align 438; CHECK-NEXT:    call void @use_pointer(ptr [[D]])39; CHECK-NEXT:    ret i32 040;41  %d = alloca [2 x i32], align 442  store i32 10, ptr %d, align 443  %arrayidx.1 = getelementptr inbounds [2 x i32], ptr %d, i64 0, i64 144  store i32 20, ptr %arrayidx.1, align 445  %arrayidx.2 = getelementptr inbounds [2 x i32], ptr %d, i64 0, i64 246  store i32 30, ptr %arrayidx.2, align 447  call void @use_pointer(ptr %d)48  ret i32 049}50 51; Make sure that out-of-bound stores are not considered killing other stores to52; the same underlying object, if they are in different basic blocks. The53; out-of-bounds store may not be executed.54;55; Test case from PR48279. FIXME.56define i32 @test_out_of_bounds_store_nonlocal(i1 %c) {57; CHECK-LABEL: @test_out_of_bounds_store_nonlocal(58; CHECK-NEXT:    [[D:%.*]] = alloca [1 x i32], align 459; CHECK-NEXT:    br label [[FOR_BODY:%.*]]60; CHECK:       for.body:61; CHECK-NEXT:    store i32 10, ptr [[D]], align 462; CHECK-NEXT:    br label [[FOR_INC:%.*]]63; CHECK:       for.inc:64; CHECK-NEXT:    br i1 [[C:%.*]], label [[FOR_BODY_1:%.*]], label [[FOR_END:%.*]]65; CHECK:       for.body.1:66; CHECK-NEXT:    ret i32 167; CHECK:       for.end:68; CHECK-NEXT:    call void @use_pointer(ptr [[D]])69; CHECK-NEXT:    ret i32 070;71  %d = alloca [1 x i32], align 472  br label %for.body73 74for.body:                                         ; preds = %for.cond75  store i32 10, ptr %d, align 476  br label %for.inc77 78for.inc:                                          ; preds = %for.body79  br i1 %c, label %for.body.1, label %for.end80 81for.body.1:                                       ; preds = %for.inc82  %arrayidx.1 = getelementptr inbounds [1 x i32], ptr %d, i64 0, i64 183  store i32 20, ptr %arrayidx.1, align 484  ret i32 185 86for.end:                                          ; preds = %for.inc87  call void @use_pointer(ptr %d)88  ret i32 089}90