Commit Graph

89000 Commits

Author SHA1 Message Date
Aaron Puchert 572fe08776 Thread safety analysis: Simplify intersectAndWarn (NFC)
Instead of conditionally overwriting a nullptr and then branching on its
nullness, just branch directly on the original condition. Then we can
make both pointers (non-null) references instead.
2021-04-23 23:19:15 +02:00
Stephen Kelly 94340dd5bb Enable AST introspection on non-X86 2021-04-23 21:56:36 +01:00
Thomas Lively 502f54049d [WebAssembly] Finalize wasm_simd128.h intrinsics
Adds new intrinsics for instructions that are in the final SIMD spec but did not
previously have intrinsics. Also updates the names of existing intrinsics to
reflect the final names of the underlying instructions in the spec. Keeps the
old names as deprecated functions to ease the transition to the new names.

Differential Revision: https://reviews.llvm.org/D101112
2021-04-23 13:37:27 -07:00
Nemanja Ivanovic 19b29b1ed1 [PowerPC] Provide XL-compatible builtins in altivec.h
There are some interfaces in altivec.h that are not compatible
between Clang and XL (although Clang is compatible with GCC).
Currently, we have found 3 but there may be others.

Clang/GCC signatures:

vector double vec_ctf(vector signed long long)
vector double vec_ctf(vector unsigned long long)
vector signed long long vec_cts(vector double)
vector unsigned long long vec_ctu(vector double)

XL signatures:

vector float vec_ctf(vector signed long long)
vector float vec_ctf(vector unsigned long long)
vector signed int vec_cts(vector double)
vector unsigned int vec_ctu(vector double)

This patch provides the XL behaviour under the __XL_COMPAT_ALTIVEC__
macro for users that rely on XL behaviour.

Differential revision: https://reviews.llvm.org/D101130
2021-04-23 15:13:46 -05:00
Fangrui Song a92dbadffe [OpenMP] Fix -Wdeprecated-copy 2021-04-23 10:49:19 -07:00
Chris Hamilton cae3b70ceb [PR49761] Fix variadic arg handling in matcher
Mishandling of variadic arguments in a function call caused a crash
(runtime assert fail) in bugprone-infinite-loop tidy checker.  Fix
is to limit argument matching to the lesser of the number of variadic
params in the prototype or the number of actual args in the call.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D101108
2021-04-23 12:07:14 -05:00
Stephen Kelly df82fa8d9b [AST] Update tests to query for introspection support 2021-04-23 17:51:10 +01:00
Johannes Doerfert cbe8b57a67 [Clang] Allow the combination of loader_uninitialized and address spaces
When an object is allocated in a non-default address space we do not
need to check for a constructor if it is not initialized and has a
trivial constructor (which we won't call then).

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D100929
2021-04-23 11:21:52 -05:00
Nemanja Ivanovic 6725b90a02 [PowerPC] Add vec_ctsl and vec_ctul to altivec.h
These are added for compatibility with XLC. They are similar to
vec_cts and vec_ctu except that the result is a doubleword vector
regardless of the parameter type.
2021-04-23 11:03:38 -05:00
Gabor Marton a7cb951fa4 [Analyzer][StdLibraryFunctionsChecker] Describe arg constraints
In this patch, I provide a detailed explanation for each argument
constraint. This explanation is added in an extra 'note' tag, which is
displayed alongside the warning.
Since these new notes describe clearly the constraint, there is no need
to provide the number of the argument (e.g. 'Arg3') within the warning.
However, I decided to keep the name of the constraint in the warning (but
this could be a subject of discussion) in order to be able to identify
the different kind of constraint violations easily in a bug database
(e.g. CodeChecker).

Differential Revision: https://reviews.llvm.org/D101060
2021-04-23 17:27:54 +02:00
Stephen Kelly 35918bcb6f [AST] Sort introspection results without instantiating other data
Avoid string allocation in particular, but also avoid attempting to
impose any particular ordering based on formatted results.

Differential Revision: https://reviews.llvm.org/D101054
2021-04-23 16:21:01 +01:00
Anastasia Stulova fcb45b544d [OpenCL] Fix typo in the test. 2021-04-23 14:36:36 +01:00
Dávid Bolvanský 2cae7025c1 Reland "[Clang] Propagate guaranteed alignment for malloc and others"
This relands commit 6914a0ed2b. Crash in InstCombine was fixed.
2021-04-23 14:05:57 +02:00
Adam Czachorowski ddfbdbfefa [clang] Do not crash on template specialization following a fatal error
There was a missing isInvalid() check leading to an attempt to
instantiate template with an empty instantiation stack.

Differential Revision: https://reviews.llvm.org/D100675
2021-04-23 13:34:05 +02:00
Dávid Bolvanský 6914a0ed2b Revert "[Clang] Propagate guaranteed alignment for malloc and others"
This reverts commit c2297544c0. Some buildbots are broken.
2021-04-23 11:33:33 +02:00
Dávid Bolvanský c2297544c0 [Clang] Propagate guaranteed alignment for malloc and others
LLVM should be smarter about *known* malloc's alignment and this knowledge may enable other optimizations.

Originally started as LLVM patch - https://reviews.llvm.org/D100862 but this logic should be really in Clang.

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D100879
2021-04-23 11:07:14 +02:00
Hsiangkai Wang 43cd588c2d [RISCV] Implement the vnot.v builtin.
Differential Revision: https://reviews.llvm.org/D100820
2021-04-23 13:16:23 +08:00
Wang, Pengfei e8bce83996 [X86] Enable compilation of user interrupt handlers.
Add __uintr_frame structure and use UIRET instruction for functions with
x86 interrupt calling convention when UINTR is present.

Reviewed By: LuoYuanke

Differential Revision: https://reviews.llvm.org/D99708
2021-04-23 11:43:57 +08:00
Hsiangkai Wang 14cc1cb222 [RISCV] Implement the vneg.v builtin.
Differential Revision: https://reviews.llvm.org/D100819
2021-04-23 11:40:18 +08:00
Fangrui Song 2786e673c7 [IR][sanitizer] Add module flag "frame-pointer" and set it for cc1 -mframe-pointer={non-leaf,all}
The Linux kernel objtool diagnostic `call without frame pointer save/setup`
arise in multiple instrumentation passes (asan/tsan/gcov). With the mechanism
introduced in D100251, it's trivial to respect the command line
-m[no-]omit-leaf-frame-pointer/-f[no-]omit-frame-pointer, so let's do it.

Fix: https://github.com/ClangBuiltLinux/linux/issues/1236 (tsan)
Fix: https://github.com/ClangBuiltLinux/linux/issues/1238 (asan)

Also document the function attribute "frame-pointer" which is long overdue.

Differential Revision: https://reviews.llvm.org/D101016
2021-04-22 18:07:30 -07:00
Jon Chesterfield 15be0c41d2 Reapply "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed"
This reverts commit 24c1ed3b34.
2021-04-23 01:07:16 +01:00
Richard Smith 40beb1f84a CWG2076: Permit implicit conversions within a single level of braces
during overload resolution, even when calling a copy constructor.
2021-04-22 16:49:39 -07:00
Levy Hsu b49337bbb9 [RISCV] [1/2] Add IR intrinsic for Zbp extension
RV32/64:
    grev
    grevi
    gorc
    gorci
    shfl
    shfli
    unshfl
    unshfli

RV64 ONLY:
    grevw
    greviw
    gorcw
    gorciw
    shflw
    shfli     (For non-existing shfliw)
    unshfli   (For non-existing unshfliw)

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D100830
2021-04-22 16:34:51 -07:00
Jon Chesterfield 2cdb9873b2 [clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion
[clang][nfc] Split getOrCheckAMDGPUCodeObjectVersion

Separates detection of deprecated or invalid code object version from
returning the version. Written to avoid any behaviour change.

Precursor to a revision of D98746.

Reviewed By: yaxunl

Differential Revision: https://reviews.llvm.org/D101077
2021-04-23 00:24:42 +01:00
Yaxun (Sam) Liu 8baba6890d [HIP] Support overloaded math functions for hipRTC
Remove the dependence on standard C++ header
for overloaded math functions in HIP header
since standard C++ header is not available for hipRTC.

Reviewed by: Artem Belevich, Justin Lebar

Differential Revision: https://reviews.llvm.org/D100794
2021-04-22 19:06:51 -04:00
Stephen Kelly af91065ce5 Revert "[AST] Enable AST node introspection on Apple"
This reverts commit 907409a536.

This caused a failure

  http://green.lab.llvm.org/green//job/lldb-cmake-standalone/2827/consoleFull#-210109660a1ca8a51-895e-46c6-af87-ce24fa4cd561

Assertion failed: (!CodeSynthesisContexts.empty() && "Cannot perform an
instantiation without some context on the " "instantiation stack"),
function SubstType, file
/Users/buildslave/jenkins/workspace/lldb-cmake-standalone/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp,
line 2071.
2021-04-22 23:54:16 +01:00
Stephen Kelly 907409a536 [AST] Enable AST node introspection on Apple
This was previously excluded due to possible buildbot failures.
2021-04-22 22:19:21 +01:00
Petr Hosek d5f433d330 Revert "Re-land "[Driver] Support default libc++ library location on Darwin""
This reverts commit 6331680ad2 because
this breaks the compiler-rt build.
2021-04-22 14:04:24 -07:00
Jon Chesterfield 24c1ed3b34 Revert "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed"
This reverts commit 722d4d8e75.

Unclear where hsa.h should be included from, see report in D99949
2021-04-22 19:39:37 +01:00
Sylvestre Ledru d71ee3993f Add support of the next Ubuntu (Ubuntu 21.10 - Impish Idri) 2021-04-22 20:38:28 +02:00
Dávid Bolvanský abf3ca61e3 [Diagnostics] Restore -Wdeprecated warning when user-declared copy assignment operator is defined as deleted (PR45634)
Solves https://bugs.llvm.org/show_bug.cgi?id=45634
Be more agressive than GCC with -Wdeprecated-copy. Also provide -W(no-)deprecated-copy-user-provided-copy/dtor options to on/off this behaviour.

Reviewed By: Quuxplusone

Differential Revision: https://reviews.llvm.org/D79714
2021-04-22 20:35:41 +02:00
Duncan P. N. Exon Smith d4ee603c8f Coverage: Document how to collect a profile without a filesystem
The profiling runtime was designed to work without static initializers
or a a filesystem (see 117cf2bd1f and
others). The no-static-initializers part was already documented but this
part got missed before.

Differential Revision: https://reviews.llvm.org/D101000
2021-04-22 11:29:39 -07:00
Petr Hosek 45340efb4c [Driver] Specify -ccc-install-dir for linux-cross test
This avoids test failures where extra files exist in the tree, such
as the standard library built using the runtimes build.

Differential Revision: https://reviews.llvm.org/D101023
2021-04-22 10:58:26 -07:00
Vitaly Buka 37e1458128 [NFC] Remove reference to file deleted by D100981. 2021-04-22 10:40:18 -07:00
Fangrui Song ef5e7f90ea Temporarily revert the code part of D100981 "Delete le32/le64 targets"
This partially reverts commit 77ac823fd2.

Halide uses le32/le64 (https://github.com/halide/Halide/pull/5934).
Temporarily brings back the code part to give them some time for migration.
2021-04-22 10:18:44 -07:00
Nemanja Ivanovic 7a5641d651 [PowerPC] Add missing casts for vec_xlds and vec_load_splats
The previous commits just missed some pointer casts and ended up
producing warnings.
2021-04-22 10:31:00 -05:00
Nemanja Ivanovic 1cc1d9db28 [PowerPC] Add vec_vclz as an alias for vec_cntlz in altivec.h
Another addition for compatibility with XLC. The functions have the
same overloads so just add it as a preprocessor define.
2021-04-22 10:31:00 -05:00
Nemanja Ivanovic e43963db24 [PowerPC] Add vec_load_splats to altivec.h
Add these overloads for compatibility with XLC. This is a word
load-and-splat.
2021-04-22 10:31:00 -05:00
Nemanja Ivanovic a0e6189712 [PowerPC] Add vec_xlds to altivec.h
Add these overloads for compatibility with XLC. This is a doubleword
load-and-splat.
2021-04-22 10:31:00 -05:00
Nemanja Ivanovic a1d325af67 [PowerPC] Add vec_roundz as alias for vec_trunc in altivec.h
Add the overloads for compatibility with XLC.
2021-04-22 10:31:00 -05:00
Nemanja Ivanovic 1550c47c18 [PowerPC] Add vec_roundp as alias for vec_ceil
Add the overloads for compatibility with XLC.
2021-04-22 10:30:59 -05:00
Nemanja Ivanovic 51692c6c63 [PowerPC] Add missing VSX guard for vec_roundm with vector double
The guard was missed in the previous commit.
2021-04-22 10:30:59 -05:00
Nemanja Ivanovic 3a46667059 [PowerPC] Add vec_roundm as alias for vec_floor in altivec.h
Add the overloads for compatibility with XLC.
2021-04-22 10:30:59 -05:00
Anastasia Stulova 362958ac73 [C++4OpenCL] Add extra diagnostics for kernel argument types
Add restrictions on type layout (PR48099):
- Types passed by pointer or reference must be standard layout types.
- Types passed by value must be POD types.

Patch by olestrohm (Ole Strohm)!

Differential Revision: https://reviews.llvm.org/D100471
2021-04-22 15:28:04 +01:00
Sven van Haastregt 4138e7bd76 [OpenCL] Add missing C++ legacy atomics with generic
https://reviews.llvm.org/D62335 added some C++ for OpenCL specific
builtins to opencl-c.h, but these were not mirrored to the TableGen
builtin functions yet.

The TableGen builtins machinery does not have dedicated version
handling for C++ for OpenCL at the moment: all builtin versioning is
tied to `LangOpts.OpenCLVersion` (i.e., the OpenCL C version).  As a
workaround, to add builtins that are only available in C++ for OpenCL,
we define a function extension guarded by the __cplusplus macro.

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

Fixes PR50041.
2021-04-22 15:08:36 +01:00
Paula Toth 71e80386d0 Update shebang for clang-format-diff script to python3.
Different distributions have different strategies migrating the `python` symlink. Debian and its derivatives provide `python-is-python2` and `python-is-python3`. If neither is installed, the user gets no `/usr/bin/python`. The clang-format-diff script and consequently `arc diff` can thus fail with a python not found error.  Since we require python greater than 3.6 as part of llvm prerequisites (https://llvm.org/docs/GettingStarted.html#software), let's go ahead and update this shebang.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D100968
2021-04-22 06:47:51 -07:00
Stephen Kelly 6f48d6a9df [AST] Make comment a bit more specific 2021-04-22 13:40:56 +01:00
Nathan Sidwell 6ad7e87806 clang: libstdc++ LWM is 4.8.3
Document oldest libstdc++ as 4.8.3, remove a hack for a 4.6 issue.

Differential Revision: https://reviews.llvm.org/D100465
2021-04-22 05:26:07 -07:00
Sander de Smalen e951b045bf [AArch64][SVE] Regression test all ACLE tests with C++
We found issues with a number of intrinsics when building them with
C++, so it makes sense to guard these tests with some extra RUN lines
to build the tests in C++ mode.
2021-04-22 13:24:04 +01:00
Valeriy Savchenko 5780dbeee6 [-Wcalled-once] Do not run analysis on Obj-C++
Objective-C++ is not yet suppoerted.

rdar://76729552

Differential Revision: https://reviews.llvm.org/D100955
2021-04-22 15:20:52 +03:00
Jan Svoboda 850e01a34d [clang][deps] Check extra args in tests
These flags are being generated by `clang-scan-deps` and it makes sense to ensure it keeps doing so.
2021-04-22 14:10:08 +02:00
Stephen Kelly 5e50f473d9 [AST] Add clarification comment 2021-04-22 12:51:25 +01:00
Stephen Kelly aee6c86c4d [AST] De-duplicate empty node introspection
This way we can add support for other nodes without duplication.

Differential Revision: https://reviews.llvm.org/D98774
2021-04-22 12:30:04 +01:00
Hamza Mahfooz be2277fbf2
[Matrix] Support #pragma clang fp
From https://bugs.llvm.org/show_bug.cgi?id=49739:

Currently, `#pragma clang fp` are ignored for matrix types.

For the code below, the `contract` fast-math flag should be added to the generated call to `llvm.matrix.multiply` and `fadd`

```
typedef float fx2x2_t __attribute__((matrix_type(2, 2)));

void foo(fx2x2_t &A, fx2x2_t &C, fx2x2_t &B) {
  #pragma clang fp contract(fast)
  C = A*B + C;
}
```

Reviewed By: fhahn, mibintc

Differential Revision: https://reviews.llvm.org/D100834
2021-04-22 11:45:34 +01:00
Nemanja Ivanovic 3bcd0ece43 [PowerPC] Add vec_roundc as alias for vec_rint in altivec.h
For compatibility with XLC, add these overloads.
2021-04-22 05:31:38 -05:00
Stephen Kelly 21ce124e1e [AST] Add NestedNameSpecifierLoc accessors to node introspection
Differential Revision: https://reviews.llvm.org/D100712
2021-04-22 11:27:19 +01:00
Jan Svoboda 398f253400 [clang][deps] Include "-cc1" in the arguments
To simplify tools consuming dependency scanning results, prepend the "-cc1" argument by default.

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D100942
2021-04-22 10:57:56 +02:00
Martin Probst fbc6f42dbe clang-format: [JS] do not merge side-effect imports.
The if condition was testing the current element, but
forgot to check the previous element (doh), so it
would fail depending on sort order of the imports.

Differential Revision: https://reviews.llvm.org/D101020
2021-04-22 10:36:47 +02:00
Pushpinder Singh 722d4d8e75 [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed
This patch adds new clang tool named amdgpu-arch which uses
HSA to detect installed AMDGPU and report back latter's march.
This tool is built only if system has HSA installed.

The value printed by amdgpu-arch is used to fill -march when
latter is not explicitly provided in -Xopenmp-target.

Reviewed By: JonChesterfield, gregrodgers

Differential Revision: https://reviews.llvm.org/D99949
2021-04-22 05:20:28 +00:00
Chen Zheng 26f138eed4 [Debug-Info] implement -gstrict-dwarf
This patch implements -gstrict-dwarf option in clang FE.

Reviewed By: dblaikie, probinson, aprantl

Differential Revision: https://reviews.llvm.org/D100809
2021-04-22 00:41:25 -04:00
Giorgis Georgakoudis a2dbfb6b72 [OpenMP] Simplify offloading parallel call codegen
This revision simplifies Clang codegen for parallel regions in OpenMP GPU target offloading and corresponding changes in libomptarget: SPMD/non-SPMD parallel calls are unified under a single `kmpc_parallel_51` runtime entry point for parallel regions (which will be commonized between target, host-side parallel regions), data sharing is internalized to the runtime. Tests have been auto-generated using `update_cc_test_checks.py`. Also, the revision contains changes to OpenMPOpt for remark creation on target offloading regions.

Reviewed By: jdoerfert, Meinersbur

Differential Revision: https://reviews.llvm.org/D95976
2021-04-21 18:46:07 -07:00
Fangrui Song 77ac823fd2 Delete le32/le64 targets
They are unused now.

Note: NaCl is still used and is currently expected to be needed until 2022-06
(https://blog.chromium.org/2020/08/changes-to-chrome-app-support-timeline.html).

Differential Revision: https://reviews.llvm.org/D100981
2021-04-21 18:44:12 -07:00
Fangrui Song 775a9483e5 [IR][sanitizer] Set nounwind on module ctor/dtor, additionally set uwtable if -fasynchronous-unwind-tables
On ELF targets, if a function has uwtable or personality, or does not have
nounwind (`needsUnwindTableEntry`), it marks that `.eh_frame` is needed in the module.

Then, a function gets `.eh_frame` if `needsUnwindTableEntry` or `-g[123]` is specified.
(i.e. If -g[123], every function gets `.eh_frame`.
This behavior is strange but that is the status quo on GCC and Clang.)

Let's take asan as an example. Other sanitizers are similar.
`asan.module_[cd]tor` has no attribute. `needsUnwindTableEntry` returns true,
so every function gets `.eh_frame` if `-g[123]` is specified.
This is the root cause that
`-fno-exceptions -fno-asynchronous-unwind-tables -g` produces .debug_frame
while
`-fno-exceptions -fno-asynchronous-unwind-tables -g -fsanitize=address` produces .eh_frame.

This patch

* sets the nounwind attribute on sanitizer module ctor/dtor.
* let Clang emit a module flag metadata "uwtable" for -fasynchronous-unwind-tables. If "uwtable" is set, sanitizer module ctor/dtor additionally get the uwtable attribute.

The "uwtable" mechanism is generic: synthesized functions not cloned/specialized
from existing ones should consider `Function::createWithDefaultAttr` instead of
`Function::create` if they want to get some default attributes which
have more of module semantics.

Other candidates: "frame-pointer" (https://github.com/ClangBuiltLinux/linux/issues/955
https://github.com/ClangBuiltLinux/linux/issues/1238), dso_local, etc.

Differential Revision: https://reviews.llvm.org/D100251
2021-04-21 15:58:20 -07:00
Petr Hosek f749550cfe [libcxx] Stop using use c++ subdirectory for libc++ library
The new layout more closely matches the layout used by other compilers.
This is only used when LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is enabled.

Differential Revision: https://reviews.llvm.org/D100869
2021-04-21 15:39:03 -07:00
Jonas Devlieghere 6331680ad2 Re-land "[Driver] Support default libc++ library location on Darwin"
This reverts commit 05eeed9691 and after
fixing the impacted lldb tests in 5d1c43f333.

  [Driver] Support default libc++ library location on Darwin

  Darwin driver currently uses libc++ headers that are part of Clang
  toolchain when available (by default ../include/c++/v1 relative to
  executable), but it completely ignores the libc++ library itself
  because it doesn't pass the location of libc++ library that's part
  of Clang (by default ../lib relative to the exceutable) to the linker
  always using the system copy of libc++.

  This may lead to subtle issues when the compilation fails because the
  headers that are part of Clang toolchain are incompatible with the
  system library. Either the driver should ignore both headers as well as
  the library, or it should always try to use both when available.

  This patch changes the driver behavior to do the latter which seems more
  reasonable, it makes it easy to test and use custom libc++ build on
  Darwin while still allowing the use of system version. This also matches
  the Clang driver behavior on other systems.

  Differential Revision: https://reviews.llvm.org/D45639
2021-04-21 14:22:13 -07:00
Yaxun (Sam) Liu 5a2d78b163 [HIP] Add option -fgpu-inline-threshold
Add option -fgpu-inline-threshold for inline threshold for device compilation only.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D99233
2021-04-21 17:18:18 -04:00
Alexey Bataev 079884225a [OPENMP]Fix PR49698: OpenMP declare mapper causes segmentation fault.
The implicitly generated mappings for allocation/deallocation in mappers
runtime should be mapped as implicit, also no need to clear member_of
flag to avoid ref counter increment. Also, the ref counter should not be
incremented for the very first element that comes from the mapper
function.

Differential Revision: https://reviews.llvm.org/D100673
2021-04-21 10:38:31 -07:00
Fangrui Song 4cbe488188 [lsan][docs] Clarify supported platforms
Differential Revision: https://reviews.llvm.org/D100907
2021-04-21 10:27:55 -07:00
Martin Probst 70ae843d99 clang-format: [JS] do not wrap after `asserts`
`asserts` is a pseudo keyword in TypeScript used in return types.
Wrapping after it triggers automatic semicolon insertion, which
breaks the code semantics/syntax.

`asserts` is different from other pseudo keywords in that it is
specific to TS and only carries meaning in a very specific location.
Thus introducing a token type is probably overkill.

Differential Revision: https://reviews.llvm.org/D100953
2021-04-21 16:33:55 +02:00
Nico Weber ba7a92c01e [Support] Don't include VirtualFileSystem.h in CommandLine.h
CommandLine.h is indirectly included in ~50% of TUs when building
clang, and VirtualFileSystem.h is large.

(Already remarked by jhenderson on D70769.)

No behavior change.

Differential Revision: https://reviews.llvm.org/D100957
2021-04-21 10:19:01 -04:00
Victor Campos ee3e01627f [Clang][ARM] Define __VFP_FP__ macro unconditionally
Clang only defines __VFP_FP__ when the FPU is enabled. However, gcc
defines it unconditionally.

This patch aligns Clang with gcc.

Reviewed By: peter.smith, rengolin

Differential Revision: https://reviews.llvm.org/D100372
2021-04-21 15:03:59 +01:00
Aaron Ballman a63c9b2562 Do not pass null attributes to BuildAttributedStmt during instantiation
When transforming an attribute during template instantiation, if the
transformation fails, it may result in a null attribute being returned.
This null attribute should not be passed in as one of the attributes
used to create an attributed statement.

If all of the attributes fail to transform, we do not create an
attributed statement at all.

There are no attributes that return null currently, so there is no easy
way to test this currently. However, this fixes a crash caused by
8344675908.
2021-04-21 09:30:56 -04:00
LemonBoy 8e336511f1 [clang] Recognize ppc32 as valid mcpu value
The `ppc32` cpu model was introduced a while ago in a9321059b9 as an independent copy of the `ppc` one but was never wired into clang.

Reviewed By: #powerpc, nemanjai

Differential Revision: https://reviews.llvm.org/D100933
2021-04-21 15:11:01 +02:00
John Brawn 5f02c308e6 Fix clang/test/Frontend/plugin-annotate-functions.c
FileCheck now gives an error when there's a check for an undefined
variable, which this test does in one of its NOT checks. Fix this by
being a bit looser in what the test checks.
2021-04-21 14:00:38 +01:00
Sylvain Audi 8c16c8b7ef Reland "[clang-scan-deps] Add support for clang-cl"
This reverts commit 199c397482.
This time, clang-scan-deps's search for output argument in clang-cl command line will now ignore arguments preceded by "-Xclang".
That way, it won't detect a /o argument in "-Xclang -ivfsoverlay -Xclang /opt/subpath"

Initial patch description:
clang-scan-deps contains some command line parsing and modifications.
This patch adds support for clang-cl command options.

Differential Revision: https://reviews.llvm.org/D92191
2021-04-21 07:56:39 -04:00
Sven van Haastregt e2b3b89bf1 [OpenCL] Do not add builtins with unavailable types
Add functionality to assign extensions to types in OpenCLBuiltins.td
and use that information to filter candidates that should not be
exposed if a type is not available.

Differential Revision: https://reviews.llvm.org/D100209
2021-04-21 11:59:29 +01:00
Sven van Haastregt fdcb9c2728 [OpenCL] Refactor shuffle builtin decls
The shuffle and shuffle2 builtins relied on processing two TypeLists
for different arguments in sync.  This will no longer work when a type
(e.g. double) in one of the TypeLists is optional.

Rewrite the declarations using explicit types instead of GenericTypes.
2021-04-21 11:59:24 +01:00
Martin Storsjö 174e796c7d [llvm-rc] Fix a new test to disambiguate macOS paths like /Users/... from options starting with a slash
This should fix test failures on macOS.
2021-04-21 13:34:33 +03:00
Simon Tatham 77e170db86 [ARM][Driver][Windows] Allow command-line upgrade to Armv8.
If you gave clang the options `--target=arm-pc-windows-msvc` and
`-march=armv8-a+crypto` together, the crypto extension would not be
enabled in the compilation, and you'd see the following warning
message suggesting that the 'armv8-a' had been ignored:

  clang: warning: ignoring extension 'crypto' because the 'armv7-a' architecture does not support it [-Winvalid-command-line-argument]

This happens because Triple::getARMCPUForArch(), for the Win32 OS,
unconditionally returns "cortex-a9" (an Armv7 CPU) regardless of
MArch, which overrides the architecture setting on the command line.

I don't think that the combination of Windows and AArch32 _should_
unconditionally outlaw the use of the crypto extension. MSVC itself
doesn't think so: you can perfectly well compile Thumb crypto code
using its AArch32-targeted compiler.

All the other default CPUs in the same switch statement are
conditional on a particular MArch setting; this is the only one that
returns a particular CPU _regardless_ of MArch. So I've fixed this one
by adding a condition, so that if you ask for an architecture *above*
v7, the default of Cortex-A9 no longer overrides it.

Reviewed By: mstorsjo

Differential Revision: https://reviews.llvm.org/D100937
2021-04-21 11:20:05 +01:00
Martin Storsjö 066b8f2fc6 [llvm-rc] Try to fix the Preprocessor/llvm-rc.rc test on non arm/x86 architectures
When llvm-rc invokes clang for preprocessing, it uses a target
triple derived from the default target. The test verifies that
e.g. _WIN32 is defined when preprocessing.

If running clang with e.g. -target ppc64le-windows-msvc, that
particular arch/OS combination isn't hooked up, so _WIN32 doesn't
get defined in that configuration. Therefore, the preprocessing
test fails.

Instead make llvm-rc inspect the architecture of the default target.
If it's one of the known supported architectures, use it as such,
otherwise set a default one (x86_64). (Clang can run preprocessing
with an x86_64 target triple, even if the x86 backend isn't
enabled.)

Also remove superfluous llvm:: specifications on enums in llvm-rc.cpp.
2021-04-21 12:47:33 +03:00
Andrzej Warzynski dc256a443a [flang][driver] Add support for `-fget-definition`
This patch adds `-fget-definition` to `flang-new`. The semantics of this
option are identical in both drivers. The error message in the
"throwaway" driver is updated so that it matches the one from
`flang-new` (which is auto-generated and cannot be changed easily).

Tests are updated accordingly. A dedicated test for error handling was
added: get-definition.f90 (for the sake of simplicity,
getdefinition01.f90 no longer tests for errors).

The `ParseFrontendArgs` function is updated so that it can return
errors. This change is required in order to report invalid values
following `-fget-definition`.

The actual implementation of `GetDefinitionAction::ExecuteAction()` was
extracted from f18.cpp (i.e. the bit that deals with
`-fget-definition`).

Depends on: https://reviews.llvm.org/D100556

Differential Revision: https://reviews.llvm.org/D100558
2021-04-21 09:31:36 +00:00
Martin Storsjö 64bc44f5dd [llvm-rc] Run clang to preprocess input files
Allow opting out from preprocessing with a command line argument.

Update tests to pass -no-preprocess to make it not try to use clang
(which isn't a build level dependency of llvm-rc), but add a test that
does preprocessing under clang/test/Preprocessor.

Update a few options to allow them both joined (as -DFOO) and separate
(-D BR), as rc.exe allows both forms of them.

With the verbose flag set, this prints the preprocessing command
used (which differs from what rc.exe does).

Tests under llvm/test/tools/llvm-rc only test constructing the
preprocessor commands, while tests under clang/test/Preprocessor test
actually running the preprocessor.

Differential Revision: https://reviews.llvm.org/D100755
2021-04-21 11:50:10 +03:00
ShihPo Hung 11072a0bdb [RISCV][Clang] Add RVV AMO builtins
Add vamo[swap/add/xor/and/or/min/max/minu/maxu] builtins.

Reviewed By: khchen

Differential Revision: https://reviews.llvm.org/D100448
2021-04-21 01:48:02 -07:00
Pushpinder Singh 0ad50bf27f Revert "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed"
This reverts commit 3194761d27.
2021-04-21 08:05:38 +00:00
Pushpinder Singh 3194761d27 [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed
This patch adds new clang tool named amdgpu-arch which uses
HSA to detect installed AMDGPU and report back latter's march.
This tool is built only if system has HSA installed.

The value printed by amdgpu-arch is used to fill -march when
latter is not explicitly provided in -Xopenmp-target.

Reviewed By: JonChesterfield, gregrodgers

Differential Revision: https://reviews.llvm.org/D99949
2021-04-21 05:05:49 +00:00
Jonas Devlieghere 05eeed9691 Revert "[Driver] Support default libc++ library location on Darwin"
This reverts the following commits because it breaks
TestAppleSimulatorOSType.py on GreenDragon [1].

caff17e503
f5efe0aa04
ae8b2cab67

[1] http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/31346/
2021-04-20 20:42:50 -07:00
Liu, Chen3 72e4bf12ee [X86] Support some missing intrinsics
Support for _mm512_i32logather_pd, _mm512_mask_i32logather_pd,
_mm512_i32logather_epi64, _mm512_mask_i32logather_epi64, _mm512_i32loscatter_pd,
_mm512_mask_i32loscatter_pd, _mm512_i32loscatter_epi64,
_mm512_mask_i32loscatter_epi64.

Differential Revision: https://reviews.llvm.org/D100368
2021-04-21 10:50:37 +08:00
Dávid Bolvanský 9f1e2ee462 [Clang, builtins] Added aligned_alloc, memalign support 2021-04-21 00:11:54 +02:00
Petr Hosek caff17e503 [Driver] Don't use capture for InstalledDir
This is another attempt to address the issue introduced in
ae8b2cab67.

We cannot capture InstalledDir because FileCheck doesn't handle
the backslashes correctly, so instead we just consume the entire
path prefix which is what other tests are doing.
2021-04-20 13:43:56 -07:00
Petr Hosek f5efe0aa04 [Driver] Support both slashes
This addresses Windows breakage introduced by
ae8b2cab67.
2021-04-20 13:25:38 -07:00
Petr Hosek ae8b2cab67 [Driver] Support default libc++ library location on Darwin
Darwin driver currently uses libc++ headers that are part of Clang
toolchain when available (by default ../include/c++/v1 relative to
executable), but it completely ignores the libc++ library itself
because it doesn't pass the location of libc++ library that's part
of Clang (by default ../lib relative to the exceutable) to the linker
always using the system copy of libc++.

This may lead to subtle issues when the compilation fails because the
headers that are part of Clang toolchain are incompatible with the
system library. Either the driver should ignore both headers as well as
the library, or it should always try to use both when available.

This patch changes the driver behavior to do the latter which seems more
reasonable, it makes it easy to test and use custom libc++ build on
Darwin while still allowing the use of system version. This also matches
the Clang driver behavior on other systems.

Differential Revision: https://reviews.llvm.org/D45639
2021-04-20 12:30:35 -07:00
Nathan Sidwell 057b6f5d0b clang: Update libstdc++ issue workaround
Add some specificity to libstdc++ hack, perhaps we can remove it at a
later date.
2021-04-20 11:34:12 -07:00
Alessandro Vergani 6e77a67171 Fix clang Visual Studio build instructions
Change cd ..\.. to cd llvm-project (the former is probably a leftover
of the old svn instructions)

Committer: Adrian McCarthy <amccarth@google.com>

Differential Revision: https://reviews.llvm.org/D68321
2021-04-20 11:17:29 -07:00
Nicolás Alvarez b0322a4ed2 [docs] Fix doxygen comments wrongly attached to the clang namespace
Looking at the Doxygen-generated documentation for the clang namespace
currently shows several random comments from different parts of the
codebase. These are caused by:

- File doc comments that aren't marked with \file, so they're attached to
  the next declaration, which is usually "namespace clang {".
- Class doc comments placed before the namespace rather than before the
  class.

This commit fixes these comments. The generated doxygen documentation now
has proper docs for several classes and files, and the docs for the clang
namespace is now empty.

Differential Revision: https://reviews.llvm.org/D96738
2021-04-20 13:50:11 -04:00
Nicolás Alvarez 2da4ceec93 [docs] Use make_unique in FrontendAction example
The code example for "RecursiveASTVisitor based ASTFrontendActions"
was using unique_ptr<X>(new X) when creating the AST consumer; change
it to use make_unique instead. The main function of the same example
already used make_unique.

Differential Revision: https://reviews.llvm.org/D93185
2021-04-20 13:47:16 -04:00
Ahmed Bougacha cedb5b06df [AArch64] Don't always override CPU for arm64e.
This demotes the apple-a12 CPU selection for arm64e to just be the
last-resort default.  Concretely, this means:
- an explicitly-specified -mcpu will override the arm64e default;
  a user could potentially pick an invalid CPU that doesn't have
  v8.3a support, but that's not a major problem anymore
- arm64e-apple-macos (and variants) will pick apple-m1 instead of
  being forced to apple-a12.
2021-04-20 08:41:04 -07:00
Ahmed Bougacha a8a3a43792 [AArch64] Add apple-m1 CPU, and default to it for macOS.
apple-m1 has the same level of ISA support as apple-a14,
so this is a straightforward mechanical change.  However, that
also means this inherits apple-a14's v8.5a+nobti quirkiness.

rdar://68287159
2021-04-20 08:41:04 -07:00
Erich Keane 0ed613612c Ensure target-multiversioning emits deferred declarations
As reported in PR50025, sometimes we would end up not emitting functions
needed by inline multiversioned variants. This is because we typically
use the 'deferred decl' mechanism to emit these.  However, the variants
are emitted after that typically happens.  This fixes that by ensuring
we re-run deferred decls after this happens. Also, the multiversion
emission is done recursively to ensure that MV functions that require
other MV functions to be emitted get emitted.
2021-04-20 08:10:26 -07:00
Simon Pilgrim fce8c10b68 Fix Wdocumentation warning by consistently using '///' comment blocks. NFCI. 2021-04-20 12:37:00 +01:00
Martin Probst 3d4a6037ff clang-format: [JS] do not merge imports and exports.
Previously, clang-format would erroneously merge import and export
statements. These need to be kept separate, as the semantics differ.

Differential Revision: https://reviews.llvm.org/D100752
2021-04-20 13:08:18 +02:00
Thomas Preud'homme 8cee150e9a [C++, test] Fix typo in NSS* vars
The NSS FileCheck variables at the end of the
CodeGenCXX/split-stacks.cpp clang testcase are off by 1, resulting in
the use of an undefined variable (NSS3). One of the CHECK-NOT is also
redundant because _Z8tnosplitIiEiv uses the same attribute as _Z3foov
without split stack. This commit fixes that.

Reviewed By: ChuanqiXu

Differential Revision: https://reviews.llvm.org/D99839
2021-04-20 12:07:41 +01:00
Serguei Katkov 70193bdfc0 Re-land [GreedyRA ORE] Add Cost of spill locations into remark
Re-land the patch with a fix of clang test.

Cost of spill location is computed basing on relative branch frequency
where corresponding spill/reload/copy are located.

While the number itself is highly depends on incoming IR,
the total cost can be used when do some changes in RA.

Revert "Revert "[GreedyRA ORE] Add Cost of spill locations into remark""
This reverts commit 680f3d6de7.
2021-04-20 16:21:07 +07:00
Alexandre Ganea 199c397482 Revert "[clang-scan-deps] Add support for clang-cl"
This reverts commit bb26fa8c28.
2021-04-19 17:45:18 -04:00
Stephen Kelly 782c3e23ba [AST] Fix comparison to of SourceRanges in container
Differential Revision: https://reviews.llvm.org/D100723
2021-04-19 21:19:21 +01:00
Stephen Kelly abacaef181 [AST] Update introspection API to use const-ref for copyable types
Differential Revision: https://reviews.llvm.org/D100720
2021-04-19 21:07:47 +01:00
Yaxun (Sam) Liu d8805574c1 [CUDA][HIP] Allow non-ODR use of host var in device
Reviewed by: Artem Belevich, Richard Smith

Differential Revision: https://reviews.llvm.org/D98193
2021-04-19 14:45:24 -04:00
Wael Yehia 369c0e0f48 [AIX] Diagnose thinLTO usage in clang on AIX.
Reviewed By: Xiangling Liao

Differential Revision: https://reviews.llvm.org/D100350
2021-04-19 16:39:48 +00:00
Jan Svoboda 6a72ed239c [clang] NFC: Fix range-based for loop warnings related to decl lookup 2021-04-19 18:31:31 +02:00
Hans Wennborg aa1e391402 Fix test/Frontend/print-header-includes.c
I managed to run the wrong tests before committing D100759.
2021-04-19 15:39:09 +02:00
Abhina Sreeskantharajan 05b4babc9d [SystemZ][z/OS] Set more text files as text
This patch corrects more instances of text files being opened as text.

Reviewed By: Jonathan.Crowther

Differential Revision: https://reviews.llvm.org/D100654
2021-04-19 09:31:46 -04:00
Hans Wennborg bb36dc8dcf Rename -show-skipped-includes to -fshow-skipped-includes and make it a driver option
This is a user-facing option, so it doesn't make sense for it to be cc1
only.

Follow-up to D100420

Differential revision: https://reviews.llvm.org/D100759
2021-04-19 15:22:15 +02:00
Jan Svoboda 95588c0da4 [clang][deps] NFC: Remove unused FullDependencies member
This patch removes the `FullDependencies::AdditionalNonPathCommandLine` member, as it's value-initialized and never mutated.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D100536
2021-04-19 15:02:54 +02:00
Jan Svoboda 0a92e09c07 [clang][deps] Generate the full command-line for modules
This patch uses the new `CompilerInvocation::generateCC1CommandLine` to generate the full canonical command line for modular dependencies, instead of only appending additional arguments.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D100534
2021-04-19 14:32:49 +02:00
Abhina Sreeskantharajan fbc3259346 [SystemZ][z/OS] Set files in FileRemapper.cpp are text
This patch sets files in FileRemapper to open as text.

Reviewed By: Jonathan.Crowther

Differential Revision: https://reviews.llvm.org/D100056
2021-04-19 07:59:42 -04:00
Timm Bäder 320311a01b [clang][parser] Unify rejecting (non) decl stmts with gnu attributes
The comment here was introduced in
a3e01cf822 and suggests that we should
handle declaration statements and non-declaration statements the same,
but don't because ProhibitAttributes() can't handle GNU attributes. That
has recently changed, so remove the comment and handle all statements
the same.

Differential Revision: https://reviews.llvm.org/D99936
2021-04-19 12:43:55 +02:00
Jan Svoboda 2b73565210 [clang][deps] Remove the -full-command-line flag
This patch removes the `-full-command-line` option from `clang-scan-deps`. It's only used with `-format=experimental-full`, where omitting the command lines doesn't make much sense. There are no tests without `-full-command-line`.

Depends on D100531.

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D100533
2021-04-19 12:28:02 +02:00
Jan Svoboda 32219c8c44 [clang][deps] Simplify function discovering .pcm and .modulemap files
This patch simplifies (and renames) the `appendCommonModuleArguments` function.

It no longer tries to construct the command line for explicitly building modules. Instead, it only performs the DFS traversal of modular dependencies and queries the callbacks to collect paths to `.pcm` and `.modulemap` files.

This makes it more flexible and usable in two contexts:

* Generating additional command line arguments for the main TU in modular build. The `std::vector<std::string>` output parameters can be used to manually generate appropriate command line flags.
* Generate full command line for a module. The output parameters can be the corresponding parts of `CompilerInvocation`. (In a follow-up patch.)

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D100531
2021-04-19 12:11:39 +02:00
Jan Svoboda fb2aa63d7d [clang][cli] NFC: Move conditional LangOptions parsing/generation
NFC, this simplifies the main parsing/generating functions by moving logic around conditional `LangOptions` where it belongs.

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D100653
2021-04-19 11:25:40 +02:00
Sven van Haastregt 6cb7631df3 [OpenCL] Change OpenCL builtin version encoding
Instead of using a MinVersion and MaxVersion field, encode the version
of a builtin using a mask that aligns better with version handling in
OpenCLOptions.h.  In addition, this saves a field in the BuiltinTable.

This change allows a finer-grained control over the OpenCL versions in
which a builtin is available: instead of a range, we can now toggle
each version individually.

The fine-grained version control is not yet exposed on the TableGen
definitions side, as changes for OpenCL 3 feature optionality still
need to be defined and will affect how we want to expose these.

Differential Revision: https://reviews.llvm.org/D100492
2021-04-19 10:23:13 +01:00
Jan Svoboda 64e4dfd72b [clang][cli] NFC: Use Diags to report parsing success/failure
`Success` is set to `false` whenever `Diags.Report(diag::err_)` is called. Remove the duplication and use `Diags` as the source of truth when deciding whether to report parsing success/failure.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D100644
2021-04-19 11:17:16 +02:00
Jan Svoboda 26bbb8700b [clang] Implement CompilerInvocation copy assignment
This patch implements the copy assignment for `CompilerInvocation`.

Eventually, the deep-copy operation will be moved into a `clone()` method (D100460), but until then, this is necessary for basic ergonomics.

Depends on D100455.

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D100473
2021-04-19 11:12:22 +02:00
Jan Svoboda 782b985888 [clang] Rename CompilerInvocationBase to RefBase, split out ValueBase
This patch documents the reason `CompilerInvocationBase` exists and renames it to more descriptive `CompilerInvocationRefBase`.

To make the distinction obvious, it also splits out new `CompilerInvocationValueBase` class.

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D100455
2021-04-19 10:31:11 +02:00
ShihPo Hung 27edaee84e [RISCV][Driver] Make the ordering of CmdArgs consistent between RISCV::Linker and baremetal::Linker
In baremetal::Linker::ConstructJob, LinkerInput is handled prior to T_Group options,
but on the other side in RISCV::Linker::ConstructJob, it is opposite.

We want it to be consistent whether users are using RISCV::Linker or baremetal::Linker.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D100615
2021-04-18 19:05:20 -07:00
Xun Li 5faba87938 Revert "[Coroutines] Set presplit attribute in Clang instead of CoroEarly pass"
This reverts commit fa6b54c44a.
The commited patch broke mlir tests. It seems that mlir tests depend on coroutine function properties set in CoroEarly pass.
2021-04-18 17:22:28 -07:00
Xun Li fa6b54c44a [Coroutines] Set presplit attribute in Clang instead of CoroEarly pass
Presplit coroutines cannot be inlined. During AlwaysInliner we check if a function is a presplit coroutine, if so we skip inlining.
The presplit coroutine attributes are set in CoroEarly pass.
However in O0 pipeline, AlwaysInliner runs before CoroEarly, so the attribute isn't set yet and will still inline the coroutine.
This causes Clang to crash: https://bugs.llvm.org/show_bug.cgi?id=49920

To fix this, we set the attributes in the Clang front-end instead of in CoroEarly pass.

Reviewed By: rjmccall, ChuanqiXu

Differential Revision: https://reviews.llvm.org/D100282
2021-04-18 15:41:09 -07:00
Xun Li c0211e8d7d Revert "[Coroutines] Move CoroEarly pass to before AlwaysInliner"
This reverts commit 2b50f5a434.
Forgot to update the description of the commit to sync with phabricator. Going to redo the commit.
2021-04-18 15:38:19 -07:00
Xun Li 2b50f5a434 [Coroutines] Move CoroEarly pass to before AlwaysInliner
Presplit coroutines cannot be inlined. During AlwaysInliner we check if a function is a presplit coroutine, if so we skip inlining.
The presplit coroutine attributes are set in CoroEarly pass.
However in O0 pipeline, AlwaysInliner runs before CoroEarly, so the attribute isn't set yet and will still inline the coroutine.
This causes Clang to crash: https://bugs.llvm.org/show_bug.cgi?id=49920

Differential Revision: https://reviews.llvm.org/D100282
2021-04-18 14:54:04 -07:00
Nathan James db75db85f2
[Introspection] Dont emit json if unchanged.
Saves running the generate inc script in the, somewhat common, case where the json file doesn't need changing.

Reviewed By: steveire

Differential Revision: https://reviews.llvm.org/D100719
2021-04-18 20:22:09 +01:00
Martin Storsjö d4528cbb0e [clang] Fix cross compiling clang for windows after 141945f950
Don't try to execute clang-ast-dump when cross compiling.
2021-04-18 15:56:18 +03:00
Nathan James a0898f0cec [AST][Introspection][NFC] Remove unnecessary temporary strings. 2021-04-18 09:25:19 +01:00
Stephen Kelly dd68942f1d [AST] Add TypeLoc support to node introspection
Extend the matchers gathering API for types to record template
parameters.  The TypeLoc type hierarchy has some types which are
templates used in CRTP such as PointerLikeTypeLoc.  Record the inherited
template and template arguments of types inheriting those CRTP types in
the ClassInheritance map.  Because the name inherited from is now
computed, the value type in that map changes from StringRef to
std::string.  This also causes the toJSON override signature used to
serialize that map to change.

Remove the logic for skipping over empty ClassData instances.  Several
classes such as TypeOfExprTypeLoc inherit a CRTP class which provides
interesting locations though the derived class does not.  Record it as a
class to make the locations it inherits available.

Record the typeSourceInfo accessors too as they provide access to
TypeLocs in many classes.

The existing unit tests use UnorderedElementsAre to compare the
introspection result with the expected result.  Our current
implementation of google mock (in gmock-generated-matchers.h) is limited
to support for comparing a container of 10 elements.  As we are now
returning more than 10 results for one of the introspection tests,
change it to instead compare against an ordered vector of pairs.

Because a macro is used to generate API strings and API calls, disable
clang-format in blocks of expected results.  Otherwise clang-format
would insert whitespaces which would then be compared against the
introspected strings and fail the test.

Introduce a recursion guard in the generated code.  The TypeLoc class
has IgnoreParens() API which by default returns itself, so it would
otherwise recurse infinitely.

Differential Revision: https://reviews.llvm.org/D100516
2021-04-17 22:58:02 +01:00
Sylvain Audi bb26fa8c28 [clang-scan-deps] Add support for clang-cl
clang-scan-deps contains some command line parsing and modifications.
This patch adds support for clang-cl command options.

Differential Revision: https://reviews.llvm.org/D92191
2021-04-17 14:22:51 -04:00
Sylvain Audi 488a19d00c [clang-scan-deps] Support double-dashes in clang command lines
This fixes argument injection in clang command lines, by adding them before "--".

Previously, the arguments were injected at the end of the command line and could be added after "--", which would be wrongly interpreted as input file paths.

This fix is needed for a subsequent patch, see D92191.

Differential Revision: https://reviews.llvm.org/D95099
2021-04-17 14:22:51 -04:00
Stephen Kelly 141945f950 [AST] Enable AST node introspection on WIN32 2021-04-17 18:59:35 +01:00
Jennifer Chukwu 21bef4e11e [NFC] Fixed Typos
Reviewed By: xgupta

Differential Revision: https://reviews.llvm.org/D100705
2021-04-17 22:02:23 +05:30
Stephen Kelly ebc6608fb7 [AST] Remove args from LocationCall
This class initially had args to be generic to future needs. In
particular, I thought that source location introspection should show the
getBeginLoc of CallExpr args and the getArgLoc of
TemplateSpecializationLocInfo etc.  However, that is probably best left
out of source location introspection because it involves node traversal.

If something like this is needed in the future, it can be added in the
future.

Differential Revision: https://reviews.llvm.org/D100688
2021-04-17 17:21:55 +01:00
Yaxun (Sam) Liu 6823af0ca8 [HIP] Support hipRTC in header
hipRTC compiles HIP device code at run time. Since the system may not
have development tools installed, when a HIP program is compiled through
hipRTC, there is no standard C or C++ header available. As such, the HIP
headers should not depend on standard C or C++ headers when used
with hipRTC. Basically when hipRTC is used, HIP headers only provides
definitions of HIP device API functions. This is in line with what nvRTC does.

This patch adds support of hipRTC to HIP headers in clang. Basically hipRTC
defines a macro __HIPCC_RTC__ when compile HIP code at run time. When
this macro is defined, HIP headers do not include standard C/C++ headers.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D100652
2021-04-17 11:34:52 -04:00
Dávid Bolvanský 12a1f1d9d7 [Pragma] Added support for GCC unroll/nounroll
GCC 8 introduced these new pragmas to control loop unrolling. We should support them for compatibility reasons and the implementation itself requires few lines of code, since everything needed is already implemented for #pragma unroll/nounroll.
2021-04-17 17:29:55 +02:00
Yaxun (Sam) Liu d5c0f00e21 [CUDA][HIP] Mark device var used by host only
Add device variables to llvm.compiler.used if they are
ODR-used by either host or device functions.

This is necessary to prevent them from being
eliminated by whole-program optimization
where the compiler has no way to know a device
variable is used by some host code.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D98814
2021-04-17 11:25:25 -04:00
Yaxun (Sam) Liu 3597f02fd5 [AMDGPU] Add GlobalDCE before internalization pass
The internalization pass only internalizes global variables
with no users. If the global variable has some dead user,
the internalization pass will not internalize it.

To be able to internalize global variables with dead
users, a global dce pass is needed before the
internalization pass.

This patch adds that.

Reviewed by: Artem Belevich, Matt Arsenault

Differential Revision: https://reviews.llvm.org/D98783
2021-04-17 11:25:25 -04:00
Serge Guelton d6de1e1a71 Normalize interaction with boolean attributes
Such attributes can either be unset, or set to "true" or "false" (as string).
throughout the codebase, this led to inelegant checks ranging from

        if (Fn->getFnAttribute("no-jump-tables").getValueAsString() == "true")

to

        if (Fn->hasAttribute("no-jump-tables") && Fn->getFnAttribute("no-jump-tables").getValueAsString() == "true")

Introduce a getValueAsBool that normalize the check, with the following
behavior:

no attributes or attribute set to "false" => return false
attribute set to "true" => return true

Differential Revision: https://reviews.llvm.org/D99299
2021-04-17 08:17:33 +02:00
Ben Barham 1206b95e07 [ASTReader] Only mark module out of date if not already compiled
If a module contains errors (ie. it was built with
-fallow-pcm-with-compiler-errors and had errors) and was from the module
cache, it is marked as out of date - see
a2c1054c30.

When a module is imported multiple times in the one compile, this caused
it to be recompiled each time - removing the existing buffer from the
module cache and replacing it. This results in various errors further
down the line.

Instead, only mark the module as out of date if it isn't already
finalized in the module cache.

Reviewed By: akyrtzi

Differential Revision: https://reviews.llvm.org/D100619
2021-04-16 17:57:03 -07:00
Ben Shi 06995fe256 [clang][NFC] Fix a potential assert failure
Reviewed By: MaskRay, craig.topper

Differential Revision: https://reviews.llvm.org/D100616
2021-04-17 07:17:34 +08:00
Philip Reames f549176ad9 [funcattrs] Add the maximal set of implied attributes to definitions
Have funcattrs expand all implied attributes into the IR. This expands the infrastructure from D100400, but for definitions not declarations this time.

Somewhat subtly, this mostly isn't semantic. Because the accessors did the inference, any client which used the accessor was already getting the stronger result. Clients that directly checked presence of attributes (there are some), will see a stronger result now.

The old behavior can end up quite confusing for two reasons:
* Without this change, we have situations where function-attrs appears to fail when inferring an attribute (as seen by a human reading IR), but that consuming code will see that it should have been implied. As a human trying to sanity check test results and study IR for optimization possibilities, this is exceeding error prone and confusing. (I'll note that I wasted several hours recently because of this.)
* We can have transforms which trigger without the IR appearing (on inspection) to meet the preconditions. This change doesn't prevent this from happening (as the accessors still involve multiple checks), but it should make it less frequent.

I'd argue in favor of deleting the extra checks out of the accessors after this lands, but I want that in it's own review as a) it's purely stylistic, and b) I already know there's some disagreement.

Once this lands, I'm also going to do a cleanup change which will delete some now redundant duplicate predicates in the inference code, but again, that deserves to be a change of it's own.

Differential Revision: https://reviews.llvm.org/D100226
2021-04-16 14:22:19 -07:00
Thomas Lively 5c729750a6 [WebAssembly] Remove saturating fp-to-int target intrinsics
Use the target-independent @llvm.fptosi and @llvm.fptoui intrinsics instead.
This includes removing the instrinsics for i32x4.trunc_sat_zero_f64x2_{s,u},
which are now represented in IR as a saturating truncation to a v2i32 followed by
a concatenation with a zero vector.

Differential Revision: https://reviews.llvm.org/D100596
2021-04-16 12:11:20 -07:00
Björn Schäpers 4696857733 DeclContext: Fix iterator category
This amends 0cb7e7ca0c.
The iterator category of lookup_iterator was changed, but here it stayed
hardcoded as random access. Found while trying to build Clazy.

Differential-Revision: https://reviews.llvm.org/D100590
2021-04-16 20:59:36 +02:00
Dávid Bolvanský 0daf273025 [Builtins] Add memory allocation builtins (PR12543) 2021-04-16 20:36:46 +02:00
Artem Belevich eaa9ef075d [CUDA, FDO] Filter out profiling options from GPU-side compilations.
Differential Revision: https://reviews.llvm.org/D100598
2021-04-16 11:35:28 -07:00
Min-Yih Hsu 59437cb7d7 [M68k] Fix empty builtin va_list kind
Clang _requires_ every target to provide a va_list kind so we shouldn't
put a llvm_unreachable there. Using `VoidPtrBuiltinVaList` because m68k
doesn't have any special ABI for variadic args.
2021-04-16 11:09:22 -07:00
Zakk Chen 8f683366af [RISCV][Clang] Add RVV miscellaneous intrinsic functions.
1. vreinterpret
2. vundefined
3. LMUL truncation and extension.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D100391
2021-04-16 09:41:19 -07:00
Zakk Chen ca9e52f67c [RISCV][Clang] Drop the assembly tests for RVV intrinsics.
We had verified the correctness of all intrinsics in downstream, so
dropping the assembly tests to decrease the check-clang time.
It would remove 1/3 of the RUN lines.

https://reviews.llvm.org/D99151#2654154 mentions why we need to have
the ASM tests before.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D100617
2021-04-16 09:30:12 -07:00
Troy Johnson 8628ed0310 [Driver] Allow both lib64 and lib in rocm-detect test.
Differential Revision: https://reviews.llvm.org/D100502
2021-04-16 09:55:57 -05:00
Jonathan Crowther e71994a239 [SystemZ][z/OS] Add IsText Argument to GetFile and GetFileOrSTDIN
Add the `IsText` argument to `GetFile` and `GetFileOrSTDIN` which will help z/OS distinguish between text and binary correctly. This is an extension to [this patch](https://reviews.llvm.org/D97785)

Reviewed By: abhina.sreeskantharajan, amccarth

Differential Revision: https://reviews.llvm.org/D100488
2021-04-16 10:08:36 -04:00
Alexey Bataev 10c7b9f64f [OPENMP]Fix PR49115: Incorrect results for scan directive.
For combined worksharing directives need to emit the temp arrays outside
of the parallel region and update them in the master thread only.

Differential Revision: https://reviews.llvm.org/D100187
2021-04-16 06:25:35 -07:00
Pushpinder Singh efc013ec4d Revert "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed"
This reverts commit 7029cffc4e.
2021-04-16 09:16:58 +00:00
Max Sagebaum fd4e08aa8f [clang-format] Inconsistent behavior regarding line break before access modifier
Fixes https://llvm.org/PR41870.

Checks for newlines in option Style.EmptyLineBeforeAccessModifier are now based on the formatted new lines and not on the new lines in the file.

Reviewed By: HazardyKnusperkeks, curdeius

Differential Revision: https://reviews.llvm.org/D99503
2021-04-16 10:39:13 +02:00
Pushpinder Singh 7029cffc4e [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed
This patch adds new clang tool named amdgpu-arch which uses
HSA to detect installed AMDGPU and report back latter's march.
This tool is built only if system has HSA installed.

The value printed by amdgpu-arch is used to fill -march when
latter is not explicitly provided in -Xopenmp-target.

Reviewed By: JonChesterfield, gregrodgers

Differential Revision: https://reviews.llvm.org/D99949
2021-04-16 05:26:20 +00:00
Richard Smith f7c9de0de5 Add triple to fix test failure.
This test uses `__regcall`, support for which is target-specific.
2021-04-15 18:08:35 -07:00
Joshua Haberman 8344675908 Implemented [[clang::musttail]] attribute for guaranteed tail calls.
This is a Clang-only change and depends on the existing "musttail"
support already implemented in LLVM.

The [[clang::musttail]] attribute goes on a return statement, not
a function definition. There are several constraints that the user
must follow when using [[clang::musttail]], and these constraints
are verified by Sema.

Tail calls are supported on regular function calls, calls through a
function pointer, member function calls, and even pointer to member.

Future work would be to throw a warning if a users tries to pass
a pointer or reference to a local variable through a musttail call.

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D99517
2021-04-15 17:12:21 -07:00
Stephen Kelly f62ad15cd7 NFC: Add a simple test for introspection call formatting 2021-04-15 23:45:54 +01:00
Stephen Kelly be65347326 NFC: Add missing matcher for test method
The intention is to match the definition.
2021-04-15 23:26:00 +01:00
cchen 924cdff0ae [OpenMP5][DOCS] Update status of masked construct and correct the color
for omp_target_is_present, NFC.
2021-04-15 17:19:04 -05:00
Stephen Kelly 4f6d698467 [AST] Fix location call storage with common last-invocation
Differential Revision: https://reviews.llvm.org/D100548
2021-04-15 23:15:11 +01:00
Momchil Velikov f9d932e673 [clang][AArch64] Correctly align HFA arguments when passed on the stack
When we pass a AArch64 Homogeneous Floating-Point
Aggregate (HFA) argument with increased alignment
requirements, for example

    struct S {
      __attribute__ ((__aligned__(16))) double v[4];
    };

Clang uses `[4 x double]` for the parameter, which is passed
on the stack at alignment 8, whereas it should be at
alignment 16, following Rule C.4 in
AAPCS (https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst#642parameter-passing-rules)

Currently we don't have a way to express in LLVM IR the
alignment requirements of the function arguments. The align
attribute is applicable to pointers only, and only for some
special ways of passing arguments (e..g byval). When
implementing AAPCS32/AAPCS64, clang resorts to dubious hacks
of coercing to types, which naturally have the needed
alignment. We don't have enough types to cover all the
cases, though.

This patch introduces a new use of the stackalign attribute
to control stack slot alignment, when and if an argument is
passed in memory.

The attribute align is left as an optimizer hint - it still
applies to pointer types only and pertains to the content of
the pointer, whereas the alignment of the pointer itself is
determined by the stackalign attribute.

For byval arguments, the stackalign attribute assumes the
role, previously perfomed by align, falling back to align if
stackalign` is absent.

On the clang side, when passing arguments using the "direct"
style (cf. `ABIArgInfo::Kind`), now we can optionally
specify an alignment, which is emitted as the new
`stackalign` attribute.

Patch by Momchil Velikov and Lucas Prates.

Differential Revision: https://reviews.llvm.org/D98794
2021-04-15 22:58:14 +01:00
Nathan James f019e5f73e
[AST][Introspection] Add a check to detect if introspection is supported.
This could probably be made into a compile time constant, but that would involve generating a second inc file.

Reviewed By: steveire

Differential Revision: https://reviews.llvm.org/D100530
2021-04-15 22:21:41 +01:00
Nathan James 542e7806e6
[AST] Add a print method to Introspection LocationCall
Add a print method that takes a raw_ostream.
Change LocationCallFormatterCpp::format to call that method.

Reviewed By: steveire

Differential Revision: https://reviews.llvm.org/D100423
2021-04-15 22:18:29 +01:00
Martin Storsjö 8e0f2e89ff [clang] [AArch64] Fix handling of HFAs passed to Windows variadic functions
The documentation says that for variadic functions, all composites
are treated similarly, no special handling of HFAs/HVAs, not even
for the fixed arguments of a variadic function.

Differential Revision: https://reviews.llvm.org/D100467
2021-04-15 22:21:27 +03:00
Max Sagebaum dda978eef8 [clang-format] Option for empty lines after an access modifier.
The current logic for access modifiers in classes ignores the option 'MaxEmptyLinesToKeep=1'. It is therefore impossible to have a coding style that requests one empty line after an access modifier. The patch allows the user to configure how many empty lines clang-format should add after an access modifier. This will remove lines if there are to many and will add them if there are missing.

Reviewed By: MyDeveloperDay, curdeius

Differential Revision: https://reviews.llvm.org/D98237
2021-04-15 21:03:07 +02:00
cchen e0c2125d1d [OpenMP] Added codegen for masked directive
Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D100514
2021-04-15 12:55:07 -05:00
Melanie Blower 938b863bb5 [clang][patch] Modify diagnostic level from err to warn: anyx86_interrupt_regsave
Reviewed By: Aaron Ballman

Differential Revision: https://reviews.llvm.org/D100511
2021-04-15 13:11:33 -04:00
Arthur Eubanks c8f0a7c215 [NewPM] Cleanup IR printing instrumentation
Being lazy with printing the banner seems hard to reason with, we should print it
unconditionally first (it could also lead to duplicate banners if we
have multiple functions in -filter-print-funcs).

The printIR() functions were doing too many things. I separated out the
call from PrintPassInstrumentation since we were essentially doing two
completely separate things in printIR() from different callers.

There were multiple ways to generate the name of some IR. That's all
been moved to getIRName(). The printing of the IR name was also
inconsistent, now it's always "IR Dump on $foo" where "$foo" is the
name. For a function, it's the function name. For a loop, it's what's
printed by Loop::print(), which is more detailed. For an SCC, it's the
list of functions in parentheses. For a module it's "[module]", to
differentiate between a possible SCC with a function called "module".

To preserve D74814, we have to check if we're going to print anything at
all first. This is unfortunate, but I would consider this a special
case that shouldn't be handled in the core logic.

Reviewed By: jamieschmeiser

Differential Revision: https://reviews.llvm.org/D100231
2021-04-15 09:50:55 -07:00
Mark Johnston 99eca1bd9c [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
2021-04-15 17:49:00 +01:00
Shilei Tian 2a95cb5858 [Clang][Docs] Claim the atomic compare
I'm working on the implementation of OpenMP 5.1 feature `atomic compare`.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D100507
2021-04-15 11:10:15 -04:00
Aaron Ballman ad2d6bbb14 Fix potential infinite loop with malformed attribute syntax
Double square bracket attribute arguments can be arbitrarily complex,
and the attribute argument parsing logic recovers by skipping tokens.
As a fallback recovery mechanism, parse recovery stops before reading a
semicolon. This could lead to an infinite loop in the attribute list
parsing logic.
2021-04-15 10:47:32 -04:00
Matthias Klose 56cb214b38 add test case for ignoring -flto=auto and -flto=jobserver
as requested in https://reviews.llvm.org/D99501, test that the two new options are ignored.

Reviewed By: tejohnson, fhahn

Differential Revision: https://reviews.llvm.org/D100484
2021-04-15 12:19:14 +02:00
Jan Svoboda 06eff02ba1 [clang][deps] NFC: Improve documentation
Fix typos and simplify wording
2021-04-15 10:31:09 +02:00
Martin Storsjö ee570e2153 [clang] [test] Share patterns in CodeGen/ms_abi_aarch64.c between cases. NFC.
Differential Revision: https://reviews.llvm.org/D100468
2021-04-15 11:02:14 +03:00
Zakk Chen ea5d33dbc1 [RISCV][Clang] Add vmv and vfmv series intrinsic functions.
Authored-by: Roger Ferrer Ibanez <rofirrim@gmail.com>
Co-Authored-by: Zakk Chen <zakk.chen@sifive.com>

Reviewed By: craig.topper, Jim

Differential Revision: https://reviews.llvm.org/D100266
2021-04-14 22:22:39 -07:00
Eli Friedman dc1ab590a0 [Sema] Fold VLA types in compound literals to constant arrays.
Similar to variables with an initializer, this is never valid in
standard C, so we can safely constant-fold as an extension.  I ran into
this construct in a couple proprietary codebases.

While I'm here, drive-by fix for 090dd647: we should only fold variables
with VLA types, not arbitrary variably modified types.

Differential Revision: https://reviews.llvm.org/D98363
2021-04-14 17:09:59 -07:00
Philip Reames dd985551c2 Reapply "[InferAttributes] Materialize all infered attributes for declaration"" and follow on patches.
This reverts commit ab98f2c712 and 98eea392cd.

It includes a fix for the clang test which triggered the revert.  I failed to notice this one because there was another AMDGPU llvm test with a similiar name and the exact same text in the error message.  Odd.  Since only one build bot reported the clang test, I didn't notice that one.
2021-04-14 16:38:07 -07:00
Nathan James 6890f302f5
[AST][Introspection] Fix args not being set.
This field isn't set in the constructor.
Tweak its accessor to return an ArrayRef.
2021-04-15 00:19:40 +01:00
Nathan James bfb6c2874b
[AST][NFC] Remove temporary ASTTU file from Introspection generation.
We can use the Preprocessor to remap this file, cleaning up the cmake code.

Reviewed By: steveire

Differential Revision: https://reviews.llvm.org/D100343
2021-04-15 00:14:55 +01:00
Nathan James b23abbeab1
[AST] Use IntrusiveRefCntPtr for Introspection LocationCall.
Reviewed By: steveire

Differential Revision: https://reviews.llvm.org/D100378
2021-04-15 00:12:22 +01:00
Stephen Kelly c960c3836c NFC: Remove condition to simplify code
The run method is only called if there is a match with a binding.
2021-04-14 23:38:04 +01:00
Thomas Lively 6a18cc23ef [WebAssembly] Codegen for i64x2.extend_{low,high}_i32x4_{s,u}
Removes the builtins and intrinsics used to opt in to using these instructions
and replaces them with normal ISel patterns now that they are no longer
prototypes.

Differential Revision: https://reviews.llvm.org/D100402
2021-04-14 13:43:09 -07:00
Stephen Kelly f347f0e0b8 [AST] Add introspection support for more base nodes
Fix the logic of detecting pseudo-virtual getBeginLoc etc on Stmt and
Decl subclasses.

Adjust the test infrastructure to filter out invalid source locations.
This makes the tests more clear about which nodes have which locations.

Differential Revision: https://reviews.llvm.org/D99231
2021-04-14 21:31:23 +01:00
Sterling Augustine d2bb3cbbf8 Make test runnable on read-only file systems. 2021-04-14 13:29:51 -07:00
Stephen Kelly 6559ebd91b [AST] Replace asserts with a condition
As was done for other locations in commit 54272e5b (NFC:
Replace asserts with if() in SourceLocation accessors, 2019-01-07).

Extracted from  https://reviews.llvm.org/D99231
2021-04-14 21:14:05 +01:00
Alex Lorenz c1554f32e3 [clang][FileManager] Support empty file name in getVirtualFileRef for serialized diagnostics
After https://reviews.llvm.org/D90484 libclang is unable to read a serialized diagnostic file
which contains a diagnostic which came from a file with an empty filename. The reason being is
that the serialized diagnostic reader is creating a virtual file for the "" filename, which now
fails after the changes in https://reviews.llvm.org/D90484. This patch restores the previous
behavior in getVirtualFileRef by allowing it to construct a file entry ref with an empty name by
pretending its name is "." so that the directory entry can be created.

Differential Revision: https://reviews.llvm.org/D100428
2021-04-14 11:29:25 -07:00
Shu-Chun Weng 1c5717225e [libTooling] Add smart pointer support to the `access` Stencil
This extends smart pointer support beyond the existing `maybeDeref` and
`maybeAddressOf`.

Differential Revision: https://reviews.llvm.org/D100450
2021-04-14 10:45:59 -07:00
Thomas Lively af7925b4dd [WebAssembly] Codegen for f64x2.convert_low_i32x4_{s,u}
Add a custom DAG combine and ISD opcode for detecting patterns like

  (uint_to_fp (extract_subvector ...))

before the extract_subvector is expanded to ensure that they will ultimately
lower to f64x2.convert_low_i32x4_{s,u} instructions. Since these instructions
are no longer prototypes and can now be produced via standard IR, this commit
also removes the target intrinsics and builtins that had been used to prototype
the instructions.

Differential Revision: https://reviews.llvm.org/D100425
2021-04-14 10:42:45 -07:00
Martin Probst 2fe4909748 clang-format: fix undefined behavior.
The previous change failed to initialize the SymbolsMerged field.
2021-04-14 19:41:18 +02:00
Thomas Lively af7ab81ce3 [WebAssembly] Use standard intrinsics for f32x4 and f64x2 ops
Now that these instructions are no longer prototypes, we do not need to be
careful about keeping them opt-in and can use the standard LLVM infrastructure
for them. This commit removes the bespoke intrinsics we were using to represent
these operations in favor of the corresponding target-independent intrinsics.
The clang builtins are preserved because there is no standard way to easily
represent these operations in C/C++.

For consistency with the scalar codegen in the Wasm backend, the intrinsic used
to represent {f32x4,f64x2}.nearest is @llvm.nearbyint even though
@llvm.roundeven better captures the semantics of the underlying Wasm
instruction. Replacing our use of @llvm.nearbyint with use of @llvm.roundeven is
left to a potential future patch.

Differential Revision: https://reviews.llvm.org/D100411
2021-04-14 09:19:27 -07:00
Martin Probst 4d195f1b4d review comments
track symbol merge status in references to avoid excesive rewrites
2021-04-14 17:20:08 +02:00
Martin Probst d45df0d29f clang-format: [JS] merge import lines.
Multiple lines importing from the same URL can be merged:

    import {X} from 'a';
    import {Y} from 'a';

Merge to:

    import {X, Y} from 'a';

This change implements this merge operation. It takes care not to merge in
various corner case situations (default imports, star imports).

Differential Revision: https://reviews.llvm.org/D100466
2021-04-14 17:20:07 +02:00
Hans Wennborg f29dcbdde1 Add flag for showing skipped headers in -H / --show-includes output
Consider the following set of files:

  a.cc:
  #include "a.h"

  a.h:
  #ifndef A_H
  #define A_H

  #include "b.h"
  #include "c.h"  // This gets "skipped".

  #endif

  b.h:
  #ifndef B_H
  #define B_H

  #include "c.h"

  #endif

  c.h:
  #ifndef C_H
  #define C_H

  void c();

  #endif

And the output of the -H option:

  $ clang -c -H a.cc
  . ./a.h
  .. ./b.h
  ... ./c.h

Note that the include of c.h in a.h is not shown in the output (GCC does the
same). This is because of the include guard optimization: clang knows c.h is
covered by an include guard which is already defined, so when it sees the
include in a.h, it skips it. The same would have happened if #pragma once were
used instead of include guards.

However, a.h *does* include c.h, and it may be useful to show that in the -H
output. This patch adds a flag for doing that.

Differential revision: https://reviews.llvm.org/D100480
2021-04-14 17:01:51 +02:00
Erich Keane 92aba5ae49 CPUDispatch- allow out of line member definitions
ICC permits this, and after some extensive testing it looks like we can
support this with very little trouble.  We intentionally don't choose to
do this with attribute-target (despite it likely working as well!)
  because GCC does not support that, and introducing said
  incompatibility doesn't seem worth it.
2021-04-14 06:19:49 -07:00
Sven van Haastregt 856c49d79c [OpenCL][Docs] Update OpenCL 3.0 implementation status
Reviewed-By: Anastasia Stulova
2021-04-14 13:56:26 +01:00
Martin Storsjö 3637c5c8ec [clang] [AArch64] Fix Windows va_arg handling for larger structs
Aggregate types over 16 bytes are passed by reference.

Contrary to the x86_64 ABI, smaller structs with an odd (non power
of two) are padded and passed in registers.

Differential Revision: https://reviews.llvm.org/D100374
2021-04-14 14:51:53 +03:00
Liu, Chen3 1c4108ab66 [i386] Modify the alignment of __m128/__m256/__m512 vector type according i386 abi.
According to i386 System V ABI:

1. when __m256 are required to be passed on the stack, the stack pointer must be aligned on a 0 mod 32 byte boundary at the time of the call.
2. when __m512 are required to be passed on the stack, the stack pointer must be aligned on a 0 mod 64 byte boundary at the time of the call.

The current method of clang passing __m512 parameter are as follow:

1. when target supports avx512, passing it with 64 byte alignment;
2. when target supports avx, passing it with 32 byte alignment;
3. Otherwise, passing it with 16 byte alignment.

Passing __m256 parameter are as follow:

1. when target supports avx or avx512, passing it with 32 byte alignment;
2. Otherwise, passing it with 16 byte alignment.

This pach will passing __m128/__m256/__m512 following i386 System V ABI and
apply it to Linux only since other System V OS (e.g Darwin, PS4 and FreeBSD) don't
want to spend any effort dealing with the ramifications of ABI breaks at present.

Differential Revision: https://reviews.llvm.org/D78564
2021-04-14 16:44:54 +08:00