Lines Matching +full:nand +full:- +full:style

1 //===- BitcodeReader.cpp - Internal BitcodeReader implementation ----------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
24 #include "llvm/Config/llvm-config.h"
96 "print-summary-global-ids", cl::init(false), cl::Hidden,
101 "expand-constant-exprs", cl::Hidden,
110 "load-bitcode-into-experimental-debuginfo-iterators", cl::Hidden,
159 // If we have a wrapper header, parse it and ignore the non-bc file contents.
244 // We expect a number of well-defined blocks, though we don't necessarily
263 // Ignore other sub-blocks.
324 // We expect a number of well-defined blocks, though we don't necessarily
341 // Ignore other sub-blocks.
400 // We expect a number of well-defined blocks, though we don't necessarily
418 // Ignore other sub-blocks.
438 this->Stream.setBlockInfo(&BlockInfo);
512 // Opcodes used for non-expressions. This includes constant aggregates
513 // (struct, array, vector) that might need expansion, as well as non-leaf
571 static bool classof(const Value *V) { return V->getValueID() == SubclassID; }
668 /// These are basic blocks forward-referenced by block addresses. They are
685 /// types. Once the old style function blocks have been phased out, we would
746 if (Ty && Ty->isMetadataTy())
747 return MetadataAsValue::get(Ty->getContext(), getFnMetadataByID(ID));
752 return MDLoader->getMetadataFwdRefOrLoad(ID);
761 if (i-1 < MAttributes.size())
762 return MAttributes[i-1];
776 ValNo = InstNum - ValNo;
782 assert((!ResVal || ResVal->getType() == getTypeByID(TypeID)) &&
825 ValNo = InstNum - ValNo;
837 ValNo = InstNum - ValNo;
844 if (Record.size() - OpNum < 2)
849 if (Record.size() - OpNum < LowerActiveWords + UpperActiveWords)
867 if (Record.size() - OpNum < 1)
873 /// Upgrades old-style typeless byval/sret/inalloca attributes by adding the
936 /// Used to enable on-demand parsing of the VST.
1028 ValueList(this->Stream.SizeInBytes(),
1032 this->ProducerIdentification = std::string(ProducerIdentification);
1054 if (!F->isMaterializable())
1073 //===----------------------------------------------------------------------===//
1075 //===----------------------------------------------------------------------===//
1190 (1 << CalleeInfo::RelBlockFreqBits) - 1;
1242 default: // Map unknown non-zero value to general dynamic.
1261 default: return -1;
1279 bool IsFP = Ty->isFPOrFPVectorTy();
1281 if (!IsFP && !Ty->isIntOrIntVectorTy())
1282 return -1;
1286 return -1;
1288 return IsFP ? Instruction::FNeg : -1;
1293 bool IsFP = Ty->isFPOrFPVectorTy();
1295 if (!IsFP && !Ty->isIntOrIntVectorTy())
1296 return -1;
1300 return -1;
1308 return IsFP ? -1 : Instruction::UDiv;
1312 return IsFP ? -1 : Instruction::URem;
1316 return IsFP ? -1 : Instruction::Shl;
1318 return IsFP ? -1 : Instruction::LShr;
1320 return IsFP ? -1 : Instruction::AShr;
1322 return IsFP ? -1 : Instruction::And;
1324 return IsFP ? -1 : Instruction::Or;
1326 return IsFP ? -1 : Instruction::Xor;
1337 case bitc::RMW_NAND: return AtomicRMWInst::Nand;
1363 default: // Map unknown orderings to sequentially-consistent.
1407 if (GV->hasLocalLinkage())
1410 case 5: GV->setDLLStorageClass(GlobalValue::DLLImportStorageClass); break;
1411 case 6: GV->setDLLStorageClass(GlobalValue::DLLExportStorageClass); break;
1433 if (Idx >= It->second.size())
1436 return It->second[Idx];
1444 if (!Ty->isPointerTy())
1461 ContainedTypeIDs[It->second] == ChildTypeIDs) &&
1463 return It->second;
1486 uint8_t Opcode = BC->Opcode;
1492 // If -expand-constant-exprs is set, we want to consider all expressions
1504 return ConstantExpr::isSupportedGetElementPtr(BC->SrcElemTy);
1549 for (unsigned OpID : reverse(BC->getOperandIDs())) {
1552 Ops.push_back(It->second);
1559 if (Ops.size() != BC->getOperandIDs().size())
1571 if (Instruction::isCast(BC->Opcode)) {
1572 C = UpgradeBitCastExpr(BC->Opcode, ConstOps[0], BC->getType());
1574 C = ConstantExpr::getCast(BC->Opcode, ConstOps[0], BC->getType());
1575 } else if (Instruction::isBinaryOp(BC->Opcode)) {
1576 C = ConstantExpr::get(BC->Opcode, ConstOps[0], ConstOps[1], BC->Flags);
1578 switch (BC->Opcode) {
1613 unsigned BBID = BC->BlockAddressBB;
1617 if (!Fn->empty()) {
1618 Function::iterator BBI = Fn->begin(), BBE = Fn->end();
1641 C = ConstantStruct::get(cast<StructType>(BC->getType()), ConstOps);
1644 C = ConstantArray::get(cast<ArrayType>(BC->getType()), ConstOps);
1651 BC->SrcElemTy, ConstOps[0], ArrayRef(ConstOps).drop_front(),
1652 toGEPNoWrapFlags(BC->Flags), BC->getInRange());
1682 BC->getOpcodeName());
1686 if (Instruction::isCast(BC->Opcode)) {
1687 I = CastInst::Create((Instruction::CastOps)BC->Opcode, Ops[0],
1688 BC->getType(), "constexpr", InsertBB);
1689 } else if (Instruction::isUnaryOp(BC->Opcode)) {
1690 I = UnaryOperator::Create((Instruction::UnaryOps)BC->Opcode, Ops[0],
1692 } else if (Instruction::isBinaryOp(BC->Opcode)) {
1693 I = BinaryOperator::Create((Instruction::BinaryOps)BC->Opcode, Ops[0],
1696 if (BC->Flags & OverflowingBinaryOperator::NoSignedWrap)
1697 I->setHasNoSignedWrap();
1698 if (BC->Flags & OverflowingBinaryOperator::NoUnsignedWrap)
1699 I->setHasNoUnsignedWrap();
1702 (BC->Flags & PossiblyExactOperator::IsExact))
1703 I->setIsExact();
1705 switch (BC->Opcode) {
1707 Type *IdxTy = Type::getInt32Ty(BC->getContext());
1708 Value *V = PoisonValue::get(BC->getType());
1719 Value *V = PoisonValue::get(BC->getType());
1728 I = CmpInst::Create((Instruction::OtherOps)BC->Opcode,
1729 (CmpInst::Predicate)BC->Flags, Ops[0], Ops[1],
1733 I = GetElementPtrInst::Create(BC->SrcElemTy, Ops[0],
1736 cast<GetElementPtrInst>(I)->setNoWrapFlags(toGEPNoWrapFlags(BC->Flags));
1786 //===----------------------------------------------------------------------===//
1788 //===----------------------------------------------------------------------===//
1875 B.addAlignmentAttr(1ULL << ((A >> 16) - 1));
1877 B.addStackAlignmentAttr(1ULL << ((A >> 26)-1));
1879 B.addTypeAttr(I, nullptr); // Type will be auto-upgraded.
1892 // The alignment is stored as a 16-bit raw value from bits 31--16. We shift
2288 // Upgrade old-style byval attribute to one with a type, even if it's
2370 i--;
2394 i--;
2554 if (!ResultTy || ArgTys.size() < Record.size()-3)
2577 if (!ResultTy || ArgTys.size() < Record.size()-2)
2594 if (EltTys.size() != Record.size()-1)
2615 Res->setName(TypeName);
2628 if (EltTys.size() != Record.size()-1)
2630 Res->setBody(EltTys, Record[0]);
2645 Res->setName(TypeName);
2820 V->setName(NameStr);
2823 GO->setComdat(TheModule->getOrInsertComdat(V->getName()));
2851 uint64_t FuncWordOffset = Record[1] - 1;
2861 /// Read a new-style GlobalValue symbol table.
2907 // Pass in the Offset to distinguish between calling for the module-level
2908 // VST (where we want to jump to the VST offset) and the function-level
2915 // If this module uses a string table, read this as a module-level VST.
2923 // Otherwise, the VST will be in a similar format to a function-level VST,
2928 // to the word-aligned ENTER_SUBBLOCK for the function block, and that
2946 Triple TT(TheModule->getTargetTriple());
3006 BB->setName(ValueName.str());
3020 return -(V >> 1);
3021 // There is no such thing as -0 with integers. "-0" really means MININT.
3044 GlobalInitWorklist.back().first->setInitializer(MaybeC.get());
3060 if (C->getType() != GV->getType())
3062 GA->setAliasee(C);
3064 GI->setResolver(C);
3075 unsigned ValID = Info.PersonalityFn - 1;
3080 Info.F->setPersonalityFn(MaybeC.get());
3085 unsigned ValID = Info.Prefix - 1;
3090 Info.F->setPrefixData(MaybeC.get());
3095 unsigned ValID = Info.Prologue - 1;
3100 Info.F->setPrologueData(MaybeC.get());
3179 if (CurTy->isVoidTy() || CurTy->isFunctionTy() || CurTy->isLabelTy())
3182 if (!TETy->hasProperty(TargetExtType::HasZeroInit))
3187 if (!CurTy->isIntOrIntVectorTy() || Record.empty())
3192 if (!CurTy->isIntOrIntVectorTy() || Record.empty())
3195 auto *ScalarTy = cast<IntegerType>(CurTy->getScalarType());
3196 APInt VInt = readWideAPInt(Record, ScalarTy->getBitWidth());
3204 auto *ScalarTy = CurTy->getScalarType();
3205 if (ScalarTy->isHalfTy())
3208 else if (ScalarTy->isBFloatTy())
3211 else if (ScalarTy->isFloatTy())
3214 else if (ScalarTy->isDoubleTy())
3217 else if (ScalarTy->isX86_FP80Ty()) {
3224 } else if (ScalarTy->isFP128Ty())
3227 else if (ScalarTy->isPPC_FP128Ty())
3274 EltTy = Array->getElementType();
3276 EltTy = cast<VectorType>(CurTy)->getElementType();
3277 if (EltTy->isIntegerTy(8)) {
3283 } else if (EltTy->isIntegerTy(16)) {
3289 } else if (EltTy->isIntegerTy(32)) {
3295 } else if (EltTy->isIntegerTy(64)) {
3301 } else if (EltTy->isHalfTy()) {
3307 } else if (EltTy->isBFloatTy()) {
3313 } else if (EltTy->isFloatTy()) {
3319 } else if (EltTy->isDoubleTy()) {
3449 return error("Missing element type for old-style constant GEP");
3541 {(uint8_t)(OpTy->isFPOrFPVectorTy() ? Instruction::FCmp
3547 // This maintains backward compatibility, pre-asm dialect keywords.
3568 return error("Missing element type for old-style inlineasm");
3595 return error("Missing element type for old-style inlineasm");
3627 return error("Missing element type for old-style inlineasm");
3713 assert(V->getType() == getTypeByID(CurTyID) && "Incorrect result type ID");
3771 for (const Use &U : V->materialized_uses()) {
3774 Order[&U] = Record[NumUses - 1];
3778 // (out-of-order), or a value has been upgraded.
3781 V->sortUseList([&](const Use &L, const Use &R) {
3808 if (Error Err = MDLoader->parseModuleMetadata())
3812 // Upgrade "Linker Options" module flag to "llvm.linker.options" module-level
3815 if (!TheModule->getNamedMetadata("llvm.linker.options")) {
3816 if (Metadata *Val = TheModule->getModuleFlag("Linker Options")) {
3818 TheModule->getOrInsertNamedMetadata("llvm.linker.options");
3819 for (const MDOperand &MDOptions : cast<MDNode>(Val)->operands())
3820 LinkerOpts->addOperand(cast<MDNode>(MDOptions));
3863 MDLoader->upgradeDebugIntrinsics(F);
3877 for (GlobalVariable &GV : TheModule->globals())
3881 Pair.first->eraseFromParent();
3882 TheModule->insertGlobalVariable(Pair.second);
3962 if (ComdatNameSize > Record.size() - 2)
3969 Comdat *C = TheModule->getOrInsertComdat(Name);
3970 C->setSelectionKind(SK);
3977 if (GV->hasLocalLinkage() ||
3978 (!GV->hasDefaultVisibility() && !GV->hasExternalWeakLinkage()))
3979 GV->setDSOLocal(true);
4017 if (!Ty->isPointerTy())
4019 AddressSpace = cast<PointerType>(Ty)->getAddressSpace();
4023 return error("Missing element type for old-style global");
4033 if (Record[5] - 1 >= SectionTable.size())
4035 Section = SectionTable[Record[5] - 1];
4039 // auto-upgrade `hidden` and `protected` for old bitcode.
4059 NewGV->setAlignment(*Alignment);
4061 NewGV->setSection(Section);
4062 NewGV->setVisibility(Visibility);
4063 NewGV->setUnnamedAddr(UnnamedAddr);
4067 if (!NewGV->hasLocalLinkage()) {
4068 NewGV->setDLLStorageClass(getDecodedDLLStorageClass(Record[10]));
4074 ValueList.push_back(NewGV, getVirtualTypeID(NewGV->getType(), TyID));
4078 GlobalInits.push_back(std::make_pair(NewGV, InitID - 1));
4084 NewGV->setComdat(ComdatList[ComdatID - 1]);
4092 NewGV->setAttributes(AS);
4096 NewGV->setDSOLocal(getDecodedDSOLocal(Record[13]));
4102 NewGV->setPartition(StringRef(Strtab.data() + Record[14], Record[15]));
4107 NewGV->setSanitizerMetadata(Meta);
4112 NewGV->setCodeModel(*CM);
4146 return error("Missing element type for old-style function");
4155 unsigned AddrSpace = TheModule->getDataLayout().getProgramAddressSpace();
4163 assert(Func->getFunctionType() == FTy &&
4167 Func->setCallingConv(CC);
4170 Func->setLinkage(getDecodedLinkage(RawLinkage));
4171 Func->setAttributes(getAttributes(Record[4]));
4174 // Upgrade any old-style byval or sret without a type by propagating the
4177 for (unsigned i = 0; i != Func->arg_size(); ++i) {
4180 if (!Func->hasParamAttribute(i, Kind))
4183 if (Func->getParamAttribute(i, Kind).getValueAsType())
4186 Func->removeParamAttr(i, Kind);
4208 Func->addParamAttr(i, NewAttr);
4212 if (Func->getCallingConv() == CallingConv::X86_INTR &&
4213 !Func->arg_empty() && !Func->hasParamAttribute(0, Attribute::ByVal)) {
4219 Func->addParamAttr(0, NewAttr);
4226 Func->setAlignment(*Alignment);
4228 if (Record[6] - 1 >= SectionTable.size())
4230 Func->setSection(SectionTable[Record[6] - 1]);
4233 // auto-upgrade `hidden` and `protected` for old bitcode.
4234 if (!Func->hasLocalLinkage())
4235 Func->setVisibility(getDecodedVisibility(Record[7]));
4237 if (Record[8] - 1 >= GCTable.size())
4239 Func->setGC(GCTable[Record[8] - 1]);
4244 Func->setUnnamedAddr(UnnamedAddr);
4252 if (!Func->hasLocalLinkage()) {
4253 Func->setDLLStorageClass(getDecodedDLLStorageClass(Record[11]));
4263 Func->setComdat(ComdatList[ComdatID - 1]);
4276 Func->setDSOLocal(getDecodedDSOLocal(Record[15]));
4286 Func->setPartition(StringRef(Strtab.data() + Record[17], Record[18]));
4289 ValueList.push_back(Func, getVirtualTypeID(Func->getType(), FTyID));
4297 Func->setIsMaterializable(true);
4331 AddrSpace = PTy->getAddressSpace();
4335 return error("Missing element type for old-style indirect symbol");
4352 // auto-upgrade `hidden` and `protected` for old bitcode.
4355 if (!NewGA->hasLocalLinkage())
4356 NewGA->setVisibility(getDecodedVisibility(Record[VisInd]));
4363 if (!NewGA->hasLocalLinkage())
4364 NewGA->setDLLStorageClass(getDecodedDLLStorageClass(S));
4369 NewGA->setThreadLocalMode(getDecodedThreadLocalMode(Record[OpNum++]));
4371 NewGA->setUnnamedAddr(getDecodedUnnamedAddrType(Record[OpNum++]));
4374 NewGA->setDSOLocal(getDecodedDSOLocal(Record[OpNum++]));
4382 NewGA->setPartition(
4386 ValueList.push_back(NewGA, getVirtualTypeID(NewGA->getType(), TypeID));
4398 TheModule->IsNewDbgInfoFormat =
4403 this->ValueTypeCallback = std::move(Callbacks.ValueType);
4419 std::string TentativeDataLayoutStr = TheModule->getDataLayoutStr();
4421 auto ResolveDataLayout = [&]() -> Error {
4428 // Auto-upgrade the layout string
4430 TentativeDataLayoutStr, TheModule->getTargetTriple());
4435 TheModule->getTargetTriple(), TentativeDataLayoutStr))
4444 TheModule->setDataLayout(MaybeDL.get());
4517 if (Error Err = MDLoader->parseModuleMetadata())
4521 if (Error Err = MDLoader->parseMetadataKinds())
4576 // are auto-upgraded.
4619 TheModule->setTargetTriple(S);
4633 TheModule->setModuleInlineAsm(S);
4666 // (https://github.com/llvm/llvm-project/blob/b6a93967d9c11e79802b5e75cec1584d6c8aa472/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp#L4714)
4690 VSTOffset = Record[0] - 1;
4697 TheModule->setSourceFileName(ValueName);
4702 this->ValueTypeCallback = std::nullopt;
4730 AttributeList Attrs = CB->getAttributes();
4731 for (unsigned i = 0; i != CB->arg_size(); ++i) {
4761 if (CB->isInlineAsm()) {
4762 const InlineAsm *IA = cast<InlineAsm>(CB->getCalledOperand());
4764 for (const InlineAsm::ConstraintInfo &CI : IA->ParseConstraints()) {
4781 switch (CB->getIntrinsicID()) {
4793 switch (CB->getIntrinsicID()) {
4817 CB->setAttributes(Attrs);
4827 if (MDLoader->hasFwdRefs())
4832 unsigned ModuleMDLoaderSize = MDLoader->size();
4837 for (Argument &I : F->args()) {
4855 auto getLastInstruction = [&]() -> Instruction * {
4856 if (CurBB && !CurBB->empty())
4857 return &CurBB->back();
4858 else if (CurBBNo && FunctionBBs[CurBBNo - 1] &&
4859 !FunctionBBs[CurBBNo - 1]->empty())
4860 return &FunctionBBs[CurBBNo - 1]->back();
4897 if (Error Err = MDLoader->parseMetadataAttachment(*F, InstructionList))
4902 "Must read all module-level metadata before function-level");
4903 if (Error Err = MDLoader->parseFunctionMetadata())
4940 auto &BBRefs = BBFRI->second;
4949 BBRefs[I]->insertInto(F);
4995 I->setDebugLoc(LastLoc);
5011 MDLoader->getMetadataFwdRefOrLoad(ScopeID - 1));
5017 MDLoader->getMetadataFwdRefOrLoad(IAID - 1));
5021 LastLoc = DILocation::get(Scope->getContext(), Line, Col, Scope, IA,
5023 I->setDebugLoc(LastLoc);
5035 int Opc = getDecodedUnaryOpcode(Record[OpNum++], LHS->getType());
5036 if (Opc == -1)
5045 I->setFastMathFlags(FMF);
5055 popValue(Record, OpNum, NextValueNo, LHS->getType(), TypeID, RHS,
5060 int Opc = getDecodedBinaryOpcode(Record[OpNum++], LHS->getType());
5061 if (Opc == -1)
5072 cast<BinaryOperator>(I)->setHasNoSignedWrap(true);
5074 cast<BinaryOperator>(I)->setHasNoUnsignedWrap(true);
5080 cast<BinaryOperator>(I)->setIsExact(true);
5083 cast<PossiblyDisjointInst>(I)->setIsDisjoint(true);
5087 I->setFastMathFlags(FMF);
5104 if (Opc == -1 || !ResTy)
5111 Temp->insertInto(CurBB, CurBB->end());
5123 cast<PossiblyNonNegInst>(I)->setNonNeg(true);
5126 cast<TruncInst>(I)->setHasNoUnsignedWrap(true);
5128 cast<TruncInst>(I)->setHasNoSignedWrap(true);
5163 if (BasePtr->getType()->isVectorTy())
5181 if (cast<GEPOperator>(I)->getNumIndices() != 0) {
5183 for (Value *Idx : drop_begin(cast<GEPOperator>(I)->indices())) {
5187 Idx->getType()->isVectorTy()
5188 ? cast<ConstantInt>(cast<Constant>(Idx)->getSplatValue())
5190 SubType = IdxC->getZExtValue();
5199 ResTypeID = getVirtualTypeID(I->getType()->getScalarType(), ResTypeID);
5200 if (I->getType()->isVectorTy())
5201 ResTypeID = getVirtualTypeID(I->getType(), ResTypeID);
5204 GEP->setNoWrapFlags(NW);
5215 Type *Ty = Agg->getType();
5224 bool IsArray = Ty->isArrayTy();
5225 bool IsStruct = Ty->isStructTy();
5232 if (IsStruct && Index >= Ty->getStructNumElements())
5234 if (IsArray && Index >= Ty->getArrayNumElements())
5239 Ty = Ty->getStructElementType(Index);
5242 Ty = Ty->getArrayElementType();
5269 Type *CurTy = Agg->getType();
5271 bool IsArray = CurTy->isArrayTy();
5272 bool IsStruct = CurTy->isStructTy();
5279 if (IsStruct && Index >= CurTy->getStructNumElements())
5281 if (IsArray && Index >= CurTy->getArrayNumElements())
5286 CurTy = CurTy->getStructElementType(Index);
5288 CurTy = CurTy->getArrayElementType();
5291 if (CurTy != Val->getType())
5309 popValue(Record, OpNum, NextValueNo, TrueVal->getType(), TypeID,
5329 popValue(Record, OpNum, NextValueNo, TrueVal->getType(), ValTypeID,
5336 dyn_cast<VectorType>(Cond->getType())) {
5338 if (vector_type->getElementType() != Type::getInt1Ty(Context))
5342 if (Cond->getType() != Type::getInt1Ty(Context))
5352 I->setFastMathFlags(FMF);
5364 if (!Vec->getType()->isVectorTy())
5378 if (!Vec->getType()->isVectorTy())
5381 cast<VectorType>(Vec->getType())->getElementType(),
5397 popValue(Record, OpNum, NextValueNo, Vec1->getType(), Vec1TypeID,
5404 if (!Vec1->getType()->isVectorTy() || !Vec2->getType()->isVectorTy())
5409 getVirtualTypeID(I->getType(), getContainedTypeID(Vec1TypeID));
5425 popValue(Record, OpNum, NextValueNo, LHS->getType(), LHSTypeID, RHS,
5434 bool IsFP = LHS->getType()->isFPOrFPVectorTy();
5452 ResTypeID = getVirtualTypeID(I->getType()->getScalarType());
5453 if (LHS->getType()->isVectorTy())
5454 ResTypeID = getVirtualTypeID(I->getType(), ResTypeID);
5457 I->setFastMathFlags(FMF);
5579 CatchSwitch->addHandler(Handler);
5581 ResTypeID = getVirtualTypeID(I->getType());
5617 ResTypeID = getVirtualTypeID(I->getType());
5631 unsigned ValueBitWidth = cast<IntegerType>(OpTy)->getBitWidth();
5677 SI->addCase(Cst, DestBB);
5693 unsigned NumCases = (Record.size()-3)/2;
5704 SI->addCase(CaseVal, DestBB);
5717 unsigned NumDests = Record.size()-2;
5722 IBI->addDestination(DestBB);
5757 PointerType *CalleeTy = dyn_cast<PointerType>(Callee->getType());
5766 if (Record.size() < FTy->getNumParams() + OpNum)
5771 for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i, ++OpNum) {
5773 Ops.push_back(getValue(Record, OpNum, NextValueNo, FTy->getParamType(i),
5780 if (!FTy->isVarArg()) {
5804 cast<InvokeInst>(I)->setCallingConv(
5806 cast<InvokeInst>(I)->setAttributes(PAL);
5808 I->deleteValue();
5851 PointerType *OpTy = dyn_cast<PointerType>(Callee->getType());
5860 if (Record.size() < FTy->getNumParams() + OpNum)
5866 for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i, ++OpNum) {
5869 if (FTy->getParamType(i)->isLabelTy())
5872 Arg = getValue(Record, OpNum, NextValueNo, FTy->getParamType(i),
5881 if (!FTy->isVarArg()) {
5900 InlineAsm::ConstraintInfoVector ConstraintInfo = IA->ParseConstraints();
5909 unsigned FirstBlockArg = Args.size() - IndirectDests.size();
5911 unsigned LabelNo = ArgNo - FirstBlockArg;
5913 if (!BA || BA->getFunction() != F ||
5915 BA->getBasicBlock() != IndirectDests[LabelNo])
5926 ArgTys.push_back(Arg->getType());
5928 FunctionType::get(FTy->getReturnType(), ArgTys, FTy->isVarArg());
5931 std::string Constraints = IA->getConstraintString();
5948 Callee = InlineAsm::get(FTy, IA->getAsmString(), Constraints,
5949 IA->hasSideEffects(), IA->isAlignStack(),
5950 IA->getDialect(), IA->canThrow());
5959 cast<CallBrInst>(I)->setCallingConv(
5961 cast<CallBrInst>(I)->setAttributes(PAL);
5963 I->deleteValue();
5982 // There is an optional final record for fast-math-flags if this phi has a
5983 // floating-point type.
5984 size_t NumArgs = (Record.size() - 1) / 2;
5986 if ((Record.size() - 1) % 2 == 1 && !isa<FPMathOperator>(PN)) {
5987 PN->deleteValue();
5996 PN->deleteValue();
6006 PN->addIncoming(It->second, BB);
6030 PN->deleteValue();
6031 PhiConstExprBB->eraseFromParent();
6035 if (EdgeBB == PhiConstExprBB && !EdgeBB->empty()) {
6039 PN->addIncoming(V, BB);
6048 FastMathFlags FMF = getDecodedFastMathFlags(Record[Record.size() - 1]);
6050 I->setFastMathFlags(FMF);
6079 if (!F->hasPersonalityFn())
6080 F->setPersonalityFn(cast<Constant>(PersFn));
6081 else if (F->getPersonalityFn() != cast<Constant>(PersFn))
6088 LP->setCleanup(IsCleanup);
6102 !isa<ArrayType>(Val->getType())) &&
6105 isa<ArrayType>(Val->getType())) &&
6107 LP->addClause(cast<Constant>(Val));
6128 return error("Missing element type for old-style alloca");
6143 const DataLayout &DL = TheModule->getDataLayout();
6147 if (!Align && !Ty->isSized(&Visited))
6152 if (!Size->getType()->isIntegerTy())
6156 AI->setUsedWithInAlloca(InAlloca);
6157 AI->setSwiftError(SwiftError);
6159 ResTypeID = getVirtualTypeID(AI->getType(), TyID);
6171 if (!isa<PointerType>(Op->getType()))
6186 if (Error Err = typeCheckLoadStoreInst(Ty, Op->getType()))
6193 if (!Align && !Ty->isSized(&Visited))
6196 Align = TheModule->getDataLayout().getABITypeAlign(Ty);
6210 if (!isa<PointerType>(Op->getType()))
6225 if (Error Err = typeCheckLoadStoreInst(Ty, Op->getType()))
6267 if (Error Err = typeCheckLoadStoreInst(Val->getType(), Ptr->getType()))
6273 if (!Align && !Val->getType()->isSized(&Visited))
6276 Align = TheModule->getDataLayout().getABITypeAlign(Val->getType());
6288 !isa<PointerType>(Ptr->getType()))
6303 if (Error Err = typeCheckLoadStoreInst(Val->getType(), Ptr->getType()))
6333 if (!isa<PointerType>(Ptr->getType()))
6343 if (popValue(Record, OpNum, NextValueNo, Cmp->getType(), CmpTypeID,
6356 if (Error Err = typeCheckLoadStoreInst(Cmp->getType(), Ptr->getType()))
6369 TheModule->getDataLayout().getTypeStoreSize(Cmp->getType()));
6373 cast<AtomicCmpXchgInst>(I)->setVolatile(Record[OpNum]);
6379 I->insertInto(CurBB, CurBB->end());
6383 cast<AtomicCmpXchgInst>(I)->setWeak(Record[OpNum + 4]);
6385 ResTypeID = getVirtualTypeID(I->getType(), {CmpTypeID, I1TypeID});
6401 if (!isa<PointerType>(Ptr->getType()))
6410 if (popValue(Record, OpNum, NextValueNo, Cmp->getType(), CmpTypeID, Val,
6426 if (Error Err = typeCheckLoadStoreInst(Cmp->getType(), Ptr->getType()))
6444 Align(TheModule->getDataLayout().getTypeStoreSize(Cmp->getType()));
6448 cast<AtomicCmpXchgInst>(I)->setVolatile(IsVol);
6449 cast<AtomicCmpXchgInst>(I)->setWeak(IsWeak);
6452 ResTypeID = getVirtualTypeID(I->getType(), {CmpTypeID, I1TypeID});
6469 if (!isa<PointerType>(Ptr->getType()))
6511 Align(TheModule->getDataLayout().getTypeStoreSize(Val->getType()));
6515 cast<AtomicRMWInst>(I)->setVolatile(IsVol);
6542 Inst->getParent()->insertDbgRecordBefore(
6543 new DbgLabelRecord(Label, DebugLoc(DIL)), Inst->getIterator());
6561 // dbg_value (FUNC_CODE_DEBUG_RECORD_VALUE_SIMPLE - abbrev'd)
6568 // Common fields (0-2).
6581 // use-before-defs are encoded with the standard non-abbrev record
6589 assert((SlotBefore == Slot - 1) && "unexpected fwd ref");
6618 Inst->getParent()->insertDbgRecordBefore(DVR, Inst->getIterator());
6652 PointerType *OpTy = dyn_cast<PointerType>(Callee->getType());
6661 if (Record.size() < FTy->getNumParams() + OpNum)
6667 for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i, ++OpNum) {
6669 if (FTy->getParamType(i)->isLabelTy())
6673 FTy->getParamType(i), ArgTyID, CurBB));
6680 if (!FTy->isVarArg()) {
6702 cast<CallInst>(I)->setCallingConv(
6711 cast<CallInst>(I)->setTailCallKind(TCK);
6712 cast<CallInst>(I)->setAttributes(PAL);
6716 I->deleteValue();
6721 return error("Fast-math-flags specified for call without "
6722 "floating-point scalar or vector return type");
6723 I->setFastMathFlags(FMF);
6784 I->deleteValue();
6788 I->deleteValue();
6791 I->insertInto(CurBB, CurBB->end());
6794 if (I->isTerminator()) {
6799 // Non-void values get registered in the value table for future use.
6800 if (!I->getType()->isVoidTy()) {
6801 assert(I->getType() == getTypeByID(ResTypeID) &&
6815 if (!A->getParent()) {
6818 if ((A = dyn_cast_or_null<Argument>(ValueList[i])) && !A->getParent()) {
6819 A->replaceAllUsesWith(PoisonValue::get(A->getType()));
6828 if (MDLoader->hasFwdRefs())
6832 PhiConstExprBB->eraseFromParent();
6839 From->getTerminator()->replaceSuccessorWith(To, EdgeBB);
6840 To->replacePhiUsesWith(From, EdgeBB);
6841 EdgeBB->moveBefore(To);
6846 MDLoader->shrinkTo(ModuleMDLoaderSize);
6855 while (DeferredFunctionInfoIterator->second == 0) {
6860 assert(VSTOffset == 0 || !F->hasName());
6877 //===----------------------------------------------------------------------===//
6879 //===----------------------------------------------------------------------===//
6884 if (!F || !F->isMaterializable())
6891 if (DFII->second == 0)
6900 if (Error JumpFailed = Stream.JumpToBit(DFII->second))
6905 F->IsNewDbgInfoFormat = true;
6909 F->setIsMaterializable(false);
6918 SeenAnyDebugInfo ? SeenDebugRecord : F->getParent()->IsNewDbgInfoFormat;
6928 if (NewDbgInfoFormatDesired != F->getParent()->IsNewDbgInfoFormat)
6929 F->getParent()->setNewDbgInfoFormatFlag(NewDbgInfoFormatDesired);
6931 F->setNewDbgInfoFormatFlag(NewDbgInfoFormatDesired);
6934 // desired format instead of reading flags, in case we are lazy-loading and
6937 // desire the intrinsic format; everything else is a no-op or handled by the
6939 bool ModuleIsNewDbgInfoFormat = F->getParent()->IsNewDbgInfoFormat;
6941 F->setNewDbgInfoFormatFlag(ModuleIsNewDbgInfoFormat);
6943 F->setIsNewDbgInfoFormat(ModuleIsNewDbgInfoFormat);
6951 for (User *U : llvm::make_early_inc_range(I.first->materialized_users()))
6956 // Finish fn->subprogram upgrade for materialized functions.
6957 if (DISubprogram *SP = MDLoader->lookupSubprogramForFunction(F))
6958 F->setSubprogram(SP);
6961 if (!MDLoader->isStrippingTBAA()) {
6966 MDLoader->setStripTBAA(true);
6967 stripTBAA(F->getParent());
6974 if (MD->getOperand(0) != nullptr && isa<MDString>(MD->getOperand(0))) {
6975 MDString *MDS = cast<MDString>(MD->getOperand(0));
6976 StringRef ProfName = MDS->getString();
6982 ExpectedNumOperands = BI->getNumSuccessors();
6984 ExpectedNumOperands = SI->getNumSuccessors();
6988 ExpectedNumOperands = IBI->getNumDestinations();
6997 if (MD->getNumOperands() != Offset + ExpectedNumOperands)
7004 CI->removeRetAttrs(AttributeFuncs::typeIncompatible(
7005 CI->getFunctionType()->getReturnType()));
7007 for (unsigned ArgNo = 0; ArgNo < CI->arg_size(); ++ArgNo)
7008 CI->removeParamAttrs(ArgNo, AttributeFuncs::typeIncompatible(
7009 CI->getArgOperand(ArgNo)->getType()));
7016 // Bring in any functions that this function forward-referenced via
7053 for (auto *U : I.first->users()) {
7057 if (!I.first->use_empty())
7058 I.first->replaceAllUsesWith(I.second);
7059 I.first->eraseFromParent();
7135 assert(Offset > 0 && "Expected non-zero VST offset");
7185 auto Linkage = VLI->second;
7199 auto Linkage = VLI->second;
7264 // Add the module if it is a per-module index (has a source file name).
7314 auto &Hash = getThisModule()->second;
7329 VSTOffset = Record[0] - 1;
7511 unsigned FirstWORef = Refs.size() - WOCnt;
7512 unsigned RefNo = FirstWORef - ROCnt;
7545 ". Version should be in the range [1-" +
7586 // is a per-module index or a combined index file. In the per-module
7646 // string table section in the per-module index, we create a single
7680 FS->setModulePath(getThisModule()->first());
7681 FS->setOriginalName(std::get<1>(VIAndOriginalGUID));
7697 // string table section in the per-module index, we create a single
7700 AS->setModulePath(getThisModule()->first());
7706 AS->setAliasee(AliaseeVI, AliaseeInModule);
7709 AS->setOriginalName(std::get<1>(GUID));
7731 FS->setModulePath(getThisModule()->first());
7733 FS->setOriginalName(std::get<1>(GUID));
7758 VS->setModulePath(getThisModule()->first());
7759 VS->setVTableFuncs(VTableFuncs);
7761 VS->setOriginalName(std::get<1>(GUID));
7800 NumRORefs = Record[RefListStartIndex - NumRORefsOffset];
7828 FS->setModulePath(ModuleIdMap[ModuleId]);
7843 AS->setModulePath(ModuleIdMap[ModuleId]);
7846 auto AliaseeInModule = TheIndex.findSummaryInModule(AliaseeVI, AS->modulePath());
7847 AS->setAliasee(AliaseeVI, AliaseeInModule);
7874 FS->setModulePath(ModuleIdMap[ModuleId]);
7885 LastSeenSummary->setOriginalName(OriginalName);
8002 assert(Record.size() - I >= 2);
8005 assert(Record.size() - I >= NumStackEntries);
8016 assert(I == Record.size() || Record.size() - I == NumMIBs);
8037 assert(Record.size() - I >= 2);
8040 assert(Record.size() - I >= NumStackEntries);
8049 assert(Record.size() - I >= NumVersions);
8055 assert(I == Record.size() || Record.size() - I == NumMIBs);
8118 ModuleIdMap[ModuleId] = LastSeenModule->first();
8132 LastSeenModule->second[Pos++] = Val;
8208 //===----------------------------------------------------------------------===//
8210 //===----------------------------------------------------------------------===//
8217 return std::move(FOrErr->Mods);
8248 uint64_t IdentificationBit = -1ull;
8250 IdentificationBit = Stream.GetCurrentBitNo() - BCBegin * 8;
8267 uint64_t ModuleBit = Stream.GetCurrentBitNo() - BCBegin * 8;
8272 BCBegin, Stream.getCurrentByteNo() - BCBegin),
8286 // with "llvm-cat -b".
8329 /// Get a lazy one-at-time loading module from bitcode.
8333 /// in forward-referenced functions from block address references.
8344 if (IdentificationBit != -1ull) {
8359 M->setMaterializer(R);
8362 if (Error Err = R->parseBitcodeInto(M.get(), ShouldLazyLoadMetadata,
8368 if (Error Err = M->materializeAll())
8372 if (Error Err = R->materializeForwardReferencedFunctions())
8515 // Ignore other sub-blocks.
8534 if (MsOrErr->size() != 1)
8548 return BM->getLazyModule(Context, ShouldLazyLoadMetadata, IsImporting,
8558 (*MOrErr)->setOwnedMemoryBuffer(std::move(Buffer));
8565 // TODO: Restore the use-lists to the in-memory state when the bitcode was
8576 return BM->parseModule(Context, Callbacks);
8609 return BM->readSummary(CombinedIndex, BM->getModuleIdentifier());
8618 return BM->getSummary();
8626 return BM->getLTOInfo();
8636 if (IgnoreEmptyThinLTOIndexFile && !(*FileOrErr)->getBufferSize())