diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2017-03-22 18:04:39 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2017-03-22 18:04:39 +0000 |
commit | 9a3f97977f388cf76161ec0c87e0a70e49caa4ec (patch) | |
tree | ade250774948afb93bf8ee2f4b747cf58fdf2fd1 /llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp | |
parent | 84a6218fbe354d2bcc2254cc3f8b74bba55bca8c (diff) | |
download | bcm5719-llvm-9a3f97977f388cf76161ec0c87e0a70e49caa4ec.tar.gz bcm5719-llvm-9a3f97977f388cf76161ec0c87e0a70e49caa4ec.zip |
IR: Fix a race condition in type id clients of ModuleSummaryIndex.
Add a const version of the getTypeIdSummary accessor that avoids
mutating the TypeIdMap.
Differential Revision: https://reviews.llvm.org/D31226
llvm-svn: 298531
Diffstat (limited to 'llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp index ba44921d4d5..68d7bd56813 100644 --- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp +++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -1196,9 +1196,14 @@ void DevirtModule::scanTypeCheckedLoadUsers(Function *TypeCheckedLoadFunc) { } void DevirtModule::importResolution(VTableSlot Slot, VTableSlotInfo &SlotInfo) { - const WholeProgramDevirtResolution &Res = - Summary->getTypeIdSummary(cast<MDString>(Slot.TypeID)->getString()) - .WPDRes[Slot.ByteOffset]; + const TypeIdSummary *TidSummary = + Summary->getTypeIdSummary(cast<MDString>(Slot.TypeID)->getString()); + if (!TidSummary) + return; + auto ResI = TidSummary->WPDRes.find(Slot.ByteOffset); + if (ResI == TidSummary->WPDRes.end()) + return; + const WholeProgramDevirtResolution &Res = ResI->second; if (Res.TheKind == WholeProgramDevirtResolution::SingleImpl) { // The type of the function in the declaration is irrelevant because every @@ -1354,10 +1359,10 @@ bool DevirtModule::run() { S.first.ByteOffset)) { WholeProgramDevirtResolution *Res = nullptr; if (Action == PassSummaryAction::Export && isa<MDString>(S.first.TypeID)) - Res = - &Summary - ->getTypeIdSummary(cast<MDString>(S.first.TypeID)->getString()) - .WPDRes[S.first.ByteOffset]; + Res = &Summary + ->getOrInsertTypeIdSummary( + cast<MDString>(S.first.TypeID)->getString()) + .WPDRes[S.first.ByteOffset]; if (!trySingleImplDevirt(TargetsForSlot, S.second, Res) && tryVirtualConstProp(TargetsForSlot, S.second, Res, S.first)) |