aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/llvm12/lib/Analysis/ReplayInlineAdvisor.cpp
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:39 +0300
commite9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch)
tree64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/libs/llvm12/lib/Analysis/ReplayInlineAdvisor.cpp
parent2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff)
downloadydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/llvm12/lib/Analysis/ReplayInlineAdvisor.cpp')
-rw-r--r--contrib/libs/llvm12/lib/Analysis/ReplayInlineAdvisor.cpp164
1 files changed, 82 insertions, 82 deletions
diff --git a/contrib/libs/llvm12/lib/Analysis/ReplayInlineAdvisor.cpp b/contrib/libs/llvm12/lib/Analysis/ReplayInlineAdvisor.cpp
index 9833a5635c..b9dac2f3ff 100644
--- a/contrib/libs/llvm12/lib/Analysis/ReplayInlineAdvisor.cpp
+++ b/contrib/libs/llvm12/lib/Analysis/ReplayInlineAdvisor.cpp
@@ -1,82 +1,82 @@
-//===- ReplayInlineAdvisor.cpp - Replay InlineAdvisor ---------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements ReplayInlineAdvisor that replays inline decisions based
-// on previous inline remarks from optimization remark log. This is a best
-// effort approach useful for testing compiler/source changes while holding
-// inlining steady.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Analysis/ReplayInlineAdvisor.h"
-#include "llvm/IR/DebugInfoMetadata.h"
-#include "llvm/IR/Instructions.h"
-#include "llvm/Support/LineIterator.h"
-
-using namespace llvm;
-
-#define DEBUG_TYPE "inline-replay"
-
-ReplayInlineAdvisor::ReplayInlineAdvisor(
- Module &M, FunctionAnalysisManager &FAM, LLVMContext &Context,
- std::unique_ptr<InlineAdvisor> OriginalAdvisor, StringRef RemarksFile,
- bool EmitRemarks)
- : InlineAdvisor(M, FAM), OriginalAdvisor(std::move(OriginalAdvisor)),
- HasReplayRemarks(false), EmitRemarks(EmitRemarks) {
- auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(RemarksFile);
- std::error_code EC = BufferOrErr.getError();
- if (EC) {
- Context.emitError("Could not open remarks file: " + EC.message());
- return;
- }
-
- // Example for inline remarks to parse:
- // main:3:1.1: _Z3subii inlined into main at callsite sum:1 @ main:3:1.1
- // We use the callsite string after `at callsite` to replay inlining.
- line_iterator LineIt(*BufferOrErr.get(), /*SkipBlanks=*/true);
- for (; !LineIt.is_at_eof(); ++LineIt) {
- StringRef Line = *LineIt;
- auto Pair = Line.split(" at callsite ");
-
- auto Callee = Pair.first.split(" inlined into").first.rsplit(": ").second;
-
- auto CallSite = Pair.second.split(";").first;
-
- if (Callee.empty() || CallSite.empty())
- continue;
-
- std::string Combined = (Callee + CallSite).str();
- InlineSitesFromRemarks.insert(Combined);
- }
-
- HasReplayRemarks = true;
-}
-
-std::unique_ptr<InlineAdvice> ReplayInlineAdvisor::getAdviceImpl(CallBase &CB) {
- assert(HasReplayRemarks);
-
- Function &Caller = *CB.getCaller();
- auto &ORE = FAM.getResult<OptimizationRemarkEmitterAnalysis>(Caller);
-
- if (InlineSitesFromRemarks.empty())
- return std::make_unique<DefaultInlineAdvice>(this, CB, None, ORE,
- EmitRemarks);
-
- std::string CallSiteLoc = getCallSiteLocation(CB.getDebugLoc());
- StringRef Callee = CB.getCalledFunction()->getName();
- std::string Combined = (Callee + CallSiteLoc).str();
- auto Iter = InlineSitesFromRemarks.find(Combined);
-
- Optional<InlineCost> InlineRecommended = None;
- if (Iter != InlineSitesFromRemarks.end()) {
- InlineRecommended = llvm::InlineCost::getAlways("found in replay");
- }
-
- return std::make_unique<DefaultInlineAdvice>(this, CB, InlineRecommended, ORE,
- EmitRemarks);
-}
+//===- ReplayInlineAdvisor.cpp - Replay InlineAdvisor ---------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements ReplayInlineAdvisor that replays inline decisions based
+// on previous inline remarks from optimization remark log. This is a best
+// effort approach useful for testing compiler/source changes while holding
+// inlining steady.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Analysis/ReplayInlineAdvisor.h"
+#include "llvm/IR/DebugInfoMetadata.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/Support/LineIterator.h"
+
+using namespace llvm;
+
+#define DEBUG_TYPE "inline-replay"
+
+ReplayInlineAdvisor::ReplayInlineAdvisor(
+ Module &M, FunctionAnalysisManager &FAM, LLVMContext &Context,
+ std::unique_ptr<InlineAdvisor> OriginalAdvisor, StringRef RemarksFile,
+ bool EmitRemarks)
+ : InlineAdvisor(M, FAM), OriginalAdvisor(std::move(OriginalAdvisor)),
+ HasReplayRemarks(false), EmitRemarks(EmitRemarks) {
+ auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(RemarksFile);
+ std::error_code EC = BufferOrErr.getError();
+ if (EC) {
+ Context.emitError("Could not open remarks file: " + EC.message());
+ return;
+ }
+
+ // Example for inline remarks to parse:
+ // main:3:1.1: _Z3subii inlined into main at callsite sum:1 @ main:3:1.1
+ // We use the callsite string after `at callsite` to replay inlining.
+ line_iterator LineIt(*BufferOrErr.get(), /*SkipBlanks=*/true);
+ for (; !LineIt.is_at_eof(); ++LineIt) {
+ StringRef Line = *LineIt;
+ auto Pair = Line.split(" at callsite ");
+
+ auto Callee = Pair.first.split(" inlined into").first.rsplit(": ").second;
+
+ auto CallSite = Pair.second.split(";").first;
+
+ if (Callee.empty() || CallSite.empty())
+ continue;
+
+ std::string Combined = (Callee + CallSite).str();
+ InlineSitesFromRemarks.insert(Combined);
+ }
+
+ HasReplayRemarks = true;
+}
+
+std::unique_ptr<InlineAdvice> ReplayInlineAdvisor::getAdviceImpl(CallBase &CB) {
+ assert(HasReplayRemarks);
+
+ Function &Caller = *CB.getCaller();
+ auto &ORE = FAM.getResult<OptimizationRemarkEmitterAnalysis>(Caller);
+
+ if (InlineSitesFromRemarks.empty())
+ return std::make_unique<DefaultInlineAdvice>(this, CB, None, ORE,
+ EmitRemarks);
+
+ std::string CallSiteLoc = getCallSiteLocation(CB.getDebugLoc());
+ StringRef Callee = CB.getCalledFunction()->getName();
+ std::string Combined = (Callee + CallSiteLoc).str();
+ auto Iter = InlineSitesFromRemarks.find(Combined);
+
+ Optional<InlineCost> InlineRecommended = None;
+ if (Iter != InlineSitesFromRemarks.end()) {
+ InlineRecommended = llvm::InlineCost::getAlways("found in replay");
+ }
+
+ return std::make_unique<DefaultInlineAdvice>(this, CB, InlineRecommended, ORE,
+ EmitRemarks);
+}