Index: llvm/lib/CodeGen/LiveDebugVariables.cpp =================================================================== --- llvm/lib/CodeGen/LiveDebugVariables.cpp +++ llvm/lib/CodeGen/LiveDebugVariables.cpp @@ -148,9 +148,8 @@ /// closure of that relation. class UserValue { const DILocalVariable *Variable; ///< The debug info variable we are part of. - // FIXME: This is only used to get the FragmentInfo that describes the part - // of the variable we are a part of. We should just store the FragmentInfo. - const DIExpression *Expression; ///< Any complex address expression. + /// The part of the variable we describe. + const Optional Fragment; DebugLoc dl; ///< The debug location for the variable. This is ///< used by dwarf writer to find lexical scope. UserValue *leader; ///< Equivalence class leader. @@ -176,9 +175,10 @@ public: /// Create a new UserValue. - UserValue(const DILocalVariable *var, const DIExpression *expr, DebugLoc L, + UserValue(const DILocalVariable *var, + Optional Fragment, DebugLoc L, LocMap::Allocator &alloc) - : Variable(var), Expression(expr), dl(std::move(L)), leader(this), + : Variable(var), Fragment(Fragment), dl(std::move(L)), leader(this), locInts(alloc) {} /// Get the leader of this value's equivalence class. @@ -193,7 +193,8 @@ UserValue *getNext() const { return next; } /// Does this UserValue match the parameters? - bool match(const DILocalVariable *Var, const DIExpression *Expr, + bool match(const DILocalVariable *Var, + Optional OtherFragment, const DILocation *IA) const { // FIXME: Handle partially overlapping fragments. // A DBG_VALUE with a fragment which overlaps a previous DBG_VALUE fragment @@ -205,8 +206,7 @@ // therefore we do not faithfully represent the original intervals. // See D70121#1849741 for a more detailed explanation and further // discussion. - return Var == Variable && - Expr->getFragmentInfo() == Expression->getFragmentInfo() && + return Var == Variable && OtherFragment == Fragment && dl->getInlinedAt() == IA; } @@ -419,7 +419,8 @@ UVMap userVarMap; /// Find or create a UserValue. - UserValue *getUserValue(const DILocalVariable *Var, const DIExpression *Expr, + UserValue *getUserValue(const DILocalVariable *Var, + Optional Fragment, const DebugLoc &DL); /// Find the EC leader for VirtReg or null. @@ -580,18 +581,19 @@ } UserValue *LDVImpl::getUserValue(const DILocalVariable *Var, - const DIExpression *Expr, const DebugLoc &DL) { + Optional Fragment, + const DebugLoc &DL) { UserValue *&Leader = userVarMap[Var]; if (Leader) { UserValue *UV = Leader->getLeader(); Leader = UV; for (; UV; UV = UV->getNext()) - if (UV->match(Var, Expr, DL->getInlinedAt())) + if (UV->match(Var, Fragment, DL->getInlinedAt())) return UV; } userValues.push_back( - std::make_unique(Var, Expr, DL, allocator)); + std::make_unique(Var, Fragment, DL, allocator)); UserValue *UV = userValues.back().get(); Leader = UserValue::merge(Leader, UV); return UV; @@ -656,7 +658,7 @@ "DBG_VALUE with nonzero offset"); const DILocalVariable *Var = MI.getDebugVariable(); const DIExpression *Expr = MI.getDebugExpression(); - UserValue *UV = getUserValue(Var, Expr, MI.getDebugLoc()); + UserValue *UV = getUserValue(Var, Expr->getFragmentInfo(), MI.getDebugLoc()); if (!Discard) UV->addDef(Idx, MI.getOperand(0), *Expr); else {