From a8a118b68fa3ca1632e7280cd6994aa0f8f1eec1 Mon Sep 17 00:00:00 2001
From: Gordon Henriksen
Date: Thu, 8 May 2008 17:46:35 +0000
Subject: [PATCH] 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
---
docs/Passes.html | 174 ++++++++++++---------
lib/Transforms/IPO/StripDeadPrototypes.cpp | 6 +-
lib/Transforms/IPO/StructRetPromotion.cpp | 13 +-
lib/Transforms/Scalar/CodeGenPrepare.cpp | 4 +-
lib/Transforms/Scalar/JumpThreading.cpp | 33 ++--
lib/Transforms/Scalar/LoopDeletion.cpp | 8 +-
6 files changed, 136 insertions(+), 102 deletions(-)
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 !
-argpromotion | Promote 'by reference' arguments to scalars |
-block-placement | Profile Guided Basic Block Placement |
-break-crit-edges | Break critical edges in CFG |
--cee | Correlated Expression Elimination |
+-codegenprepare | Prepare a function for code generation |
-condprop | Conditional Propagation |
-constmerge | Merge Duplicate Global Constants |
-constprop | Simple constant propagation |
@@ -142,8 +142,10 @@ perl -e '$/ = undef; for (split(/\n/, <>)) { s:^ *///? ?::; print " \n" if !
-internalize | Internalize Global Symbols |
-ipconstprop | Interprocedural constant propagation |
-ipsccp | Interprocedural Sparse Conditional Constant Propagation |
+-jump-threading | Thread control through conditional blocks |
-lcssa | Loop-Closed SSA Form Pass |
-licm | Loop Invariant Code Motion |
+-loop-deletion | Dead Loop Deletion Pass |
-loop-extract | Extract loops into new functions |
-loop-extract-single | Extract at most one loop into a new function |
-loop-index-split | Index Split Loops |
@@ -152,14 +154,12 @@ perl -e '$/ = undef; for (split(/\n/, <>)) { s:^ *///? ?::; print " \n" if !
-loop-unroll | Unroll loops |
-loop-unswitch | Unswitch loops |
-loopsimplify | Canonicalize natural loops |
--lower-packed | lowers packed operations to operations on smaller packed datatypes |
-lowerallocs | Lower allocations from instructions to calls |
--lowergc | Lower GC intrinsics, for GCless code generators |
-lowerinvoke | Lower invoke and unwind, for unwindless code generators |
--lowerselect | Lower select instructions to branches |
-lowersetjmp | Lower Set Jump |
-lowerswitch | Lower SwitchInst's to branches |
-mem2reg | Promote Memory to Register |
+-memcpyopt | Optimize use of memcpy and friends |
-mergereturn | Unify function exit nodes |
-predsimplify | Predicate Simplifier |
-prune-eh | Remove unused exception handling info |
@@ -171,6 +171,8 @@ perl -e '$/ = undef; for (split(/\n/, <>)) { s:^ *///? ?::; print " \n" if !
-simplify-libcalls | Simplify well-known library calls |
-simplifycfg | Simplify the CFG |
-strip | Strip all symbols from a module |
+-strip-dead-prototypes | Remove unused function declarations |
+-sretpromotion | Promote sret arguments |
-tailcallelim | Tail Call Elimination |
-tailduplicate | Tail Duplication |
@@ -739,27 +741,12 @@ perl -e '$/ = undef; for (split(/\n/, <>)) { s:^ *///? ?::; print " \n" if !
-
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)
+
+
+
+
+ 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.
+
+
+
+
+
+
+
+ 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 operations on vector datatypes into operations on more primitive vector
- datatypes, and finally to scalar operations.
-
-
-
-
-
-
-
- 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
-
-
-
-
-
-
-
- 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.
-
-
-
+
+
+
+
+ This pass performs various transformations related to eliminating memcpy
+ calls, or transforming sets of stores into memset's.
+
+
+
+
+
+
+
+ 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).
+
+
+
+
+
+
+
+ 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:
+
+
+
+ - The returned struct must not contain other structs
+ - The returned struct must only be used to load values from
+ - The placeholder struct passed in is the result of an alloca
+
+
+
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.
//
//===----------------------------------------------------------------------===//