From: Gordon Henriksen Date: Thu, 8 May 2008 17:46:35 +0000 (+0000) Subject: Improve pass documentation and comments. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=a8a118b68fa3ca1632e7280cd6994aa0f8f1eec1 Improve pass documentation and comments. Patch by Matthijs Kooijman! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50861 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/Passes.html b/docs/Passes.html index a01b754d70d..21b03f53997 100644 --- a/docs/Passes.html +++ b/docs/Passes.html @@ -116,7 +116,7 @@ perl -e '$/ = undef; for (split(/\n/, <>)) { s:^ *///? ?::; print "

\n" if ! -argpromotionPromote 'by reference' arguments to scalars -block-placementProfile Guided Basic Block Placement -break-crit-edgesBreak critical edges in CFG --ceeCorrelated Expression Elimination +-codegenpreparePrepare a function for code generation -condpropConditional Propagation -constmergeMerge Duplicate Global Constants -constpropSimple constant propagation @@ -142,8 +142,10 @@ perl -e '$/ = undef; for (split(/\n/, <>)) { s:^ *///? ?::; print "

\n" if ! -internalizeInternalize Global Symbols -ipconstpropInterprocedural constant propagation -ipsccpInterprocedural Sparse Conditional Constant Propagation +-jump-threadingThread control through conditional blocks -lcssaLoop-Closed SSA Form Pass -licmLoop Invariant Code Motion +-loop-deletionDead Loop Deletion Pass -loop-extractExtract loops into new functions -loop-extract-singleExtract at most one loop into a new function -loop-index-splitIndex Split Loops @@ -152,14 +154,12 @@ perl -e '$/ = undef; for (split(/\n/, <>)) { s:^ *///? ?::; print "

\n" if ! -loop-unrollUnroll loops -loop-unswitchUnswitch loops -loopsimplifyCanonicalize natural loops --lower-packedlowers packed operations to operations on smaller packed datatypes -lowerallocsLower allocations from instructions to calls --lowergcLower GC intrinsics, for GCless code generators -lowerinvokeLower invoke and unwind, for unwindless code generators --lowerselectLower select instructions to branches -lowersetjmpLower Set Jump -lowerswitchLower SwitchInst's to branches -mem2regPromote Memory to Register +-memcpyoptOptimize use of memcpy and friends -mergereturnUnify function exit nodes -predsimplifyPredicate Simplifier -prune-ehRemove unused exception handling info @@ -171,6 +171,8 @@ perl -e '$/ = undef; for (split(/\n/, <>)) { s:^ *///? ?::; print "

\n" if ! -simplify-libcallsSimplify well-known library calls -simplifycfgSimplify the CFG -stripStrip all symbols from a module +-strip-dead-prototypesRemove unused function declarations +-sretpromotionPromote sret arguments -tailcallelimTail Call Elimination -tailduplicateTail Duplication @@ -739,27 +741,12 @@ perl -e '$/ = undef; for (split(/\n/, <>)) { s:^ *///? ?::; print "

\n" if !

- Correlated Expression Elimination + Prepare a function for code generation
-

Correlated Expression Elimination propagates information from conditional - branches to blocks dominated by destinations of the branch. It propagates - information from the condition check itself into the body of the branch, - allowing transformations like these for example:

- -
-if (i == 7)
-  ... 4*i;  // constant propagation
-
-M = i+1; N = j+1;
-if (i == j)
-  X = M-N;  // = M-M == 0;
-
- -

This is called Correlated Expression Elimination because we eliminate or - simplify expressions that are correlated with the direction of a branch. In - this way we use static information to give us some information about the - dynamic value of a variable.

+ This pass munges the code in the input function to better prepare it for + SelectionDAG-based code generation. This works around limitations in it's + basic-block-at-a-time approach. It should eventually be removed.
@@ -1181,6 +1168,35 @@ if (i == j)

+ +
+ Thread control through conditional blocks +
+
+

+ Jump threading tries to find distinct threads of control flow running through + a basic block. This pass looks at blocks that have multiple predecessors and + multiple successors. If one or more of the predecessors of the block can be + proven to always cause a jump to one of the successors, we forward the edge + from the predecessor to the successor by duplicating the contents of this + block. +

+

+ An example of when this can occur is code like this: +

+ +
if () { ...
+  X = 4;
+}
+if (X < 3) {
+ +

+ In this case, the unconditional branch at the end of the first if can be + revectored to the false side of the second if. +

+
+
Loop-Closed SSA Form Pass @@ -1246,6 +1262,18 @@ if (i == j) variable.
+ +
+ Dead Loop Deletion Pass +
+
+

+ This file implements the Dead Loop Deletion Pass. This pass is responsible + for eliminating loops with non-infinite computable trip counts that have no + side effects or volatile instructions, and do not contribute to the + computation of the function's return value. +

+
@@ -1388,17 +1416,6 @@ if (i == j)

- -
- lowers packed operations to operations on smaller packed datatypes -
-
-

- Lowers operations on vector datatypes into operations on more primitive vector - datatypes, and finally to scalar operations. -

-
-
Lower allocations from instructions to calls @@ -1415,29 +1432,6 @@ if (i == j)

- -
- Lower GC intrinsics, for GCless code generators -
-
-

- This file implements lowering for the llvm.gc* intrinsics for targets - that do not natively support them (which includes the C backend). Note that - the code generated is not as efficient as it would be for targets that - natively support the GC intrinsics, but it is useful for getting new targets - up-and-running quickly. -

- -

- This pass implements the code transformation described in this paper: -

- -

- "Accurate Garbage Collection in an Uncooperative Environment" - Fergus Henderson, ISMM, 2002 -

-
-
Lower invoke and unwind, for unwindless code generators @@ -1479,25 +1473,6 @@ if (i == j)

- -
- Lower select instructions to branches -
-
-

- Lowers select instructions into conditional branches for targets that do not - have conditional moves or that have not implemented the select instruction - yet. -

- -

- Note that this pass could be improved. In particular it turns every select - instruction into a new conditional branch, even though some common cases have - select instructions on the same predicate next to each other. It would be - better to use the same branch for the whole group of selects. -

-
-
Lower Set Jump @@ -1555,6 +1530,17 @@ if (i == j)

+ +
+ Optimize use of memcpy and friend +
+
+

+ This pass performs various transformations related to eliminating memcpy + calls, or transforming sets of stores into memset's. +

+
+
Unify function exit nodes @@ -1751,6 +1737,42 @@ if (i == j)

+ +
+ Remove unused function declarations +
+
+

+ This pass loops over all of the functions in the input module, looking for + dead declarations and removes them. Dead declarations are declarations of + functions for which no implementation is available (i.e., declarations for + unused library functions). +

+
+ + +
+ Promote sret arguments +
+
+

+ This pass finds functions that return a struct (using a pointer to the struct + as the first argument of the function, marked with the 'sret' attribute) and + replaces them with a new function that simply returns each of the elements of + that struct (using multiple return values). +

+ +

+ This pass works under a number of conditions: +

+ + +
+
Tail Call Elimination diff --git a/lib/Transforms/IPO/StripDeadPrototypes.cpp b/lib/Transforms/IPO/StripDeadPrototypes.cpp index fd22fdb37f8..ca8a436844a 100644 --- a/lib/Transforms/IPO/StripDeadPrototypes.cpp +++ b/lib/Transforms/IPO/StripDeadPrototypes.cpp @@ -1,4 +1,4 @@ -//===-- StripDeadPrototypes.cpp - Removed unused function declarations ----===// +//===-- StripDeadPrototypes.cpp - Remove unused function declarations ----===// // // The LLVM Compiler Infrastructure // @@ -8,7 +8,9 @@ //===----------------------------------------------------------------------===// // // This pass loops over all of the functions in the input module, looking for -// dead declarations and removes them. +// dead declarations and removes them. Dead declarations are declarations of +// functions for which no implementation is available (i.e., declarations for +// unused library functions). // //===----------------------------------------------------------------------===// diff --git a/lib/Transforms/IPO/StructRetPromotion.cpp b/lib/Transforms/IPO/StructRetPromotion.cpp index 77a35b42875..83ceb0dd0eb 100644 --- a/lib/Transforms/IPO/StructRetPromotion.cpp +++ b/lib/Transforms/IPO/StructRetPromotion.cpp @@ -1,4 +1,4 @@ -//===-- StructRetPromotion.cpp - Promote sret arguments -000000------------===// +//===-- StructRetPromotion.cpp - Promote sret arguments ------------------===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,16 @@ // //===----------------------------------------------------------------------===// // -// TODO : Describe this pass. +// This pass finds functions that return a struct (using a pointer to the struct +// as the first argument of the function, marked with the 'sret' attribute) and +// replaces them with a new function that simply returns each of the elements of +// that struct (using multiple return values). +// +// This pass works under a number of conditions: +// 1. The returned struct must not contain other structs +// 2. The returned struct must only be used to load values from +// 3. The placeholder struct passed in is the result of an alloca +// //===----------------------------------------------------------------------===// #define DEBUG_TYPE "sretpromotion" diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp index 87c9374b2ff..bc19114fa2d 100644 --- a/lib/Transforms/Scalar/CodeGenPrepare.cpp +++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp @@ -8,8 +8,8 @@ //===----------------------------------------------------------------------===// // // This pass munges the code in the input function to better prepare it for -// SelectionDAG-based code generation. This works around limitations in it's -// basic-block-at-a-time approach. It should eventually be removed. +// SelectionDAG-based code generation. This works around limitations in it's +// basic-block-at-a-time approach. It should eventually be removed. // //===----------------------------------------------------------------------===// diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp index 991b11110b4..964fe90c467 100644 --- a/lib/Transforms/Scalar/JumpThreading.cpp +++ b/lib/Transforms/Scalar/JumpThreading.cpp @@ -9,6 +9,23 @@ // // This file implements the Jump Threading pass. // +// Jump threading tries to find distinct threads of control flow running through +// a basic block. This pass looks at blocks that have multiple predecessors and +// multiple successors. If one or more of the predecessors of the block can be +// proven to always cause a jump to one of the successors, we forward the edge +// from the predecessor to the successor by duplicating the contents of this +// block. +// +// An example of when this can occur is code like this: +// +// if () { ... +// X = 4; +// } +// if (X < 3) { +// +// In this case, the unconditional branch at the end of the first if can be +// revectored to the false side of the second if. +// //===----------------------------------------------------------------------===// #define DEBUG_TYPE "jump-threading" @@ -33,22 +50,6 @@ Threshold("jump-threading-threshold", cl::init(6), cl::Hidden); namespace { - /// This pass performs 'jump threading', which looks at blocks that have - /// multiple predecessors and multiple successors. If one or more of the - /// predecessors of the block can be proven to always jump to one of the - /// successors, we forward the edge from the predecessor to the successor by - /// duplicating the contents of this block. - /// - /// An example of when this can occur is code like this: - /// - /// if () { ... - /// X = 4; - /// } - /// if (X < 3) { - /// - /// In this case, the unconditional branch at the end of the first if can be - /// revectored to the false side of the second if. - /// class VISIBILITY_HIDDEN JumpThreading : public FunctionPass { public: static char ID; // Pass identification diff --git a/lib/Transforms/Scalar/LoopDeletion.cpp b/lib/Transforms/Scalar/LoopDeletion.cpp index 1ea2f6ac9ea..02a5ca98d97 100644 --- a/lib/Transforms/Scalar/LoopDeletion.cpp +++ b/lib/Transforms/Scalar/LoopDeletion.cpp @@ -7,10 +7,10 @@ // //===----------------------------------------------------------------------===// // -// This file implements the Dead Loop Elimination Pass. This pass is -// responsible for eliminating loops with non-infinite computable trip counts -// that have no side effects or volatile instructions, and do not contribute -// to the computation of the function's return value. +// This file implements the Dead Loop Deletion Pass. This pass is responsible +// for eliminating loops with non-infinite computable trip counts that have no +// side effects or volatile instructions, and do not contribute to the +// computation of the function's return value. // //===----------------------------------------------------------------------===//