[PATCH] Propagate -fno-unwind-tables to EHABI

Logan Chien tzuhsiang.chien at gmail.com
Tue Mar 18 11:52:39 PDT 2014


  Yes.  I am aware of the difference between the eh unwind table and stack unwind table.  In fact, I deliberately distinguished them in the my article discussing the problems with `nounwind` and `uwtable` attributes [1].

  Your change looks reasonable to me, i.e. we should emit .cantunwind regardless the existence of the `uwtable` attribute.  In fact, I had considered to do the same change when I was fixing an issue.

  However, the reality is that the run-time libraries rely on the eh unwind table to perform the stack unwinding (including for debugger and profiler.)  As far as I know, various unwinding libraries rely on the EHABI tables to perform backtraces.  That's why we can't emit .cantunwind when the `uwtable` attribute is available.  I remembered that in the mailing list [2][3], Rafael said he would prefer the unwind table emitted as what it was.  Besides, this behavior is same with the one generated by GCC.  I would suggest you to talk to Rafael before committing this change.

  There's some further discussion if applying this patch as-is is not viable:

  Originally, the behavior of the compiler is:
  (1) function without attributes ==> generate eh table
  (2) function with nounwind ==> generate eh table with cantunwind
  (3) function with uwtable ==> generate eh table
  (4) function with both attributes ==> generate eh table **without** cantunwind

  After your patch, the behavior becomes:
  (1) function without attributes ==> don't generate any table
  (2) function with nounwind ==> don't generate any table
  (3) function with uwtable ==> generate eh table
  (4) function with both attributes ==> generate eh table **with** cantunwind

  As you can see, this patch changes the behavior dramatically.  One solution is to change the condition to emit the cantunwind to `(!nounwind)` and change shouldEmitEH to `(uwtable || !nounwind)`.  Then,

  (1) function without attributes ==> don't generate any table
  (2) function with nounwind ==> generate eh table with cantunwind
  (3) function with uwtable ==> generate eh table
  (4) function with both attributes ==> generate eh table **without** cantunwind

  I think you can pass the existing test without changing the test case with this version.  But I guess this is not what you want.  The problem here is that if the uwtable semantics in [3] is adopted, there is no way to explicitly specify that "we don't want the unwinding table at all".  I don't see a good solution without adding a new attribute.  Feel free to correct me if I am wrong.

  Best regards,
  logan

  #Footnotes
  [1] http://loganchien.github.io/llvm/nounwind.html
  [2] http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-February/070416.html
  [3] http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-February/070417.html

http://llvm-reviews.chandlerc.com/D3079



More information about the llvm-commits mailing list