diff options
author | Chris Lattner <sabre@nondot.org> | 2008-08-21 17:31:45 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-08-21 17:31:45 +0000 |
commit | b6135a054d46c00e2ba604e8f509de48e6dcfde6 (patch) | |
tree | b89b68aa7ec08a75dc1c7088530397961996ef73 /lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | 5cc101ec897ea185088f3c1dbff88789ddd04cdb (diff) |
Switch from an O(n) method to an O(1) method for changing non-constant
operands.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55127 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | lib/Bitcode/Reader/BitcodeReader.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 1151496d1e..79d863833d 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/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; |