MCPcopy Create free account
hub / github.com/GANGE666/xVMP / parseFunctionRecord

Method parseFunctionRecord

src/lib/Bitcode/Reader/BitcodeReader.cpp:2975–3071  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2973}
2974
2975Error BitcodeReader::parseFunctionRecord(ArrayRef<uint64_t> Record) {
2976 // v1: [type, callingconv, isproto, linkage, paramattr, alignment, section,
2977 // visibility, gc, unnamed_addr, prologuedata, dllstorageclass, comdat,
2978 // prefixdata, personalityfn, preemption specifier, addrspace] (name in VST)
2979 // v2: [strtab_offset, strtab_size, v1]
2980 StringRef Name;
2981 std::tie(Name, Record) = readNameFromStrtab(Record);
2982
2983 if (Record.size() < 8)
2984 return error("Invalid record");
2985 Type *Ty = getTypeByID(Record[0]);
2986 if (!Ty)
2987 return error("Invalid record");
2988 if (auto *PTy = dyn_cast<PointerType>(Ty))
2989 Ty = PTy->getElementType();
2990 auto *FTy = dyn_cast<FunctionType>(Ty);
2991 if (!FTy)
2992 return error("Invalid type for value");
2993 auto CC = static_cast<CallingConv::ID>(Record[1]);
2994 if (CC & ~CallingConv::MaxID)
2995 return error("Invalid calling convention ID");
2996
2997 unsigned AddrSpace = TheModule->getDataLayout().getProgramAddressSpace();
2998 if (Record.size() > 16)
2999 AddrSpace = Record[16];
3000
3001 Function *Func = Function::Create(FTy, GlobalValue::ExternalLinkage,
3002 AddrSpace, Name, TheModule);
3003
3004 Func->setCallingConv(CC);
3005 bool isProto = Record[2];
3006 uint64_t RawLinkage = Record[3];
3007 Func->setLinkage(getDecodedLinkage(RawLinkage));
3008 Func->setAttributes(getAttributes(Record[4]));
3009
3010 unsigned Alignment;
3011 if (Error Err = parseAlignmentValue(Record[5], Alignment))
3012 return Err;
3013 Func->setAlignment(Alignment);
3014 if (Record[6]) {
3015 if (Record[6] - 1 >= SectionTable.size())
3016 return error("Invalid ID");
3017 Func->setSection(SectionTable[Record[6] - 1]);
3018 }
3019 // Local linkage must have default visibility.
3020 if (!Func->hasLocalLinkage())
3021 // FIXME: Change to an error if non-default in 4.0.
3022 Func->setVisibility(getDecodedVisibility(Record[7]));
3023 if (Record.size() > 8 && Record[8]) {
3024 if (Record[8] - 1 >= GCTable.size())
3025 return error("Invalid ID");
3026 Func->setGC(GCTable[Record[8] - 1]);
3027 }
3028 GlobalValue::UnnamedAddr UnnamedAddr = GlobalValue::UnnamedAddr::None;
3029 if (Record.size() > 9)
3030 UnnamedAddr = getDecodedUnnamedAddrType(Record[9]);
3031 Func->setUnnamedAddr(UnnamedAddr);
3032 if (Record.size() > 10 && Record[10] != 0)

Callers

nothing calls this directly

Calls 15

getDecodedLinkageFunction · 0.85
getDecodedVisibilityFunction · 0.85
hasImplicitComdatFunction · 0.85
getDecodedDSOLocalFunction · 0.85
inferDSOLocalFunction · 0.85
successFunction · 0.85
hasLocalLinkageMethod · 0.80
setUnnamedAddrMethod · 0.80

Tested by

no test coverage detected