Page MenuHomePhabricator

[libunwind][AIX] Initial patch of the unwinder on AIX
Needs ReviewPublic

Authored by xingxue on Thu, Apr 8, 11:48 AM.

Details

Reviewers
rprichard
jasonliu
hubert.reinterpretcast
cebowleratibm
sfertile
ldionne
Group Reviewers
Restricted Project
Summary

This is the initial patch of the unwinder for IBM AIX.

  • AIX does not support the eh_frame section. Instead, the traceback table located at the end each function provides the information for stack unwinding and EH. In this patch macro _LIBUNWIND_SUPPORT_TBTAB_UNWIND is used to guard code for AIX traceback table based unwinding. Function getInfoFromTBTable() and stepWithTBTable() are added to get the EH information from the traceback table and to step up the stack respectively.
  • This patch supports two kinds of LSDA information for EH on AIX, the state table and the range table. The state table is used by the previous version of the IBM XL compiler, i.e., xlclang++. The DWARF based range table is used by AIX clang++. The traceback table has flags to differentiate these cases. For the range table, relative addresses are calculated using a base of DW_EH_PE_datarel, which is the TOC base of the module where the function of the current frame belongs.
  • Two personality routines are employed to handle these two different LSDAs, __xlcxx_personality_v0() for the state table and __xlcxx_personality_v1() for the range table. Since the traceback table does not have the information of the personality for the state table approach, its personality __xlcxx_personality_v0() is directly assigned as the handler for the state table. For the range table, the locations of the LSDA and its associated personality routine are found in the traceback table.
  • Assembly code for 32- and 64-bit PowerPC in UnwindRegistersRestore.S and UnwindRegistersSave.S are modified with macros to accommodate differences in the representation of things such as registers of the AIX assembly language. The restoration of vector registers does not check VRSAVE because in the AIX ABI, VRSAVE is not used.
  • No issues were found running tests of the libunwind and libcxxabi test suites, except some test cases of libunwind needs to be excluded for AIX and there are 7 libcxxabi test cases failing at the compile time. The LIT test will be addressed once the packaging of runtime libraries and the compiler for AIX is finalized.

Diff Detail

Event Timeline

xingxue created this revision.Thu, Apr 8, 11:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptThu, Apr 8, 11:48 AM
Herald added 1 blocking reviewer(s): Restricted Project. · View Herald Transcript
xingxue requested review of this revision.Thu, Apr 8, 11:48 AM
xingxue updated this revision to Diff 336198.Thu, Apr 8, 12:43 PM

Updated after running git-clang-format.

xingxue updated this revision to Diff 336214.Thu, Apr 8, 1:55 PM
xingxue set the repository for this revision to rG LLVM Github Monorepo.

Renamed variables in Unwind_AIXExtras.cpp.

xingxue updated this revision to Diff 336568.Fri, Apr 9, 2:50 PM

Fixed the issue caused by git-clang-format in file assembly.h.

ldionne resigned from this revision.Mon, Apr 12, 11:45 AM
ldionne added a subscriber: steven_wu.

Dear Reviewers.

The pre-commit check of this patch flagged clang-format and clang-tidy problems.

  • The clang-tidy failures are related to using of undeclared identifier UNW_STEP_END and UNW_STEP_SUCCESS. These macros are defined in <libunwind_ext.h> without any guarding conditions. I was able to build the patch on a PowerPC Linux system running 'Ubuntu 18.04.5' as well as AIX successfully. Maybe I missed something but I was unable to figure out why the AIX unwinder code would affect UNW_STEP_END and UNW_STEP_SUCCESS. It would be greatly appreciated if you could provide guidance on resolving it.
  • The clang-format flags the following issues <assembly.h>. I cannot really put a space between % and r as suggested because this represent the registers in assembly language, e.g., %r1, %f1. The assembler will complain if it is % r1, % f1. Again, any help would be greatly appreciated.
clang-format: please reformat the code

-#define GPR(num) %r##num
-#define FPR(num) %f##num
-#define VSR(num) %vs##num
-#define VR(num) %v##num
+#define GPR(num) % r##num
+#define FPR(num) % f##num
+#define VSR(num) % vs##num
+#define VR(num) % v##num
xingxue updated this revision to Diff 337240.Tue, Apr 13, 12:51 PM

Fixed some more assembly issues from the formatter.

lkail added a subscriber: lkail.Wed, Apr 14, 12:38 AM
xingxue edited the summary of this revision. (Show Details)Wed, Apr 14, 12:54 PM
xingxue added a reviewer: sfertile. xingxue removed 1 blocking reviewer(s): Restricted Project.
Herald added 1 blocking reviewer(s): Restricted Project. · View Herald TranscriptWed, Apr 14, 12:54 PM