From: Daniel Berlin Date: Sun, 19 Feb 2017 04:29:01 +0000 (+0000) Subject: Add a DebugCounter for PredicateInfo renaming, and an associated test X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2287817fa92c32d1a3b49a1a272aa9c6da3eb805;p=llvm Add a DebugCounter for PredicateInfo renaming, and an associated test git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295594 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Utils/PredicateInfo.cpp b/lib/Transforms/Utils/PredicateInfo.cpp index b97a1bc766c..ac6843ff04d 100644 --- a/lib/Transforms/Utils/PredicateInfo.cpp +++ b/lib/Transforms/Utils/PredicateInfo.cpp @@ -31,6 +31,7 @@ #include "llvm/IR/Module.h" #include "llvm/IR/PatternMatch.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/DebugCounter.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Transforms/Scalar.h" #include @@ -48,6 +49,9 @@ INITIALIZE_PASS_END(PredicateInfoPrinterLegacyPass, "print-predicateinfo", static cl::opt VerifyPredicateInfo( "verify-predicateinfo", cl::init(false), cl::Hidden, cl::desc("Verify PredicateInfo in legacy printer pass.")); +DEBUG_COUNTER(RenameCounter, "predicateinfo-rename", + "Controls which variables are renamed with predicateinfo"); + namespace llvm { namespace PredicateInfoClasses { enum LocalNum { @@ -578,6 +582,10 @@ void PredicateInfo::renameUses(SmallPtrSetImpl &OpsToRename) { // Skip values, only want to rename the uses if (VD.Def || PossibleCopy) continue; + if (!DebugCounter::shouldExecute(RenameCounter)) { + DEBUG(dbgs() << "Skipping execution due to debug counter\n"); + continue; + } ValueDFS &Result = RenameStack.back(); // If the possible copy dominates something, materialize our stack up to diff --git a/test/Other/debugcounter.ll b/test/Other/debugcounter.ll new file mode 100644 index 00000000000..c9702a7051c --- /dev/null +++ b/test/Other/debugcounter.ll @@ -0,0 +1,39 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +;; Test that, with debug counters on, we don't rename the first info, only the second +; RUN: opt -debug-counter=predicateinfo-rename-skip=1,predicateinfo-rename-count=1 -print-predicateinfo -analyze < %s 2>&1 | FileCheck %s +define fastcc void @barney() { +; CHECK-LABEL: @barney( +; CHECK-NEXT: bb: +; CHECK-NEXT: br label [[BB22:%.*]] +; CHECK: bb22: +; CHECK-NEXT: [[TMP23:%.*]] = icmp eq i32 undef, 2 +; CHECK: [[TMP23_0:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[TMP23]]) +; CHECK-NEXT: br i1 [[TMP23]], label [[BB29:%.*]], label [[BB35:%.*]] +; CHECK: bb29: +; CHECK: [[TMP23_0_1:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[TMP23_0]]) +; CHECK-NEXT: br i1 [[TMP23]], label [[BB33:%.*]], label [[BB35]] +; CHECK: bb33: +; CHECK-NEXT: br i1 [[TMP23_0_1]], label [[BB35]], label [[BB35]] +; CHECK: bb35: +; CHECK-NEXT: unreachable +; +bb: + br label %bb22 +bb22: ; preds = %bb21 + %tmp23 = icmp eq i32 undef, 2 + br i1 %tmp23, label %bb29, label %bb35 + + +bb29: ; preds = %bb28 +;; We will not rename this one (we will still generate a copy of a copy for the next one) + br i1 %tmp23, label %bb33, label %bb35 + + +bb33: ; preds = %bb31 +;; We will rename this one + br i1 %tmp23, label %bb35, label %bb35 + +bb35: ; preds = %bb33, %bb29, %bb22 + unreachable +} +