You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "kou (via GitHub)" <gi...@apache.org> on 2023/10/01 20:03:31 UTC

[GitHub] [arrow] kou commented on a diff in pull request #37867: GH-37834: [Gandiva] Migrate to new LLVM PassManager API

kou commented on code in PR #37867:
URL: https://github.com/apache/arrow/pull/37867#discussion_r1342181374


##########
cpp/src/gandiva/engine.cc:
##########
@@ -268,49 +283,104 @@ Status Engine::LoadPreCompiledIR() {
 // a pass for dead code elimination.
 Status Engine::RemoveUnusedFunctions() {
   // Setup an optimiser pipeline
-  std::unique_ptr<llvm::legacy::PassManager> pass_manager(
-      new llvm::legacy::PassManager());
+  llvm::PassBuilder pass_builder;
+  llvm::ModuleAnalysisManager module_am;
+
+  pass_builder.registerModuleAnalyses(module_am);
+  llvm::ModulePassManager module_pm;
 
   std::unordered_set<std::string> used_functions;
   used_functions.insert(functions_to_compile_.begin(), functions_to_compile_.end());
 
-  pass_manager->add(
-      llvm::createInternalizePass([&used_functions](const llvm::GlobalValue& func) {
-        return (used_functions.find(func.getName().str()) != used_functions.end());
+  module_pm.addPass(
+      llvm::InternalizePass([&used_functions](const llvm::GlobalValue& GV) -> bool {
+        return used_functions.find(GV.getName().str()) != used_functions.end();

Review Comment:
   How about lower case for like others?
   
   ```suggestion
         llvm::InternalizePass([&used_functions](const llvm::GlobalValue& gv) -> bool {
           return used_functions.find(gv.getName().str()) != used_functions.end();
   ```
   
   Or can we use `variable` instead of `gv` for readability?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org