brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 680e1df Raw
73 lines · plain
1; RUN: opt -debug-pass-manager -aa-pipeline=basic-aa -passes='require<phi-values>,memcpyopt,instcombine' -disable-output < %s 2>&1 | FileCheck %s2 3; Check that phi values is not run when it's not already available, and that4; basicaa is not freed after a pass that preserves CFG, as it preserves CFG.5 6; CHECK-DAG: Running analysis: PhiValuesAnalysis7; CHECK-DAG: Running analysis: BasicAA8; CHECK-DAG: Running analysis: MemorySSA9; CHECK: Running pass: MemCpyOptPass10; CHECK-NOT: Invalidating analysis11; CHECK: Running pass: InstCombinePass12 13target datalayout = "p:8:8-n8"14 15declare void @otherfn(ptr)16declare i32 @__gxx_personality_v0(...)17declare void @llvm.lifetime.end.p0(ptr nocapture)18@c = external global ptr, align 119 20; This function is one where if we didn't free basicaa after memcpyopt then the21; usage of basicaa in instcombine would cause a segfault due to stale phi-values22; results being used.23define void @fn(ptr %this, ptr %ptr, i1 %arg) personality ptr @__gxx_personality_v0 {24entry:25  %arr = alloca [4 x i8], align 826  br i1 %arg, label %then, label %if27 28if:29  br label %then30 31then:32  %phi = phi ptr [ %ptr, %if ], [ null, %entry ]33  store i8 1, ptr %arr, align 834  %load = load i64, ptr %phi, align 835  %gep2 = getelementptr inbounds i8, ptr undef, i64 %load36  %gep3 = getelementptr inbounds i8, ptr %gep2, i64 4037  invoke i32 undef(ptr undef)38     to label %invoke unwind label %lpad39 40invoke:41  unreachable42 43lpad:44  landingpad { ptr, i32 }45     catch ptr null46  call void @otherfn(ptr nonnull %arr)47  unreachable48}49 50; When running instcombine after memdep, the basicaa used by instcombine uses51; the phivalues that memdep used. This would then cause a segfault due to52; instcombine deleting a phi whose values had been cached.53define void @fn2(i1 %arg) {54entry:55  %a = alloca i8, align 156  %0 = load ptr, ptr @c, align 157  br label %for.cond58 59for.cond:                                         ; preds = %for.body, %entry60  %d.0 = phi ptr [ %0, %entry ], [ null, %for.body ]61  br i1 %arg, label %for.body, label %for.cond.cleanup62 63for.body:                                         ; preds = %for.cond64  store volatile i8 undef, ptr %a, align 165  br label %for.cond66 67for.cond.cleanup:                                 ; preds = %for.cond68  call void @llvm.lifetime.end.p0(ptr %a)69  %1 = load ptr, ptr %d.0, align 170  store ptr %1, ptr @c, align 171  ret void72}73