================
@@ -226,8 +230,44 @@ DILocation *DILocation::getMergedLocation(DILocation
*LocA, DILocation *LocB) {
bool SameCol = L1->getColumn() == L2->getColumn();
unsigned Line = SameLine ? L1->getLine() : 0;
unsigned Col = SameLine && SameCol ? L1->getColumn() : 0;
-
- return DILocation::get(C, Line, Col, Scope, InlinedAt);
+ bool IsImplicitCode = L1->isImplicitCode() && L2->isImplicitCode();
+ uint64_t Group = 0;
+ uint64_t Rank = 0;
+ if (SameLine) {
+ if (L1->getAtomGroup() || L2->getAtomGroup()) {
+ // If we're preserving the same matching inlined-at field we can
+ // preserve the atom.
+ if (LocBIA == LocAIA && InlinedAt == LocBIA) {
+ // Deterministically keep the lowest non-zero ranking atom group
+ // number.
+ // FIXME: It would be nice if we could track that an instruction
+ // belongs to two source atoms.
+ bool UseL1Atom = [L1, L2]() {
+ if (L1->getAtomRank() == L2->getAtomRank()) {
+ // Arbitrarily choose the lowest non-zero group number.
+ if (!L1->getAtomGroup() || !L2->getAtomGroup())
+ return !L2->getAtomGroup();
+ return L1->getAtomGroup() < L2->getAtomGroup();
+ }
+ // Choose the lowest non-zero rank.
+ if (!L1->getAtomRank() || !L2->getAtomRank())
+ return !L2->getAtomRank();
+ return L1->getAtomRank() < L2->getAtomRank();
+ }();
+ Group = UseL1Atom ? L1->getAtomGroup() : L2->getAtomGroup();
+ Rank = UseL1Atom ? L1->getAtomRank() : L2->getAtomRank();
+ } else {
+ // If either instruction is part of a source atom, reassign it a new
+ // atom group. This essentially regresses to non-key-instructions
+ // behaviour (now that it's the only instruction in its group it'll
+ // probably get is_stmt applied).
+ Group = C.incNextAtomGroup();
+ Rank = 1;
----------------
OCHyams wrote:
The new {atomGroup, inlinedAt} tuple wouldn't necessarily be distinct. (It
feels unlikely, but AFAICT is possible that another merged instruction from a
different source atom ends up with the same tuple).
https://github.com/llvm/llvm-project/pull/133480
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits