MCPcopy Create free account
hub / github.com/apache/arrow / RemoveUnusedFunctions

Method RemoveUnusedFunctions

cpp/src/gandiva/engine.cc:454–473  ·  view source on GitHub ↗

Get rid of all functions that don't need to be compiled. This helps in reducing the overall compilation time. This pass is trivial, and is always done since the number of functions in gandiva is very high. (Adapted from Apache Impala) Done by marking all the unused functions as internal, and then, running a pass for dead code elimination.

Source from the content-addressed store, hash-verified

452// Done by marking all the unused functions as internal, and then, running
453// a pass for dead code elimination.
454Status Engine::RemoveUnusedFunctions() {
455 // Setup an optimiser pipeline
456 llvm::PassBuilder pass_builder;
457 llvm::ModuleAnalysisManager module_am;
458
459 pass_builder.registerModuleAnalyses(module_am);
460 llvm::ModulePassManager module_pm;
461
462 std::unordered_set<std::string> used_functions;
463 used_functions.insert(functions_to_compile_.begin(), functions_to_compile_.end());
464
465 module_pm.addPass(
466 llvm::InternalizePass([&used_functions](const llvm::GlobalValue& variable) -> bool {
467 return used_functions.find(variable.getName().str()) != used_functions.end();
468 }));
469 module_pm.addPass(llvm::GlobalDCEPass());
470
471 module_pm.run(*module_, module_am);
472 return Status::OK();
473}
474
475// several passes requiring LLVM 14+ that are not available in the legacy pass manager
476#if LLVM_VERSION_MAJOR >= 14

Callers

nothing calls this directly

Calls 8

strMethod · 0.80
getNameMethod · 0.80
OKFunction · 0.50
insertMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
findMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected