From 978e8f929115fb3057410ab162dbb1c29a3fe68d Mon Sep 17 00:00:00 2001 From: Andre Masella Date: Tue, 15 Mar 2022 15:12:26 -0400 Subject: [PATCH 1/6] Add more LLVM pass bindings --- .clang-format | 2 + ffi/passmanagers.cpp | 407 ++++++++++++++++++++++++------- llvmlite/binding/passmanagers.py | 272 ++++++++++++++++++++- llvmlite/tests/test_binding.py | 38 +++ 4 files changed, 631 insertions(+), 88 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..a74fda4b6 --- /dev/null +++ b/.clang-format @@ -0,0 +1,2 @@ +BasedOnStyle: LLVM +AlwaysBreakTemplateDeclarations: Yes diff --git a/ffi/passmanagers.cpp b/ffi/passmanagers.cpp index 0206d1759..a1fb0b880 100644 --- a/ffi/passmanagers.cpp +++ b/ffi/passmanagers.cpp @@ -2,19 +2,36 @@ #include "core.h" -#include "llvm/IR/Module.h" #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/DiagnosticPrinter.h" +#include "llvm/IR/Module.h" #include "llvm/Support/raw_ostream.h" -#include "llvm-c/Transforms/Scalar.h" #include "llvm-c/Transforms/IPO.h" +#include "llvm-c/Transforms/Scalar.h" #include "llvm/IR/LegacyPassManager.h" -#include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/IPO.h" +#include "llvm/Transforms/Scalar.h" #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace llvm; /* @@ -24,164 +41,380 @@ using namespace llvm; extern "C" { API_EXPORT(void) -LLVMPY_SetTimePasses(bool enable){ - TimePassesIsEnabled = enable; -} +LLVMPY_SetTimePasses(bool enable) { TimePassesIsEnabled = enable; } API_EXPORT(void) LLVMPY_ReportAndResetTimings(const char **outmsg) { - std::string osbuf; - raw_string_ostream os(osbuf); - reportAndResetTimings(&os); - os.flush(); - *outmsg = LLVMPY_CreateString(os.str().c_str()); + std::string osbuf; + raw_string_ostream os(osbuf); + reportAndResetTimings(&os); + os.flush(); + *outmsg = LLVMPY_CreateString(os.str().c_str()); } - API_EXPORT(LLVMPassManagerRef) -LLVMPY_CreatePassManager() -{ - return LLVMCreatePassManager(); -} +LLVMPY_CreatePassManager() { return LLVMCreatePassManager(); } API_EXPORT(void) -LLVMPY_DisposePassManager(LLVMPassManagerRef PM) -{ - return LLVMDisposePassManager(PM); +LLVMPY_DisposePassManager(LLVMPassManagerRef PM) { + return LLVMDisposePassManager(PM); } API_EXPORT(LLVMPassManagerRef) -LLVMPY_CreateFunctionPassManager(LLVMModuleRef M) -{ - return LLVMCreateFunctionPassManagerForModule(M); +LLVMPY_CreateFunctionPassManager(LLVMModuleRef M) { + return LLVMCreateFunctionPassManagerForModule(M); } API_EXPORT(int) -LLVMPY_RunPassManager(LLVMPassManagerRef PM, - LLVMModuleRef M) -{ - return LLVMRunPassManager(PM, M); +LLVMPY_RunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M) { + return LLVMRunPassManager(PM, M); } API_EXPORT(int) -LLVMPY_RunFunctionPassManager(LLVMPassManagerRef PM, - LLVMValueRef F) -{ - return LLVMRunFunctionPassManager(PM, F); +LLVMPY_RunFunctionPassManager(LLVMPassManagerRef PM, LLVMValueRef F) { + return LLVMRunFunctionPassManager(PM, F); } API_EXPORT(int) -LLVMPY_InitializeFunctionPassManager(LLVMPassManagerRef FPM) -{ - return LLVMInitializeFunctionPassManager(FPM); +LLVMPY_InitializeFunctionPassManager(LLVMPassManagerRef FPM) { + return LLVMInitializeFunctionPassManager(FPM); } API_EXPORT(int) -LLVMPY_FinalizeFunctionPassManager(LLVMPassManagerRef FPM) -{ - return LLVMFinalizeFunctionPassManager(FPM); +LLVMPY_FinalizeFunctionPassManager(LLVMPassManagerRef FPM) { + return LLVMFinalizeFunctionPassManager(FPM); +} + +API_EXPORT(void) +LLVMPY_AddAAEvalPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(llvm::createAAEvalPass()); +} + +API_EXPORT(void) +LLVMPY_AddBasicAAPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(llvm::createBasicAAWrapperPass()); +} + +API_EXPORT(void) +LLVMPY_AddDependenceAnalysisPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(llvm::createDependenceAnalysisWrapperPass()); +} + +API_EXPORT(void) +LLVMPY_AddCallGraphViewerPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(llvm::createCallGraphViewerPass()); +} + +API_EXPORT(void) +LLVMPY_AddDotCallGraphPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(llvm::createCallGraphDOTPrinterPass()); +} + +API_EXPORT(void) +LLVMPY_AddDotDomPrinterPass(LLVMPassManagerRef PM, bool showBody) { + unwrap(PM)->add(showBody ? llvm::createDomPrinterPass() + : llvm::createDomOnlyPrinterPass()); +} + +API_EXPORT(void) +LLVMPY_AddGlobalsModRefAAPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(llvm::createGlobalsAAWrapperPass()); +} + +API_EXPORT(void) +LLVMPY_AddDotPostDomPrinterPass(LLVMPassManagerRef PM, bool showBody) { + unwrap(PM)->add(showBody ? llvm::createPostDomPrinterPass() + : llvm::createPostDomOnlyPrinterPass()); +} + +API_EXPORT(void) +LLVMPY_AddCFGPrinterPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(llvm::createCFGPrinterLegacyPassPass()); +} + +API_EXPORT(void) +LLVMPY_AddConstantMergePass(LLVMPassManagerRef PM) { + LLVMAddConstantMergePass(PM); +} + +API_EXPORT(void) +LLVMPY_AddDeadInstructionEliminationPrinterPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(llvm::createDeadInstEliminationPass()); +} + +API_EXPORT(void) +LLVMPY_AddDeadStoreEliminationPrinterPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(llvm::createDeadStoreEliminationPass()); +} + +API_EXPORT(void) +LLVMPY_AddPostOrderFunctionAttrsPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(llvm::createReversePostOrderFunctionAttrsPass()); +} + +API_EXPORT(void) +LLVMPY_AddDeadArgEliminationPass(LLVMPassManagerRef PM) { + LLVMAddDeadArgEliminationPass(PM); +} + +API_EXPORT(void) +LLVMPY_AddInstructionCountPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(llvm::createInstCountPass()); +} + +API_EXPORT(void) +LLVMPY_AddIVUsersPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(llvm::createIVUsersPass()); +} + +API_EXPORT(void) +LLVMPY_AddLazyValueInfoPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(llvm::createLazyValueInfoPass()); +} +API_EXPORT(void) +LLVMPY_AddLintPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(llvm::createLintPass()); +} +API_EXPORT(void) +LLVMPY_AddModuleDebugInfoPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(llvm::createModuleDebugInfoPrinterPass()); +} + +API_EXPORT(void) +LLVMPY_AddRegionInfoPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(llvm::createRegionInfoPass()); +} + +API_EXPORT(void) +LLVMPY_AddScalarEvolutionAAPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(llvm::createSCEVAAWrapperPass()); +} + +API_EXPORT(void) +LLVMPY_AddAggressiveDCEPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(llvm::createAggressiveDCEPass()); +} + +API_EXPORT(void) +LLVMPY_AddAlwaysInlinePass(LLVMPassManagerRef PM, bool insertLifetime) { + unwrap(PM)->add(llvm::createAlwaysInlinerLegacyPass(insertLifetime)); +} + +API_EXPORT(void) +LLVMPY_AddArgPromotionPass(LLVMPassManagerRef PM, unsigned int maxElements) { + unwrap(PM)->add(llvm::createArgumentPromotionPass(maxElements)); +} + +API_EXPORT(void) +LLVMPY_AddBreakCritEdgesPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(llvm::createBreakCriticalEdgesPass()); +} + +API_EXPORT(void) +LLVMPY_AddFunctionAttrsPass(LLVMPassManagerRef PM) { + LLVMAddFunctionAttrsPass(PM); +} + +API_EXPORT(void) +LLVMPY_AddFunctionInliningPass(LLVMPassManagerRef PM, int Threshold) { + unwrap(PM)->add(createFunctionInliningPass(Threshold)); +} + +API_EXPORT(void) +LLVMPY_AddGlobalOptimizerPass(LLVMPassManagerRef PM) { + LLVMAddGlobalOptimizerPass(PM); +} + +API_EXPORT(void) +LLVMPY_AddGlobalDCEPass(LLVMPassManagerRef PM) { LLVMAddGlobalDCEPass(PM); } + +API_EXPORT(void) +LLVMPY_AddIPSCCPPass(LLVMPassManagerRef PM) { LLVMAddIPSCCPPass(PM); } + +API_EXPORT(void) +LLVMPY_AddDeadCodeEliminationPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createDeadCodeEliminationPass()); +} + +API_EXPORT(void) +LLVMPY_AddAggressiveInstructionCombiningPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createAggressiveInstCombinerPass()); +} + +API_EXPORT(void) +LLVMPY_AddInternalizePass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createInternalizePass()); +} + +API_EXPORT(void) +LLVMPY_AddJumpThreadingPass(LLVMPassManagerRef PM, int threshold) { + unwrap(PM)->add(createJumpThreadingPass(threshold)); +} + +API_EXPORT(void) +LLVMPY_AddLCSSAPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createLCSSAPass()); +} + +API_EXPORT(void) +LLVMPY_AddLoopDeletionPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createLoopDeletionPass()); +} + +API_EXPORT(void) +LLVMPY_AddLoopExtractorPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createLoopExtractorPass()); +} + +API_EXPORT(void) +LLVMPY_AddSingleLoopExtractorPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createSingleLoopExtractorPass()); +} + +API_EXPORT(void) +LLVMPY_AddLoopStrengthReducePass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createLoopStrengthReducePass()); +} + +API_EXPORT(void) +LLVMPY_AddLoopSimplificationPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createLoopSimplifyPass()); +} + +API_EXPORT(void) +LLVMPY_AddLoopUnrollPass(LLVMPassManagerRef PM) { LLVMAddLoopUnrollPass(PM); } + +API_EXPORT(void) +LLVMPY_AddLoopUnrollAndJamPass(LLVMPassManagerRef PM) { + LLVMAddLoopUnrollAndJamPass(PM); +} + +API_EXPORT(void) +LLVMPY_AddLoopUnswitchPass(LLVMPassManagerRef PM, bool optimizeForSize, + bool hasBranchDivergence) { + unwrap(PM)->add(createLoopUnswitchPass(optimizeForSize, hasBranchDivergence)); } API_EXPORT(void) -LLVMPY_AddConstantMergePass(LLVMPassManagerRef PM) -{ - LLVMAddConstantMergePass(PM); +LLVMPY_AddLowerAtomicPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createLowerAtomicPass()); } API_EXPORT(void) -LLVMPY_AddDeadArgEliminationPass(LLVMPassManagerRef PM) -{ - LLVMAddDeadArgEliminationPass(PM); +LLVMPY_AddLowerInvokePass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createLowerInvokePass()); } API_EXPORT(void) -LLVMPY_AddFunctionAttrsPass(LLVMPassManagerRef PM) -{ - LLVMAddFunctionAttrsPass(PM); +LLVMPY_AddLowerSwitchPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createLowerSwitchPass()); } API_EXPORT(void) -LLVMPY_AddFunctionInliningPass(LLVMPassManagerRef PM, int Threshold) -{ - unwrap(PM)->add(createFunctionInliningPass(Threshold)); +LLVMPY_AddMemCpyOptimizationPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createMemCpyOptPass()); } API_EXPORT(void) -LLVMPY_AddGlobalOptimizerPass(LLVMPassManagerRef PM) -{ - LLVMAddGlobalOptimizerPass(PM); +LLVMPY_AddMergeFunctionsPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createMergeFunctionsPass()); } API_EXPORT(void) -LLVMPY_AddGlobalDCEPass(LLVMPassManagerRef PM) -{ - LLVMAddGlobalDCEPass(PM); +LLVMPY_AddMergeReturnsPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createUnifyFunctionExitNodesPass()); } API_EXPORT(void) -LLVMPY_AddIPSCCPPass(LLVMPassManagerRef PM) -{ - LLVMAddIPSCCPPass(PM); +LLVMPY_AddPartialInliningPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createPartialInliningPass()); } API_EXPORT(void) -LLVMPY_AddDeadCodeEliminationPass(LLVMPassManagerRef PM) -{ - unwrap(PM)->add(createDeadCodeEliminationPass()); +LLVMPY_AddPruneExceptionHandlingPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createPruneEHPass()); } API_EXPORT(void) -LLVMPY_AddCFGSimplificationPass(LLVMPassManagerRef PM) -{ - LLVMAddCFGSimplificationPass(PM); +LLVMPY_AddReassociatePass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createReassociatePass()); } API_EXPORT(void) -LLVMPY_AddGVNPass(LLVMPassManagerRef PM) -{ - LLVMAddGVNPass(PM); +LLVMPY_AddDemoteRegisterToMemoryPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createDemoteRegisterToMemoryPass()); } API_EXPORT(void) -LLVMPY_AddInstructionCombiningPass(LLVMPassManagerRef PM) -{ - LLVMAddInstructionCombiningPass(PM); +LLVMPY_AddSinkPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createSinkingPass()); } API_EXPORT(void) -LLVMPY_AddLICMPass(LLVMPassManagerRef PM) -{ - LLVMAddLICMPass(PM); +LLVMPY_AddStripSymbolsPass(LLVMPassManagerRef PM, bool onlyDebugInfo) { + unwrap(PM)->add(createStripSymbolsPass(onlyDebugInfo)); } API_EXPORT(void) -LLVMPY_AddSCCPPass(LLVMPassManagerRef PM) -{ - LLVMAddSCCPPass(PM); +LLVMPY_AddStripDeadDebugInfoPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createStripDeadDebugInfoPass()); } API_EXPORT(void) -LLVMPY_AddSROAPass(LLVMPassManagerRef PM) -{ - unwrap(PM)->add(createSROAPass()); +LLVMPY_AddStripDeadPrototypesPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createStripDeadPrototypesPass()); } API_EXPORT(void) -LLVMPY_AddTypeBasedAliasAnalysisPass(LLVMPassManagerRef PM) -{ - LLVMAddTypeBasedAliasAnalysisPass(PM); +LLVMPY_AddStripDebugDeclarePrototypesPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createStripDebugDeclarePass()); +} + +API_EXPORT(void) +LLVMPY_AddStripNondebugSymbolsPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createStripNonDebugSymbolsPass()); +} + +API_EXPORT(void) +LLVMPY_AddTailCallEliminationPass(LLVMPassManagerRef PM) { + unwrap(PM)->add(createTailCallEliminationPass()); +} + +API_EXPORT(void) +LLVMPY_AddCFGSimplificationPass(LLVMPassManagerRef PM) { + LLVMAddCFGSimplificationPass(PM); +} + +API_EXPORT(void) +LLVMPY_AddGVNPass(LLVMPassManagerRef PM) { LLVMAddGVNPass(PM); } + +API_EXPORT(void) +LLVMPY_AddInstructionCombiningPass(LLVMPassManagerRef PM) { + LLVMAddInstructionCombiningPass(PM); +} + +API_EXPORT(void) +LLVMPY_AddLICMPass(LLVMPassManagerRef PM) { LLVMAddLICMPass(PM); } + +API_EXPORT(void) +LLVMPY_AddSCCPPass(LLVMPassManagerRef PM) { LLVMAddSCCPPass(PM); } + +API_EXPORT(void) +LLVMPY_AddSROAPass(LLVMPassManagerRef PM) { unwrap(PM)->add(createSROAPass()); } + +API_EXPORT(void) +LLVMPY_AddTypeBasedAliasAnalysisPass(LLVMPassManagerRef PM) { + LLVMAddTypeBasedAliasAnalysisPass(PM); } API_EXPORT(void) -LLVMPY_AddBasicAliasAnalysisPass(LLVMPassManagerRef PM) -{ - LLVMAddBasicAliasAnalysisPass(PM); +LLVMPY_AddBasicAliasAnalysisPass(LLVMPassManagerRef PM) { + LLVMAddBasicAliasAnalysisPass(PM); } API_EXPORT(void) -LLVMPY_LLVMAddLoopRotatePass(LLVMPassManagerRef PM) -{ - LLVMAddLoopRotatePass(PM); +LLVMPY_LLVMAddLoopRotatePass(LLVMPassManagerRef PM) { + LLVMAddLoopRotatePass(PM); } } // end extern "C" diff --git a/llvmlite/binding/passmanagers.py b/llvmlite/binding/passmanagers.py index 6f9b7aa31..3601f5f9f 100644 --- a/llvmlite/binding/passmanagers.py +++ b/llvmlite/binding/passmanagers.py @@ -1,4 +1,4 @@ -from ctypes import c_bool, c_int, c_size_t, Structure, byref +from ctypes import c_bool, c_int, c_size_t, c_uint, Structure, byref from collections import namedtuple from enum import IntFlag from llvmlite.binding import ffi @@ -104,6 +104,14 @@ class PassManager(ffi.ObjectRef): def _dispose(self): self._capi.LLVMPY_DisposePassManager(self) + def add_aa_eval_pass(self): + """See https://llvm.org/docs/Passes.html#aa-eval-exhaustive-alias-analysis-precision-evaluator.""" # noqa E501 + ffi.lib.LLVMPY_AddAAEvalPass(self) + + def add_basic_aa_pass(self): + """See https://llvm.org/docs/Passes.html#basic-aa-basic-alias-analysis-stateless-aa-impl.""" # noqa E501 + ffi.lib.LLVMPY_AddBasicAAPass(self) + def add_constant_merge_pass(self): """See http://llvm.org/docs/Passes.html#constmerge-merge-duplicate-global-constants.""" # noqa E501 ffi.lib.LLVMPY_AddConstantMergePass(self) @@ -112,6 +120,86 @@ def add_dead_arg_elimination_pass(self): """See http://llvm.org/docs/Passes.html#deadargelim-dead-argument-elimination.""" # noqa E501 ffi.lib.LLVMPY_AddDeadArgEliminationPass(self) + def add_dependence_analysis_pass(self): + """See https://llvm.org/docs/Passes.html#da-dependence-analysis""" # noqa E501 + ffi.lib.LLVMPY_AddDependenceAnalysisPass(self) + + def add_dot_call_graph_pass(self): + """See https://llvm.org/docs/Passes.html#dot-callgraph-print-call-graph-to-dot-file""" # noqa E501 + ffi.lib.LLVMPY_AddDotCallGraphPass(self) + + def add_dot_cfg_printer_pass(self): + """See https://llvm.org/docs/Passes.html#dot-callgraph-print-call-graph-to-dot-file""" # noqa E501 + ffi.lib.LLVMPY_AddCallGraphViewerPass(self) + + def add_dot_dom_printer_pass(self, show_body=False): + """See https://llvm.org/docs/Passes.html#dot-dom-print-dominance-tree-of-function-to-dot-file""" # noqa E501 + ffi.lib.LLVMPY_AddDotDomPrinterPass(self, show_body) + + def add_dot_postdom_printer_pass(self, show_body=False): + """See https://llvm.org/docs/Passes.html#dot-postdom-print-postdominance-tree-of-function-to-dot-file""" # noqa E501 + ffi.lib.LLVMPY_AddDotPostDomPrinterPass(self, show_body) + + def add_globals_mod_ref_aa_pass(self): + """See https://llvm.org/docs/Passes.html#globalsmodref-aa-simple-mod-ref-analysis-for-globals""" # noqa E501 + ffi.lib.LLVMPY_AddGlobalsModRefAAPass(self) + + def add_iv_users_pass(self): + """See https://llvm.org/docs/Passes.html#iv-users-induction-variable-users""" # noqa E501 + ffi.lib.LLVMPY_AddIVUsersPass(self) + + def add_lint_pass(self): + """See https://llvm.org/docs/Passes.html#libcall-aa-libcall-alias-analysis""" # noqa E501 + ffi.lib.LLVMPY_AddLintPass(self) + + def add_lazy_value_info_pass(self): + """See https://llvm.org/docs/Passes.html#lazy-value-info-lazy-value-information-analysis""" # noqa E501 + ffi.lib.LLVMPY_AddLazyValueInfoPass(self) + + def add_intervals_pass(self): + """See https://llvm.org/docs/Passes.html#intervals-interval-partition-construction""" # noqa E501 + ffi.lib.LLVMPY_AddIntervalsPass(self) + + def add_module_debug_info_pass(self): + """See https://llvm.org/docs/Passes.html#intervals-interval-partition-construction""" # noqa E501 + ffi.lib.LLVMPY_AddModuleDebugInfoPass(self) + + def add_region_info_pass(self): + """See https://llvm.org/docs/Passes.html#regions-detect-single-entry-single-exit-regions""" # noqa E501 + ffi.lib.LLVMPY_AddRegionInfoPass(self) + + def add_scalar_evolution_aa_pass(self): + """See https://llvm.org/docs/Passes.html#scev-aa-scalarevolution-based-alias-analysis""" # noqa E501 + ffi.lib.LLVMPY_AddScalarEvolutionAAPass(self) + + def add_aggressive_dead_code_elimination_pass(self): + """See https://llvm.org/docs/Passes.html#adce-aggressive-dead-code-elimination""" # noqa E501 + ffi.lib.LLVMPY_AddAggressiveDCEPass(self) + + def add_always_inline_pass(self, insert_lifetime=True): + """See https://llvm.org/docs/Passes.html#always-inline-inliner-for-always-inline-functions""" # noqa E501 + ffi.lib.LLVMPY_AddAlwaysInlinePass(self, insert_lifetime) + + def add_arg_promotion_pass(self, max_elements): + """See https://llvm.org/docs/Passes.html#argpromotion-promote-by-reference-arguments-to-scalars""" # noqa E501 + ffi.lib.LLVMPY_AddArgPromotionPass(self, max_elements) + + def add_break_critical_edges_pass(self): + """See https://llvm.org/docs/Passes.html#break-crit-edges-break-critical-edges-in-cfg""" # noqa E501 + ffi.lib.LLVMPY_AddBreakCritEdgesPass(self) + + def add_dead_instruction_elimination_pass(self): + """See https://llvm.org/docs/Passes.html#die-dead-instruction-elimination""" # noqa E501 + ffi.lib.LLVMPY_AddDeadInstructionEliminationPrinterPass(self) + + def add_dead_store_elimination_pass(self): + """See https://llvm.org/docs/Passes.html#dse-dead-store-elimination""" # noqa E501 + ffi.lib.LLVMPY_AddDeadStoreEliminationPrinterPass(self) + + def add_post_order_function_attrs_pass(self): + """See https://llvm.org/docs/Passes.html#function-attrs-deduce-function-attributes""" # noqa E501 + ffi.lib.LLVMPY_AddPostOrderFunctionAttrsPass(self) + def add_function_attrs_pass(self): """See http://llvm.org/docs/Passes.html#functionattrs-deduce-function-attributes.""" # noqa E501 ffi.lib.LLVMPY_AddFunctionAttrsPass(self) @@ -136,10 +224,26 @@ def add_dead_code_elimination_pass(self): """See http://llvm.org/docs/Passes.html#dce-dead-code-elimination.""" ffi.lib.LLVMPY_AddDeadCodeEliminationPass(self) + def add_aggressive_instruction_combining_pass(self): + """See https://llvm.org/docs/Passes.html#aggressive-instcombine-combine-expression-patterns""" # noqa E501 + ffi.lib.LLVMPY_AddAggressiveInstructionCombiningPass(self) + + def add_internalize_pass(self): + """See https://llvm.org/docs/Passes.html#internalize-internalize-global-symbols""" # noqa E501 + ffi.lib.LLVMPY_AddInternalizePass(self) + def add_cfg_simplification_pass(self): """See http://llvm.org/docs/Passes.html#simplifycfg-simplify-the-cfg.""" ffi.lib.LLVMPY_AddCFGSimplificationPass(self) + def add_jump_threading_pass(self, threshold): + """See https://llvm.org/docs/Passes.html#jump-threading-jump-threading""" # noqa E501 + ffi.lib.LLVMPY_AddJumpThreadingPass(self, threshold) + + def add_lcssa_pass(self): + """See https://llvm.org/docs/Passes.html#lcssa-loop-closed-ssa-form-pass""" # noqa E501 + ffi.lib.LLVMPY_AddLCSSAPass(self) + def add_gvn_pass(self): """See http://llvm.org/docs/Passes.html#gvn-global-value-numbering.""" ffi.lib.LLVMPY_AddGVNPass(self) @@ -152,16 +256,120 @@ def add_licm_pass(self): """See http://llvm.org/docs/Passes.html#licm-loop-invariant-code-motion.""" # noqa E501 ffi.lib.LLVMPY_AddLICMPass(self) + def add_loop_deletion_pass(self): + """See https://llvm.org/docs/Passes.html#loop-deletion-delete-dead-loops""" # noqa E501 + ffi.lib.LLVMPY_AddLoopDeletionPass(self) + + def add_loop_extractor_pass(self): + """See https://llvm.org/docs/Passes.html#loop-extract-extract-loops-into-new-functions""" # noqa E501 + ffi.lib.LLVMPY_AddLoopExtractorPass(self) + + def add_single_loop_extractor_pass(self): + """See https://llvm.org/docs/Passes.html#loop-extract-single-extract-at-most-one-loop-into-a-new-function""" # noqa E501 + ffi.lib.LLVMPY_AddSingleLoopExtractorPass(self) + def add_sccp_pass(self): """See http://llvm.org/docs/Passes.html#sccp-sparse-conditional-constant-propagation.""" # noqa E501 ffi.lib.LLVMPY_AddSCCPPass(self) + def add_loop_strength_reduce_pass(self): + """See https://llvm.org/docs/Passes.html#loop-reduce-loop-strength-reduction""" # noqa E501 + ffi.lib.LLVMPY_AddLoopStrengthReducePass(self) + + def add_loop_simplification_pass(self): + """See https://llvm.org/docs/Passes.html#loop-simplify-canonicalize-natural-loops""" # noqa E501 + ffi.lib.LLVMPY_AddLoopSimplificationPass(self) + + def add_loop_unroll_pass(self): + """See https://llvm.org/docs/Passes.html#loop-unroll-unroll-loops""" # noqa E501 + ffi.lib.LLVMPY_AddLoopUnrollPass(self) + + def add_loop_unroll_and_jam_pass(self): + """See https://llvm.org/docs/Passes.html#loop-unroll-and-jam-unroll-and-jam-loops""" # noqa E501 + ffi.lib.LLVMPY_AddLoopUnrollAndJamPass(self) + + def add_loop_unswitch_pass(self, + optimize_for_size=False, + has_branch_divergence=False): + """See https://llvm.org/docs/Passes.html#loop-unswitch-unswitch-loops""" # noqa E501 + ffi.lib.LLVMPY_AddLoopUnswitchPass(self, + optimize_for_size, + has_branch_divergence) + + def add_lower_atomic_pass(self): + """See https://llvm.org/docs/Passes.html#loweratomic-lower-atomic-intrinsics-to-non-atomic-form""" # noqa E501 + ffi.lib.LLVMPY_AddLowerAtomicPass(self) + + def add_lower_invoke_pass(self): + """See https://llvm.org/docs/Passes.html#lowerinvoke-lower-invokes-to-calls-for-unwindless-code-generators""" # noqa E501 + ffi.lib.LLVMPY_AddLowerInvokePass(self) + + def add_lower_switch_pass(self): + """See https://llvm.org/docs/Passes.html#lowerswitch-lower-switchinsts-to-branches""" # noqa E501 + ffi.lib.LLVMPY_AddLowerSwitchPass(self) + + def add_memcpy_optimization_pass(self): + """See https://llvm.org/docs/Passes.html#memcpyopt-memcpy-optimization""" # noqa E501 + ffi.lib.LLVMPY_AddMemCpyOptimizationPass(self) + + def add_merge_functions_pass(self): + """See https://llvm.org/docs/Passes.html#mergefunc-merge-functions""" # noqa E501 + ffi.lib.LLVMPY_AddMergeFunctionsPass(self) + + def add_merge_returns_pass(self): + """See https://llvm.org/docs/Passes.html#mergereturn-unify-function-exit-nodes""" # noqa E501 + ffi.lib.LLVMPY_AddMergeReturnsPass(self) + + def add_partial_inlining_pass(self): + """See https://llvm.org/docs/Passes.html#partial-inliner-partial-inliner""" # noqa E501 + ffi.lib.LLVMPY_AddPartialInliningPass(self) + + def add_prune_exception_handling_pass(self): + """See https://llvm.org/docs/Passes.html#prune-eh-remove-unused-exception-handling-info""" # noqa E501 + ffi.lib.LLVMPY_AddPruneExceptionHandlingPass(self) + + def add_reassociate_pass(self): + """See https://llvm.org/docs/Passes.html#reassociate-reassociate-expressions""" # noqa E501 + ffi.lib.LLVMPY_AddReassociatePass(self) + + def add_demote_register_to_memory_pass(self): + """See https://llvm.org/docs/Passes.html#rel-lookup-table-converter-relative-lookup-table-converter""" # noqa E501 + ffi.lib.LLVMPY_AddDemoteRegisterToMemoryPass(self) + def add_sroa_pass(self): """See http://llvm.org/docs/Passes.html#scalarrepl-scalar-replacement-of-aggregates-dt. Note that this pass corresponds to the ``opt -sroa`` command-line option, despite the link above.""" # noqa E501 ffi.lib.LLVMPY_AddSROAPass(self) + def add_sink_pass(self): + """See https://llvm.org/docs/Passes.html#sink-code-sinking""" # noqa E501 + ffi.lib.LLVMPY_AddSinkPass(self) + + def add_strip_symbols_pass(self, only_debug=False): + """See https://llvm.org/docs/Passes.html#strip-strip-all-symbols-from-a-module""" # noqa E501 + ffi.lib.LLVMPY_AddStripSymbolsPass(self, only_debug) + + def add_strip_dead_debug_info_pass(self): + """See https://llvm.org/docs/Passes.html#strip-dead-debug-info-strip-debug-info-for-unused-symbols""" # noqa E501 + ffi.lib.LLVMPY_AddStripDeadDebugInfoPass(self) + + def add_strip_dead_prototypes_pass(self): + """See https://llvm.org/docs/Passes.html#strip-dead-prototypes-strip-unused-function-prototypes""" # noqa E501 + ffi.lib.LLVMPY_AddStripDeadPrototypesPass(self) + + def add_strip_debug_declare_pass(self): + """See https://llvm.org/docs/Passes.html#strip-debug-declare-strip-all-llvm-dbg-declare-intrinsics""" # noqa E501 + ffi.lib.LLVMPY_AddStripDebugDeclarePrototypesPass(self) + + def add_strip_nondebug_symbols_pass(self): + """See https://llvm.org/docs/Passes.html#strip-nondebug-strip-all-symbols-except-dbg-symbols-from-a-module""" # noqa E501 + ffi.lib.LLVMPY_AddStripNondebugSymbolsPass(self) + + def add_tail_call_elimination_pass(self): + """See https://llvm.org/docs/Passes.html#tailcallelim-tail-call-elimination""" # noqa E501 + ffi.lib.LLVMPY_AddTailCallEliminationPass(self) + def add_type_based_alias_analysis_pass(self): ffi.lib.LLVMPY_AddTypeBasedAliasAnalysisPass(self) @@ -260,8 +468,70 @@ def run(self, function): ffi.LLVMValueRef] ffi.lib.LLVMPY_RunFunctionPassManager.restype = c_bool +ffi.lib.LLVMPY_AddAAEvalPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddBasicAAPass.argtypes = [ffi.LLVMPassManagerRef] ffi.lib.LLVMPY_AddConstantMergePass.argtypes = [ffi.LLVMPassManagerRef] ffi.lib.LLVMPY_AddDeadArgEliminationPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddDependenceAnalysisPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddDotCallGraphPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddCallGraphViewerPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddDotDomPrinterPass.argtypes = [ffi.LLVMPassManagerRef, c_bool] +ffi.lib.LLVMPY_AddDotPostDomPrinterPass.argtypes = [ + ffi.LLVMPassManagerRef, + c_bool] +ffi.lib.LLVMPY_AddGlobalsModRefAAPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddInstructionCountPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddIVUsersPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddLazyValueInfoPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddLintPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddModuleDebugInfoPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddRegionInfoPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddScalarEvolutionAAPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddAggressiveDCEPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddAlwaysInlinePass.argtypes = [ffi.LLVMPassManagerRef, c_bool] +ffi.lib.LLVMPY_AddArgPromotionPass.argtypes = [ffi.LLVMPassManagerRef, c_uint] +ffi.lib.LLVMPY_AddBreakCritEdgesPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddDeadInstructionEliminationPrinterPass.argtypes = [ + ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddDeadStoreEliminationPrinterPass.argtypes = [ + ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddPostOrderFunctionAttrsPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddAggressiveInstructionCombiningPass.argtypes = [ + ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddInternalizePass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddLCSSAPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddLoopDeletionPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddLoopExtractorPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddSingleLoopExtractorPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddLoopStrengthReducePass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddLoopStrengthReducePass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddLoopSimplificationPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddLoopUnrollPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddLoopUnrollAndJamPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddLoopUnswitchPass.argtypes = [ + ffi.LLVMPassManagerRef, + c_bool, + c_bool] +ffi.lib.LLVMPY_AddLoopUnrollPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddLowerAtomicPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddLowerInvokePass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddLowerSwitchPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddMemCpyOptimizationPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddMergeFunctionsPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddMergeReturnsPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddPartialInliningPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddPruneExceptionHandlingPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddReassociatePass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddDemoteRegisterToMemoryPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddSinkPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddStripSymbolsPass.argtypes = [ffi.LLVMPassManagerRef, c_bool] +ffi.lib.LLVMPY_AddStripDeadDebugInfoPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddStripDeadPrototypesPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddStripDebugDeclarePrototypesPass.argtypes = [ + ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddStripNondebugSymbolsPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddTailCallEliminationPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddJumpThreadingPass.argtypes = [ffi.LLVMPassManagerRef, c_int] ffi.lib.LLVMPY_AddFunctionAttrsPass.argtypes = [ffi.LLVMPassManagerRef] ffi.lib.LLVMPY_AddFunctionInliningPass.argtypes = [ ffi.LLVMPassManagerRef, c_int] diff --git a/llvmlite/tests/test_binding.py b/llvmlite/tests/test_binding.py index 7c21f4267..035b720bc 100644 --- a/llvmlite/tests/test_binding.py +++ b/llvmlite/tests/test_binding.py @@ -1407,6 +1407,44 @@ def test_populate(self): pm.add_type_based_alias_analysis_pass() pm.add_basic_alias_analysis_pass() pm.add_loop_rotate_pass() + pm.add_region_info_pass() + pm.add_scalar_evolution_aa_pass() + pm.add_aggressive_dead_code_elimination_pass() + pm.add_always_inline_pass() + pm.add_arg_promotion_pass(42) + pm.add_break_critical_edges_pass() + pm.add_dead_instruction_elimination_pass() + pm.add_dead_store_elimination_pass() + pm.add_post_order_function_attrs_pass() + pm.add_aggressive_instruction_combining_pass() + pm.add_internalize_pass() + pm.add_jump_threading_pass(7) + pm.add_lcssa_pass() + pm.add_loop_deletion_pass() + pm.add_loop_extractor_pass() + pm.add_single_loop_extractor_pass() + pm.add_loop_strength_reduce_pass() + pm.add_loop_simplification_pass() + pm.add_loop_unroll_pass() + pm.add_loop_unroll_and_jam_pass() + pm.add_loop_unswitch_pass() + pm.add_lower_atomic_pass() + pm.add_lower_invoke_pass() + pm.add_lower_switch_pass() + pm.add_memcpy_optimization_pass() + pm.add_merge_functions_pass() + pm.add_merge_returns_pass() + pm.add_partial_inlining_pass() + pm.add_prune_exception_handling_pass() + pm.add_reassociate_pass() + pm.add_demote_register_to_memory_pass() + pm.add_sink_pass() + pm.add_strip_symbols_pass() + pm.add_strip_dead_debug_info_pass() + pm.add_strip_dead_prototypes_pass() + pm.add_strip_debug_declare_pass() + pm.add_strip_nondebug_symbols_pass() + pm.add_tail_call_elimination_pass() class TestDylib(BaseTest): From 83d437cf01d3c162bb79dda74a5ba76b8d000b58 Mon Sep 17 00:00:00 2001 From: Andre Masella Date: Wed, 23 Mar 2022 15:33:38 -0400 Subject: [PATCH 2/6] Rename some passes Make pass names more consistent --- ffi/passmanagers.cpp | 16 +++++------ llvmlite/binding/passmanagers.py | 47 ++++++++++++++++---------------- llvmlite/tests/test_binding.py | 5 ++-- 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/ffi/passmanagers.cpp b/ffi/passmanagers.cpp index a1fb0b880..d6493eb13 100644 --- a/ffi/passmanagers.cpp +++ b/ffi/passmanagers.cpp @@ -91,7 +91,7 @@ LLVMPY_AddAAEvalPass(LLVMPassManagerRef PM) { } API_EXPORT(void) -LLVMPY_AddBasicAAPass(LLVMPassManagerRef PM) { +LLVMPY_AddBasicAAWrapperPass(LLVMPassManagerRef PM) { unwrap(PM)->add(llvm::createBasicAAWrapperPass()); } @@ -106,7 +106,7 @@ LLVMPY_AddCallGraphViewerPass(LLVMPassManagerRef PM) { } API_EXPORT(void) -LLVMPY_AddDotCallGraphPass(LLVMPassManagerRef PM) { +LLVMPY_AddCallGraphDOTPrinterPass(LLVMPassManagerRef PM) { unwrap(PM)->add(llvm::createCallGraphDOTPrinterPass()); } @@ -138,17 +138,17 @@ LLVMPY_AddConstantMergePass(LLVMPassManagerRef PM) { } API_EXPORT(void) -LLVMPY_AddDeadInstructionEliminationPrinterPass(LLVMPassManagerRef PM) { +LLVMPY_AddDeadInstructionEliminationPass(LLVMPassManagerRef PM) { unwrap(PM)->add(llvm::createDeadInstEliminationPass()); } API_EXPORT(void) -LLVMPY_AddDeadStoreEliminationPrinterPass(LLVMPassManagerRef PM) { +LLVMPY_AddDeadStoreEliminationPass(LLVMPassManagerRef PM) { unwrap(PM)->add(llvm::createDeadStoreEliminationPass()); } API_EXPORT(void) -LLVMPY_AddPostOrderFunctionAttrsPass(LLVMPassManagerRef PM) { +LLVMPY_AddReversePostOrderFunctionAttrsPass(LLVMPassManagerRef PM) { unwrap(PM)->add(llvm::createReversePostOrderFunctionAttrsPass()); } @@ -176,7 +176,7 @@ LLVMPY_AddLintPass(LLVMPassManagerRef PM) { unwrap(PM)->add(llvm::createLintPass()); } API_EXPORT(void) -LLVMPY_AddModuleDebugInfoPass(LLVMPassManagerRef PM) { +LLVMPY_AddModuleDebugInfoPrinterPass(LLVMPassManagerRef PM) { unwrap(PM)->add(llvm::createModuleDebugInfoPrinterPass()); } @@ -196,7 +196,7 @@ LLVMPY_AddAggressiveDCEPass(LLVMPassManagerRef PM) { } API_EXPORT(void) -LLVMPY_AddAlwaysInlinePass(LLVMPassManagerRef PM, bool insertLifetime) { +LLVMPY_AddAlwaysInlinerPass(LLVMPassManagerRef PM, bool insertLifetime) { unwrap(PM)->add(llvm::createAlwaysInlinerLegacyPass(insertLifetime)); } @@ -206,7 +206,7 @@ LLVMPY_AddArgPromotionPass(LLVMPassManagerRef PM, unsigned int maxElements) { } API_EXPORT(void) -LLVMPY_AddBreakCritEdgesPass(LLVMPassManagerRef PM) { +LLVMPY_AddBreakCriticalEdgesPass(LLVMPassManagerRef PM) { unwrap(PM)->add(llvm::createBreakCriticalEdgesPass()); } diff --git a/llvmlite/binding/passmanagers.py b/llvmlite/binding/passmanagers.py index 3601f5f9f..f0420e534 100644 --- a/llvmlite/binding/passmanagers.py +++ b/llvmlite/binding/passmanagers.py @@ -110,7 +110,7 @@ def add_aa_eval_pass(self): def add_basic_aa_pass(self): """See https://llvm.org/docs/Passes.html#basic-aa-basic-alias-analysis-stateless-aa-impl.""" # noqa E501 - ffi.lib.LLVMPY_AddBasicAAPass(self) + ffi.lib.LLVMPY_AddBasicAAWrapperPass(self) def add_constant_merge_pass(self): """See http://llvm.org/docs/Passes.html#constmerge-merge-duplicate-global-constants.""" # noqa E501 @@ -126,10 +126,10 @@ def add_dependence_analysis_pass(self): def add_dot_call_graph_pass(self): """See https://llvm.org/docs/Passes.html#dot-callgraph-print-call-graph-to-dot-file""" # noqa E501 - ffi.lib.LLVMPY_AddDotCallGraphPass(self) + ffi.lib.LLVMPY_AddCallGraphDOTPrinterPass(self) def add_dot_cfg_printer_pass(self): - """See https://llvm.org/docs/Passes.html#dot-callgraph-print-call-graph-to-dot-file""" # noqa E501 + """See https://llvm.org/docs/Passes.html#dot-cfg-print-cfg-of-function-to-dot-file""" # noqa E501 ffi.lib.LLVMPY_AddCallGraphViewerPass(self) def add_dot_dom_printer_pass(self, show_body=False): @@ -149,7 +149,7 @@ def add_iv_users_pass(self): ffi.lib.LLVMPY_AddIVUsersPass(self) def add_lint_pass(self): - """See https://llvm.org/docs/Passes.html#libcall-aa-libcall-alias-analysis""" # noqa E501 + """See https://llvm.org/docs/Passes.html#lint-statically-lint-checks-llvm-ir""" # noqa E501 ffi.lib.LLVMPY_AddLintPass(self) def add_lazy_value_info_pass(self): @@ -161,8 +161,8 @@ def add_intervals_pass(self): ffi.lib.LLVMPY_AddIntervalsPass(self) def add_module_debug_info_pass(self): - """See https://llvm.org/docs/Passes.html#intervals-interval-partition-construction""" # noqa E501 - ffi.lib.LLVMPY_AddModuleDebugInfoPass(self) + """See https://llvm.org/docs/Passes.html#module-debuginfo-decodes-module-level-debug-info""" # noqa E501 + ffi.lib.LLVMPY_AddModuleDebugInfoPrinterPass(self) def add_region_info_pass(self): """See https://llvm.org/docs/Passes.html#regions-detect-single-entry-single-exit-regions""" # noqa E501 @@ -176,29 +176,29 @@ def add_aggressive_dead_code_elimination_pass(self): """See https://llvm.org/docs/Passes.html#adce-aggressive-dead-code-elimination""" # noqa E501 ffi.lib.LLVMPY_AddAggressiveDCEPass(self) - def add_always_inline_pass(self, insert_lifetime=True): + def add_always_inliner_pass(self, insert_lifetime=True): """See https://llvm.org/docs/Passes.html#always-inline-inliner-for-always-inline-functions""" # noqa E501 - ffi.lib.LLVMPY_AddAlwaysInlinePass(self, insert_lifetime) + ffi.lib.LLVMPY_AddAlwaysInlinerPass(self, insert_lifetime) - def add_arg_promotion_pass(self, max_elements): + def add_arg_promotion_pass(self, max_elements=3): """See https://llvm.org/docs/Passes.html#argpromotion-promote-by-reference-arguments-to-scalars""" # noqa E501 ffi.lib.LLVMPY_AddArgPromotionPass(self, max_elements) def add_break_critical_edges_pass(self): """See https://llvm.org/docs/Passes.html#break-crit-edges-break-critical-edges-in-cfg""" # noqa E501 - ffi.lib.LLVMPY_AddBreakCritEdgesPass(self) + ffi.lib.LLVMPY_AddBreakCriticalEdgesPass(self) def add_dead_instruction_elimination_pass(self): """See https://llvm.org/docs/Passes.html#die-dead-instruction-elimination""" # noqa E501 - ffi.lib.LLVMPY_AddDeadInstructionEliminationPrinterPass(self) + ffi.lib.LLVMPY_AddDeadInstructionEliminationPass(self) def add_dead_store_elimination_pass(self): """See https://llvm.org/docs/Passes.html#dse-dead-store-elimination""" # noqa E501 - ffi.lib.LLVMPY_AddDeadStoreEliminationPrinterPass(self) + ffi.lib.LLVMPY_AddDeadStoreEliminationPass(self) def add_post_order_function_attrs_pass(self): """See https://llvm.org/docs/Passes.html#function-attrs-deduce-function-attributes""" # noqa E501 - ffi.lib.LLVMPY_AddPostOrderFunctionAttrsPass(self) + ffi.lib.LLVMPY_AddReversePostOrderFunctionAttrsPass(self) def add_function_attrs_pass(self): """See http://llvm.org/docs/Passes.html#functionattrs-deduce-function-attributes.""" # noqa E501 @@ -236,7 +236,7 @@ def add_cfg_simplification_pass(self): """See http://llvm.org/docs/Passes.html#simplifycfg-simplify-the-cfg.""" ffi.lib.LLVMPY_AddCFGSimplificationPass(self) - def add_jump_threading_pass(self, threshold): + def add_jump_threading_pass(self, threshold=-1): """See https://llvm.org/docs/Passes.html#jump-threading-jump-threading""" # noqa E501 ffi.lib.LLVMPY_AddJumpThreadingPass(self, threshold) @@ -328,7 +328,7 @@ def add_prune_exception_handling_pass(self): """See https://llvm.org/docs/Passes.html#prune-eh-remove-unused-exception-handling-info""" # noqa E501 ffi.lib.LLVMPY_AddPruneExceptionHandlingPass(self) - def add_reassociate_pass(self): + def add_reassociate_expressions_pass(self): """See https://llvm.org/docs/Passes.html#reassociate-reassociate-expressions""" # noqa E501 ffi.lib.LLVMPY_AddReassociatePass(self) @@ -469,11 +469,11 @@ def run(self, function): ffi.lib.LLVMPY_RunFunctionPassManager.restype = c_bool ffi.lib.LLVMPY_AddAAEvalPass.argtypes = [ffi.LLVMPassManagerRef] -ffi.lib.LLVMPY_AddBasicAAPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddBasicAAWrapperPass.argtypes = [ffi.LLVMPassManagerRef] ffi.lib.LLVMPY_AddConstantMergePass.argtypes = [ffi.LLVMPassManagerRef] ffi.lib.LLVMPY_AddDeadArgEliminationPass.argtypes = [ffi.LLVMPassManagerRef] ffi.lib.LLVMPY_AddDependenceAnalysisPass.argtypes = [ffi.LLVMPassManagerRef] -ffi.lib.LLVMPY_AddDotCallGraphPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddCallGraphDOTPrinterPass.argtypes = [ffi.LLVMPassManagerRef] ffi.lib.LLVMPY_AddCallGraphViewerPass.argtypes = [ffi.LLVMPassManagerRef] ffi.lib.LLVMPY_AddDotDomPrinterPass.argtypes = [ffi.LLVMPassManagerRef, c_bool] ffi.lib.LLVMPY_AddDotPostDomPrinterPass.argtypes = [ @@ -484,18 +484,19 @@ def run(self, function): ffi.lib.LLVMPY_AddIVUsersPass.argtypes = [ffi.LLVMPassManagerRef] ffi.lib.LLVMPY_AddLazyValueInfoPass.argtypes = [ffi.LLVMPassManagerRef] ffi.lib.LLVMPY_AddLintPass.argtypes = [ffi.LLVMPassManagerRef] -ffi.lib.LLVMPY_AddModuleDebugInfoPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddModuleDebugInfoPrinterPass.argtypes = [ffi.LLVMPassManagerRef] ffi.lib.LLVMPY_AddRegionInfoPass.argtypes = [ffi.LLVMPassManagerRef] ffi.lib.LLVMPY_AddScalarEvolutionAAPass.argtypes = [ffi.LLVMPassManagerRef] ffi.lib.LLVMPY_AddAggressiveDCEPass.argtypes = [ffi.LLVMPassManagerRef] -ffi.lib.LLVMPY_AddAlwaysInlinePass.argtypes = [ffi.LLVMPassManagerRef, c_bool] +ffi.lib.LLVMPY_AddAlwaysInlinerPass.argtypes = [ffi.LLVMPassManagerRef, c_bool] ffi.lib.LLVMPY_AddArgPromotionPass.argtypes = [ffi.LLVMPassManagerRef, c_uint] -ffi.lib.LLVMPY_AddBreakCritEdgesPass.argtypes = [ffi.LLVMPassManagerRef] -ffi.lib.LLVMPY_AddDeadInstructionEliminationPrinterPass.argtypes = [ +ffi.lib.LLVMPY_AddBreakCriticalEdgesPass.argtypes = [ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddDeadInstructionEliminationPass.argtypes = [ + ffi.LLVMPassManagerRef] +ffi.lib.LLVMPY_AddDeadStoreEliminationPass.argtypes = [ ffi.LLVMPassManagerRef] -ffi.lib.LLVMPY_AddDeadStoreEliminationPrinterPass.argtypes = [ +ffi.lib.LLVMPY_AddReversePostOrderFunctionAttrsPass.argtypes = [ ffi.LLVMPassManagerRef] -ffi.lib.LLVMPY_AddPostOrderFunctionAttrsPass.argtypes = [ffi.LLVMPassManagerRef] ffi.lib.LLVMPY_AddAggressiveInstructionCombiningPass.argtypes = [ ffi.LLVMPassManagerRef] ffi.lib.LLVMPY_AddInternalizePass.argtypes = [ffi.LLVMPassManagerRef] diff --git a/llvmlite/tests/test_binding.py b/llvmlite/tests/test_binding.py index 035b720bc..501b46c17 100644 --- a/llvmlite/tests/test_binding.py +++ b/llvmlite/tests/test_binding.py @@ -1410,7 +1410,8 @@ def test_populate(self): pm.add_region_info_pass() pm.add_scalar_evolution_aa_pass() pm.add_aggressive_dead_code_elimination_pass() - pm.add_always_inline_pass() + pm.add_aa_eval_pass() + pm.add_always_inliner_pass() pm.add_arg_promotion_pass(42) pm.add_break_critical_edges_pass() pm.add_dead_instruction_elimination_pass() @@ -1436,7 +1437,7 @@ def test_populate(self): pm.add_merge_returns_pass() pm.add_partial_inlining_pass() pm.add_prune_exception_handling_pass() - pm.add_reassociate_pass() + pm.add_reassociate_expressions_pass() pm.add_demote_register_to_memory_pass() pm.add_sink_pass() pm.add_strip_symbols_pass() From e1b0d27c1d2bcabbead790aeea9c299a74faca8c Mon Sep 17 00:00:00 2001 From: Andre Masella Date: Wed, 23 Mar 2022 15:50:21 -0400 Subject: [PATCH 3/6] Add formatting checker for C++ Use clang-format from Azure pipelines to check formatting of C++ code. --- azure-pipelines.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 19e1851ad..ad481334d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -68,3 +68,13 @@ jobs: parameters: name: Windows vmImage: windows-2019 + +- job: check_formatting + pool: + vmImage: 'ubuntu-latest' + steps: + - script: | + set -e + sudo apt install -y clang-format + clang-format -n -Werror ffi/*.cpp ffi/*.h + displayName: Check C++ formatting From d8d17fda497b782a40f8ec4c6df233aea0791893 Mon Sep 17 00:00:00 2001 From: Andre Masella Date: Tue, 5 Apr 2022 15:22:21 -0400 Subject: [PATCH 5/6] Update to LLVM 12-13 Modify llvmlite to support LLVM 11-13 and modify conda recipe to build LLVM13. Also lift over all patches to LLVM versions as required. --- ...-Limit-size-of-non-GlobalValue-name.patch} | 0 ...tch => llvm11-consecutive_registers.patch} | 0 ...-entrypoints-in-add-TLI-mappings.ll.patch} | 0 ...atch => llvm11-intel-D47188-svml-VF.patch} | 0 ...o-static.patch => llvm11-lto-static.patch} | 0 ...ing.patch => llvm11-partial-testing.patch} | 0 ...t-Limit-size-of-non-GlobalValue-name.patch | 49 +++++ .../llvm12-consecutive_registers.patch | 181 ++++++++++++++++++ conda-recipes/llvm12-lto-static.patch | 12 ++ conda-recipes/llvm13-lto-static.patch | 12 ++ conda-recipes/llvmdev/build.sh | 1 + conda-recipes/llvmdev/meta.yaml | 18 +- ffi/Makefile.freebsd | 2 +- ffi/Makefile.osx | 4 +- ffi/build.py | 7 +- ffi/passmanagers.cpp | 9 +- ffi/targets.cpp | 4 + ffi/value.cpp | 13 +- llvmlite/binding/passmanagers.py | 6 - llvmlite/tests/test_binding.py | 3 +- 20 files changed, 287 insertions(+), 34 deletions(-) rename conda-recipes/{0001-Revert-Limit-size-of-non-GlobalValue-name.patch => llvm11-0001-Revert-Limit-size-of-non-GlobalValue-name.patch} (100%) rename conda-recipes/{llvm_11_consecutive_registers.patch => llvm11-consecutive_registers.patch} (100%) rename conda-recipes/{expect-fastmath-entrypoints-in-add-TLI-mappings.ll.patch => llvm11-expect-fastmath-entrypoints-in-add-TLI-mappings.ll.patch} (100%) rename conda-recipes/{intel-D47188-svml-VF.patch => llvm11-intel-D47188-svml-VF.patch} (100%) rename conda-recipes/{llvm-lto-static.patch => llvm11-lto-static.patch} (100%) rename conda-recipes/{partial-testing.patch => llvm11-partial-testing.patch} (100%) create mode 100644 conda-recipes/llvm12-0001-Revert-Limit-size-of-non-GlobalValue-name.patch create mode 100644 conda-recipes/llvm12-consecutive_registers.patch create mode 100644 conda-recipes/llvm12-lto-static.patch create mode 100644 conda-recipes/llvm13-lto-static.patch diff --git a/conda-recipes/0001-Revert-Limit-size-of-non-GlobalValue-name.patch b/conda-recipes/llvm11-0001-Revert-Limit-size-of-non-GlobalValue-name.patch similarity index 100% rename from conda-recipes/0001-Revert-Limit-size-of-non-GlobalValue-name.patch rename to conda-recipes/llvm11-0001-Revert-Limit-size-of-non-GlobalValue-name.patch diff --git a/conda-recipes/llvm_11_consecutive_registers.patch b/conda-recipes/llvm11-consecutive_registers.patch similarity index 100% rename from conda-recipes/llvm_11_consecutive_registers.patch rename to conda-recipes/llvm11-consecutive_registers.patch diff --git a/conda-recipes/expect-fastmath-entrypoints-in-add-TLI-mappings.ll.patch b/conda-recipes/llvm11-expect-fastmath-entrypoints-in-add-TLI-mappings.ll.patch similarity index 100% rename from conda-recipes/expect-fastmath-entrypoints-in-add-TLI-mappings.ll.patch rename to conda-recipes/llvm11-expect-fastmath-entrypoints-in-add-TLI-mappings.ll.patch diff --git a/conda-recipes/intel-D47188-svml-VF.patch b/conda-recipes/llvm11-intel-D47188-svml-VF.patch similarity index 100% rename from conda-recipes/intel-D47188-svml-VF.patch rename to conda-recipes/llvm11-intel-D47188-svml-VF.patch diff --git a/conda-recipes/llvm-lto-static.patch b/conda-recipes/llvm11-lto-static.patch similarity index 100% rename from conda-recipes/llvm-lto-static.patch rename to conda-recipes/llvm11-lto-static.patch diff --git a/conda-recipes/partial-testing.patch b/conda-recipes/llvm11-partial-testing.patch similarity index 100% rename from conda-recipes/partial-testing.patch rename to conda-recipes/llvm11-partial-testing.patch diff --git a/conda-recipes/llvm12-0001-Revert-Limit-size-of-non-GlobalValue-name.patch b/conda-recipes/llvm12-0001-Revert-Limit-size-of-non-GlobalValue-name.patch new file mode 100644 index 000000000..9b722d36c --- /dev/null +++ b/conda-recipes/llvm12-0001-Revert-Limit-size-of-non-GlobalValue-name.patch @@ -0,0 +1,49 @@ +diff -ur a/lib/IR/Value.cpp b/lib/IR/Value.cpp +--- a/lib/IR/Value.cpp 2021-04-06 12:38:18.000000000 -0400 ++++ b/lib/IR/Value.cpp 2022-03-31 15:39:31.000000000 -0400 +@@ -38,10 +38,6 @@ + + using namespace llvm; + +-static cl::opt NonGlobalValueMaxNameSize( +- "non-global-value-max-name-size", cl::Hidden, cl::init(1024), +- cl::desc("Maximum size for the name of non-global values.")); +- + //===----------------------------------------------------------------------===// + // Value Class + //===----------------------------------------------------------------------===// +@@ -319,11 +315,6 @@ + if (getName() == NameRef) + return; + +- // Cap the size of non-GlobalValue names. +- if (NameRef.size() > NonGlobalValueMaxNameSize && !isa(this)) +- NameRef = +- NameRef.substr(0, std::max(1u, (unsigned)NonGlobalValueMaxNameSize)); +- + assert(!getType()->isVoidTy() && "Cannot assign a name to void values!"); + + // Get the symbol table to update for this object. +diff -ur a/test/Bitcode/value-with-long-name.ll b/test/Bitcode/value-with-long-name.ll +deleted file mode 1000644 +--- a/test/Bitcode/value-with-long-name.ll ++++ /dev/null +@@ -1,18 +0,0 @@ +-; Check the size of generated variable when no option is set +-; RUN: opt -S %s -O2 -o - | FileCheck -check-prefix=CHECK-LONG %s +-; CHECK-LONG: %{{[a-z]{4}[a-z]+}} +- +-; Then check we correctly cap the size of newly generated non-global values name +-; Force the size to be small so that the check works on release and debug build +-; RUN: opt -S %s -O2 -o - -non-global-value-max-name-size=0 | FileCheck -check-prefix=CHECK-SHORT %s +-; RUN: opt -S %s -O2 -o - -non-global-value-max-name-size=1 | FileCheck -check-prefix=CHECK-SHORT %s +-; CHECK-SHORT-NOT: %{{[a-z][a-z]+}} +- +-define i32 @f(i32 %a, i32 %b) { +- %c = add i32 %a, %b +- %d = add i32 %c, %a +- %e = add i32 %d, %b +- ret i32 %e +-} +- +- diff --git a/conda-recipes/llvm12-consecutive_registers.patch b/conda-recipes/llvm12-consecutive_registers.patch new file mode 100644 index 000000000..cc60217bd --- /dev/null +++ b/conda-recipes/llvm12-consecutive_registers.patch @@ -0,0 +1,181 @@ +diff -ur a/include/llvm/CodeGen/TargetLowering.h b/include/llvm/CodeGen/TargetLowering.h +--- a/include/llvm/CodeGen/TargetLowering.h 2021-04-06 12:38:18.000000000 -0400 ++++ b/include/llvm/CodeGen/TargetLowering.h 2022-03-31 15:52:45.000000000 -0400 +@@ -3975,7 +3975,8 @@ + /// must be passed in a block of consecutive registers. + virtual bool + functionArgumentNeedsConsecutiveRegisters(Type *Ty, CallingConv::ID CallConv, +- bool isVarArg) const { ++ bool isVarArg, ++ const DataLayout &DL) const { + return false; + } + +diff -ur a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp +--- a/lib/CodeGen/SelectionDAG/FastISel.cpp 2021-04-06 12:38:18.000000000 -0400 ++++ b/lib/CodeGen/SelectionDAG/FastISel.cpp 2022-03-31 15:52:45.000000000 -0400 +@@ -1087,7 +1087,7 @@ + if (Arg.IsByVal) + FinalType = cast(Arg.Ty)->getElementType(); + bool NeedsRegBlock = TLI.functionArgumentNeedsConsecutiveRegisters( +- FinalType, CLI.CallConv, CLI.IsVarArg); ++ FinalType, CLI.CallConv, CLI.IsVarArg, DL); + + ISD::ArgFlagsTy Flags; + if (Arg.IsZExt) +diff -ur a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +--- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp 2021-04-06 12:38:18.000000000 -0400 ++++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp 2022-03-31 15:52:45.000000000 -0400 +@@ -1851,7 +1851,7 @@ + + bool NeedsRegBlock = TLI.functionArgumentNeedsConsecutiveRegisters( + I.getOperand(0)->getType(), F->getCallingConv(), +- /*IsVarArg*/ false); ++ /*IsVarArg*/ false, DL); + + ISD::NodeType ExtendKind = ISD::ANY_EXTEND; + if (F->getAttributes().hasAttribute(AttributeList::ReturnIndex, +@@ -9229,7 +9229,7 @@ + CLI.IsTailCall = false; + } else { + bool NeedsRegBlock = functionArgumentNeedsConsecutiveRegisters( +- CLI.RetTy, CLI.CallConv, CLI.IsVarArg); ++ CLI.RetTy, CLI.CallConv, CLI.IsVarArg, DL); + for (unsigned I = 0, E = RetTys.size(); I != E; ++I) { + ISD::ArgFlagsTy Flags; + if (NeedsRegBlock) { +@@ -9289,7 +9289,7 @@ + if (Args[i].IsByVal) + FinalType = cast(Args[i].Ty)->getElementType(); + bool NeedsRegBlock = functionArgumentNeedsConsecutiveRegisters( +- FinalType, CLI.CallConv, CLI.IsVarArg); ++ FinalType, CLI.CallConv, CLI.IsVarArg, DL); + for (unsigned Value = 0, NumValues = ValueVTs.size(); Value != NumValues; + ++Value) { + EVT VT = ValueVTs[Value]; +@@ -9830,7 +9830,7 @@ + if (Arg.hasAttribute(Attribute::ByVal)) + FinalType = Arg.getParamByValType(); + bool NeedsRegBlock = TLI->functionArgumentNeedsConsecutiveRegisters( +- FinalType, F.getCallingConv(), F.isVarArg()); ++ FinalType, F.getCallingConv(), F.isVarArg(), DL); + for (unsigned Value = 0, NumValues = ValueVTs.size(); + Value != NumValues; ++Value) { + EVT VT = ValueVTs[Value]; +diff -ur a/lib/Target/AArch64/AArch64ISelLowering.cpp b/lib/Target/AArch64/AArch64ISelLowering.cpp +--- a/lib/Target/AArch64/AArch64ISelLowering.cpp 2021-04-06 12:38:18.000000000 -0400 ++++ b/lib/Target/AArch64/AArch64ISelLowering.cpp 2022-03-31 15:52:45.000000000 -0400 +@@ -30,6 +30,7 @@ + #include "llvm/ADT/Triple.h" + #include "llvm/ADT/Twine.h" + #include "llvm/Analysis/VectorUtils.h" ++#include "llvm/CodeGen/Analysis.h" + #include "llvm/CodeGen/CallingConvLower.h" + #include "llvm/CodeGen/MachineBasicBlock.h" + #include "llvm/CodeGen/MachineFrameInfo.h" +@@ -16455,15 +16456,17 @@ + } + + bool AArch64TargetLowering::functionArgumentNeedsConsecutiveRegisters( +- Type *Ty, CallingConv::ID CallConv, bool isVarArg) const { +- if (Ty->isArrayTy()) +- return true; +- +- const TypeSize &TySize = Ty->getPrimitiveSizeInBits(); +- if (TySize.isScalable() && TySize.getKnownMinSize() > 128) +- return true; ++ Type *Ty, CallingConv::ID CallConv, bool isVarArg, ++ const DataLayout &DL) const { ++ if (!Ty->isArrayTy()) { ++ const TypeSize &TySize = Ty->getPrimitiveSizeInBits(); ++ return TySize.isScalable() && TySize.getKnownMinSize() > 128; ++ } + +- return false; ++ // All non aggregate members of the type must have the same type ++ SmallVector ValueVTs; ++ ComputeValueVTs(*this, DL, Ty, ValueVTs); ++ return is_splat(ValueVTs); + } + + bool AArch64TargetLowering::shouldNormalizeToSelectSequence(LLVMContext &, +diff -ur a/lib/Target/AArch64/AArch64ISelLowering.h b/lib/Target/AArch64/AArch64ISelLowering.h +--- a/lib/Target/AArch64/AArch64ISelLowering.h 2021-04-06 12:38:18.000000000 -0400 ++++ b/lib/Target/AArch64/AArch64ISelLowering.h 2022-03-31 15:52:45.000000000 -0400 +@@ -770,9 +770,10 @@ + MachineMemOperand::Flags getTargetMMOFlags( + const Instruction &I) const override; + +- bool functionArgumentNeedsConsecutiveRegisters(Type *Ty, +- CallingConv::ID CallConv, +- bool isVarArg) const override; ++ bool functionArgumentNeedsConsecutiveRegisters( ++ Type *Ty, CallingConv::ID CallConv, bool isVarArg, ++ const DataLayout &DL) const override; ++ + /// Used for exception handling on Win64. + bool needsFixedCatchObjects() const override; + +diff -ur a/lib/Target/AArch64/GISel/AArch64CallLowering.cpp b/lib/Target/AArch64/GISel/AArch64CallLowering.cpp +--- a/lib/Target/AArch64/GISel/AArch64CallLowering.cpp 2021-04-06 12:38:18.000000000 -0400 ++++ b/lib/Target/AArch64/GISel/AArch64CallLowering.cpp 2022-03-31 15:52:45.000000000 -0400 +@@ -259,7 +259,7 @@ + assert(OrigArg.Regs.size() == SplitVTs.size() && "Regs / types mismatch"); + + bool NeedsRegBlock = TLI.functionArgumentNeedsConsecutiveRegisters( +- OrigArg.Ty, CallConv, false); ++ OrigArg.Ty, CallConv, false, DL); + for (unsigned i = 0, e = SplitVTs.size(); i < e; ++i) { + Type *SplitTy = SplitVTs[i].getTypeForEVT(Ctx); + SplitArgs.emplace_back(OrigArg.Regs[i], SplitTy, OrigArg.Flags[0], +diff -ur a/lib/Target/ARM/ARMCallLowering.cpp b/lib/Target/ARM/ARMCallLowering.cpp +--- a/lib/Target/ARM/ARMCallLowering.cpp 2021-04-06 12:38:18.000000000 -0400 ++++ b/lib/Target/ARM/ARMCallLowering.cpp 2022-03-31 15:52:45.000000000 -0400 +@@ -218,7 +218,7 @@ + + bool NeedsConsecutiveRegisters = + TLI.functionArgumentNeedsConsecutiveRegisters( +- SplitTy, F.getCallingConv(), F.isVarArg()); ++ SplitTy, F.getCallingConv(), F.isVarArg(), DL); + if (NeedsConsecutiveRegisters) { + Flags.setInConsecutiveRegs(); + if (i == e - 1) +diff -ur a/lib/Target/ARM/ARMISelLowering.cpp b/lib/Target/ARM/ARMISelLowering.cpp +--- a/lib/Target/ARM/ARMISelLowering.cpp 2021-04-06 12:38:18.000000000 -0400 ++++ b/lib/Target/ARM/ARMISelLowering.cpp 2022-03-31 15:52:45.000000000 -0400 +@@ -19269,7 +19269,8 @@ + /// [N x i32] or [N x i64]. This allows front-ends to skip emitting padding when + /// passing according to AAPCS rules. + bool ARMTargetLowering::functionArgumentNeedsConsecutiveRegisters( +- Type *Ty, CallingConv::ID CallConv, bool isVarArg) const { ++ Type *Ty, CallingConv::ID CallConv, bool isVarArg, ++ const DataLayout &DL) const { + if (getEffectiveCallingConv(CallConv, isVarArg) != + CallingConv::ARM_AAPCS_VFP) + return false; +diff -ur a/lib/Target/ARM/ARMISelLowering.h b/lib/Target/ARM/ARMISelLowering.h +--- a/lib/Target/ARM/ARMISelLowering.h 2021-04-06 12:38:18.000000000 -0400 ++++ b/lib/Target/ARM/ARMISelLowering.h 2022-03-31 15:52:45.000000000 -0400 +@@ -578,7 +578,8 @@ + /// Returns true if an argument of type Ty needs to be passed in a + /// contiguous block of registers in calling convention CallConv. + bool functionArgumentNeedsConsecutiveRegisters( +- Type *Ty, CallingConv::ID CallConv, bool isVarArg) const override; ++ Type *Ty, CallingConv::ID CallConv, bool isVarArg, ++ const DataLayout &DL) const override; + + /// If a physical register, this returns the register that receives the + /// exception address on entry to an EH pad. +diff -ur a/lib/Target/PowerPC/PPCISelLowering.h b/lib/Target/PowerPC/PPCISelLowering.h +--- a/lib/Target/PowerPC/PPCISelLowering.h 2021-04-06 12:38:18.000000000 -0400 ++++ b/lib/Target/PowerPC/PPCISelLowering.h 2022-03-31 15:52:45.000000000 -0400 +@@ -998,7 +998,8 @@ + /// Returns true if an argument of type Ty needs to be passed in a + /// contiguous block of registers in calling convention CallConv. + bool functionArgumentNeedsConsecutiveRegisters( +- Type *Ty, CallingConv::ID CallConv, bool isVarArg) const override { ++ Type *Ty, CallingConv::ID CallConv, bool isVarArg, ++ const DataLayout &DL) const override { + // We support any array type as "consecutive" block in the parameter + // save area. The element type defines the alignment requirement and + // whether the argument should go in GPRs, FPRs, or VRs if available. diff --git a/conda-recipes/llvm12-lto-static.patch b/conda-recipes/llvm12-lto-static.patch new file mode 100644 index 000000000..76cc55def --- /dev/null +++ b/conda-recipes/llvm12-lto-static.patch @@ -0,0 +1,12 @@ +diff -ur a/tools/lto/CMakeLists.txt b/tools/lto/CMakeLists.txt +--- llvm-12.0.0.src-orig/tools/lto/CMakeLists.txt 2021-04-06 12:38:18.000000000 -0400 ++++ llvm-12.0.0.src/tools/lto/CMakeLists.txt 2022-03-31 15:46:00.000000000 -0400 +@@ -21,7 +21,7 @@ + + set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/lto.exports) + +-add_llvm_library(LTO SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES} DEPENDS ++add_llvm_library(LTO INSTALL_WITH_TOOLCHAIN ${SOURCES} DEPENDS + intrinsics_gen) + + install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h diff --git a/conda-recipes/llvm13-lto-static.patch b/conda-recipes/llvm13-lto-static.patch new file mode 100644 index 000000000..b8a624250 --- /dev/null +++ b/conda-recipes/llvm13-lto-static.patch @@ -0,0 +1,12 @@ +diff -ur llvm-13.0.0.src-orig/tools/lto/CMakeLists.txt llvm-13.0.0.src/tools/lto/CMakeLists.txt +--- llvm-13.0.0.src-orig/tools/lto/CMakeLists.txt 2021-09-24 12:18:10.000000000 -0400 ++++ llvm-13.0.0.src/tools/lto/CMakeLists.txt 2022-03-31 17:07:07.000000000 -0400 +@@ -25,7 +25,7 @@ + set(LTO_LIBRARY_TYPE MODULE) + set(LTO_LIBRARY_NAME libLTO) + else() +- set(LTO_LIBRARY_TYPE SHARED) ++ set(LTO_LIBRARY_TYPE STATIC) + set(LTO_LIBRARY_NAME LTO) + endif() + diff --git a/conda-recipes/llvmdev/build.sh b/conda-recipes/llvmdev/build.sh index fd99eee90..d187f6482 100644 --- a/conda-recipes/llvmdev/build.sh +++ b/conda-recipes/llvmdev/build.sh @@ -39,6 +39,7 @@ _cmake_config+=(-DLLVM_ENABLE_RTTI=OFF) _cmake_config+=(-DLLVM_TARGETS_TO_BUILD=${LLVM_TARGETS_TO_BUILD}) _cmake_config+=(-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly) _cmake_config+=(-DLLVM_INCLUDE_UTILS=ON) # for llvm-lit +_cmake_config+=(-DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF) # doesn't build without the rest of LLVM project # TODO :: It would be nice if we had a cross-ecosystem 'BUILD_TIME_LIMITED' env var we could use to # disable these unnecessary but useful things. if [[ ${CONDA_FORGE} == yes ]]; then diff --git a/conda-recipes/llvmdev/meta.yaml b/conda-recipes/llvmdev/meta.yaml index 27b596ffc..9c9376bb0 100644 --- a/conda-recipes/llvmdev/meta.yaml +++ b/conda-recipes/llvmdev/meta.yaml @@ -1,7 +1,7 @@ -{% set shortversion = "11.1" %} -{% set version = "11.1.0" %} -{% set sha256_llvm = "ce8508e318a01a63d4e8b3090ab2ded3c598a50258cc49e2625b9120d4c03ea5" %} -{% set sha256_lld = "017a788cbe1ecc4a949abf10755870519086d058a2e99f438829aef24f0c66ce" %} +{% set shortversion = "13.0" %} +{% set version = "13.0.1" %} +{% set sha256_llvm = "ec6b80d82c384acad2dc192903a6cf2cdbaffb889b84bfb98da9d71e630fc834" %} +{% set sha256_lld = "666af745e8bf7b680533b4d18b7a31dc7cab575b1e6e4d261922bbafd9644cfb" %} {% set build_number = "5" %} package: @@ -13,15 +13,7 @@ source: fn: llvm-{{ version }}.src.tar.xz sha256: {{ sha256_llvm }} patches: - - ../partial-testing.patch - # Intel SVML optimizations (two patches) - - ../intel-D47188-svml-VF.patch - # Second patch from https://github.com/conda-forge/llvmdev-feedstock/blob/c706309/recipe/patches/expect-fastmath-entrypoints-in-add-TLI-mappings.ll.patch - - ../expect-fastmath-entrypoints-in-add-TLI-mappings.ll.patch - # Reverts a patch limiting non-GlobalValue name length - - ../0001-Revert-Limit-size-of-non-GlobalValue-name.patch - # Fixes for aarch64 on LLVM 11 from https://reviews.llvm.org/D104123 - - ../llvm_11_consecutive_registers.patch + - ../llvm13-lto-static.patch - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ version }}/lld-{{ version }}.src.tar.xz fn: lld-{{ version }}.src.tar.xz diff --git a/ffi/Makefile.freebsd b/ffi/Makefile.freebsd index ba727e331..7b869e876 100644 --- a/ffi/Makefile.freebsd +++ b/ffi/Makefile.freebsd @@ -1,5 +1,5 @@ -CXX = clang++ -std=c++11 -stdlib=libc++ +CXX = clang++ -stdlib=libc++ # -flto and --exclude-libs allow us to remove those parts of LLVM we don't use CXX_FLTO_FLAGS ?= -flto diff --git a/ffi/Makefile.osx b/ffi/Makefile.osx index bc192071e..74dccf32c 100644 --- a/ffi/Makefile.osx +++ b/ffi/Makefile.osx @@ -1,6 +1,6 @@ -CXX = clang++ -std=c++11 -stdlib=libc++ -CXXFLAGS = $(LLVM_CXXFLAGS) +CXX = clang++ +CXXFLAGS = $(LLVM_CXXFLAGS) -O3 # Only export the LLVMPY symbols we require and exclude everything else. EXPORT = "-Wl,-exported_symbol,_LLVMPY_*" LDFLAGS := $(LDFLAGS) $(EXPORT) $(LLVM_LDFLAGS) diff --git a/ffi/build.py b/ffi/build.py index 55343fca5..e830342eb 100755 --- a/ffi/build.py +++ b/ffi/build.py @@ -163,9 +163,10 @@ def main_posix(kind, library_ext): print(msg) print(warning + '\n') else: - - if not out.startswith('11'): - msg = ("Building llvmlite requires LLVM 11.x.x, got " + (version, _) = out.split('.', 1) + version = int(version) + if version < 11 or version > 13: + msg = ("Building llvmlite requires LLVM 11, 12, or 13, got " "{!r}. Be sure to set LLVM_CONFIG to the right executable " "path.\nRead the documentation at " "http://llvmlite.pydata.org/ for more information about " diff --git a/ffi/passmanagers.cpp b/ffi/passmanagers.cpp index d6493eb13..00e99d485 100644 --- a/ffi/passmanagers.cpp +++ b/ffi/passmanagers.cpp @@ -137,11 +137,6 @@ LLVMPY_AddConstantMergePass(LLVMPassManagerRef PM) { LLVMAddConstantMergePass(PM); } -API_EXPORT(void) -LLVMPY_AddDeadInstructionEliminationPass(LLVMPassManagerRef PM) { - unwrap(PM)->add(llvm::createDeadInstEliminationPass()); -} - API_EXPORT(void) LLVMPY_AddDeadStoreEliminationPass(LLVMPassManagerRef PM) { unwrap(PM)->add(llvm::createDeadStoreEliminationPass()); @@ -173,7 +168,11 @@ LLVMPY_AddLazyValueInfoPass(LLVMPassManagerRef PM) { } API_EXPORT(void) LLVMPY_AddLintPass(LLVMPassManagerRef PM) { +#if LLVM_VERSION_MAJOR < 12 unwrap(PM)->add(llvm::createLintPass()); +#else + unwrap(PM)->add(llvm::createLintLegacyPassPass()); +#endif } API_EXPORT(void) LLVMPY_AddModuleDebugInfoPrinterPass(LLVMPassManagerRef PM) { diff --git a/ffi/targets.cpp b/ffi/targets.cpp index 2ee892023..42fe46f2c 100644 --- a/ffi/targets.cpp +++ b/ffi/targets.cpp @@ -204,7 +204,11 @@ LLVMPY_CreateTargetMachine(LLVMTargetRef T, const char *Triple, const char *CPU, rm = Reloc::DynamicNoPIC; TargetOptions opt; +#if LLVM_VERSION_MAJOR < 12 opt.PrintMachineCode = PrintMC; +#else + opt.MCOptions.ShowMCInst = PrintMC; +#endif opt.MCOptions.ABIName = ABIName; bool jit = JIT; diff --git a/ffi/value.cpp b/ffi/value.cpp index e8222ca5b..dba16409e 100644 --- a/ffi/value.cpp +++ b/ffi/value.cpp @@ -152,8 +152,13 @@ LLVMPY_ArgumentAttributesIter(LLVMValueRef A) { using namespace llvm; Argument* arg = unwrap(A); unsigned argno = arg->getArgNo(); - AttributeSet attrs = arg->getParent() - ->getAttributes().getParamAttributes(argno); + const AttributeSet attrs = arg->getParent()->getAttributes(). +#if LLVM_VERSION_MAJOR < 14 + getParamAttributes(argno) +#else + getParamAttrs(argno) +#endif + ; return wrap(new AttributeSetIterator(attrs.begin(), attrs.end())); } @@ -352,7 +357,11 @@ LLVMPY_GetElementType(LLVMTypeRef type) { llvm::Type* unwrapped = llvm::unwrap(type); llvm::PointerType* ty = llvm::dyn_cast(unwrapped); if (ty != nullptr) { +#if LLVM_VERSION_MAJOR < 14 return llvm::wrap(ty->getElementType()); +#else + return llvm::wrap(ty->getPointerElementType()); +#endif } return nullptr; } diff --git a/llvmlite/binding/passmanagers.py b/llvmlite/binding/passmanagers.py index f0420e534..fd062ade8 100644 --- a/llvmlite/binding/passmanagers.py +++ b/llvmlite/binding/passmanagers.py @@ -188,10 +188,6 @@ def add_break_critical_edges_pass(self): """See https://llvm.org/docs/Passes.html#break-crit-edges-break-critical-edges-in-cfg""" # noqa E501 ffi.lib.LLVMPY_AddBreakCriticalEdgesPass(self) - def add_dead_instruction_elimination_pass(self): - """See https://llvm.org/docs/Passes.html#die-dead-instruction-elimination""" # noqa E501 - ffi.lib.LLVMPY_AddDeadInstructionEliminationPass(self) - def add_dead_store_elimination_pass(self): """See https://llvm.org/docs/Passes.html#dse-dead-store-elimination""" # noqa E501 ffi.lib.LLVMPY_AddDeadStoreEliminationPass(self) @@ -491,8 +487,6 @@ def run(self, function): ffi.lib.LLVMPY_AddAlwaysInlinerPass.argtypes = [ffi.LLVMPassManagerRef, c_bool] ffi.lib.LLVMPY_AddArgPromotionPass.argtypes = [ffi.LLVMPassManagerRef, c_uint] ffi.lib.LLVMPY_AddBreakCriticalEdgesPass.argtypes = [ffi.LLVMPassManagerRef] -ffi.lib.LLVMPY_AddDeadInstructionEliminationPass.argtypes = [ - ffi.LLVMPassManagerRef] ffi.lib.LLVMPY_AddDeadStoreEliminationPass.argtypes = [ ffi.LLVMPassManagerRef] ffi.lib.LLVMPY_AddReversePostOrderFunctionAttrsPass.argtypes = [ diff --git a/llvmlite/tests/test_binding.py b/llvmlite/tests/test_binding.py index 501b46c17..35fd8968c 100644 --- a/llvmlite/tests/test_binding.py +++ b/llvmlite/tests/test_binding.py @@ -510,7 +510,7 @@ def test_set_option(self): def test_version(self): major, minor, patch = llvm.llvm_version_info # one of these can be valid - valid = [(11,)] + valid = [(11,), (12, ), (13, )] self.assertIn((major,), valid) self.assertIn(patch, range(10)) @@ -1414,7 +1414,6 @@ def test_populate(self): pm.add_always_inliner_pass() pm.add_arg_promotion_pass(42) pm.add_break_critical_edges_pass() - pm.add_dead_instruction_elimination_pass() pm.add_dead_store_elimination_pass() pm.add_post_order_function_attrs_pass() pm.add_aggressive_instruction_combining_pass() From 1355013f4b8bd6fb11b5e35ea800c55a3cba268b Mon Sep 17 00:00:00 2001 From: Andre Masella Date: Mon, 11 Apr 2022 09:48:38 -0400 Subject: [PATCH 6/6] Move formatter into common pipeline and document usage Add the clang-formatting command to the existing Azure pipeline and update the documentation to explain that `clang-format` should be run. --- azure-pipelines.yml | 11 +-- buildscripts/azure/azure-linux-macos.yml | 6 ++ conda-recipes/llvm13-lto-static.patch | 4 +- .../llvm14-remove-use-of-clonefile.patch | 29 +++++++ conda-recipes/llvmdev/bld.bat | 14 +--- conda-recipes/llvmdev/build.sh | 20 ++--- conda-recipes/llvmdev/meta.yaml | 19 ++--- conda-recipes/llvmdev/numba-3016.ll | 80 ------------------- docs/source/contributing.rst | 2 +- ffi/build.py | 4 +- ffi/targets.cpp | 4 + llvmlite/tests/test_binding.py | 2 +- 12 files changed, 59 insertions(+), 136 deletions(-) create mode 100644 conda-recipes/llvm14-remove-use-of-clonefile.patch delete mode 100644 conda-recipes/llvmdev/numba-3016.ll diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ad481334d..e208351df 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -38,6 +38,7 @@ jobs: PYTHON: '3.10' CONDA_ENV: cienv RUN_FLAKE8: yes + RUN_CLANG_FORMAT: yes # temporarily disabled # pypy: # PYTHON: pypy @@ -68,13 +69,3 @@ jobs: parameters: name: Windows vmImage: windows-2019 - -- job: check_formatting - pool: - vmImage: 'ubuntu-latest' - steps: - - script: | - set -e - sudo apt install -y clang-format - clang-format -n -Werror ffi/*.cpp ffi/*.h - displayName: Check C++ formatting diff --git a/buildscripts/azure/azure-linux-macos.yml b/buildscripts/azure/azure-linux-macos.yml index 65e195475..377e6f9fe 100644 --- a/buildscripts/azure/azure-linux-macos.yml +++ b/buildscripts/azure/azure-linux-macos.yml @@ -38,6 +38,12 @@ jobs: flake8 llvmlite displayName: 'Flake8' condition: eq(variables['RUN_FLAKE8'], 'yes') + - script: | + set -e + conda install -y clang-tools + clang-format -n -Werror ffi/*.cpp ffi/*.h + displayName: Check C++ formatting + condition: eq(variables['RUN_CLANG_FORMAT'], 'yes') - script: | set -e diff --git a/conda-recipes/llvm13-lto-static.patch b/conda-recipes/llvm13-lto-static.patch index b8a624250..8e63d2b80 100644 --- a/conda-recipes/llvm13-lto-static.patch +++ b/conda-recipes/llvm13-lto-static.patch @@ -1,5 +1,5 @@ -diff -ur llvm-13.0.0.src-orig/tools/lto/CMakeLists.txt llvm-13.0.0.src/tools/lto/CMakeLists.txt ---- llvm-13.0.0.src-orig/tools/lto/CMakeLists.txt 2021-09-24 12:18:10.000000000 -0400 +diff -ur llvm-13.0.0.src-orig/llvm/tools/lto/CMakeLists.txt llvm-13.0.0.src/tools/lto/CMakeLists.txt +--- llvm-13.0.0.src-orig/llvm/tools/lto/CMakeLists.txt 2021-09-24 12:18:10.000000000 -0400 +++ llvm-13.0.0.src/tools/lto/CMakeLists.txt 2022-03-31 17:07:07.000000000 -0400 @@ -25,7 +25,7 @@ set(LTO_LIBRARY_TYPE MODULE) diff --git a/conda-recipes/llvm14-remove-use-of-clonefile.patch b/conda-recipes/llvm14-remove-use-of-clonefile.patch new file mode 100644 index 000000000..ee9c9e09f --- /dev/null +++ b/conda-recipes/llvm14-remove-use-of-clonefile.patch @@ -0,0 +1,29 @@ +--- a/llvm/lib/Support/Unix/Path.inc 2022-01-08 15:15:44.000000000 +0000 ++++ b/llvm/lib/Support/Unix/Path.inc 2022-01-08 15:16:07.000000000 +0000 +@@ -1458,6 +1458,7 @@ + std::error_code copy_file(const Twine &From, const Twine &To) { + std::string FromS = From.str(); + std::string ToS = To.str(); ++ /* + #if __has_builtin(__builtin_available) + if (__builtin_available(macos 10.12, *)) { + // Optimistically try to use clonefile() and handle errors, rather than +@@ -1486,6 +1487,7 @@ + // cheaper. + } + #endif ++ */ + if (!copyfile(FromS.c_str(), ToS.c_str(), /*State=*/NULL, COPYFILE_DATA)) + return std::error_code(); + return std::error_code(errno, std::generic_category()); +--- a/llvm/unittests/Support/Path.cpp 2022-04-25 16:53:43.000000000 -0400 ++++ b/llvm/unittests/Support/Path.cpp 2022-04-25 16:54:32.000000000 -0400 +@@ -2275,7 +2275,7 @@ + // AIX and Solaris without root will mask off (i.e., lose) the sticky bit + // on files. + #if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && \ +- !defined(_AIX) && !(defined(__sun__) && defined(__svr4__)) ++ !defined(_AIX) && !(defined(__sun__) && defined(__svr4__)) && !defined(__APPLE__) + EXPECT_EQ(fs::setPermissions(TempPath, fs::sticky_bit), NoError); + EXPECT_TRUE(CheckPermissions(fs::sticky_bit)); + diff --git a/conda-recipes/llvmdev/bld.bat b/conda-recipes/llvmdev/bld.bat index 1ce228c80..264bd63d1 100644 --- a/conda-recipes/llvmdev/bld.bat +++ b/conda-recipes/llvmdev/bld.bat @@ -48,7 +48,7 @@ set "CMAKE_GENERATOR_TOOLSET[2]=v141" REM Reduce build times and package size by removing unused stuff REM BENCHMARKS (new for llvm8) don't build under Visual Studio 14 2015 set CMAKE_CUSTOM=-DLLVM_TARGETS_TO_BUILD="%LLVM_TARGETS_TO_BUILD%" ^ - -DLLVM_INCLUDE_TESTS=OFF ^ + -DLLVM_ENABLE_PROJECTS:STRING=lld ^ -DLLVM_INCLUDE_UTILS=ON ^ -DLLVM_INCLUDE_DOCS=OFF ^ -DLLVM_INCLUDE_EXAMPLES=OFF ^ @@ -67,7 +67,7 @@ for /l %%n in (0,1,%MAX_INDEX_CMAKE_GENERATOR%) do ( -DCMAKE_BUILD_TYPE="%BUILD_CONFIG%" ^ -DCMAKE_PREFIX_PATH="%LIBRARY_PREFIX%" ^ -DCMAKE_INSTALL_PREFIX:PATH="%LIBRARY_PREFIX%" ^ - %CMAKE_CUSTOM% "%SRC_DIR%" + %CMAKE_CUSTOM% "%SRC_DIR%\llvm" if not errorlevel 1 goto configuration_successful del CMakeCache.txt ) @@ -85,13 +85,3 @@ if errorlevel 1 exit 1 REM === Install step === cmake --build . --config "%BUILD_CONFIG%" --target install if errorlevel 1 exit 1 - -REM From: https://github.com/conda-forge/llvmdev-feedstock/pull/53 -"%BUILD_CONFIG%\bin\opt" -S -vector-library=SVML -mcpu=haswell -O3 "%RECIPE_DIR%\numba-3016.ll" | "%BUILD_CONFIG%\bin\FileCheck" "%RECIPE_DIR%\numba-3016.ll" -if errorlevel 1 exit 1 - -REM This is technically how to run the suite, but it will only run in an -REM enhanced unix-like shell which has functions like `grep` available. -REM cd ..\test -REM "%PYTHON%" "..\build\%BUILD_CONFIG%\bin\llvm-lit.py" -vv Transforms ExecutionEngine Analysis CodeGen/X86 -REM if errorlevel 1 exit 1 diff --git a/conda-recipes/llvmdev/build.sh b/conda-recipes/llvmdev/build.sh index d187f6482..bdaf29769 100644 --- a/conda-recipes/llvmdev/build.sh +++ b/conda-recipes/llvmdev/build.sh @@ -19,6 +19,7 @@ fi declare -a _cmake_config _cmake_config+=(-DCMAKE_INSTALL_PREFIX:PATH=${PREFIX}) _cmake_config+=(-DCMAKE_BUILD_TYPE:STRING=Release) +_cmake_config+=(-DLLVM_ENABLE_PROJECTS:STRING="lld") # The bootstrap clang I use was built with a static libLLVMObject.a and I trying to get the same here # _cmake_config+=(-DBUILD_SHARED_LIBS:BOOL=ON) _cmake_config+=(-DLLVM_ENABLE_ASSERTIONS:BOOL=ON) @@ -27,6 +28,7 @@ _cmake_config+=(-DLINK_POLLY_INTO_TOOLS:BOOL=ON) _cmake_config+=(-DLLVM_ENABLE_LIBXML2:BOOL=OFF) # Urgh, llvm *really* wants to link to ncurses / terminfo and we *really* do not want it to. _cmake_config+=(-DHAVE_TERMINFO_CURSES=OFF) +_cmake_config+=(-DLLVM_ENABLE_TERMINFO=OFF) # Sometimes these are reported as unused. Whatever. _cmake_config+=(-DHAVE_TERMINFO_NCURSES=OFF) _cmake_config+=(-DHAVE_TERMINFO_NCURSESW=OFF) @@ -43,7 +45,6 @@ _cmake_config+=(-DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF) # doesn't build without the # TODO :: It would be nice if we had a cross-ecosystem 'BUILD_TIME_LIMITED' env var we could use to # disable these unnecessary but useful things. if [[ ${CONDA_FORGE} == yes ]]; then - _cmake_config+=(-DLLVM_INCLUDE_TESTS=OFF) _cmake_config+=(-DLLVM_INCLUDE_DOCS=OFF) _cmake_config+=(-DLLVM_INCLUDE_EXAMPLES=OFF) fi @@ -77,7 +78,7 @@ cd build cmake -G'Unix Makefiles' \ "${_cmake_config[@]}" \ - .. + ../llvm ARCH=`uname -m` if [ $ARCH == 'armv7l' ]; then # RPi need thread count throttling @@ -86,18 +87,7 @@ else make -j${CPU_COUNT} VERBOSE=1 fi +make check-llvm-unit || exit $? + # From: https://github.com/conda-forge/llvmdev-feedstock/pull/53 make install || exit $? - -# SVML tests on x86_64 arch only -if [[ $ARCH == 'x86_64' ]]; then - bin/opt -S -vector-library=SVML -mcpu=haswell -O3 $RECIPE_DIR/numba-3016.ll | bin/FileCheck $RECIPE_DIR/numba-3016.ll || exit $? -fi - -# run the tests, skip some on linux-32 -cd ../test -if [[ $ARCH == 'i686' ]]; then - ../build/bin/llvm-lit -vv Transforms Analysis CodeGen/X86 -else - ../build/bin/llvm-lit -vv Transforms ExecutionEngine Analysis CodeGen/X86 -fi diff --git a/conda-recipes/llvmdev/meta.yaml b/conda-recipes/llvmdev/meta.yaml index 9c9376bb0..3ffb8ac77 100644 --- a/conda-recipes/llvmdev/meta.yaml +++ b/conda-recipes/llvmdev/meta.yaml @@ -1,7 +1,6 @@ -{% set shortversion = "13.0" %} -{% set version = "13.0.1" %} -{% set sha256_llvm = "ec6b80d82c384acad2dc192903a6cf2cdbaffb889b84bfb98da9d71e630fc834" %} -{% set sha256_lld = "666af745e8bf7b680533b4d18b7a31dc7cab575b1e6e4d261922bbafd9644cfb" %} +{% set shortversion = "14.0" %} +{% set version = "14.0.1" %} +{% set sha256_llvm = "1a3c2e57916c5a70153aaf0a0e6f1230d6368b9e0f4d04dcb9e039a31b1cd4e6" %} {% set build_number = "5" %} package: @@ -9,16 +8,12 @@ package: version: {{ version }} source: - - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ version }}/llvm-{{ version }}.src.tar.xz + - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ version }}/llvm-project-{{ version }}.src.tar.xz fn: llvm-{{ version }}.src.tar.xz sha256: {{ sha256_llvm }} patches: - ../llvm13-lto-static.patch - - - url: https://github.com/llvm/llvm-project/releases/download/llvmorg-{{ version }}/lld-{{ version }}.src.tar.xz - fn: lld-{{ version }}.src.tar.xz - sha256: {{ sha256_lld }} - folder: tools/lld + - ../llvm14-remove-use-of-clonefile.patch build: number: {{ build_number }} @@ -51,8 +46,6 @@ requirements: - python # [not (armv6l or armv7l or aarch64 or win)] test: - files: - - numba-3016.ll commands: - $PREFIX/bin/llvm-config --libs # [not win] - $PREFIX/bin/llc -version # [not win] @@ -73,5 +66,5 @@ about: home: http://llvm.org/ dev_url: https://github.com/llvm-mirror/llvm license: NCSA - license_file: LICENSE.TXT + license_file: llvm/LICENSE.TXT summary: Development headers and libraries for LLVM diff --git a/conda-recipes/llvmdev/numba-3016.ll b/conda-recipes/llvmdev/numba-3016.ll deleted file mode 100644 index 1a9b3ecf8..000000000 --- a/conda-recipes/llvmdev/numba-3016.ll +++ /dev/null @@ -1,80 +0,0 @@ -; Regression test for llvmdev-feedstock#52 and numba#3016 - -; Generated from C code: int a[1<<10],b[1<<10]; void foo() { int i=0; for(i=0; i<1<<10; i++) { b[i]=sin(a[i]); }} -; compiled: -fvectorize -fveclib=SVML -O -S -mavx -mllvm -disable-llvm-optzns -emit-llvm - -; RUN: opt -vector-library=SVML -mcpu=haswell -O3 -S < %s | FileCheck %s -; CHECK: call {{.*}}__svml_sin4_ha( -; CHECK-NOT: call {{.*}}__svml_sin4( -; CHECK-NOT: call {{.*}}__svml_sin8 - -source_filename = "svml-3016.c" -target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-pc-linux-gnu" - -@a = common dso_local global [1024 x i32] zeroinitializer, align 16 -@b = common dso_local global [1024 x i32] zeroinitializer, align 16 - -; Function Attrs: nounwind uwtable -define dso_local void @foo() #0 { - %1 = alloca i32, align 4 - %2 = bitcast i32* %1 to i8* - call void @llvm.lifetime.start.p0i8(i64 4, i8* %2) #3 - store i32 0, i32* %1, align 4, !tbaa !2 - store i32 0, i32* %1, align 4, !tbaa !2 - br label %3 - -;