AllocaInst *AI;
SmallVector<IntrinsicInst *, 2> LifetimeStart;
SmallVector<IntrinsicInst *, 2> LifetimeEnd;
- SmallVector<DbgVariableIntrinsic *, 2> DbgVariableIntrinsics;
};
struct StackInfo {
MapVector<AllocaInst *, AllocaInfo> AllocasToInstrument;
SmallVector<Instruction *, 4> UnrecognizedLifetimes;
+ DenseMap<AllocaInst *, std::vector<DbgVariableIntrinsic *>> AllocaDbgMap;
SmallVector<Instruction *, 8> RetVec;
bool CallsReturnTwice = false;
};
AI->replaceUsesWithIf(Replacement,
[AILong](Use &U) { return U.getUser() != AILong; });
- for (auto *DDI : Info.DbgVariableIntrinsics) {
+ for (auto *DDI : SInfo.AllocaDbgMap.lookup(AI)) {
// Prepend "tag_offset, N" to the dwarf expression.
// Tag offset logically applies to the alloca pointer, and it makes sense
// to put it at the beginning of the expression.
}
if (auto *DVI = dyn_cast<DbgVariableIntrinsic>(&Inst)) {
for (Value *V : DVI->location_ops()) {
- if (auto *AI = dyn_cast_or_null<AllocaInst>(V)) {
- AllocaInfo &AInfo = Info.AllocasToInstrument[AI];
- auto &DVIVec = AInfo.DbgVariableIntrinsics;
- if (IsInterestingAlloca(*AI) &&
- (DVIVec.empty() || DVIVec.back() != DVI))
- DVIVec.push_back(DVI);
- }
+ if (auto *Alloca = dyn_cast_or_null<AllocaInst>(V))
+ if (!Info.AllocaDbgMap.count(Alloca) ||
+ Info.AllocaDbgMap[Alloca].back() != DVI)
+ Info.AllocaDbgMap[Alloca].push_back(DVI);
}
}
Instruction *ExitUntag = getUntagLocationIfFunctionExit(Inst);