![]() PHI nodes must be the first thing in a basic block, all grouped together.Īll basic blocks should only end with terminator insts, not contain them. PHI nodes must have an entry for each predecessor, with no extras. Only phi nodes can be self referential: %x = add i32 %x, %x is invalid. It is illegal to put a label into any other type (like a structure) Verify that shifts and logicals only happen onĪll of the constants in a switch statement are of the correct type. Verify that arithmetic and other things are only performed onįirst-class types. Verify that the indices of mem access instructions match other operands. Their output before performing optimizing transformations.īoth of a binary operator’s parameters are of the same type. All language front-ends are therefore encouraged to verify ![]() Note that llvm-as verifies its input beforeĮmitting bitcode, and also that malformed bitcode is likely to make This is useful to run after an optimization Source pub fn add_instruction_simplify_pass(&self) They are marked as eligible for tail call elimination (by the code generator). If it can prove that callees do not access theier caller stack frame, TRE’d if all other return instructions in the function return the exact same value. Returns something else (like constant 0), and can still be TRE’d. It is possible, though unlikely, that the return The result returned by the call, or if the function returns a run-time constant TRE is performed if the function returns void, if the return returns Recursive by an associative expression to use an accumulator variable, thusĬompiling the typical naive factorial or fib implementation into efficient code. This pass transforms functions that are prevented from being tail Moving any really useful instructions (only dead ones). Transformation from taking place, though currently the analysis cannot support Trivial instructions between the call and return do not prevent the This pass also implements the following extensions to the basic algorithm: This file transforms calls of the current function (self recursion) followedīy a return instruction with a branch to the entry of the function, creatingĪ loop. source pub fn add_loop_deletion_pass(&self) ![]() To construct the appropriate SSA form for the variable. If these conditions are true, we can promote the loadsĪnd stores in the loop of the pointer to use a temporaryĪlloca’d variable. The pointer stored through is loop invariant. ![]() Store to happen AFTER the loop instead of inside of Instruction inside of the loop, we try to move the It or sink it like any other instruction. Loop never aliases anything stored to, we can hoist If we can determine that a load or call inside of a Moving loop invariant loads and calls out of loops. This pass uses alias analysis for two purposes: Registers, thus hoisting and sinking “invariant” loads Must-aliased memory locations in the loop to live in It does this by either hoistingĬode into the preheader block, or by sinking code to This pass performs loop invariant code motion,Īttempting to remove as much code from the body ofĪ loop as possible. source pub fn add_jump_threading_pass(&self) Pass and LLVM’s knowledge of library calls on different targets. Whether or not libraryĬalls are simplified is controlled by the -functionattrs The main() function can be transformed into simply return 3. For example, a call exit(3) that occurs within This pass can also simplify calls to specific well-known function calls Multiplies with a constant power-of-two argument are transformed into shifts. Shifts are performed first, then ors, then ands, then xors.Ĭompare instructions are converted from, ≤, or ≥ to = or ≠ if possible.Īll cmp instructions on boolean values are replaced with logical operations.Īdd X, X is represented as mul X, 2 ⇒ shl X, 1 If a binary operator has a constant operand, it is moved to theīitwise operators with constant operands are always grouped so that This pass guarantees that the following canonicalizations are performed This is a simple worklist driven algorithm.
0 Comments
Leave a Reply. |