swift icon indicating copy to clipboard operation
swift copied to clipboard

[DebugInfo] Merge fragments from SIL with fragments created in IRGen

Open asavonic opened this issue 2 years ago • 2 comments

SIL variables can be split by SILSROA into separate allocations, each having op_fragment expressions in debug_value (VarInfo.DIExpr). These allocations can be further split by IRGen (multiple values in Storage argument).

These "nested" fragments refer to the same DI variable, so it is important to merge them for the LLVM IR DI expression. The compiler used to ignore fragment expressions from SIL when IRGen fragments were also present. This led to incorrect DI info generation, and for some cases even triggered assertions in LLVM X86 CodeGen:

DwarfExpression.cpp:679: void llvm::DwarfExpression::addFragmentOffset(const llvm::DIExpression *): Assertion `FragmentOffset >= OffsetInBits && "overlapping or duplicate fragments"' failed.

The patch resolves #64642. The LIT test is a reduced reproducer from that issue.

asavonic avatar Jun 08 '23 13:06 asavonic

@swift-ci please test

asl avatar Jun 08 '23 14:06 asl

Tagging @BradLarson

asl avatar Jun 08 '23 14:06 asl

@swift-ci please test

asl avatar Jun 14 '23 05:06 asl

@swift-ci please test

asl avatar Jun 14 '23 16:06 asl

@adrian-prantl ping :)

asl avatar Jun 14 '23 22:06 asl

@swift-ci please test

asl avatar Jun 19 '23 17:06 asl