summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Module.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-04-23 00:22:55 +0000
committerBill Wendling <isanbard@gmail.com>2012-04-23 00:22:55 +0000
commit3d0ec2bedbbf30aab2570d254eff4fb9771b8098 (patch)
treefef24af324787988bf1e963e324a34aae7c6ff28 /llvm/lib/VMCore/Module.cpp
parentcba4879534143d3562174645ebb99f9e1316c702 (diff)
downloadbcm5719-llvm-3d0ec2bedbbf30aab2570d254eff4fb9771b8098.tar.gz
bcm5719-llvm-3d0ec2bedbbf30aab2570d254eff4fb9771b8098.zip
Limit the number of times we recurse through this algorithm. All of the
intructions are processed. So there's no need to look at them if they're used as operands of other instructions. llvm-svn: 155327
Diffstat (limited to 'llvm/lib/VMCore/Module.cpp')
-rw-r--r--llvm/lib/VMCore/Module.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/llvm/lib/VMCore/Module.cpp b/llvm/lib/VMCore/Module.cpp
index 24c2707b543..1336c18a32c 100644
--- a/llvm/lib/VMCore/Module.cpp
+++ b/llvm/lib/VMCore/Module.cpp
@@ -505,22 +505,30 @@ namespace {
incorporateValue(Aliasee);
}
- SmallVector<std::pair<unsigned, MDNode*>, 4> MDForInst;
-
// Get types from functions.
+ SmallVector<std::pair<unsigned, MDNode*>, 4> MDForInst;
for (Module::const_iterator FI = M.begin(), E = M.end(); FI != E; ++FI) {
incorporateType(FI->getType());
+ // First incorporate the arguments.
+ for (Function::const_arg_iterator AI = FI->arg_begin(),
+ AE = FI->arg_end(); AI != AE; ++AI)
+ incorporateValue(AI);
+
for (Function::const_iterator BB = FI->begin(), E = FI->end();
BB != E;++BB)
for (BasicBlock::const_iterator II = BB->begin(),
E = BB->end(); II != E; ++II) {
const Instruction &I = *II;
- // Incorporate the type of the instruction and all its operands.
+ // Incorporate the type of the instruction.
incorporateType(I.getType());
+
+ // Incorporate non-instruction operand types. (We are incorporating
+ // all instructions with this loop.)
for (User::const_op_iterator OI = I.op_begin(), OE = I.op_end();
OI != OE; ++OI)
- incorporateValue(*OI);
+ if (!isa<Instruction>(OI))
+ incorporateValue(*OI);
// Incorporate types hiding in metadata.
I.getAllMetadataOtherThanDebugLoc(MDForInst);
@@ -570,7 +578,11 @@ namespace {
// Check this type.
incorporateType(V->getType());
-
+
+ // If this is an instruction, we incorporate it separately.
+ if (isa<Instruction>(V))
+ return;
+
// Look in operands for types.
const User *U = cast<User>(V);
for (Constant::const_op_iterator I = U->op_begin(),
OpenPOWER on IntegriCloud