1
0
mirror of https://github.com/openbsd/src.git synced 2026-06-18 07:13:36 +02:00
Commit Graph

4633 Commits

Author SHA1 Message Date
gnezdo 077d2ea485 Fix llvm x86 frame lowering for -msave-args
The problem only shows up with KASAN builds where it causes registers
saved below SP leading to fills not finding what was spilled.

go for it dlg@
2025-11-14 09:57:02 +00:00
jca baa29930eb The libunwind guts used by libexecinfo no longer need "new" from libcxx
check_sym says: No dynamic export changes

Noticed and checked by rsadowski@
2025-11-04 13:17:05 +00:00
jca d387f9c1e6 take 2: re-apply two commits that were lost while merging the 19.1.7 update
Reintroduce a tweaked version of the IP-based caching implementation.
Implementing a custom "new" operator has the two following desirable
properties:
- make the code more standalone, not depending on "new" from libcxx.
- teach this allocator to return nullptr on memory shortage ("noexcept")
  so it can fail gracefully. If we can't allocate an item, we just don't
  cache it.
That should be more resilient to memory shortages and thus more usable
from libexecinfo.

ok rsadowski@ robert@
2025-11-04 13:09:23 +00:00
jca 2da7e0886e take 2: re-apply one commit that was lost while merging the 19.1.7 update
I've been overzealous when backing out some unrelated changes.
Re-apply requested by robert@
-------------------
    Linux still doesn't actually implement IBT for userland.  And by the pace
    things are going, it will take another decade before it does.  But OpenBSD
    has it enabled *by default* already.

    Drop the #ifdef __linux__.  This should hurt other OSes when they finally
    catch up with us.

    ok robert@, tb@
2025-11-03 20:21:23 +00:00
jca 7abb703a82 Backout previous, the reintroduced code leads to a missing symbol
regress:
cc  -Wl,--export-dynamic  -o t_backtrace t_backtrace.o atf-c.o -lexecinfo
ld: error: undefined reference: operator new(unsigned long)
>>> referenced by /usr/lib/libexecinfo.so.4.0 (disallowed by --no-allow-shlib-undefined)

ok tb@
2025-11-03 18:33:06 +00:00
robert 36632bb0f3 re-apply three commits that were lost while merging the 19.1.7 update
-------------------
    Linux still doesn't actually implement IBT for userland.  And by the pace
    things are going, it will take another decade before it does.  But OpenBSD
    has it enabled *by default* already.

    Drop the #ifdef __linux__.  This should hurt other OSes when they finally
    catch up with us.

    ok robert@, tb@
-------------------
    Initial IP-based caching implementation with O(logn) lookup.

    Caching implemented via red-black trees, this can be improved and
    further work is on-going to bring it closer to GNU's performance that
    uses a LRU-MRU 8-entries based caching algorithm.

    Prompted by robert@ who run into a runtime of an executed macro of
    5 minutes in libreoffice. With this the execution is reduced to 58 seconds.

    C++11 tips from espie@, rsadowski@
    Tested by robert@
    OK mortimer@, kettenis@.

--------------------
    Make the unwind cache tread-safe by declaring it thread_local. Solves
    segfaults seen on exception handling.  ok kettenis@
--------------------
2025-11-03 09:20:19 +00:00
miod 4959bc61fd Undo a bad mistake; spotted by brynet@ 2025-10-23 20:42:52 +00:00
miod 54449f37da Don't try to install {,un}protoize manpages, they no longer exist. 2025-10-23 19:35:56 +00:00
miod 9069d57f4c gcc3 is leaving the building. 2025-10-23 19:10:32 +00:00
miod acc7c06d1c gcc3 is leaving the building.
(removal done in several commits to avoid hitting
 "Protocol error: too many arguments" errors)
2025-10-23 19:09:49 +00:00
miod 43de91522a gcc3 is leaving the building. 2025-10-23 19:08:32 +00:00
miod 27664962f0 Prepare for gcc 3 leaving the building, COMPILER_VERSION can no longer get
set to "gcc3".
2025-10-23 19:06:09 +00:00
miod 67aa317b5c Remove gcc3 workaround in UVCHR_IS_INVARIANT(). 2025-10-23 18:50:38 +00:00
miod 22e0e8faf4 Tweak the ld guts under OpenBSD/hppa to prevent enabling the options (and
code) allowing for inter-space thunks to be generated
(i.e. ld --multi-subspace), just to be sure we can sleep soundly.

ok jca@
2025-10-22 18:47:12 +00:00
miod f752a3e5bd The __builtin_return_address() internal logic, on PA-Risc, tries to read the
code at the tentative return address in order to check for a possible
inter-space thunk ("export stub" as called by HP), and in this case, unfolds
a bit more to retrieve the stub return address.

When the code pages are not readable, which is the case by default under
OpenBSD/hppa, this causes an immediate segmentation fault. But there is no
use of multiple space registers under OpenBSD either, so such thunks are
never created by ld(1). We can therefore override the logic by simply
returning the tentative return address, which is correct and does not require
read permission on the code pages.

ok jca@
2025-10-22 18:44:06 +00:00
miod 11390e98b6 The per-target adjust_cost hook only gets invoked if recog_memoized (insn)
succeeds, no need to perform this check again.
2025-10-21 18:35:35 +00:00
anton 571348cc06 Teach clang to emit an error when enabling UBSan with execute-only.
UBSan and execute-only are mutually exclusive as -fsanitize=function
implied by UBSan sanitizes indirect function calls in which a
destination is only considered valid if preceded by a well known
sequence (0xc105cafe). This of course requires being able to read the
text segment, making it incompatible with execute-only.

Running UBSan on OpenBSD now requires the options:

	-fsanitize=undefined -fsanitize-minimal-runtime Wl,--no-execute-only

ok sthen@, tb@
2025-10-20 17:38:36 +00:00
miod ffa4f20d55 Add ctzsi2 and clzzi2 insn, enabling better __builtin_clz and __builtin_ctz
code generation on 32-bit width integers.
2025-10-15 18:41:36 +00:00
miod f0a6b9bef7 Add an extra tab in the assembly output for better layout. NFC 2025-10-15 18:40:17 +00:00
miod d7efe478bf Make -mserialize-volatile the default. Correctly, this time. 2025-10-05 18:40:17 +00:00
miod fc810c5c62 Make -mserialize-volatile the default. Missed during the gcc3->gcc4 backend
conversion.
2025-10-03 19:42:56 +00:00
miod a9fc51fcf0 In the expansion of zero_extendqisi2, remove code which is not found in the
other zero_extend* expansions and is identical to the fallback MI code.
2025-10-03 19:41:06 +00:00
miod 21b3ddf0b9 In pseudo-assembly statements, %L implies a trailing %., so constructs using
%L%. are wrong.
The fact that this never caused any assembler complaints hints that the two
occurrences of this wrong construct are never hit - and in fact, commenting
them out entirely does not appear to change anything in generated code.
2025-10-03 19:40:38 +00:00
miod f3a035d2ae Make the m88k disassembler recognize more forms of ld and st instructions,
especially in scaled mode. Helps gdb correctly disassemble the code gcc can
produce...
2025-10-01 18:04:52 +00:00
miod c539be2e36 Due to the way the save area for the registers used for argument passing is
set up in variadic functions with the "new" frame layout, make sure that
variadic functions always setup a frame pointer, even if they qualify for
omitting them (e.g. variadic leaf functions which do not call alloca or use
exceptions), as their save area is relative to %r30.

This buglet amazingly went unnoticed as it was apparently not blatant enough
to break the gcc testsuite - the only piece of code it broke horribly was
the mvme88k boot blocks.
2025-09-29 18:46:51 +00:00
miod b2485efb90 Make obj in all SUBDIR even if COMPILER_VERION != gcc4. 2025-09-29 18:29:23 +00:00
robert 360f60ecdf neuter the preserve_{most,all} attributes on OpenBSD
The preserve_{most,all} attributes do not work with retguard so let's warn
the user about them while also ignoring them completely.

ok kettenis@, miod@
2025-09-29 07:49:22 +00:00
jsg 279d57bfc1 remove duplicate virtual_stack_vars_rtx test
found with cppcheck, ok miod@
2025-09-23 04:55:05 +00:00
miod 932bc229c1 Revert 1.14 and disable delayed branch optimization while reenabling
basic block reordering.

Basic block span computation has been fixed, hopefully for good, in m88k.md
rev 1.16.

The delayed branch optimization is unfortunately still corrupting register
values by moving instructions which shouldn't, in complex enough code. Even
though the gcc testsuite passes, including the few tests which exercize
this, in gcc's own tree-cfg.c, the combination of the inlining of
update_modified_stmts() and delayed branching creates a code path where the
argument of one update_stmt_operands() call (via update_stmt_is_modified())
is overwritten with a load of the (declared noreturn, and it matters)
fancy_abort() message in the stmt_ann() diagnostic.

This can be reduced to a 127 line testcase, which will hopefully let me cut
my teeth further on this.

In the meantime, disabling this optimization allows gcc 4 to be self-hosting
again on m88k.
2025-09-22 19:04:00 +00:00
miod 58f4ace048 Implement [bs]{,un}ordered insns for proper floating-point comparisons results
against NaNs.
2025-09-14 19:37:52 +00:00
miod 856a9542e2 Allow expand_block_move() to fail and have the MI code generate the memcpy
call, rather than doing it ourselves.
2025-09-14 19:37:16 +00:00
miod 60ecb338a7 Minor exception handling bug and comment fixes.
Also, revert override of TARGET_BUILTIN_SETJMP_FRAME_VALUE - this was done
while experimenting with sjlj exceptions support, to make them work better,
but now that unwinding works it is no longer useful.
2025-09-14 19:36:52 +00:00
miod 8f74c9ac29 Define AVOID_CCMODE_COPIES. While CCmode values are kept in registers, there
is no reason to copy {f,}cmp results to another register; prefer keeping that
register live as long as necessary.
2025-09-14 19:36:29 +00:00
miod b7aed249da Add more barriers for proper basic block computation. 2025-09-14 19:35:21 +00:00
miod e9fd4d2821 Fix harmless compilation warnings. 2025-09-14 19:35:02 +00:00
gkoehler 4583e465b6 Remove obsolete ppc/atomic_lock_free.c
Back when compiler-rt was missing __atomic_is_lock_free, we added it
for 64-bit atomic ops on powerpc.  A later version of compiler-rt
added __atomic_is_lock_free to builtins/atomic.c; the linker has been
finding atomic.c and ignoring atomic_lock_free.c.

ok kettenis@
2025-09-10 03:38:56 +00:00
kettenis 0d6ca4c5a5 Clean up the handling of the "TF" (quad-precision) helper functions.
Create a single arch-independent list for them and allow for replacement
of the generic C implementation with arch-dependent assembly code.

ok rsadowski@
2025-09-05 17:05:14 +00:00
kettenis 4808c24575 Remove x86-specific stanza that adds Float16 conversion functions that
are already part of the generic list of files.

ok tb@
2025-09-02 18:06:02 +00:00
jca 72daaf9865 Hook up compiler-rt cpu_model detection on i386
Lack of support spotted by sthen@ in bulk build failures
(archivers/blosc2, archivers/unrar, etc).

ok kettenis@ tb@
2025-09-01 12:31:26 +00:00
miod b3acb0f4ae Relax pledge a bit until decode_options() has completed, for it might
perform a setrlimit() call requiring the "proc" pledge if you invoke the
compiler with -dH in order to be able to get a core dump of cc1{,plus} if
it ICEs.

ok deraadt@
2025-08-29 20:33:11 +00:00
miod 3e82a9a694 Disable forcing sjlj exceptions on m88k. 2025-08-29 16:19:12 +00:00
miod 84d9ee5125 Add definitions for unwind-based exception support. 2025-08-29 16:18:19 +00:00
miod 343428ccd9 The DWARF2 code is not smart enough to recognize double-register stores as such
and would create incomplete CFI information, concerning only the lowest register
of the pair. Hilarity^Wcoredumps would then occur while trying to handle
exceptions.

Attach a note with the equivalent pair of single stores instructions, to let
it do the right thing.
2025-08-29 16:17:06 +00:00
miod 5ab5786510 Move more static global data to the per-function machine-specific struct. 2025-08-29 16:16:06 +00:00
miod 32b94551c2 Use pic_address_needs_scratch() in SECONDARY_INPUT_RELOAD_CLASS() instead of
rolling our own version.
2025-08-29 16:15:44 +00:00
miod d8c38d2a68 Bump libstdc++ v3 major in order to prepare a smooth transition from gcc 3 to
gcc 4 on luna88k.
ok deraadt@
2025-08-28 06:07:29 +00:00
miod cd958be2a3 Define PROMOTE_MODE again. This had been done, then reverted because it
caused internal compiler errors building libobjc. But libobjc is no longer
being built and I am quite sure the problem would have been fixed by the
other bugfixes of the last few weeks.
2025-08-28 05:13:01 +00:00
miod 65c8070cf8 The delay slot description allowed for a jump instruction in the being present
in the delay slot of a branch instruction, as output_call had a way to merge
them.

But the jump instruction itself may have another instruction in its own delay
slot. This would cause generated code to be:
        bsr.n   function
        br.n    label
        another instruction
which confuses the processor and has absolutely no chance to work as intended.

Apparently we had been lucky enough to not stumble upon this in the gcc 2 and
gcc 3 times, but gcc 4 is more daring at optimizing things and ends up
producing this invalid code, especially in exception-related code paths.

The only safe thing to do is to declare jump instructions as not allowed in
the delay slot of branch instructions. This loses the output_call optimization
but code correctness is preferred.
2025-08-28 05:11:41 +00:00
kettenis 0f23fd2bd6 Enable outline atomics on OpenBSD/arm64 by default.
ok patrick@, deraadt@
2025-08-27 21:33:18 +00:00
kettenis ded8dd10ba aarch64 supports Float16; also add two missing files for BFloat16 support.
ok rsadowski@, miod@
2025-08-27 20:18:11 +00:00