51 lines · plain
1; XFAIL: *2 3; RUN: opt -S -passes=dse < %s | FileCheck %s4 5; We DSE stack alloc'ed and byval locations, in the presence of fences.6; Fence does not make an otherwise thread local store visible.7; Right now the DSE in presence of fence is only done in end blocks (with no successors),8; but the same logic applies to other basic blocks as well.9; The store to %addr.i can be removed since it is a byval attribute10define void @test3(ptr byval(i32) %addr.i) {11; CHECK-LABEL: @test312; CHECK-NOT: store13; CHECK: fence14; CHECK: ret15 store i32 5, ptr %addr.i, align 416 fence release17 ret void18}19 20declare void @foo(ptr nocapture %p)21 22declare noalias ptr @malloc(i32)23 24; DSE of stores in locations allocated through library calls.25define void @test_nocapture() {26; CHECK-LABEL: @test_nocapture27; CHECK: malloc28; CHECK: foo29; CHECK-NOT: store30; CHECK: fence31 %m = call ptr @malloc(i32 24)32 call void @foo(ptr %m)33 store i8 4, ptr %m34 fence release35 ret void36}37 38 39; This is a full fence, but it does not make a thread local store visible.40; We can DSE the store in presence of the fence.41define void @fence_seq_cst() {42; CHECK-LABEL: @fence_seq_cst43; CHECK-NEXT: fence seq_cst44; CHECK-NEXT: ret void45 %P1 = alloca i3246 store i32 0, ptr %P1, align 447 fence seq_cst48 store i32 4, ptr %P1, align 449 ret void50}51