diff options
Diffstat (limited to 'llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp index 5ef850d09d92..f00528023c91 100644 --- a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp +++ b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp @@ -5,7 +5,6 @@ #include "llvm/ADT/IntervalMap.h" #include "llvm/ADT/PostOrderIterator.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/UniqueVector.h" #include "llvm/Analysis/Interval.h" @@ -26,6 +25,7 @@ #include <assert.h> #include <cstdint> #include <optional> +#include <queue> #include <sstream> #include <unordered_map> @@ -1979,20 +1979,23 @@ static AssignmentTrackingLowering::OverlapMap buildOverlapMapAndRecordDeclares( I, Fn.getParent()->getDataLayout())) { // Find markers linked to this alloca. for (DbgAssignIntrinsic *DAI : at::getAssignmentMarkers(Info->Base)) { - // Discard the fragment if it covers the entire variable. - std::optional<DIExpression::FragmentInfo> FragInfo = - [&Info, DAI]() -> std::optional<DIExpression::FragmentInfo> { - DIExpression::FragmentInfo F; - F.OffsetInBits = Info->OffsetInBits; - F.SizeInBits = Info->SizeInBits; - if (auto ExistingFrag = DAI->getExpression()->getFragmentInfo()) - F.OffsetInBits += ExistingFrag->OffsetInBits; - if (auto Sz = DAI->getVariable()->getSizeInBits()) { - if (F.OffsetInBits == 0 && F.SizeInBits == *Sz) - return std::nullopt; - } - return F; - }(); + std::optional<DIExpression::FragmentInfo> FragInfo; + + // Skip this assignment if the affected bits are outside of the + // variable fragment. + if (!at::calculateFragmentIntersect( + I.getModule()->getDataLayout(), Info->Base, + Info->OffsetInBits, Info->SizeInBits, DAI, FragInfo) || + (FragInfo && FragInfo->SizeInBits == 0)) + continue; + + // FragInfo from calculateFragmentIntersect is nullopt if the + // resultant fragment matches DAI's fragment or entire variable - in + // which case copy the fragment info from DAI. If FragInfo is still + // nullopt after the copy it means "no fragment info" instead, which + // is how it is usually interpreted. + if (!FragInfo) + FragInfo = DAI->getExpression()->getFragmentInfo(); DebugVariable DV = DebugVariable(DAI->getVariable(), FragInfo, DAI->getDebugLoc().getInlinedAt()); |
