Skip to content

Commit 2816c63

Browse files
committed
[TSAR, Memory, Dep] Intermediate, try to process partially promoted locations.
1 parent bd40e93 commit 2816c63

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

lib/Analysis/Memory/DIDependenceAnalysis.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,32 @@ template<class FuncT> void updateTraits(const Loop *L, const PHINode *Phi,
564564
continue;
565565
for (auto &DILoc : DILocs) {
566566
auto *MD = getRawDIMemoryIfExists(Incoming->getContext(), DILoc);
567-
if (!MD)
568-
continue;
567+
// If a memory location is partially promoted we will try to use
568+
// dbg.declare or dbg.addr intrinsics to find the corresponding node in
569+
// the alias tree.
570+
if (!MD) {
571+
if (DILoc.Expr->getNumOperands() != 0)
572+
continue;
573+
auto *MDV =
574+
MetadataAsValue::getIfExists(Incoming->getContext(), DILoc.Var);
575+
if (!MDV)
576+
continue;
577+
for (User *U : MDV->users()) {
578+
if (auto *DII = dyn_cast<DbgVariableIntrinsic>(U))
579+
if (DII->isAddressOfVariable()) {
580+
auto DILocCandidate = DIMemoryLocation::get(DII);
581+
if (DILocCandidate.Expr != DILoc.Expr &&
582+
DILocCandidate.Loc == DILoc.Loc)
583+
continue;
584+
MD = getRawDIMemoryIfExists(Incoming->getContext(),
585+
DILocCandidate);
586+
if (MD)
587+
break;
588+
}
589+
}
590+
if (!MD)
591+
continue;
592+
}
569593
auto DIMTraitItr = Pool.find_as(MD);
570594
if (DIMTraitItr == Pool.end() ||
571595
DIMTraitItr->getMemory()->isOriginal() ||

0 commit comments

Comments
 (0)