diff options
| author | Xinliang David Li <davidxl@google.com> | 2017-11-30 19:16:25 +0000 |
|---|---|---|
| committer | Xinliang David Li <davidxl@google.com> | 2017-11-30 19:16:25 +0000 |
| commit | c23d2c688347639f789e4b2d33d3ed1df2fd52d9 (patch) | |
| tree | 641494f1492a0f825ff4e12244831e3067b612d4 | |
| parent | b661757cd1379dcf3bc27976ed57dc9ea48b6a2e (diff) | |
| download | bcm5719-llvm-c23d2c688347639f789e4b2d33d3ed1df2fd52d9.tar.gz bcm5719-llvm-c23d2c688347639f789e4b2d33d3ed1df2fd52d9.zip | |
[PGO] Skip counter promotion for infinite loops
Differential Revision: http://reviews.llvm.org/D40662
llvm-svn: 319462
| -rw-r--r-- | llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp | 3 | ||||
| -rw-r--r-- | llvm/test/Transforms/PGOProfile/infinite_loop.ll | 21 |
2 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp index db8fa897794..787afc32dfb 100644 --- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp @@ -245,6 +245,9 @@ public: } bool run(int64_t *NumPromoted) { + // Skip 'infinite' loops: + if (ExitBlocks.size() == 0) + return false; unsigned MaxProm = getMaxNumOfPromotionsInLoop(&L); if (MaxProm == 0) return false; diff --git a/llvm/test/Transforms/PGOProfile/infinite_loop.ll b/llvm/test/Transforms/PGOProfile/infinite_loop.ll new file mode 100644 index 00000000000..68e9873f092 --- /dev/null +++ b/llvm/test/Transforms/PGOProfile/infinite_loop.ll @@ -0,0 +1,21 @@ +; RUN: opt < %s -instrprof -S -o - -do-counter-promotion=1 | FileCheck %s +; CHECK: store + +@__profn_foo = private constant [3 x i8] c"foo" + +define void @foo() { +entry: + br label %while.body + + while.body: ; preds = %entry, %while.body + call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 14813359968, i32 1, i32 0) + call void (...) @bar() #2 + br label %while.body +} + +declare void @bar(...) + +declare void @llvm.instrprof.increment(i8*, i64, i32, i32) #0 + +attributes #0 = { nounwind } + |

