[PATCH] D40979: [DWARF] Allow duplication of tails with CFI instructions

Francis Visoiu Mistrih via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 19 09:59:05 PST 2017

thegameg added a comment.

I think the bug described by @rnk in r317726 is still going to trigger with this patch.

The problem with compact unwind is that its purpose is to encode the unwind info for the **whole function**. This happens in AArch64AsmBackend.cpp, in the function `generateCompactUnwindEncoding`, where it tries to interpret the `.cfi_` directives and encode them to a specific format. Not all functions can be represented in AArch64's compact unwinding. Things like stack adjustments > 65520, `.cfi_offset` directives that don't come up as a save of pairs, and mostly everything that makes `generateCompactUnwindEncoding` return `CU::UNWIND_ARM64_MODE_DWARF` fall back to using regular DWARF for unwind info.

After we allow the duplication of `CFI_INSTRUCTIONS`, the `TailDuplicator` that runs in the `BasicBlockPlacement` pass duplicates a shrink-wrapped function prologue, and we end up with two prologues instead of one, which is not supported by compact unwinding (I am even wondering if any backtracer / debugger supports this). I am also wondering if we prevent a shrink-wrapped prologue to be duplicated in any way, or we're just lucky that it never happens because things like `CFI_INSTRUCTIONS` stay in its way. Just by looking at the code it seems that duplicating instructions with the `FrameSetup` flag is not prohibited...

In cases like this, we can probably teach the compact unwind generator to just fallback on DWARF for multiple prologues instead of asserting, even though I certainly say unwinders will act correctly on it.



More information about the llvm-commits mailing list