Extracting Module out of IR unit. Excerpted from LLVM's StandardInstrumentation.cpp
| 457 | // Extracting Module out of IR unit. |
| 458 | // Excerpted from LLVM's StandardInstrumentation.cpp |
| 459 | const 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. |
no test coverage detected