summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-08-21 17:31:45 +0000
committerChris Lattner <sabre@nondot.org>2008-08-21 17:31:45 +0000
commit479c5d9ee26cbbc33cb799ad2fdbcd6937ae27c1 (patch)
treed1b21d8aaa223e004f865e220a64614d11e4a690 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parentcdf1a276e3a8a0ea0387e6ec3d8c2e95c71c7260 (diff)
downloadbcm5719-llvm-479c5d9ee26cbbc33cb799ad2fdbcd6937ae27c1.tar.gz
bcm5719-llvm-479c5d9ee26cbbc33cb799ad2fdbcd6937ae27c1.zip
Switch from an O(n) method to an O(1) method for changing non-constant
operands. llvm-svn: 55127
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 1151496d1e2..79d863833dd 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -237,17 +237,18 @@ void BitcodeReaderValueList::ResolveConstantForwardRefs() {
// new value. If they reference more than one placeholder, update them all
// at once.
while (!Placeholder->use_empty()) {
- User *U = Placeholder->use_back();
+ Value::use_iterator UI = Placeholder->use_begin();
+
// If the using object isn't uniqued, just update the operands. This
// handles instructions and initializers for global variables.
- if (!isa<Constant>(U) || isa<GlobalValue>(U)) {
- U->replaceUsesOfWith(Placeholder, RealVal);
+ if (!isa<Constant>(*UI) || isa<GlobalValue>(*UI)) {
+ UI.getUse().set(RealVal);
continue;
}
// Otherwise, we have a constant that uses the placeholder. Replace that
// constant with a new constant that has *all* placeholder uses updated.
- Constant *UserC = cast<Constant>(U);
+ Constant *UserC = cast<Constant>(*UI);
for (User::op_iterator I = UserC->op_begin(), E = UserC->op_end();
I != E; ++I) {
Value *NewOp;
OpenPOWER on IntegriCloud