summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lib/Analysis/LoopPass.cpp
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2019-06-23 21:36:31 +0000
committerpatrick <patrick@openbsd.org>2019-06-23 21:36:31 +0000
commit23f101f37937a1bd4a29726cab2f76e0fb038b35 (patch)
treef7da7d6b32c2e07114da399150bfa88d72187012 /gnu/llvm/lib/Analysis/LoopPass.cpp
parentsort previous; ok deraadt (diff)
downloadwireguard-openbsd-23f101f37937a1bd4a29726cab2f76e0fb038b35.tar.xz
wireguard-openbsd-23f101f37937a1bd4a29726cab2f76e0fb038b35.zip
Import LLVM 8.0.0 release including clang, lld and lldb.
Diffstat (limited to 'gnu/llvm/lib/Analysis/LoopPass.cpp')
-rw-r--r--gnu/llvm/lib/Analysis/LoopPass.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/gnu/llvm/lib/Analysis/LoopPass.cpp b/gnu/llvm/lib/Analysis/LoopPass.cpp
index 07a151ce0fc..a68f114b83a 100644
--- a/gnu/llvm/lib/Analysis/LoopPass.cpp
+++ b/gnu/llvm/lib/Analysis/LoopPass.cpp
@@ -20,6 +20,7 @@
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/OptBisect.h"
#include "llvm/IR/PassManager.h"
+#include "llvm/IR/PassTimingInfo.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/raw_ostream.h"
@@ -193,8 +194,14 @@ bool LPPassManager::runOnFunction(Function &F) {
}
// Walk Loops
- unsigned InstrCount = 0;
+ unsigned InstrCount, FunctionSize = 0;
+ StringMap<std::pair<unsigned, unsigned>> FunctionToInstrCount;
bool EmitICRemark = M.shouldEmitInstrCountChangedRemark();
+ // Collect the initial size of the module and the function we're looking at.
+ if (EmitICRemark) {
+ InstrCount = initSizeRemarkInfo(M, FunctionToInstrCount);
+ FunctionSize = F.getInstructionCount();
+ }
while (!LQ.empty()) {
CurrentLoopDeleted = false;
CurrentLoop = LQ.back();
@@ -209,17 +216,28 @@ bool LPPassManager::runOnFunction(Function &F) {
initializeAnalysisImpl(P);
+ bool LocalChanged = false;
{
PassManagerPrettyStackEntry X(P, *CurrentLoop->getHeader());
TimeRegion PassTimer(getPassTimer(P));
- if (EmitICRemark)
- InstrCount = initSizeRemarkInfo(M);
- Changed |= P->runOnLoop(CurrentLoop, *this);
- if (EmitICRemark)
- emitInstrCountChangedRemark(P, M, InstrCount);
+ LocalChanged = P->runOnLoop(CurrentLoop, *this);
+ Changed |= LocalChanged;
+ if (EmitICRemark) {
+ unsigned NewSize = F.getInstructionCount();
+ // Update the size of the function, emit a remark, and update the
+ // size of the module.
+ if (NewSize != FunctionSize) {
+ int64_t Delta = static_cast<int64_t>(NewSize) -
+ static_cast<int64_t>(FunctionSize);
+ emitInstrCountChangedRemark(P, M, Delta, InstrCount,
+ FunctionToInstrCount, &F);
+ InstrCount = static_cast<int64_t>(InstrCount) + Delta;
+ FunctionSize = NewSize;
+ }
+ }
}
- if (Changed)
+ if (LocalChanged)
dumpPassInfo(P, MODIFICATION_MSG, ON_LOOP_MSG,
CurrentLoopDeleted ? "<deleted loop>"
: CurrentLoop->getName());