diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
commit | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch) | |
tree | 64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/libs/llvm12/lib/CodeGen/PseudoProbeInserter.cpp | |
parent | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff) | |
download | ydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/llvm12/lib/CodeGen/PseudoProbeInserter.cpp')
-rw-r--r-- | contrib/libs/llvm12/lib/CodeGen/PseudoProbeInserter.cpp | 190 |
1 files changed, 95 insertions, 95 deletions
diff --git a/contrib/libs/llvm12/lib/CodeGen/PseudoProbeInserter.cpp b/contrib/libs/llvm12/lib/CodeGen/PseudoProbeInserter.cpp index 8e854cf2c8..9c716a5a37 100644 --- a/contrib/libs/llvm12/lib/CodeGen/PseudoProbeInserter.cpp +++ b/contrib/libs/llvm12/lib/CodeGen/PseudoProbeInserter.cpp @@ -1,95 +1,95 @@ -//===- PseudoProbeInserter.cpp - Insert annotation for callsite profiling -===// -// -// 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 PseudoProbeInserter pass, which inserts pseudo probe -// annotations for call instructions with a pseudo-probe-specific dwarf -// discriminator. such discriminator indicates that the call instruction comes -// with a pseudo probe, and the discriminator value holds information to -// identify the corresponding counter. -//===----------------------------------------------------------------------===// - -#include "llvm/CodeGen/MachineBasicBlock.h" -#include "llvm/CodeGen/MachineFunctionPass.h" -#include "llvm/CodeGen/MachineInstr.h" -#include "llvm/CodeGen/TargetInstrInfo.h" -#include "llvm/IR/DebugInfoMetadata.h" -#include "llvm/IR/PseudoProbe.h" -#include "llvm/InitializePasses.h" -#include "llvm/Target/TargetMachine.h" -#include <unordered_map> - -#define DEBUG_TYPE "pseudo-probe-inserter" - -using namespace llvm; - -namespace { -class PseudoProbeInserter : public MachineFunctionPass { -public: - static char ID; - - PseudoProbeInserter() : MachineFunctionPass(ID) { - initializePseudoProbeInserterPass(*PassRegistry::getPassRegistry()); - } - - StringRef getPassName() const override { return "Pseudo Probe Inserter"; } - - void getAnalysisUsage(AnalysisUsage &AU) const override { - AU.setPreservesAll(); - MachineFunctionPass::getAnalysisUsage(AU); - } - - bool runOnMachineFunction(MachineFunction &MF) override { - const TargetInstrInfo *TII = MF.getSubtarget().getInstrInfo(); - bool Changed = false; - for (MachineBasicBlock &MBB : MF) { - for (MachineInstr &MI : MBB) { - if (MI.isCall()) { - if (DILocation *DL = MI.getDebugLoc()) { - auto Value = DL->getDiscriminator(); - if (DILocation::isPseudoProbeDiscriminator(Value)) { - BuildMI(MBB, MI, DL, TII->get(TargetOpcode::PSEUDO_PROBE)) - .addImm(getFuncGUID(MF.getFunction().getParent(), DL)) - .addImm( - PseudoProbeDwarfDiscriminator::extractProbeIndex(Value)) - .addImm( - PseudoProbeDwarfDiscriminator::extractProbeType(Value)) - .addImm(PseudoProbeDwarfDiscriminator::extractProbeAttributes( - Value)); - Changed = true; - } - } - } - } - } - - return Changed; - } - -private: - uint64_t getFuncGUID(Module *M, DILocation *DL) { - auto *SP = DL->getScope()->getSubprogram(); - auto Name = SP->getLinkageName(); - if (Name.empty()) - Name = SP->getName(); - return Function::getGUID(Name); - } -}; -} // namespace - -char PseudoProbeInserter::ID = 0; -INITIALIZE_PASS_BEGIN(PseudoProbeInserter, DEBUG_TYPE, - "Insert pseudo probe annotations for value profiling", - false, false) -INITIALIZE_PASS_DEPENDENCY(TargetPassConfig) -INITIALIZE_PASS_END(PseudoProbeInserter, DEBUG_TYPE, - "Insert pseudo probe annotations for value profiling", - false, false) - -FunctionPass *llvm::createPseudoProbeInserter() { - return new PseudoProbeInserter(); -} +//===- PseudoProbeInserter.cpp - Insert annotation for callsite profiling -===// +// +// 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 PseudoProbeInserter pass, which inserts pseudo probe +// annotations for call instructions with a pseudo-probe-specific dwarf +// discriminator. such discriminator indicates that the call instruction comes +// with a pseudo probe, and the discriminator value holds information to +// identify the corresponding counter. +//===----------------------------------------------------------------------===// + +#include "llvm/CodeGen/MachineBasicBlock.h" +#include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/CodeGen/MachineInstr.h" +#include "llvm/CodeGen/TargetInstrInfo.h" +#include "llvm/IR/DebugInfoMetadata.h" +#include "llvm/IR/PseudoProbe.h" +#include "llvm/InitializePasses.h" +#include "llvm/Target/TargetMachine.h" +#include <unordered_map> + +#define DEBUG_TYPE "pseudo-probe-inserter" + +using namespace llvm; + +namespace { +class PseudoProbeInserter : public MachineFunctionPass { +public: + static char ID; + + PseudoProbeInserter() : MachineFunctionPass(ID) { + initializePseudoProbeInserterPass(*PassRegistry::getPassRegistry()); + } + + StringRef getPassName() const override { return "Pseudo Probe Inserter"; } + + void getAnalysisUsage(AnalysisUsage &AU) const override { + AU.setPreservesAll(); + MachineFunctionPass::getAnalysisUsage(AU); + } + + bool runOnMachineFunction(MachineFunction &MF) override { + const TargetInstrInfo *TII = MF.getSubtarget().getInstrInfo(); + bool Changed = false; + for (MachineBasicBlock &MBB : MF) { + for (MachineInstr &MI : MBB) { + if (MI.isCall()) { + if (DILocation *DL = MI.getDebugLoc()) { + auto Value = DL->getDiscriminator(); + if (DILocation::isPseudoProbeDiscriminator(Value)) { + BuildMI(MBB, MI, DL, TII->get(TargetOpcode::PSEUDO_PROBE)) + .addImm(getFuncGUID(MF.getFunction().getParent(), DL)) + .addImm( + PseudoProbeDwarfDiscriminator::extractProbeIndex(Value)) + .addImm( + PseudoProbeDwarfDiscriminator::extractProbeType(Value)) + .addImm(PseudoProbeDwarfDiscriminator::extractProbeAttributes( + Value)); + Changed = true; + } + } + } + } + } + + return Changed; + } + +private: + uint64_t getFuncGUID(Module *M, DILocation *DL) { + auto *SP = DL->getScope()->getSubprogram(); + auto Name = SP->getLinkageName(); + if (Name.empty()) + Name = SP->getName(); + return Function::getGUID(Name); + } +}; +} // namespace + +char PseudoProbeInserter::ID = 0; +INITIALIZE_PASS_BEGIN(PseudoProbeInserter, DEBUG_TYPE, + "Insert pseudo probe annotations for value profiling", + false, false) +INITIALIZE_PASS_DEPENDENCY(TargetPassConfig) +INITIALIZE_PASS_END(PseudoProbeInserter, DEBUG_TYPE, + "Insert pseudo probe annotations for value profiling", + false, false) + +FunctionPass *llvm::createPseudoProbeInserter() { + return new PseudoProbeInserter(); +} |