MCPcopy Create free account
hub / github.com/avast/retdec / splitFunctionOn

Method splitFunctionOn

src/bin2llvmir/optimizations/decoder/ir_modifications.cpp:474–512  ·  view source on GitHub ↗

* This can create new BB at \p addr even if it then cannot split function * on this new BB. Is this desirable behavior? */

Source from the content-addressed store, hash-verified

472 * on this new BB. Is this desirable behavior?
473 */
474llvm::Function* Decoder::splitFunctionOn(common::Address addr)
475{
476 if (auto* bb = getBasicBlockAtAddress(addr))
477 {
478 LOG << "\t\t\t\t" << "S: splitFunctionOn @ " << addr << std::endl;
479 return bb->getPrevNode()
480 ? splitFunctionOn(addr, bb)
481 : bb->getParent();
482 }
483 // There is an instruction at address, but not BB -> do not split
484 // existing blocks to create functions.
485 //
486 else if (auto ai = AsmInstruction(_module, addr))
487 {
488 if (ai.isInvalid())
489 {
490 LOG << "\t\t\t\t" << "S: invalid ASM @ " << addr << std::endl;
491 return nullptr;
492 }
493 else
494 {
495 LOG << "\t\t\t\t" << "S: ASM @ " << addr << std::endl;
496 return nullptr;
497 }
498 }
499 else if (getFunctionContainingAddress(addr))
500 {
501 LOG << "\t\t\t\t" << "S: getFunctionContainingAddress() @ " << addr << std::endl;
502 auto* before = getBasicBlockBeforeAddress(addr);
503 assert(before);
504 auto* newBb = createBasicBlock(addr, before->getParent(), before);
505 return splitFunctionOn(addr, newBb);
506 }
507 else
508 {
509 LOG << "\t\t\t\t" << "S: createFunction() @ " << addr << std::endl;
510 return createFunction(addr);
511 }
512}
513
514llvm::Function* Decoder::splitFunctionOn(
515 common::Address addr,

Callers

nothing calls this directly

Calls 15

generateFunctionNameFunction · 0.85
dumpModuleToFileFunction · 0.85
isInvalidMethod · 0.80
strMethod · 0.80
getSuccessorMethod · 0.80
getContextMethod · 0.80
getOutputDirectoryMethod · 0.80
AsmInstructionClass · 0.50
getParentMethod · 0.45
getNameMethod · 0.45
emptyMethod · 0.45
getReturnTypeMethod · 0.45

Tested by

no test coverage detected