aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/llvm12/lib/Bitcode
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:30 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:30 +0300
commit2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch)
tree012bb94d777798f1f56ac1cec429509766d05181 /contrib/libs/llvm12/lib/Bitcode
parent6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff)
downloadydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/llvm12/lib/Bitcode')
-rw-r--r--contrib/libs/llvm12/lib/Bitcode/Reader/BitcodeAnalyzer.cpp10
-rw-r--r--contrib/libs/llvm12/lib/Bitcode/Reader/BitcodeReader.cpp406
-rw-r--r--contrib/libs/llvm12/lib/Bitcode/Reader/MetadataLoader.cpp318
-rw-r--r--contrib/libs/llvm12/lib/Bitcode/Reader/ya.make10
-rw-r--r--contrib/libs/llvm12/lib/Bitcode/Writer/BitcodeWriter.cpp314
-rw-r--r--contrib/libs/llvm12/lib/Bitcode/Writer/ValueEnumerator.cpp62
-rw-r--r--contrib/libs/llvm12/lib/Bitcode/Writer/ya.make14
7 files changed, 567 insertions, 567 deletions
diff --git a/contrib/libs/llvm12/lib/Bitcode/Reader/BitcodeAnalyzer.cpp b/contrib/libs/llvm12/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
index e91af121ea..bb69e625ea 100644
--- a/contrib/libs/llvm12/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
+++ b/contrib/libs/llvm12/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
@@ -135,7 +135,7 @@ static Optional<const char *> GetCodeName(unsigned CodeID, unsigned BlockID,
STRINGIFY_CODE(MODULE_CODE, FUNCTION)
STRINGIFY_CODE(MODULE_CODE, ALIAS)
STRINGIFY_CODE(MODULE_CODE, GCNAME)
- STRINGIFY_CODE(MODULE_CODE, COMDAT)
+ STRINGIFY_CODE(MODULE_CODE, COMDAT)
STRINGIFY_CODE(MODULE_CODE, VSTOFFSET)
STRINGIFY_CODE(MODULE_CODE, METADATA_VALUES_UNUSED)
STRINGIFY_CODE(MODULE_CODE, SOURCE_FILENAME)
@@ -177,20 +177,20 @@ static Optional<const char *> GetCodeName(unsigned CodeID, unsigned BlockID,
STRINGIFY_CODE(TYPE_CODE, OPAQUE)
STRINGIFY_CODE(TYPE_CODE, INTEGER)
STRINGIFY_CODE(TYPE_CODE, POINTER)
- STRINGIFY_CODE(TYPE_CODE, HALF)
+ STRINGIFY_CODE(TYPE_CODE, HALF)
STRINGIFY_CODE(TYPE_CODE, ARRAY)
STRINGIFY_CODE(TYPE_CODE, VECTOR)
STRINGIFY_CODE(TYPE_CODE, X86_FP80)
STRINGIFY_CODE(TYPE_CODE, FP128)
STRINGIFY_CODE(TYPE_CODE, PPC_FP128)
STRINGIFY_CODE(TYPE_CODE, METADATA)
- STRINGIFY_CODE(TYPE_CODE, X86_MMX)
+ STRINGIFY_CODE(TYPE_CODE, X86_MMX)
STRINGIFY_CODE(TYPE_CODE, STRUCT_ANON)
STRINGIFY_CODE(TYPE_CODE, STRUCT_NAME)
STRINGIFY_CODE(TYPE_CODE, STRUCT_NAMED)
STRINGIFY_CODE(TYPE_CODE, FUNCTION)
- STRINGIFY_CODE(TYPE_CODE, TOKEN)
- STRINGIFY_CODE(TYPE_CODE, BFLOAT)
+ STRINGIFY_CODE(TYPE_CODE, TOKEN)
+ STRINGIFY_CODE(TYPE_CODE, BFLOAT)
}
case bitc::CONSTANTS_BLOCK_ID:
diff --git a/contrib/libs/llvm12/lib/Bitcode/Reader/BitcodeReader.cpp b/contrib/libs/llvm12/lib/Bitcode/Reader/BitcodeReader.cpp
index f2800201e8..38befd1cde 100644
--- a/contrib/libs/llvm12/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/contrib/libs/llvm12/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -20,8 +20,8 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
#include "llvm/ADT/Twine.h"
-#include "llvm/Bitcode/BitcodeCommon.h"
-#include "llvm/Bitcode/LLVMBitCodes.h"
+#include "llvm/Bitcode/BitcodeCommon.h"
+#include "llvm/Bitcode/LLVMBitCodes.h"
#include "llvm/Bitstream/BitstreamReader.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/IR/Argument.h"
@@ -579,7 +579,7 @@ public:
/// \returns true if an error occurred.
Error parseBitcodeInto(
Module *M, bool ShouldLazyLoadMetadata = false, bool IsImporting = false,
- DataLayoutCallbackTy DataLayoutCallback = [](StringRef) { return None; });
+ DataLayoutCallbackTy DataLayoutCallback = [](StringRef) { return None; });
static uint64_t decodeSignRotatedValue(uint64_t V);
@@ -649,7 +649,7 @@ private:
/// Read a value/type pair out of the specified record from slot 'Slot'.
/// Increment Slot past the number of slots used in the record. Return true on
/// failure.
- bool getValueTypePair(const SmallVectorImpl<uint64_t> &Record, unsigned &Slot,
+ bool getValueTypePair(const SmallVectorImpl<uint64_t> &Record, unsigned &Slot,
unsigned InstNum, Value *&ResVal,
Type **FullTy = nullptr) {
if (Slot == Record.size()) return true;
@@ -676,7 +676,7 @@ private:
/// Read a value out of the specified record from slot 'Slot'. Increment Slot
/// past the number of slots used by the value in the record. Return true if
/// there is an error.
- bool popValue(const SmallVectorImpl<uint64_t> &Record, unsigned &Slot,
+ bool popValue(const SmallVectorImpl<uint64_t> &Record, unsigned &Slot,
unsigned InstNum, Type *Ty, Value *&ResVal) {
if (getValue(Record, Slot, InstNum, Ty, ResVal))
return true;
@@ -686,7 +686,7 @@ private:
}
/// Like popValue, but does not increment the Slot number.
- bool getValue(const SmallVectorImpl<uint64_t> &Record, unsigned Slot,
+ bool getValue(const SmallVectorImpl<uint64_t> &Record, unsigned Slot,
unsigned InstNum, Type *Ty, Value *&ResVal) {
ResVal = getValue(Record, Slot, InstNum, Ty);
return ResVal == nullptr;
@@ -694,7 +694,7 @@ private:
/// Version of getValue that returns ResVal directly, or 0 if there is an
/// error.
- Value *getValue(const SmallVectorImpl<uint64_t> &Record, unsigned Slot,
+ Value *getValue(const SmallVectorImpl<uint64_t> &Record, unsigned Slot,
unsigned InstNum, Type *Ty) {
if (Slot == Record.size()) return nullptr;
unsigned ValNo = (unsigned)Record[Slot];
@@ -705,7 +705,7 @@ private:
}
/// Like getValue, but decodes signed VBRs.
- Value *getValueSigned(const SmallVectorImpl<uint64_t> &Record, unsigned Slot,
+ Value *getValueSigned(const SmallVectorImpl<uint64_t> &Record, unsigned Slot,
unsigned InstNum, Type *Ty) {
if (Slot == Record.size()) return nullptr;
unsigned ValNo = (unsigned)decodeSignRotatedValue(Record[Slot]);
@@ -715,9 +715,9 @@ private:
return getFnValueByID(ValNo, Ty);
}
- /// Upgrades old-style typeless byval or sret attributes by adding the
- /// corresponding argument's pointee type.
- void propagateByValSRetTypes(CallBase *CB, ArrayRef<Type *> ArgsFullTys);
+ /// Upgrades old-style typeless byval or sret attributes by adding the
+ /// corresponding argument's pointee type.
+ void propagateByValSRetTypes(CallBase *CB, ArrayRef<Type *> ArgsFullTys);
/// Converts alignment exponent (i.e. power of two (or zero)) to the
/// corresponding alignment to use. If alignment is too large, returns
@@ -833,8 +833,8 @@ private:
void parseTypeIdCompatibleVtableSummaryRecord(ArrayRef<uint64_t> Record);
void parseTypeIdCompatibleVtableInfo(ArrayRef<uint64_t> Record, size_t &Slot,
TypeIdCompatibleVtableInfo &TypeId);
- std::vector<FunctionSummary::ParamAccess>
- parseParamAccesses(ArrayRef<uint64_t> Record);
+ std::vector<FunctionSummary::ParamAccess>
+ parseParamAccesses(ArrayRef<uint64_t> Record);
std::pair<ValueInfo, GlobalValue::GUID>
getValueInfoFromValueId(unsigned ValueId);
@@ -1433,8 +1433,8 @@ static Attribute::AttrKind getAttrFromCode(uint64_t Code) {
return Attribute::NoAlias;
case bitc::ATTR_KIND_NO_BUILTIN:
return Attribute::NoBuiltin;
- case bitc::ATTR_KIND_NO_CALLBACK:
- return Attribute::NoCallback;
+ case bitc::ATTR_KIND_NO_CALLBACK:
+ return Attribute::NoCallback;
case bitc::ATTR_KIND_NO_CAPTURE:
return Attribute::NoCapture;
case bitc::ATTR_KIND_NO_DUPLICATE:
@@ -1535,12 +1535,12 @@ static Attribute::AttrKind getAttrFromCode(uint64_t Code) {
return Attribute::Preallocated;
case bitc::ATTR_KIND_NOUNDEF:
return Attribute::NoUndef;
- case bitc::ATTR_KIND_BYREF:
- return Attribute::ByRef;
- case bitc::ATTR_KIND_MUSTPROGRESS:
- return Attribute::MustProgress;
- case bitc::ATTR_KIND_HOT:
- return Attribute::Hot;
+ case bitc::ATTR_KIND_BYREF:
+ return Attribute::ByRef;
+ case bitc::ATTR_KIND_MUSTPROGRESS:
+ return Attribute::MustProgress;
+ case bitc::ATTR_KIND_HOT:
+ return Attribute::Hot;
}
}
@@ -1615,8 +1615,8 @@ Error BitcodeReader::parseAttributeGroupBlock() {
// this AttributeList with a function.
if (Kind == Attribute::ByVal)
B.addByValAttr(nullptr);
- else if (Kind == Attribute::StructRet)
- B.addStructRetAttr(nullptr);
+ else if (Kind == Attribute::StructRet)
+ B.addStructRetAttr(nullptr);
B.addAttribute(Kind);
} else if (Record[i] == 1) { // Integer attribute
@@ -1660,10 +1660,10 @@ Error BitcodeReader::parseAttributeGroupBlock() {
return Err;
if (Kind == Attribute::ByVal) {
B.addByValAttr(HasType ? getTypeByID(Record[++i]) : nullptr);
- } else if (Kind == Attribute::StructRet) {
- B.addStructRetAttr(HasType ? getTypeByID(Record[++i]) : nullptr);
- } else if (Kind == Attribute::ByRef) {
- B.addByRefAttr(getTypeByID(Record[++i]));
+ } else if (Kind == Attribute::StructRet) {
+ B.addStructRetAttr(HasType ? getTypeByID(Record[++i]) : nullptr);
+ } else if (Kind == Attribute::ByRef) {
+ B.addByRefAttr(getTypeByID(Record[++i]));
} else if (Kind == Attribute::Preallocated) {
B.addPreallocatedAttr(getTypeByID(Record[++i]));
}
@@ -1726,7 +1726,7 @@ Error BitcodeReader::parseTypeTableBody() {
case bitc::TYPE_CODE_NUMENTRY: // TYPE_CODE_NUMENTRY: [numentries]
// TYPE_CODE_NUMENTRY contains a count of the number of types in the
// type list. This allows us to reserve space.
- if (Record.empty())
+ if (Record.empty())
return error("Invalid record");
TypeList.resize(Record[0]);
continue;
@@ -1763,14 +1763,14 @@ Error BitcodeReader::parseTypeTableBody() {
case bitc::TYPE_CODE_X86_MMX: // X86_MMX
ResultTy = Type::getX86_MMXTy(Context);
break;
- case bitc::TYPE_CODE_X86_AMX: // X86_AMX
- ResultTy = Type::getX86_AMXTy(Context);
- break;
+ case bitc::TYPE_CODE_X86_AMX: // X86_AMX
+ ResultTy = Type::getX86_AMXTy(Context);
+ break;
case bitc::TYPE_CODE_TOKEN: // TOKEN
ResultTy = Type::getTokenTy(Context);
break;
case bitc::TYPE_CODE_INTEGER: { // INTEGER: [width]
- if (Record.empty())
+ if (Record.empty())
return error("Invalid record");
uint64_t NumBits = Record[0];
@@ -1782,7 +1782,7 @@ Error BitcodeReader::parseTypeTableBody() {
}
case bitc::TYPE_CODE_POINTER: { // POINTER: [pointee type] or
// [pointee type, address space]
- if (Record.empty())
+ if (Record.empty())
return error("Invalid record");
unsigned AddressSpace = 0;
if (Record.size() == 2)
@@ -1837,7 +1837,7 @@ Error BitcodeReader::parseTypeTableBody() {
break;
}
case bitc::TYPE_CODE_STRUCT_ANON: { // STRUCT: [ispacked, eltty x N]
- if (Record.empty())
+ if (Record.empty())
return error("Invalid record");
SmallVector<Type*, 8> EltTys;
for (unsigned i = 1, e = Record.size(); i != e; ++i) {
@@ -1857,7 +1857,7 @@ Error BitcodeReader::parseTypeTableBody() {
continue;
case bitc::TYPE_CODE_STRUCT_NAMED: { // STRUCT: [ispacked, eltty x N]
- if (Record.empty())
+ if (Record.empty())
return error("Invalid record");
if (NumRecords >= TypeList.size())
@@ -2417,9 +2417,9 @@ Error BitcodeReader::parseConstants() {
case bitc::CST_CODE_UNDEF: // UNDEF
V = UndefValue::get(CurTy);
break;
- case bitc::CST_CODE_POISON: // POISON
- V = PoisonValue::get(CurTy);
- break;
+ case bitc::CST_CODE_POISON: // POISON
+ V = PoisonValue::get(CurTy);
+ break;
case bitc::CST_CODE_SETTYPE: // SETTYPE: [typeid]
if (Record.empty())
return error("Invalid record");
@@ -2933,7 +2933,7 @@ Error BitcodeReader::parseUseLists() {
if (RecordLength < 3)
// Records should have at least an ID and two indexes.
return error("Invalid record");
- unsigned ID = Record.pop_back_val();
+ unsigned ID = Record.pop_back_val();
Value *V;
if (IsBB) {
@@ -2985,15 +2985,15 @@ Error BitcodeReader::materializeMetadata() {
}
// Upgrade "Linker Options" module flag to "llvm.linker.options" module-level
- // metadata. Only upgrade if the new option doesn't exist to avoid upgrade
- // multiple times.
- if (!TheModule->getNamedMetadata("llvm.linker.options")) {
- if (Metadata *Val = TheModule->getModuleFlag("Linker Options")) {
- NamedMDNode *LinkerOpts =
- TheModule->getOrInsertNamedMetadata("llvm.linker.options");
- for (const MDOperand &MDOptions : cast<MDNode>(Val)->operands())
- LinkerOpts->addOperand(cast<MDNode>(MDOptions));
- }
+ // metadata. Only upgrade if the new option doesn't exist to avoid upgrade
+ // multiple times.
+ if (!TheModule->getNamedMetadata("llvm.linker.options")) {
+ if (Metadata *Val = TheModule->getModuleFlag("Linker Options")) {
+ NamedMDNode *LinkerOpts =
+ TheModule->getOrInsertNamedMetadata("llvm.linker.options");
+ for (const MDOperand &MDOptions : cast<MDNode>(Val)->operands())
+ LinkerOpts->addOperand(cast<MDNode>(MDOptions));
+ }
}
DeferredMetadataInfo.clear();
@@ -3301,24 +3301,24 @@ Error BitcodeReader::parseFunctionRecord(ArrayRef<uint64_t> Record) {
Func->setLinkage(getDecodedLinkage(RawLinkage));
Func->setAttributes(getAttributes(Record[4]));
- // Upgrade any old-style byval or sret without a type by propagating the
- // argument's pointee type. There should be no opaque pointers where the byval
- // type is implicit.
+ // Upgrade any old-style byval or sret without a type by propagating the
+ // argument's pointee type. There should be no opaque pointers where the byval
+ // type is implicit.
for (unsigned i = 0; i != Func->arg_size(); ++i) {
- for (Attribute::AttrKind Kind : {Attribute::ByVal, Attribute::StructRet}) {
- if (!Func->hasParamAttribute(i, Kind))
- continue;
-
- Func->removeParamAttr(i, Kind);
-
- Type *PTy = cast<FunctionType>(FullFTy)->getParamType(i);
- Type *PtrEltTy = getPointerElementFlatType(PTy);
- Attribute NewAttr =
- Kind == Attribute::ByVal
- ? Attribute::getWithByValType(Context, PtrEltTy)
- : Attribute::getWithStructRetType(Context, PtrEltTy);
- Func->addParamAttr(i, NewAttr);
- }
+ for (Attribute::AttrKind Kind : {Attribute::ByVal, Attribute::StructRet}) {
+ if (!Func->hasParamAttribute(i, Kind))
+ continue;
+
+ Func->removeParamAttr(i, Kind);
+
+ Type *PTy = cast<FunctionType>(FullFTy)->getParamType(i);
+ Type *PtrEltTy = getPointerElementFlatType(PTy);
+ Attribute NewAttr =
+ Kind == Attribute::ByVal
+ ? Attribute::getWithByValType(Context, PtrEltTy)
+ : Attribute::getWithStructRetType(Context, PtrEltTy);
+ Func->addParamAttr(i, NewAttr);
+ }
}
MaybeAlign Alignment;
@@ -3738,7 +3738,7 @@ Error BitcodeReader::parseModule(uint64_t ResumeBit,
break;
/// MODULE_CODE_VSTOFFSET: [offset]
case bitc::MODULE_CODE_VSTOFFSET:
- if (Record.empty())
+ if (Record.empty())
return error("Invalid record");
// Note that we subtract 1 here because the offset is relative to one word
// before the start of the identification or module block, which was
@@ -3779,22 +3779,22 @@ Error BitcodeReader::typeCheckLoadStoreInst(Type *ValType, Type *PtrType) {
return Error::success();
}
-void BitcodeReader::propagateByValSRetTypes(CallBase *CB,
- ArrayRef<Type *> ArgsFullTys) {
+void BitcodeReader::propagateByValSRetTypes(CallBase *CB,
+ ArrayRef<Type *> ArgsFullTys) {
for (unsigned i = 0; i != CB->arg_size(); ++i) {
- for (Attribute::AttrKind Kind : {Attribute::ByVal, Attribute::StructRet}) {
- if (!CB->paramHasAttr(i, Kind))
- continue;
-
- CB->removeParamAttr(i, Kind);
-
- Type *PtrEltTy = getPointerElementFlatType(ArgsFullTys[i]);
- Attribute NewAttr =
- Kind == Attribute::ByVal
- ? Attribute::getWithByValType(Context, PtrEltTy)
- : Attribute::getWithStructRetType(Context, PtrEltTy);
- CB->addParamAttr(i, NewAttr);
- }
+ for (Attribute::AttrKind Kind : {Attribute::ByVal, Attribute::StructRet}) {
+ if (!CB->paramHasAttr(i, Kind))
+ continue;
+
+ CB->removeParamAttr(i, Kind);
+
+ Type *PtrEltTy = getPointerElementFlatType(ArgsFullTys[i]);
+ Attribute NewAttr =
+ Kind == Attribute::ByVal
+ ? Attribute::getWithByValType(Context, PtrEltTy)
+ : Attribute::getWithStructRetType(Context, PtrEltTy);
+ CB->addParamAttr(i, NewAttr);
+ }
}
}
@@ -3898,7 +3898,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
default: // Default behavior: reject
return error("Invalid value");
case bitc::FUNC_CODE_DECLAREBLOCKS: { // DECLAREBLOCKS: [nblocks]
- if (Record.empty() || Record[0] == 0)
+ if (Record.empty() || Record[0] == 0)
return error("Invalid record");
// Create all the basic blocks for the function.
FunctionBBs.resize(Record[0]);
@@ -3965,8 +3965,8 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
if (!IA)
return error("Invalid record");
}
- LastLoc = DILocation::get(Scope->getContext(), Line, Col, Scope, IA,
- isImplicitCode);
+ LastLoc = DILocation::get(Scope->getContext(), Line, Col, Scope, IA,
+ isImplicitCode);
I->setDebugLoc(LastLoc);
I = nullptr;
continue;
@@ -4647,7 +4647,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
cast<InvokeInst>(I)->setCallingConv(
static_cast<CallingConv::ID>(CallingConv::MaxID & CCInfo));
cast<InvokeInst>(I)->setAttributes(PAL);
- propagateByValSRetTypes(cast<CallBase>(I), ArgsFullTys);
+ propagateByValSRetTypes(cast<CallBase>(I), ArgsFullTys);
break;
}
@@ -4741,7 +4741,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
InstructionList.push_back(I);
break;
case bitc::FUNC_CODE_INST_PHI: { // PHI: [ty, val0,bb0, ...]
- if (Record.empty())
+ if (Record.empty())
return error("Invalid record");
// The first record specifies the type.
FullTy = getFullyStructuredTypeByID(Record[0]);
@@ -4843,13 +4843,13 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
case bitc::FUNC_CODE_INST_ALLOCA: { // ALLOCA: [instty, opty, op, align]
if (Record.size() != 4)
return error("Invalid record");
- using APV = AllocaPackedValues;
- const uint64_t Rec = Record[3];
- const bool InAlloca = Bitfield::get<APV::UsedWithInAlloca>(Rec);
- const bool SwiftError = Bitfield::get<APV::SwiftError>(Rec);
+ using APV = AllocaPackedValues;
+ const uint64_t Rec = Record[3];
+ const bool InAlloca = Bitfield::get<APV::UsedWithInAlloca>(Rec);
+ const bool SwiftError = Bitfield::get<APV::SwiftError>(Rec);
FullTy = getFullyStructuredTypeByID(Record[0]);
Type *Ty = flattenPointerTypes(FullTy);
- if (!Bitfield::get<APV::ExplicitType>(Rec)) {
+ if (!Bitfield::get<APV::ExplicitType>(Rec)) {
auto *PTy = dyn_cast_or_null<PointerType>(Ty);
if (!PTy)
return error("Old-style alloca with a non-pointer type");
@@ -4858,8 +4858,8 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
Type *OpTy = getTypeByID(Record[1]);
Value *Size = getFnValueByID(Record[2], OpTy);
MaybeAlign Align;
- if (Error Err =
- parseAlignmentValue(Bitfield::get<APV::Align>(Rec), Align)) {
+ if (Error Err =
+ parseAlignmentValue(Bitfield::get<APV::Align>(Rec), Align)) {
return Err;
}
if (!Ty || !Size)
@@ -5016,55 +5016,55 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
InstructionList.push_back(I);
break;
}
- case bitc::FUNC_CODE_INST_CMPXCHG_OLD: {
- // CMPXCHG_OLD: [ptrty, ptr, cmp, val, vol, ordering, synchscope,
- // failure_ordering?, weak?]
- const size_t NumRecords = Record.size();
+ case bitc::FUNC_CODE_INST_CMPXCHG_OLD: {
+ // CMPXCHG_OLD: [ptrty, ptr, cmp, val, vol, ordering, synchscope,
+ // failure_ordering?, weak?]
+ const size_t NumRecords = Record.size();
unsigned OpNum = 0;
- Value *Ptr = nullptr;
+ Value *Ptr = nullptr;
if (getValueTypePair(Record, OpNum, NextValueNo, Ptr, &FullTy))
return error("Invalid record");
if (!isa<PointerType>(Ptr->getType()))
return error("Cmpxchg operand is not a pointer type");
- Value *Cmp = nullptr;
- if (popValue(Record, OpNum, NextValueNo,
- getPointerElementFlatType(FullTy), Cmp))
+ Value *Cmp = nullptr;
+ if (popValue(Record, OpNum, NextValueNo,
+ getPointerElementFlatType(FullTy), Cmp))
return error("Invalid record");
- FullTy = cast<PointerType>(FullTy)->getElementType();
-
- Value *New = nullptr;
+ FullTy = cast<PointerType>(FullTy)->getElementType();
+
+ Value *New = nullptr;
if (popValue(Record, OpNum, NextValueNo, Cmp->getType(), New) ||
- NumRecords < OpNum + 3 || NumRecords > OpNum + 5)
+ NumRecords < OpNum + 3 || NumRecords > OpNum + 5)
return error("Invalid record");
- const AtomicOrdering SuccessOrdering =
- getDecodedOrdering(Record[OpNum + 1]);
+ const AtomicOrdering SuccessOrdering =
+ getDecodedOrdering(Record[OpNum + 1]);
if (SuccessOrdering == AtomicOrdering::NotAtomic ||
SuccessOrdering == AtomicOrdering::Unordered)
return error("Invalid record");
- const SyncScope::ID SSID = getDecodedSyncScopeID(Record[OpNum + 2]);
-
+ const SyncScope::ID SSID = getDecodedSyncScopeID(Record[OpNum + 2]);
+
if (Error Err = typeCheckLoadStoreInst(Cmp->getType(), Ptr->getType()))
return Err;
- const AtomicOrdering FailureOrdering =
- NumRecords < 7
- ? AtomicCmpXchgInst::getStrongestFailureOrdering(SuccessOrdering)
- : getDecodedOrdering(Record[OpNum + 3]);
-
- const Align Alignment(
+ const AtomicOrdering FailureOrdering =
+ NumRecords < 7
+ ? AtomicCmpXchgInst::getStrongestFailureOrdering(SuccessOrdering)
+ : getDecodedOrdering(Record[OpNum + 3]);
+
+ const Align Alignment(
TheModule->getDataLayout().getTypeStoreSize(Cmp->getType()));
-
+
I = new AtomicCmpXchgInst(Ptr, Cmp, New, Alignment, SuccessOrdering,
FailureOrdering, SSID);
- cast<AtomicCmpXchgInst>(I)->setVolatile(Record[OpNum]);
+ cast<AtomicCmpXchgInst>(I)->setVolatile(Record[OpNum]);
FullTy = StructType::get(Context, {FullTy, Type::getInt1Ty(Context)});
- if (NumRecords < 8) {
+ if (NumRecords < 8) {
// Before weak cmpxchgs existed, the instruction simply returned the
// value loaded from memory, so bitcode files from that era will be
// expecting the first component of a modern cmpxchg.
@@ -5072,59 +5072,59 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
I = ExtractValueInst::Create(I, 0);
FullTy = cast<StructType>(FullTy)->getElementType(0);
} else {
- cast<AtomicCmpXchgInst>(I)->setWeak(Record[OpNum + 4]);
+ cast<AtomicCmpXchgInst>(I)->setWeak(Record[OpNum + 4]);
}
InstructionList.push_back(I);
break;
}
- case bitc::FUNC_CODE_INST_CMPXCHG: {
- // CMPXCHG: [ptrty, ptr, cmp, val, vol, success_ordering, synchscope,
- // failure_ordering, weak]
- const size_t NumRecords = Record.size();
- unsigned OpNum = 0;
- Value *Ptr = nullptr;
- if (getValueTypePair(Record, OpNum, NextValueNo, Ptr, &FullTy))
- return error("Invalid record");
-
- if (!isa<PointerType>(Ptr->getType()))
- return error("Cmpxchg operand is not a pointer type");
-
- Value *Cmp = nullptr;
- if (getValueTypePair(Record, OpNum, NextValueNo, Cmp, &FullTy))
- return error("Invalid record");
-
- Value *Val = nullptr;
- if (popValue(Record, OpNum, NextValueNo, Cmp->getType(), Val) ||
- NumRecords < OpNum + 3 || NumRecords > OpNum + 5)
- return error("Invalid record");
-
- const AtomicOrdering SuccessOrdering =
- getDecodedOrdering(Record[OpNum + 1]);
- if (SuccessOrdering == AtomicOrdering::NotAtomic ||
- SuccessOrdering == AtomicOrdering::Unordered)
- return error("Invalid record");
-
- const SyncScope::ID SSID = getDecodedSyncScopeID(Record[OpNum + 2]);
-
- if (Error Err = typeCheckLoadStoreInst(Cmp->getType(), Ptr->getType()))
- return Err;
-
- const AtomicOrdering FailureOrdering =
- getDecodedOrdering(Record[OpNum + 3]);
-
- const Align Alignment(
- TheModule->getDataLayout().getTypeStoreSize(Cmp->getType()));
-
- I = new AtomicCmpXchgInst(Ptr, Cmp, Val, Alignment, SuccessOrdering,
- FailureOrdering, SSID);
- FullTy = StructType::get(Context, {FullTy, Type::getInt1Ty(Context)});
- cast<AtomicCmpXchgInst>(I)->setVolatile(Record[OpNum]);
- cast<AtomicCmpXchgInst>(I)->setWeak(Record[OpNum + 4]);
-
- InstructionList.push_back(I);
- break;
- }
+ case bitc::FUNC_CODE_INST_CMPXCHG: {
+ // CMPXCHG: [ptrty, ptr, cmp, val, vol, success_ordering, synchscope,
+ // failure_ordering, weak]
+ const size_t NumRecords = Record.size();
+ unsigned OpNum = 0;
+ Value *Ptr = nullptr;
+ if (getValueTypePair(Record, OpNum, NextValueNo, Ptr, &FullTy))
+ return error("Invalid record");
+
+ if (!isa<PointerType>(Ptr->getType()))
+ return error("Cmpxchg operand is not a pointer type");
+
+ Value *Cmp = nullptr;
+ if (getValueTypePair(Record, OpNum, NextValueNo, Cmp, &FullTy))
+ return error("Invalid record");
+
+ Value *Val = nullptr;
+ if (popValue(Record, OpNum, NextValueNo, Cmp->getType(), Val) ||
+ NumRecords < OpNum + 3 || NumRecords > OpNum + 5)
+ return error("Invalid record");
+
+ const AtomicOrdering SuccessOrdering =
+ getDecodedOrdering(Record[OpNum + 1]);
+ if (SuccessOrdering == AtomicOrdering::NotAtomic ||
+ SuccessOrdering == AtomicOrdering::Unordered)
+ return error("Invalid record");
+
+ const SyncScope::ID SSID = getDecodedSyncScopeID(Record[OpNum + 2]);
+
+ if (Error Err = typeCheckLoadStoreInst(Cmp->getType(), Ptr->getType()))
+ return Err;
+
+ const AtomicOrdering FailureOrdering =
+ getDecodedOrdering(Record[OpNum + 3]);
+
+ const Align Alignment(
+ TheModule->getDataLayout().getTypeStoreSize(Cmp->getType()));
+
+ I = new AtomicCmpXchgInst(Ptr, Cmp, Val, Alignment, SuccessOrdering,
+ FailureOrdering, SSID);
+ FullTy = StructType::get(Context, {FullTy, Type::getInt1Ty(Context)});
+ cast<AtomicCmpXchgInst>(I)->setVolatile(Record[OpNum]);
+ cast<AtomicCmpXchgInst>(I)->setWeak(Record[OpNum + 4]);
+
+ InstructionList.push_back(I);
+ break;
+ }
case bitc::FUNC_CODE_INST_ATOMICRMW: {
// ATOMICRMW:[ptrty, ptr, val, op, vol, ordering, ssid]
unsigned OpNum = 0;
@@ -5254,7 +5254,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
TCK = CallInst::TCK_NoTail;
cast<CallInst>(I)->setTailCallKind(TCK);
cast<CallInst>(I)->setAttributes(PAL);
- propagateByValSRetTypes(cast<CallBase>(I), ArgsFullTys);
+ propagateByValSRetTypes(cast<CallBase>(I), ArgsFullTys);
if (FMF.any()) {
if (!isa<FPMathOperator>(I))
return error("Fast-math-flags specified for call without "
@@ -5282,7 +5282,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
// number of operand bundle blocks. These blocks are read into
// OperandBundles and consumed at the next call or invoke instruction.
- if (Record.empty() || Record[0] >= BundleTags.size())
+ if (Record.empty() || Record[0] >= BundleTags.size())
return error("Invalid record");
std::vector<Value *> Inputs;
@@ -5472,36 +5472,36 @@ Error BitcodeReader::materialize(GlobalValue *GV) {
}
}
- // "Upgrade" older incorrect branch weights by dropping them.
- for (auto &I : instructions(F)) {
- if (auto *MD = I.getMetadata(LLVMContext::MD_prof)) {
- if (MD->getOperand(0) != nullptr && isa<MDString>(MD->getOperand(0))) {
- MDString *MDS = cast<MDString>(MD->getOperand(0));
- StringRef ProfName = MDS->getString();
- // Check consistency of !prof branch_weights metadata.
- if (!ProfName.equals("branch_weights"))
- continue;
- unsigned ExpectedNumOperands = 0;
- if (BranchInst *BI = dyn_cast<BranchInst>(&I))
- ExpectedNumOperands = BI->getNumSuccessors();
- else if (SwitchInst *SI = dyn_cast<SwitchInst>(&I))
- ExpectedNumOperands = SI->getNumSuccessors();
- else if (isa<CallInst>(&I))
- ExpectedNumOperands = 1;
- else if (IndirectBrInst *IBI = dyn_cast<IndirectBrInst>(&I))
- ExpectedNumOperands = IBI->getNumDestinations();
- else if (isa<SelectInst>(&I))
- ExpectedNumOperands = 2;
- else
- continue; // ignore and continue.
-
- // If branch weight doesn't match, just strip branch weight.
- if (MD->getNumOperands() != 1 + ExpectedNumOperands)
- I.setMetadata(LLVMContext::MD_prof, nullptr);
- }
- }
- }
-
+ // "Upgrade" older incorrect branch weights by dropping them.
+ for (auto &I : instructions(F)) {
+ if (auto *MD = I.getMetadata(LLVMContext::MD_prof)) {
+ if (MD->getOperand(0) != nullptr && isa<MDString>(MD->getOperand(0))) {
+ MDString *MDS = cast<MDString>(MD->getOperand(0));
+ StringRef ProfName = MDS->getString();
+ // Check consistency of !prof branch_weights metadata.
+ if (!ProfName.equals("branch_weights"))
+ continue;
+ unsigned ExpectedNumOperands = 0;
+ if (BranchInst *BI = dyn_cast<BranchInst>(&I))
+ ExpectedNumOperands = BI->getNumSuccessors();
+ else if (SwitchInst *SI = dyn_cast<SwitchInst>(&I))
+ ExpectedNumOperands = SI->getNumSuccessors();
+ else if (isa<CallInst>(&I))
+ ExpectedNumOperands = 1;
+ else if (IndirectBrInst *IBI = dyn_cast<IndirectBrInst>(&I))
+ ExpectedNumOperands = IBI->getNumDestinations();
+ else if (isa<SelectInst>(&I))
+ ExpectedNumOperands = 2;
+ else
+ continue; // ignore and continue.
+
+ // If branch weight doesn't match, just strip branch weight.
+ if (MD->getNumOperands() != 1 + ExpectedNumOperands)
+ I.setMetadata(LLVMContext::MD_prof, nullptr);
+ }
+ }
+ }
+
// Look for functions that rely on old function attribute behavior.
UpgradeFunctionAttributes(*F);
@@ -5815,7 +5815,7 @@ Error ModuleSummaryIndexBitcodeReader::parseModule() {
}
/// MODULE_CODE_VSTOFFSET: [offset]
case bitc::MODULE_CODE_VSTOFFSET:
- if (Record.empty())
+ if (Record.empty())
return error("Invalid record");
// Note that we subtract 1 here because the offset is relative to one
// word before the start of the identification or module block, which
@@ -5933,8 +5933,8 @@ static void parseTypeIdSummaryRecord(ArrayRef<uint64_t> Record,
parseWholeProgramDevirtResolution(Record, Strtab, Slot, TypeId);
}
-std::vector<FunctionSummary::ParamAccess>
-ModuleSummaryIndexBitcodeReader::parseParamAccesses(ArrayRef<uint64_t> Record) {
+std::vector<FunctionSummary::ParamAccess>
+ModuleSummaryIndexBitcodeReader::parseParamAccesses(ArrayRef<uint64_t> Record) {
auto ReadRange = [&]() {
APInt Lower(FunctionSummary::ParamAccess::RangeWidth,
BitcodeReader::decodeSignRotatedValue(Record.front()));
@@ -5960,7 +5960,7 @@ ModuleSummaryIndexBitcodeReader::parseParamAccesses(ArrayRef<uint64_t> Record) {
for (auto &Call : ParamAccess.Calls) {
Call.ParamNo = Record.front();
Record = Record.drop_front();
- Call.Callee = getValueInfoFromValueId(Record.front()).first;
+ Call.Callee = getValueInfoFromValueId(Record.front()).first;
Record = Record.drop_front();
Call.Offsets = ReadRange();
}
@@ -6357,7 +6357,7 @@ Error ModuleSummaryIndexBitcodeReader::parseEntireSummary(unsigned ID) {
}
case bitc::FS_TYPE_TESTS:
assert(PendingTypeTests.empty());
- llvm::append_range(PendingTypeTests, Record);
+ llvm::append_range(PendingTypeTests, Record);
break;
case bitc::FS_TYPE_TEST_ASSUME_VCALLS:
diff --git a/contrib/libs/llvm12/lib/Bitcode/Reader/MetadataLoader.cpp b/contrib/libs/llvm12/lib/Bitcode/Reader/MetadataLoader.cpp
index 8cdda62870..4f517ef277 100644
--- a/contrib/libs/llvm12/lib/Bitcode/Reader/MetadataLoader.cpp
+++ b/contrib/libs/llvm12/lib/Bitcode/Reader/MetadataLoader.cpp
@@ -365,7 +365,7 @@ public:
~PlaceholderQueue() {
assert(empty() && "PlaceholderQueue hasn't been flushed before being destroyed");
}
- bool empty() const { return PHs.empty(); }
+ bool empty() const { return PHs.empty(); }
DistinctMDOperandPlaceholder &getPlaceholderOp(unsigned ID);
void flush(BitcodeReaderMetadataList &MetadataList);
@@ -438,20 +438,20 @@ class MetadataLoader::MetadataLoaderImpl {
/// Index that keeps track of where to find a metadata record in the stream.
std::vector<uint64_t> GlobalMetadataBitPosIndex;
- /// Cursor position of the start of the global decl attachments, to enable
- /// loading using the index built for lazy loading, instead of forward
- /// references.
- uint64_t GlobalDeclAttachmentPos = 0;
-
-#ifndef NDEBUG
- /// Sanity check that we end up parsing all of the global decl attachments.
- unsigned NumGlobalDeclAttachSkipped = 0;
- unsigned NumGlobalDeclAttachParsed = 0;
-#endif
-
- /// Load the global decl attachments, using the index built for lazy loading.
- Expected<bool> loadGlobalDeclAttachments();
-
+ /// Cursor position of the start of the global decl attachments, to enable
+ /// loading using the index built for lazy loading, instead of forward
+ /// references.
+ uint64_t GlobalDeclAttachmentPos = 0;
+
+#ifndef NDEBUG
+ /// Sanity check that we end up parsing all of the global decl attachments.
+ unsigned NumGlobalDeclAttachSkipped = 0;
+ unsigned NumGlobalDeclAttachParsed = 0;
+#endif
+
+ /// Load the global decl attachments, using the index built for lazy loading.
+ Expected<bool> loadGlobalDeclAttachments();
+
/// Populate the index above to enable lazily loading of metadata, and load
/// the named metadata as well as the transitively referenced global
/// Metadata.
@@ -676,7 +676,7 @@ public:
return FunctionsWithSPs.lookup(F);
}
- bool hasSeenOldLoopTags() const { return HasSeenOldLoopTags; }
+ bool hasSeenOldLoopTags() const { return HasSeenOldLoopTags; }
Error parseMetadataAttachment(
Function &F, const SmallVectorImpl<Instruction *> &InstructionList);
@@ -684,7 +684,7 @@ public:
Error parseMetadataKinds();
void setStripTBAA(bool Value) { StripTBAA = Value; }
- bool isStrippingTBAA() const { return StripTBAA; }
+ bool isStrippingTBAA() const { return StripTBAA; }
unsigned size() const { return MetadataList.size(); }
void shrinkTo(unsigned N) { MetadataList.shrinkTo(N); }
@@ -695,10 +695,10 @@ Expected<bool>
MetadataLoader::MetadataLoaderImpl::lazyLoadModuleMetadataBlock() {
IndexCursor = Stream;
SmallVector<uint64_t, 64> Record;
- GlobalDeclAttachmentPos = 0;
+ GlobalDeclAttachmentPos = 0;
// Get the abbrevs, and preload record positions to make them lazy-loadable.
while (true) {
- uint64_t SavedPos = IndexCursor.GetCurrentBitNo();
+ uint64_t SavedPos = IndexCursor.GetCurrentBitNo();
Expected<BitstreamEntry> MaybeEntry = IndexCursor.advanceSkippingSubblocks(
BitstreamCursor::AF_DontPopBlockAtEnd);
if (!MaybeEntry)
@@ -833,11 +833,11 @@ MetadataLoader::MetadataLoaderImpl::lazyLoadModuleMetadataBlock() {
break;
}
case bitc::METADATA_GLOBAL_DECL_ATTACHMENT: {
- if (!GlobalDeclAttachmentPos)
- GlobalDeclAttachmentPos = SavedPos;
-#ifndef NDEBUG
- NumGlobalDeclAttachSkipped++;
-#endif
+ if (!GlobalDeclAttachmentPos)
+ GlobalDeclAttachmentPos = SavedPos;
+#ifndef NDEBUG
+ NumGlobalDeclAttachSkipped++;
+#endif
break;
}
case bitc::METADATA_KIND:
@@ -852,7 +852,7 @@ MetadataLoader::MetadataLoaderImpl::lazyLoadModuleMetadataBlock() {
case bitc::METADATA_SUBRANGE:
case bitc::METADATA_ENUMERATOR:
case bitc::METADATA_BASIC_TYPE:
- case bitc::METADATA_STRING_TYPE:
+ case bitc::METADATA_STRING_TYPE:
case bitc::METADATA_DERIVED_TYPE:
case bitc::METADATA_COMPOSITE_TYPE:
case bitc::METADATA_SUBROUTINE_TYPE:
@@ -875,7 +875,7 @@ MetadataLoader::MetadataLoaderImpl::lazyLoadModuleMetadataBlock() {
case bitc::METADATA_OBJC_PROPERTY:
case bitc::METADATA_IMPORTED_ENTITY:
case bitc::METADATA_GLOBAL_VAR_EXPR:
- case bitc::METADATA_GENERIC_SUBRANGE:
+ case bitc::METADATA_GENERIC_SUBRANGE:
// We don't expect to see any of these, if we see one, give up on
// lazy-loading and fallback.
MDStringRef.clear();
@@ -888,83 +888,83 @@ MetadataLoader::MetadataLoaderImpl::lazyLoadModuleMetadataBlock() {
}
}
-// Load the global decl attachments after building the lazy loading index.
-// We don't load them "lazily" - all global decl attachments must be
-// parsed since they aren't materialized on demand. However, by delaying
-// their parsing until after the index is created, we can use the index
-// instead of creating temporaries.
-Expected<bool> MetadataLoader::MetadataLoaderImpl::loadGlobalDeclAttachments() {
- // Nothing to do if we didn't find any of these metadata records.
- if (!GlobalDeclAttachmentPos)
- return true;
- // Use a temporary cursor so that we don't mess up the main Stream cursor or
- // the lazy loading IndexCursor (which holds the necessary abbrev ids).
- BitstreamCursor TempCursor = Stream;
- SmallVector<uint64_t, 64> Record;
- // Jump to the position before the first global decl attachment, so we can
- // scan for the first BitstreamEntry record.
- if (Error Err = TempCursor.JumpToBit(GlobalDeclAttachmentPos))
- return std::move(Err);
- while (true) {
- Expected<BitstreamEntry> MaybeEntry = TempCursor.advanceSkippingSubblocks(
- BitstreamCursor::AF_DontPopBlockAtEnd);
- if (!MaybeEntry)
- return MaybeEntry.takeError();
- BitstreamEntry Entry = MaybeEntry.get();
-
- switch (Entry.Kind) {
- case BitstreamEntry::SubBlock: // Handled for us already.
- case BitstreamEntry::Error:
- return error("Malformed block");
- case BitstreamEntry::EndBlock:
- // Sanity check that we parsed them all.
- assert(NumGlobalDeclAttachSkipped == NumGlobalDeclAttachParsed);
- return true;
- case BitstreamEntry::Record:
- break;
- }
- uint64_t CurrentPos = TempCursor.GetCurrentBitNo();
- Expected<unsigned> MaybeCode = TempCursor.skipRecord(Entry.ID);
- if (!MaybeCode)
- return MaybeCode.takeError();
- if (MaybeCode.get() != bitc::METADATA_GLOBAL_DECL_ATTACHMENT) {
- // Anything other than a global decl attachment signals the end of
- // these records. sanity check that we parsed them all.
- assert(NumGlobalDeclAttachSkipped == NumGlobalDeclAttachParsed);
- return true;
- }
-#ifndef NDEBUG
- NumGlobalDeclAttachParsed++;
-#endif
- // FIXME: we need to do this early because we don't materialize global
- // value explicitly.
- if (Error Err = TempCursor.JumpToBit(CurrentPos))
- return std::move(Err);
- Record.clear();
- if (Expected<unsigned> MaybeRecord =
- TempCursor.readRecord(Entry.ID, Record))
- ;
- else
- return MaybeRecord.takeError();
- if (Record.size() % 2 == 0)
- return error("Invalid record");
- unsigned ValueID = Record[0];
- if (ValueID >= ValueList.size())
- return error("Invalid record");
- if (auto *GO = dyn_cast<GlobalObject>(ValueList[ValueID])) {
- // Need to save and restore the current position since
- // parseGlobalObjectAttachment will resolve all forward references which
- // would require parsing from locations stored in the index.
- CurrentPos = TempCursor.GetCurrentBitNo();
- if (Error Err = parseGlobalObjectAttachment(
- *GO, ArrayRef<uint64_t>(Record).slice(1)))
- return std::move(Err);
- if (Error Err = TempCursor.JumpToBit(CurrentPos))
- return std::move(Err);
- }
- }
-}
-
+// Load the global decl attachments after building the lazy loading index.
+// We don't load them "lazily" - all global decl attachments must be
+// parsed since they aren't materialized on demand. However, by delaying
+// their parsing until after the index is created, we can use the index
+// instead of creating temporaries.
+Expected<bool> MetadataLoader::MetadataLoaderImpl::loadGlobalDeclAttachments() {
+ // Nothing to do if we didn't find any of these metadata records.
+ if (!GlobalDeclAttachmentPos)
+ return true;
+ // Use a temporary cursor so that we don't mess up the main Stream cursor or
+ // the lazy loading IndexCursor (which holds the necessary abbrev ids).
+ BitstreamCursor TempCursor = Stream;
+ SmallVector<uint64_t, 64> Record;
+ // Jump to the position before the first global decl attachment, so we can
+ // scan for the first BitstreamEntry record.
+ if (Error Err = TempCursor.JumpToBit(GlobalDeclAttachmentPos))
+ return std::move(Err);
+ while (true) {
+ Expected<BitstreamEntry> MaybeEntry = TempCursor.advanceSkippingSubblocks(
+ BitstreamCursor::AF_DontPopBlockAtEnd);
+ if (!MaybeEntry)
+ return MaybeEntry.takeError();
+ BitstreamEntry Entry = MaybeEntry.get();
+
+ switch (Entry.Kind) {
+ case BitstreamEntry::SubBlock: // Handled for us already.
+ case BitstreamEntry::Error:
+ return error("Malformed block");
+ case BitstreamEntry::EndBlock:
+ // Sanity check that we parsed them all.
+ assert(NumGlobalDeclAttachSkipped == NumGlobalDeclAttachParsed);
+ return true;
+ case BitstreamEntry::Record:
+ break;
+ }
+ uint64_t CurrentPos = TempCursor.GetCurrentBitNo();
+ Expected<unsigned> MaybeCode = TempCursor.skipRecord(Entry.ID);
+ if (!MaybeCode)
+ return MaybeCode.takeError();
+ if (MaybeCode.get() != bitc::METADATA_GLOBAL_DECL_ATTACHMENT) {
+ // Anything other than a global decl attachment signals the end of
+ // these records. sanity check that we parsed them all.
+ assert(NumGlobalDeclAttachSkipped == NumGlobalDeclAttachParsed);
+ return true;
+ }
+#ifndef NDEBUG
+ NumGlobalDeclAttachParsed++;
+#endif
+ // FIXME: we need to do this early because we don't materialize global
+ // value explicitly.
+ if (Error Err = TempCursor.JumpToBit(CurrentPos))
+ return std::move(Err);
+ Record.clear();
+ if (Expected<unsigned> MaybeRecord =
+ TempCursor.readRecord(Entry.ID, Record))
+ ;
+ else
+ return MaybeRecord.takeError();
+ if (Record.size() % 2 == 0)
+ return error("Invalid record");
+ unsigned ValueID = Record[0];
+ if (ValueID >= ValueList.size())
+ return error("Invalid record");
+ if (auto *GO = dyn_cast<GlobalObject>(ValueList[ValueID])) {
+ // Need to save and restore the current position since
+ // parseGlobalObjectAttachment will resolve all forward references which
+ // would require parsing from locations stored in the index.
+ CurrentPos = TempCursor.GetCurrentBitNo();
+ if (Error Err = parseGlobalObjectAttachment(
+ *GO, ArrayRef<uint64_t>(Record).slice(1)))
+ return std::move(Err);
+ if (Error Err = TempCursor.JumpToBit(CurrentPos))
+ return std::move(Err);
+ }
+ }
+}
+
/// Parse a METADATA_BLOCK. If ModuleLevel is true then we are parsing
/// module level metadata.
Error MetadataLoader::MetadataLoaderImpl::parseMetadata(bool ModuleLevel) {
@@ -994,14 +994,14 @@ Error MetadataLoader::MetadataLoaderImpl::parseMetadata(bool ModuleLevel) {
MetadataList.resize(MDStringRef.size() +
GlobalMetadataBitPosIndex.size());
- // Now that we have built the index, load the global decl attachments
- // that were deferred during that process. This avoids creating
- // temporaries.
- SuccessOrErr = loadGlobalDeclAttachments();
- if (!SuccessOrErr)
- return SuccessOrErr.takeError();
- assert(SuccessOrErr.get());
-
+ // Now that we have built the index, load the global decl attachments
+ // that were deferred during that process. This avoids creating
+ // temporaries.
+ SuccessOrErr = loadGlobalDeclAttachments();
+ if (!SuccessOrErr)
+ return SuccessOrErr.takeError();
+ assert(SuccessOrErr.get());
+
// Reading the named metadata created forward references and/or
// placeholders, that we flush here.
resolveForwardRefsAndPlaceholders(Placeholders);
@@ -1372,18 +1372,18 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
NextMetadataNo++;
break;
}
- case bitc::METADATA_GENERIC_SUBRANGE: {
- Metadata *Val = nullptr;
- Val = GET_OR_DISTINCT(DIGenericSubrange,
- (Context, getMDOrNull(Record[1]),
- getMDOrNull(Record[2]), getMDOrNull(Record[3]),
- getMDOrNull(Record[4])));
-
- MetadataList.assignValue(Val, NextMetadataNo);
- IsDistinct = Record[0] & 1;
- NextMetadataNo++;
- break;
- }
+ case bitc::METADATA_GENERIC_SUBRANGE: {
+ Metadata *Val = nullptr;
+ Val = GET_OR_DISTINCT(DIGenericSubrange,
+ (Context, getMDOrNull(Record[1]),
+ getMDOrNull(Record[2]), getMDOrNull(Record[3]),
+ getMDOrNull(Record[4])));
+
+ MetadataList.assignValue(Val, NextMetadataNo);
+ IsDistinct = Record[0] & 1;
+ NextMetadataNo++;
+ break;
+ }
case bitc::METADATA_ENUMERATOR: {
if (Record.size() < 3)
return error("Invalid record");
@@ -1423,20 +1423,20 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
NextMetadataNo++;
break;
}
- case bitc::METADATA_STRING_TYPE: {
- if (Record.size() != 8)
- return error("Invalid record");
-
- IsDistinct = Record[0];
- MetadataList.assignValue(
- GET_OR_DISTINCT(DIStringType,
- (Context, Record[1], getMDString(Record[2]),
- getMDOrNull(Record[3]), getMDOrNull(Record[4]),
- Record[5], Record[6], Record[7])),
- NextMetadataNo);
- NextMetadataNo++;
- break;
- }
+ case bitc::METADATA_STRING_TYPE: {
+ if (Record.size() != 8)
+ return error("Invalid record");
+
+ IsDistinct = Record[0];
+ MetadataList.assignValue(
+ GET_OR_DISTINCT(DIStringType,
+ (Context, Record[1], getMDString(Record[2]),
+ getMDOrNull(Record[3]), getMDOrNull(Record[4]),
+ Record[5], Record[6], Record[7])),
+ NextMetadataNo);
+ NextMetadataNo++;
+ break;
+ }
case bitc::METADATA_DERIVED_TYPE: {
if (Record.size() < 12 || Record.size() > 13)
return error("Invalid record");
@@ -1462,7 +1462,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
break;
}
case bitc::METADATA_COMPOSITE_TYPE: {
- if (Record.size() < 16 || Record.size() > 21)
+ if (Record.size() < 16 || Record.size() > 21)
return error("Invalid record");
// If we have a UUID and this is not a forward declaration, lookup the
@@ -1487,9 +1487,9 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
Metadata *TemplateParams = nullptr;
Metadata *Discriminator = nullptr;
Metadata *DataLocation = nullptr;
- Metadata *Associated = nullptr;
- Metadata *Allocated = nullptr;
- Metadata *Rank = nullptr;
+ Metadata *Associated = nullptr;
+ Metadata *Allocated = nullptr;
+ Metadata *Rank = nullptr;
auto *Identifier = getMDString(Record[15]);
// If this module is being parsed so that it can be ThinLTO imported
// into another module, composite types only need to be imported
@@ -1514,21 +1514,21 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
Discriminator = getMDOrNull(Record[16]);
if (Record.size() > 17)
DataLocation = getMDOrNull(Record[17]);
- if (Record.size() > 19) {
- Associated = getMDOrNull(Record[18]);
- Allocated = getMDOrNull(Record[19]);
- }
- if (Record.size() > 20) {
- Rank = getMDOrNull(Record[20]);
- }
+ if (Record.size() > 19) {
+ Associated = getMDOrNull(Record[18]);
+ Allocated = getMDOrNull(Record[19]);
+ }
+ if (Record.size() > 20) {
+ Rank = getMDOrNull(Record[20]);
+ }
}
DICompositeType *CT = nullptr;
if (Identifier)
CT = DICompositeType::buildODRType(
Context, *Identifier, Tag, Name, File, Line, Scope, BaseType,
SizeInBits, AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
- VTableHolder, TemplateParams, Discriminator, DataLocation, Associated,
- Allocated, Rank);
+ VTableHolder, TemplateParams, Discriminator, DataLocation, Associated,
+ Allocated, Rank);
// Create a node if we didn't get a lazy ODR type.
if (!CT)
@@ -1536,8 +1536,8 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
(Context, Tag, Name, File, Line, Scope, BaseType,
SizeInBits, AlignInBits, OffsetInBits, Flags,
Elements, RuntimeLang, VTableHolder, TemplateParams,
- Identifier, Discriminator, DataLocation, Associated,
- Allocated, Rank));
+ Identifier, Discriminator, DataLocation, Associated,
+ Allocated, Rank));
if (!IsNotUsedInTypeRef && Identifier)
MetadataList.addTypeRef(*Identifier, *cast<DICompositeType>(CT));
@@ -1565,20 +1565,20 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
}
case bitc::METADATA_MODULE: {
- if (Record.size() < 5 || Record.size() > 9)
+ if (Record.size() < 5 || Record.size() > 9)
return error("Invalid record");
- unsigned Offset = Record.size() >= 8 ? 2 : 1;
+ unsigned Offset = Record.size() >= 8 ? 2 : 1;
IsDistinct = Record[0];
MetadataList.assignValue(
GET_OR_DISTINCT(
DIModule,
- (Context, Record.size() >= 8 ? getMDOrNull(Record[1]) : nullptr,
+ (Context, Record.size() >= 8 ? getMDOrNull(Record[1]) : nullptr,
getMDOrNull(Record[0 + Offset]), getMDString(Record[1 + Offset]),
getMDString(Record[2 + Offset]), getMDString(Record[3 + Offset]),
getMDString(Record[4 + Offset]),
- Record.size() <= 7 ? 0 : Record[7],
- Record.size() <= 8 ? false : Record[8])),
+ Record.size() <= 7 ? 0 : Record[7],
+ Record.size() <= 8 ? false : Record[8])),
NextMetadataNo);
NextMetadataNo++;
break;
@@ -2126,8 +2126,8 @@ Error MetadataLoader::MetadataLoaderImpl::parseGlobalObjectAttachment(
auto K = MDKindMap.find(Record[I]);
if (K == MDKindMap.end())
return error("Invalid ID");
- MDNode *MD =
- dyn_cast_or_null<MDNode>(getMetadataFwdRefOrLoad(Record[I + 1]));
+ MDNode *MD =
+ dyn_cast_or_null<MDNode>(getMetadataFwdRefOrLoad(Record[I + 1]));
if (!MD)
return error("Invalid metadata attachment: expect fwd ref to MDNode");
GO.addMetadata(K->second, *MD);
diff --git a/contrib/libs/llvm12/lib/Bitcode/Reader/ya.make b/contrib/libs/llvm12/lib/Bitcode/Reader/ya.make
index c648d2fc66..12ecee8a38 100644
--- a/contrib/libs/llvm12/lib/Bitcode/Reader/ya.make
+++ b/contrib/libs/llvm12/lib/Bitcode/Reader/ya.make
@@ -12,11 +12,11 @@ LICENSE(Apache-2.0 WITH LLVM-exception)
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
PEERDIR(
- contrib/libs/llvm12
- contrib/libs/llvm12/include
- contrib/libs/llvm12/lib/Bitstream/Reader
- contrib/libs/llvm12/lib/IR
- contrib/libs/llvm12/lib/Support
+ contrib/libs/llvm12
+ contrib/libs/llvm12/include
+ contrib/libs/llvm12/lib/Bitstream/Reader
+ contrib/libs/llvm12/lib/IR
+ contrib/libs/llvm12/lib/Support
)
ADDINCL(
diff --git a/contrib/libs/llvm12/lib/Bitcode/Writer/BitcodeWriter.cpp b/contrib/libs/llvm12/lib/Bitcode/Writer/BitcodeWriter.cpp
index 37ecb9992e..d653669bf6 100644
--- a/contrib/libs/llvm12/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/contrib/libs/llvm12/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -24,7 +24,7 @@
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
-#include "llvm/Bitcode/BitcodeCommon.h"
+#include "llvm/Bitcode/BitcodeCommon.h"
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/Bitcode/LLVMBitCodes.h"
#include "llvm/Bitstream/BitCodes.h"
@@ -86,9 +86,9 @@ static cl::opt<unsigned>
IndexThreshold("bitcode-mdindex-threshold", cl::Hidden, cl::init(25),
cl::desc("Number of metadatas above which we emit an index "
"to enable lazy-loading"));
-static cl::opt<uint32_t> FlushThreshold(
- "bitcode-flush-threshold", cl::Hidden, cl::init(512),
- cl::desc("The threshold (unit M) for flushing LLVM bitcode."));
+static cl::opt<uint32_t> FlushThreshold(
+ "bitcode-flush-threshold", cl::Hidden, cl::init(512),
+ cl::desc("The threshold (unit M) for flushing LLVM bitcode."));
static cl::opt<bool> WriteRelBFToSummary(
"write-relbf-to-summary", cl::Hidden, cl::init(false),
@@ -300,15 +300,15 @@ private:
SmallVectorImpl<uint64_t> &Record, unsigned &Abbrev);
void writeDISubrange(const DISubrange *N, SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
- void writeDIGenericSubrange(const DIGenericSubrange *N,
- SmallVectorImpl<uint64_t> &Record,
- unsigned Abbrev);
+ void writeDIGenericSubrange(const DIGenericSubrange *N,
+ SmallVectorImpl<uint64_t> &Record,
+ unsigned Abbrev);
void writeDIEnumerator(const DIEnumerator *N,
SmallVectorImpl<uint64_t> &Record, unsigned Abbrev);
void writeDIBasicType(const DIBasicType *N, SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
- void writeDIStringType(const DIStringType *N,
- SmallVectorImpl<uint64_t> &Record, unsigned Abbrev);
+ void writeDIStringType(const DIStringType *N,
+ SmallVectorImpl<uint64_t> &Record, unsigned Abbrev);
void writeDIDerivedType(const DIDerivedType *N,
SmallVectorImpl<uint64_t> &Record, unsigned Abbrev);
void writeDICompositeType(const DICompositeType *N,
@@ -403,8 +403,8 @@ private:
unsigned getEncodedSyncScopeID(SyncScope::ID SSID) {
return unsigned(SSID);
}
-
- unsigned getEncodedAlign(MaybeAlign Alignment) { return encode(Alignment); }
+
+ unsigned getEncodedAlign(MaybeAlign Alignment) { return encode(Alignment); }
};
/// Class to manage the bitcode writing for a combined index.
@@ -626,8 +626,8 @@ static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind) {
return bitc::ATTR_KIND_IN_ALLOCA;
case Attribute::Cold:
return bitc::ATTR_KIND_COLD;
- case Attribute::Hot:
- return bitc::ATTR_KIND_HOT;
+ case Attribute::Hot:
+ return bitc::ATTR_KIND_HOT;
case Attribute::InaccessibleMemOnly:
return bitc::ATTR_KIND_INACCESSIBLEMEM_ONLY;
case Attribute::InaccessibleMemOrArgMemOnly:
@@ -648,8 +648,8 @@ static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind) {
return bitc::ATTR_KIND_NO_ALIAS;
case Attribute::NoBuiltin:
return bitc::ATTR_KIND_NO_BUILTIN;
- case Attribute::NoCallback:
- return bitc::ATTR_KIND_NO_CALLBACK;
+ case Attribute::NoCallback:
+ return bitc::ATTR_KIND_NO_CALLBACK;
case Attribute::NoCapture:
return bitc::ATTR_KIND_NO_CAPTURE;
case Attribute::NoDuplicate:
@@ -680,8 +680,8 @@ static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind) {
return bitc::ATTR_KIND_NOSYNC;
case Attribute::NoCfCheck:
return bitc::ATTR_KIND_NOCF_CHECK;
- case Attribute::NoProfile:
- return bitc::ATTR_KIND_NO_PROFILE;
+ case Attribute::NoProfile:
+ return bitc::ATTR_KIND_NO_PROFILE;
case Attribute::NoUnwind:
return bitc::ATTR_KIND_NO_UNWIND;
case Attribute::NullPointerIsValid:
@@ -750,10 +750,10 @@ static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind) {
return bitc::ATTR_KIND_PREALLOCATED;
case Attribute::NoUndef:
return bitc::ATTR_KIND_NOUNDEF;
- case Attribute::ByRef:
- return bitc::ATTR_KIND_BYREF;
- case Attribute::MustProgress:
- return bitc::ATTR_KIND_MUSTPROGRESS;
+ case Attribute::ByRef:
+ return bitc::ATTR_KIND_BYREF;
+ case Attribute::MustProgress:
+ return bitc::ATTR_KIND_MUSTPROGRESS;
case Attribute::EndAttrKinds:
llvm_unreachable("Can not encode end-attribute kinds marker.");
case Attribute::None:
@@ -915,7 +915,7 @@ void ModuleBitcodeWriter::writeTypeTable() {
case Type::LabelTyID: Code = bitc::TYPE_CODE_LABEL; break;
case Type::MetadataTyID: Code = bitc::TYPE_CODE_METADATA; break;
case Type::X86_MMXTyID: Code = bitc::TYPE_CODE_X86_MMX; break;
- case Type::X86_AMXTyID: Code = bitc::TYPE_CODE_X86_AMX; break;
+ case Type::X86_AMXTyID: Code = bitc::TYPE_CODE_X86_AMX; break;
case Type::TokenTyID: Code = bitc::TYPE_CODE_TOKEN; break;
case Type::IntegerTyID:
// INTEGER: [width]
@@ -985,7 +985,7 @@ void ModuleBitcodeWriter::writeTypeTable() {
// VECTOR [numelts, eltty] or
// [numelts, eltty, scalable]
Code = bitc::TYPE_CODE_VECTOR;
- TypeVals.push_back(VT->getElementCount().getKnownMinValue());
+ TypeVals.push_back(VT->getElementCount().getKnownMinValue());
TypeVals.push_back(VE.getTypeID(VT->getElementType()));
if (isa<ScalableVectorType>(VT))
TypeVals.push_back(true);
@@ -1201,14 +1201,14 @@ void ModuleBitcodeWriter::writeModuleInfo() {
// compute the maximum alignment value.
std::map<std::string, unsigned> SectionMap;
std::map<std::string, unsigned> GCMap;
- MaybeAlign MaxAlignment;
+ MaybeAlign MaxAlignment;
unsigned MaxGlobalType = 0;
- const auto UpdateMaxAlignment = [&MaxAlignment](const MaybeAlign A) {
- if (A)
- MaxAlignment = !MaxAlignment ? *A : std::max(*MaxAlignment, *A);
- };
+ const auto UpdateMaxAlignment = [&MaxAlignment](const MaybeAlign A) {
+ if (A)
+ MaxAlignment = !MaxAlignment ? *A : std::max(*MaxAlignment, *A);
+ };
for (const GlobalVariable &GV : M.globals()) {
- UpdateMaxAlignment(GV.getAlign());
+ UpdateMaxAlignment(GV.getAlign());
MaxGlobalType = std::max(MaxGlobalType, VE.getTypeID(GV.getValueType()));
if (GV.hasSection()) {
// Give section names unique ID's.
@@ -1221,7 +1221,7 @@ void ModuleBitcodeWriter::writeModuleInfo() {
}
}
for (const Function &F : M) {
- UpdateMaxAlignment(F.getAlign());
+ UpdateMaxAlignment(F.getAlign());
if (F.hasSection()) {
// Give section names unique ID's.
unsigned &Entry = SectionMap[std::string(F.getSection())];
@@ -1257,10 +1257,10 @@ void ModuleBitcodeWriter::writeModuleInfo() {
//| constant
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Initializer.
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // Linkage.
- if (!MaxAlignment) // Alignment.
+ if (!MaxAlignment) // Alignment.
Abbv->Add(BitCodeAbbrevOp(0));
else {
- unsigned MaxEncAlignment = getEncodedAlign(MaxAlignment);
+ unsigned MaxEncAlignment = getEncodedAlign(MaxAlignment);
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
Log2_32_Ceil(MaxEncAlignment+1)));
}
@@ -1313,7 +1313,7 @@ void ModuleBitcodeWriter::writeModuleInfo() {
Vals.push_back(GV.isDeclaration() ? 0 :
(VE.getValueID(GV.getInitializer()) + 1));
Vals.push_back(getEncodedLinkage(GV));
- Vals.push_back(getEncodedAlign(GV.getAlign()));
+ Vals.push_back(getEncodedAlign(GV.getAlign()));
Vals.push_back(GV.hasSection() ? SectionMap[std::string(GV.getSection())]
: 0);
if (GV.isThreadLocal() ||
@@ -1359,7 +1359,7 @@ void ModuleBitcodeWriter::writeModuleInfo() {
Vals.push_back(F.isDeclaration());
Vals.push_back(getEncodedLinkage(F));
Vals.push_back(VE.getAttributeListID(F.getAttributes()));
- Vals.push_back(getEncodedAlign(F.getAlign()));
+ Vals.push_back(getEncodedAlign(F.getAlign()));
Vals.push_back(F.hasSection() ? SectionMap[std::string(F.getSection())]
: 0);
Vals.push_back(getEncodedVisibility(F));
@@ -1561,19 +1561,19 @@ void ModuleBitcodeWriter::writeDISubrange(const DISubrange *N,
Record.clear();
}
-void ModuleBitcodeWriter::writeDIGenericSubrange(
- const DIGenericSubrange *N, SmallVectorImpl<uint64_t> &Record,
- unsigned Abbrev) {
- Record.push_back((uint64_t)N->isDistinct());
- Record.push_back(VE.getMetadataOrNullID(N->getRawCountNode()));
- Record.push_back(VE.getMetadataOrNullID(N->getRawLowerBound()));
- Record.push_back(VE.getMetadataOrNullID(N->getRawUpperBound()));
- Record.push_back(VE.getMetadataOrNullID(N->getRawStride()));
-
- Stream.EmitRecord(bitc::METADATA_GENERIC_SUBRANGE, Record, Abbrev);
- Record.clear();
-}
-
+void ModuleBitcodeWriter::writeDIGenericSubrange(
+ const DIGenericSubrange *N, SmallVectorImpl<uint64_t> &Record,
+ unsigned Abbrev) {
+ Record.push_back((uint64_t)N->isDistinct());
+ Record.push_back(VE.getMetadataOrNullID(N->getRawCountNode()));
+ Record.push_back(VE.getMetadataOrNullID(N->getRawLowerBound()));
+ Record.push_back(VE.getMetadataOrNullID(N->getRawUpperBound()));
+ Record.push_back(VE.getMetadataOrNullID(N->getRawStride()));
+
+ Stream.EmitRecord(bitc::METADATA_GENERIC_SUBRANGE, Record, Abbrev);
+ Record.clear();
+}
+
static void emitSignedInt64(SmallVectorImpl<uint64_t> &Vals, uint64_t V) {
if ((int64_t)V >= 0)
Vals.push_back(V << 1);
@@ -1620,22 +1620,22 @@ void ModuleBitcodeWriter::writeDIBasicType(const DIBasicType *N,
Record.clear();
}
-void ModuleBitcodeWriter::writeDIStringType(const DIStringType *N,
- SmallVectorImpl<uint64_t> &Record,
- unsigned Abbrev) {
- Record.push_back(N->isDistinct());
- Record.push_back(N->getTag());
- Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
- Record.push_back(VE.getMetadataOrNullID(N->getStringLength()));
- Record.push_back(VE.getMetadataOrNullID(N->getStringLengthExp()));
- Record.push_back(N->getSizeInBits());
- Record.push_back(N->getAlignInBits());
- Record.push_back(N->getEncoding());
-
- Stream.EmitRecord(bitc::METADATA_STRING_TYPE, Record, Abbrev);
- Record.clear();
-}
-
+void ModuleBitcodeWriter::writeDIStringType(const DIStringType *N,
+ SmallVectorImpl<uint64_t> &Record,
+ unsigned Abbrev) {
+ Record.push_back(N->isDistinct());
+ Record.push_back(N->getTag());
+ Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
+ Record.push_back(VE.getMetadataOrNullID(N->getStringLength()));
+ Record.push_back(VE.getMetadataOrNullID(N->getStringLengthExp()));
+ Record.push_back(N->getSizeInBits());
+ Record.push_back(N->getAlignInBits());
+ Record.push_back(N->getEncoding());
+
+ Stream.EmitRecord(bitc::METADATA_STRING_TYPE, Record, Abbrev);
+ Record.clear();
+}
+
void ModuleBitcodeWriter::writeDIDerivedType(const DIDerivedType *N,
SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
@@ -1685,9 +1685,9 @@ void ModuleBitcodeWriter::writeDICompositeType(
Record.push_back(VE.getMetadataOrNullID(N->getRawIdentifier()));
Record.push_back(VE.getMetadataOrNullID(N->getDiscriminator()));
Record.push_back(VE.getMetadataOrNullID(N->getRawDataLocation()));
- Record.push_back(VE.getMetadataOrNullID(N->getRawAssociated()));
- Record.push_back(VE.getMetadataOrNullID(N->getRawAllocated()));
- Record.push_back(VE.getMetadataOrNullID(N->getRawRank()));
+ Record.push_back(VE.getMetadataOrNullID(N->getRawAssociated()));
+ Record.push_back(VE.getMetadataOrNullID(N->getRawAllocated()));
+ Record.push_back(VE.getMetadataOrNullID(N->getRawRank()));
Stream.EmitRecord(bitc::METADATA_COMPOSITE_TYPE, Record, Abbrev);
Record.clear();
@@ -1871,7 +1871,7 @@ void ModuleBitcodeWriter::writeDIModule(const DIModule *N,
for (auto &I : N->operands())
Record.push_back(VE.getMetadataOrNullID(I));
Record.push_back(N->getLineNo());
- Record.push_back(N->getIsDecl());
+ Record.push_back(N->getIsDecl());
Stream.EmitRecord(bitc::METADATA_MODULE, Record, Abbrev);
Record.clear();
@@ -2433,8 +2433,8 @@ void ModuleBitcodeWriter::writeConstants(unsigned FirstVal, unsigned LastVal,
unsigned AbbrevToUse = 0;
if (C->isNullValue()) {
Code = bitc::CST_CODE_NULL;
- } else if (isa<PoisonValue>(C)) {
- Code = bitc::CST_CODE_POISON;
+ } else if (isa<PoisonValue>(C)) {
+ Code = bitc::CST_CODE_POISON;
} else if (isa<UndefValue>(C)) {
Code = bitc::CST_CODE_UNDEF;
} else if (const ConstantInt *IV = dyn_cast<ConstantInt>(C)) {
@@ -3002,13 +3002,13 @@ void ModuleBitcodeWriter::writeInstruction(const Instruction &I,
Vals.push_back(VE.getTypeID(AI.getAllocatedType()));
Vals.push_back(VE.getTypeID(I.getOperand(0)->getType()));
Vals.push_back(VE.getValueID(I.getOperand(0))); // size.
- using APV = AllocaPackedValues;
- unsigned Record = 0;
- Bitfield::set<APV::Align>(Record, getEncodedAlign(AI.getAlign()));
- Bitfield::set<APV::UsedWithInAlloca>(Record, AI.isUsedWithInAlloca());
- Bitfield::set<APV::ExplicitType>(Record, true);
- Bitfield::set<APV::SwiftError>(Record, AI.isSwiftError());
- Vals.push_back(Record);
+ using APV = AllocaPackedValues;
+ unsigned Record = 0;
+ Bitfield::set<APV::Align>(Record, getEncodedAlign(AI.getAlign()));
+ Bitfield::set<APV::UsedWithInAlloca>(Record, AI.isUsedWithInAlloca());
+ Bitfield::set<APV::ExplicitType>(Record, true);
+ Bitfield::set<APV::SwiftError>(Record, AI.isSwiftError());
+ Vals.push_back(Record);
break;
}
@@ -3022,7 +3022,7 @@ void ModuleBitcodeWriter::writeInstruction(const Instruction &I,
AbbrevToUse = FUNCTION_INST_LOAD_ABBREV;
}
Vals.push_back(VE.getTypeID(I.getType()));
- Vals.push_back(getEncodedAlign(cast<LoadInst>(I).getAlign()));
+ Vals.push_back(getEncodedAlign(cast<LoadInst>(I).getAlign()));
Vals.push_back(cast<LoadInst>(I).isVolatile());
if (cast<LoadInst>(I).isAtomic()) {
Vals.push_back(getEncodedOrdering(cast<LoadInst>(I).getOrdering()));
@@ -3036,7 +3036,7 @@ void ModuleBitcodeWriter::writeInstruction(const Instruction &I,
Code = bitc::FUNC_CODE_INST_STORE;
pushValueAndType(I.getOperand(1), InstID, Vals); // ptrty + ptr
pushValueAndType(I.getOperand(0), InstID, Vals); // valty + val
- Vals.push_back(getEncodedAlign(cast<StoreInst>(I).getAlign()));
+ Vals.push_back(getEncodedAlign(cast<StoreInst>(I).getAlign()));
Vals.push_back(cast<StoreInst>(I).isVolatile());
if (cast<StoreInst>(I).isAtomic()) {
Vals.push_back(getEncodedOrdering(cast<StoreInst>(I).getOrdering()));
@@ -3599,10 +3599,10 @@ void IndexBitcodeWriter::writeModStrings() {
/// Write the function type metadata related records that need to appear before
/// a function summary entry (whether per-module or combined).
-template <typename Fn>
+template <typename Fn>
static void writeFunctionTypeMetadataRecords(BitstreamWriter &Stream,
- FunctionSummary *FS,
- Fn GetValueID) {
+ FunctionSummary *FS,
+ Fn GetValueID) {
if (!FS->type_tests().empty())
Stream.EmitRecord(bitc::FS_TYPE_TESTS, FS->type_tests());
@@ -3631,7 +3631,7 @@ static void writeFunctionTypeMetadataRecords(BitstreamWriter &Stream,
Record.clear();
Record.push_back(VC.VFunc.GUID);
Record.push_back(VC.VFunc.Offset);
- llvm::append_range(Record, VC.Args);
+ llvm::append_range(Record, VC.Args);
Stream.EmitRecord(Ty, Record);
}
};
@@ -3652,25 +3652,25 @@ static void writeFunctionTypeMetadataRecords(BitstreamWriter &Stream,
if (!FS->paramAccesses().empty()) {
Record.clear();
for (auto &Arg : FS->paramAccesses()) {
- size_t UndoSize = Record.size();
+ size_t UndoSize = Record.size();
Record.push_back(Arg.ParamNo);
WriteRange(Arg.Use);
Record.push_back(Arg.Calls.size());
for (auto &Call : Arg.Calls) {
Record.push_back(Call.ParamNo);
- Optional<unsigned> ValueID = GetValueID(Call.Callee);
- if (!ValueID) {
- // If ValueID is unknown we can't drop just this call, we must drop
- // entire parameter.
- Record.resize(UndoSize);
- break;
- }
- Record.push_back(*ValueID);
+ Optional<unsigned> ValueID = GetValueID(Call.Callee);
+ if (!ValueID) {
+ // If ValueID is unknown we can't drop just this call, we must drop
+ // entire parameter.
+ Record.resize(UndoSize);
+ break;
+ }
+ Record.push_back(*ValueID);
WriteRange(Call.Offsets);
}
}
- if (!Record.empty())
- Stream.EmitRecord(bitc::FS_PARAM_ACCESS, Record);
+ if (!Record.empty())
+ Stream.EmitRecord(bitc::FS_PARAM_ACCESS, Record);
}
}
@@ -3705,7 +3705,7 @@ static void writeWholeProgramDevirtResolutionByArg(
SmallVector<uint64_t, 64> &NameVals, const std::vector<uint64_t> &args,
const WholeProgramDevirtResolution::ByArg &ByArg) {
NameVals.push_back(args.size());
- llvm::append_range(NameVals, args);
+ llvm::append_range(NameVals, args);
NameVals.push_back(ByArg.TheKind);
NameVals.push_back(ByArg.Info);
@@ -3768,11 +3768,11 @@ void ModuleBitcodeWriterBase::writePerModuleFunctionSummaryRecord(
FunctionSummary *FS = cast<FunctionSummary>(Summary);
- writeFunctionTypeMetadataRecords(
- Stream, FS, [&](const ValueInfo &VI) -> Optional<unsigned> {
- return {VE.getValueID(VI.getValue())};
- });
-
+ writeFunctionTypeMetadataRecords(
+ Stream, FS, [&](const ValueInfo &VI) -> Optional<unsigned> {
+ return {VE.getValueID(VI.getValue())};
+ });
+
auto SpecialRefCnts = FS->specialRefCounts();
NameVals.push_back(getEncodedGVSummaryFlags(FS->flags()));
NameVals.push_back(FS->instCount());
@@ -3832,7 +3832,7 @@ void ModuleBitcodeWriterBase::writeModuleLevelReferences(
NameVals.push_back(VE.getValueID(RI.getValue()));
// Sort the refs for determinism output, the vector returned by FS->refs() has
// been initialized from a DenseSet.
- llvm::sort(drop_begin(NameVals, SizeBeforeRefs));
+ llvm::sort(drop_begin(NameVals, SizeBeforeRefs));
if (VTableFuncs.empty())
Stream.EmitRecord(bitc::FS_PERMODULE_GLOBALVAR_INIT_REFS, NameVals,
@@ -4148,38 +4148,38 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
return;
}
- auto GetValueId = [&](const ValueInfo &VI) -> Optional<unsigned> {
- GlobalValue::GUID GUID = VI.getGUID();
- Optional<unsigned> CallValueId = getValueId(GUID);
- if (CallValueId)
- return CallValueId;
- // For SamplePGO, the indirect call targets for local functions will
- // have its original name annotated in profile. We try to find the
- // corresponding PGOFuncName as the GUID.
- GUID = Index.getGUIDFromOriginalID(GUID);
- if (!GUID)
- return None;
- CallValueId = getValueId(GUID);
- if (!CallValueId)
- return None;
- // The mapping from OriginalId to GUID may return a GUID
- // that corresponds to a static variable. Filter it out here.
- // This can happen when
- // 1) There is a call to a library function which does not have
- // a CallValidId;
- // 2) There is a static variable with the OriginalGUID identical
- // to the GUID of the library function in 1);
- // When this happens, the logic for SamplePGO kicks in and
- // the static variable in 2) will be found, which needs to be
- // filtered out.
- auto *GVSum = Index.getGlobalValueSummary(GUID, false);
- if (GVSum && GVSum->getSummaryKind() == GlobalValueSummary::GlobalVarKind)
- return None;
- return CallValueId;
- };
-
+ auto GetValueId = [&](const ValueInfo &VI) -> Optional<unsigned> {
+ GlobalValue::GUID GUID = VI.getGUID();
+ Optional<unsigned> CallValueId = getValueId(GUID);
+ if (CallValueId)
+ return CallValueId;
+ // For SamplePGO, the indirect call targets for local functions will
+ // have its original name annotated in profile. We try to find the
+ // corresponding PGOFuncName as the GUID.
+ GUID = Index.getGUIDFromOriginalID(GUID);
+ if (!GUID)
+ return None;
+ CallValueId = getValueId(GUID);
+ if (!CallValueId)
+ return None;
+ // The mapping from OriginalId to GUID may return a GUID
+ // that corresponds to a static variable. Filter it out here.
+ // This can happen when
+ // 1) There is a call to a library function which does not have
+ // a CallValidId;
+ // 2) There is a static variable with the OriginalGUID identical
+ // to the GUID of the library function in 1);
+ // When this happens, the logic for SamplePGO kicks in and
+ // the static variable in 2) will be found, which needs to be
+ // filtered out.
+ auto *GVSum = Index.getGlobalValueSummary(GUID, false);
+ if (GVSum && GVSum->getSummaryKind() == GlobalValueSummary::GlobalVarKind)
+ return None;
+ return CallValueId;
+ };
+
auto *FS = cast<FunctionSummary>(S);
- writeFunctionTypeMetadataRecords(Stream, FS, GetValueId);
+ writeFunctionTypeMetadataRecords(Stream, FS, GetValueId);
getReferencedTypeIds(FS, ReferencedTypeIds);
NameVals.push_back(*ValueId);
@@ -4221,9 +4221,9 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
for (auto &EI : FS->calls()) {
// If this GUID doesn't have a value id, it doesn't have a function
// summary and we don't need to record any calls to it.
- Optional<unsigned> CallValueId = GetValueId(EI.first);
- if (!CallValueId)
- continue;
+ Optional<unsigned> CallValueId = GetValueId(EI.first);
+ if (!CallValueId)
+ continue;
NameVals.push_back(*CallValueId);
if (HasProfileData)
NameVals.push_back(static_cast<uint8_t>(EI.second.Hotness));
@@ -4485,8 +4485,8 @@ static void writeBitcodeHeader(BitstreamWriter &Stream) {
Stream.Emit(0xD, 4);
}
-BitcodeWriter::BitcodeWriter(SmallVectorImpl<char> &Buffer, raw_fd_stream *FS)
- : Buffer(Buffer), Stream(new BitstreamWriter(Buffer, FS, FlushThreshold)) {
+BitcodeWriter::BitcodeWriter(SmallVectorImpl<char> &Buffer, raw_fd_stream *FS)
+ : Buffer(Buffer), Stream(new BitstreamWriter(Buffer, FS, FlushThreshold)) {
writeBitcodeHeader(*Stream);
}
@@ -4597,7 +4597,7 @@ void llvm::WriteBitcodeToFile(const Module &M, raw_ostream &Out,
if (TT.isOSDarwin() || TT.isOSBinFormatMachO())
Buffer.insert(Buffer.begin(), BWH_HeaderSize, 0);
- BitcodeWriter Writer(Buffer, dyn_cast<raw_fd_stream>(&Out));
+ BitcodeWriter Writer(Buffer, dyn_cast<raw_fd_stream>(&Out));
Writer.writeModule(M, ShouldPreserveUseListOrder, Index, GenerateHash,
ModHash);
Writer.writeSymtab();
@@ -4607,8 +4607,8 @@ void llvm::WriteBitcodeToFile(const Module &M, raw_ostream &Out,
emitDarwinBCHeaderAndTrailer(Buffer, TT);
// Write the generated bitstream to "Out".
- if (!Buffer.empty())
- Out.write((char *)&Buffer.front(), Buffer.size());
+ if (!Buffer.empty())
+ Out.write((char *)&Buffer.front(), Buffer.size());
}
void IndexBitcodeWriter::write() {
@@ -4812,9 +4812,9 @@ static const char *getSectionNameForBitcode(const Triple &T) {
case Triple::Wasm:
case Triple::UnknownObjectFormat:
return ".llvmbc";
- case Triple::GOFF:
- llvm_unreachable("GOFF is not yet implemented");
- break;
+ case Triple::GOFF:
+ llvm_unreachable("GOFF is not yet implemented");
+ break;
case Triple::XCOFF:
llvm_unreachable("XCOFF is not yet implemented");
break;
@@ -4831,9 +4831,9 @@ static const char *getSectionNameForCommandline(const Triple &T) {
case Triple::Wasm:
case Triple::UnknownObjectFormat:
return ".llvmcmd";
- case Triple::GOFF:
- llvm_unreachable("GOFF is not yet implemented");
- break;
+ case Triple::GOFF:
+ llvm_unreachable("GOFF is not yet implemented");
+ break;
case Triple::XCOFF:
llvm_unreachable("XCOFF is not yet implemented");
break;
@@ -4842,8 +4842,8 @@ static const char *getSectionNameForCommandline(const Triple &T) {
}
void llvm::EmbedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf,
- bool EmbedBitcode, bool EmbedCmdline,
- const std::vector<uint8_t> &CmdArgs) {
+ bool EmbedBitcode, bool EmbedCmdline,
+ const std::vector<uint8_t> &CmdArgs) {
// Save llvm.compiler.used and remove it.
SmallVector<Constant *, 2> UsedArray;
SmallPtrSet<GlobalValue *, 4> UsedGlobals;
@@ -4862,10 +4862,10 @@ void llvm::EmbedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf,
std::string Data;
ArrayRef<uint8_t> ModuleData;
Triple T(M.getTargetTriple());
-
+
if (EmbedBitcode) {
- if (Buf.getBufferSize() == 0 ||
- !isBitcode((const unsigned char *)Buf.getBufferStart(),
+ if (Buf.getBufferSize() == 0 ||
+ !isBitcode((const unsigned char *)Buf.getBufferStart(),
(const unsigned char *)Buf.getBufferEnd())) {
// If the input is LLVM Assembly, bitcode is produced by serializing
// the module. Use-lists order need to be preserved in this case.
@@ -4884,9 +4884,9 @@ void llvm::EmbedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf,
M, ModuleConstant->getType(), true, llvm::GlobalValue::PrivateLinkage,
ModuleConstant);
GV->setSection(getSectionNameForBitcode(T));
- // Set alignment to 1 to prevent padding between two contributions from input
- // sections after linking.
- GV->setAlignment(Align(1));
+ // Set alignment to 1 to prevent padding between two contributions from input
+ // sections after linking.
+ GV->setAlignment(Align(1));
UsedArray.push_back(
ConstantExpr::getPointerBitCastOrAddrSpaceCast(GV, UsedElementType));
if (llvm::GlobalVariable *Old =
@@ -4900,17 +4900,17 @@ void llvm::EmbedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf,
}
// Skip if only bitcode needs to be embedded.
- if (EmbedCmdline) {
+ if (EmbedCmdline) {
// Embed command-line options.
- ArrayRef<uint8_t> CmdData(const_cast<uint8_t *>(CmdArgs.data()),
- CmdArgs.size());
+ ArrayRef<uint8_t> CmdData(const_cast<uint8_t *>(CmdArgs.data()),
+ CmdArgs.size());
llvm::Constant *CmdConstant =
llvm::ConstantDataArray::get(M.getContext(), CmdData);
GV = new llvm::GlobalVariable(M, CmdConstant->getType(), true,
llvm::GlobalValue::PrivateLinkage,
CmdConstant);
GV->setSection(getSectionNameForCommandline(T));
- GV->setAlignment(Align(1));
+ GV->setAlignment(Align(1));
UsedArray.push_back(
ConstantExpr::getPointerBitCastOrAddrSpaceCast(GV, UsedElementType));
if (llvm::GlobalVariable *Old = M.getGlobalVariable("llvm.cmdline", true)) {
diff --git a/contrib/libs/llvm12/lib/Bitcode/Writer/ValueEnumerator.cpp b/contrib/libs/llvm12/lib/Bitcode/Writer/ValueEnumerator.cpp
index bbee8b3249..d7b3b19844 100644
--- a/contrib/libs/llvm12/lib/Bitcode/Writer/ValueEnumerator.cpp
+++ b/contrib/libs/llvm12/lib/Bitcode/Writer/ValueEnumerator.cpp
@@ -78,16 +78,16 @@ struct OrderMap {
} // end anonymous namespace
-/// Look for a value that might be wrapped as metadata, e.g. a value in a
-/// metadata operand. Returns nullptr for a non-wrapped input value if
-/// OnlyWrapped is true, or it returns the input value as-is if false.
-static const Value *skipMetadataWrapper(const Value *V, bool OnlyWrapped) {
- if (const auto *MAV = dyn_cast<MetadataAsValue>(V))
- if (const auto *VAM = dyn_cast<ValueAsMetadata>(MAV->getMetadata()))
- return VAM->getValue();
- return OnlyWrapped ? nullptr : V;
-}
-
+/// Look for a value that might be wrapped as metadata, e.g. a value in a
+/// metadata operand. Returns nullptr for a non-wrapped input value if
+/// OnlyWrapped is true, or it returns the input value as-is if false.
+static const Value *skipMetadataWrapper(const Value *V, bool OnlyWrapped) {
+ if (const auto *MAV = dyn_cast<MetadataAsValue>(V))
+ if (const auto *VAM = dyn_cast<ValueAsMetadata>(MAV->getMetadata()))
+ return VAM->getValue();
+ return OnlyWrapped ? nullptr : V;
+}
+
static void orderValue(const Value *V, OrderMap &OM) {
if (OM.lookup(V).first)
return;
@@ -133,25 +133,25 @@ static OrderMap orderModule(const Module &M) {
if (!isa<GlobalValue>(U.get()))
orderValue(U.get(), OM);
}
-
- // As constants used in metadata operands are emitted as module-level
- // constants, we must order them before other operands. Also, we must order
- // these before global values, as these will be read before setting the
- // global values' initializers. The latter matters for constants which have
- // uses towards other constants that are used as initializers.
- for (const Function &F : M) {
- if (F.isDeclaration())
- continue;
- for (const BasicBlock &BB : F)
- for (const Instruction &I : BB)
- for (const Value *V : I.operands()) {
- if (const Value *Op = skipMetadataWrapper(V, true)) {
- if ((isa<Constant>(*Op) && !isa<GlobalValue>(*Op)) ||
- isa<InlineAsm>(*Op))
- orderValue(Op, OM);
- }
- }
- }
+
+ // As constants used in metadata operands are emitted as module-level
+ // constants, we must order them before other operands. Also, we must order
+ // these before global values, as these will be read before setting the
+ // global values' initializers. The latter matters for constants which have
+ // uses towards other constants that are used as initializers.
+ for (const Function &F : M) {
+ if (F.isDeclaration())
+ continue;
+ for (const BasicBlock &BB : F)
+ for (const Instruction &I : BB)
+ for (const Value *V : I.operands()) {
+ if (const Value *Op = skipMetadataWrapper(V, true)) {
+ if ((isa<Constant>(*Op) && !isa<GlobalValue>(*Op)) ||
+ isa<InlineAsm>(*Op))
+ orderValue(Op, OM);
+ }
+ }
+ }
OM.LastGlobalConstantID = OM.size();
// Initializers of GlobalValues are processed in
@@ -1002,8 +1002,8 @@ void ValueEnumerator::incorporateFunction(const Function &F) {
EnumerateValue(&I);
if (I.hasAttribute(Attribute::ByVal))
EnumerateType(I.getParamByValType());
- else if (I.hasAttribute(Attribute::StructRet))
- EnumerateType(I.getParamStructRetType());
+ else if (I.hasAttribute(Attribute::StructRet))
+ EnumerateType(I.getParamStructRetType());
}
FirstFuncConstantID = Values.size();
diff --git a/contrib/libs/llvm12/lib/Bitcode/Writer/ya.make b/contrib/libs/llvm12/lib/Bitcode/Writer/ya.make
index 624b4f8e7e..7eec1a75c1 100644
--- a/contrib/libs/llvm12/lib/Bitcode/Writer/ya.make
+++ b/contrib/libs/llvm12/lib/Bitcode/Writer/ya.make
@@ -12,13 +12,13 @@ LICENSE(Apache-2.0 WITH LLVM-exception)
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
PEERDIR(
- contrib/libs/llvm12
- contrib/libs/llvm12/include
- contrib/libs/llvm12/lib/Analysis
- contrib/libs/llvm12/lib/IR
- contrib/libs/llvm12/lib/MC
- contrib/libs/llvm12/lib/Object
- contrib/libs/llvm12/lib/Support
+ contrib/libs/llvm12
+ contrib/libs/llvm12/include
+ contrib/libs/llvm12/lib/Analysis
+ contrib/libs/llvm12/lib/IR
+ contrib/libs/llvm12/lib/MC
+ contrib/libs/llvm12/lib/Object
+ contrib/libs/llvm12/lib/Support
)
ADDINCL(