[PATCH] D74303: [CFI] cfi directive insertion for callee-save-registers in CFIInstrInserter pass

Wei Mi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 24 11:16:58 PDT 2020


wmi added a comment.

The original committed patch was reverted because a test failure in libc++ was reported.

The original patch only inserts .cfi_restore. A missing piece in the original patch is for some cases, it needs to generate .cfi_offset/.cfi_register as well. I attach a new patch which fixes the problem.

Here is a case just used to show where is the problem. In reality the test below won't expose the problem because we don't generate .cfi_restore in epilogue if it is a return block. Suppose the final machine code has the same layout as the c code below.

  int foo(bool cond) {
    // prologue: .cfi_offset $rbp 16
    if (cond) {
      b = 5;
      // epilogue: .cfi_restore $rbp
      return 2;
    } 
    // currently, we don't insert anything here, but we need to insert .cfi_offset $rbp 16 because at the place of 'a = 3', $rbp has not been restored to its value in previous frame yet. 
    a = 3;
    // epilogue: .cfi_restore $rbp
    return 3;
  }


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74303/new/

https://reviews.llvm.org/D74303





More information about the llvm-commits mailing list