• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -basic-aa -print-memoryssa -verify-memoryssa -enable-new-pm=0 -analyze < %s 2>&1 | FileCheck %s
2; RUN: opt -aa-pipeline=basic-aa -passes='print<memoryssa>' -verify-memoryssa < %s 2>&1 | FileCheck %s
3;
4; Things that BasicAA can prove points to constant memory should be
5; liveOnEntry, as well.
6
7declare void @clobberAllTheThings()
8
9@str = private unnamed_addr constant [2 x i8] c"hi"
10
11define i8 @foo() {
12; CHECK: 1 = MemoryDef(liveOnEntry)
13; CHECK-NEXT: call void @clobberAllTheThings()
14  call void @clobberAllTheThings()
15  %1 = getelementptr [2 x i8], [2 x i8]* @str, i64 0, i64 0
16; CHECK: MemoryUse(liveOnEntry)
17; CHECK-NEXT: %2 = load i8
18  %2 = load i8, i8* %1, align 1
19  %3 = getelementptr [2 x i8], [2 x i8]* @str, i64 0, i64 1
20; CHECK: MemoryUse(liveOnEntry)
21; CHECK-NEXT: %4 = load i8
22  %4 = load i8, i8* %3, align 1
23  %5 = add i8 %2, %4
24  ret i8 %5
25}
26
27define i8 @select(i1 %b) {
28  %1 = alloca i8, align 1
29; CHECK: 1 = MemoryDef(liveOnEntry)
30; CHECK-NEXT: store i8 0
31  store i8 0, i8* %1, align 1
32
33; CHECK: 2 = MemoryDef(1)
34; CHECK-NEXT: call void @clobberAllTheThings()
35  call void @clobberAllTheThings()
36  %2 = getelementptr [2 x i8], [2 x i8]* @str, i64 0, i64 0
37  %3 = select i1 %b, i8* %2, i8* %1
38; CHECK: MemoryUse(2)
39; CHECK-NEXT: %4 = load i8
40  %4 = load i8, i8* %3, align 1
41  ret i8 %4
42}
43