llvm.org GIT mirror llvm / de15f17
[NewGVN] Don't incorrectly reset the memory leader. This code was missing a check for stores, so we were thinking the congruency class didn't have any memory members, and reset the memory leader. Differential Revision: https://reviews.llvm.org/D33056 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302905 91177308-0d34-0410-b5e6-96231b3b80d8 Davide Italiano 3 years ago
2 changed file(s) with 69 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
14081408 NewClass->memory_insert(MP);
14091409 // This may have killed the class if it had no non-memory members
14101410 if (OldClass->getMemoryLeader() == From) {
1411 if (OldClass->memory_empty()) {
1411 if (OldClass->definesNoMemory()) {
14121412 OldClass->setMemoryLeader(nullptr);
14131413 } else {
14141414 OldClass->setMemoryLeader(getNextMemoryLeader(OldClass));
0 ; RUN: opt -S -newgvn %s | FileCheck %s
1
2 ; CHECK: define void @tinkywinky() {
3 ; CHECK-NEXT: entry:
4 ; CHECK-NEXT: %d = alloca i32, align 4
5 ; CHECK-NEXT: store i32 0, i32* null, align 4
6 ; CHECK-NEXT: br label %for.cond
7 ; CHECK: for.cond: ; preds = %if.end, %entry
8 ; CHECK-NEXT: %0 = load i32, i32* null, align 4
9 ; CHECK-NEXT: %cmp = icmp slt i32 %0, 1
10 ; CHECK-NEXT: br i1 %cmp, label %for.body, label %while.cond
11 ; CHECK: for.body: ; preds = %for.cond
12 ; CHECK-NEXT: %1 = load i32, i32* @a, align 4
13 ; CHECK-NEXT: store i32 %1, i32* %d, align 4
14 ; CHECK-NEXT: br label %L
15 ; CHECK: L: ; preds = %if.then, %for.body
16 ; CHECK-NEXT: %tobool = icmp ne i32 %1, 0
17 ; CHECK-NEXT: br i1 %tobool, label %if.then, label %if.end
18 ; CHECK: if.then: ; preds = %L
19 ; CHECK-NEXT: call void (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @patatino, i32 0, i32 0))
20 ; CHECK-NEXT: br label %L
21 ; CHECK: if.end: ; preds = %L
22 ; CHECK-NEXT: br label %for.cond
23 ; CHECK: while.cond: ; preds = %while.body, %for.cond
24 ; CHECK-NEXT: br i1 undef, label %while.body, label %while.end
25 ; CHECK: while.body: ; preds = %while.cond
26 ; CHECK-NEXT: call void (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @patatino, i32 0, i32 0))
27 ; CHECK-NEXT: br label %while.cond
28 ; CHECK: while.end:
29 ; CHECK-NEXT: %2 = load i32, i32* @a, align 4
30 ; CHECK-NEXT: store i32 %2, i32* undef, align 4
31 ; CHECK-NEXT: ret void
32
33 @a = external global i32, align 4
34 @patatino = external unnamed_addr constant [2 x i8], align 1
35 define void @tinkywinky() {
36 entry:
37 %d = alloca i32, align 4
38 store i32 0, i32* null, align 4
39 br label %for.cond
40 for.cond:
41 %0 = load i32, i32* null, align 4
42 %cmp = icmp slt i32 %0, 1
43 br i1 %cmp, label %for.body, label %while.cond
44 for.body:
45 %1 = load i32, i32* @a, align 4
46 store i32 %1, i32* %d, align 4
47 br label %L
48 L:
49 %2 = load i32, i32* %d, align 4
50 %tobool = icmp ne i32 %2, 0
51 br i1 %tobool, label %if.then, label %if.end
52 if.then:
53 call void (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @patatino, i32 0, i32 0))
54 br label %L
55 if.end:
56 br label %for.cond
57 while.cond:
58 br i1 undef, label %while.body, label %while.end
59 while.body:
60 call void (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @patatino, i32 0, i32 0))
61 br label %while.cond
62 while.end:
63 %3 = load i32, i32* @a, align 4
64 store i32 %3, i32* undef, align 4
65 ret void
66 }
67 declare void @printf(i8*, ...) #1