47
47
#include " clang/Basic/TargetInfo.h"
48
48
#include " clang/Frontend/CompilerInstance.h"
49
49
#include " clang/Serialization/ASTReader.h"
50
+ #include " llvm/ADT/StringSet.h"
50
51
#include " llvm/Config/config.h"
51
52
#include " llvm/IR/DIBuilder.h"
52
53
#include " llvm/IR/DebugInfo.h"
@@ -107,9 +108,9 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
107
108
const PathRemapper &DebugPrefixMap;
108
109
109
110
// / Various caches.
110
- // / @ {
111
- using SILVarScope = llvm::PointerUnion< const SILDebugScope *, SILFunction *> ;
112
- using VarID = std::tuple<SILVarScope, const char * , uint16_t >;
111
+ // / \ {
112
+ llvm::StringSet<> VarNames ;
113
+ using VarID = std::tuple<llvm::MDNode *, llvm::StringRef, unsigned , uint16_t >;
113
114
llvm::DenseMap<VarID, llvm::TrackingMDNodeRef> LocalVarCache;
114
115
llvm::DenseMap<const SILDebugScope *, llvm::TrackingMDNodeRef> ScopeCache;
115
116
llvm::DenseMap<const SILDebugScope *, llvm::TrackingMDNodeRef> InlinedAtCache;
@@ -120,7 +121,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
120
121
llvm::StringMap<llvm::TrackingMDNodeRef> DIFileCache;
121
122
TrackingDIRefMap DIRefMap;
122
123
TrackingDIRefMap InnerTypeCache;
123
- // / @ }
124
+ // / \ }
124
125
125
126
// / A list of replaceable fwddecls that need to be RAUWed at the end.
126
127
std::vector<std::pair<TypeBase *, llvm::TrackingMDRef>> ReplaceMap;
@@ -2444,7 +2445,6 @@ void IRGenDebugInfoImpl::emitVariableDeclaration(
2444
2445
if (!DbgTy.getTypeSize ())
2445
2446
DbgTy.setSize (getStorageSize (IGM.DataLayout , Storage));
2446
2447
2447
- SILVarScope KeyScope = DS;
2448
2448
auto *Scope = dyn_cast_or_null<llvm::DILocalScope>(getOrCreateScope (DS));
2449
2449
assert (Scope && " variable has no local scope" );
2450
2450
auto DInstLoc = getStartLocation (DbgInstLoc);
@@ -2455,7 +2455,6 @@ void IRGenDebugInfoImpl::emitVariableDeclaration(
2455
2455
if (ArgNo > 0 ) {
2456
2456
while (isa<llvm::DILexicalBlock>(Scope))
2457
2457
Scope = cast<llvm::DILexicalBlock>(Scope)->getScope ();
2458
- KeyScope = DS->getInlinedFunction ();
2459
2458
}
2460
2459
assert (isa_and_nonnull<llvm::DIScope>(Scope) && " variable has no scope" );
2461
2460
llvm::DIFile *Unit = getFile (Scope);
@@ -2476,22 +2475,25 @@ void IRGenDebugInfoImpl::emitVariableDeclaration(
2476
2475
2477
2476
// Create the descriptor for the variable.
2478
2477
unsigned DVarLine = DInstLine;
2478
+ uint16_t DVarCol = 0 ;
2479
2479
if (VarInfo.Loc ) {
2480
2480
auto DVarLoc = getStartLocation (VarInfo.Loc );
2481
2481
DVarLine = DVarLoc.line ;
2482
+ DVarCol = DVarLoc.column ;
2482
2483
}
2483
2484
llvm::DIScope *VarScope = Scope;
2484
2485
if (ArgNo == 0 && VarInfo.Scope ) {
2485
2486
if (auto *VS = dyn_cast_or_null<llvm::DILocalScope>(
2486
2487
getOrCreateScope (VarInfo.Scope ))) {
2487
2488
VarScope = VS;
2488
- KeyScope = VarInfo.Scope ;
2489
2489
}
2490
2490
}
2491
2491
2492
2492
// Get or create the DILocalVariable.
2493
2493
llvm::DILocalVariable *Var;
2494
- VarID Key (KeyScope, VarInfo.Name .data (), ArgNo);
2494
+ // VarInfo.Name points into tail-allocated storage in debug_value insns.
2495
+ llvm::StringRef UniqueName = VarNames.insert (VarInfo.Name ).first ->getKey ();
2496
+ VarID Key (VarScope, UniqueName, DVarLine, DVarCol);
2495
2497
auto CachedVar = LocalVarCache.find (Key);
2496
2498
if (CachedVar != LocalVarCache.end ()) {
2497
2499
Var = cast<llvm::DILocalVariable>(CachedVar->second );
0 commit comments