Commit Graph

91805 Commits

Author SHA1 Message Date
Jan Svoboda da920c3bcc [clang][deps] NFC: Move entry initialization into member functions
This is a prep-patch for making `CachedFileSystemEntry` initialization more lazy.
2021-12-15 16:39:29 +01:00
Jan Svoboda 3031fd71b9 [clang][deps] NFC: Use clearer wording around entry initialization
The code and documentation around `CachedFileSystemEntry` use the following terms:
* "invalid stat" for `llvm::ErrorOr<llvm::vfs::Status>` that is *not* an error and contains an unknown status,
* "initialized entry" for an entry that contains "invalid stat",
* "valid entry" for an entry that contains "invalid stat", synonymous to "initialized" entry.

Having an entry be "valid" while it contains an "invalid" status object is counter-intuitive.
This patch cleans up the wording by referring to the status as "unknown" and to the entry as either "initialized" or "uninitialized".
2021-12-15 16:14:44 +01:00
Ed Maste b41bb6c1b7 [Driver] Default to contemporary FreeBSD profiling behaviour
Prior to FreeBSD 14, FreeBSD provided special _p.a libraries for use
with -pg.  They are no longer used or provided.  If the target does
not specify a major version (e.g. amd64-unknown-freebsd, rather than
amd64-unknown-freebsd12) default to the new behaviour.

Differential Revision:	https://reviews.llvm.org/D114396
2021-12-15 09:05:35 -05:00
Nikita Popov b9492ec649 [CodeGen] Avoid some pointer element type accesses 2021-12-15 14:46:10 +01:00
Sam McCall e7007b69d4 [Sema] Add FixIt when a C++ out-of-line method has extra/missing const
Differential Revision: https://reviews.llvm.org/D115567
2021-12-15 14:30:54 +01:00
Nikita Popov d930c3155c [CodeGen] Pass element type to EmitCheckedInBoundsGEP()
Same as for other GEP creation methods.
2021-12-15 14:03:33 +01:00
Chuanqi Xu 5653d127d7 [docs] Give the reason why the support for coroutine is partial
This helps user to know what level of support there
is (roughly) for coroutine feature.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D115778
2021-12-15 21:01:46 +08:00
gysit b7f2c108eb [mlir][linalg] Replace LinalgOps.h and LinalgTypes.h by a single header.
After removing the range type, Linalg does not define any type. The revision thus consolidates the LinalgOps.h and LinalgTypes.h into a single Linalg.h header. Additionally, LinalgTypes.cpp is renamed to LinalgDialect.cpp to follow the convention adopted by other dialects such as the tensor dialect.

Depends On D115727

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D115728
2021-12-15 12:15:03 +00:00
Nikita Popov 90bbf79c7b [CodeGen] Avoid some deprecated Address constructors
Some of these are on the critical path towards making something
minimal work with opaque pointers.
2021-12-15 12:45:23 +01:00
Nikita Popov 481de0ed80 [CodeGen] Prefer CreateElementBitCast() where possible
CreateElementBitCast() can preserve the pointer element type in
the presence of opaque pointers, so use it in place of CreateBitCast()
in some places. This also sometimes simplifies the code a bit.
2021-12-15 11:48:39 +01:00
Gabor Marton bd9e23943a [analyzer] Expand conversion check to check more expressions for overflow and underflow
This expands checking for more expressions. This will check underflow
and loss of precision when using call expressions like:

  void foo(unsigned);
  int i = -1;
  foo(i);

This also includes other expressions as well, so it can catch negative
indices to std::vector since it uses unsigned integers for [] and .at()
function.

Patch by: @pfultz2

Differential Revision: https://reviews.llvm.org/D46081
2021-12-15 11:41:34 +01:00
Nikita Popov 834c8ff587 [CodeGen] Avoid some uses of deprecated Address constructor
Explicitly pass in the element type instead.
2021-12-15 11:13:10 +01:00
Nikita Popov c3b624a191 [CodeGen] Avoid deprecated ConstantAddress constructor
Change all uses of the deprecated constructor to pass the
element type explicitly and drop it.

For cases where the correct element type was not immediately
obvious to me or would require a slightly larger change I'm
falling back to explicitly calling getPointerElementType() for now.
2021-12-15 10:42:41 +01:00
Nikita Popov b4f46555d7 [CodeGen] Avoid some pointer element type accesses 2021-12-15 09:29:27 +01:00
Nikita Popov abbc2e997b [CodeGen] Store ElementType in Address
Explicitly track the pointer element type in Address, rather than
deriving it from the pointer type, which will no longer be possible
with opaque pointers. This just adds the basic facility, for now
everything is still going through the deprecated constructors.

I had to adjust one place in the LValue implementation to satisfy
the new assertions: Global registers are represented as a
MetadataAsValue, which does not have a pointer type. We should
avoid using Address in this case.

This implements a part of D103465.

Differential Revision: https://reviews.llvm.org/D115725
2021-12-15 08:59:44 +01:00
Nico Weber b45ad7363c [clang] Use usual lit pattern for CLANG_DEFAULT_PIE_ON_LINUX and LLVM_WITH_Z3
See D28294 for context.

Differential Revision: https://reviews.llvm.org/D115751
2021-12-14 21:44:56 -05:00
Sindhu Chittireddy 4706a297fb Avoid setting tbaa on the store of return type of call to inline assembler.
In 32bit mode, attaching TBAA metadata to the store following the call
to inline assembler results in describing the wrong type by making a
fake lvalue(i.e., whatever the inline assembler happens to leave in
EAX:EDX.) Even if inline assembler somehow describes the correct type,
setting TBAA information on return type of call to inline assembler is
likely not correct, since TBAA rules need not apply to inline assembler.

Differential Revision: https://reviews.llvm.org/D115320
2021-12-14 17:40:33 -08:00
Stephan T. Lavavej 8bd106a891 [NFC] Fix typos in release notes.
Reviewed By: ldionne, Mordante, MaskRay

Differential Revision: https://reviews.llvm.org/D115685
2021-12-14 14:19:42 -08:00
Sanjay Patel 1a60ae02c6 [InstCombine] fold mask-with-signbit-splat to icmp+select
~(iN X s>> (N-1)) & Y --> (X s< 0) ? 0 : Y

https://alive2.llvm.org/ce/z/JKlQ9x

This is similar to D111410 / 727e642e97 ,
but it includes a 'not' of the signbit and so it
saves an instruction in the basic pattern.

DAGCombiner or target-specific folds can expand
this back into bit-hacks.

The diffs in the logical-select tests are not true
regressions - running early-cse and another round
of instcombine is expected in a normal opt pipeline,
and that reduces back to a minimal form as shown
in the duplicated PhaseOrdering test.

I have no understanding of the SystemZ diffs, so
I made the minimal edits suggested by FileCheck to
make that test pass again. That whole test file is
wrong though. It is running the entire optimizer (-O2)
to check IR, and then topping that by even running
codegen and checking asm. It needs to be split up.

Fixes #52631
2021-12-14 16:00:42 -05:00
Mingming Liu 09a704c5ef [LTO] Ignore unreachable virtual functions in WPD in hybrid LTO.
Differential Revision: https://reviews.llvm.org/D115492
2021-12-14 20:18:04 +00:00
Michael Benfield bc5f2d12ca [clang] diagnose_as_builtin attribute for Fortify diagnosing like builtins.
Differential Revision: https://reviews.llvm.org/D112024
2021-12-14 19:42:23 +00:00
Henry Linjamäki 4e94cba5b4 [HIPSPV][2/4] Add HIPSPV tool chain
This patch adds a new tool chain, HIPSPVToolChain, for emitting HIP
device code as SPIR-V binary. The SPIR-V binary is emitted by using an
external tool, SPIRV-LLVM-Translator, temporarily. We intend to switch
the translator to the llc tool when the SPIR-V backend lands on LLVM
and proves to work well on HIP implementations which consume SPIR-V.

Before the SPIR-V emission the tool chain loads an optional external
pass plugin, either automatically from a HIP installation or from a
path pointed by --hipspv-pass-plugin, and runs passes that are meant
to expand/lower HIP features that do not have direct counterpart in
SPIR-V (e.g. dynamic shared memory).

Code emission for SPIR-V will be enabled and HIPSPVToolChain tests
will be added in the follow up patch part 3.

Other changes: New option ‘-nohipwrapperinc’ is added to exclude HIP
include wrappers. The reason for the addition is that they cause
compile errors when compiling HIP sources for the host side for HIPCL
and HIPLZ implementations. New option is added to avoid this issue.

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D110618
2021-12-14 10:22:38 -08:00
Michael Spencer 04192422c4 [Clang][ScanDeps] Use the virtual path for module maps
Make clang-scan-deps use the virtual path for module maps instead of the on disk
path. This is needed so that modulemap relative lookups are done correctly in
the actual module builds. The file dependencies still use the on disk path as
that's what matters for build invalidation.

Differential Revision: https://reviews.llvm.org/D114206
2021-12-14 11:21:42 -07:00
Fangrui Song 1042de9058 [Driver] Add CLANG_DEFAULT_PIE_ON_LINUX to emulate GCC --enable-default-pie
In 2015-05, GCC added the configure option `--enable-default-pie`. When enabled,

* in the absence of -fno-pic/-fpie/-fpic (and their upper-case variants), -fPIE is the default.
* in the absence of -no-pie/-pie/-shared/-static/-static-pie, -pie is the default.

This has been adopted by all(?) major distros.

I think default PIE is the majority in the Linux world, but
--disable-default-pie users is not that uncommon because GCC upstream hasn't
switched the default yet (https://gcc.gnu.org/PR103398).

This patch add CLANG_DEFAULT_PIE_ON_LINUX which allows distros to use default PIE.
The option is justified as its adoption can be very high among Linux distros
to make Clang default match GCC, and is likely a future-new-default, at which
point we will remove CLANG_DEFAULT_PIE_ON_LINUX.
The lit feature `default-pie-on-linux` can be handy to exclude default PIE sensitive tests.

Reviewed By: foutrelis, sylvestre.ledru, thesamesam

Differential Revision: https://reviews.llvm.org/D113372
2021-12-14 10:09:00 -08:00
mydeveloperday cea81e95b0 [clang-format] add support for cppm files
C++20 Modules current style is to assign a new file suffix .cppm.

https://github.com/llvm/llvm-project/issues/52658

Ensure git-clang-format can handle that as a default extension

Reviewed By: ChuanqiXu, HazardyKnusperkeks, curdeius

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

Fixes: #52658
2021-12-14 14:55:38 +00:00
mydeveloperday 6482383e50 [clang-format] FixNamespaceComments does not understand namespace aliases
https://github.com/llvm/llvm-project/issues/35876

Ensure a namespace alias doesn't get incorrectly identifier as a namespace

Reviewed By: HazardyKnusperkeks, curdeius, owenpan

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

Fixes: #35876
2021-12-14 14:53:04 +00:00
Nikita Popov b81450afb6 [CodeGen] Add std:: qualifier
Hopefully addresses the buildbot failures.
2021-12-14 12:17:55 +01:00
Nikita Popov b8d121eb1d [CodeGen] Require use of Address::invalid() for invalid address (NFC)
This no longer allows creating an invalid Address through the regular
constructor. There were only two places that did this (AggValueSlot
and EHCleanupScope) which did this by converting a potential nullptr
into an Address. I've fixed both of these by directly storing an
Address instead.

This is intended as a bit of preliminary cleanup for D103465.

Differential Revision: https://reviews.llvm.org/D115630
2021-12-14 12:06:05 +01:00
Jan Svoboda 47eec789ed [clang][deps] Remove hard-coded resource directory from tests
Dependency scanner test for resource directory deduction doesn't account for LLVM builds with custom `CLANG_RESOURCE_DIR`.

This patch ensures we don't hardcode the default behavior into the test and take into account the actual value. This is done by running `%clang -print-resource-dir` and using that as the expected value in test assertions.
New comment also clarifies this is different from running that command as part of the dependency scan.

Reviewed By: mgorny

Differential Revision: https://reviews.llvm.org/D115628
2021-12-14 10:59:47 +01:00
Ellis Hoag c809da7d9c Revert "[InstrProf] Attach debug info to counters"
This reverts commit 800bf8ed29.

The `Instrumentation/InstrProfiling/debug-info-correlate.ll` test was
failing because I forgot the `llc` commands are architecture specific.
I'll follow up with a fix.

Differential Revision: https://reviews.llvm.org/D115689
2021-12-13 18:15:17 -08:00
Ellis Hoag 800bf8ed29 [InstrProf] Attach debug info to counters
Add the llvm flag `-debug-info-correlate` to attach debug info to instrumentation counters so we can correlate raw profile data to their functions. Raw profiles are dumped as `.proflite` files. The next diff enables `llvm-profdata` to consume `.proflite` and debug info files to produce a normal `.profdata` profile.

Part of the "lightweight instrumentation" work: https://groups.google.com/g/llvm-dev/c/r03Z6JoN7d4

Reviewed By: kyulee

Differential Revision: https://reviews.llvm.org/D114565
2021-12-13 17:51:22 -08:00
Philip Reames e6ad9ef4e7 [instcombine] Canonicalize constant index type to i64 for extractelement/insertelement
The basic idea to this is that a) having a single canonical type makes CSE easier, and b) many of our transforms are inconsistent about which types we end up with based on visit order.

I'm restricting this to constants as for non-constants, we'd have to decide whether the simplicity was worth extra instructions. For constants, there are no extra instructions.

We chose the canonical type as i64 arbitrarily.  We might consider changing this to something else in the future if we have cause.

Differential Revision: https://reviews.llvm.org/D115387
2021-12-13 16:56:22 -08:00
Shilei Tian d762c3d905 [NFC][Clang][OpenMP] Use switch-case statement to process clauses of atomic directive
This patch makes the process of clauses of atomic directive more clear
and preparation for the support for `atomic compare capture`.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D115586
2021-12-13 19:18:28 -05:00
Ethan Stewart d1327f8a57 [clang][amdgpu] - Choose when to promote VarDecl to address space 4.
There are instances where clang codegen creates stores to
address space 4 in ctors, which causes a crash in llc.
This store was being optimized out at opt levels > 0.

For example:

pragma omp declare target
static  const double log_smallx = log2(smallx);
pragma omp end declare target

This patch ensures that any global const that does not
have constant initialization stays in address space 1.

Note - a second patch is in the works where all global
constants are placed in address space 1 during
codegen and then the opt pass InferAdressSpaces
will promote to address space 4 where necessary.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D115661
2021-12-13 16:31:24 -06:00
Michał Górny fd0b00b5c6 [clang] [unitttests] Fix linking Basic test to LLVMTestingSupport
Link BasicTests via explicit target_link_libraries() rather than
clang_target_link_libraries() in order to fix linking when building
clang against libclang-cpp.  The latter requires all listed libraries
to be part of libclang-cpp and omits them if libclang-cpp is used.
However, LLVMTestingSupport is not part of libclang-cpp, so omitting it
causes undefined symbols.  Link to the library explicitly to follow suit
with the 7 other unittest programs.

Differential Revision: https://reviews.llvm.org/D115580
2021-12-13 23:00:31 +01:00
Shilei Tian d6449d0d08 Revert "[NFC][Clang][OpenMP] Use switch-case statement to process clauses of atomic directive"
This reverts commit 5c23acbc02.
2021-12-13 16:31:04 -05:00
Shilei Tian 5c23acbc02 [NFC][Clang][OpenMP] Use switch-case statement to process clauses of atomic directive
This patch makes the process of clauses of atomic directive more clear
and preparation for the support for `atomic compare capture`.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D115586
2021-12-13 16:20:10 -05:00
John Ericson ddcc02dbcc Quote some more destination paths with variables
Just defensive CMake-ing. I pulled this from D115544 and D99484 which
are blocked on some lldb CI failures I don't yet understand. Hoping to land
something smaller in the meantime.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D115566
2021-12-13 17:29:08 +00:00
Adrian Prantl 915d1c0b74 Add missing textual header to module map 2021-12-13 09:21:21 -08:00
Adrian Prantl c03c58c97a Add missing textual header to module map 2021-12-13 09:19:22 -08:00
Yaxun (Sam) Liu 006fb62434 Fix build failure of HIPUtility.cpp on Windows 2021-12-13 11:53:06 -05:00
Yaxun (Sam) Liu 240be6541d Fix warning about unused variable in HIPAMD.cpp 2021-12-13 11:25:48 -05:00
Yaxun (Sam) Liu 78b0f3701d [HIPSPV][1/4] Refactor HIP tool chain
This patch refactors the HIP tool chain for new HIP tool chain, HIPSPV
tool chain, which is added in the follow up patch part 2.

Rename HIPToolChain to HIPAMDToolChain and Renames HIP.* files to HIPAMD.*.
Introduce HIPUtility.* file where common HIP utilities, shared among HIP
tool chain implementations, are placed in.
Move constructHIPFatbinCommand() and
constructGenerateObjFileFromHIPFatBinary() to HIPUtility. HIPSPV tool
chain is going to use them.
Tweak bundle target ID in constructHIPFatbinCommand(): extra dashes are
dropped if the Target ID is empty and 'hip' offload kind is made default
for non-AMD targets.

Patch by: Henry Linjamäki

Reviewed by: Yaxun Liu, Artem Belevich, Eric Christopher

Differential Revision: https://reviews.llvm.org/D110549
2021-12-13 10:50:25 -05:00
Chuanqi Xu 9db8162820 [NFC] Format .cppm files in tests 2021-12-13 23:32:25 +08:00
Nico Weber 45158b1804 Revert "[NFC] format .cppm files in test"
This reverts commit 7c51a12833.
Breaks SemaCXX/modules-ts.cppm in check-clang.
2021-12-13 07:13:17 -05:00
Nico Weber b6f317d94d [gn build] Make arm_neon_sve_bridge.h header auto-syncable 2021-12-13 07:04:45 -05:00
Chuanqi Xu 7c51a12833 [NFC] format .cppm files in test 2021-12-13 19:52:31 +08:00
Matt Devereau 41def32040 [AArch64][SVE][NEON] Add NEON-SVE-Bridge intrinsics
Adds svset_neonq, svget_neonq, svdup_neonq AArch64 intrinsics.

These are described in the ACLE specification:
https://github.com/ARM-software/acle/pull/72

https://reviews.llvm.org/D114713
2021-12-13 11:31:57 +00:00
Fangrui Song 5fadb39e9b [Driver][test] Make some tests work with CLANG_DEFAULT_PIE_ON_LINUX=on
Also delete some cross-linux.c tests which are covered by linux-cross.cpp
2021-12-12 16:28:33 -08:00
mydeveloperday 05bea533d1 [clang-format] [PR49298] Sort includes pass will sort inside raw strings
https://github.com/llvm/llvm-project/issues/48642

clang-format does not respect raw string literals when sorting includes

```
const char *RawStr = R"(
)";
```

Running clang-format over with SortIncludes enabled transforms this code to:

```
const char *RawStr = R"(
)";
```
The following code tries to minimize this impact during IncludeSorting, by treating R"( and )" as equivalent of // clang-format off/on

Reviewed By: HazardyKnusperkeks, curdeius

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

Fixes #48642
2021-12-12 17:00:43 +00:00