Skip to content

Commit bec0881

Browse files
authored
Merge pull request #23 from CodaFi/dont-pass-me-by
Add the majority of the remaining optimizer passes
2 parents 0c6b336 + 5eb9f65 commit bec0881

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

Sources/LLVM/PassManager.swift

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,46 @@ public enum FunctionPass {
124124
case basicAliasAnalysis
125125
/// Runs the LLVM IR Verifier to sanity check the results of passes.
126126
case verifier
127+
/// A pass to inline and remove functions marked as "always_inline".
128+
case alwaysInliner
129+
/// This pass promotes "by reference" arguments to be passed by value if the
130+
/// number of elements passed is less than or equal to 3.
131+
case argumentPromotion
132+
/// This function returns a new pass that merges duplicate global constants
133+
/// together into a single constant that is shared. This is useful because
134+
/// some passes (ie TraceValues) insert a lot of string constants into the
135+
/// program, regardless of whether or not they duplicate an existing string.
136+
case constantMerge
137+
/// This pass removes arguments from functions which are not used by the body
138+
/// of the function.
139+
case deadArgElimination
140+
/// This pass walks SCCs of the call graph in RPO to deduce and propagate
141+
/// function attributes. Currently it only handles synthesizing `norecurse`
142+
/// attributes.
143+
case functionAttrs
144+
/// Uses a heuristic to inline direct function calls to small functions.
145+
case functionInlining
146+
/// This transform is designed to eliminate unreachable internal globals
147+
/// (functions or global variables)
148+
case globalDCE
149+
/// This function returns a new pass that optimizes non-address taken internal
150+
/// globals.
151+
case globalOptimizer
152+
/// This pass propagates constants from call sites into the bodies of
153+
/// functions.
154+
case ipConstantPropagation
155+
/// This pass propagates constants from call sites into the bodies of
156+
/// functions, and keeps track of whether basic blocks are executable in the
157+
/// process.
158+
case ipscc
159+
/// Return a new pass object which transforms invoke instructions into calls,
160+
/// if the callee can *not* unwind the stack.
161+
case pruneEH
162+
/// This pass removes any function declarations (prototypes) that are not used.
163+
case stripDeadPrototypes
164+
/// These functions removes symbols from functions and modules without
165+
/// touching symbols for debugging information.
166+
case stripSymbols
127167
}
128168

129169
/// A `FunctionPassManager` is an object that collects a sequence of passes
@@ -170,6 +210,22 @@ public class FunctionPassManager {
170210
.typeBasedAliasAnalysis: LLVMAddTypeBasedAliasAnalysisPass,
171211
.scopedNoAliasAA: LLVMAddScopedNoAliasAAPass,
172212
.basicAliasAnalysis: LLVMAddBasicAliasAnalysisPass,
213+
.alwaysInliner: LLVMAddAlwaysInlinerPass,
214+
.argumentPromotion: LLVMAddArgumentPromotionPass,
215+
.constantMerge: LLVMAddConstantMergePass,
216+
.deadArgElimination: LLVMAddDeadArgEliminationPass,
217+
.functionAttrs: LLVMAddFunctionAttrsPass,
218+
.functionInlining: LLVMAddFunctionInliningPass,
219+
.globalDCE: LLVMAddGlobalDCEPass,
220+
.globalOptimizer: LLVMAddGlobalOptimizerPass,
221+
.ipConstantPropagation: LLVMAddIPConstantPropagationPass,
222+
.ipscc: LLVMAddIPSCCPPass,
223+
.pruneEH: LLVMAddPruneEHPass,
224+
.stripDeadPrototypes: LLVMAddStripDeadPrototypesPass,
225+
.stripSymbols: LLVMAddStripSymbolsPass,
226+
227+
// .internalize: LLVMAddInternalizePass,
228+
// .sroaWithThreshhold: LLVMAddScalarReplAggregatesPassWithThreshold,
173229
]
174230

175231
/// Creates a `FunctionPassManager` bound to the given module's IR.

0 commit comments

Comments
 (0)