diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-17 03:59:37 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-17 03:59:37 +0000 |
| commit | 93f53c426275ebe6fad14d79deca16f70365c206 (patch) | |
| tree | 717cba4e6604cefed152957fe57acdc11e073b87 /llvm | |
| parent | 5ab2be094e9b1e75a91b214a214d07e58aacef53 (diff) | |
| download | bcm5719-llvm-93f53c426275ebe6fad14d79deca16f70365c206.tar.gz bcm5719-llvm-93f53c426275ebe6fad14d79deca16f70365c206.zip | |
Revert "use range loop, try to make comments more meaningful; NFCI"
This reverts commit r266541 since it introduces a use-after-free:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/11471
llvm-svn: 266550
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/IR/AutoUpgrade.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp index 9ddfc91978e..121b43b7964 100644 --- a/llvm/lib/IR/AutoUpgrade.cpp +++ b/llvm/lib/IR/AutoUpgrade.cpp @@ -802,18 +802,21 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { } } -void llvm::UpgradeCallsToIntrinsic(Function *F) { +// This tests each Function to determine if it needs upgrading. When we find +// one we are interested in, we then upgrade all calls to reflect the new +// function. +void llvm::UpgradeCallsToIntrinsic(Function* F) { assert(F && "Illegal attempt to upgrade a non-existent intrinsic."); - // Check if this function should be upgraded and get the replacement function - // if there is one. + // Upgrade the function and check if it is a totaly new function. Function *NewFn; if (UpgradeIntrinsicFunction(F, NewFn)) { - // Replace all users of the old function with the new function or new IR. - for (User *U : F->users()) - if (CallInst *CI = dyn_cast<CallInst>(U)) + // Replace all uses to the old function with the new one if necessary. + for (Value::user_iterator UI = F->user_begin(), UE = F->user_end(); + UI != UE;) { + if (CallInst *CI = dyn_cast<CallInst>(*UI++)) UpgradeIntrinsicCall(CI, NewFn); - + } // Remove old function, no longer used, from the module. F->eraseFromParent(); } |

