35 while (!BlockAddrFwdRefs.empty()) {
36 Function *
F = BlockAddrFwdRefs.begin()->first;
45 std::vector<Type*>().
swap(TypeList);
49 std::vector<AttributeSet>().
swap(MAttributes);
50 std::vector<BasicBlock*>().
swap(FunctionBBs);
51 std::vector<Function*>().
swap(FunctionsWithBodies);
52 DeferredFunctionInfo.clear();
55 assert(BlockAddrFwdRefs.empty() &&
"Unresolved blockaddress fwd references");
64 template<
typename StrTy>
67 if (Idx > Record.
size())
70 for (
unsigned i = Idx, e = Record.
size(); i != e; ++i)
71 Result += (
char)Record[i];
204 void *operator new(
size_t s) {
205 return User::operator
new(s, 1);
213 static bool classof(
const Value *V) {
214 return isa<ConstantExpr>(V) &&
215 cast<ConstantExpr>(V)->getOpcode() == Instruction::UserOp1;
241 WeakVH &OldV = ValuePtrs[Idx];
249 if (
Constant *PHC = dyn_cast<Constant>(&*OldV)) {
250 ResolveConstants.push_back(std::make_pair(PHC, Idx));
254 Value *PrevVal = OldV;
255 OldV->replaceAllUsesWith(V);
266 if (
Value *V = ValuePtrs[Idx]) {
267 assert(Ty == V->getType() &&
"Type mismatch in constant table!");
268 return cast<Constant>(V);
272 Constant *
C =
new ConstantPlaceHolder(Ty, Context);
281 if (
Value *V = ValuePtrs[Idx]) {
282 assert((Ty == 0 || Ty == V->getType()) &&
"Type mismatch in value table!");
287 if (Ty == 0)
return 0;
305 std::sort(ResolveConstants.begin(), ResolveConstants.end());
309 while (!ResolveConstants.empty()) {
311 Constant *Placeholder = ResolveConstants.back().first;
312 ResolveConstants.pop_back();
317 while (!Placeholder->use_empty()) {
323 if (!isa<Constant>(U) || isa<GlobalValue>(U)) {
330 Constant *UserC = cast<Constant>(U);
334 if (!isa<ConstantPlaceHolder>(*
I)) {
337 }
else if (*
I == Placeholder) {
342 ResolveConstantsTy::iterator It =
343 std::lower_bound(ResolveConstants.begin(), ResolveConstants.end(),
344 std::pair<Constant*, unsigned>(cast<Constant>(*I),
346 assert(It != ResolveConstants.end() && It->first == *
I);
350 NewOps.push_back(cast<Constant>(NewOp));
355 if (
ConstantArray *UserCA = dyn_cast<ConstantArray>(UserC)) {
357 }
else if (
ConstantStruct *UserCS = dyn_cast<ConstantStruct>(UserC)) {
359 }
else if (isa<ConstantVector>(UserC)) {
362 assert(isa<ConstantExpr>(UserC) &&
"Must be a ConstantExpr.");
363 NewC = cast<ConstantExpr>(UserC)->getWithOperands(NewOps);
372 Placeholder->replaceAllUsesWith(RealVal);
386 WeakVH &OldV = MDValuePtrs[Idx];
393 MDNode *PrevVal = cast<MDNode>(OldV);
394 OldV->replaceAllUsesWith(V);
398 MDValuePtrs[Idx] = V;
405 if (
Value *V = MDValuePtrs[Idx]) {
406 assert(V->getType()->isMetadataTy() &&
"Type mismatch in value table!");
412 MDValuePtrs[Idx] = V;
416 Type *BitcodeReader::getTypeByID(
unsigned ID) {
418 if (ID >= TypeList.size())
421 if (
Type *Ty = TypeList[ID])
439 uint64_t EncodedAttrs) {
444 unsigned Alignment = (EncodedAttrs & (0xffffULL << 16)) >> 16;
446 "Alignment must be a power of two.");
450 B.
addRawValue(((EncodedAttrs & (0xfffffULL << 32)) >> 11) |
451 (EncodedAttrs & 0xffff));
454 error_code BitcodeReader::ParseAttributeBlock() {
458 if (!MAttributes.empty())
469 switch (Entry.
Kind) {
487 if (Record.
size() & 1)
490 for (
unsigned i = 0, e = Record.
size(); i != e; i += 2) {
493 Attrs.
push_back(AttributeSet::get(Context, Record[i], B));
496 MAttributes.push_back(AttributeSet::get(Context, Attrs));
501 for (
unsigned i = 0, e = Record.
size(); i != e; ++i)
502 Attrs.
push_back(MAttributeGroups[Record[i]]);
504 MAttributes.push_back(AttributeSet::get(Context, Attrs));
602 error_code BitcodeReader::ParseAttributeGroupBlock() {
606 if (!MAttributeGroups.empty())
615 switch (Entry.
Kind) {
632 if (Record.
size() < 3)
635 uint64_t GrpID = Record[0];
636 uint64_t Idx = Record[1];
639 for (
unsigned i = 2, e = Record.
size(); i != e; ++i) {
640 if (Record[i] == 0) {
642 if (
error_code EC = ParseAttrKind(Record[++i], &Kind))
646 }
else if (Record[i] == 1) {
648 if (
error_code EC = ParseAttrKind(Record[++i], &Kind))
655 assert((Record[i] == 3 || Record[i] == 4) &&
656 "Invalid attribute group entry");
657 bool HasValue = (Record[i++] == 4);
661 while (Record[i] != 0 && i != e)
662 KindStr += Record[i++];
663 assert(Record[i] == 0 &&
"Kind string not null terminated");
668 while (Record[i] != 0 && i != e)
669 ValStr += Record[i++];
670 assert(Record[i] == 0 &&
"Value string not null terminated");
677 MAttributeGroups[GrpID] = AttributeSet::get(Context, Idx, B);
688 return ParseTypeTableBody();
691 error_code BitcodeReader::ParseTypeTableBody() {
692 if (!TypeList.empty())
696 unsigned NumRecords = 0;
704 switch (Entry.
Kind) {
709 if (NumRecords != TypeList.size())
726 if (Record.
size() < 1)
728 TypeList.resize(Record[0]);
761 if (Record.
size() < 1)
768 if (Record.
size() < 1)
771 if (Record.
size() == 2)
772 AddressSpace = Record[1];
773 ResultTy = getTypeByID(Record[0]);
782 if (Record.
size() < 3)
785 for (
unsigned i = 3, e = Record.
size(); i != e; ++i) {
786 if (
Type *
T = getTypeByID(Record[i]))
792 ResultTy = getTypeByID(Record[2]);
793 if (ResultTy == 0 || ArgTys.
size() < Record.
size()-3)
801 if (Record.
size() < 2)
804 for (
unsigned i = 2, e = Record.
size(); i != e; ++i) {
805 if (
Type *
T = getTypeByID(Record[i]))
811 ResultTy = getTypeByID(Record[1]);
812 if (ResultTy == 0 || ArgTys.
size() < Record.
size()-2)
819 if (Record.
size() < 1)
822 for (
unsigned i = 1, e = Record.
size(); i != e; ++i) {
823 if (
Type *
T = getTypeByID(Record[i]))
828 if (EltTys.
size() != Record.
size()-1)
839 if (Record.
size() < 1)
842 if (NumRecords >= TypeList.size())
846 StructType *Res = cast_or_null<StructType>(TypeList[NumRecords]);
849 TypeList[NumRecords] = 0;
855 for (
unsigned i = 1, e = Record.
size(); i != e; ++i) {
856 if (
Type *
T = getTypeByID(Record[i]))
861 if (EltTys.
size() != Record.
size()-1)
863 Res->
setBody(EltTys, Record[0]);
868 if (Record.
size() != 1)
871 if (NumRecords >= TypeList.size())
875 StructType *Res = cast_or_null<StructType>(TypeList[NumRecords]);
878 TypeList[NumRecords] = 0;
886 if (Record.
size() < 2)
888 if ((ResultTy = getTypeByID(Record[1])))
894 if (Record.
size() < 2)
896 if ((ResultTy = getTypeByID(Record[1])))
903 if (NumRecords >= TypeList.size())
905 assert(ResultTy &&
"Didn't read a type?");
906 assert(TypeList[NumRecords] == 0 &&
"Already read type?");
907 TypeList[NumRecords++] = ResultTy;
911 error_code BitcodeReader::ParseValueSymbolTable() {
922 switch (Entry.
Kind) {
941 unsigned ValueID = Record[0];
942 if (ValueID >= ValueList.
size())
944 Value *V = ValueList[ValueID];
966 unsigned NextMDValueNo = MDValueList.
size();
977 switch (Entry.
Kind) {
988 bool IsFunctionLocal =
false;
1002 unsigned NextBitCode = Stream.
readRecord(Code, Record);
1006 unsigned Size = Record.
size();
1008 for (
unsigned i = 0; i != Size; ++i) {
1017 IsFunctionLocal =
true;
1020 if (Record.
size() % 2 == 1)
1023 unsigned Size = Record.
size();
1025 for (
unsigned i = 0; i != Size; i += 2) {
1026 Type *Ty = getTypeByID(Record[i]);
1037 IsFunctionLocal =
false;
1048 if (Record.
size() < 2)
1051 unsigned Kind = Record[0];
1055 if (!MDKindMap.
insert(std::make_pair(Kind, NewKind)).second)
1076 error_code BitcodeReader::ResolveGlobalAndAliasInits() {
1077 std::vector<std::pair<GlobalVariable*, unsigned> > GlobalInitWorklist;
1078 std::vector<std::pair<GlobalAlias*, unsigned> > AliasInitWorklist;
1079 std::vector<std::pair<Function*, unsigned> > FunctionPrefixWorklist;
1081 GlobalInitWorklist.swap(GlobalInits);
1082 AliasInitWorklist.swap(AliasInits);
1083 FunctionPrefixWorklist.swap(FunctionPrefixes);
1085 while (!GlobalInitWorklist.empty()) {
1086 unsigned ValID = GlobalInitWorklist.back().second;
1087 if (ValID >= ValueList.
size()) {
1089 GlobalInits.push_back(GlobalInitWorklist.back());
1091 if (
Constant *
C = dyn_cast<Constant>(ValueList[ValID]))
1092 GlobalInitWorklist.back().first->setInitializer(
C);
1096 GlobalInitWorklist.pop_back();
1099 while (!AliasInitWorklist.empty()) {
1100 unsigned ValID = AliasInitWorklist.back().second;
1101 if (ValID >= ValueList.
size()) {
1102 AliasInits.push_back(AliasInitWorklist.back());
1104 if (
Constant *
C = dyn_cast<Constant>(ValueList[ValID]))
1105 AliasInitWorklist.back().first->setAliasee(
C);
1109 AliasInitWorklist.pop_back();
1112 while (!FunctionPrefixWorklist.empty()) {
1113 unsigned ValID = FunctionPrefixWorklist.back().second;
1114 if (ValID >= ValueList.
size()) {
1115 FunctionPrefixes.push_back(FunctionPrefixWorklist.back());
1117 if (
Constant *
C = dyn_cast<Constant>(ValueList[ValID]))
1118 FunctionPrefixWorklist.back().first->setPrefixData(
C);
1122 FunctionPrefixWorklist.pop_back();
1130 std::transform(Vals.
begin(), Vals.
end(), Words.begin(),
1133 return APInt(TypeBits, Words);
1144 unsigned NextCstNo = ValueList.
size();
1148 switch (Entry.
Kind) {
1153 if (NextCstNo != ValueList.
size())
1168 unsigned BitCode = Stream.
readRecord(Entry.
ID, Record);
1177 if (Record[0] >= TypeList.size())
1179 CurTy = TypeList[Record[0]];
1204 APInt(16, (uint16_t)Record[0])));
1207 APInt(32, (uint32_t)Record[0])));
1210 APInt(64, Record[0])));
1213 uint64_t Rearrange[2];
1214 Rearrange[0] = (Record[1] & 0xffffLL) | (Record[0] << 16);
1215 Rearrange[1] = Record[0] >> 48;
1217 APInt(80, Rearrange)));
1220 APInt(128, Record)));
1223 APInt(128, Record)));
1233 unsigned Size = Record.size();
1236 if (
StructType *STy = dyn_cast<StructType>(CurTy)) {
1237 for (
unsigned i = 0; i != Size; ++i)
1239 STy->getElementType(i)));
1241 }
else if (
ArrayType *ATy = dyn_cast<ArrayType>(CurTy)) {
1242 Type *EltTy = ATy->getElementType();
1243 for (
unsigned i = 0; i != Size; ++i)
1246 }
else if (
VectorType *VTy = dyn_cast<VectorType>(CurTy)) {
1247 Type *EltTy = VTy->getElementType();
1248 for (
unsigned i = 0; i != Size; ++i)
1270 Type *EltTy = cast<SequentialType>(CurTy)->getElementType();
1271 unsigned Size = Record.size();
1275 if (isa<VectorType>(CurTy))
1281 if (isa<VectorType>(CurTy))
1287 if (isa<VectorType>(CurTy))
1293 if (isa<VectorType>(CurTy))
1300 if (isa<VectorType>(CurTy))
1306 std::transform(Record.begin(), Record.end(), Elts.
begin(),
1308 if (isa<VectorType>(CurTy))
1319 if (Record.size() < 3)
1328 if (Record.size() >= 4) {
1329 if (Opc == Instruction::Add ||
1330 Opc == Instruction::Sub ||
1331 Opc == Instruction::Mul ||
1332 Opc == Instruction::Shl) {
1337 }
else if (Opc == Instruction::SDiv ||
1338 Opc == Instruction::UDiv ||
1339 Opc == Instruction::LShr ||
1340 Opc == Instruction::AShr) {
1350 if (Record.size() < 3)
1356 Type *OpTy = getTypeByID(Record[1]);
1367 if (Record.size() & 1)
1370 for (
unsigned i = 0, e = Record.size(); i != e; i += 2) {
1371 Type *ElTy = getTypeByID(Record[i]);
1383 if (Record.size() < 3)
1390 if (
VectorType *VTy = dyn_cast<VectorType>(CurTy))
1392 VTy->getNumElements());
1401 if (Record.size() < 3)
1404 dyn_cast_or_null<VectorType>(getTypeByID(Record[0]));
1415 if (Record.size() < 3 || OpTy == 0)
1427 if (Record.size() < 3 || OpTy == 0)
1440 dyn_cast_or_null<VectorType>(getTypeByID(Record[0]));
1441 if (Record.size() < 4 || RTy == 0 || OpTy == 0)
1452 if (Record.size() < 4)
1454 Type *OpTy = getTypeByID(Record[0]);
1469 if (Record.size() < 2)
1471 std::string AsmStr, ConstrStr;
1472 bool HasSideEffects = Record[0] & 1;
1473 bool IsAlignStack = Record[0] >> 1;
1474 unsigned AsmStrSize = Record[1];
1475 if (2+AsmStrSize >= Record.size())
1477 unsigned ConstStrSize = Record[2+AsmStrSize];
1478 if (3+AsmStrSize+ConstStrSize > Record.size())
1481 for (
unsigned i = 0; i != AsmStrSize; ++i)
1482 AsmStr += (
char)Record[2+i];
1483 for (
unsigned i = 0; i != ConstStrSize; ++i)
1484 ConstrStr += (
char)Record[3+AsmStrSize+i];
1487 AsmStr, ConstrStr, HasSideEffects, IsAlignStack);
1493 if (Record.size() < 2)
1495 std::string AsmStr, ConstrStr;
1496 bool HasSideEffects = Record[0] & 1;
1497 bool IsAlignStack = (Record[0] >> 1) & 1;
1498 unsigned AsmDialect = Record[0] >> 2;
1499 unsigned AsmStrSize = Record[1];
1500 if (2+AsmStrSize >= Record.size())
1502 unsigned ConstStrSize = Record[2+AsmStrSize];
1503 if (3+AsmStrSize+ConstStrSize > Record.size())
1506 for (
unsigned i = 0; i != AsmStrSize; ++i)
1507 AsmStr += (
char)Record[2+i];
1508 for (
unsigned i = 0; i != ConstStrSize; ++i)
1509 ConstrStr += (
char)Record[3+AsmStrSize+i];
1512 AsmStr, ConstrStr, HasSideEffects, IsAlignStack,
1517 if (Record.size() < 3)
1519 Type *FnTy = getTypeByID(Record[0]);
1531 for (
size_t I = 0, E = Record[2];
I != E; ++
I) {
1544 BlockAddrFwdRefs[Fn].push_back(std::make_pair(Record[2], FwdRef));
1566 switch (Entry.
Kind) {
1583 unsigned RecordLength = Record.
size();
1584 if (RecordLength < 1)
1586 UseListRecords.push_back(Record);
1596 error_code BitcodeReader::RememberAndSkipFunctionBody() {
1598 if (FunctionsWithBodies.empty())
1601 Function *Fn = FunctionsWithBodies.back();
1602 FunctionsWithBodies.pop_back();
1606 DeferredFunctionInfo[Fn] = CurBit;
1616 ResolveGlobalAndAliasInits();
1617 if (!GlobalInits.empty() || !AliasInits.empty())
1625 UpgradedIntrinsics.push_back(std::make_pair(FI, NewFn));
1635 std::vector<std::pair<GlobalVariable*, unsigned> >().
swap(GlobalInits);
1636 std::vector<std::pair<GlobalAlias*, unsigned> >().
swap(AliasInits);
1640 error_code BitcodeReader::ParseModule(
bool Resume) {
1647 std::vector<std::string> SectionTable;
1648 std::vector<std::string> GCTable;
1654 switch (Entry.
Kind) {
1658 return GlobalCleanup();
1675 if (
error_code EC = ParseAttributeGroupBlock())
1685 SeenValueSymbolTable =
true;
1690 if (
error_code EC = ResolveGlobalAndAliasInits())
1700 if (!SeenFirstFunctionBody) {
1701 std::reverse(FunctionsWithBodies.begin(), FunctionsWithBodies.end());
1704 SeenFirstFunctionBody =
true;
1707 if (
error_code EC = RememberAndSkipFunctionBody())
1715 if (LazyStreamer && SeenValueSymbolTable) {
1737 if (Record.
size() < 1)
1740 unsigned module_version = Record[0];
1741 switch (module_version) {
1745 UseRelativeIDs =
false;
1748 UseRelativeIDs =
true;
1786 SectionTable.push_back(S);
1793 GCTable.push_back(S);
1800 if (Record.
size() < 6)
1802 Type *Ty = getTypeByID(Record[0]);
1807 unsigned AddressSpace = cast<PointerType>(Ty)->getAddressSpace();
1808 Ty = cast<PointerType>(Ty)->getElementType();
1810 bool isConstant = Record[1];
1812 unsigned Alignment = (1 << Record[4]) >> 1;
1815 if (Record[5]-1 >= SectionTable.
size())
1817 Section = SectionTable[Record[5]-1];
1820 if (Record.
size() > 6)
1824 if (Record.
size() > 7)
1827 bool UnnamedAddr =
false;
1828 if (Record.
size() > 8)
1829 UnnamedAddr = Record[8];
1831 bool ExternallyInitialized =
false;
1832 if (Record.
size() > 9)
1833 ExternallyInitialized = Record[9];
1836 new GlobalVariable(*TheModule, Ty, isConstant, Linkage, 0,
"", 0,
1837 TLM, AddressSpace, ExternallyInitialized);
1839 if (!Section.empty())
1847 if (
unsigned InitID = Record[2])
1848 GlobalInits.push_back(std::make_pair(NewGV, InitID-1));
1854 if (Record.
size() < 8)
1856 Type *Ty = getTypeByID(Record[0]);
1870 bool isProto = Record[2];
1876 if (Record[6]-1 >= SectionTable.
size())
1881 if (Record.
size() > 8 && Record[8]) {
1882 if (Record[8]-1 > GCTable.
size())
1886 bool UnnamedAddr =
false;
1887 if (Record.
size() > 9)
1888 UnnamedAddr = Record[9];
1890 if (Record.
size() > 10 && Record[10] != 0)
1891 FunctionPrefixes.push_back(std::make_pair(Func, Record[10]-1));
1897 FunctionsWithBodies.push_back(Func);
1898 if (LazyStreamer) DeferredFunctionInfo[
Func] = 0;
1905 if (Record.
size() < 3)
1907 Type *Ty = getTypeByID(Record[0]);
1916 if (Record.
size() > 3)
1919 AliasInits.push_back(std::make_pair(NewGA, Record[1]));
1925 if (Record.
size() < 1 || Record[0] > ValueList.
size())
1941 if (Stream.
Read(8) !=
'B' ||
1942 Stream.
Read(8) !=
'C' ||
1943 Stream.
Read(4) != 0x0 ||
1944 Stream.
Read(4) != 0xC ||
1945 Stream.
Read(4) != 0xE ||
1946 Stream.
Read(4) != 0xD)
1958 switch (Entry.
Kind) {
1993 Stream.
Read(6) == 2 && Stream.
Read(24) == 0xa0a0a &&
2012 switch (Entry.
Kind) {
2043 if (Stream.
Read(8) !=
'B' ||
2044 Stream.
Read(8) !=
'C' ||
2045 Stream.
Read(4) != 0x0 ||
2046 Stream.
Read(4) != 0xC ||
2047 Stream.
Read(4) != 0xE ||
2048 Stream.
Read(4) != 0xD)
2056 switch (Entry.
Kind) {
2064 return ParseModuleTriple(Triple);
2079 error_code BitcodeReader::ParseMetadataAttachment() {
2087 switch (Entry.
Kind) {
2104 unsigned RecordLength = Record.
size();
2105 if (Record.
empty() || (RecordLength - 1) % 2 == 1)
2108 for (
unsigned i = 1; i != RecordLength; i = i+2) {
2109 unsigned Kind = Record[i];
2111 MDKindMap.
find(Kind);
2112 if (I == MDKindMap.
end())
2117 InstsWithTBAATag.push_back(Inst);
2130 InstructionList.clear();
2131 unsigned ModuleValueListSize = ValueList.
size();
2132 unsigned ModuleMDValueListSize = MDValueList.
size();
2138 unsigned NextValueNo = ValueList.
size();
2140 unsigned CurBBNo = 0;
2149 switch (Entry.
Kind) {
2153 goto OutOfRecordLoop;
2164 NextValueNo = ValueList.
size();
2171 if (
error_code EC = ParseMetadataAttachment())
2189 unsigned BitCode = Stream.
readRecord(Entry.
ID, Record);
2194 if (Record.
size() < 1 || Record[0] == 0)
2197 FunctionBBs.resize(Record[0]);
2198 for (
unsigned i = 0, e = FunctionBBs.size(); i != e; ++i)
2200 CurBB = FunctionBBs[0];
2209 if (CurBB && !CurBB->
empty())
2211 else if (CurBBNo && FunctionBBs[CurBBNo-1] &&
2212 !FunctionBBs[CurBBNo-1]->empty())
2213 I = &FunctionBBs[CurBBNo-1]->back();
2223 if (CurBB && !CurBB->
empty())
2225 else if (CurBBNo && FunctionBBs[CurBBNo-1] &&
2226 !FunctionBBs[CurBBNo-1]->empty())
2227 I = &FunctionBBs[CurBBNo-1]->back();
2228 if (I == 0 || Record.
size() < 4)
2231 unsigned Line = Record[0], Col = Record[1];
2232 unsigned ScopeID = Record[2], IAID = Record[3];
2234 MDNode *Scope = 0, *IA = 0;
2235 if (ScopeID) Scope = cast<MDNode>(MDValueList.
getValueFwdRef(ScopeID-1));
2246 if (getValueTypePair(Record, OpNum, NextValueNo, LHS) ||
2247 popValue(Record, OpNum, NextValueNo, LHS->
getType(), RHS) ||
2248 OpNum+1 > Record.
size())
2255 InstructionList.push_back(I);
2256 if (OpNum < Record.
size()) {
2257 if (Opc == Instruction::Add ||
2258 Opc == Instruction::Sub ||
2259 Opc == Instruction::Mul ||
2260 Opc == Instruction::Shl) {
2262 cast<BinaryOperator>(I)->setHasNoSignedWrap(
true);
2264 cast<BinaryOperator>(
I)->setHasNoUnsignedWrap(
true);
2265 }
else if (Opc == Instruction::SDiv ||
2266 Opc == Instruction::UDiv ||
2267 Opc == Instruction::LShr ||
2268 Opc == Instruction::AShr) {
2270 cast<BinaryOperator>(
I)->setIsExact(
true);
2271 }
else if (isa<FPMathOperator>(I)) {
2293 if (getValueTypePair(Record, OpNum, NextValueNo, Op) ||
2294 OpNum+2 != Record.
size())
2297 Type *ResTy = getTypeByID(Record[OpNum]);
2299 if (Opc == -1 || ResTy == 0)
2304 InstructionList.push_back(Temp);
2310 InstructionList.push_back(I);
2317 if (getValueTypePair(Record, OpNum, NextValueNo, BasePtr))
2321 while (OpNum != Record.
size()) {
2323 if (getValueTypePair(Record, OpNum, NextValueNo, Op))
2329 InstructionList.push_back(I);
2331 cast<GetElementPtrInst>(
I)->setIsInBounds(
true);
2339 if (getValueTypePair(Record, OpNum, NextValueNo, Agg))
2343 for (
unsigned RecSize = Record.
size();
2344 OpNum != RecSize; ++OpNum) {
2345 uint64_t Index = Record[OpNum];
2346 if ((
unsigned)Index != Index)
2348 EXTRACTVALIdx.
push_back((
unsigned)Index);
2352 InstructionList.push_back(I);
2360 if (getValueTypePair(Record, OpNum, NextValueNo, Agg))
2363 if (getValueTypePair(Record, OpNum, NextValueNo, Val))
2367 for (
unsigned RecSize = Record.
size();
2368 OpNum != RecSize; ++OpNum) {
2369 uint64_t Index = Record[OpNum];
2370 if ((
unsigned)Index != Index)
2372 INSERTVALIdx.
push_back((
unsigned)Index);
2376 InstructionList.push_back(I);
2384 Value *TrueVal, *FalseVal, *Cond;
2385 if (getValueTypePair(Record, OpNum, NextValueNo, TrueVal) ||
2386 popValue(Record, OpNum, NextValueNo, TrueVal->
getType(), FalseVal) ||
2391 InstructionList.push_back(I);
2399 Value *TrueVal, *FalseVal, *Cond;
2400 if (getValueTypePair(Record, OpNum, NextValueNo, TrueVal) ||
2401 popValue(Record, OpNum, NextValueNo, TrueVal->
getType(), FalseVal) ||
2402 getValueTypePair(Record, OpNum, NextValueNo, Cond))
2407 dyn_cast<VectorType>(Cond->
getType())) {
2418 InstructionList.push_back(I);
2425 if (getValueTypePair(Record, OpNum, NextValueNo, Vec) ||
2429 InstructionList.push_back(I);
2435 Value *Vec, *Elt, *Idx;
2436 if (getValueTypePair(Record, OpNum, NextValueNo, Vec) ||
2437 popValue(Record, OpNum, NextValueNo,
2438 cast<VectorType>(Vec->
getType())->getElementType(), Elt) ||
2442 InstructionList.push_back(I);
2448 Value *Vec1, *Vec2, *Mask;
2449 if (getValueTypePair(Record, OpNum, NextValueNo, Vec1) ||
2450 popValue(Record, OpNum, NextValueNo, Vec1->
getType(), Vec2))
2453 if (getValueTypePair(Record, OpNum, NextValueNo, Mask))
2456 InstructionList.push_back(I);
2469 if (getValueTypePair(Record, OpNum, NextValueNo, LHS) ||
2470 popValue(Record, OpNum, NextValueNo, LHS->
getType(), RHS) ||
2471 OpNum+1 != Record.
size())
2478 InstructionList.push_back(I);
2484 unsigned Size = Record.
size();
2487 InstructionList.push_back(I);
2493 if (getValueTypePair(Record, OpNum, NextValueNo, Op))
2495 if (OpNum != Record.
size())
2499 InstructionList.push_back(I);
2503 if (Record.
size() != 1 && Record.
size() != 3)
2505 BasicBlock *TrueDest = getBasicBlock(Record[0]);
2509 if (Record.
size() == 1) {
2511 InstructionList.push_back(I);
2514 BasicBlock *FalseDest = getBasicBlock(Record[1]);
2515 Value *Cond = getValue(Record, 2, NextValueNo,
2517 if (FalseDest == 0 || Cond == 0)
2520 InstructionList.push_back(I);
2532 Type *OpTy = getTypeByID(Record[1]);
2533 unsigned ValueBitWidth = cast<IntegerType>(OpTy)->
getBitWidth();
2535 Value *Cond = getValue(Record, 2, NextValueNo, OpTy);
2537 if (OpTy == 0 || Cond == 0 || Default == 0)
2540 unsigned NumCases = Record[4];
2543 InstructionList.push_back(SI);
2545 unsigned CurIdx = 5;
2546 for (
unsigned i = 0; i != NumCases; ++i) {
2548 unsigned NumItems = Record[CurIdx++];
2549 for (
unsigned ci = 0; ci != NumItems; ++ci) {
2550 bool isSingleNumber = Record[CurIdx++];
2553 unsigned ActiveWords = 1;
2554 if (ValueBitWidth > 64)
2555 ActiveWords = Record[CurIdx++];
2558 CurIdx += ActiveWords;
2560 if (!isSingleNumber) {
2562 if (ValueBitWidth > 64)
2563 ActiveWords = Record[CurIdx++];
2567 CurIdx += ActiveWords;
2573 for ( ; Low.
ule(High); ++Low)
2578 BasicBlock *DestBB = getBasicBlock(Record[CurIdx++]);
2580 cve = CaseVals.
end(); cvi != cve; ++cvi)
2589 if (Record.
size() < 3 || (Record.
size() & 1) == 0)
2591 Type *OpTy = getTypeByID(Record[0]);
2592 Value *Cond = getValue(Record, 1, NextValueNo, OpTy);
2593 BasicBlock *Default = getBasicBlock(Record[2]);
2594 if (OpTy == 0 || Cond == 0 || Default == 0)
2596 unsigned NumCases = (Record.
size()-3)/2;
2598 InstructionList.push_back(SI);
2599 for (
unsigned i = 0, e = NumCases; i != e; ++i) {
2601 dyn_cast_or_null<ConstantInt>(getFnValueByID(Record[3+i*2], OpTy));
2602 BasicBlock *DestBB = getBasicBlock(Record[1+3+i*2]);
2603 if (CaseVal == 0 || DestBB == 0) {
2613 if (Record.
size() < 2)
2615 Type *OpTy = getTypeByID(Record[0]);
2616 Value *Address = getValue(Record, 1, NextValueNo, OpTy);
2617 if (OpTy == 0 || Address == 0)
2619 unsigned NumDests = Record.
size()-2;
2621 InstructionList.push_back(IBI);
2622 for (
unsigned i = 0, e = NumDests; i != e; ++i) {
2623 if (
BasicBlock *DestBB = getBasicBlock(Record[2+i])) {
2636 if (Record.
size() < 4)
2639 unsigned CCInfo = Record[1];
2640 BasicBlock *NormalBB = getBasicBlock(Record[2]);
2641 BasicBlock *UnwindBB = getBasicBlock(Record[3]);
2645 if (getValueTypePair(Record, OpNum, NextValueNo, Callee))
2653 if (FTy == 0 || NormalBB == 0 || UnwindBB == 0 ||
2654 Record.
size() < OpNum+FTy->getNumParams())
2658 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i, ++OpNum) {
2659 Ops.
push_back(getValue(Record, OpNum, NextValueNo,
2660 FTy->getParamType(i)));
2661 if (Ops.
back() == 0)
2665 if (!FTy->isVarArg()) {
2666 if (Record.
size() != OpNum)
2670 while (OpNum != Record.
size()) {
2672 if (getValueTypePair(Record, OpNum, NextValueNo, Op))
2679 InstructionList.push_back(I);
2680 cast<InvokeInst>(
I)->setCallingConv(
2681 static_cast<CallingConv::ID>(CCInfo));
2682 cast<InvokeInst>(
I)->setAttributes(PAL);
2688 if (getValueTypePair(Record, Idx, NextValueNo, Val))
2691 InstructionList.push_back(I);
2696 InstructionList.push_back(I);
2699 if (Record.
size() < 1 || ((Record.
size()-1)&1))
2701 Type *Ty = getTypeByID(Record[0]);
2706 InstructionList.push_back(PN);
2708 for (
unsigned i = 0, e = Record.
size()-1; i != e; i += 2) {
2714 V = getValueSigned(Record, 1+i, NextValueNo, Ty);
2716 V = getValue(Record, 1+i, NextValueNo, Ty);
2729 if (Record.
size() < 4)
2731 Type *Ty = getTypeByID(Record[Idx++]);
2735 if (getValueTypePair(Record, Idx, NextValueNo, PersFn))
2738 bool IsCleanup = !!Record[Idx++];
2739 unsigned NumClauses = Record[Idx++];
2742 for (
unsigned J = 0; J != NumClauses; ++J) {
2747 if (getValueTypePair(Record, Idx, NextValueNo, Val)) {
2753 !isa<ArrayType>(Val->
getType())) &&
2754 "Catch clause has a invalid type!");
2756 isa<ArrayType>(Val->
getType())) &&
2757 "Filter clause has invalid type!");
2762 InstructionList.push_back(I);
2767 if (Record.
size() != 4)
2770 dyn_cast_or_null<PointerType>(getTypeByID(Record[0]));
2771 Type *OpTy = getTypeByID(Record[1]);
2772 Value *Size = getFnValueByID(Record[2], OpTy);
2773 unsigned Align = Record[3];
2777 InstructionList.push_back(I);
2783 if (getValueTypePair(Record, OpNum, NextValueNo, Op) ||
2784 OpNum+2 != Record.
size())
2787 I =
new LoadInst(Op,
"", Record[OpNum+1], (1 << Record[OpNum]) >> 1);
2788 InstructionList.push_back(I);
2795 if (getValueTypePair(Record, OpNum, NextValueNo, Op) ||
2796 OpNum+4 != Record.
size())
2804 if (Ordering !=
NotAtomic && Record[OpNum] == 0)
2808 I =
new LoadInst(Op,
"", Record[OpNum+1], (1 << Record[OpNum]) >> 1,
2809 Ordering, SynchScope);
2810 InstructionList.push_back(I);
2816 if (getValueTypePair(Record, OpNum, NextValueNo, Ptr) ||
2817 popValue(Record, OpNum, NextValueNo,
2818 cast<PointerType>(Ptr->
getType())->getElementType(), Val) ||
2819 OpNum+2 != Record.
size())
2822 I =
new StoreInst(Val, Ptr, Record[OpNum+1], (1 << Record[OpNum]) >> 1);
2823 InstructionList.push_back(I);
2830 if (getValueTypePair(Record, OpNum, NextValueNo, Ptr) ||
2831 popValue(Record, OpNum, NextValueNo,
2832 cast<PointerType>(Ptr->
getType())->getElementType(), Val) ||
2833 OpNum+4 != Record.
size())
2841 if (Ordering !=
NotAtomic && Record[OpNum] == 0)
2844 I =
new StoreInst(Val, Ptr, Record[OpNum+1], (1 << Record[OpNum]) >> 1,
2845 Ordering, SynchScope);
2846 InstructionList.push_back(I);
2852 Value *Ptr, *Cmp, *New;
2853 if (getValueTypePair(Record, OpNum, NextValueNo, Ptr) ||
2854 popValue(Record, OpNum, NextValueNo,
2855 cast<PointerType>(Ptr->
getType())->getElementType(), Cmp) ||
2856 popValue(Record, OpNum, NextValueNo,
2857 cast<PointerType>(Ptr->
getType())->getElementType(), New) ||
2858 OpNum+3 != Record.
size())
2865 cast<AtomicCmpXchgInst>(
I)->setVolatile(Record[OpNum]);
2866 InstructionList.push_back(I);
2873 if (getValueTypePair(Record, OpNum, NextValueNo, Ptr) ||
2874 popValue(Record, OpNum, NextValueNo,
2875 cast<PointerType>(Ptr->
getType())->getElementType(), Val) ||
2876 OpNum+4 != Record.
size())
2886 I =
new AtomicRMWInst(Operation, Ptr, Val, Ordering, SynchScope);
2887 cast<AtomicRMWInst>(
I)->setVolatile(Record[OpNum+1]);
2888 InstructionList.push_back(I);
2892 if (2 != Record.
size())
2899 I =
new FenceInst(Context, Ordering, SynchScope);
2900 InstructionList.push_back(I);
2905 if (Record.
size() < 3)
2909 unsigned CCInfo = Record[1];
2913 if (getValueTypePair(Record, OpNum, NextValueNo, Callee))
2919 if (!FTy || Record.
size() < FTy->getNumParams()+OpNum)
2924 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i, ++OpNum) {
2925 if (FTy->getParamType(i)->isLabelTy())
2926 Args.
push_back(getBasicBlock(Record[OpNum]));
2928 Args.
push_back(getValue(Record, OpNum, NextValueNo,
2929 FTy->getParamType(i)));
2930 if (Args.
back() == 0)
2935 if (!FTy->isVarArg()) {
2936 if (OpNum != Record.
size())
2939 while (OpNum != Record.
size()) {
2941 if (getValueTypePair(Record, OpNum, NextValueNo, Op))
2948 InstructionList.push_back(I);
2949 cast<CallInst>(
I)->setCallingConv(
2950 static_cast<CallingConv::ID>(CCInfo>>1));
2951 cast<CallInst>(
I)->setTailCall(CCInfo & 1);
2952 cast<CallInst>(
I)->setAttributes(PAL);
2956 if (Record.
size() < 3)
2958 Type *OpTy = getTypeByID(Record[0]);
2959 Value *Op = getValue(Record, 1, NextValueNo, OpTy);
2960 Type *ResTy = getTypeByID(Record[2]);
2961 if (!OpTy || !Op || !ResTy)
2964 InstructionList.push_back(I);
2978 if (isa<TerminatorInst>(I)) {
2980 CurBB = CurBBNo < FunctionBBs.size() ? FunctionBBs[CurBBNo] : 0;
2992 if (
A->getParent() == 0) {
2994 for (
unsigned i = ModuleValueListSize, e = ValueList.
size(); i != e; ++i){
2995 if ((
A = dyn_cast<Argument>(ValueList[i])) &&
A->getParent() == 0) {
3010 BlockAddrFwdRefs.find(F);
3011 if (BAFRI != BlockAddrFwdRefs.end()) {
3012 std::vector<BlockAddrRefTy> &RefList = BAFRI->second;
3013 for (
unsigned i = 0, e = RefList.size(); i != e; ++i) {
3014 unsigned BlockIdx = RefList[i].first;
3015 if (BlockIdx >= FunctionBBs.size())
3023 BlockAddrFwdRefs.erase(BAFRI);
3027 ValueList.
shrinkTo(ModuleValueListSize);
3028 MDValueList.
shrinkTo(ModuleMDValueListSize);
3029 std::vector<BasicBlock*>().
swap(FunctionBBs);
3036 while (DeferredFunctionInfoIterator->second == 0) {
3053 if (
const Function *F = dyn_cast<Function>(GV)) {
3055 DeferredFunctionInfo.count(const_cast<Function*>(F));
3067 assert(DFII != DeferredFunctionInfo.end() &&
"Deferred function not found!");
3070 if (DFII->second == 0 && LazyStreamer)
3071 if (
error_code EC = FindFunctionInStream(F, DFII))
3081 for (UpgradedIntrinsicMap::iterator I = UpgradedIntrinsics.begin(),
3082 E = UpgradedIntrinsics.end(); I != E; ++
I) {
3083 if (I->first != I->second) {
3085 UE = I->first->
use_end(); UI != UE; ) {
3086 if (
CallInst* CI = dyn_cast<CallInst>(*UI++))
3099 return DeferredFunctionInfo.count(const_cast<Function*>(F));
3108 assert(DeferredFunctionInfo.count(F) &&
"No info to read function later?");
3116 assert(M == TheModule &&
3117 "Can only Materialize the Module this BitcodeReader is attached to.");
3137 for (std::vector<std::pair<Function*, Function*> >::iterator I =
3138 UpgradedIntrinsics.begin(), E = UpgradedIntrinsics.end(); I != E; ++
I) {
3139 if (I->first != I->second) {
3141 UE = I->first->
use_end(); UI != UE; ) {
3142 if (
CallInst* CI = dyn_cast<CallInst>(*UI++))
3150 std::vector<std::pair<Function*, Function*> >().
swap(UpgradedIntrinsics);
3152 for (
unsigned I = 0, E = InstsWithTBAATag.size(); I < E; I++)
3160 return InitLazyStream();
3161 return InitStreamFromBuffer();
3164 error_code BitcodeReader::InitStreamFromBuffer() {
3165 const unsigned char *BufPtr = (
const unsigned char*)Buffer->
getBufferStart();
3166 const unsigned char *BufEnd = BufPtr+Buffer->
getBufferSize();
3182 Stream.
init(*StreamFile);
3192 Stream.
init(*StreamFile);
3194 unsigned char buf[16];
3202 const unsigned char *bitcodeStart = buf;
3203 const unsigned char *bitcodeEnd = buf + 16;
3212 class BitcodeErrorCategoryType :
public _do_message {
3214 return "llvm.bitcode";
3220 return "Bitcode stream length should be >= 16 bytes and a multiple of 4";
3222 return "Conflicting METADATA_KIND records";
3224 return "Could not find function in stream";
3226 return "Expected a constant";
3228 return "Insufficient function protos";
3230 return "Invalid bitcode signature";
3232 return "Invalid bitcode wrapper header";
3234 return "Invalid ronstant reference";
3236 return "Invalid ID";
3238 return "Invalid instruction with no BB";
3240 return "Invalid record";
3242 return "Invalid type for value";
3244 return "Invalid TYPE table";
3246 return "Invalid type";
3248 return "Malformed block";
3250 return "Malformed global initializer set";
3252 return "Invalid multiple blocks";
3254 return "Never resolved value found in function";
3256 return "Invalid value";
3264 static BitcodeErrorCategoryType O;
3276 std::string *ErrMsg) {
3280 if (
error_code EC = R->ParseBitcodeInto(M)) {
3282 *ErrMsg = EC.message();
3288 R->setBufferOwned(
true);
3290 R->materializeForwardReferencedFunctions();
3299 std::string *ErrMsg) {
3305 *ErrMsg = EC.message();
3316 std::string *ErrMsg){
3338 std::string *ErrMsg) {
3343 std::string Triple(
"");
3346 *ErrMsg = EC.message();
void setVisibility(VisibilityTypes V)
static AtomicOrdering GetDecodedOrdering(unsigned Val)
void push_back(const T &Elt)
static void deleteTemporary(MDNode *N)
static MDNode * getTemporary(LLVMContext &Context, ArrayRef< Value * > Vals)
static Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
void setFastMathFlags(FastMathFlags FMF)
Like Private, but linker removes.
void setDataLayout(StringRef DL)
Set the data layout.
static Type * getDoubleTy(LLVMContext &C)
static IntegerType * getInt1Ty(LLVMContext &C)
static Constant * getShuffleVector(Constant *V1, Constant *V2, Constant *Mask)
void addIncoming(Value *V, BasicBlock *BB)
Special purpose, only applies to global arrays.
*p = old <signed v ? old : v
static uint64_t decodeSignRotatedValue(uint64_t V)
LLVM Argument representation.
bool EnterSubBlock(unsigned BlockID, unsigned *NumWordsP=0)
const Instruction & back() const
const char * getBufferStart() const
Sign extended before/after call.
Module * getLazyBitcodeModule(MemoryBuffer *Buffer, LLVMContext &Context, std::string *ErrMsg=0)
static const fltSemantics IEEEdouble
static APInt ReadWideAPInt(ArrayRef< uint64_t > Vals, unsigned TypeBits)
Force argument to be passed in register.
The main container class for the LLVM Intermediate Representation.
void setNoNaNs()
Flag setters.
Same, but only replaced by something equivalent.
static GlobalValue::LinkageTypes GetDecodedLinkage(unsigned Val)
static MDString * get(LLVMContext &Context, StringRef Str)
static Constant * getSelect(Constant *C, Constant *V1, Constant *V2)
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", Instruction *InsertBefore=0)
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Available for inspection, not emission.
Nested function static chain.
void addCase(ConstantInt *OnVal, BasicBlock *Dest)
static Constant * getGetElementPtr(Constant *C, ArrayRef< Constant * > IdxList, bool InBounds=false)
void setMaterializer(GVMaterializer *GVM)
static int GetDecodedCastOpcode(unsigned Val)
void addOperand(MDNode *M)
addOperand - Add metadata operand.
static PointerType * get(Type *ElementType, unsigned AddressSpace)
float BitsToFloat(uint32_t Bits)
*p = old <unsigned v ? old : v
static Constant * getExtractElement(Constant *Vec, Constant *Idx)
Like Internal, but omit from symbol table.
Source said inlining was desirable.
*p = old >unsigned v ? old : v
NamedMDNode * getOrInsertNamedMetadata(StringRef Name)
Externally visible function.
bool isDoubleTy() const
isDoubleTy - Return true if this is 'double', a 64-bit IEEE fp type.
bool isBitcodeWrapper(const unsigned char *BufPtr, const unsigned char *BufEnd)
void setSection(StringRef S)
MDNode - a tuple of other values.
static Constant * getFCmp(unsigned short pred, Constant *LHS, Constant *RHS)
AttrBuilder & addAttribute(Attribute::AttrKind Val)
Add an attribute to the builder.
static Type * getMetadataTy(LLVMContext &C)
static IndirectBrInst * Create(Value *Address, unsigned NumDests, Instruction *InsertBefore=0)
unsigned readRecord(unsigned AbbrevID, SmallVectorImpl< uint64_t > &Vals, StringRef *Blob=0)
void UpgradeIntrinsicCall(CallInst *CI, Function *NewFn)
void AssignValue(Value *V, unsigned Idx)
static Type * getX86_MMXTy(LLVMContext &C)
*p = old >signed v ? old : v
void setDebugLoc(const DebugLoc &Loc)
setDebugLoc - Set the debug location information for this instruction.
static Type * getX86_FP80Ty(LLVMContext &C)
AttrBuilder & addRawValue(uint64_t Val)
Add the raw value to the internal representation.
void shrinkTo(unsigned N)
uint64_t GetCurrentBitNo() const
GetCurrentBitNo - Return the bit # of the bit we are reading.
Value * getValueFwdRef(unsigned Idx, Type *Ty)
static Constant * getNullValue(Type *Ty)
void swap(OwningPtr< T > &a, OwningPtr< T > &b)
static const fltSemantics x87DoubleExtended
virtual const char * getBufferIdentifier() const
void push_back(NodeTy *val)
static unsigned getBitWidth(Type *Ty, const DataLayout *TD)
static Constant * get(unsigned Opcode, Constant *C1, Constant *C2, unsigned Flags=0)
static Type * getFloatTy(LLVMContext &C)
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
static Constant * get(LLVMContext &Context, ArrayRef< uint8_t > Elts)
#define llvm_unreachable(msg)
GVMaterializer * getMaterializer() const
getMaterializer - Retrieves the GVMaterializer, if any, for this Module.
static Constant * get(ArrayRef< Constant * > V)
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=0)
No attributes have been set.
void setModuleInlineAsm(StringRef Asm)
Set the module-scope inline assembly blocks.
Function must be in a unwind table.
static const fltSemantics IEEEquad
void setName(const Twine &Name)
bool any()
Whether any flag is set.
ID
LLVM Calling Convention Representation.
static Type * getPPC_FP128Ty(LLVMContext &C)
Function does not access memory.
Hidden pointer to structure to return.
Function creates no aliases of pointer.
void setKnownObjectSize(size_t size)
std::string getBitcodeTargetTriple(MemoryBuffer *Buffer, LLVMContext &Context, std::string *ErrMsg=0)
global_iterator global_begin()
void ResolveConstantForwardRefs()
static Type * getLabelTy(LLVMContext &C)
void setCleanup(bool V)
setCleanup - Indicate that this landingpad instruction is a cleanup.
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
bool isHalfTy() const
isHalfTy - Return true if this is 'half', a 16-bit IEEE fp type.
static Constant * getICmp(unsigned short pred, Constant *LHS, Constant *RHS)
VisibilityTypes
An enumeration for the kinds of visibility of global values.
Function to be imported from DLL.
static Attribute::AttrKind GetAttrFromCode(uint64_t Code)
static bool ConvertToString(ArrayRef< uint64_t > Record, unsigned Idx, StrTy &Result)
Represents a floating point comparison operator.
bool isMaterializable() const
static LandingPadInst * Create(Type *RetTy, Value *PersonalityFn, unsigned NumReservedClauses, const Twine &NameStr="", Instruction *InsertBefore=0)
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
bool UpgradeIntrinsicFunction(Function *F, Function *&NewFn)
void AssignValue(Value *V, unsigned Idx)
void replaceAllUsesWith(Value *V)
BitstreamEntry advanceSkippingSubblocks(unsigned Flags=0)
unsigned getNumElements() const
Return the number of elements in the Vector type.
void addClause(Value *ClauseVal)
addClause - Add a catch or filter clause to the landing pad.
bool isPPC_FP128Ty() const
isPPC_FP128Ty - Return true if this is powerpc long double.
Type * getElementType() const
size_t size() const
size - Get the array size.
Considered to not alias after call.
Value * getValueFwdRef(unsigned Idx)
bool MaterializeAllPermanently(std::string *ErrInfo=0)
void shrinkTo(unsigned N)
static CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=0)
Construct any of the CastInst subclasses.
ExternalWeak linkage description.
void setCallingConv(CallingConv::ID CC)
Same, but only replaced by something equivalent.
error_code Error(ErrorType E)
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", Instruction *InsertBefore=0)
LLVM Basic Block Representation.
virtual error_code Materialize(GlobalValue *GV)
static BlockAddress * get(Function *F, BasicBlock *BB)
get - Return a BlockAddress for the specified function and basic block.
LLVM Constant Representation.
bool isFloatTy() const
isFloatTy - Return true if this is 'float', a 32-bit IEEE fp type.
APInt Or(const APInt &LHS, const APInt &RHS)
Bitwise OR function for APInt.
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
static InvokeInst * Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr="", Instruction *InsertBefore=0)
APInt Xor(const APInt &LHS, const APInt &RHS)
Bitwise XOR function for APInt.
virtual void eraseFromParent()
Return value is always equal to this argument.
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", Instruction *InsertBefore=0)
static Type * getVoidTy(LLVMContext &C)
const InstListType & getInstList() const
Return the underlying instruction list container.
Represent an integer comparison operator.
Value * operator[](unsigned i) const
Zero extended before/after call.
void init(BitstreamReader &R)
error_code ParseTriple(std::string &Triple)
Cheap mechanism to just extract module triple.
Function to be accessible from DLL.
Function doesn't unwind stack.
static Constant * get(StructType *T, ArrayRef< Constant * > V)
Marks function as being in a cold path.
Mark the function as not returning.
bool isFP128Ty() const
isFP128Ty - Return true if this is 'fp128'.
static UndefValue * get(Type *T)
Constant * getConstantFwdRef(unsigned Idx, Type *Ty)
bool isFPOrFPVectorTy() const
void setBody(ArrayRef< Type * > Elements, bool isPacked=false)
setBody - Specify a body for an opaque identified type.
static const fltSemantics IEEEhalf
Call cannot be duplicated.
void setMetadata(unsigned KindID, MDNode *Node)
static Type * getFP128Ty(LLVMContext &C)
static GlobalValue::VisibilityTypes GetDecodedVisibility(unsigned Val)
static CallInst * Create(Value *Func, ArrayRef< Value * > Args, const Twine &NameStr="", Instruction *InsertBefore=0)
global_iterator global_end()
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
static Type * getHalfTy(LLVMContext &C)
static IntegerType * get(LLVMContext &C, unsigned NumBits)
Get or create an IntegerType instance.
Instruction * UpgradeBitCastInst(unsigned Opc, Value *V, Type *DestTy, Instruction *&Temp)
static MDNode * getWhenValsUnresolved(LLVMContext &Context, ArrayRef< Value * > Vals, bool isFunctionLocal)
static const fltSemantics PPCDoubleDouble
SmallVectorImpl< T >::const_pointer c_str(SmallVectorImpl< T > &str)
Class for constant integers.
error_code ParseBitcodeInto(Module *M)
Main interface to parsing a bitcode buffer.
void setBufferOwned(bool Owned)
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
void setAlignment(unsigned Align)
void setAllowReciprocal()
Keep one copy of function when linking (inline)
bool UpgradeGlobalVariable(GlobalVariable *GV)
bool isBitcode(const unsigned char *BufPtr, const unsigned char *BufEnd)
void setUnnamedAddr(bool Val)
void skipRecord(unsigned AbbrevID)
skipRecord - Read the current record and discard it.
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
static GetElementPtrInst * Create(Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=0)
static Constant * get(Type *Ty, double V)
bool isRawBitcode(const unsigned char *BufPtr, const unsigned char *BufEnd)
double BitsToDouble(uint64_t Bits)
void setLinkage(LinkageTypes LT)
#define LLVM_DELETED_FUNCTION
virtual bool isDematerializable(const GlobalValue *GV) const
Module * getStreamedBitcodeModule(const std::string &name, DataStreamer *streamer, LLVMContext &Context, std::string *ErrMsg=0)
Class for arbitrary precision integers.
virtual int readBytes(uint64_t address, uint64_t size, uint8_t *buf) const LLVM_OVERRIDE
StringRef str() const
Explicit conversion to StringRef.
LinkageTypes
An enumeration for the kinds of linkage for global values.
virtual void destroyConstant()
virtual bool isMaterializable(const GlobalValue *GV) const
Function must not be optimized.
Function only reads from memory.
void setGC(const char *Str)
static SynchronizationScope GetDecodedSynchScope(unsigned Val)
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(DefaultAlign), cl::values(clEnumValN(DefaultAlign,"arm-default-align","Generate unaligned accesses only on hardware/OS ""combinations that are known to support them"), clEnumValN(StrictAlign,"arm-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"arm-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
size_t getBufferSize() const
APInt And(const APInt &LHS, const APInt &RHS)
Bitwise AND function for APInt.
Like LinkerPrivate, but weak.
static DebugLoc get(unsigned Line, unsigned Col, MDNode *Scope, MDNode *InlinedAt=0)
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr="", Instruction *InsertBefore=0)
void setName(StringRef Name)
uint32_t Read(unsigned NumBits)
static const fltSemantics IEEEsingle
bool isX86_FP80Ty() const
isX86_FP80Ty - Return true if this is x86 long double.
pointer data()
data - Return a pointer to the vector's buffer, even if empty().
bool SkipBitcodeWrapperHeader(const unsigned char *&BufPtr, const unsigned char *&BufEnd, bool VerifyBufferSize)
static IntegerType * getInt32Ty(LLVMContext &C)
bool isDeclaration() const
Callee isn't recognized as a builtin.
static error_code success()
virtual void Dematerialize(GlobalValue *GV)
static int GetDecodedBinaryOpcode(unsigned Val, Type *Ty)
static AtomicRMWInst::BinOp GetDecodedRMWOperation(unsigned Val)
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=0, BasicBlock *InsertBefore=0)
Creates a new BasicBlock.
static ArrayType * get(Type *ElementType, uint64_t NumElements)
void setTargetTriple(StringRef T)
Set the target triple.
Keep one copy of named function when linking (weak)
Rename collisions when linking (static functions).
static BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), Instruction *InsertBefore=0)
static InlineAsm * get(FunctionType *Ty, StringRef AsmString, StringRef Constraints, bool hasSideEffects, bool isAlignStack=false, AsmDialect asmDialect=AD_ATT)
Module * ParseBitcodeFile(MemoryBuffer *Buffer, LLVMContext &Context, std::string *ErrMsg=0)
static ReturnInst * Create(LLVMContext &C, Value *retVal=0, Instruction *InsertBefore=0)
void setAttributes(AttributeSet attrs)
Set the attribute list for this Function.
void addDestination(BasicBlock *Dest)
static GlobalVariable::ThreadLocalMode GetDecodedThreadLocalMode(unsigned Val)
void JumpToBit(uint64_t BitNo)
JumpToBit - Reset the stream to the specified bit number.
static void decodeLLVMAttributesForBitcode(AttrBuilder &B, uint64_t EncodedAttrs)
This fills an AttrBuilder object with the LLVM attributes that have been decoded from the given integ...
void materializeForwardReferencedFunctions()
Function can return twice.
StringMapEntry< Value * > ValueName
LLVM Value Representation.
static VectorType * get(Type *ElementType, unsigned NumElements)
static StructType * create(LLVMContext &Context, StringRef Name)
StructType::create - This creates an identified struct.
Disable implicit floating point insts.
virtual error_code MaterializeModule(Module *M)
AttrBuilder & addStackAlignmentAttr(unsigned Align)
This turns an int stack alignment (which must be a power of 2) into the form used internally in Attri...
void UpgradeInstWithTBAATag(Instruction *I)
BitstreamEntry advance(unsigned Flags=0)
bool isPowerOf2_32(uint32_t Value)
Convenience struct for specifying and reasoning about fast-math flags.
bool dropLeadingBytes(size_t s)
AttrBuilder & addAlignmentAttr(unsigned Align)
This turns an int alignment (which must be a power of 2) into the form used internally in Attribute...
bool Materialize(std::string *ErrInfo=0)
Value * UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy)
unsigned getAbbrevIDWidth() const
getAbbrevIDWidth - Return the number of bits used to encode an abbrev #.
static Constant * get(LLVMContext &Context, ArrayRef< uint8_t > Elts)
iterator find(const KeyT &Val)
unsigned getMDKindID(StringRef Name) const
static Constant * getCast(unsigned ops, Constant *C, Type *Ty)
Stack protection required.
bool ule(const APInt &RHS) const
Unsigned less or equal comparison.
static IntegerType * getInt8Ty(LLVMContext &C)
static ResumeInst * Create(Value *Exn, Instruction *InsertBefore=0)
static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, Instruction *InsertBefore=0)
enum llvm::BitstreamEntry::@27 Kind
bool ReadBlockInfoBlock()
static Constant * getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx)
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=0)
bool isVoidTy() const
isVoidTy - Return true if this is 'void'.
bool isMetadataTy() const
isMetadataTy - Return true if this is 'metadata'.
Function must be optimized for size first.