Skip to content

Commit

Permalink
Revert "[LoopDeletion] Allows deletion of possibly infinite side-effe…
Browse files Browse the repository at this point in the history
…ct free loops"

This reverts commit 0b17c6e. This patch
causes a compile-time error in SCEV.
  • Loading branch information
atmnpatel committed Nov 7, 2020
1 parent d3e75d3 commit 04a0896
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 272 deletions.
3 changes: 0 additions & 3 deletions llvm/include/llvm/Transforms/Utils/LoopUtils.h
Expand Up @@ -229,9 +229,6 @@ bool hasDisableAllTransformsHint(const Loop *L);
/// Look for the loop attribute that disables the LICM transformation heuristics.
bool hasDisableLICMTransformsHint(const Loop *L);

/// Look for the loop attribute that requires progress within the loop.
bool hasMustProgress(const Loop *L);

/// The mode sets how eager a transformation should be applied.
enum TransformationMode {
/// The pass can use heuristics to determine whether a transformation should
Expand Down
6 changes: 2 additions & 4 deletions llvm/lib/Transforms/Scalar/LoopDeletion.cpp
Expand Up @@ -210,10 +210,8 @@ static LoopDeletionResult deleteLoopIfDead(Loop *L, DominatorTree &DT,
// Don't remove loops for which we can't solve the trip count.
// They could be infinite, in which case we'd be changing program behavior.
const SCEV *S = SE.getConstantMaxBackedgeTakenCount(L);
if (isa<SCEVCouldNotCompute>(S) &&
!L->getHeader()->getParent()->mustProgress() && !hasMustProgress(L)) {
LLVM_DEBUG(dbgs() << "Could not compute SCEV MaxBackedgeTakenCount and was "
"not required to make progress.\n");
if (isa<SCEVCouldNotCompute>(S)) {
LLVM_DEBUG(dbgs() << "Could not compute SCEV MaxBackedgeTakenCount.\n");
return Changed ? LoopDeletionResult::Modified
: LoopDeletionResult::Unmodified;
}
Expand Down
5 changes: 0 additions & 5 deletions llvm/lib/Transforms/Utils/LoopUtils.cpp
Expand Up @@ -63,7 +63,6 @@ static cl::opt<bool> ForceReductionIntrinsic(

static const char *LLVMLoopDisableNonforced = "llvm.loop.disable_nonforced";
static const char *LLVMLoopDisableLICM = "llvm.licm.disable";
static const char *LLVMLoopMustProgress = "llvm.loop.mustprogress";

bool llvm::formDedicatedExitBlocks(Loop *L, DominatorTree *DT, LoopInfo *LI,
MemorySSAUpdater *MSSAU,
Expand Down Expand Up @@ -405,10 +404,6 @@ bool llvm::hasDisableLICMTransformsHint(const Loop *L) {
return getBooleanLoopAttribute(L, LLVMLoopDisableLICM);
}

bool llvm::hasMustProgress(const Loop *L) {
return getBooleanLoopAttribute(L, LLVMLoopMustProgress);
}

TransformationMode llvm::hasUnrollTransformation(Loop *L) {
if (getBooleanLoopAttribute(L, "llvm.loop.unroll.disable"))
return TM_SuppressedByUser;
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Other/loop-deletion-printer.ll
Expand Up @@ -14,7 +14,7 @@
; DELETED-BUT-PRINTED: IR Dump {{.*}}LoopDeletionPass {{.*invalidated:}}
; DELETED-BUT-PRINTED-NOT: IR Dump {{.*}}LoopInstSimplifyPass

define void @deleteme() willreturn {
define void @deleteme() {
entry:
br label %loop
loop:
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Other/loop-pm-invalidation.ll
Expand Up @@ -227,7 +227,7 @@ exit:
ret void
}

define void @dead_loop() willreturn {
define void @dead_loop() {
; CHECK-LOOP-INV: Starting {{.*}}Function pass manager run
; CHECK-LOOP-INV-NEXT: Starting {{.*}}Function pass manager run
; CHECK-LOOP-INV-NEXT: Running pass: LoopSimplifyPass
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/LICM/2003-02-27-PreheaderProblem.ll
Expand Up @@ -6,7 +6,7 @@
; RUN: opt < %s -licm -loop-deletion -simplifycfg -S | \
; RUN: not grep "br "

define i32 @main(i32 %argc) willreturn {
define i32 @main(i32 %argc) {
; <label>:0
br label %bb5
bb5: ; preds = %bb5, %0
Expand Down
Expand Up @@ -15,7 +15,7 @@
; DT: [3] %for.body
; DT: [4] %for.cond3.loopexit

define i32 @fn1() willreturn {
define i32 @fn1() {
entry:
br label %for.cond

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/LoopDeletion/basic-remark.ll
Expand Up @@ -10,7 +10,7 @@
; CHECK-NEXT: Args:
; CHECK-NEXT: - String: Loop deleted because it is invariant
; CHECK-NEXT: ...
define i32 @main() local_unnamed_addr willreturn {
define i32 @main() local_unnamed_addr #0 {
entry:
br label %for.cond, !dbg !9

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/LoopDeletion/diundef.ll
Expand Up @@ -5,7 +5,7 @@ target triple = "x86_64-apple-macosx10.14.0"

@a = common local_unnamed_addr global i32 0, align 4, !dbg !0

define i32 @b() local_unnamed_addr willreturn !dbg !12 {
define i32 @b() local_unnamed_addr !dbg !12 {
entry:
call void @llvm.dbg.value(metadata i32 0, metadata !16, metadata !DIExpression()), !dbg !17
br label %for.cond, !dbg !18
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/LoopDeletion/invalidation.ll
Expand Up @@ -8,7 +8,7 @@
; RUN: | FileCheck %s --check-prefixes=CHECK,AFTER


define void @foo(i64 %n, i64 %m) nounwind willreturn {
define void @foo(i64 %n, i64 %m) nounwind {
; CHECK-LABEL: @foo(

entry:
Expand Down
Expand Up @@ -11,7 +11,7 @@
; CHECK: return:
; CHECK-NEXT: ret void

define void @foo(i64 %n, i64 %m) nounwind willreturn {
define void @foo(i64 %n, i64 %m) nounwind {
entry:
br label %bb

Expand Down
8 changes: 3 additions & 5 deletions llvm/test/Transforms/LoopDeletion/multiple-exits.ll
Expand Up @@ -10,7 +10,7 @@
; RUN: opt < %s -passes=loop-deletion -S | FileCheck %s --check-prefixes=CHECK,AFTER


define void @foo(i64 %n, i64 %m) #0 {
define void @foo(i64 %n, i64 %m) nounwind {
; CHECK-LABEL: @foo(

entry:
Expand Down Expand Up @@ -43,7 +43,7 @@ return:
; CHECK-NEXT: ret void
}

define i64 @bar(i64 %n, i64 %m, i64 %maybe_zero) #0 {
define i64 @bar(i64 %n, i64 %m, i64 %maybe_zero) nounwind {
; CHECK-LABEL: @bar(

entry:
Expand Down Expand Up @@ -95,7 +95,7 @@ return:

; This function has a loop which looks like @bar's but that cannot be deleted
; because which path we exit through determines which value is selected.
define i64 @baz(i64 %n, i64 %m, i64 %maybe_zero) #0 {
define i64 @baz(i64 %n, i64 %m, i64 %maybe_zero) nounwind {
; CHECK-LABEL: @baz(

entry:
Expand Down Expand Up @@ -136,5 +136,3 @@ return:
; CHECK-NEXT: %[[X:.*]] = phi i64 [ 12, %bb ], [ 10, %bb2 ], [ 10, %bb3 ]
; CHECK-NEXT: ret i64 %[[X]]
}

attributes #0 = { nounwind willreturn }
237 changes: 0 additions & 237 deletions llvm/test/Transforms/LoopDeletion/mustprogress.ll

This file was deleted.

0 comments on commit 04a0896

Please sign in to comment.