Remove always-true comparison, NFC.
Summary: Looking at r241279, I noticed that UpgradedIntrinsics only gets written to in the following code: if (UpgradeIntrinsicFunction(&F, NewFn)) UpgradedIntrinsics[&F] = NewFn; Looking through UpgradeIntrinsicFunction, we always return false OR NewFn will be set to a different function from our source. This patch pulls the F != NewFn into UpgradeIntrinsicFunction as an assert, and removes the check from callers of UpgradeIntrinsicFunction. Reviewers: rafael, chandlerc Subscribers: llvm-commits-list Differential Revision: http://reviews.llvm.org/D10915 llvm-svn: 241369
This commit is contained in:
parent
c36cfe7af0
commit
0011c58444
|
@ -4458,14 +4458,11 @@ std::error_code BitcodeReader::materialize(GlobalValue *GV) {
|
||||||
|
|
||||||
// Upgrade any old intrinsic calls in the function.
|
// Upgrade any old intrinsic calls in the function.
|
||||||
for (auto &I : UpgradedIntrinsics) {
|
for (auto &I : UpgradedIntrinsics) {
|
||||||
if (I.first != I.second) {
|
for (auto UI = I.first->user_begin(), UE = I.first->user_end(); UI != UE;) {
|
||||||
for (auto UI = I.first->user_begin(), UE = I.first->user_end();
|
User *U = *UI;
|
||||||
UI != UE;) {
|
++UI;
|
||||||
User *U = *UI;
|
if (CallInst *CI = dyn_cast<CallInst>(U))
|
||||||
++UI;
|
UpgradeIntrinsicCall(CI, I.second);
|
||||||
if (CallInst *CI = dyn_cast<CallInst>(U))
|
|
||||||
UpgradeIntrinsicCall(CI, I.second);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4533,15 +4530,13 @@ std::error_code BitcodeReader::materializeModule(Module *M) {
|
||||||
// module is materialized because there could always be another function body
|
// module is materialized because there could always be another function body
|
||||||
// with calls to the old function.
|
// with calls to the old function.
|
||||||
for (auto &I : UpgradedIntrinsics) {
|
for (auto &I : UpgradedIntrinsics) {
|
||||||
if (I.first != I.second) {
|
for (auto *U : I.first->users()) {
|
||||||
for (auto *U : I.first->users()) {
|
if (CallInst *CI = dyn_cast<CallInst>(U))
|
||||||
if (CallInst *CI = dyn_cast<CallInst>(U))
|
UpgradeIntrinsicCall(CI, I.second);
|
||||||
UpgradeIntrinsicCall(CI, I.second);
|
|
||||||
}
|
|
||||||
if (!I.first->use_empty())
|
|
||||||
I.first->replaceAllUsesWith(I.second);
|
|
||||||
I.first->eraseFromParent();
|
|
||||||
}
|
}
|
||||||
|
if (!I.first->use_empty())
|
||||||
|
I.first->replaceAllUsesWith(I.second);
|
||||||
|
I.first->eraseFromParent();
|
||||||
}
|
}
|
||||||
UpgradedIntrinsics.clear();
|
UpgradedIntrinsics.clear();
|
||||||
|
|
||||||
|
|
|
@ -229,6 +229,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
|
||||||
bool llvm::UpgradeIntrinsicFunction(Function *F, Function *&NewFn) {
|
bool llvm::UpgradeIntrinsicFunction(Function *F, Function *&NewFn) {
|
||||||
NewFn = nullptr;
|
NewFn = nullptr;
|
||||||
bool Upgraded = UpgradeIntrinsicFunction1(F, NewFn);
|
bool Upgraded = UpgradeIntrinsicFunction1(F, NewFn);
|
||||||
|
assert(F != NewFn && "Intrinsic function upgraded to the same function");
|
||||||
|
|
||||||
// Upgrade intrinsic attributes. This does not change the function.
|
// Upgrade intrinsic attributes. This does not change the function.
|
||||||
if (NewFn)
|
if (NewFn)
|
||||||
|
@ -710,16 +711,14 @@ void llvm::UpgradeCallsToIntrinsic(Function* F) {
|
||||||
// Upgrade the function and check if it is a totaly new function.
|
// Upgrade the function and check if it is a totaly new function.
|
||||||
Function *NewFn;
|
Function *NewFn;
|
||||||
if (UpgradeIntrinsicFunction(F, NewFn)) {
|
if (UpgradeIntrinsicFunction(F, NewFn)) {
|
||||||
if (NewFn != F) {
|
// Replace all uses to the old function with the new one if necessary.
|
||||||
// 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();
|
||||||
for (Value::user_iterator UI = F->user_begin(), UE = F->user_end();
|
UI != UE;) {
|
||||||
UI != UE; ) {
|
if (CallInst *CI = dyn_cast<CallInst>(*UI++))
|
||||||
if (CallInst *CI = dyn_cast<CallInst>(*UI++))
|
UpgradeIntrinsicCall(CI, NewFn);
|
||||||
UpgradeIntrinsicCall(CI, NewFn);
|
|
||||||
}
|
|
||||||
// Remove old function, no longer used, from the module.
|
|
||||||
F->eraseFromParent();
|
|
||||||
}
|
}
|
||||||
|
// Remove old function, no longer used, from the module.
|
||||||
|
F->eraseFromParent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue