Commit Graph

179 Commits

Author SHA1 Message Date
Mateusz Guzik
30ed48b0a5 clang: Skip attempts to access /proc/self/fd
In contrast to Linux it does not provide entries which can be readlinked
-- these are just regular files, not giving the expected outcome. That's
on top of procfs not being mounted by default to begin with.

Reviewed by:	dim
Differential Revision:		https://reviews.freebsd.org/D34684
2022-03-27 18:01:38 +00:00
Piotr Kubaj
9b597132ae Merge LLVM commit c03fdd340356 to fix lang/rust on powerpc
Summary:
Without it building rust fails with:
ld: error: CallSiteSplitting.cpp:(function llvm::SmallVectorImpl<std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<std::__1::pair<llvm::ICmpInst*, unsigned int>, 2u> > >::operator=(llvm::SmallVectorImpl<std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<std::__1::pair<llvm::ICmpInst*, unsigned int>, 2u> > >&&): .text._ZN4llvm15SmallVectorImplINSt3__14pairIPNS_10BasicBlockENS_11SmallVectorINS2_IPNS_8ICmpInstEjEELj2EEEEEEaSEOSB_+0xB0): relocation R_PPC_PLTREL24 out of range: -33582208 is not in [-33554432, 33554431]

This will need to be merged to releng/13.1.

Reviewed by:	dim
Differential Revision: https://reviews.freebsd.org/D34652
MFC after:	3 days
2022-03-24 09:06:12 +01:00
Dimitry Andric
8e72f458c6 Fix llvm build after 1b3bef43e3, due to API change
After merging llvm commit b9ca73e1a8fd for PR 262608, it would fail to
compile with:

/usr/src/contrib/llvm-project/llvm/lib/IR/Operator.cpp:197:22: error: no member named 'isZero' in 'llvm::APInt'
   if (!IndexedSize.isZero()) {
        ~~~~~~~~~~~ ^

Upstream refactored their APInt class, and isZero() was one of the newer
methods which did not yet exist in llvm 13.0.0. Fix this by using the
older but equivalent isNullValue() method instead.

Fixes:		1b3bef43e3
MFC after:	3 days
2022-03-20 00:12:58 +01:00
Dimitry Andric
1b3bef43e3 Apply llvm fix for assertion compiling certain versions of Wine
Merge commit b9ca73e1a8fd from llvm git (by Stephen Tozer):

  [DebugInfo] Correctly handle arrays with 0-width elements in GEP salvaging

  Fixes an issue where GEP salvaging did not properly account for GEP
  instructions which stepped over array elements of width 0 (effectively a
  no-op). This unnecessarily produced long expressions by appending
  `... + (x * 0)` and potentially extended the number of SSA values used
  in the dbg.value. This also erroneously triggered an assert in the
  salvage function that the element width would be strictly positive.
  These issues are resolved by simply ignoring these useless operands.

  Reviewed By: aprantl

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

PR:		262608
Reported by:	Damjan Jovanovic <damjan.jov@gmail.com>
MFC after:	3 days
2022-03-19 20:59:04 +01:00
Piotr Kubaj
3781e77995 riscv: actually enable sanitizers
1. Backport b475ce39e8.
2. Enable libclang_rt for riscv.

Previous commit missed it.

MFC after:	3 days
Reviewed by:	dim
Differential Revision: https://reviews.freebsd.org/D34543
2022-03-13 13:06:57 +01:00
Dimitry Andric
298c3e8d6b Apply lld fixes for internal errors building perl on 32-bit PowerPC
Merge commit f457863ae345 from llvm git (by Fangrui Song):

  [ELF] Support REL-format R_AARCH64_NONE relocation

  -fprofile-use=/-fprofile-sample-use= compiles may produce REL-format
  .rel.llvm.call-graph-profile even if the prevailing format is RELA on AArch64.
  Add R_AARCH64_NONE to getImplicitAddend to fix this linker error:

  ```
  ld.lld: error: internal linker error: cannot read addend for relocation R_AARCH64_NONE
  PLEASE submit a bug report to https://crbug.com and run tools/clang/scripts/process_crashreports.py (only works inside Google) which will upload a report and include the crash backtrace.
  ```

Merge commit 53fc5d9b9a01 from llvm git (by Fangrui Song):

  [ELF] Support R_PPC_NONE/R_PPC64_NONE in getImplicitAddend

  Similar to f457863ae345d2635026501f5383e0e625869639

Merge commit 767e64fc11d7 from llvm git (by Fangrui Song):

  [ELF] Support some absolute/PC-relative relocation types for REL format

  ctfconvert seems to use REL-format `.rel.SUNW_dof` for 32-bit architectures.
  ```
  Binary file usr/ports/lang/perl5.32/work/perl-5.32.1/dtrace_mini.o matches
  [alfredo.junior@dell-a ~/tmp/llvm-bug]$ readelf -r dtrace_mini.o

  Relocation section (.rel.SUNW_dof):
  r_offset r_info   r_type              st_value st_name
  00000184 0000281a R_PPC_REL32         00000000 $dtrace1772974259.Perl_dtrace_probe_load
  ```

  Support R_PPC_REL32 to fix `ld.lld: error: drti.c:(.SUNW_dof+0x4E4): internal linker error: cannot read addend for relocation R_PPC_REL32`.
  While here, add some common relocation types for AArch64, PPC, and PPC64.
  We perform minimum tests.

  Reviewed By: adalava, arichardson

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

Requested by:	alfredo
MFC after:	3 days
2022-02-27 13:53:19 +01:00
Dimitry Andric
1c21bfb1b1 Apply fix for ThreadSanitizer false positive data race reports
Merge commit 28fb22c90fe7 from llvm git (by Dimitry Andric):

  [TSan] Handle FreeBSD specific indirection of libpthread functions

  Similar to 60cc1d3218fc for NetBSD, add aliases and interceptors for the
  following pthread related functions:

  - pthread_cond_init(3)
  - pthread_cond_destroy(3)
  - pthread_cond_signal(3)
  - pthread_cond_broadcast(3)
  - pthread_cond_wait(3)
  - pthread_mutex_init(3)
  - pthread_mutex_destroy(3)
  - pthread_mutex_lock(3)
  - pthread_mutex_trylock(3)
  - pthread_mutex_unlock(3)
  - pthread_rwlock_init(3)
  - pthread_rwlock_destroy(3)
  - pthread_rwlock_rdlock(3)
  - pthread_rwlock_tryrdlock(3)
  - pthread_rwlock_wrlock(3)
  - pthread_rwlock_trywrlock(3)
  - pthread_rwlock_unlock(3)
  - pthread_once(3)
  - pthread_sigmask(3)

  In FreeBSD's libc, a number of internal aliases of the pthread functions
  are invoked, typically with an additional prefixed underscore, e.g.
  _pthread_cond_init() and so on.

  ThreadSanitizer needs to intercept these aliases too, otherwise some
  false positive reports about data races might be produced.

  Reviewed By: dvyukov

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

MFC after:	3 days
2022-02-07 19:39:02 +01:00
Ed Maste
930a7c2ac6 compiler-rt: re-exec with ASLR disabled when necessary
Some sanitizers (at least msan) currently require ASLR to be disabled.
When we detect that ASLR is enabled, re-exec with it disabled rather
than exiting with an error.  See LLVM GitHub issue 53256 for more
detail: https://github.com/llvm/llvm-project/issues/53256

No objection:	dim
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33934
2022-02-04 11:20:00 -05:00
Ed Maste
96fe7c8ab0 compiler-rt: support ReExec() on FreeBSD
Based on getMainExecutable() in llvm/lib/Support/Unix/Path.inc.
This will need a little more work for an upstream change as it must
support older FreeBSD releases that lack elf_aux_info() / AT_EXEC_PATH.

No objection:	dim
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33934
2022-02-04 11:18:12 -05:00
Dimitry Andric
fdf2784101 Apply clang fix for assertion failure compiling science/chrono
Merge commit 6b0f35931a44 from llvm git (by Jennifer Yu):

  Fix signal during the call to checkOpenMPLoop.

  The root problem is a null pointer is accessed during the call to
  checkOpenMPLoop, because loop up bound expr is an error expression
  due to error diagnostic was emit early.

  To fix this, in setLCDeclAndLB, setUB and setStep instead return false,
  return true when LB, UB or Step contains Error, so that the checking is
  stopped in checkOpenMPLoop.

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

Note this only fixes the assertion reported in bug 261567; some other
tweaks for port dependencies are probably still required to make it
build to completion.

PR:		261567
MFC after:	3 days
2022-01-30 21:41:37 +01:00
Dimitry Andric
9738bc28ab Apply llvm fix for assertion failure compiling recent libc++
Merge commit c7c84b90879f from llvm git (by Adrian Prantl):

  [DwarfDebug] Refuse to emit DW_OP_LLVM_arg values wider than 64 bits

  DwarfExpression::addUnsignedConstant(const APInt &Value) only supports
  wider-than-64-bit values when it is used to emit a top-level DWARF
  expression representing the location of a variable. Before this change,
  it was possible to call addUnsignedConstant on >64 bit values within a
  subexpression when substituting DW_OP_LLVM_arg values.

  This can trigger an assertion failure (e.g. PR52584, PR52333) when it
  happens in a fragment (DW_OP_LLVM_fragment) expression, as
  addUnsignedConstant on >64 bit values splits the constant into separate
  DW_OP_pieces, which modifies DwarfExpression::OffsetInBits.

  This change papers over the assertion errors by bailing on overly wide
  DW_OP_LLVM_arg values. A more comprehensive fix might be to be to split
  wide values into pointer-sized fragments.

  [0] https://github.com/llvm/llvm-project/blob/e71fa03/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp#L799-L805

  Patch by Ricky Zhou!

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

MFC after:	3 days
2022-01-29 22:28:24 +01:00
Ed Maste
7cafe89f9c sanitizers: Improve FreeBSD ASLR detection
The kern.elf64.aslr.pie_enable and kern.elf32.aslr.pie_enable sysctls
control the default setting for PIE binary address randomization, but
it is possible to enable or disable ASLR on a per-process basis.  Use
procctl(2) to query whether ASLR is enabled.

(Note that with ASLR enabled but sysctl kern.elf64.aslr.pie_enable=0
a PIE binary will in effect have randomization disabled, and be
functional with msan.  This is not intended as as a user-facing control
though.  The user can use proccontrol(1) to disable aslr for the
process.)

Approved by:	dim
Obtained from:	LLVM 64de0064f315f57044294879d9ff4eacb454d45b
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33933
2022-01-19 13:07:40 -05:00
Dimitry Andric
1331805574 Avoid emitting popcnt in libclang_rt.fuzzer*.a if unsupported
Since popcnt is only supported by CPUTYPE=nehalem and later, ensure that
this instruction is only emitted when appropriate. Otherwise, programs
using the library can abort with SIGILL.

See also: https://github.com/llvm/llvm-project/issues/52893

PR:		258156
Reported by:	Eric Rucker <bhtooefr@bhtooefr.org>
MFC after:	3 days
2021-12-30 10:55:49 +01:00
Dimitry Andric
ada8b24d48 Apply clang fix for crash or assertion failure compiling part of llvm
Merge commit 77e8f4eeeeed from llvm git (by David Green):

  [ARM] Define ComplexPatternFuncMutatesDAG

  Some of the Arm complex pattern functions call canExtractShiftFromMul,
  which can modify the DAG in-place. For this to be valid and handled
  successfully we need to define ComplexPatternFuncMutatesDAG.

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

When building parts of llvm targeting armv6 on stable/12, the following
assertion can appear (or if assertions are disabled, clang is likely to
crash):

Assertion failed: (NodeToMatch->getOpcode() != ISD::DELETED_NODE && "NodeToMatch was removed partway through selection"), function SelectCodeCommon, file /usr/src/contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp, line 3573.
PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /usr/obj/usr/src/freebsd12-amd64/tmp/usr/bin/c++ -cc1 -triple armv6kz-unknown-freebsd12.3-gnueabihf -S --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -mrelocation-model static -mconstructor-aliases -target-cpu arm1176jzf-s -target-feature +vfp2 -target-feature +vfp2sp -target-feature -vfp3 -target-feature -vfp3d16 -target-feature -vfp3d16sp -target-feature -vfp3sp -target-feature -fp16 -target-feature -vfp4 -target-feature -vfp4d16 -target-feature -vfp4d16sp -target-feature -vfp4sp -target-feature -fp-armv8 -target-feature -fp-armv8d16 -target-feature -fp-armv8d16sp -target-feature -fp-armv8sp -target-feature -fullfp16 -target-feature +fp64 -target-feature -d32 -target-feature -neon -target-feature -sha2 -target-feature -aes -target-feature -fp16fml -target-feature +strict-align -target-abi aapcs-linux -mfloat-abi hard -fallow-half-arguments-and-returns -ffunction-sections -fdata-sections -O1 -std=c++14 -fdeprecated-macro -fno-rtti -fno-signed-char -faddrsig -fexperimental-new-pass-manager PPCISelLowering-009095.ii
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'PPCISelLowering-009095.cpp'.
4.	Running pass 'ARM Instruction Selection' on function '@_ZN4llvm17PPCTargetLoweringC2ERKNS_16PPCTargetMachineERKNS_12PPCSubtargetE'

This crash or assertion is fixed by the upstream commit.

MFC after:	3 days
2021-12-24 12:46:00 +01:00
Dimitry Andric
5a925e4644 Apply fix for clang incorrectly optimizing part of dns/bind916
Merge commit e5a8af7a90c6 from llvm git (by Gulfem Savrun Yeniceri):

  [Passes] Fix relative lookup table converter pass

  This patch fixes the relative table converter pass for the lookup table
  accesses that are resulted in an instruction sequence, where gep is not
  immediately followed by a load, such as gep being hoisted outside the loop
  or another instruction is inserted in between them. The fix inserts the
  call to load.relative.instrinsic in the original place of load instead of gep.
  Issue is reported by FreeBSD via https://bugs.freebsd.org/259921.

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

PR:		259921
Reported by:	O. Hartmann <freebsd@walstatt-de.de>
MFC after:	3 days
2021-12-15 22:27:39 +01:00
Dimitry Andric
da2012af42 Revert clang change that breaks CTF on aarch64
Revert commit e655e74a318e from llvm git (by Peter Collingbourne):

  AST: Create __va_list in the std namespace even in C.

  This ensures that the mangled type names match between C and C++,
  which is significant when using -fsanitize=cfi-icall. Ideally we
  wouldn't have created this namespace at all, but it's now part of
  the ABI (e.g. in mangled names), so we can't change it.

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

As reported by Jessica in https://reviews.llvm.org/D104830#3129527, this
upstream change is implemented in such a way that it breaks DTrace's
CTF. Since a proper fix has not yet been forthcoming, and we are
unaffected by the (CFI-related) problem upstream was trying to address,
revert the change for now.

Requested by:	jrtc27
MFC after:	3 days
2021-12-12 21:11:40 +01:00
Dimitry Andric
a9cd5c30d6 Apply fix for clang crashing on invalid -Wa,-march= values
Merge commit df08b2fe8b35 from llvm git (by Dimitry Andric):

  [AArch64] Avoid crashing on invalid -Wa,-march= values

  As reported in https://bugs.freebsd.org/260078, the gnutls Makefiles
  pass -Wa,-march=all to compile a number of assembly files. Clang does
  not support this -march value, but because of a mistake in handling
  the arguments, an unitialized Arg pointer is dereferenced, which can
  cause a segfault.

  Work around this by adding a check if the local WaMArch variable is
  initialized, and if so, using its value in the diagnostic message.

  Reviewed By: tschuett

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

PR:		260078
Reported by:	bz
MFC after:	3 days
2021-12-05 18:54:13 +01:00
Dimitry Andric
3adc9c8c73 Belatedly update contrib/llvm-project/FREEBSD-Xlist for llvm 13
MFC after:      2 weeks
2021-11-20 18:06:36 +01:00
Dimitry Andric
397a8ba053 Apply fix for LLVM PR51957 (Miscompilation in Botan's SHA3)
Merge commit e27a6db5298f from llvm git (by Jameson Nash):

  Bad SLPVectorization shufflevector replacement, resulting in write to wrong memory location

  We see that it might otherwise do:

    %10 = getelementptr {}**, <2 x {}***> %9, <2 x i32> <i32 10, i32 4>
    %11 = bitcast <2 x {}***> %10 to <2 x i64*>
  ...
    %27 = extractelement <2 x i64*> %11, i32 0
    %28 = bitcast i64* %27 to <2 x i64>*
    store <2 x i64> %22, <2 x i64>* %28, align 4, !tbaa !2

  Which is an out-of-bounds store (the extractelement got offset 10
  instead of offset 4 as intended). With the fix, we correctly generate
  extractelement for i32 1 and generate correct code.

  Differential Revision: https://reviews.llvm.org/D106613
2021-11-13 21:52:25 +01:00
Dimitry Andric
a18c6161ef Fix assertion when building devel/glog with new pass manager
Merge commit 029f1a534489 from llvm git (by Arthur Eubanks):

  [LazyCallGraph] Skip blockaddresses

  blockaddresses do not participate in the call graph since the only
  instructions that use them must all return to someplace within the
  current function. And passes cannot retrieve a function address from a
  blockaddress.

  This was suggested by efriedma in D58260.

  Fixes PR50881.

  Reviewed By: nickdesaulniers

  Differential Revision: https://reviews.llvm.org/D112178
2021-11-13 21:52:24 +01:00
Dimitry Andric
4e117af10c Fix "Bad machine code" when building world for mips or mips64
Merge commit f5755c0849a5 from llvm git (by Jessica Clarke):

  [Mips] Add glue between CopyFromReg, CopyToReg and RDHWR nodes for TLS

  The MIPS ABI requires the thread pointer be accessed via rdhwr $3, $r29.
  This is currently represented by (CopyToReg $3, (RDHWR $29)) followed by
  a (CopyFromReg $3). However, there is no glue between these, meaning
  scheduling can break those apart. In particular, PR51691 is a report
  where PseudoSELECT_I was moved to between the CopyToReg and CopyFromReg,
  and since its expansion uses branches, it split the def and use of the
  physical register between two basic blocks, resulting in the def being
  eliminated and the use having no def. It also seems possible that a
  similar situation could arise splitting up the CopyToReg from the RDHWR,
  causing the RDHWR to use a destination register other than $3, violating
  the ABI requirement.

  Thus, add glue between all three nodes to ensure they aren't split up
  during instruction selection. No regression test is added since any test
  would be implictly relying on specific scheduling behaviour, so whilst
  it might be testing that glue is preventing reordering today, changes to
  scheduling behaviour could result in the test no longer being able to
  catch a regression here, as the reordering might no longer happen for
  other unrelated reasons.

  Fixes PR51691.

  Reviewed By: atanasyan, dim

  Differential Revision: https://reviews.llvm.org/D111967
2021-11-13 21:52:24 +01:00
Dimitry Andric
39dadd0628 Stop clang 13 from defining conflicting macros on PowerPC
Merge commit c9539f957f57 from llvm git (by Nemanja Ivanovic):

  [PowerPC] Define XL-compatible macros only for AIX and Linux

  Since XLC only ever shipped on PowerPC AIX and Linux, it is not
  reasonable to provide the compatibility macros on any target other
  than those two. This patch restricts those macros to AIX/Linux.

  Differential revision: https://reviews.llvm.org/D110213

PR:		258209
2021-11-13 21:52:23 +01:00
Dimitry Andric
28a41182c0 Merge llvm-project 13.0.0 release
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-13.0.0-0-gd7b669b3a303, aka 13.0.0 release.

PR:		258209
MFC after:	2 weeks
2021-11-13 21:49:29 +01:00
Dimitry Andric
8c6f6c0c80 Merge llvm-project release/13.x llvmorg-13.0.0-rc3-8-g08642a395f23
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-13.0.0-rc3-8-g08642a395f23.

PR:		258209
MFC after:	2 weeks
2021-11-13 21:46:08 +01:00
Dimitry Andric
69ade1e033 Merge llvm-project release/13.x llvmorg-13.0.0-rc2-43-gf56129fe78d5
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-13.0.0-rc2-43-gf56129fe78d5.

PR:		258209
MFC after:	2 weeks
2021-11-13 21:45:49 +01:00
Dimitry Andric
6e75b2fbf9 Merge llvm-project release/13.x llvmorg-13.0.0-rc1-97-g23ba3732246a
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-13.0.0-rc1-97-g23ba3732246a.

PR:		258209
MFC after:	2 weeks
2021-11-13 21:42:03 +01:00
Dimitry Andric
fe6060f10f Merge llvm-project main llvmorg-13-init-16847-g88e66fa60ae5
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-13-init-16847-g88e66fa60ae5, the last commit before
the upstream release/13.x branch was created.

PR:		258209
MFC after:	2 weeks
2021-11-13 21:39:49 +01:00
Dimitry Andric
4b9725184e Fix clang's internal assembler adding unwanted prefix to VIA xstore
Merge commit 2d8c18fbbdd1 from llvm git (by Jessica Clarke):

  [X86] Don't add implicit REP prefix to VIA PadLock xstore

  Commit 8fa3e8fa1492 added an implicit REP prefix to all VIA PadLock
  instructions, but GNU as doesn't add one to xstore, only all the others.
  This resulted in a kernel panic regression in FreeBSD upon updating to
  LLVM 11 (https://bugs.freebsd.org/259218) which includes the commit in
  question. This partially reverts that commit.

  Reviewed By: craig.topper

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

MFC after:	3 days
2021-10-23 20:20:00 +02:00
Dimitry Andric
efe67f33c3 compiler-rt: add aarch64 init function for LSE atomics
As reported by Ronald, adding the out-of-line LSE atomics helpers for
aarch64 to compiler-rt was not sufficient to link programs using these,
as they also require a __aarch64_have_lse_atomics global. This is
initialized in compiler-rt's lib/builtins/cpu_model.c, roughly similar
to the x86 CPU model and feature detection in that file.

Since upstream does not yet have a FreeBSD specific implementation for
getting the required information, add a simple one that should work for
now, while I try to get it sorted with the LLVM people.

Reported by:	Ronald Klop <ronald-lists@klop.ws>
Fixes:		cc55ee8009
PR:		257392
MFC after:	2 weeks
2021-09-06 21:24:01 +02:00
Alfredo Dal'Ava Junior
f21fcae487 llvm: Revert "[HardwareLoops] Change order of SCEV expression construction for InitLoopCount."
Reverts llvm commit 42eaf4fe0adef3344adfd9fbccd49f325cb549ef, pointed
from bisect as source of regression that causes liblzma to compress/
uncompress incorrectly. It's know to affect powerpc64 BE only.

The patch unbreaks FreeBSD powerpc64 installation media, since
bsdinstall can't uncompress the *.txz produced by FreeBSD CI. It's
probably miscompiling other software bas well.

Upstream PR: https://bugs.llvm.org/show_bug.cgi?id=51714

Reviewed by:	dim
MFC after:	2 days
Sponsored by:	Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D31804
2021-09-03 13:31:54 -03:00
Alfredo Dal'Ava Junior
9a4d48a645 llvm/powerpc64*: fix broken binaries generated by clang12
Amends LLVM commit 2518433f861fcb877d0a7bdd9aec1aec1f77505a that
was pointed as the source of regression on LLVM12.

This affects powerpc64*, making binaries crash with segmentation fault
due to bad code generation around "__stack_chk_guard"

Root cause and/or proper fix is under investigation by:
    https://bugs.llvm.org/show_bug.cgi?id=51590

Reviewed by:    dim
MFC after:      2 days
Sponsored by:   Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:  https://reviews.freebsd.org/D31698
2021-08-27 11:47:11 -03:00
Dimitry Andric
efa485d5c3 Apply clang fix for assertion failure compiling multimedia/minitube
Merge commit 79f9cfbc21e0 from llvm git (by Yaxun (Sam) Liu):

  Do not merge LocalInstantiationScope for template specialization

  A lambda in a function template may be recursively instantiated. The recursive
  lambda will cause a lambda function instantiated multiple times, one inside another.
  The inner LocalInstantiationScope should not be marked as MergeWithParentScope
  since it already has references to locals properly substituted, otherwise it causes
  assertion due to the check for duplicate locals in merged LocalInstantiationScope.

  Reviewed by: Richard Smith

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

Reported by:	yuri
PR:		257978
MFC after:	3 days
2021-08-21 23:03:50 +02:00
Dimitry Andric
c1a540709a Apply upstream lldb fix for unhandled Error causing abort
Merge commit 5033f0793fe6 from llvm git (by Dimitry Andric):

  [lldb] Avoid unhandled Error in TypeSystemMap::GetTypeSystemForLanguage

  When assertions are turned off, the `llvm::Error` value created at the
  start of this function is overwritten using the move-assignment
  operator, but the success value is never checked. Whenever a TypeSystem
  cannot be found or created, this can lead to lldb core dumping with:

      Program aborted due to an unhandled Error:
      Error value was Success. (Note: Success values must still be checked prior to being destroyed).

  Fix this by not creating a `llvm::Error` value in advance, and directly
  returning the result of `llvm::make_error` instead, whenever an error is
  encountered.

  See also: <https://bugs.freebsd.org/253881> and
  <https://bugs.freebsd.org/257829>.

  Reviewed By: teemperor

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

Reported by:	dmgk, ota@j.email.ne.jp
PR:		253881, 257829
MFC after:	3 days
2021-08-16 18:57:24 +02:00
Dimitry Andric
d69d07569e Apply upstream lld fix for compressed input sections on BE targets
Merge commit c6ebc651b6fa from llvm git (by Simon Atanasyan):

  [LLD] Support compressed input sections on big-endian targets

  This patch enables compressed input sections on big-endian targets by
  checking the target endianness and selecting an appropriate `Chdr`
  structure.

  Fixes PR51369

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

Reported by:	emaste
MFC after:	3 days
2021-08-07 13:14:11 +02:00
Alex Richardson
31ba4ce889 Allow bootstrapping llvm-tblgen on macOS and Linux
This is needed in order to build various LLVM binutils (e.g. addr2line)
as well as clang/lld/lldb.

Co-authored-by: Jessica Clarke <jrtc27@FreeBSD.org>
Test Plan:	Compiles on ubuntu 18.04 and macOS 11.4
Reviewed By:	dim
Differential Revision: https://reviews.freebsd.org/D31057
2021-08-02 14:36:03 +01:00
Dimitry Andric
4652422eb4 Merge llvm-project 12.0.1 release
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12.0.1-0-gfed41342a82f, a.k.a. 12.0.1 release.

PR:		255570
MFC after:	6 weeks
2021-07-16 18:29:42 +02:00
Dimitry Andric
5866c369e4 Revert libunwind change to fix backtrace segfault on aarch64
Revert commit 22b615a96593 from llvm git (by Daniel Kiss):

  [libunwind] Support for leaf function unwinding.

  Unwinding leaf function is useful in cases when the backtrace finds a
  leaf function for example when it caused a signal.
  This patch also add the support for the DW_CFA_undefined because it marks
  the end of the frames.

  Ryan Prichard provided code for the tests.

  Reviewed By: #libunwind, mstorsjo

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

  Reland with limit the test to the x86_64-linux target.

Bisection has shown that this particular upstream commit causes programs
using backtrace(3) on aarch64 to segfault. This affects the lang/rust
port, for instance. Until we can upstream to fix this problem, revert
the commit for now.

Reported by:	mikael
PR:		256864
2021-07-03 00:35:49 +02:00
Ed Maste
b762974cf4 clang: stop linking _p libs for -pg as of FreeBSD 14
In FreeBSD 14 we will stop providing _p libraries (compiled with -pg).

Reviewed by:	dim (upstream)
Obtained from:	LLVM 699d47472c3f
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D30861
2021-06-27 13:12:12 -04:00
Dimitry Andric
014a40f8f6 Disable llvm generating 128-bit multiply libcalls on 32-bit ARM
Merge commit 789708617d20 from llvm git (Koutheir Attouchi):

  Do not generate calls to the 128-bit function __multi3() on 32-bit ARM

  Re-applying this patch after bots failures. Should be fine now.

  The function __multi3() is undefined on 32-bit ARM, so a call to it should
  never be emitted. Instead, plain instructions need to be generated to
  perform 128-bit multiplications.

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

Reported by:	mmel
MFC after:	3 days
2021-06-22 22:26:13 +02:00
Dimitry Andric
e7e517981a Fix clang assertion while building recent www/chromium
Merge commit c8227f06b335 from llvm git (by Arthur Eubanks):

  [clang] Don't assert in EmitAggregateCopy on trivial_abi types

  Fixes PR42961.

  Reviewed By: rnk

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

PR:		256721, 255570
Reported by:	jbeich
MFC after:	3 days
2021-06-21 20:48:37 +02:00
Dimitry Andric
23408297fb Merge llvm-project 12.0.1 rc2
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12.0.1-rc2-0-ge7dac564cd0e, a.k.a. 12.0.1 rc2.

PR:		255570
MFC after:	6 weeks
2021-06-19 20:09:28 +02:00
Dimitry Andric
d099db2546 Apply upstream libc++ fix to allow building with devel/xxx-xtoolchain-gcc
Merge commit 52e9d80d5db2 from llvm git (by Jason Liu):

  [libc++] add `inline` for __open's definition in ifstream and ofstream

  Summary:

  When building with gcc on AIX, it seems that gcc does not like the
  `always_inline` without the `inline` keyword.
  So adding the inline keywords in for __open in ifstream and ofstream.
  That will also make it consistent with __open in basic_filebuf
  (it seems we added `inline` there before for gcc build as well).

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

PR:		255570
MFC after:	6 weeks
2021-06-14 20:44:09 +02:00
Dimitry Andric
715df83abc Disable strict-fp for powerpcspe, as it does not work properly yet
Merge commit 5c18d1136665 from llvm git (by Qiu Chaofan)

  [SPE] Disable strict-fp for SPE by default

  As discussed in PR50385, strict-fp on PowerPC SPE has not been
  handled well. This patch disables it by default for SPE.

  Reviewed By: nemanjai, vit9696, jhibbits

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

PR:		255570
MFC after:	6 weeks
2021-06-14 18:10:03 +02:00
Dimitry Andric
d409305fa3 Merge llvm-project 12.0.0 release
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12.0.0-0-gd28af7c654d8, a.k.a. 12.0.0 release.

PR:		255570
MFC after:	6 weeks
2021-06-13 22:01:15 +02:00
Dimitry Andric
e8d8bef961 Merge llvm-project main llvmorg-12-init-17869-g8e464dd76bef
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12-init-17869-g8e464dd76bef, the last commit before the
upstream release/12.x branch was created.

PR:		255570
MFC after:	6 weeks
2021-06-13 21:37:19 +02:00
Dimitry Andric
1b00608b26 Merge llvm commits for kernel address and memory sanitizer support
Merge commit 99eca1bd9c7a from llvm git (by Mark Johnston):

  [Driver] Enable kernel address and memory sanitizers on FreeBSD

  Test Plan: using kernel ASAN and MSAN implementations in FreeBSD

  Reviewed By: emaste, dim, arichardson

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

Merge commit f511dc75e4c1 from llvm git (by Mark Johnston):

  [asan] Add an offset for the kernel address sanitizer on FreeBSD

  This is based on a port of the sanitizer runtime to the FreeBSD kernel
  that has been commited as https://cgit.freebsd.org/src/commit/?id=38da497a4dfcf1979c8c2b0e9f3fa0564035c147
  and the following commits.

  Reviewed By: emaste, dim
  Differential Revision: https://reviews.llvm.org/D98285

Requested by:	markj
MFC after:	3 days
2021-04-27 21:18:13 +02:00
Ed Maste
19587d7422 clang: Fix -gz=zlib options for linker
Clang commit ccb4124a4172bf2cb2e1cd7c253f0f1654fce294:

Fix -gz=zlib options for linker

gcc translates -gz=zlib to --compress-debug-options=zlib for both
assembler and linker but clang only does this for assembler.

The linker needs --compress-debug-options=zlib option to compress the
debug sections in the generated executable or shared library.

Due to this bug, -gz=zlib has no effect on the generated executable or
shared library.

This patch fixes that.

Clang commit 462cf39a5c180621b56f7602270ce33eb7b68d23:

[Driver] Fix -gz=zlib options for linker also on FreeBSD

ccb4124a4172 fixed translating -gz=zlib to --compress-debug-sections for
linker invocation for several ToolChains, but omitted FreeBSD.

Approved by:	dim
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29028
2021-03-04 15:10:03 -05:00
Dimitry Andric
e63539f305 Fix clang assertion when compiling the devel/onetbb port
Merge commit 740a164de from llvm git (by Richard Smith):

  PR46377: Fix dependence calculation for function types and typedef
  types.

  We previously did not treat a function type as dependent if it had a
  parameter pack with a non-dependent type -- such a function type depends
  on the arity of the pack so is dependent even though none of the
  parameter types is dependent. In order to properly handle this, we now
  treat pack expansion types as always being dependent types (depending on
  at least the pack arity), and always canonically being pack expansion
  types, even in the unusual case when the pattern is not a dependent
  type. This does mean that we can have canonical types that are pack
  expansions that contain no unexpanded packs, which is unfortunate but
  not inaccurate.

  We also previously did not treat a typedef type as
  instantiation-dependent if its canonical type was not
  instantiation-dependent. That's wrong because instantiation-dependence
  is a property of the type sugar, not of the type; an
  instantiation-dependent type can have a non-instantiation-dependent
  canonical type.

Merge commit 9cf98d26e from llvm git (by Richard Smith):

  PR46637: Fix handling of placeholder types in trailing-return-types.

  Only permit a placeholder type in a trailing-return-type if it would
  also have been permitted in the decl-specifier sequence of a
  corresponding declaration with no trailing-return-type. The standard
  doesn't actually say this, but this is the only thing that makes sense.

  Also fix handling of an 'auto' in a trailing-return-type in a parameter
  of a generic lambda. We used to crash if we saw such a thing.

Merge commit 234f51a65 from llvm git (by Richard Smith):

  Don't crash if we deserialize a pack expansion type whose pattern
  contains no packs.

  Fixes a regression from 740a164dec483225cbd02ab6c82199e2747ffacb.

PR:		252892
Reported by:	thierry
MFC after:	3 days
2021-01-26 17:51:25 +01:00
Dimitry Andric
86d2671e3e Update contrib/llvm-project/FREEBSD-Xlist for llvmorg-11.0.1-rc2.
MFC after:	4 weeks
X-MFC-With:	r364284
2021-01-03 14:21:54 +01:00
Dimitry Andric
eaeb601bd6 Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
release/11.x llvmorg-11.0.1-rc2-0-g43ff75f2c3f (aka 11.0.1 rc2).

MFC after:	4 weeks
X-MFC-With:	r364284
2021-01-03 13:54:24 +01:00