|
1 |
| -; RUN: opt -debug-pass=Executions -phi-values -memcpyopt -instcombine -disable-output < %s 2>&1 | FileCheck %s |
| 1 | +; RUN: opt -debug-pass=Executions -phi-values -memcpyopt -instcombine -disable-output < %s 2>&1 | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-MEMCPY |
| 2 | +; RUN: opt -debug-pass=Executions -memdep -instcombine -disable-output < %s 2>&1 | FileCheck %s -check-prefix=CHECK |
2 | 3 |
|
3 | 4 | ; Check that phi values is not run when it's not already available, and that
|
4 | 5 | ; basicaa is freed after a pass that preserves CFG.
|
5 | 6 |
|
6 | 7 | ; CHECK: Executing Pass 'Phi Values Analysis'
|
7 | 8 | ; CHECK: Executing Pass 'Basic Alias Analysis (stateless AA impl)'
|
8 | 9 | ; CHECK: Executing Pass 'Memory Dependence Analysis'
|
9 |
| -; CHECK: Executing Pass 'MemCpy Optimization' |
10 |
| -; CHECK-DAG: Freeing Pass 'MemCpy Optimization' |
| 10 | +; CHECK-MEMCPY: Executing Pass 'MemCpy Optimization' |
| 11 | +; CHECK-MEMCPY-DAG: Freeing Pass 'MemCpy Optimization' |
11 | 12 | ; CHECK-DAG: Freeing Pass 'Phi Values Analysis'
|
12 | 13 | ; CHECK-DAG: Freeing Pass 'Memory Dependence Analysis'
|
13 | 14 | ; CHECK-DAG: Freeing Pass 'Basic Alias Analysis (stateless AA impl)'
|
14 | 15 | ; CHECK-NOT: Executing Pass 'Phi Values Analysis'
|
15 |
| -; CHECK: Executing Pass 'Basic Alias Analysis (stateless AA impl)' |
| 16 | +; CHECK-MEMCPY: Executing Pass 'Basic Alias Analysis (stateless AA impl)' |
16 | 17 | ; CHECK: Executing Pass 'Combine redundant instructions'
|
17 | 18 |
|
| 19 | +target datalayout = "p:8:8-n8" |
| 20 | + |
18 | 21 | declare void @otherfn([4 x i8]*)
|
19 | 22 | declare i32 @__gxx_personality_v0(...)
|
| 23 | +declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) |
| 24 | +@c = external global i8*, align 1 |
20 | 25 |
|
21 | 26 | ; This function is one where if we didn't free basicaa after memcpyopt then the
|
22 | 27 | ; usage of basicaa in instcombine would cause a segfault due to stale phi-values
|
|
48 | 53 | call void @otherfn([4 x i8]* nonnull %arr)
|
49 | 54 | unreachable
|
50 | 55 | }
|
| 56 | + |
| 57 | +; When running instcombine after memdep, the basicaa used by instcombine uses |
| 58 | +; the phivalues that memdep used. This would then cause a segfault due to |
| 59 | +; instcombine deleting a phi whose values had been cached. |
| 60 | +define void @fn2() { |
| 61 | +entry: |
| 62 | + %a = alloca i8, align 1 |
| 63 | + %0 = load i8*, i8** @c, align 1 |
| 64 | + %1 = bitcast i8* %0 to i8** |
| 65 | + br label %for.cond |
| 66 | + |
| 67 | +for.cond: ; preds = %for.body, %entry |
| 68 | + %d.0 = phi i8** [ %1, %entry ], [ null, %for.body ] |
| 69 | + br i1 undef, label %for.body, label %for.cond.cleanup |
| 70 | + |
| 71 | +for.body: ; preds = %for.cond |
| 72 | + store volatile i8 undef, i8* %a, align 1 |
| 73 | + br label %for.cond |
| 74 | + |
| 75 | +for.cond.cleanup: ; preds = %for.cond |
| 76 | + call void @llvm.lifetime.end.p0i8(i64 1, i8* %a) |
| 77 | + %2 = load i8*, i8** %d.0, align 1 |
| 78 | + store i8* %2, i8** @c, align 1 |
| 79 | + ret void |
| 80 | +} |
0 commit comments