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

Method parseFunctionBody

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

Lazily parse the specified function body block.

Source from the content-addressed store, hash-verified

3409
3410/// Lazily parse the specified function body block.
3411Error BitcodeReader::parseFunctionBody(Function *F) {
3412 if (Stream.EnterSubBlock(bitc::FUNCTION_BLOCK_ID))
3413 return error("Invalid record");
3414
3415 // Unexpected unresolved metadata when parsing function.
3416 if (MDLoader->hasFwdRefs())
3417 return error("Invalid function metadata: incoming forward references");
3418
3419 InstructionList.clear();
3420 unsigned ModuleValueListSize = ValueList.size();
3421 unsigned ModuleMDLoaderSize = MDLoader->size();
3422
3423 // Add all the function arguments to the value table.
3424 for (Argument &I : F->args())
3425 ValueList.push_back(&I);
3426
3427 unsigned NextValueNo = ValueList.size();
3428 BasicBlock *CurBB = nullptr;
3429 unsigned CurBBNo = 0;
3430
3431 DebugLoc LastLoc;
3432 auto getLastInstruction = [&]() -> Instruction * {
3433 if (CurBB && !CurBB->empty())
3434 return &CurBB->back();
3435 else if (CurBBNo && FunctionBBs[CurBBNo - 1] &&
3436 !FunctionBBs[CurBBNo - 1]->empty())
3437 return &FunctionBBs[CurBBNo - 1]->back();
3438 return nullptr;
3439 };
3440
3441 std::vector<OperandBundleDef> OperandBundles;
3442
3443 // Read all the records.
3444 SmallVector<uint64_t, 64> Record;
3445
3446 while (true) {
3447 BitstreamEntry Entry = Stream.advance();
3448
3449 switch (Entry.Kind) {
3450 case BitstreamEntry::Error:
3451 return error("Malformed block");
3452 case BitstreamEntry::EndBlock:
3453 goto OutOfRecordLoop;
3454
3455 case BitstreamEntry::SubBlock:
3456 switch (Entry.ID) {
3457 default: // Skip unknown content.
3458 if (Stream.SkipBlock())
3459 return error("Invalid record");
3460 break;
3461 case bitc::CONSTANTS_BLOCK_ID:
3462 if (Error Err = parseConstants())
3463 return Err;
3464 NextValueNo = ValueList.size();
3465 break;
3466 case bitc::VALUE_SYMTAB_BLOCK_ID:
3467 if (Error Err = parseValueSymbolTable())
3468 return Err;

Callers

nothing calls this directly

Calls 15

getDecodedUnaryOpcodeFunction · 0.85
getDecodedFastMathFlagsFunction · 0.85
getDecodedBinaryOpcodeFunction · 0.85
getDecodedCastOpcodeFunction · 0.85
getValueFunction · 0.85
readWideAPIntFunction · 0.85
makeArrayRefFunction · 0.85
ClauseTypeEnum · 0.85
getDecodedOrderingFunction · 0.85
getDecodedRMWOperationFunction · 0.85
successFunction · 0.85
EnterSubBlockMethod · 0.80

Tested by

no test coverage detected