Skip to content

Commit 4e72121

Browse files
committedJul 2, 2015
Fix for PR23310: llvm-dis crashes when trying to upgrade an intrinsic.
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. llvm-svn: 241281
1 parent d80c526 commit 4e72121

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed
 

‎llvm/lib/Bitcode/Reader/BitcodeReader.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class BitcodeReader : public GVMaterializer {
170170

171171
// When intrinsic functions are encountered which require upgrading they are
172172
// stored here with their replacement function.
173-
typedef std::vector<std::pair<Function*, Function*> > UpgradedIntrinsicMap;
173+
typedef DenseMap<Function*, Function*> UpgradedIntrinsicMap;
174174
UpgradedIntrinsicMap UpgradedIntrinsics;
175175

176176
// Map the bitcode's custom MDKind ID to the Module's MDKind ID.
@@ -2710,7 +2710,7 @@ std::error_code BitcodeReader::globalCleanup() {
27102710
for (Function &F : *TheModule) {
27112711
Function *NewFn;
27122712
if (UpgradeIntrinsicFunction(&F, NewFn))
2713-
UpgradedIntrinsics.push_back(std::make_pair(&F, NewFn));
2713+
UpgradedIntrinsics[&F] = NewFn;
27142714
}
27152715

27162716
// Look for global variables which need to be renamed.
@@ -4540,7 +4540,7 @@ std::error_code BitcodeReader::materializeModule(Module *M) {
45404540
I.first->eraseFromParent();
45414541
}
45424542
}
4543-
std::vector<std::pair<Function*, Function*> >().swap(UpgradedIntrinsics);
4543+
UpgradedIntrinsics.clear();
45444544

45454545
for (unsigned I = 0, E = InstsWithTBAATag.size(); I < E; I++)
45464546
UpgradeInstWithTBAATag(InstsWithTBAATag[I]);

‎llvm/test/Bitcode/Inputs/PR23310.bc

178 KB
Binary file not shown.

‎llvm/test/Bitcode/PR23310.test

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
RUN: llvm-dis -disable-output %p/Inputs/PR23310.bc

0 commit comments

Comments
 (0)
Please sign in to comment.