MCPcopy Create free account
hub / github.com/AliveToolkit/alive2 / unwrapModule

Function unwrapModule

tv/tv.cpp:459–473  ·  view source on GitHub ↗

Extracting Module out of IR unit. Excerpted from LLVM's StandardInstrumentation.cpp

Source from the content-addressed store, hash-verified

457// Extracting Module out of IR unit.
458// Excerpted from LLVM's StandardInstrumentation.cpp
459const llvm::Module * unwrapModule(llvm::Any IR) {
460 using namespace llvm;
461
462 if (auto **M = any_cast<const Module *>(&IR))
463 return *M;
464 else if (auto **F = any_cast<const llvm::Function *>(&IR))
465 return (*F)->getParent();
466 else if (auto **C = any_cast<const LazyCallGraph::SCC *>(&IR)) {
467 assert((*C)->begin() != (*C)->end()); // there's at least one function
468 return (*C)->begin()->getFunction().getParent();
469 } else if (auto **L = any_cast<const Loop *>(&IR))
470 return (*L)->getHeader()->getParent()->getParent();
471
472 llvm_unreachable("Unknown IR unit");
473}
474
475
476// List 'leaf' interprocedural passes only.

Calls 3

getParentMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected