[llvm] r266550 - Revert "use range loop, try to make comments more meaningful; NFCI"
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 16 20:59:37 PDT 2016
Author: dexonsmith
Date: Sat Apr 16 22:59:37 2016
New Revision: 266550
URL: http://llvm.org/viewvc/llvm-project?rev=266550&view=rev
Log:
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
Modified:
llvm/trunk/lib/IR/AutoUpgrade.cpp
Modified: llvm/trunk/lib/IR/AutoUpgrade.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AutoUpgrade.cpp?rev=266550&r1=266549&r2=266550&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AutoUpgrade.cpp (original)
+++ llvm/trunk/lib/IR/AutoUpgrade.cpp Sat Apr 16 22:59:37 2016
@@ -802,18 +802,21 @@ void llvm::UpgradeIntrinsicCall(CallInst
}
}
-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();
}
More information about the llvm-commits
mailing list