[PATCH] D18046: [X86] Providing correct unwind info in function epilogue

Violeta Vukobrat via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 8 05:15:51 PDT 2016


violetav added a comment.

Hi, I would like to propose a potential solution to this problem. If anyone knows a reason why this would fail, or if someone can think of a better way to do it, share your thoughts, help would be much appreciated. Here is the proposal:

- insert cfi instructions in epilogue during frame lowering

- add a flag to each MBB that specifies the type of that MBB based on its beginning and end cfi offset:
  - type 1: MBBs that are inside the prologue-epilogue path and have the same beginning and end offset (the one set by prologue)
  - type 2: prologue block that has initial frame offset as the beginning offset and sets its own end offset
  - type 3: epilogue blocks that have beginning offset the same as end prologue offset and end offset the same as initial frame offset
  - type 4: MBBs that are outside the prologue-epilogue path, that have beginning and end offset the same as the initial frame offset

Default value of the flag would be type 1. During frame lowering, prologue and epilogue blocks would have their appropriate flags set, as well as blocks that are outside the prologue-epilogue path. Maybe this could also be done in shrink wrapping, by finding predecessors of the prologue and successors of the epilogue. This would probably require some tree searching, but it would be limited to basic blocks outside of prologue-epilogue path. Does anyone know of a better way to find information about which blocks are outside of the prologue-epilogue path?

- teach tail duplication and any other pass that causes problems to allow cfi instructions in the epilogue and not to change the code generation

- maintain information about added flags throughout different passes (during merging, splitting of MBBs)

- the late pass would go through all MBBs while keeping track of the current cfi offset that is set and add cfi instructions if needed (based on the information from the added flags). Could information about offset set by the prologue be obtained from getStackSize() (for the case without FP)?

What are your thoughts? Can anyone think of something that breaks this solution? One thing that comes to mind would be the existence of multiple prologues, i.e. multiple prologue-epilogue pairs with different frame sizes. Can this happen in LLVM?


Repository:
  rL LLVM

http://reviews.llvm.org/D18046





More information about the llvm-commits mailing list