diff options
| author | Patrick Walton <[email protected]> | 2011-05-06 18:56:11 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-05-09 11:44:47 -0700 |
| commit | bc879a4e1e72295ad46a482f7abadc41005340e3 (patch) | |
| tree | 3ff0f6136012e2953bc9993bb60d822ab9a73e3f | |
| parent | Register new snapshots. (diff) | |
| download | rust-bc879a4e1e72295ad46a482f7abadc41005340e3.tar.xz rust-bc879a4e1e72295ad46a482f7abadc41005340e3.zip | |
rustc: Replace our homebrew list of passes with the standard function and module passes, along with the TargetData passes.
| -rw-r--r-- | src/comp/back/Link.rs | 66 | ||||
| -rw-r--r-- | src/comp/lib/llvm.rs | 6 |
2 files changed, 21 insertions, 51 deletions
diff --git a/src/comp/back/Link.rs b/src/comp/back/Link.rs index 89ed0d37..15be6dc8 100644 --- a/src/comp/back/Link.rs +++ b/src/comp/back/Link.rs @@ -10,6 +10,7 @@ import lib.llvm.mk_pass_manager; import lib.llvm.mk_target_data; import lib.llvm.mk_type_names; import lib.llvm.False; +import lib.llvm.True; tag output_type { output_type_none; @@ -79,6 +80,9 @@ mod Write { auto pm = mk_pass_manager(); auto opts = sess.get_opts(); + auto td = mk_target_data(x86.get_data_layout()); + llvm.LLVMAddTargetData(td.lltd, pm.llpm); + // TODO: run the linter here also, once there are llvm-c bindings for // it. @@ -109,58 +113,20 @@ mod Write { // tool? if (opts.optimize) { auto fpm = mk_pass_manager(); - - // createStandardFunctionPasses - llvm.LLVMAddTypeBasedAliasAnalysisPass(fpm.llpm); - llvm.LLVMAddBasicAliasAnalysisPass(fpm.llpm); - llvm.LLVMAddCFGSimplificationPass(fpm.llpm); - llvm.LLVMAddScalarReplAggregatesPass(fpm.llpm); - llvm.LLVMAddEarlyCSEPass(fpm.llpm); - + llvm.LLVMAddTargetData(td.lltd, fpm.llpm); + llvm.LLVMAddStandardFunctionPasses(fpm.llpm, 2u); llvm.LLVMRunPassManager(fpm.llpm, llmod); - // createStandardModulePasses - llvm.LLVMAddTypeBasedAliasAnalysisPass(pm.llpm); - llvm.LLVMAddBasicAliasAnalysisPass(pm.llpm); - llvm.LLVMAddGlobalOptimizerPass(pm.llpm); - llvm.LLVMAddIPSCCPPass(pm.llpm); - llvm.LLVMAddDeadArgEliminationPass(pm.llpm); - llvm.LLVMAddInstructionCombiningPass(pm.llpm); - llvm.LLVMAddCFGSimplificationPass(pm.llpm); - llvm.LLVMAddPruneEHPass(pm.llpm); - llvm.LLVMAddFunctionInliningPass(pm.llpm); - llvm.LLVMAddFunctionAttrsPass(pm.llpm); - llvm.LLVMAddScalarReplAggregatesPassSSA(pm.llpm); - llvm.LLVMAddEarlyCSEPass(pm.llpm); - llvm.LLVMAddSimplifyLibCallsPass(pm.llpm); - llvm.LLVMAddJumpThreadingPass(pm.llpm); - llvm.LLVMAddCorrelatedValuePropagationPass(pm.llpm); - llvm.LLVMAddCFGSimplificationPass(pm.llpm); - llvm.LLVMAddInstructionCombiningPass(pm.llpm); - llvm.LLVMAddTailCallEliminationPass(pm.llpm); - llvm.LLVMAddCFGSimplificationPass(pm.llpm); - llvm.LLVMAddReassociatePass(pm.llpm); - llvm.LLVMAddLoopRotatePass(pm.llpm); - llvm.LLVMAddLICMPass(pm.llpm); - llvm.LLVMAddLoopUnswitchPass(pm.llpm); - llvm.LLVMAddInstructionCombiningPass(pm.llpm); - llvm.LLVMAddIndVarSimplifyPass(pm.llpm); - llvm.LLVMAddLoopIdiomPass(pm.llpm); - llvm.LLVMAddLoopDeletionPass(pm.llpm); - llvm.LLVMAddLoopUnrollPass(pm.llpm); - llvm.LLVMAddInstructionCombiningPass(pm.llpm); - llvm.LLVMAddGVNPass(pm.llpm); - llvm.LLVMAddMemCpyOptPass(pm.llpm); - llvm.LLVMAddSCCPPass(pm.llpm); - llvm.LLVMAddInstructionCombiningPass(pm.llpm); - llvm.LLVMAddJumpThreadingPass(pm.llpm); - llvm.LLVMAddCorrelatedValuePropagationPass(pm.llpm); - llvm.LLVMAddDeadStoreEliminationPass(pm.llpm); - llvm.LLVMAddAggressiveDCEPass(pm.llpm); - llvm.LLVMAddCFGSimplificationPass(pm.llpm); - llvm.LLVMAddStripDeadPrototypesPass(pm.llpm); - llvm.LLVMAddDeadTypeEliminationPass(pm.llpm); - llvm.LLVMAddConstantMergePass(pm.llpm); + // TODO: On -O3, use 275 instead of 225 for the inlining + // threshold. + llvm.LLVMAddStandardModulePasses(pm.llpm, + 2u, // optimization level + False, // optimize for size + True, // unit-at-a-time + True, // unroll loops + True, // simplify lib calls + True, // have exceptions + 225u); // inlining threshold } if (opts.verify) { diff --git a/src/comp/lib/llvm.rs b/src/comp/lib/llvm.rs index 80b216e6..c4114261 100644 --- a/src/comp/lib/llvm.rs +++ b/src/comp/lib/llvm.rs @@ -748,6 +748,9 @@ native mod llvm = llvm_lib { /** Creates target data from a target layout string. */ fn LLVMCreateTargetData(sbuf StringRep) -> TargetDataRef; + /** Adds the target data to the given pass manager. The pass manager + references the target data only weakly. */ + fn LLVMAddTargetData(TargetDataRef TD, PassManagerRef PM); /** Returns the size of a type. FIXME: rv is actually a ULongLong! */ fn LLVMStoreSizeOfType(TargetDataRef TD, TypeRef Ty) -> uint; /** Returns the alignment of a type. */ @@ -802,7 +805,8 @@ native mod llvm = llvm_lib { fn LLVMAddTypeBasedAliasAnalysisPass(PassManagerRef PM); fn LLVMAddBasicAliasAnalysisPass(PassManagerRef PM); - // FIXME: Native stubs don't allow this many arguments yet. + fn LLVMAddStandardFunctionPasses(PassManagerRef PM, + uint OptimizationLevel); fn LLVMAddStandardModulePasses(PassManagerRef PM, uint OptimizationLevel, Bool OptimizeSize, |