forked from OSchip/llvm-project
[mlir][LLVMDebugTranslation] Only insert the location mapping after translation
This fixes an iteration invalidation bug when the map grows beyond capacity and the iterator for the location to translate becomes invalid.
This commit is contained in:
parent
a4ccfd9565
commit
6fab33b20a
|
@ -110,10 +110,11 @@ DebugTranslation::translateLoc(Location loc, llvm::DILocalScope *scope,
|
|||
return nullptr;
|
||||
|
||||
// Check for a cached instance.
|
||||
const auto *&llvmLoc = locationToLoc[std::make_pair(loc, scope)];
|
||||
if (llvmLoc)
|
||||
return llvmLoc;
|
||||
auto existingIt = locationToLoc.find(std::make_pair(loc, scope));
|
||||
if (existingIt != locationToLoc.end())
|
||||
return existingIt->second;
|
||||
|
||||
const llvm::DILocation *llvmLoc = nullptr;
|
||||
switch (loc->getKind()) {
|
||||
case StandardAttributes::CallSiteLocation: {
|
||||
auto callLoc = loc.dyn_cast<CallSiteLoc>();
|
||||
|
@ -154,6 +155,7 @@ DebugTranslation::translateLoc(Location loc, llvm::DILocalScope *scope,
|
|||
default:
|
||||
llvm_unreachable("unknown location kind");
|
||||
}
|
||||
locationToLoc.try_emplace(std::make_pair(loc, scope), llvmLoc);
|
||||
return llvmLoc;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue