When trying to upgrade @llvm.x86.sse2.psrl.dq while parsing a module,
BitcodeReader adds the function to its worklist twice, resulting in a
crash when accessing it the second time.
This patch replaces the worklist vector by a map.
Patch by Philip Pfaffe.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241281
91177308-0d34-0410-b5e6-
96231b3b80d8
// When intrinsic functions are encountered which require upgrading they are
// stored here with their replacement function.
// When intrinsic functions are encountered which require upgrading they are
// stored here with their replacement function.
- typedef std::vector<std::pair<Function*, Function*> > UpgradedIntrinsicMap;
+ typedef DenseMap<Function*, Function*> UpgradedIntrinsicMap;
UpgradedIntrinsicMap UpgradedIntrinsics;
// Map the bitcode's custom MDKind ID to the Module's MDKind ID.
UpgradedIntrinsicMap UpgradedIntrinsics;
// Map the bitcode's custom MDKind ID to the Module's MDKind ID.
for (Function &F : *TheModule) {
Function *NewFn;
if (UpgradeIntrinsicFunction(&F, NewFn))
for (Function &F : *TheModule) {
Function *NewFn;
if (UpgradeIntrinsicFunction(&F, NewFn))
- UpgradedIntrinsics.push_back(std::make_pair(&F, NewFn));
+ UpgradedIntrinsics[&F] = NewFn;
}
// Look for global variables which need to be renamed.
}
// Look for global variables which need to be renamed.
I.first->eraseFromParent();
}
}
I.first->eraseFromParent();
}
}
- std::vector<std::pair<Function*, Function*> >().swap(UpgradedIntrinsics);
+ UpgradedIntrinsics.clear();
for (unsigned I = 0, E = InstsWithTBAATag.size(); I < E; I++)
UpgradeInstWithTBAATag(InstsWithTBAATag[I]);
for (unsigned I = 0, E = InstsWithTBAATag.size(); I < E; I++)
UpgradeInstWithTBAATag(InstsWithTBAATag[I]);
--- /dev/null
+RUN: llvm-dis -disable-output %p/Inputs/PR23310.bc