diff options
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index f763683..290d873 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -7015,13 +7015,6 @@ Error BitcodeReader::materialize(GlobalValue *GV) { if (StripDebugInfo) stripDebugInfo(*F); - // Upgrade any old intrinsic calls in the function. - for (auto &I : UpgradedIntrinsics) { - for (User *U : llvm::make_early_inc_range(I.first->materialized_users())) - if (CallInst *CI = dyn_cast<CallInst>(U)) - UpgradeIntrinsicCall(CI, I.second); - } - // Finish fn->subprogram upgrade for materialized functions. if (DISubprogram *SP = MDLoader->lookupSubprogramForFunction(F)) F->setSubprogram(SP); @@ -7037,7 +7030,7 @@ Error BitcodeReader::materialize(GlobalValue *GV) { } } - for (auto &I : instructions(F)) { + for (auto &I : make_early_inc_range(instructions(F))) { // "Upgrade" older incorrect branch weights by dropping them. if (auto *MD = I.getMetadata(LLVMContext::MD_prof)) { if (MD->getOperand(0) != nullptr && isa<MDString>(MD->getOperand(0))) { @@ -7068,8 +7061,8 @@ Error BitcodeReader::materialize(GlobalValue *GV) { } } - // Remove incompatible attributes on function calls. if (auto *CI = dyn_cast<CallBase>(&I)) { + // Remove incompatible attributes on function calls. CI->removeRetAttrs(AttributeFuncs::typeIncompatible( CI->getFunctionType()->getReturnType(), CI->getRetAttributes())); @@ -7077,6 +7070,13 @@ Error BitcodeReader::materialize(GlobalValue *GV) { CI->removeParamAttrs(ArgNo, AttributeFuncs::typeIncompatible( CI->getArgOperand(ArgNo)->getType(), CI->getParamAttributes(ArgNo))); + + // Upgrade intrinsics. + if (Function *OldFn = CI->getCalledFunction()) { + auto It = UpgradedIntrinsics.find(OldFn); + if (It != UpgradedIntrinsics.end()) + UpgradeIntrinsicCall(CI, It->second); + } } } |