diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
commit | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch) | |
tree | 012bb94d777798f1f56ac1cec429509766d05181 /contrib/libs/llvm12/lib/Target/TargetLoweringObjectFile.cpp | |
parent | 6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff) | |
download | ydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/llvm12/lib/Target/TargetLoweringObjectFile.cpp')
-rw-r--r-- | contrib/libs/llvm12/lib/Target/TargetLoweringObjectFile.cpp | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/contrib/libs/llvm12/lib/Target/TargetLoweringObjectFile.cpp b/contrib/libs/llvm12/lib/Target/TargetLoweringObjectFile.cpp index 81af4eead6..1c8d852504 100644 --- a/contrib/libs/llvm12/lib/Target/TargetLoweringObjectFile.cpp +++ b/contrib/libs/llvm12/lib/Target/TargetLoweringObjectFile.cpp @@ -20,7 +20,7 @@ #include "llvm/IR/GlobalVariable.h" #include "llvm/IR/Mangler.h" #include "llvm/IR/Module.h" -#include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCStreamer.h" @@ -50,23 +50,23 @@ void TargetLoweringObjectFile::Initialize(MCContext &ctx, // Reset various EH DWARF encodings. PersonalityEncoding = LSDAEncoding = TTypeEncoding = dwarf::DW_EH_PE_absptr; CallSiteEncoding = dwarf::DW_EH_PE_uleb128; - - this->TM = &TM; + + this->TM = &TM; } TargetLoweringObjectFile::~TargetLoweringObjectFile() { delete Mang; } -unsigned TargetLoweringObjectFile::getCallSiteEncoding() const { - // If target does not have LEB128 directives, we would need the - // call site encoding to be udata4 so that the alternative path - // for not having LEB128 directives could work. - if (!getContext().getAsmInfo()->hasLEB128Directives()) - return dwarf::DW_EH_PE_udata4; - return CallSiteEncoding; -} - +unsigned TargetLoweringObjectFile::getCallSiteEncoding() const { + // If target does not have LEB128 directives, we would need the + // call site encoding to be udata4 so that the alternative path + // for not having LEB128 directives could work. + if (!getContext().getAsmInfo()->hasLEB128Directives()) + return dwarf::DW_EH_PE_udata4; + return CallSiteEncoding; +} + static bool isNullOrUndef(const Constant *C) { // Check that the constant isn't all zeros or undefs. if (C->isNullValue() || isa<UndefValue>(C)) @@ -148,53 +148,53 @@ void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer, const MCSymbol *Sym) const { } -void TargetLoweringObjectFile::emitCGProfileMetadata(MCStreamer &Streamer, - Module &M) const { - MCContext &C = getContext(); - SmallVector<Module::ModuleFlagEntry, 8> ModuleFlags; - M.getModuleFlagsMetadata(ModuleFlags); - - MDNode *CFGProfile = nullptr; - - for (const auto &MFE : ModuleFlags) { - StringRef Key = MFE.Key->getString(); - if (Key == "CG Profile") { - CFGProfile = cast<MDNode>(MFE.Val); - break; - } - } - - if (!CFGProfile) - return; - - auto GetSym = [this](const MDOperand &MDO) -> MCSymbol * { - if (!MDO) - return nullptr; - auto *V = cast<ValueAsMetadata>(MDO); - const Function *F = cast<Function>(V->getValue()->stripPointerCasts()); - if (F->hasDLLImportStorageClass()) - return nullptr; - return TM->getSymbol(F); - }; - - for (const auto &Edge : CFGProfile->operands()) { - MDNode *E = cast<MDNode>(Edge); - const MCSymbol *From = GetSym(E->getOperand(0)); - const MCSymbol *To = GetSym(E->getOperand(1)); - // Skip null functions. This can happen if functions are dead stripped after - // the CGProfile pass has been run. - if (!From || !To) - continue; - uint64_t Count = cast<ConstantAsMetadata>(E->getOperand(2)) - ->getValue() - ->getUniqueInteger() - .getZExtValue(); - Streamer.emitCGProfileEntry( - MCSymbolRefExpr::create(From, MCSymbolRefExpr::VK_None, C), - MCSymbolRefExpr::create(To, MCSymbolRefExpr::VK_None, C), Count); - } -} - +void TargetLoweringObjectFile::emitCGProfileMetadata(MCStreamer &Streamer, + Module &M) const { + MCContext &C = getContext(); + SmallVector<Module::ModuleFlagEntry, 8> ModuleFlags; + M.getModuleFlagsMetadata(ModuleFlags); + + MDNode *CFGProfile = nullptr; + + for (const auto &MFE : ModuleFlags) { + StringRef Key = MFE.Key->getString(); + if (Key == "CG Profile") { + CFGProfile = cast<MDNode>(MFE.Val); + break; + } + } + + if (!CFGProfile) + return; + + auto GetSym = [this](const MDOperand &MDO) -> MCSymbol * { + if (!MDO) + return nullptr; + auto *V = cast<ValueAsMetadata>(MDO); + const Function *F = cast<Function>(V->getValue()->stripPointerCasts()); + if (F->hasDLLImportStorageClass()) + return nullptr; + return TM->getSymbol(F); + }; + + for (const auto &Edge : CFGProfile->operands()) { + MDNode *E = cast<MDNode>(Edge); + const MCSymbol *From = GetSym(E->getOperand(0)); + const MCSymbol *To = GetSym(E->getOperand(1)); + // Skip null functions. This can happen if functions are dead stripped after + // the CGProfile pass has been run. + if (!From || !To) + continue; + uint64_t Count = cast<ConstantAsMetadata>(E->getOperand(2)) + ->getValue() + ->getUniqueInteger() + .getZExtValue(); + Streamer.emitCGProfileEntry( + MCSymbolRefExpr::create(From, MCSymbolRefExpr::VK_None, C), + MCSymbolRefExpr::create(To, MCSymbolRefExpr::VK_None, C), Count); + } +} + /// getKindForGlobal - This is a top-level target-independent classifier for /// a global object. Given a global variable and information from the TM, this /// function classifies the global in a target independent manner. This function |