Chris used to use '...' instead of proper grammar.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85775 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-11-02 02:33:50 +00:00
parent ea0db070a1
commit 2f09625a9f

View File

@ -310,7 +310,7 @@ private:
// getValueState - Return the LatticeVal object that corresponds to the value. // getValueState - Return the LatticeVal object that corresponds to the value.
// This function is necessary because not all values should start out in the // This function is necessary because not all values should start out in the
// underdefined state... Argument's should be overdefined, and // underdefined state. Argument's should be overdefined, and
// constants should be marked as constants. If a value is not known to be an // constants should be marked as constants. If a value is not known to be an
// Instruction object, then use this accessor to get its value from the map. // Instruction object, then use this accessor to get its value from the map.
// //
@ -327,12 +327,12 @@ private:
return LV; return LV;
} }
} }
// All others are underdefined by default... // All others are underdefined by default.
return ValueState[V]; return ValueState[V];
} }
// markEdgeExecutable - Mark a basic block as executable, adding it to the BB // markEdgeExecutable - Mark a basic block as executable, adding it to the BB
// work list if it is not already executable... // work list if it is not already executable.
// //
void markEdgeExecutable(BasicBlock *Source, BasicBlock *Dest) { void markEdgeExecutable(BasicBlock *Source, BasicBlock *Dest) {
if (!KnownFeasibleEdges.insert(Edge(Source, Dest)).second) if (!KnownFeasibleEdges.insert(Edge(Source, Dest)).second)
@ -359,12 +359,12 @@ private:
void getFeasibleSuccessors(TerminatorInst &TI, SmallVector<bool, 16> &Succs); void getFeasibleSuccessors(TerminatorInst &TI, SmallVector<bool, 16> &Succs);
// isEdgeFeasible - Return true if the control flow edge from the 'From' basic // isEdgeFeasible - Return true if the control flow edge from the 'From' basic
// block to the 'To' basic block is currently feasible... // block to the 'To' basic block is currently feasible.
// //
bool isEdgeFeasible(BasicBlock *From, BasicBlock *To); bool isEdgeFeasible(BasicBlock *From, BasicBlock *To);
// OperandChangedState - This method is invoked on all of the users of an // OperandChangedState - This method is invoked on all of the users of an
// instruction that was just changed state somehow.... Based on this // instruction that was just changed state somehow. Based on this
// information, we need to update the specified user of this instruction. // information, we need to update the specified user of this instruction.
// //
void OperandChangedState(User *U) { void OperandChangedState(User *U) {
@ -377,7 +377,7 @@ private:
private: private:
friend class InstVisitor<SCCPSolver>; friend class InstVisitor<SCCPSolver>;
// visit implementations - Something changed in this instruction... Either an // visit implementations - Something changed in this instruction. Either an
// operand made a transition, or the instruction is newly executable. Change // operand made a transition, or the instruction is newly executable. Change
// the value type of I to reflect these changes if appropriate. // the value type of I to reflect these changes if appropriate.
// //
@ -397,7 +397,7 @@ private:
void visitExtractValueInst(ExtractValueInst &EVI); void visitExtractValueInst(ExtractValueInst &EVI);
void visitInsertValueInst(InsertValueInst &IVI); void visitInsertValueInst(InsertValueInst &IVI);
// Instructions that cannot be folded away... // Instructions that cannot be folded away.
void visitStoreInst (Instruction &I); void visitStoreInst (Instruction &I);
void visitLoadInst (LoadInst &I); void visitLoadInst (LoadInst &I);
void visitGetElementPtrInst(GetElementPtrInst &I); void visitGetElementPtrInst(GetElementPtrInst &I);
@ -418,7 +418,7 @@ private:
void visitVAArgInst (Instruction &I) { markOverdefined(&I); } void visitVAArgInst (Instruction &I) { markOverdefined(&I); }
void visitInstruction(Instruction &I) { void visitInstruction(Instruction &I) {
// If a new instruction is added to LLVM that we don't handle... // If a new instruction is added to LLVM that we don't handle.
errs() << "SCCP: Don't know how to handle: " << I; errs() << "SCCP: Don't know how to handle: " << I;
markOverdefined(&I); // Just in case markOverdefined(&I); // Just in case
} }
@ -485,7 +485,7 @@ void SCCPSolver::getFeasibleSuccessors(TerminatorInst &TI,
// isEdgeFeasible - Return true if the control flow edge from the 'From' basic // isEdgeFeasible - Return true if the control flow edge from the 'From' basic
// block to the 'To' basic block is currently feasible... // block to the 'To' basic block is currently feasible.
// //
bool SCCPSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To) { bool SCCPSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To) {
assert(BBExecutable.count(To) && "Dest should always be alive!"); assert(BBExecutable.count(To) && "Dest should always be alive!");
@ -493,7 +493,7 @@ bool SCCPSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To) {
// Make sure the source basic block is executable!! // Make sure the source basic block is executable!!
if (!BBExecutable.count(From)) return false; if (!BBExecutable.count(From)) return false;
// Check to make sure this edge itself is actually feasible now... // Check to make sure this edge itself is actually feasible now.
TerminatorInst *TI = From->getTerminator(); TerminatorInst *TI = From->getTerminator();
if (BranchInst *BI = dyn_cast<BranchInst>(TI)) { if (BranchInst *BI = dyn_cast<BranchInst>(TI)) {
if (BI->isUnconditional()) if (BI->isUnconditional())
@ -530,11 +530,11 @@ bool SCCPSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To) {
// Make sure to skip the "default value" which isn't a value // Make sure to skip the "default value" which isn't a value
for (unsigned i = 1, E = SI->getNumSuccessors(); i != E; ++i) for (unsigned i = 1, E = SI->getNumSuccessors(); i != E; ++i)
if (SI->getSuccessorValue(i) == CPV) // Found the taken branch... if (SI->getSuccessorValue(i) == CPV) // Found the taken branch.
return SI->getSuccessor(i) == To; return SI->getSuccessor(i) == To;
// Constant value not equal to any of the branches... must execute // If the constant value is not equal to any of the branches, we must
// default branch then... // execute default branch.
return SI->getDefaultDest() == To; return SI->getDefaultDest() == To;
} }
return false; return false;
@ -551,7 +551,7 @@ bool SCCPSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To) {
llvm_unreachable(0); llvm_unreachable(0);
} }
// visit Implementations - Something changed in this instruction... Either an // visit Implementations - Something changed in this instruction, either an
// operand made a transition, or the instruction is newly executable. Change // operand made a transition, or the instruction is newly executable. Change
// the value type of I to reflect these changes if appropriate. This method // the value type of I to reflect these changes if appropriate. This method
// makes sure to do the following actions: // makes sure to do the following actions:
@ -612,14 +612,14 @@ void SCCPSolver::visitPHINode(PHINode &PN) {
return; return;
} }
if (OperandVal == 0) { // Grab the first value... if (OperandVal == 0) { // Grab the first value.
OperandVal = IV.getConstant(); OperandVal = IV.getConstant();
} else { // Another value is being merged in! } else { // Another value is being merged in!
// There is already a reachable operand. If we conflict with it, // There is already a reachable operand. If we conflict with it,
// then the PHI node becomes overdefined. If we agree with it, we // then the PHI node becomes overdefined. If we agree with it, we
// can continue on. // can continue on.
// Check to see if there are two different constants merging... // Check to see if there are two different constants merging.
if (IV.getConstant() != OperandVal) { if (IV.getConstant() != OperandVal) {
// Yes there is. This means the PHI node is not constant. // Yes there is. This means the PHI node is not constant.
// You must be overdefined poor PHI. // You must be overdefined poor PHI.
@ -687,7 +687,7 @@ void SCCPSolver::visitTerminatorInst(TerminatorInst &TI) {
BasicBlock *BB = TI.getParent(); BasicBlock *BB = TI.getParent();
// Mark all feasible successors executable... // Mark all feasible successors executable.
for (unsigned i = 0, e = SuccFeasible.size(); i != e; ++i) for (unsigned i = 0, e = SuccFeasible.size(); i != e; ++i)
if (SuccFeasible[i]) if (SuccFeasible[i])
markEdgeExecutable(BB, TI.getSuccessor(i)); markEdgeExecutable(BB, TI.getSuccessor(i));
@ -819,7 +819,7 @@ void SCCPSolver::visitSelectInst(SelectInst &I) {
} }
} }
// Handle BinaryOperators and Shift Instructions... // Handle BinaryOperators and Shift Instructions.
void SCCPSolver::visitBinaryOperator(Instruction &I) { void SCCPSolver::visitBinaryOperator(Instruction &I) {
LatticeVal &IV = ValueState[&I]; LatticeVal &IV = ValueState[&I];
if (IV.isOverdefined()) return; if (IV.isOverdefined()) return;
@ -946,7 +946,7 @@ void SCCPSolver::visitBinaryOperator(Instruction &I) {
} }
} }
// Handle ICmpInst instruction... // Handle ICmpInst instruction.
void SCCPSolver::visitCmpInst(CmpInst &I) { void SCCPSolver::visitCmpInst(CmpInst &I) {
LatticeVal &IV = ValueState[&I]; LatticeVal &IV = ValueState[&I];
if (IV.isOverdefined()) return; if (IV.isOverdefined()) return;
@ -1104,7 +1104,7 @@ void SCCPSolver::visitShuffleVectorInst(ShuffleVectorInst &I) {
#endif #endif
} }
// Handle getelementptr instructions... if all operands are constants then we // Handle getelementptr instructions. If all operands are constants then we
// can turn this into a getelementptr ConstantExpr. // can turn this into a getelementptr ConstantExpr.
// //
void SCCPSolver::visitGetElementPtrInst(GetElementPtrInst &I) { void SCCPSolver::visitGetElementPtrInst(GetElementPtrInst &I) {
@ -1117,8 +1117,9 @@ void SCCPSolver::visitGetElementPtrInst(GetElementPtrInst &I) {
for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) { for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) {
LatticeVal &State = getValueState(I.getOperand(i)); LatticeVal &State = getValueState(I.getOperand(i));
if (State.isUndefined()) if (State.isUndefined())
return; // Operands are not resolved yet... return; // Operands are not resolved yet.
else if (State.isOverdefined()) {
if (State.isOverdefined()) {
markOverdefined(IV, &I); markOverdefined(IV, &I);
return; return;
} }
@ -1127,7 +1128,7 @@ void SCCPSolver::visitGetElementPtrInst(GetElementPtrInst &I) {
} }
Constant *Ptr = Operands[0]; Constant *Ptr = Operands[0];
Operands.erase(Operands.begin()); // Erase the pointer from idx list... Operands.erase(Operands.begin()); // Erase the pointer from idx list.
markConstant(IV, &I, ConstantExpr::getGetElementPtr(Ptr, &Operands[0], markConstant(IV, &I, ConstantExpr::getGetElementPtr(Ptr, &Operands[0],
Operands.size())); Operands.size()));
@ -1306,7 +1307,7 @@ void SCCPSolver::Solve() {
// Process the work lists until they are empty! // Process the work lists until they are empty!
while (!BBWorkList.empty() || !InstWorkList.empty() || while (!BBWorkList.empty() || !InstWorkList.empty() ||
!OverdefinedInstWorkList.empty()) { !OverdefinedInstWorkList.empty()) {
// Process the instruction work list... // Process the instruction work list.
while (!OverdefinedInstWorkList.empty()) { while (!OverdefinedInstWorkList.empty()) {
Value *I = OverdefinedInstWorkList.back(); Value *I = OverdefinedInstWorkList.back();
OverdefinedInstWorkList.pop_back(); OverdefinedInstWorkList.pop_back();
@ -1318,13 +1319,14 @@ void SCCPSolver::Solve() {
// //
// Anything on this worklist that is overdefined need not be visited // Anything on this worklist that is overdefined need not be visited
// since all of its users will have already been marked as overdefined // since all of its users will have already been marked as overdefined
// Update all of the users of this instruction's value... // Update all of the users of this instruction's value.
// //
for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
UI != E; ++UI) UI != E; ++UI)
OperandChangedState(*UI); OperandChangedState(*UI);
} }
// Process the instruction work list...
// Process the instruction work list.
while (!InstWorkList.empty()) { while (!InstWorkList.empty()) {
Value *I = InstWorkList.back(); Value *I = InstWorkList.back();
InstWorkList.pop_back(); InstWorkList.pop_back();
@ -1336,7 +1338,7 @@ void SCCPSolver::Solve() {
// //
// Anything on this worklist that is overdefined need not be visited // Anything on this worklist that is overdefined need not be visited
// since all of its users will have already been marked as overdefined. // since all of its users will have already been marked as overdefined.
// Update all of the users of this instruction's value... // Update all of the users of this instruction's value.
// //
if (!getValueState(I).isOverdefined()) if (!getValueState(I).isOverdefined())
for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
@ -1344,7 +1346,7 @@ void SCCPSolver::Solve() {
OperandChangedState(*UI); OperandChangedState(*UI);
} }
// Process the basic block work list... // Process the basic block work list.
while (!BBWorkList.empty()) { while (!BBWorkList.empty()) {
BasicBlock *BB = BBWorkList.back(); BasicBlock *BB = BBWorkList.back();
BBWorkList.pop_back(); BBWorkList.pop_back();
@ -1559,7 +1561,7 @@ char SCCP::ID = 0;
static RegisterPass<SCCP> static RegisterPass<SCCP>
X("sccp", "Sparse Conditional Constant Propagation"); X("sccp", "Sparse Conditional Constant Propagation");
// createSCCPPass - This is the public interface to this file... // createSCCPPass - This is the public interface to this file.
FunctionPass *llvm::createSCCPPass() { FunctionPass *llvm::createSCCPPass() {
return new SCCP(); return new SCCP();
} }
@ -1664,7 +1666,7 @@ char IPSCCP::ID = 0;
static RegisterPass<IPSCCP> static RegisterPass<IPSCCP>
Y("ipsccp", "Interprocedural Sparse Conditional Constant Propagation"); Y("ipsccp", "Interprocedural Sparse Conditional Constant Propagation");
// createIPSCCPPass - This is the public interface to this file... // createIPSCCPPass - This is the public interface to this file.
ModulePass *llvm::createIPSCCPPass() { ModulePass *llvm::createIPSCCPPass() {
return new IPSCCP(); return new IPSCCP();
} }