r363939 - AIX system headers need stdint.h and inttypes.h to be re-enterable

2019-06-20 Thread Xing Xue via cfe-commits
Author: xingxue
Date: Thu Jun 20 08:36:32 2019
New Revision: 363939

URL: http://llvm.org/viewvc/llvm-project?rev=363939&view=rev
Log:
AIX system headers need stdint.h and inttypes.h to be re-enterable

Summary:
AIX system headers need stdint.h and inttypes.h to be re-enterable when macro 
_STD_TYPES_T is defined so that limit macro definitions such as UINT32_MAX can 
be found. This patch attempts to allow that on AIX.

Reviewers: hubert.reinterpretcast, jasonliu, mclow.lists, EricWF

Reviewed by: hubert.reinterpretcast, mclow.lists

Subscribers: jfb, jsji, christof, cfe-commits, libcxx-commits, llvm-commits

Tags: #LLVM, #clang, #libc++

Differential Revision: https://reviews.llvm.org/D59253

Modified:
cfe/trunk/lib/Headers/inttypes.h
cfe/trunk/lib/Headers/stdint.h

Modified: cfe/trunk/lib/Headers/inttypes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/inttypes.h?rev=363939&r1=363938&r2=363939&view=diff
==
--- cfe/trunk/lib/Headers/inttypes.h (original)
+++ cfe/trunk/lib/Headers/inttypes.h Thu Jun 20 08:36:32 2019
@@ -7,7 +7,12 @@
 
\*===--===*/
 
 #ifndef __CLANG_INTTYPES_H
+// AIX system headers need inttypes.h to be re-enterable while _STD_TYPES_T
+// is defined until an inclusion of it without _STD_TYPES_T occurs, in which
+// case the header guard macro is defined.
+#if !defined(_AIX) || !defined(_STD_TYPES_T)
 #define __CLANG_INTTYPES_H
+#endif
 
 #if defined(_MSC_VER) && _MSC_VER < 1800
 #error MSVC does not have inttypes.h prior to Visual Studio 2013

Modified: cfe/trunk/lib/Headers/stdint.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/stdint.h?rev=363939&r1=363938&r2=363939&view=diff
==
--- cfe/trunk/lib/Headers/stdint.h (original)
+++ cfe/trunk/lib/Headers/stdint.h Thu Jun 20 08:36:32 2019
@@ -7,7 +7,12 @@
 
\*===--===*/
 
 #ifndef __CLANG_STDINT_H
+// AIX system headers need stdint.h to be re-enterable while _STD_TYPES_T
+// is defined until an inclusion of it without _STD_TYPES_T occurs, in which
+// case the header guard macro is defined.
+#if !defined(_AIX) || !defined(_STD_TYPES_T) || !defined(__STDC_HOSTED__)
 #define __CLANG_STDINT_H
+#endif
 
 /* If we're hosted, fall back to the system's stdint.h, which might have
  * additional definitions.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r364462 - Print NULL as "(null)" in diagnostic message

2019-06-26 Thread Xing Xue via cfe-commits
Author: xingxue
Date: Wed Jun 26 12:27:16 2019
New Revision: 364462

URL: http://llvm.org/viewvc/llvm-project?rev=364462&view=rev
Log:
Print NULL as "(null)" in diagnostic message

Summary:
Passing a null pointer to the printf family for a %s format specifier leads to 
undefined behaviour. The tests currently expect (null). Explicitly test for a 
null pointer and provide the expected string.

Authored By: andusy

Reviewers: hubert.reinterpretcast, xingxue, jasonliu, daltenty, cebowleratibm

Reviewed By: hubert.reinterpretcast

Subscribers: arphaman, jsji, cfe-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D63786

Modified:
cfe/trunk/tools/c-index-test/c-index-test.c

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=364462&r1=364461&r2=364462&view=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Wed Jun 26 12:27:16 2019
@@ -1053,7 +1053,8 @@ static void PrintCursor(CXCursor Cursor,
 if (Cursor.kind == CXCursor_InclusionDirective) {
   CXFile File = clang_getIncludedFile(Cursor);
   CXString Included = clang_getFileName(File);
-  printf(" (%s)", clang_getCString(Included));
+  const char *IncludedString = clang_getCString(Included);
+  printf(" (%s)", IncludedString ? IncludedString : "(null)");
   clang_disposeString(Included);
   
   if (clang_isFileMultipleIncludeGuarded(TU, File))
@@ -4644,18 +4645,19 @@ static void printDiagnosticSet(CXDiagnos
 CXFile File;
 CXString FileName, DiagSpelling, DiagOption, DiagCat;
 unsigned line, column, offset;
-const char *DiagOptionStr = 0, *DiagCatStr = 0;
+const char *FileNameStr = 0, *DiagOptionStr = 0, *DiagCatStr = 0;
 
 D = clang_getDiagnosticInSet(Diags, i);
 DiagLoc = clang_getDiagnosticLocation(D);
 clang_getExpansionLocation(DiagLoc, &File, &line, &column, &offset);
 FileName = clang_getFileName(File);
+FileNameStr = clang_getCString(FileName);
 DiagSpelling = clang_getDiagnosticSpelling(D);
-
+
 printIndent(indent);
 
 fprintf(stderr, "%s:%d:%d: %s: %s",
-clang_getCString(FileName),
+FileNameStr ? FileNameStr : "(null)",
 line,
 column,
 getSeverityString(clang_getDiagnosticSeverity(D)),


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r360900 - Add AIX Version Macros

2019-05-16 Thread Xing Xue via cfe-commits
Author: xingxue
Date: Thu May 16 07:22:37 2019
New Revision: 360900

URL: http://llvm.org/viewvc/llvm-project?rev=360900&view=rev
Log:
Add AIX Version Macros

Summary:
- This patch checks the AIX version and defines the appropriate macros.
- Follow up to a comment on D59048.

Author: andusy

Reviewers: hubert.reinterpretcast, jasonliu, sfertile, xingxue

Reviewed By: sfertile

Subscribers: jsji, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D61530

Modified:
cfe/trunk/lib/Basic/Targets/OSTargets.h
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=360900&r1=360899&r2=360900&view=diff
==
--- cfe/trunk/lib/Basic/Targets/OSTargets.h (original)
+++ cfe/trunk/lib/Basic/Targets/OSTargets.h Thu May 16 07:22:37 2019
@@ -654,9 +654,25 @@ protected:
 Builder.defineMacro("_IBMR2");
 Builder.defineMacro("_POWER");
 
-// FIXME: Define AIX OS-Version Macros.
 Builder.defineMacro("_AIX");
 
+unsigned Major, Minor, Micro;
+Triple.getOSVersion(Major, Minor, Micro);
+
+// Define AIX OS-Version Macros.
+// Includes logic for legacy versions of AIX; no specific intent to 
support.
+std::pair OsVersion = {Major, Minor};
+if (OsVersion >= std::make_pair(3, 2)) Builder.defineMacro("_AIX32");
+if (OsVersion >= std::make_pair(4, 1)) Builder.defineMacro("_AIX41");
+if (OsVersion >= std::make_pair(4, 3)) Builder.defineMacro("_AIX43");
+if (OsVersion >= std::make_pair(5, 0)) Builder.defineMacro("_AIX50");
+if (OsVersion >= std::make_pair(5, 1)) Builder.defineMacro("_AIX51");
+if (OsVersion >= std::make_pair(5, 2)) Builder.defineMacro("_AIX52");
+if (OsVersion >= std::make_pair(5, 3)) Builder.defineMacro("_AIX53");
+if (OsVersion >= std::make_pair(6, 1)) Builder.defineMacro("_AIX61");
+if (OsVersion >= std::make_pair(7, 1)) Builder.defineMacro("_AIX71");
+if (OsVersion >= std::make_pair(7, 2)) Builder.defineMacro("_AIX72");
+
 // FIXME: Do not define _LONG_LONG when -fno-long-long is specified.
 Builder.defineMacro("_LONG_LONG");
 

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=360900&r1=360899&r2=360900&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Thu May 16 07:22:37 2019
@@ -7243,6 +7243,129 @@
 // PPC-AIX:#define __powerpc__ 1
 // PPC-AIX:#define __ppc__ 1
 //
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.2.0.0 < 
/dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX72 %s
+//
+// PPC-AIX72:#define _AIX32 1
+// PPC-AIX72:#define _AIX41 1
+// PPC-AIX72:#define _AIX43 1
+// PPC-AIX72:#define _AIX50 1
+// PPC-AIX72:#define _AIX51 1
+// PPC-AIX72:#define _AIX52 1
+// PPC-AIX72:#define _AIX53 1
+// PPC-AIX72:#define _AIX61 1
+// PPC-AIX72:#define _AIX71 1
+// PPC-AIX72:#define _AIX72 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 < 
/dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX71 %s
+//
+// PPC-AIX71:#define _AIX32 1
+// PPC-AIX71:#define _AIX41 1
+// PPC-AIX71:#define _AIX43 1
+// PPC-AIX71:#define _AIX50 1
+// PPC-AIX71:#define _AIX51 1
+// PPC-AIX71:#define _AIX52 1
+// PPC-AIX71:#define _AIX53 1
+// PPC-AIX71:#define _AIX61 1
+// PPC-AIX71:#define _AIX71 1
+// PPC-AIX71-NOT:#define _AIX72 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix6.1.0.0 < 
/dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX61 %s
+//
+// PPC-AIX61:#define _AIX32 1
+// PPC-AIX61:#define _AIX41 1
+// PPC-AIX61:#define _AIX43 1
+// PPC-AIX61:#define _AIX50 1
+// PPC-AIX61:#define _AIX51 1
+// PPC-AIX61:#define _AIX52 1
+// PPC-AIX61:#define _AIX53 1
+// PPC-AIX61:#define _AIX61 1
+// PPC-AIX61-NOT:#define _AIX71 1
+// PPC-AIX61-NOT:#define _AIX72 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix5.3.0.0 < 
/dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX53 %s
+// PPC-AIX53:#define _AIX32 1
+// PPC-AIX53:#define _AIX41 1
+// PPC-AIX53:#define _AIX43 1
+// PPC-AIX53:#define _AIX50 1
+// PPC-AIX53:#define _AIX51 1
+// PPC-AIX53:#define _AIX52 1
+// PPC-AIX53:#define _AIX53 1
+// PPC-AIX53-NOT:#define _AIX61 1
+// PPC-AIX53-NOT:#define _AIX71 1
+// PPC-AIX53-NOT:#define _AIX72 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix5.2.0.0 < 
/dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX52 %s
+// PPC-AIX52:#define _AIX32 1
+// PPC-AIX52:#define _AIX41 1
+// PPC-AIX52:#define _AIX43 1
+// PPC-AIX52:#define _AIX50 1
+// PPC-AIX52:#define _AIX51 1
+// PPC-AIX52:#define _AIX52 1
+// PPC-AIX52-NOT:#define _AIX53 1
+// PPC-AIX52-NOT:#define _AIX61 1
+// PPC-AIX52-NOT:#define _AIX71

[libunwind] 8408d3f - [libunwind] NFC: Use macros to accommodate differences in representation of PowerPC assemblers

2021-05-06 Thread Xing Xue via cfe-commits

Author: Xing Xue
Date: 2021-05-06T14:33:38-04:00
New Revision: 8408d3f2d814b19da450ff162f47981b55a9703a

URL: 
https://github.com/llvm/llvm-project/commit/8408d3f2d814b19da450ff162f47981b55a9703a
DIFF: 
https://github.com/llvm/llvm-project/commit/8408d3f2d814b19da450ff162f47981b55a9703a.diff

LOG: [libunwind] NFC: Use macros to accommodate differences in representation 
of PowerPC assemblers

Summary:
This NFC patch replaces the representation of registers and the left shift 
operator in the PowerPC assembly code to allow it to be consumed by the GNU 
flavored assembler and the AIX assembler.

* Registers - change the representation of PowperPC registers from %rn, %fn, 
%vsn, and %vrn to the register number alone, e.g., n. The GNU flavored 
assembler and the AIX assembler are able to determine the register kind based 
on the context of the instruction in which the register is used.

* Left shift operator - use macro PPC_LEFT_SHIFT to represent the left shift 
operator. The left shift operator in the AIX assembly language is < instead of 
<<

Reviewed by: sfertile, MaskRay, compnerd

Differential Revision: https://reviews.llvm.org/D101179

Added: 


Modified: 
libunwind/src/UnwindRegistersRestore.S
libunwind/src/UnwindRegistersSave.S
libunwind/src/assembly.h

Removed: 




diff  --git a/libunwind/src/UnwindRegistersRestore.S 
b/libunwind/src/UnwindRegistersRestore.S
index 6d12d93cb102..d8bf1adee416 100644
--- a/libunwind/src/UnwindRegistersRestore.S
+++ b/libunwind/src/UnwindRegistersRestore.S
@@ -134,7 +134,7 @@ 
DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind15Registers_ppc646jumptoEv)
 
 // load register (GPR)
 #define PPC64_LR(n) \
-  ld%r##n, (8 * (n + 2))(%r3)
+  ldn, (8 * (n + 2))(3)
 
   // restore integral registers
   // skip r0 for now
@@ -176,12 +176,12 @@ 
DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind15Registers_ppc646jumptoEv)
   // (note that this also restores floating point registers and V registers,
   // because part of VS is mapped to these registers)
 
-  addi  %r4, %r3, PPC64_OFFS_FP
+  addi  4, 3, PPC64_OFFS_FP
 
 // load VS register
 #define PPC64_LVS(n) \
-  lxvd2x  %vs##n, 0, %r4;\
-  addi%r4, %r4, 16
+  lxvd2x  n, 0, 4   ;\
+  addi4, 4, 16
 
   // restore the first 32 VS regs (and also all floating point regs)
   PPC64_LVS(0)
@@ -220,23 +220,23 @@ 
DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind15Registers_ppc646jumptoEv)
   // use VRSAVE to conditionally restore the remaining VS regs,
   // that are where the V regs are mapped
 
-  ld%r5, PPC64_OFFS_VRSAVE(%r3)   // test VRsave
-  cmpwi %r5, 0
+  ld5, PPC64_OFFS_VRSAVE(3)   // test VRsave
+  cmpwi 5, 0
   beq   Lnovec
 
 // conditionally load VS
 #define PPC64_CLVS_BOTTOM(n)   \
   beqLdone##n ;\
-  addi   %r4, %r3, PPC64_OFFS_FP + n * 16 ;\
-  lxvd2x %vs##n, 0, %r4   ;\
+  addi   4, 3, PPC64_OFFS_FP + n * 16 ;\
+  lxvd2x n, 0, 4  ;\
 Ldone##n:
 
-#define PPC64_CLVSl(n)   \
-  andis. %r0, %r5, (1<<(47-n))  ;\
+#define PPC64_CLVSl(n)\
+  andis. 0, 5, (1 PPC_LEFT_SHIFT(47-n))  ;\
 PPC64_CLVS_BOTTOM(n)
 
-#define PPC64_CLVSh(n)   \
-  andi.  %r0, %r5, (1<<(63-n))  ;\
+#define PPC64_CLVSh(n)\
+  andi.  0, 5, (1 PPC_LEFT_SHIFT(63-n))  ;\
 PPC64_CLVS_BOTTOM(n)
 
   PPC64_CLVSl(32)
@@ -276,7 +276,7 @@ PPC64_CLVS_BOTTOM(n)
 
 // load FP register
 #define PPC64_LF(n) \
-  lfd   %f##n, (PPC64_OFFS_FP + n * 16)(%r3)
+  lfd   n, (PPC64_OFFS_FP + n * 16)(3)
 
   // restore float registers
   PPC64_LF(0)
@@ -314,30 +314,30 @@ PPC64_CLVS_BOTTOM(n)
 
 #if defined(__ALTIVEC__)
   // restore vector registers if any are in use
-  ld%r5, PPC64_OFFS_VRSAVE(%r3)   // test VRsave
-  cmpwi %r5, 0
+  ld5, PPC64_OFFS_VRSAVE(3)   // test VRsave
+  cmpwi 5, 0
   beq   Lnovec
 
-  subi  %r4, %r1, 16
+  subi  4, 1, 16
   // r4 is now a 16-byte aligned pointer into the red zone
   // the _vectorScalarRegisters may not be 16-byte aligned
   // so copy via red zone temp buffer
 
 #define PPC64_CLV_UNALIGNED_BOTTOM(n)\
   beqLdone##n   ;\
-  ld %r0, (PPC64_OFFS_V + n * 16)(%r3)  ;\
-  std%r0, 0(%r4);\
-  ld %r0, (PPC64_OFFS_V + n * 16 + 8)(%r3)  ;\
-  std%r0, 8(%r4);\
-  lvx%v##n, 0, %r4  ;\
+  ld 0, (PPC64_OFFS_V + n * 16)(3)  ;\
+  std0, 0(4);\
+  ld 0, (PPC64_OFFS_V + n * 16 + 8)(3)  ;\
+  std0, 8(4);\
+  lvxn, 0, 4;\
 Ldone  ## n:
 
-#define PPC64_CLV_UNALIGNEDl(n)  \
-  andis. %r0, %r5, (1<<(15-n))  ;\
+#define PPC64_CLV_UNALIGNEDl(n) \
+  andis. 0, 5, (1 PPC_LEFT_SHIFT(15-n));\
 PPC64_CLV_UNALIGNE

[libunwind] a85da64 - [libunwind][AIX] implementation of the unwinder for AIX

2022-04-13 Thread Xing Xue via cfe-commits

Author: Xing Xue
Date: 2022-04-13T11:01:59-04:00
New Revision: a85da649b9ac67afffec6bff9487e6405e1f9cba

URL: 
https://github.com/llvm/llvm-project/commit/a85da649b9ac67afffec6bff9487e6405e1f9cba
DIFF: 
https://github.com/llvm/llvm-project/commit/a85da649b9ac67afffec6bff9487e6405e1f9cba.diff

LOG: [libunwind][AIX] implementation of the unwinder for AIX

Summary:
This patch contains the implementation of the unwinder for IBM AIX.

AIX does not support the eh_frame section. Instead, the traceback table located 
at the end of 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.

There are 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., xlC and 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 dynamically resolved 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 so that it can be consumed by the GNU flavor 
assembler and the AIX assembler. The restoration of vector registers does not 
check VRSAVE on AIX because VRSAVE is not used in the AIX ABI.

Reviewed by: MaskRay, compnerd, cebowleratibm, sfertile, libunwind

Differential Revision: https://reviews.llvm.org/D100132

Added: 
libunwind/src/Unwind_AIXExtras.cpp

Modified: 
libunwind/include/libunwind.h
libunwind/include/unwind.h
libunwind/src/AddressSpace.hpp
libunwind/src/CMakeLists.txt
libunwind/src/Registers.hpp
libunwind/src/UnwindCursor.hpp
libunwind/src/UnwindLevel1-gcc-ext.c
libunwind/src/UnwindLevel1.c
libunwind/src/UnwindRegistersRestore.S
libunwind/src/UnwindRegistersSave.S
libunwind/src/assembly.h
libunwind/src/config.h
libunwind/src/libunwind.cpp
libunwind/src/libunwind_ext.h

Removed: 




diff  --git a/libunwind/include/libunwind.h b/libunwind/include/libunwind.h
index 9a74faa48d6ff..a69e72fc132df 100644
--- a/libunwind/include/libunwind.h
+++ b/libunwind/include/libunwind.h
@@ -120,6 +120,9 @@ extern int unw_resume(unw_cursor_t *) LIBUNWIND_AVAIL;
 extern void unw_save_vfp_as_X(unw_cursor_t *) LIBUNWIND_AVAIL;
 #endif
 
+#ifdef _AIX
+extern uintptr_t unw_get_data_rel_base(unw_cursor_t *) LIBUNWIND_AVAIL;
+#endif
 
 extern const char *unw_regname(unw_cursor_t *, unw_regnum_t) LIBUNWIND_AVAIL;
 extern int unw_get_proc_info(unw_cursor_t *, unw_proc_info_t *) 
LIBUNWIND_AVAIL;

diff  --git a/libunwind/include/unwind.h b/libunwind/include/unwind.h
index b8d6020a33672..6557374fa9d31 100644
--- a/libunwind/include/unwind.h
+++ b/libunwind/include/unwind.h
@@ -160,7 +160,7 @@ extern const void *_Unwind_Find_FDE(const void *pc, struct 
dwarf_eh_bases *);
 extern void *_Unwind_FindEnclosingFunction(void *pc);
 
 // Mac OS X does not support text-rel and data-rel addressing so these 
functions
-// are unimplemented
+// are unimplemented.
 extern uintptr_t _Unwind_GetDataRelBase(struct _Unwind_Context *context)
 LIBUNWIND_UNAVAIL;
 extern uintptr_t _Unwind_GetTextRelBase(struct _Unwind_Context *context)

diff  --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp
index 0c4dfeb4e6834..3d5c001608d05 100644
--- a/libunwind/src/AddressSpace.hpp
+++ b/libunwind/src/AddressSpace.hpp
@@ -24,11 +24,11 @@
 #include "Registers.hpp"
 
 #ifndef _LIBUNWIND_USE_DLADDR
-  #if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
-#define _LIBUNWIND_USE_DLADDR 1
-  #else
-#define _LIBUNWIND_USE_DLADDR 0
-  #endif
+#if !(defined(_LIBUNWIND_IS_BAREMETAL) || defined(_WIN32) || defined(_AIX))
+#define _LIBUNWIND_USE_DLADDR 1
+#else
+#define _LIBUNWIND_USE_DLADDR 0
+#endif
 #endif
 
 #if _LIBUNWIND_USE_DLADDR
@@ -45,6 +45,13 @@ struct EHABIIndexEntry {
 };
 #endif
 
+#if defined(_AIX)
+namespace libunwind {
+char *getFuncNameFromTBTable(uintptr_t pc, uint16_t &NameLen,
+ unw_word_t *offset);
+}
+#endif
+
 #i

[libunwind] 9c0152c - [libunwind][AIX] implementation of the unwinder for AIX

2022-04-13 Thread Xing Xue via cfe-commits

Author: Xing Xue
Date: 2022-04-13T11:29:37-04:00
New Revision: 9c0152cda35f58ad9916b698c7a645d4a4dfeaf2

URL: 
https://github.com/llvm/llvm-project/commit/9c0152cda35f58ad9916b698c7a645d4a4dfeaf2
DIFF: 
https://github.com/llvm/llvm-project/commit/9c0152cda35f58ad9916b698c7a645d4a4dfeaf2.diff

LOG: [libunwind][AIX] implementation of the unwinder for AIX

Summary:
This is an add-on patch to address comments.
- Replace #elif in file  with #else as suggested;
- Reversed the indentation changes in the main patch.

Differential Revision: https://reviews.llvm.org/D100132

Added: 


Modified: 
libunwind/src/assembly.h
libunwind/src/config.h

Removed: 




diff  --git a/libunwind/src/assembly.h b/libunwind/src/assembly.h
index 9554ca8cc62b1..fb07d04071af3 100644
--- a/libunwind/src/assembly.h
+++ b/libunwind/src/assembly.h
@@ -209,7 +209,7 @@
 #if defined(__powerpc64__)
 #define VBYTE_LEN 8
 #define CSECT_ALIGN 3
-#elif defined(__ppc__)
+#else
 #define VBYTE_LEN 4
 #define CSECT_ALIGN 2
 #endif

diff  --git a/libunwind/src/config.h b/libunwind/src/config.h
index 7fd6b7334053e..e751860bd936e 100644
--- a/libunwind/src/config.h
+++ b/libunwind/src/config.h
@@ -60,13 +60,13 @@
   #define _LIBUNWIND_EXPORT
   #define _LIBUNWIND_HIDDEN
 #else
-#if !defined(__ELF__) && !defined(__MACH__) && !defined(_AIX)
-#define _LIBUNWIND_EXPORT __declspec(dllexport)
-#define _LIBUNWIND_HIDDEN
-#else
-#define _LIBUNWIND_EXPORT __attribute__((visibility("default")))
-#define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden")))
-#endif
+  #if !defined(__ELF__) && !defined(__MACH__) && !defined(_AIX)
+#define _LIBUNWIND_EXPORT __declspec(dllexport)
+#define _LIBUNWIND_HIDDEN
+  #else
+#define _LIBUNWIND_EXPORT __attribute__((visibility("default")))
+#define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden")))
+  #endif
 #endif
 
 #define STR(a) #a



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] 7165edc - [libunwind][AIX] implementation of the unwinder for AIX

2022-04-13 Thread Xing Xue via cfe-commits

Author: Xing Xue
Date: 2022-04-13T13:18:10-04:00
New Revision: 7165edcad76fec2e025414ddf44e76363806fc3d

URL: 
https://github.com/llvm/llvm-project/commit/7165edcad76fec2e025414ddf44e76363806fc3d
DIFF: 
https://github.com/llvm/llvm-project/commit/7165edcad76fec2e025414ddf44e76363806fc3d.diff

LOG: [libunwind][AIX] implementation of the unwinder for AIX

NFC - revert identation changes in AddressSpace.hpp from the previous commit

Differential Revision: https://reviews.llvm.org/D100132

Added: 


Modified: 
libunwind/src/AddressSpace.hpp

Removed: 




diff  --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp
index 3d5c001608d05..5fc9ee3fe6c38 100644
--- a/libunwind/src/AddressSpace.hpp
+++ b/libunwind/src/AddressSpace.hpp
@@ -24,11 +24,11 @@
 #include "Registers.hpp"
 
 #ifndef _LIBUNWIND_USE_DLADDR
-#if !(defined(_LIBUNWIND_IS_BAREMETAL) || defined(_WIN32) || defined(_AIX))
-#define _LIBUNWIND_USE_DLADDR 1
-#else
-#define _LIBUNWIND_USE_DLADDR 0
-#endif
+  #if !(defined(_LIBUNWIND_IS_BAREMETAL) || defined(_WIN32) || defined(_AIX))
+#define _LIBUNWIND_USE_DLADDR 1
+  #else
+#define _LIBUNWIND_USE_DLADDR 0
+  #endif
 #endif
 
 #if _LIBUNWIND_USE_DLADDR



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] dfaee3c - [libunwind][ci][AIX] Add libunwind to buildbot CI

2022-06-02 Thread Xing Xue via cfe-commits

Author: Xing Xue
Date: 2022-06-02T09:03:10-04:00
New Revision: dfaee3c9cfa17fce6af317ddcae89c6f6550cf94

URL: 
https://github.com/llvm/llvm-project/commit/dfaee3c9cfa17fce6af317ddcae89c6f6550cf94
DIFF: 
https://github.com/llvm/llvm-project/commit/dfaee3c9cfa17fce6af317ddcae89c6f6550cf94.diff

LOG: [libunwind][ci][AIX] Add libunwind to buildbot CI

Summary:
This patch changes scripts to add libunwind CI on AIX. Test config file 
ibm-libunwind-shared.cfg.in is introduced for testing on AIX.

Reviewed by: ldionne, MaskRay, libunwind, ibc++abi

Differential Revision: https://reviews.llvm.org/D126017

Added: 
libunwind/test/configs/ibm-libunwind-shared.cfg.in

Modified: 
libcxx/cmake/caches/AIX.cmake
libcxx/utils/ci/run-buildbot

Removed: 




diff  --git a/libcxx/cmake/caches/AIX.cmake b/libcxx/cmake/caches/AIX.cmake
index 029b8deae3d7..fcd4ec25ec20 100644
--- a/libcxx/cmake/caches/AIX.cmake
+++ b/libcxx/cmake/caches/AIX.cmake
@@ -14,3 +14,6 @@ set(LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
 set(LIBCXXABI_ENABLE_SHARED ON CACHE BOOL "")
 set(LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL "")
 set(LIBCXX_CXX_ABI libcxxabi CACHE STRING "")
+set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+set(LIBUNWIND_ENABLE_SHARED ON CACHE BOOL "")
+set(LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "")

diff  --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 2b9f129fd258..2213a3a46d3f 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -575,10 +575,8 @@ aix)
 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AIX.cmake" \
-DLIBCXX_TEST_CONFIG="ibm-libc++-shared.cfg.in" \
-DLIBCXXABI_TEST_CONFIG="ibm-libc++abi-shared.cfg.in" \
-   -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi"
-# TODO: use check-runtimes once libunwind builds cleanly on AIX.
-${NINJA} -vC "${BUILD_DIR}" install-cxx install-cxxabi
-${NINJA} -vC "${BUILD_DIR}" check-cxx check-cxxabi
+   -DLIBUNWIND_TEST_CONFIG="ibm-libunwind-shared.cfg.in"
+check-runtimes
 ;;
 #
 # Insert vendor-specific internal configurations below.

diff  --git a/libunwind/test/configs/ibm-libunwind-shared.cfg.in 
b/libunwind/test/configs/ibm-libunwind-shared.cfg.in
new file mode 100644
index ..c3c0ddd5c726
--- /dev/null
+++ b/libunwind/test/configs/ibm-libunwind-shared.cfg.in
@@ -0,0 +1,25 @@
+# Configuration file for running the libunwind tests on AIX.
+#
+
+lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
+
+config.substitutions.append(('%{flags}', ''))
+config.substitutions.append(('%{compile_flags}',
+'-nostdinc++ -I %{include} -I %{cxx-include}'
+))
+config.substitutions.append(('%{link_flags}',
+'-nostdlib++ -L %{lib} -lunwind -ldl -Wl,-bbigtoc'
+))
+config.substitutions.append(('%{exec}',
+'%{executor} --execdir %T --env LIBPATH=%{lib} -- '
+))
+
+import os, site
+site.addsitedir(os.path.join('@LIBUNWIND_LIBCXX_PATH@', 'utils'))
+import libcxx.test.params, libcxx.test.newconfig, libcxx.test.newconfig
+libcxx.test.newconfig.configure(
+libcxx.test.params.DEFAULT_PARAMETERS,
+libcxx.test.features.DEFAULT_FEATURES,
+config,
+lit_config
+)



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] 45d1511 - [libunwind][AIX] Fix problem with stepping up from a leaf function when unwinding started in a signal handler

2023-10-16 Thread Xing Xue via cfe-commits

Author: Xing Xue
Date: 2023-10-16T12:24:05-04:00
New Revision: 45d151138008c4880c8f9b77ffc43c23e0a9f1cb

URL: 
https://github.com/llvm/llvm-project/commit/45d151138008c4880c8f9b77ffc43c23e0a9f1cb
DIFF: 
https://github.com/llvm/llvm-project/commit/45d151138008c4880c8f9b77ffc43c23e0a9f1cb.diff

LOG: [libunwind][AIX] Fix problem with stepping up from a leaf function when 
unwinding started in a signal handler

Summary:
The implementation of AIX unwinder gets the return address from the link area 
of the stack frame of a function and uses the return address to walk up 
functions. However, when unwinding starts from a signal handler and the 
function that raised the signal happens to be a leaf function and it does not 
have its own stack frame, the return address of the stack frame of the leaf 
function points to the caller of the function that calls the leaf function 
because the leaf function and its caller share the same stack frame. As a 
result, the caller of the leaf function is skipped. This patch fixes the 
problem by saving the LR value in sigcontext when the unwinder hits the signal 
handler trampoline frame and using it as the return address of the leaf 
function. The LR value from sigcontext is saved in the unwinding context slot 
for LR currently unused.

Reviewed by: stephenpeckham

Differential Revision: https://reviews.llvm.org/D158655

Added: 
libunwind/test/aix_signal_unwind.pass.sh.S

Modified: 
libunwind/src/Registers.hpp
libunwind/src/UnwindCursor.hpp
libunwind/src/UnwindRegistersSave.S

Removed: 




diff  --git a/libunwind/src/Registers.hpp b/libunwind/src/Registers.hpp
index fb6e04e50fa1c7e..d11ddb3426d522e 100644
--- a/libunwind/src/Registers.hpp
+++ b/libunwind/src/Registers.hpp
@@ -619,6 +619,8 @@ class _LIBUNWIND_HIDDEN Registers_ppc {
   void  setIP(uint32_t value) { _registers.__srr0 = value; }
   uint64_t  getCR() const { return _registers.__cr; }
   void  setCR(uint32_t value) { _registers.__cr = value; }
+  uint64_t  getLR() const { return _registers.__lr; }
+  void  setLR(uint32_t value) { _registers.__lr = value; }
 
 private:
   struct ppc_thread_state_t {
@@ -1189,6 +1191,8 @@ class _LIBUNWIND_HIDDEN Registers_ppc64 {
   void  setIP(uint64_t value) { _registers.__srr0 = value; }
   uint64_t  getCR() const { return _registers.__cr; }
   void  setCR(uint64_t value) { _registers.__cr = value; }
+  uint64_t  getLR() const { return _registers.__lr; }
+  void  setLR(uint64_t value) { _registers.__lr = value; }
 
 private:
   struct ppc64_thread_state_t {

diff  --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index dde94773bc34170..f89c5b2c2f73e33 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -2301,27 +2301,39 @@ int UnwindCursor::stepWithTBTable(pint_t pc, 
tbtable *TBTable,
 if (!getFunctionName(functionBuf, sizeof(functionBuf), &offset)) {
   functionName = ".anonymous.";
 }
-_LIBUNWIND_TRACE_UNWINDING("%s: Look up traceback table of func=%s at %p",
-   __func__, functionName,
-   reinterpret_cast(TBTable));
+_LIBUNWIND_TRACE_UNWINDING(
+"%s: Look up traceback table of func=%s at %p, pc=%p, "
+"SP=%p, saves_lr=%d, stores_bc=%d",
+__func__, functionName, reinterpret_cast(TBTable),
+reinterpret_cast(pc),
+reinterpret_cast(registers.getSP()), TBTable->tb.saves_lr,
+TBTable->tb.stores_bc);
   }
 
 #if defined(__powerpc64__)
-  // Instruction to reload TOC register "l r2,40(r1)"
+  // Instruction to reload TOC register "ld r2,40(r1)"
   const uint32_t loadTOCRegInst = 0xe8410028;
   const int32_t unwPPCF0Index = UNW_PPC64_F0;
   const int32_t unwPPCV0Index = UNW_PPC64_V0;
 #else
-  // Instruction to reload TOC register "l r2,20(r1)"
+  // Instruction to reload TOC register "lwz r2,20(r1)"
   const uint32_t loadTOCRegInst = 0x80410014;
   const int32_t unwPPCF0Index = UNW_PPC_F0;
   const int32_t unwPPCV0Index = UNW_PPC_V0;
 #endif
 
+  // lastStack points to the stack frame of the next routine up.
+  pint_t curStack = static_cast(registers.getSP());
+  pint_t lastStack = *reinterpret_cast(curStack);
+
+  if (lastStack == 0)
+return UNW_STEP_END;
+
   R newRegisters = registers;
 
-  // lastStack points to the stack frame of the next routine up.
-  pint_t lastStack = *(reinterpret_cast(registers.getSP()));
+  // If backchain is not stored, use the current stack frame.
+  if (!TBTable->tb.stores_bc)
+lastStack = curStack;
 
   // Return address is the address after call site instruction.
   pint_t returnAddress;
@@ -2331,33 +2343,41 @@ int UnwindCursor::stepWithTBTable(pint_t pc, 
tbtable *TBTable,
reinterpret_cast(lastStack));
 
 sigcontext *sigContext = reinterpret_cast(
-reinterpret_cast(lastSta

[clang] [clang] Default to -fno-sized-deallocation for AIX (PR #97076)

2024-06-28 Thread Xing Xue via cfe-commits

https://github.com/xingxue-ibm created 
https://github.com/llvm/llvm-project/pull/97076

Some `libc++` LIT test cases and user code define their own version of 
`operator delete` that are not sized. With `-fno-sized-deallocation`, 
destructors call the non-sized `operator delete` and it will be resolved to the 
user defined version. However, with `-fsized-deallocation`, destructors will 
call the sized `operator delete` which will be resolved to the weak definition 
in `libc++abi` because the user code does not define the corresponding sized 
version. The `libc++abi` sized `operator delete` in turn calls the non-sized 
version of `operator delete` of the same shared object inside `libc++abi` 
instead of the user defined version on AIX because runtime linking is not the 
default for AIX and therefore, fails the tests or user code. This patch sets 
`-fno-sized-deallocation` as the default for AIX if neither 
`-fsize-deallocation` nor `-fno-sized-deallocation` is explicitly set, similar 
to what is done for ZOS.

>From d6a486c4f007297d087fe4454da3ec501e824825 Mon Sep 17 00:00:00 2001
From: Xing Xue 
Date: Fri, 28 Jun 2024 11:25:25 -0400
Subject: [PATCH] Default to -fno-sized-deallocation for AIX.

---
 clang/lib/Driver/ToolChains/AIX.cpp  | 6 ++
 clang/unittests/StaticAnalyzer/CallEventTest.cpp | 4 
 2 files changed, 10 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 381d72e045b95..b04502a57a9f7 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -551,6 +551,12 @@ void AIX::addClangTargetOptions(
   if (Args.hasFlag(options::OPT_fxl_pragma_pack,
options::OPT_fno_xl_pragma_pack, true))
 CC1Args.push_back("-fxl-pragma-pack");
+
+  // Pass "-fno-sized-deallocation" only when the user hasn't manually enabled
+  // or disabled sized deallocations.
+  if (!Args.getLastArgNoClaim(options::OPT_fsized_deallocation,
+  options::OPT_fno_sized_deallocation))
+CC1Args.push_back("-fno-sized-deallocation");
 }
 
 void AIX::addProfileRTLibs(const llvm::opt::ArgList &Args,
diff --git a/clang/unittests/StaticAnalyzer/CallEventTest.cpp 
b/clang/unittests/StaticAnalyzer/CallEventTest.cpp
index 7c4132788ca7e..de28bb158ef66 100644
--- a/clang/unittests/StaticAnalyzer/CallEventTest.cpp
+++ b/clang/unittests/StaticAnalyzer/CallEventTest.cpp
@@ -76,7 +76,11 @@ TEST(CXXDeallocatorCall, SimpleDestructor) {
 }
   )",
  Diags));
+#if !defined(__cpp_sized_deallocation)
+  EXPECT_EQ(Diags, "test.CXXDeallocator: NumArgs: 1\n");
+#else
   EXPECT_EQ(Diags, "test.CXXDeallocator: NumArgs: 2\n");
+#endif
 }
 
 } // namespace

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Default to -fno-sized-deallocation for AIX (PR #97076)

2024-06-29 Thread Xing Xue via cfe-commits

https://github.com/xingxue-ibm updated 
https://github.com/llvm/llvm-project/pull/97076

>From d6a486c4f007297d087fe4454da3ec501e824825 Mon Sep 17 00:00:00 2001
From: Xing Xue 
Date: Fri, 28 Jun 2024 11:25:25 -0400
Subject: [PATCH 1/2] Default to -fno-sized-deallocation for AIX.

---
 clang/lib/Driver/ToolChains/AIX.cpp  | 6 ++
 clang/unittests/StaticAnalyzer/CallEventTest.cpp | 4 
 2 files changed, 10 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 381d72e045b95..b04502a57a9f7 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -551,6 +551,12 @@ void AIX::addClangTargetOptions(
   if (Args.hasFlag(options::OPT_fxl_pragma_pack,
options::OPT_fno_xl_pragma_pack, true))
 CC1Args.push_back("-fxl-pragma-pack");
+
+  // Pass "-fno-sized-deallocation" only when the user hasn't manually enabled
+  // or disabled sized deallocations.
+  if (!Args.getLastArgNoClaim(options::OPT_fsized_deallocation,
+  options::OPT_fno_sized_deallocation))
+CC1Args.push_back("-fno-sized-deallocation");
 }
 
 void AIX::addProfileRTLibs(const llvm::opt::ArgList &Args,
diff --git a/clang/unittests/StaticAnalyzer/CallEventTest.cpp 
b/clang/unittests/StaticAnalyzer/CallEventTest.cpp
index 7c4132788ca7e..de28bb158ef66 100644
--- a/clang/unittests/StaticAnalyzer/CallEventTest.cpp
+++ b/clang/unittests/StaticAnalyzer/CallEventTest.cpp
@@ -76,7 +76,11 @@ TEST(CXXDeallocatorCall, SimpleDestructor) {
 }
   )",
  Diags));
+#if !defined(__cpp_sized_deallocation)
+  EXPECT_EQ(Diags, "test.CXXDeallocator: NumArgs: 1\n");
+#else
   EXPECT_EQ(Diags, "test.CXXDeallocator: NumArgs: 2\n");
+#endif
 }
 
 } // namespace

>From 612f60e20ba45dd91cd6722a8df33410f452127e Mon Sep 17 00:00:00 2001
From: Xing Xue 
Date: Sat, 29 Jun 2024 19:35:18 -0400
Subject: [PATCH 2/2] Guard the NumArgs check with OS macros instead of
 __cpp_sized_deallocation because the latter is not defined for the test.

---
 clang/unittests/StaticAnalyzer/CallEventTest.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/unittests/StaticAnalyzer/CallEventTest.cpp 
b/clang/unittests/StaticAnalyzer/CallEventTest.cpp
index de28bb158ef66..987162f9fdf34 100644
--- a/clang/unittests/StaticAnalyzer/CallEventTest.cpp
+++ b/clang/unittests/StaticAnalyzer/CallEventTest.cpp
@@ -76,7 +76,8 @@ TEST(CXXDeallocatorCall, SimpleDestructor) {
 }
   )",
  Diags));
-#if !defined(__cpp_sized_deallocation)
+#if defined(_AIX) || defined(__MVS__)
+  // AIX and ZOS default to -fno-sized-deallocation.
   EXPECT_EQ(Diags, "test.CXXDeallocator: NumArgs: 1\n");
 #else
   EXPECT_EQ(Diags, "test.CXXDeallocator: NumArgs: 2\n");

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Default to -fno-sized-deallocation for AIX (PR #97076)

2024-07-01 Thread Xing Xue via cfe-commits

https://github.com/xingxue-ibm closed 
https://github.com/llvm/llvm-project/pull/97076
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] [libunwind][AIX] Cast NULL as type uintptr_t. (PR #93204)

2024-05-23 Thread Xing Xue via cfe-commits

https://github.com/xingxue-ibm created 
https://github.com/llvm/llvm-project/pull/93204

Casting NULL as type `uintptr_t` to allow type checking in both 32-bit and 
64-bit mode.

>From 1e21301d3b07bd72696f39a0ca8cd19907cdcf71 Mon Sep 17 00:00:00 2001
From: Xing Xue 
Date: Thu, 23 May 2024 10:51:32 -0400
Subject: [PATCH] Cast NULL as type uintptr_t.

---
 libunwind/src/UnwindCursor.hpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 7753936a5894a..66fe8e2a32cca 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -2416,7 +2416,7 @@ int UnwindCursor::stepWithTBTable(pint_t pc, 
tbtable *TBTable,
 }
 
 // Reset LR in the current context.
-newRegisters.setLR(NULL);
+newRegisters.setLR(static_cast(NULL));
 
 _LIBUNWIND_TRACE_UNWINDING(
 "Extract info from lastStack=%p, returnAddress=%p",

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] [libunwind][AIX] Cast NULL as type uintptr_t. (PR #93204)

2024-05-23 Thread Xing Xue via cfe-commits

xingxue-ibm wrote:

> LGTM, assuming the CI passes

Thanks! Seems 3 failures are unrelated.

https://github.com/llvm/llvm-project/pull/93204
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] [libunwind][AIX] Cast NULL as type uintptr_t. (PR #93204)

2024-05-23 Thread Xing Xue via cfe-commits

https://github.com/xingxue-ibm closed 
https://github.com/llvm/llvm-project/pull/93204
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] cc8edbe - [libunwind][AIX] Save/restore errno before/after system calls dlopen/dlsym/dlclose

2022-08-08 Thread Xing Xue via cfe-commits

Author: Xing Xue
Date: 2022-08-08T17:21:30-04:00
New Revision: cc8edbea7a5f26906ae3d1f7ba0dc5da8fc5afb5

URL: 
https://github.com/llvm/llvm-project/commit/cc8edbea7a5f26906ae3d1f7ba0dc5da8fc5afb5
DIFF: 
https://github.com/llvm/llvm-project/commit/cc8edbea7a5f26906ae3d1f7ba0dc5da8fc5afb5.diff

LOG: [libunwind][AIX] Save/restore errno before/after system calls 
dlopen/dlsym/dlclose

Summary:
libunwind on AIX calls dlopen()/dlsym()/dlclose() to dynamically load libc++abi 
and get the personality for state table EH when it is running against the 
legacy xlcang++ compiler genereated applications. dlopen() sets errno to 0 when 
it is successful, which clobbers the value in errno from the user code. This 
seems to be an AIX bug that it should not set errno to 0 according to POSIX. We 
will open a bug report to AIX but in the mean time there won't be time line 
when AIX will have a fix and even AIX does fix it, it won't help earlier AIX 
releases in the field. This patch saves and restores errno before and after 
these calls so that user code can work as expected.

Reviewed by: compnerd, libunwind

Differential Revision: https://reviews.llvm.org/D131292

Added: 


Modified: 
libunwind/src/UnwindCursor.hpp

Removed: 




diff  --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index b8bd9bc59010..d325ed5f0eea 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -2106,6 +2106,11 @@ bool UnwindCursor::getInfoFromTBTable(pint_t pc, R 
®isters) {
   // using dlopen().
   const char libcxxabi[] = "libc++abi.a(libc++abi.so.1)";
   void *libHandle;
+  // The AIX dlopen() sets errno to 0 when it is successful, which
+  // clobbers the value of errno from the user code. This is an AIX
+  // bug because according to POSIX it should not set errno to 0. To
+  // workaround before AIX fixes the bug, errno is saved and restored.
+  int saveErrno = errno;
   libHandle = dlopen(libcxxabi, RTLD_MEMBER | RTLD_NOW);
   if (libHandle == NULL) {
 _LIBUNWIND_TRACE_UNWINDING("dlopen() failed with errno=%d\n",
@@ -2119,6 +2124,7 @@ bool UnwindCursor::getInfoFromTBTable(pint_t pc, R 
®isters) {
 assert(0 && "dlsym() failed");
   }
   dlclose(libHandle);
+  errno = saveErrno;
 }
   }
   xlcPersonalityV0InitLock.unlock();



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] 2366c6a - [libunwind][AIX] Implement _Unwind_FindEnclosingFunction() using traceback table on AIX

2022-08-12 Thread Xing Xue via cfe-commits

Author: Xing Xue
Date: 2022-08-12T18:07:56-04:00
New Revision: 2366c6adfc95e1aca9afbbbf5251a61552865b55

URL: 
https://github.com/llvm/llvm-project/commit/2366c6adfc95e1aca9afbbbf5251a61552865b55
DIFF: 
https://github.com/llvm/llvm-project/commit/2366c6adfc95e1aca9afbbbf5251a61552865b55.diff

LOG: [libunwind][AIX] Implement _Unwind_FindEnclosingFunction() using traceback 
table on AIX

Summary:
The implementation of  _Unwind_FindEnclosingFunction(void *ip) takes the 
context of itself and then uses the context to get the info of the function 
enclosing ip. This approach does not work for AIX because on AIX, the TOC base 
in GPR2 is used as the base for calculating relative addresses. Since  
_Unwind_FindEnclosingFunction() may be in a different shared lib than the 
function containing ip, their TOC bases can be different. Therefore, using the 
value of GPR2 in the context from  _Unwind_FindEnclosingFunction() as the base 
results in incorrect addresses. On the other hand, the start address of a 
function is available in the traceback table following the instructions of each 
function on AIX. To get to the traceback table, search a word of 0 starting 
from ip and the traceback table is located after the word 0. This patch 
implements _Unwind_FindEnclosingFunction() for AIX by obtaining the function 
start address from its traceback table.

Reviewed by: compnerd, MaskRay, libunwind

Differential Revision: https://reviews.llvm.org/D131709

Added: 


Modified: 
libunwind/src/UnwindLevel1-gcc-ext.c
libunwind/src/Unwind_AIXExtras.cpp

Removed: 




diff  --git a/libunwind/src/UnwindLevel1-gcc-ext.c 
b/libunwind/src/UnwindLevel1-gcc-ext.c
index 0250664bbc7e..e24fcc3caddf 100644
--- a/libunwind/src/UnwindLevel1-gcc-ext.c
+++ b/libunwind/src/UnwindLevel1-gcc-ext.c
@@ -22,6 +22,10 @@
 #include "Unwind-EHABI.h"
 #include "unwind.h"
 
+#if defined(_AIX)
+#include 
+#endif
+
 #if defined(_LIBUNWIND_BUILD_ZERO_COST_APIS)
 
 #if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
@@ -82,6 +86,32 @@ _Unwind_GetTextRelBase(struct _Unwind_Context *context) {
 /// specified code address "pc".
 _LIBUNWIND_EXPORT void *_Unwind_FindEnclosingFunction(void *pc) {
   _LIBUNWIND_TRACE_API("_Unwind_FindEnclosingFunction(pc=%p)", pc);
+#if defined(_AIX)
+  if (pc == NULL)
+return NULL;
+
+  // Get the start address of the enclosing function from the function's
+  // traceback table.
+  uint32_t *p = (uint32_t *)pc;
+
+  // Keep looking forward until a word of 0 is found. The traceback
+  // table starts at the following word.
+  while (*p)
+++p;
+  struct tbtable *TBTable = (struct tbtable *)(p + 1);
+
+  // Get the address of the traceback table extension.
+  p = (uint32_t *)&TBTable->tb_ext;
+
+  // Skip field parminfo if it exists.
+  if (TBTable->tb.fixedparms || TBTable->tb.floatparms)
+++p;
+
+  if (TBTable->tb.has_tboff)
+// *p contains the offset from the function start to traceback table.
+return (void *)((uintptr_t)TBTable - *p - sizeof(uint32_t));
+  return NULL;
+#else
   // This is slow, but works.
   // We create an unwind cursor then alter the IP to be pc
   unw_cursor_t cursor;
@@ -94,6 +124,7 @@ _LIBUNWIND_EXPORT void *_Unwind_FindEnclosingFunction(void 
*pc) {
 return (void *)(intptr_t) info.start_ip;
   else
 return NULL;
+#endif
 }
 
 /// Walk every frame and call trace function at each one.  If trace function

diff  --git a/libunwind/src/Unwind_AIXExtras.cpp 
b/libunwind/src/Unwind_AIXExtras.cpp
index 7e47f70186e7..66194ab4a16b 100644
--- a/libunwind/src/Unwind_AIXExtras.cpp
+++ b/libunwind/src/Unwind_AIXExtras.cpp
@@ -38,7 +38,7 @@ char *getFuncNameFromTBTable(uintptr_t Pc, uint16_t &NameLen,
   if (TBTable->tb.fixedparms || TBTable->tb.floatparms)
 p++;
 
-  // If the tb_offset field exisits, get the offset from the start of
+  // If the tb_offset field exists, get the offset from the start of
   // the function to pc. Skip the field.
   if (TBTable->tb.has_tboff) {
 unw_word_t StartIp =



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fa7477e - [Clang][CodeGen][AIX] Map __builtin_frexpl, __builtin_ldexpl, and __builtin_modfl to 'double' version lib calls in 64-bit 'long double' mode

2022-11-18 Thread Xing Xue via cfe-commits

Author: Xing Xue
Date: 2022-11-18T11:36:56-05:00
New Revision: fa7477eb87fd262898e78db983c7b0951b87641c

URL: 
https://github.com/llvm/llvm-project/commit/fa7477eb87fd262898e78db983c7b0951b87641c
DIFF: 
https://github.com/llvm/llvm-project/commit/fa7477eb87fd262898e78db983c7b0951b87641c.diff

LOG: [Clang][CodeGen][AIX] Map __builtin_frexpl, __builtin_ldexpl, and 
__builtin_modfl to 'double' version lib calls in 64-bit 'long double' mode

Summary:
AIX library functions frexpl(), ldexpl(), and modfl() are for 128-bit IBM long 
double, i.e. __ibm128. Other *l() functions, e.g., acosl(), are for 64-bit long 
double. The AIX Clang compiler currently maps builtin functions 
__builtin_frexpl(), __builtin_ldexpl(), and __builtin_modfl() to frexpl(), 
ldexpl(), and modfl() in 64-bit long double mode which results in seg-faults or 
incorrect return values. This patch changes to map __builtin_frexpl(), 
__builtin_ldexpl(), and __builtin_modfl() to double version lib functions 
frexp(), ldexp() and modf() in 64-bit long double mode.

Reviewed by: hubert.reinterpretcast, daltenty

Differential Revision: https://reviews.llvm.org/D137986

Added: 
clang/test/CodeGen/aix-builtin-mapping.c

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 50b0eaed82ec6..6000478bf545e 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -106,6 +106,15 @@ llvm::Constant *CodeGenModule::getBuiltinLibFunction(const 
FunctionDecl *FD,
   {Builtin::BI__builtin_nexttowardf128, "__nexttowardieee128"},
   };
 
+  // The AIX library functions frexpl, ldexpl, and modfl are for 128-bit
+  // IBM 'long double' (i.e. __ibm128). Map to the 'double' versions
+  // if it is 64-bit 'long double' mode.
+  static SmallDenseMap AIXLongDouble64Builtins{
+  {Builtin::BI__builtin_frexpl, "frexp"},
+  {Builtin::BI__builtin_ldexpl, "ldexp"},
+  {Builtin::BI__builtin_modfl, "modf"},
+  };
+
   // If the builtin has been declared explicitly with an assembler label,
   // use the mangled name. This 
diff ers from the plain label on platforms
   // that prefix labels.
@@ -118,6 +127,12 @@ llvm::Constant *CodeGenModule::getBuiltinLibFunction(const 
FunctionDecl *FD,
 &getTarget().getLongDoubleFormat() == &llvm::APFloat::IEEEquad() &&
 F128Builtins.find(BuiltinID) != F128Builtins.end())
   Name = F128Builtins[BuiltinID];
+else if (getTriple().isOSAIX() &&
+ &getTarget().getLongDoubleFormat() ==
+ &llvm::APFloat::IEEEdouble() &&
+ AIXLongDouble64Builtins.find(BuiltinID) !=
+ AIXLongDouble64Builtins.end())
+  Name = AIXLongDouble64Builtins[BuiltinID];
 else
   Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
   }

diff  --git a/clang/test/CodeGen/aix-builtin-mapping.c 
b/clang/test/CodeGen/aix-builtin-mapping.c
new file mode 100644
index 0..57ea558652e1a
--- /dev/null
+++ b/clang/test/CodeGen/aix-builtin-mapping.c
@@ -0,0 +1,22 @@
+// AIX library functions frexpl, ldexpl, and modfl are for 128-bit IBM
+// 'long double' (i.e. __ibm128). Check that the compiler generates
+// calls to the 'double' versions for corresponding builtin functions in
+// 64-bit 'long double' mode.
+
+// RUN: %clang_cc1 -triple powerpc-ibm-aix -mlong-double-64 -emit-llvm -o - %s 
| FileCheck -check-prefix=CHECK %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix -mlong-double-64 -emit-llvm -o - 
%s | FileCheck -check-prefix=CHECK %s
+
+int main()
+{
+  int DummyInt;
+  long double DummyLongDouble;
+  long double returnValue;
+
+  returnValue = __builtin_modfl(1.0L, &DummyLongDouble);
+  returnValue = __builtin_frexpl(0.0L, &DummyInt);
+  returnValue = __builtin_ldexpl(1.0L, 1);
+}
+
+// CHECK: %call = call double @modf(double noundef 1.00e+00, ptr noundef 
%DummyLongDouble) #3
+// CHECK: %call1 = call double @frexp(double noundef 0.00e+00, ptr noundef 
%DummyInt) #3
+// CHECK: %call2 = call double @ldexp(double noundef 1.00e+00, i32 noundef 
{{(signext )?}}1) #4



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] 11982ee - [libunwind][AIX] Mark signal_frame.pass.cpp UNSUPPORTED on AIX

2021-11-18 Thread Xing Xue via cfe-commits

Author: Xing Xue
Date: 2021-11-18T10:24:58-05:00
New Revision: 11982eed2bc818fdbd525e3237a77a3efeb6a497

URL: 
https://github.com/llvm/llvm-project/commit/11982eed2bc818fdbd525e3237a77a3efeb6a497
DIFF: 
https://github.com/llvm/llvm-project/commit/11982eed2bc818fdbd525e3237a77a3efeb6a497.diff

LOG: [libunwind][AIX] Mark signal_frame.pass.cpp UNSUPPORTED on AIX

Summary:
This patch marks libunwind test case signal_frame.pass.cpp as UNSUPPORTED on 
AIX because the AIX assembler does not support CFI directives.

Reviewed by: danielkiss, MaskRay, ldionne, libunwind

Differential Revision: https://reviews.llvm.org/D113607

Added: 


Modified: 
libunwind/test/signal_frame.pass.cpp

Removed: 




diff  --git a/libunwind/test/signal_frame.pass.cpp 
b/libunwind/test/signal_frame.pass.cpp
index cfd4f484a18b7..513eef53bbc6c 100644
--- a/libunwind/test/signal_frame.pass.cpp
+++ b/libunwind/test/signal_frame.pass.cpp
@@ -17,6 +17,10 @@
 
 // UNSUPPORTED: libunwind-arm-ehabi
 
+// The AIX assembler does not support CFI directives, which
+// are necessary to run this test.
+// UNSUPPORTED: target=powerpc{{(64)?}}-ibm-aix
+
 #include 
 #include 
 #include 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b05fa4f - [clang][driver][AIX] Add OpenMP runtime if -fopenmp specified

2023-01-19 Thread Xing Xue via cfe-commits

Author: Xing Xue
Date: 2023-01-19T12:46:22-05:00
New Revision: b05fa4faf64d6c6811bbecead13dc7c23ac43aca

URL: 
https://github.com/llvm/llvm-project/commit/b05fa4faf64d6c6811bbecead13dc7c23ac43aca
DIFF: 
https://github.com/llvm/llvm-project/commit/b05fa4faf64d6c6811bbecead13dc7c23ac43aca.diff

LOG: [clang][driver][AIX] Add OpenMP runtime if -fopenmp specified

Summary:
This patch adds OpenMP runtime to the linker command line if -fopenmp is 
specifed for AIX.

Reviewed by: daltenty

Differential Revision: https://reviews.llvm.org/D141862

Added: 


Modified: 
clang/lib/Driver/ToolChains/AIX.cpp
clang/test/Driver/aix-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 5f893ba6e8918..abbd3ef6c68f3 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -243,6 +243,25 @@ void aix::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
+// Add OpenMP runtime if -fopenmp is specified.
+if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+ options::OPT_fno_openmp, false)) {
+  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+  case Driver::OMPRT_OMP:
+CmdArgs.push_back("-lomp");
+break;
+  case Driver::OMPRT_IOMP5:
+CmdArgs.push_back("-liomp5");
+break;
+  case Driver::OMPRT_GOMP:
+CmdArgs.push_back("-lgomp");
+break;
+  case Driver::OMPRT_Unknown:
+// Already diagnosed.
+break;
+  }
+}
+
 // Support POSIX threads if "-pthreads" or "-pthread" is present.
 if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
   CmdArgs.push_back("-lpthreads");

diff  --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index 42631f4c59eee..ddf3ae7a2ecb4 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -1016,3 +1016,68 @@
 // CHECK-LD64-SHARED-EXPFULL: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc64.a"
 // CHECK-LD64-SHARED-EXPFULL: "-lm"
 // CHECK-LD64-SHARED-EXPFULL: "-lc"
+
+// Check powerpc-ibm-aix7.1.0.0. -fopenmp to use default OpenMP runtime libomp.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-fopenmp \
+// RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP,CHECK-FOPENMP-OMP %s
+// CHECK-FOPENMP-NOT: warning:
+// CHECK-FOPENMP: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-FOPENMP: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-FOPENMP: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-FOPENMP: "{{.*}}ld{{(.exe)?}}"
+// CHECK-FOPENMP-NOT: "-bnso"
+// CHECK-FOPENMP: "-b32"
+// CHECK-FOPENMP: "-bpT:0x1000" "-bpD:0x2000"
+// CHECK-FOPENMP: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-FOPENMP: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-FOPENMP-NOT: "-lc++"
+// CHECK-FOPENMP-NOT: "-lc++abi"
+// CHECK-FOPENMP: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aix{{/|}}libclang_rt.builtins-powerpc.a"
+// CHECK-FOPENMP-NOT: "--as-needed"
+// CHECK-FOPENMP: "-lunwind"
+// CHECK-FOPENMP-NOT: "--no-as-needed"
+// CHECK-FOPENMP-NOT: "-lm"
+// CHECK-FOPENMP-OMP: "-lomp"
+// CHECK-FOPENMP-IOMP5:   "-liomp5"
+// CHECK-FOPENMP-GOMP:"-lgomp"
+// CHECK-FOPENMP: "-lc"
+
+// Check powerpc-ibm-aix7.1.0.0. -fopenmp=libomp to specify libomp explicitly.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-fopenmp=libomp \
+// RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP,CHECK-FOPENMP-OMP %s
+
+// Check powerpc-ibm-aix7.1.0.0. -fopenmp=libiomp5 to specify libgomp 
explicitly.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-fopenmp=libiomp5 \
+// RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP,CHECK-FOPENMP-IOMP5 %s
+
+// Check powerpc-ibm-aix7.1.0.0. -fopenmp=libgomp to specify libgomp 
explicitly.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-fopenmp=libgomp \
+// RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP,CHECK-FOPENMP-GOMP %s
+
+// Chec

[libunwind] [libunwind][AIX] Fix the wrong traceback from signal handler (PR #101069)

2024-07-29 Thread Xing Xue via cfe-commits

https://github.com/xingxue-ibm created 
https://github.com/llvm/llvm-project/pull/101069

Patch [llvm#92291](https://github.com/llvm/llvm-project/pull/92291) causes 
wrong traceback from a signal handler for AIX because the AIX unwinder uses the 
traceback table at the end of each function instead of FDE/CIE for unwinding. 
This patch adds a condition to exclude traceback table based unwinding from the 
code added by the patch.

>From 05110959c01b5b7d4f2530e4d21232053db939f3 Mon Sep 17 00:00:00 2001
From: Xing Xue 
Date: Mon, 29 Jul 2024 14:53:36 -0400
Subject: [PATCH] Fix the problem introduced by upstream patch
 https://github.com/llvm/llvm-project/pull/92291 guard the code added to
 exclude traceback based unwinding used for AIX.

---
 libunwind/src/UnwindCursor.hpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 2ec60e4c123d5..758557337899e 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -2589,7 +2589,8 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool 
isReturnAddress) {
 --pc;
 #endif
 
-#if !(defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) && defined(_WIN32))
+#if !(defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) && defined(_WIN32)) &&
\
+!defined(_LIBUNWIND_SUPPORT_TBTAB_UNWIND)
   // In case of this is frame of signal handler, the IP saved in the signal
   // handler points to first non-executed instruction, while FDE/CIE expects IP
   // to be after the first non-executed instruction.

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] [libunwind][AIX] Fix the wrong traceback from signal handler (PR #101069)

2024-07-29 Thread Xing Xue via cfe-commits

https://github.com/xingxue-ibm updated 
https://github.com/llvm/llvm-project/pull/101069

>From 05110959c01b5b7d4f2530e4d21232053db939f3 Mon Sep 17 00:00:00 2001
From: Xing Xue 
Date: Mon, 29 Jul 2024 14:53:36 -0400
Subject: [PATCH 1/2] Fix the problem introduced by upstream patch
 https://github.com/llvm/llvm-project/pull/92291 guard the code added to
 exclude traceback based unwinding used for AIX.

---
 libunwind/src/UnwindCursor.hpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 2ec60e4c123d5..758557337899e 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -2589,7 +2589,8 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool 
isReturnAddress) {
 --pc;
 #endif
 
-#if !(defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) && defined(_WIN32))
+#if !(defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) && defined(_WIN32)) &&
\
+!defined(_LIBUNWIND_SUPPORT_TBTAB_UNWIND)
   // In case of this is frame of signal handler, the IP saved in the signal
   // handler points to first non-executed instruction, while FDE/CIE expects IP
   // to be after the first non-executed instruction.

>From c5176fb8bdb18d3776d3df98a6a15f9630184982 Mon Sep 17 00:00:00 2001
From: Xing Xue 
Date: Mon, 29 Jul 2024 15:49:27 -0400
Subject: [PATCH 2/2] Fix REQUIRES for AIX.

---
 libunwind/test/aix_signal_unwind.pass.sh.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libunwind/test/aix_signal_unwind.pass.sh.S 
b/libunwind/test/aix_signal_unwind.pass.sh.S
index 9ca18e9481f4f..a666577d095b1 100644
--- a/libunwind/test/aix_signal_unwind.pass.sh.S
+++ b/libunwind/test/aix_signal_unwind.pass.sh.S
@@ -10,7 +10,7 @@
 // a correct traceback when the function raising the signal does not save
 // the link register or does not store the stack back chain.
 
-// REQUIRES: target=powerpc{{(64)?}}-ibm-aix
+// REQUIRES: target=powerpc{{(64)?}}-ibm-aix{{.*}}
 
 // Test when the function raising the signal does not save the link register
 // RUN: %{cxx} -x c++ %s -o %t.exe -DCXX_CODE %{flags} %{compile_flags}

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] [libcxxabi] [libunwind] [NFC][libc++][libc++abi][libunwind][test] Fix/unify AIX triples used in LIT tests (PR #101196)

2024-07-30 Thread Xing Xue via cfe-commits

https://github.com/xingxue-ibm created 
https://github.com/llvm/llvm-project/pull/101196

This patch fixes/unifies AIX target triples used in libc++, libc++abi, and 
libunwind LIT tests.

>From d3fb26a629ec9761037065d1dba67fd8a93414bf Mon Sep 17 00:00:00 2001
From: Xing Xue 
Date: Tue, 30 Jul 2024 11:10:58 -0400
Subject: [PATCH] Fix the AIX triples used in LIT tests.

---
 libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp| 2 +-
 libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_32.pass.sh.s  | 2 +-
 libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_64.pass.sh.s  | 2 +-
 .../test/vendor/ibm/aix_xlclang_passing_excp_obj_32.pass.sh.S   | 2 +-
 .../test/vendor/ibm/aix_xlclang_passing_excp_obj_64.pass.sh.S   | 2 +-
 libcxxabi/test/vendor/ibm/cond_reg_restore.pass.cpp | 2 +-
 libcxxabi/test/vendor/ibm/vec_reg_restore.pass.cpp  | 2 +-
 libunwind/test/aix_signal_unwind.pass.sh.S  | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp 
b/libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp
index 2b684465650fa..3714e4037a2dc 100644
--- a/libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp
+++ b/libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp
@@ -6,7 +6,7 @@
 //
 
//===--===//
 
-// REQUIRES: target={{powerpc.*-ibm-aix.*}}
+// REQUIRES: target={{.+}}-aix{{.*}}
 // ADDITIONAL_COMPILE_FLAGS: -fvisibility-inlines-hidden
 
 // When there is a weak hidden symbol in user code and a strong definition
diff --git a/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_32.pass.sh.s 
b/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_32.pass.sh.s
index ce90045586082..b35c999e6e50d 100644
--- a/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_32.pass.sh.s
+++ b/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_32.pass.sh.s
@@ -9,7 +9,7 @@
 # Test that a nested exception is thrown by a destructor inside a try-block
 # when the code is generated by the legacy AIX xlclang compiler.
 
-# REQUIRES: target=powerpc-ibm-aix
+# REQUIRES: target=powerpc-ibm-aix{{.*}}
 # UNSUPPORTED: no-exceptions
 
 # RUN: %{cxx} %{flags} %s %{link_flags} \
diff --git a/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_64.pass.sh.s 
b/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_64.pass.sh.s
index 7b0afb9ebae38..16754db2837ca 100644
--- a/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_64.pass.sh.s
+++ b/libcxxabi/test/vendor/ibm/aix_xlclang_nested_excp_64.pass.sh.s
@@ -8,7 +8,7 @@
 # Test that a nested exception is thrown by a destructor inside a try-block
 # when the code is generated by the legacy AIX xlclang compiler.
 
-# REQUIRES: target=powerpc64-ibm-aix
+# REQUIRES: target=powerpc64-ibm-aix{{.*}}
 # UNSUPPORTED: no-exceptions
 
 # RUN: %{cxx} %{flags} %s %{link_flags} \
diff --git 
a/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_32.pass.sh.S 
b/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_32.pass.sh.S
index 71c3ab9409a81..8b92e4febf562 100644
--- a/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_32.pass.sh.S
+++ b/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_32.pass.sh.S
@@ -14,7 +14,7 @@
 // xlclang++ compiler included in this file. This file tests for the 32-bit
 // mode.
 
-# REQUIRES: target=powerpc-ibm-aix
+# REQUIRES: target=powerpc-ibm-aix{{.*}}
 # UNSUPPORTED: no-exceptions
 
 // RUN: %{cxx} -c %s -o %t1_32.o -DT1_CPP_CODE %{flags} %{compile_flags}
diff --git 
a/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_64.pass.sh.S 
b/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_64.pass.sh.S
index da413577bd38f..64d7c80e9e6dd 100644
--- a/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_64.pass.sh.S
+++ b/libcxxabi/test/vendor/ibm/aix_xlclang_passing_excp_obj_64.pass.sh.S
@@ -14,7 +14,7 @@
 // xlclang++ compiler included in this file. This file tests for the 64-bit
 // mode.
 
-# REQUIRES: target=powerpc64-ibm-aix
+# REQUIRES: target=powerpc64-ibm-aix{{.*}}
 # UNSUPPORTED: no-exceptions
 
 // RUN: %{cxx} -c %s -o %t1_64.o -DT1_CPP_CODE %{flags} %{compile_flags}
diff --git a/libcxxabi/test/vendor/ibm/cond_reg_restore.pass.cpp 
b/libcxxabi/test/vendor/ibm/cond_reg_restore.pass.cpp
index 63817e1b13a25..a5eb3c20534a3 100644
--- a/libcxxabi/test/vendor/ibm/cond_reg_restore.pass.cpp
+++ b/libcxxabi/test/vendor/ibm/cond_reg_restore.pass.cpp
@@ -10,7 +10,7 @@
 // on AIX. Option -O3 is required so that the compiler will re-use the value
 // in the condition register instead of re-evaluating the condition expression.
 
-// REQUIRES: target=powerpc{{(64)?}}-ibm-aix
+// REQUIRES: target={{.+}}-aix{{.*}}
 // ADDITIONAL_COMPILE_FLAGS: -O3
 // UNSUPPORTED: no-exceptions
 
diff --git a/libcxxabi/test/vendor/ibm/vec_reg_restore.pass.cpp 
b/libcxxabi/test/vendor/ibm/vec_reg_restore.pass.cpp
index 703c311dae392..7c31970546993 100644
--- a/libcxxabi/test/vendor/ibm/vec_reg_restore.pass.cpp
+

[libcxx] [libcxxabi] [libunwind] [NFC][libc++][libc++abi][libunwind][test] Fix/unify AIX triples used in LIT tests (PR #101196)

2024-07-30 Thread Xing Xue via cfe-commits


@@ -6,7 +6,7 @@
 //
 
//===--===//
 
-// REQUIRES: target={{powerpc.*-ibm-aix.*}}
+// REQUIRES: target={{.+}}-aix{{.*}}

xingxue-ibm wrote:

> Why remove the vendor in the vendor specific directory?

IBM is the only vendor shipping the AIX OS so I think the vendor part is 
unnecessary. This is similar to `{{.+}}-zos{{.*}}`.

https://github.com/llvm/llvm-project/pull/101196
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] [libcxxabi] [libunwind] [NFC][libc++][libc++abi][libunwind][test] Fix/unify AIX triples used in LIT tests (PR #101196)

2024-07-30 Thread Xing Xue via cfe-commits


@@ -10,7 +10,7 @@
 // on AIX. Option -O3 is required so that the compiler will re-use the value
 // in the condition register instead of re-evaluating the condition expression.
 
-// REQUIRES: target=powerpc{{(64)?}}-ibm-aix
+// REQUIRES: target={{.+}}-aix{{.*}}

xingxue-ibm wrote:

> Why drop the vendor in the vendor specific directory?

IBM is the only vendor shipping the AIX OS so I think the vendor part is 
unnecessary. This is similar to {{.+}}-zos{{.*}}.

https://github.com/llvm/llvm-project/pull/101196
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] [libcxxabi] [libunwind] [NFC][libc++][libc++abi][libunwind][test] Fix/unify AIX triples used in LIT tests (PR #101196)

2024-07-30 Thread Xing Xue via cfe-commits


@@ -6,7 +6,7 @@
 //
 
//===--===//
 
-// REQUIRES: target={{powerpc.*-ibm-aix.*}}
+// REQUIRES: target={{.+}}-aix{{.*}}

xingxue-ibm wrote:

I see what you mean, thanks! I can do it if we think it is better to move them 
out of the `vendor/ibm` directory.

https://github.com/llvm/llvm-project/pull/101196
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] [libcxxabi] [libunwind] [NFC][libc++][libc++abi][libunwind][test] Fix/unify AIX triples used in LIT tests (PR #101196)

2024-07-31 Thread Xing Xue via cfe-commits


@@ -6,7 +6,7 @@
 //
 
//===--===//
 
-// REQUIRES: target={{powerpc.*-ibm-aix.*}}
+// REQUIRES: target={{.+}}-aix{{.*}}

xingxue-ibm wrote:

Thanks!

https://github.com/llvm/llvm-project/pull/101196
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] [libcxxabi] [libunwind] [NFC][libc++][libc++abi][libunwind][test] Fix/unify AIX triples used in LIT tests (PR #101196)

2024-08-01 Thread Xing Xue via cfe-commits

https://github.com/xingxue-ibm milestoned 
https://github.com/llvm/llvm-project/pull/101196
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] [libcxxabi] [libunwind] [NFC][libc++][libc++abi][libunwind][test] Fix/unify AIX triples used in LIT tests (PR #101196)

2024-08-01 Thread Xing Xue via cfe-commits

xingxue-ibm wrote:

/cherry-pick 
[2d36550](https://github.com/llvm/llvm-project/commit/2d3655037ccfa276cb0949c2ce0cff56985f6637)

https://github.com/llvm/llvm-project/pull/101196
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits