llvm.org GIT mirror llvm / 2cd9451
[Mem2Reg] Avoid replacing load with itself in promoteSingleBlockAlloca. We do the same thing in rewriteSingleStoreAlloca. Fixes PR37632. Reviewers: chandlerc, davide, efriedma Reviewed By: davide Differential Revision: https://reviews.llvm.org/D47825 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334187 91177308-0d34-0410-b5e6-96231b3b80d8 Florian Hahn 1 year, 5 months ago
2 changed file(s) with 25 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
510510 !isKnownNonZero(ReplVal, DL, 0, AC, LI, &DT))
511511 addAssumeNonNull(AC, LI);
512512
513 // If the replacement value is the load, this must occur in unreachable
514 // code.
515 if (ReplVal == LI)
516 ReplVal = UndefValue::get(LI->getType());
517
513518 LI->replaceAllUsesWith(ReplVal);
514519 }
515520
0 ; RUN: opt -mem2reg < %s -S | FileCheck %s
1
2
3 ; CHECK-LABEL: void @patatino()
4 ; CHECK-NEXT: ret void
5
6 ; CHECK-LABEL: cantreachme:
7 ; CHECK-NEXT: %dec = add nsw i32 undef, -1
8 ; CHECK-NEXT: br label %cantreachme
9
10 define void @patatino() {
11 %a = alloca i32, align 4
12 ret void
13 cantreachme:
14 %dec = add nsw i32 %tmp, -1
15 store i32 %dec, i32* %a
16 store i32 %tmp, i32* %a
17 %tmp = load i32, i32* %a
18 br label %cantreachme
19 }