1; RUN: opt -debug-pass=Executions -phi-values -memcpyopt -instcombine -disable-output < %s 2>&1 | FileCheck %s 2 3; Check that phi values is not run when it's not already available, and that 4; basicaa is freed after a pass that preserves CFG. 5 6; CHECK: Executing Pass 'Phi Values Analysis' 7; CHECK: Executing Pass 'Basic Alias Analysis (stateless AA impl)' 8; CHECK: Executing Pass 'Memory Dependence Analysis' 9; CHECK: Executing Pass 'MemCpy Optimization' 10; CHECK-DAG: Freeing Pass 'MemCpy Optimization' 11; CHECK-DAG: Freeing Pass 'Phi Values Analysis' 12; CHECK-DAG: Freeing Pass 'Memory Dependence Analysis' 13; CHECK-DAG: Freeing Pass 'Basic Alias Analysis (stateless AA impl)' 14; CHECK-NOT: Executing Pass 'Phi Values Analysis' 15; CHECK: Executing Pass 'Basic Alias Analysis (stateless AA impl)' 16; CHECK: Executing Pass 'Combine redundant instructions' 17 18declare void @otherfn([4 x i8]*) 19declare i32 @__gxx_personality_v0(...) 20 21; This function is one where if we didn't free basicaa after memcpyopt then the 22; usage of basicaa in instcombine would cause a segfault due to stale phi-values 23; results being used. 24define void @fn(i8* %this, i64* %ptr) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { 25entry: 26 %arr = alloca [4 x i8], align 8 27 %gep1 = getelementptr inbounds [4 x i8], [4 x i8]* %arr, i64 0, i32 0 28 br i1 undef, label %then, label %if 29 30if: 31 br label %then 32 33then: 34 %phi = phi i64* [ %ptr, %if ], [ null, %entry ] 35 store i8 1, i8* %gep1, align 8 36 %load = load i64, i64* %phi, align 8 37 %gep2 = getelementptr inbounds i8, i8* undef, i64 %load 38 %gep3 = getelementptr inbounds i8, i8* %gep2, i64 40 39 invoke i32 undef(i8* undef) 40 to label %invoke unwind label %lpad 41 42invoke: 43 unreachable 44 45lpad: 46 landingpad { i8*, i32 } 47 catch i8* null 48 call void @otherfn([4 x i8]* nonnull %arr) 49 unreachable 50} 51