Commit Graph

4531 Commits

Author SHA1 Message Date
Hafiz Abid Qadeer 670686ad8e Add initial support for multilibs in Baremetal toolchain.
This patch add support of riscv multilibs in the Baremetal toolchain. It is
a bit different to what is done in GNU.cpp as we are not iterating a
GNU sysroot to find the multilibs. This is intended for an llvm only
toolchain. We are not checking for the presence of any runtime bits to
enable a specific multilib.

I have structured the patch so that other targets for which
there is no multilibs support yet in Baremetal.cpp (e.g. arm-none-eabi)
will not be affected. Patch also allows some multilibs reuse.

Long term, I would like to go in the direction of data-driven specification of
multilib directories and flags.

Reviewed By: jroelofs

Differential Revision: https://reviews.llvm.org/D93138
2020-12-14 20:49:45 +00:00
Kazushi (Jam) Marukawa 05d1729232 [VE] Optimize toolchain regression test
Optimize toolchain regression test for VE by removing not a useful test
(-fuse-init-array test) and merge several tests to one test which checks
default behavior of driver.  Also add sysroot to reduce conflicts.

These are suggested in https://reviews.llvm.org/D92996.
Thank you so much.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D93084
2020-12-13 20:26:05 +09:00
Nico Weber 956034c6c8 [mac/arm] XFAIL two more tests on arm64-apple
Part of PR46644
2020-12-12 15:20:50 -05:00
Nico Weber a5c65de295 mac/arm: XFAIL the last 3 failing tests
We should fix them, but let's XFAIL them for now so that we can start
running check-clang on bots and lock in the passing tests.

Part of 46644.
2020-12-12 15:09:17 -05:00
Kazushi (Jam) Marukawa cd5855ac3b [VE] Remove -faddrsig and -fnoaddrsig tests
Remove explicitly declared -faddrsig and -fnoaddrsig option tests
since those are already tested in addrsig.c.  We test only the implicit
behavior of VE driver.

This is suggested in https://reviews.llvm.org/D92386.  Thanks.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D92996
2020-12-11 08:25:38 +09:00
Andrzej Warzynski 764690b8a8 [clang] Remove `-triple` from the invocations of `flang-new -fc1`
This is just a small change in the Flang tool within libclangDriver.
Currently it passes `-triple` when calling `flang-new -fc1` for various
driver Jobs. As there is no support for code-generation, `-triple` is
not required and should remain unsupported. It is safe to remove it.

This hasn't been a problem as the affected driver Jobs are not yet
implemented or used. However, we will be adding support for them in the
near future and the fact `-triple` is added will become a problem.

Differential Revision: https://reviews.llvm.org/D93027
2020-12-10 17:54:12 +00:00
Peter Waller 2315e9874c [AArch64][Driver][SVE] Push missing SVE feature error from driver to frontend
... and give more guidance to users.

If specifying -msve-vector-bits on a non-SVE target, clang would say:

    error: '-msve-vector-bits' is not supported without SVE enabled

1. The driver lacks logic for "implied features".
   This would result in this error being raised for -march=...+sve2,
   even though +sve2 implies +sve.

2. Feature implication is well modelled in LLVM, so push the error down
   the stack.

3. Hint to the user what flag they need to consider setting.

Now clang fails later, when the feature is used, saying:

  aarch64-sve-vector-bits.c:42:41: error: 'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=
  typedef svint32_t noflag __attribute__((arm_sve_vector_bits(256)));

Move clang/test/Sema/{neon => arm}-vector-types-support.c and put tests for
this warning together in one place.

Reviewed By: sdesmalen

Differential Revision: https://reviews.llvm.org/D92487
2020-12-10 12:43:14 +00:00
Fangrui Song 880aa6ac66 [test] Fix test/Driver/ve-toolchain.cpp
It should specify --sysroot to test the paths of crt1.o/crti.o/crtbegin.o.
For a user who enable VE but do not actually have VE sysroot,
the "nld" command line will have bare "crt1.o" "crti.o" ... "crtbegin.o"
2020-12-09 17:26:22 -08:00
Fangrui Song f9c0d1b056 [Driver] Add -f[no-]legacy-pass-manager to supersede -f[no-]experimental-new-pass-manager
The new PM is considered stable and many downstream groups have adopted it (some
have adopted it for more than two years). Add -f[no-]legacy-pass-manager to reflect the
fact that it is no longer experimental and the legacy pass manager is something we strive to retire.

In the future, when the legacy PM eventually goes away,
-fno-experimental-new-pass-manager and -flegacy-pass-manager will be removed.

This patch also changes -f[no-]legacy-pass-manager to pass `-plugin-opt={new,legacy}-pass-manager` to the linker (supported by both ld.lld and LLVMgold.so) when -flto/-flto=thin is specified

Reviewed By: aeubanks, rsmith

Differential Revision: https://reviews.llvm.org/D92915
2020-12-09 16:57:36 -08:00
Artem Belevich 016e4ebfde [DWARF] Allow toolchain to adjust specified DWARF version.
This is needed for CUDA compilation where NVPTX back-end only supports DWARF2,
but host compilation should be allowed to use newer DWARF versions.

Differential Revision: https://reviews.llvm.org/D92617
2020-12-09 16:34:34 -08:00
Fangrui Song 85c18d3521 [Driver] Add -gno-split-dwarf which can disable debug fission
Currently when -gsplit-dwarf is specified (could be buried in a build system),
there is no convenient way to cancel debug fission without affecting the debug
information amount (all of -g0, -g1 -fsplit-dwarf-inlining and -gline-directives-only
can, but they affect the debug information amount).

Reviewed By: #debug-info, dblaikie

Differential Revision: https://reviews.llvm.org/D92809
2020-12-08 13:24:59 -08:00
Fangrui Song 843f2dbf00 [Driver] Don't make -gsplit-dwarf imply -g2
RFC: http://lists.llvm.org/pipermail/cfe-dev/2020-May/065430.html
Agreement from GCC: https://sourceware.org/pipermail/gcc-patches/2020-May/545688.html

g_flags_Group options generally don't affect the amount of debugging
information. -gsplit-dwarf is an exception. Its order dependency with
other gN_Group options make it inconvenient in a build system:

* -g0 -gsplit-dwarf -> level 2
   -gsplit-dwarf "upgrades" the amount of debugging information despite
   the previous intention (-g0) to drop debugging information
* -g1 -gsplit-dwarf -> level 2
  -gsplit-dwarf "upgrades" the amount of debugging information.
* If we have a higher-level -gN, -gN -gsplit-dwarf will supposedly decrease the
  amount of debugging information. This happens with GCC -g3.

The non-orthogonality has confused many users. GCC 11 will change the semantics
(-gsplit-dwarf no longer implies -g2) despite the backwards compatibility break.
This patch matches its behavior.

New semantics:

* If there is a g_Group, allow split DWARF if useful
  (none of: -g0, -gline-directives-only, -g1 -fno-split-dwarf-inlining)
* Otherwise, no-op.

To restore the original behavior, replace -gsplit-dwarf with -gsplit-dwarf -g.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D80391
2020-12-08 13:14:34 -08:00
Yuanfang Chen 1821265db6 [Time-report] Add a flag -ftime-report={per-pass,per-pass-run} to control the pass timing aggregation
Currently, -ftime-report + new pass manager emits one line of report for each
pass run. This potentially causes huge output text especially with regular LTO
or large single file (Obeserved in private tests and was reported in D51276).
The behaviour of -ftime-report + legacy pass manager is
emitting one line of report for each pass object which has relatively reasonable
text output size. This patch adds a flag `-ftime-report=` to control time report
aggregation for new pass manager.

The flag is for new pass manager only. Using it with legacy pass manager gives
an error. It is a driver and cc1 flag. `per-pass` is the new default so
`-ftime-report` is aliased to `-ftime-report=per-pass`. Before this patch,
functionality-wise `-ftime-report` is aliased to `-ftime-report=per-pass-run`.

* Adds an boolean variable TimePassesHandler::PerRun to control per-pass vs per-pass-run.
* Adds a new clang CodeGen flag CodeGenOptions::TimePassesPerRun to work with the existing CodeGenOptions::TimePasses.
* Remove FrontendOptions::ShowTimers, its uses are replaced by the existing CodeGenOptions::TimePasses.
* Remove FrontendTimesIsEnabled (It was introduced in D45619 which was largely reverted.)

Differential Revision: https://reviews.llvm.org/D92436
2020-12-08 10:13:19 -08:00
Fangrui Song 29295e2165 [test] Rewrite split-debug.c
Use generic ELF target triples.
Add missing coverage: -gsplit-dwarf=split -g -fsplit-dwarf-inlining
Reorganize and add comments.
Test -gno-pubnames
2020-12-07 18:40:31 -08:00
Yaxun (Sam) Liu efc063b621 Fix lit test failure due to 0b81d9
These lit tests now requires amdgpu-registered-target since they
use clang driver and clang driver passes an LLVM option which
is available only if amdgpu target is registered.

Change-Id: I2df31967409f1627fc6d342d1ab5cc8aa17c9c0c
2020-12-07 19:50:21 -05:00
Yaxun (Sam) Liu 0b81d9a992 [AMDGPU] add -mcode-object-version=n
Add option -mcode-object-version=n to control code object version for
AMDGPU.

Differential Revision: https://reviews.llvm.org/D91310
2020-12-07 18:08:37 -05:00
Yaxun (Sam) Liu 4bed1d9b32 [HIP] fix bundle entry ID for --
Canonicalize triple used in fat binary. Change from
amdgcn-amd-amdhsa to amdgcn-amd-amdhsa-.

This is part of https://reviews.llvm.org/D60620
2020-12-07 18:08:37 -05:00
Yaxun (Sam) Liu 40ad476a32 [clang][AMDGPU] rename sram-ecc as sramecc
As backend renamed sram-ecc to sramecc, this patch makes
corresponding change in clang.

Differential Revision: https://reviews.llvm.org/D86217
2020-12-07 18:05:47 -05:00
Jinsong Ji b49b8f096c [PowerPC][Clang] Remove QPX support
Clean up QPX code in clang missed in https://reviews.llvm.org/D83915

Reviewed By: #powerpc, steven.zhang

Differential Revision: https://reviews.llvm.org/D92329
2020-12-07 10:15:39 -05:00
Qiu Chaofan 6bf29dbb15 [PowerPC] [Clang] Enable float128 feature on P9 by default
As Power9 introduced hardware support for IEEE quad-precision FP type,
the feature should be enabled by default on Power9 or newer targets.

Reviewed By: steven.zhang

Differential Revision: https://reviews.llvm.org/D90213
2020-12-07 18:31:00 +08:00
Hafiz Abid Qadeer 275592e714 Provide default location of sysroot for Baremetal toolchain.
Currently, Baremetal toolchain requires user to pass a sysroot location
using a --sysroot flag. This is not very convenient for the user. It also
creates problem for toolchain vendors who don't have a fixed location to
put the sysroot bits.

Clang does provide 'DEFAULT_SYSROOT' which can be used by the toolchain
builder to provide the default location. But it does not work if toolchain
is targeting multiple targets e.g. arm-none-eabi/riscv64-unknown-elf which
clang is capable of doing.

This patch tries to solve this problem by providing a default location of
the toolchain if user does not explicitly provides --sysroot. The exact
location and name can be different but it should fulfill these conditions:

1. The sysroot path should have a target triple element so that multi-target
toolchain problem (as I described above) could be addressed.

2. The location should not be $TOP/$Triple as this is used by gcc generally
and will be a problem for installing both gcc and clang based toolchain at
the same location.

Reviewed By: jroelofs

Differential Revision: https://reviews.llvm.org/D92677
2020-12-07 09:19:52 +00:00
Hafiz Abid Qadeer ca2888310b Don't use sysroot/include when sysroot is empty.
Baremetal toolchain add Driver.SysRoot/include to the system include
paths without checking if Driver.SysRoot is empty. This resulted in
"-internal-isystem" "include" in the command. This patch adds check for
empty sysroot.

Reviewed By: jroelofs

Differential Revision: https://reviews.llvm.org/D92176
2020-12-04 18:33:24 +00:00
Yaxun (Sam) Liu 0519e1ddb3 [HIP] Fix bug in driver about wavefront size
The static variable causes it only initialized once and take
the same value for different GPU archs, whereas they
may be different for different GPU archs, e.g. when
there are both gfx900 and gfx1010.

Removing static fixes that.

Differential Revision: https://reviews.llvm.org/D92628
2020-12-04 08:36:52 -05:00
Qiu Chaofan 9378a366b2 [NFC] [Clang] Fix ppc64le vaarg OpenMP test in CodeGen
Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D92544
2020-12-04 11:29:55 +08:00
Ahmed Bougacha f77c948d56 [Triple][MachO] Define "arm64e", an AArch64 subarch for Pointer Auth.
This also teaches MachO writers/readers about the MachO cpu subtype,
beyond the minimal subtype reader support present at the moment.

This also defines a preprocessor macro to allow users to distinguish
__arm64__ from __arm64e__.

arm64e defaults to an "apple-a12" CPU, which supports v8.3a, allowing
pointer-authentication codegen.
It also currently defaults to ios14 and macos11.

Differential Revision: https://reviews.llvm.org/D87095
2020-12-03 07:53:59 -08:00
Kazushi (Jam) Marukawa 7d30df7b59 [VE] Add standard include path and library path for C++
We have a plan to add libcxx and libcxxabi for VE.  In order to do so,
we need to compile cxx source code with bootstarapped header files.
This patch adds such expected path to make clang++ work, at least
not crash at the startup.  Add regression test for that, also.

Reviewed By: simoll

Differential Revision: https://reviews.llvm.org/D92386
2020-12-03 22:22:56 +09:00
Tim Northover 152df3add1 arm64: count Triple::aarch64_32 as an aarch64 target and enable leaf frame pointers 2020-12-03 11:09:44 +00:00
Marek Kurdej 6627a3c287 [c++2b] Add option -std=c++2b to enable support for potential C++2b features.
Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D92547
2020-12-03 10:27:47 +01:00
Qiu Chaofan 222da77a82 [NFC] [Clang] Move ppc64le f128 vaargs OpenMP test
This case for long-double semantics mismatch on OpenMP references
%clang, which should be located in Driver directory.
2020-12-03 10:50:42 +08:00
Hsiangkai Wang 432d05174e [RISCV] Handle zfh in the arch string.
Differential Revision: https://reviews.llvm.org/D91315
2020-12-03 09:16:44 +08:00
Yaxun (Sam) Liu acb6f80d96 [CUDA][HIP] Fix overloading resolution
This patch implements correct hostness based overloading resolution
in isBetterOverloadCandidate.

Based on hostness, if one candidate is emittable whereas the other
candidate is not emittable, the emittable candidate is better.

If both candidates are emittable, or neither is emittable based on hostness, then
other rules should be used to determine which is better. This is because
hostness based overloading resolution is mostly for determining
viability of a function. If two functions are both viable, other factors
should take precedence in preference.

If other rules cannot determine which is better, CUDA preference will be
used again to determine which is better.

However, correct hostness based overloading resolution
requires overloading resolution diagnostics to be deferred,
which is not on by default. The rationale is that deferring
overloading resolution diagnostics may hide overloading reslolutions
issues in header files.

An option -fgpu-exclude-wrong-side-overloads is added, which is off by
default.

When -fgpu-exclude-wrong-side-overloads is off, keep the original behavior,
that is, exclude wrong side overloads only if there are same side overloads.
This may result in incorrect overloading resolution when there are no
same side candates, but is sufficient for most CUDA/HIP applications.

When -fgpu-exclude-wrong-side-overloads is on, enable deferring
overloading resolution diagnostics and enable correct hostness
based overloading resolution, i.e., always exclude wrong side overloads.

Differential Revision: https://reviews.llvm.org/D80450
2020-12-02 16:33:33 -05:00
Leonard Chan 1e91803c67 Recommit "[clang][Fuchsia] Add relative-vtables multilib"
This recommits fdbd84c6c8 whose initial
build issues were fixed in 19bdc8e5a3.
2020-12-01 17:03:13 -08:00
Aaron En Ye Shi cd5897d559 [HIP] Fix static-lib test CHECK bug
Fix hip test failures that were introduced by
previous changes to hip-toolchain-rdc-static-lib.hip
test. The .*lld.* is matching a longer string than
expected.

Differential Revision: https://reviews.llvm.org/D92342
2020-12-01 15:49:39 +00:00
Wei Wang 93dc1b5b8c [Remarks][2/2] Expand remarks hotness threshold option support in more tools
This is the #2 of 2 changes that make remarks hotness threshold option
available in more tools. The changes also allow the threshold to sync with
hotness threshold from profile summary with special value 'auto'.

This change expands remarks hotness threshold option
-fdiagnostics-hotness-threshold in clang and *-remarks-hotness-threshold in
other tools to utilize hotness threshold from profile summary.

Remarks hotness filtering relies on several driver options. Table below lists
how different options are correlated and affect final remarks outputs:

| profile | hotness | threshold | remarks printed |
|---------|---------|-----------|-----------------|
| No      | No      | No        | All             |
| No      | No      | Yes       | None            |
| No      | Yes     | No        | All             |
| No      | Yes     | Yes       | None            |
| Yes     | No      | No        | All             |
| Yes     | No      | Yes       | None            |
| Yes     | Yes     | No        | All             |
| Yes     | Yes     | Yes       | >=threshold     |

In the presence of profile summary, it is often more desirable to directly use
the hotness threshold from profile summary. The new argument value 'auto'
indicates threshold will be synced with hotness threshold from profile summary
during compilation. The "auto" threshold relies on the availability of profile
summary. In case of missing such information, no remarks will be generated.

Differential Revision: https://reviews.llvm.org/D85808
2020-11-30 21:55:50 -08:00
Leonard Chan 7bc944c102 Revert "[clang][Fuchsia] Add relative-vtables multilib"
This reverts commit fdbd84c6c8.

Reverting due to failing CI builders for Fuchsia's toolchain:
https://luci-milo.appspot.com/p/fuchsia/builders/ci/clang-linux-x64/b8862150211240186992?
2020-11-30 19:21:35 -08:00
Leonard Chan fdbd84c6c8 [clang][Fuchsia] Add relative-vtables multilib
This adds multilibs for Fuchsia that is built with the relative vtables ABI,
one with and another without exceptions.

Differential Revision: https://reviews.llvm.org/D85576
2020-11-30 18:21:10 -08:00
Leonard Chan a160189c5d Revert "[clang][Fuchsia] Add relative-vtables multilib"
This reverts commit 7c2bc3b71d.

Forgot to add the ifferential revision.
2020-11-30 18:20:01 -08:00
Leonard Chan 7c2bc3b71d [clang][Fuchsia] Add relative-vtables multilib
This adds a multilib for Fuchsia that is built with the relative vtables
ABI.
2020-11-30 18:17:38 -08:00
Nico Weber 61da501b6a clang/test: Remove platform-linker feature
By explicitly requesting the system linker with `-fuse-ld=`, the
tests are able to CHECK for the system linker even with
CLANG_DEFAULT_LINKER=lld.

Alternative to D74704.

Differential Revision: https://reviews.llvm.org/D92291
2020-11-30 20:00:46 -05:00
Aaron En Ye Shi f89e9c8201 [HIP] Fix HIP test on windows due to lld suffix
On Windows, lld is instead named lld.exe, therefore
a few HIP tests are failing. Instead the wildcard should
be modified to .*lld.* to handle .exe. This fixes the
bug: https://bugs.llvm.org/show_bug.cgi?id=48289.

Differential Revision: https://reviews.llvm.org/D92342
2020-11-30 21:05:26 +00:00
Zarko Todorovski bc7b2688d6 Add -fintegrated-as to second invocation of clang in test case. 2020-11-30 12:15:25 -05:00
Zarko Todorovski 979bcbd3a6 Add -fintegrated-as to clang invocation
On platforms where the integrated as isn't called by default this
test fails since the output is not what it expects.  Adding this
option generates the expected output on those platforms as well.
2020-11-27 15:54:37 -05:00
Hafiz Abid Qadeer 45ba2392d7 [clang][Driver] Handle risvc in Baremetal.cpp.
I am working on a baremetal riscv toolchain using LLVM runtime and
LLD linker. Baremetal.cpp provides most of the things needed for such
toolchain. So I have modified it to also handle riscv64/32-unknown-elf
 targets alongside arm-none-eabi.

Currently, targets like riscv64-unknown-elf are handled by RISCVToolChain
which mostly expects a gcc toolchain to be present. If you dont
want the dependency on gcc-toolchain/libgloss or want to use LLD, then
RISCVToolChain is not a good fit.

So in the toolchain selection code, I have made this dependency of
RISCVToolChain on gcc toolchain explicit. It is created if gcc-toolchain
option is present. Otherwise Baremetal toolchain is created. I will be
happy to hear if there is a better way to choose between these two
toolchains.

Reviewed By: jroelofs

Differential Revision: https://reviews.llvm.org/D91442
2020-11-26 11:43:17 +00:00
Mark Murray 2b6691894a [ARM][AArch64] Adding Neoverse N2 CPU support
Add support for the Neoverse N2 CPU to the ARM and AArch64 backends.

Differential Revision: https://reviews.llvm.org/D91695
2020-11-25 11:42:54 +00:00
Nico Weber a9eaf8435d Try to fix tests after e16c0a9a68 with CLANG_DEFAULT_LINKER=lld
Tests that pass -mlinker-version=old version and that then don't
expect new flags to be passed need to explicitly request the system
linker now.
2020-11-24 22:34:12 -05:00
Richard Smith e0f4dea0d0 Don't assume the clang binary name contains the string "clang".
Also ensure the -cc1 argument is actually part of the clang -cc1 command
line rather than some unrelated command line.
2020-11-24 18:52:46 -08:00
Zarko Todorovski c92f29b05e [AIX] Add mabi=vec-extabi options to enable the AIX extended and default vector ABIs.
Added support for the options mabi=vec-extabi and mabi=vec-default which are analogous to qvecnvol and qnovecnvol when using XL on AIX.
The extended Altivec ABI on AIX is enabled using mabi=vec-extabi in clang and vec-extabi in llc.

Reviewed By: Xiangling_L, DiggerLin

Differential Revision: https://reviews.llvm.org/D89684
2020-11-24 18:17:53 -05:00
Fangrui Song 8f8bbf98da [test] Clean up ppc-features.cpp and improve tests
And add ppc-cpus.cpp for -mcpu= specific tests.
2020-11-24 11:59:15 -08:00
Fangrui Song f96fef89b5 [Driver] Default Generic_GCC aarch64 to -fasynchronous-unwind-tables
In GCC, `aarch64-*-linux` and `aarch64-*-freebsd` made the switch in 2018
(https://gcc.gnu.org/pipermail/gcc-patches/2018-March/495549.html).
In Clang, FreeBSD/Fuchsia/NetBSD/MinGW aarch64 default to -fasynchronous-unwind-tables.

This patch defaults Generic_GCC aarch64 (which affects Linux) to use -fasynchronous-unwind-tables.

Reviewed By: nickdesaulniers

Differential Revision: https://reviews.llvm.org/D91760
2020-11-24 09:51:32 -08:00
Nico Weber 9a8386dba8 clang: Pass -platform-version to new MachO LLD
New MachO LLD doesn't implement the old -macos_version_min (etc)
flags, but it understands the modern platform_version flag.
So make the clang driver pass that when using new MachO LLD.

Also, while here, don't pass -lto_library to LLD, since it
links in LTO libraries statically (which it can because it's
versioned alongside clang).

Differential Revision: https://reviews.llvm.org/D92037
2020-11-24 11:16:03 -05:00