Commit Graph

245 Commits

Author SHA1 Message Date
Hans Wennborg 1fe469ae6c Bump the trunk version to 9.0.0svn
llvm-svn: 351320
2019-01-16 10:57:02 +00:00
Hans Wennborg eb60fbfdb4 Update year in license files
In last year's update (D48219) it was suggested that the release manager
might want to do this, so here we go.

llvm-svn: 351194
2019-01-15 15:10:32 +00:00
Daniel Cederman 17121adfa6 [Sparc] Add Sparc V8 support
Summary:
Adds the register class implementation for Sparc.
Adds support for DW_CFA_GNU_window_save.
Adds save and restore context functionality.

Adds getArch() function to each Registers_ class to be able to separate
between DW_CFA_AARCH64_negate_ra_state and DW_CFA_GNU_window_save which
are both represented by the same constant.

On Sparc the return address is the address of the call instruction, so
an offset needs to be added when returning to skip the call instruction
and its delay slot. If the function returns a struct it is also necessary
to skip one extra instruction on Sparc V8.

Reviewers: jyknight, mclow.lists, mstorsjo, compnerd

Reviewed By: jyknight, compnerd

Subscribers: jgorbe, mgorny, christof, llvm-commits, fedor.sergeev, JDevlieghere, ldionne, libcxx-commits

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

llvm-svn: 351044
2019-01-14 10:15:20 +00:00
Jorge Gorbe Moya 8d530b777d Revert "[Sparc] Add Sparc V8 support"
This reverts commit r350705.

llvm-svn: 350787
2019-01-10 01:08:31 +00:00
Daniel Cederman b2be18f42d [Sparc] Add Sparc V8 support
Summary:
Adds the register class implementation for Sparc.
Adds support for DW_CFA_GNU_window_save.
Adds save and restore context functionality.

On Sparc the return address is the address of the call instruction,
so an offset needs to be added when returning to skip the call instruction
and its delay slot. If the function returns a struct it is also necessary
to skip one extra instruction.

Reviewers: jyknight, mclow.lists, mstorsjo, compnerd

Reviewed By: compnerd

Subscribers: fedor.sergeev, JDevlieghere, ldionne, libcxx-commits

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

llvm-svn: 350705
2019-01-09 12:06:05 +00:00
Martin Storsjo 09cf6374c1 [SEH] Add initial support for AArch64
This doesn't yet implement inspecting the .pdata/.xdata to find the
LSDA pointer (in UnwindCursor::getInfoFromSEH), but normal C++
exception handling seems to run just fine without it. (The only
place I can see where it's even referenced is in
unwind_phase2_forced, and I can't find a codepath where libcxxabi
would end up calling that.)

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

llvm-svn: 349532
2018-12-18 20:05:59 +00:00
Luke Cheeseman 357973192d [AArch64][libunwind] Unwinding support for return address signing with B Key
- Support for the case where the return address has been signed with the B key
- When the B key is used, a 'B' character is present in the augmentation string
  of CIE associated with the FDE for the function.

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

llvm-svn: 349339
2018-12-17 11:43:24 +00:00
Luke Cheeseman e1a819e82d [AArch64][libunwind] Unwinding support for return address signing
- Follow up to revision r342895
- gcc would not build libunwind with the earlier patch as the autia1716
  instruction wasn't allowed to be assembled for pre armv8.3a targets
- The autia1716 instruction lives in the hint space encodings so is a valid
  instruction for all armv8a targets
- To work around this I have swapped out the autia1716 instruction for the hint
  instruction

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

llvm-svn: 349140
2018-12-14 11:30:12 +00:00
Martin Storsjo 1ae5089765 Avoid code duplication in the SEH version of UnwindCursor::getRegisterName. NFC.
This requires making Registers_*::getRegisterName static.

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

llvm-svn: 348981
2018-12-12 22:24:42 +00:00
Michal Gorny c790632437 [cmake] Rename append_if to avoid collision with LLVM
Rename the 'append_if' macro used in libunwind to 'unwind_append_if'.
Otherwise, when used in a combined LLVM+libunwind build, it overrides
the *incompatible* 'append_if' function from LLVM and breaks projects
following libunwind, e.g. OpenMP.

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

llvm-svn: 348852
2018-12-11 15:30:04 +00:00
Martin Storsjo 4862ff8d17 [SEH] Zero-initialize EXCEPTION_RECORD and UNWIND_HISTORY_TABLE before calling RtlUnwindEx
This fixes PR39935.

llvm-svn: 348836
2018-12-11 09:53:11 +00:00
Martin Storsjo a64aa485e1 Don't export assembly functions when function visibility annotations are disabled
Patch by Peiyuan Song!

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

llvm-svn: 348832
2018-12-11 07:34:14 +00:00
Petr Hosek 2d2e23e89b [CMake] Passthrough CFLAGS when checking the compiler-rt path
This is needed when cross-compiling for a different target since
CFLAGS may contain additional flags like -resource-dir which
change the location in which compiler-rt builtins are found.

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

llvm-svn: 346820
2018-11-14 00:09:26 +00:00
Charles Davis 869e5d1fca [CMake] Link to compiler-rt if LIBUNWIND_USE_COMPILER_RT is ON.
Summary:
If `-nodefaultlibs` is given, we weren't actually linking to it. This
was true irrespective of passing `-rtlib=compiler-rt` (see previous
patch). Now we explicitly link it to handle that case.

I wonder if we should be linking these libraries only if we're using
`-nodefaultlibs`...

Reviewers: beanz

Subscribers: dberris, mgorny, christof, chrib, cfe-commits

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

llvm-svn: 343990
2018-10-08 18:35:00 +00:00
Luke Cheeseman 3bdf34f20e Reverting r342895
- The used builtins do not compile for pre arm v8.3a targets with gcc

llvm-svn: 342901
2018-09-24 16:36:33 +00:00
Luke Cheeseman 8284b19c76 [AArch64] Unwinding support for return address signing
- When return address signing is enabled, the LR may be signed on function entry
- When an exception is thrown the return address is inspected used to unwind the call stack
- Before this happens, the return address must be correctly authenticated to avoid causing an abort by dereferencing the signed pointer

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

llvm-svn: 342895
2018-09-24 15:55:35 +00:00
Louis Dionne 2e667527c5 [libunwind][NFC] Suppress unused parameter warnings
Reviewers: EricWF

Subscribers: christof, chrib, dexonsmith, cfe-commits

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

llvm-svn: 342811
2018-09-22 18:18:34 +00:00
Charles Davis 4c08654b17 [CMake] Don't use -rtlib=compiler-rt with -nodefaultlibs.
Summary:
This switch only has an effect at link time. It changes the default
compiler support library to `compiler-rt`. With `-nodefaultlibs`, this
library won't get linked anyway; Clang actually warns about that.

Reviewers: mstorsjo, rnk

Subscribers: dberris, mgorny, christof, cfe-commits

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

llvm-svn: 341404
2018-09-04 20:57:50 +00:00
Charles Davis 7a474b6579 [CMake] Remove variable reference that isn't used.
Summary:
This variable is never defined, so its value is always empty. Since
`libunwind` is needed to build the C++ ABI library in the first place,
it should never be linked to the C++ ABI library anyway.

Reviewers: mstorsjo, rnk

Subscribers: mgorny, christof, cfe-commits

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

llvm-svn: 341388
2018-09-04 17:40:26 +00:00
Charles Davis 805173c84d Export public functions implemented in assembly on Windows.
Summary:
By default, symbols aren't visible outside of the module that defines
them. To make them visible, they must be exported. The easiest way to do
that is to embed an `-export:symname` directive into the object file.

Reviewers: mstorsjo, rnk

Subscribers: christof, cfe-commits

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

llvm-svn: 341232
2018-08-31 18:11:48 +00:00
Martin Storsjo a2646444d2 Fix existing code for SEH on ARM to compile correctly
Even though SEH for ARM is incomplete, make what code already exists
at least compile correctly.

The _LIBUNWIND_CURSOR_SIZE wasn't correct.

ARM (and AArch64) have a DISPATCHER_CONTEXT field named TargetPc
instead of TargetIp.

For the libunwind.h UNW_* constants, there is no UNW_ARM_PC, only
UNW_ARM_IP.

Don't use 'r' as loop variable when 'r' already is a Registers_arm
member.

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

llvm-svn: 341217
2018-08-31 14:56:55 +00:00
Charles Davis 226570dcfc [AddressSpace] Use the macro to set hidden visibility on LocalAddressSpace.
Summary:
That attribute has no effect on Windows anyway--classes are hidden by
default.

Reviewers: mstorsjo, rnk

Subscribers: christof, cfe-commits

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

llvm-svn: 341210
2018-08-31 13:41:05 +00:00
Charles Davis a7e3a6d802 Add support for SEH unwinding on Windows.
Summary:
I've tested this implementation on x86-64 to ensure that it works. All
`libc++abi` tests pass, as do all `libc++` exception-related tests. ARM
still remains to be implemented (@compnerd?).

Special thanks to KJK::Hyperion for his excellent series of articles on
how EH works on x86-64 Windows. (Seriously, check it out. It's awesome.)

I'm actually not sure if this should go in as is. I particularly don't
like that I duplicated the UnwindCursor class for this special case.

Reviewers: mstorsjo, rnk, compnerd, smeenai, javed.absar

Subscribers: mgorny, kristof.beyls, christof, chrib, cfe-commits, compnerd, llvm-commits

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

llvm-svn: 341125
2018-08-30 21:29:00 +00:00
Jordan Rupprecht ca6d35b2a9 NFC: Test commit access
Testing commit access from a new machine, so using this as an opportunity to revert my old test access commit (r336006) that I never cleaned up.

llvm-svn: 339899
2018-08-16 16:55:07 +00:00
Stefan Maksimovic afc9f8ab6d [libunwind][mips] Include gcc_s for linkage
When compiling with optimizations, mips requires various helper routines(__ashldi3 and the like) contained in libgcc_s.
Conditionally include libgcc_s in the set of libraries to be linked to.

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

llvm-svn: 339878
2018-08-16 13:40:16 +00:00
Stefan Maksimovic fe50950dac [libunwind][mips] Guard accumulator registers
Mipsr6 does not possess HI and LO accumulator registers, adjust validRegister functions to respect that.

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

llvm-svn: 339849
2018-08-16 08:49:50 +00:00
Stefan Maksimovic 944677cd28 [libunwind][mips] Modify the __mips_fpr macro check
The __mips_fpr macro can take the value of 0 as well, change to account for that case.

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

llvm-svn: 339848
2018-08-16 08:47:43 +00:00
Martin Storsjo f128f27874 [cmake] Add MINGW_LIBRARIES to the linker flags
This is essential when building with -nodefaultlibs.

In some CMake versions (noticed in 3.5.1), the same libraries are
picked up from CMAKE_REQUIRED_LIBRARIES in some exceptional situations
(if CXX probing failed, due to libc++ not being built yet, the libraries
from CMAKE_REQUIRED_LIBRARIES are used for linking the target library),
but not at all in other newer CMake versions (3.10).

This is similar to what already is done in libcxxabi in SVN r302760
and libcxx in SVN r312498.

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

llvm-svn: 339642
2018-08-14 06:13:36 +00:00
Charles Davis b006dafbef Remove unneeded preprocessor condition.
llvm-svn: 339259
2018-08-08 15:18:22 +00:00
Charles Davis 06acf1f638 [libunwind][include] Add SEH declarations to <unwind.h>.
Summary:
Make the `_Unwind_Exception` struct correct under SEH. Add a
declaration of `_GCC_specific_handler()`, which is used by SEH versions
of Itanium personality handlers to do common setup. Roughly corresponds
to Clang's D50380.

Reviewers: mstorsjo, rnk, compnerd, smeenai

Subscribers: christof, chrib, cfe-commits, llvm-commits

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

llvm-svn: 339258
2018-08-08 15:18:20 +00:00
Charles Davis 8284d328ba [libunwind] Fix pointer-to-integer cast warnings on LLP64.
Summary:
`long` is too short on LLP64. We have to use `intptr_t` to
avoid truncating pointers.

Reviewers: mstorsjo, rnk, compnerd, smeenai

Subscribers: christof, cfe-commits, llvm-commits

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

llvm-svn: 339217
2018-08-08 04:21:24 +00:00
Martin Storsjo 5d108d260f [CMake] Allow building standalone without any llvm-config available
This is the same as libcxxabi/libcxx do.

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

llvm-svn: 338819
2018-08-03 05:51:31 +00:00
Hans Wennborg d541521225 Bump version number to 8.0.0svn
llvm-svn: 338570
2018-08-01 15:22:27 +00:00
Hans Wennborg a760fe6484 Update docs version and clear release notes after 8.0.0 version bump
llvm-svn: 338561
2018-08-01 14:14:09 +00:00
Petr Hosek 641a29df6d [CMake] Include CMakeDependentOption in libunwind
This should resolve the breakage introduced in r337867 which introduced
the use of cmake_dependent_option without include the necessary file.

llvm-svn: 337868
2018-07-24 23:42:51 +00:00
Petr Hosek 4a1e14ea78 [CMake] Option to control whether shared/static library is installed
Currently it's only possible to control whether shared or static library
build of libc++, libc++abi and libunwind is enabled or disabled and
whether to install everything we've built or not. However, it'd be
useful to have more fine grained control, e.g. when static libraries are
merged together into libc++.a we don't need to install libc++abi.a and
libunwind.a. This change adds this option.

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

llvm-svn: 337867
2018-07-24 23:27:51 +00:00
Joerg Sonnenberger d0166a0a93 The semantics of DW_CFA_GNU_args_size have changed subtile over the
years. Adopt the new convention that it is call-site specific and that
it should be applied before moving the IP by personality routines, but
not during normal unwinding.

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

llvm-svn: 337312
2018-07-17 19:00:51 +00:00
Petr Hosek 6aae861e0e [CMake] Set per-runtime library directory suffix in runtimes build
Do not use LLVM_RUNTIMES_LIBDIR_SUFFIX variable which is an internal
variable used by the runtimes build from individual runtimes, instead
set per-runtime librarhy directory suffix variable which is necessary
for the sanitized runtimes build to install libraries into correct
location.

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

llvm-svn: 336713
2018-07-10 19:13:33 +00:00
Jordan Rupprecht 2bd91dbd62 Introduce a separate preprocessor macro, _LIBUNWIND_USE_DLADDR, for directly controlling a dependency on dladdr(). This will allow us to use libunwind without adding a libdl dependency.
Reviewers: saugustine

Subscribers: christof, chrib, cfe-commits, echristo

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

llvm-svn: 336014
2018-06-29 20:41:50 +00:00
Eric Christopher 45a05a5457 Revert "Revert "Support for multiarch runtimes layout""
This reverts commit r336005 that was accidentally committed.

llvm-svn: 336012
2018-06-29 20:27:40 +00:00
Jordan Rupprecht 7bb861e83b Add a blank line to docs/README.txt test commit access
Subscribers: christof, cfe-commits

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

llvm-svn: 336006
2018-06-29 19:05:21 +00:00
Jordan Rupprecht 2ee550c6b3 Revert "Support for multiarch runtimes layout"
This reverts commit 0c7cea3c0c6338b99e30c13201365a3dd4edc6f4.

llvm-svn: 336005
2018-06-29 19:05:20 +00:00
Petr Hosek 887f26d470 Support for multiarch runtimes layout
This change adds a support for multiarch style runtimes layout, so in
addition to the existing layout where runtimes get installed to:

lib/clang/$version/lib/$os

Clang now allows runtimes to be installed to:

lib/clang/$version/$target/lib

This also includes libc++, libc++abi and libunwind; today those are
assumed to be in Clang library directory built for host, with the
new layout it is possible to install libc++, libc++abi and libunwind
into the runtime directory built for different targets.

The use of new layout is enabled by setting the
LLVM_ENABLE_RUNTIME_TARGET_DIR CMake variable and is supported by both
projects and runtimes layouts. The runtimes CMake build has been further
modified to use the new layout when building runtimes for multiple
targets.

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

llvm-svn: 335809
2018-06-28 03:11:52 +00:00
Martin Storsjo faf9589fae [CMake] Convert paths to the right form in standalone builds on Windows
The paths output from llvm-config --cmakedir and from clang
--print-libgcc-file-name can contain backslashes, while CMake
can't handle the paths in this form.

This matches what compiler-rt already does (since SVN r203789
and r293195).

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

llvm-svn: 335169
2018-06-20 20:53:19 +00:00
Paul Robinson 7555c589af Update copyright year to 2018.
llvm-svn: 334936
2018-06-18 12:22:17 +00:00
whitequark 4f9c59f863 [OR1K] Add the EPCR special-purpose register to register state.
This makes it possible to unwind hardware exception stack frames,
which necessarily save every register and so need an extra column
for storing the return address. CFI for the exception handler could
then look as follows:

.globl exception_vector
exception_vector:
    .cfi_startproc
    .cfi_signal_frame
    .cfi_return_column 32
    l.addi  r1, r1, -0x100
    .cfi_def_cfa_offset 0x100
    l.sw    0x00(r1), r2
    .cfi_offset 2, 0x00-0x100
    l.sw    0x04(r1), r3
    .cfi_offset 3, 0x04-0x100
    l.sw    0x08(r1), r4
    .cfi_offset 4, 0x08-0x100
    l.mfspr r3, r0, SPR_EPCR_BASE
    l.sw    0x78(r1), r3
    .cfi_offset 32, 0x78-0x100
    l.jal   exception_handler
     l.nop
    l.lwz   r2, 0x00(r1)
    l.lwz   r3, 0x04(r1)
    l.lwz   r4, 0x08(r1)
    l.jr    r9
     l.nop
    .cfi_endproc

This register could, of course, also be accessed by the trace
callback or personality function, if so desired.

llvm-svn: 332513
2018-05-16 19:09:48 +00:00
whitequark 3f948cd79d [OR1K] Add a dedicated PC register to register state.
Before this commit, R9, the link register, was used as PC register.
However, a stack frame may have R9 not set to PC on entry, either
because it uses a custom calling convention, or, more likely,
because this is a signal or exception stack frame. Using R9 as
PC register made it impossible to unwind such frames.

All other architectures similarly use a dedicated PC register.

llvm-svn: 332512
2018-05-16 19:09:41 +00:00
John Baldwin c3f240f7dc [libunwind][MIPS] Support MIPS floating-point registers for hard-float ABIs.
Summary:
For MIPS ABIs with 64-bit floating point registers including newabi
and O32 with 64-bit floating point registers, just save and restore the
32 floating-point registers as doubles.

For O32 MIPS with 32-bit floating-point registers, save and restore the
individual floating-point registers as "plain" registers.  These registers
are encoded as floats rather than doubles, but the DWARF unwinder
assumes that floating-point registers are stored as doubles when reading
them from memory (via AddressSpace::getDouble()).  Treating the
registers as "normal" registers instead causes the DWARF unwinder to
fetch them from memory as a 32-bit register.  This does mean that for
O32 with 32-bit floating-point registers unw_get_fpreg() and
unw_set_fpreg() do not work.  One would have to use unw_get_reg()
and unw_set_reg() instead.  However, DWARF unwinding works
correctly as the DWARF CFI emits records for individual 32-bit
floating-point registers even when they are treated as doubles stored
in paired registers.  If the lack of unw_get/set_fpreg() becomes a pressing
need in the future for O32 MIPS we could add in special handling to
make it work.

Reviewers: sdardis, compnerd

Reviewed By: sdardis

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

llvm-svn: 332414
2018-05-15 22:44:56 +00:00
Aaron Smith 596b0f03a0 [cmake] Remove duplicate command line options from build
CMAKE_CXX_FLAGS and CMAKE_C_FLAGS are added twice to the command line.
This causes the command line options to be doubled which works until
it doesn't as not all options can be specified twice. 

For example,

clang-cl foo.c /GS- /GS- -mllvm -small-loop-cost=1 -mllvm -small-loop-cost=1
clang (LLVM option parsing): for the -small-loop-cost option: may only occur zero or one times!

llvm-svn: 329340
2018-04-05 20:27:50 +00:00
Petr Hosek 2dcd1d0989 [CMake] Support for monorepo layout
Support finding libcxx sources in monorepo style layout.

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

llvm-svn: 329212
2018-04-04 17:57:15 +00:00