Commit Graph

428137 Commits

Author SHA1 Message Date
Stephen Long 186bea3750 [MSVC] Add initial support for MSVC pragma optimize
MSVC's pragma optimize turns optimizations on or off based on the list
passed. At the moment, we only support an empty optimization list.

i.e. `#pragma optimize("", on | off)`

From MSVC's docs:

| Parameter | Type of optimization                             |
|-----------|--------------------------------------------------|
| g         | Enable global optimizations. Deprecated          |
| s or t    | Specify short or fast sequences of machine code  |
| y         | Generate frame pointers on the program stack     |

https://docs.microsoft.com/en-us/cpp/preprocessor/optimize?view=msvc-170

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D125723
2022-06-24 08:03:42 -07:00
Tapasweni Pathak 946c45a4ed Implement soft reset of the diagnostics engine.
This patch implements soft reset and adds tests for soft reset success of the
diagnostics engine. This allows us to recover from errors in clang-repl without
resetting the pragma handlers' state.

Differential revision: https://reviews.llvm.org/D126183
2022-06-24 14:46:54 +00:00
Sam Estep 8c278a2781 [clang][dataflow] Allow MatchSwitch to return a value
Reland of D128467. This version replaces `return {};` with `return Result();`, since the former failed on GCC with `Result = void`.

Reviewed By: gribozavr2

Differential Revision: https://reviews.llvm.org/D128533
2022-06-24 14:38:00 +00:00
Nicolas Vasilache f6c79c6ae4 [mlir][Vector]Fix bug where vector::WarpExecuteOnLane0Op are created with 2 blocks in the region
Differential Revision: https://reviews.llvm.org/D128534
2022-06-24 07:33:58 -07:00
Dawid Jurczak b7e7f4e1b6 [InlineCost] Improve debugging experience by adding print about initial inlining cost
Differential Revision: https://reviews.llvm.org/D127597
2022-06-24 16:27:26 +02:00
serge-sans-paille 886715af96 [clang] Introduce -fstrict-flex-arrays=<n> for stricter handling of flexible arrays
Some code [0] consider that trailing arrays are flexible, whatever their size.
Support for these legacy code has been introduced in
f8f6324983 but it prevents evaluation of
__builtin_object_size and __builtin_dynamic_object_size in some legit cases.

Introduce -fstrict-flex-arrays=<n> to have stricter conformance when it is
desirable.

n = 0: current behavior, any trailing array member is a flexible array. The default.
n = 1: any trailing array member of undefined, 0 or 1 size is a flexible array member
n = 2: any trailing array member of undefined or 0 size is a flexible array member
n = 3: any trailing array member of undefined size is a flexible array member (strict c99 conformance)

Similar patch for gcc discuss here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836

[0] https://docs.freebsd.org/en/books/developers-handbook/sockets/#sockets-essential-functions
2022-06-24 16:13:29 +02:00
Nikita Popov 871197d0a3 [MemoryBuiltins] Accept any value in getInitialValueOfAllocation() (NFC)
Drop the requirement that getInitialValueOfAllocation() must be
passed an allocator function, shifting the responsibility for
checking that into the function (which it does anyway). The
motivation is to avoid some calls to isAllocationFn(), which has
somewhat ill-defined semantics (given the number of
allocator-related attributes we have floating around...)

(For this function, all we eventually need is an allockind of
zeroed or uninitialized.)

Differential Revision: https://reviews.llvm.org/D127274
2022-06-24 16:08:07 +02:00
Nikita Popov 999aa6bf7f [GlobalOpt] Add tests for PR55859 (NFC) 2022-06-24 16:06:37 +02:00
Joseph Huber 1dcbe03c32 [Binary] Further improve malformed input handling for the OffloadBinary
Summary:
This patch adds some new sanity checks to make sure that the sizes of
the offsets are within the bounds of the file or what is expected by the
binary. This also improves the error handling of the version structure
to be built into the binary itself so we can change it easier.
2022-06-24 09:57:44 -04:00
Kai Luo acc22aeb0f [AIX][libatomic] Fix link flags after 30dfe016d4 for libatomic on AIX
After 30dfe016d4, we no longer use string as link flags.

Patch by @tingwang.

Reviewed By: tingwang

Differential Revision: https://reviews.llvm.org/D128524
2022-06-24 13:56:32 +00:00
Sam Estep 7b326b946a Revert "[clang][dataflow] Allow MatchSwitch to return a value"
This reverts commit 4eecd194b0.
2022-06-24 13:52:11 +00:00
Sam Estep 4eecd194b0 [clang][dataflow] Allow MatchSwitch to return a value
This patch adds another `typename` parameter to `MatchSwitch` class: `Result` (defaults to `void`), corresponding to the return type of the function. This necessitates a couple minor changes to the `MatchSwitchBuilder` class, and is tested via a new `ReturnNonVoid` test in `clang/unittests/Analysis/FlowSensitive/MatchSwitchTest.cpp`.

Reviewed By: gribozavr2, sgatev, xazax.hun

Differential Revision: https://reviews.llvm.org/D128467
2022-06-24 13:32:47 +00:00
Haojian Wu 9081d3d809 [clang-tidy] Make the cert/uppercase-literal-suffix-integer fully hermetic.
after the test-reorg commit (89a1d03e2b), the
cert/uppercase test starts to fail in our internal environment -- it accesses
a header file from "../readability", which is not friendly to a hermetic test environment.

This change makes the test fully hermetic, and does some cleanup on the
uppercase header (I think it is better to move it the share
Inputs/Header directory, and rename it)

Differential Revision: https://reviews.llvm.org/D128511
2022-06-24 14:18:02 +02:00
Matthias Springer 3798678bd1 [mlir][sparse][bufferize] Implement BufferizableOpInterface
Only the analysis part of the interface is implemented. The bufferization itself is performed by the SparseTensorConversion pass.

Differential Revision: https://reviews.llvm.org/D128138
2022-06-24 13:47:01 +02:00
LLVM GN Syncbot 05558c0692 [gn build] Port 7a3918b540 2022-06-24 11:33:41 +00:00
Aaron Ballman 7a3918b540 Revert "[clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface"
This reverts commit 6546fdbe36.

This broke some build bots due to a layering issue:
https://lab.llvm.org/buildbot/#/builders/57/builds/19244
2022-06-24 07:33:07 -04:00
LLVM GN Syncbot f09dad0c85 [gn build] Port 6546fdbe36 2022-06-24 11:18:35 +00:00
Vaibhav Yenamandra 6546fdbe36 [clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface
Create an interface for writing SARIF documents from within clang:

The primary intent of this change is to introduce the interface
clang::SarifDocumentWriter, which allows incrementally adding
diagnostic data to a JSON backed document. The proposed interface is
not yet connected to the compiler internals, which will be covered in
future work. As such this change will not change the input/output
interface of clang.

This change also introduces the clang::FullSourceRange type that is
modeled after clang::SourceRange + clang::FullSourceLoc, this is useful
for packaging a pair of clang::SourceLocation objects with their
corresponding SourceManagers.

Previous discussions:

RFC for this change: https://lists.llvm.org/pipermail/cfe-dev/2021-March/067907.html
https://lists.llvm.org/pipermail/cfe-dev/2021-July/068480.html
SARIF Standard (2.1.0):

https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html

Differential Revision: https://reviews.llvm.org/D109701
2022-06-24 07:16:54 -04:00
Nikita Popov e523baa664 [InlineFunction] Slightly clarify noalias scope calculation (NFC)
Rename CanDeriveViaCapture -> RequiresNoCaptureBefore, drop
unnecessary const cast, reformat some code avoid an ugly
super-indented comment.
2022-06-24 12:31:46 +02:00
Nabeel Omer 0d41794335 [SLP] Add cost model for `llvm.powi.*` intrinsics (REAPPLIED)
Patch was reverted in 4c5f10a due to buildbot failures, now being
reapplied with updated AArch64 and RISCV tests.

This patch adds handling for the llvm.powi.* intrinsics in
BasicTTIImplBase::getIntrinsicInstrCost() and improves vectorization.
Closes #53887.

Differential Revision: https://reviews.llvm.org/D128172
2022-06-24 10:23:19 +00:00
Muhammad Omair Javaid 91d61c1431 [LLDB] Mark TestExprsChar Xfail for Windows/AArch64
test_unsigned_char test in TestExprsChar.py fails on AArch64/Windows
platform. There is known bug already present for the failure for various
arch/os combinations. This patch marks the test as xfail for
windows/AArch64.
2022-06-24 13:59:22 +04:00
Nikita Popov 54eff7da3c [AA] Export isEscapeSource() API (NFC)
Export API that was previously private to BasicAliasAnalysis and
will be used in D127202.
2022-06-24 11:59:15 +02:00
Frederic Cambus a129a37161 [clang] Update Clang version from 14 to 15 in scan-build.1.
Similar to D110763.
2022-06-24 11:09:34 +02:00
David Green 03c65c0d32 [AArch64] Convert vector add(ext, ext) into ext(add(ext, ext))
Given a vector add or sub from extends that needs more that one 'step'
(i.e i8 to i32 or i16 to i64), we can transform the sequence to
sext(add(ext, ext)), to allow the add(ext, ext) to become a single uaddl
and a larger extend, producing less instructions in total.
https://alive2.llvm.org/ce/z/S2T4k-

Differential Revision: https://reviews.llvm.org/D128426
2022-06-24 10:04:28 +01:00
Nikita Popov bcadfc2595 [BasicAA] Handle passthru calls in isEscapeSource()
isEscapeSource() currently considers all call return values as
escape sources. However, CaptureTracking can look through certain
calls, so we shouldn't consider these as escape sources either.

The corresponding CaptureTracking code is:
7c9a3825b8/llvm/lib/Analysis/CaptureTracking.cpp (L332-L333)

Differential Revision: https://reviews.llvm.org/D128444
2022-06-24 11:00:57 +02:00
Kiran Chandramohan 703b1054e9 [Flang] enable fir.is_present and fir.absent with function types
Fortran dummy procedures and procedure pointer can be OPTIONAL, and
there is no technical reason to prevent fir.is_present and
fir.absent from accepting function types, so allow it and add test.

Note: This is part of upstreaming from the fir-dev branch of
https://github.com/flang-compiler/f18-llvm-project. This patch is
basically upstreaming the following PR.
https://github.com/flang-compiler/f18-llvm-project/pull/1568

Reviewed By: clementval

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
2022-06-24 08:46:14 +00:00
David Green ae7fbcd199 [AArch64] Add addition extend of add/sub neon tests. NFC 2022-06-24 09:41:10 +01:00
Vassil Vassilev ac6c5c5e8f Reland "[clang-repl] Recover the lookup tables of the primary context."
The asan issue was fixed in llvm/llvm-project@7bc00ce5cd

This reverts commit 575e297fcb.

Differential revision: https://reviews.llvm.org/D123674
2022-06-24 08:35:41 +00:00
Petr Hosek 8bee6e52f8 Revert "[CMake][compiler-rt] Clean up the use of libcxx and libcxxabi"
This reverts commit c0d4f2282d which
broke clang-x86_64-debian-fast:

  https://lab.llvm.org/buildbot/#/builders/109/builds/41268
2022-06-24 08:24:45 +00:00
Siva Chandra Reddy f4580c6d5a [libc][NFC] Remove the templatization from the linux implementation of thread.
This enables setting up a single "self" thread object to be returned by
API like thrd_self and pthread_self.
2022-06-24 08:22:53 +00:00
Cullen Rhodes 2b3de29717 [AArch64] NFC: Fix PRFS -> PRFW inst def name 2022-06-24 08:17:50 +00:00
Florian Hahn b18141a8f2
[VPlan] Set VFs included in plan before last set of VPTransforms (NFC).
This allows VPlanTransforms to query the VFs included in the plan in the
future.
2022-06-24 10:16:56 +02:00
Petr Hosek c0d4f2282d [CMake][compiler-rt] Clean up the use of libcxx and libcxxabi
We no longer support the use of LLVM_ENABLE_PROJECTS for libcxx and
libcxxabi. We don't use paths to libcxx and libcxxabi in compiler-rt.

Differential Revision: https://reviews.llvm.org/D126905
2022-06-24 08:11:37 +00:00
Matt Devereau cc3ef26f60 [AArch64][SVE] Add sve.dupq.lane(insert(constant vector, 0), 0) ld1rq tests 2022-06-24 07:40:31 +00:00
Fangrui Song 0ecea5b2d3 [gdb-scripts] Fix PointerIntPairPrinter.to_string after D127969 2022-06-24 00:36:26 -07:00
Peixin-Qiao 27afb362b1 [flang][OpenMP] Initial support the lowering of copyin clause
This supports the lowering of copyin clause initially. The pointer,
allocatable, common block, polymorphic varaibles will be supported
later.

This also includes the following changes:

1. Resolve the COPYIN clause and make the entity as host associated.

2. Fix collectSymbolSet by adding one option to control collecting the
   symbol itself or ultimate symbol of it so that it can be used
   explicitly differentiate the host and associated variables in
   host-association.

3. Add one helper function `lookupOneLevelUpSymbol` to differentiate the
   usage of host and associated variables explicitly. The previous
   lowering of firstprivate depends on the order of
   `createHostAssociateVarClone` and `lookupSymbol` of host symbol. With
   this fix, this dependence is removed.

4. Reuse `copyHostAssociateVar` for copying operation of COPYIN clause.

Reviewed By: kiranchandramohan, NimishMishra

Differential Revision: https://reviews.llvm.org/D127468
2022-06-24 15:33:09 +08:00
Florian Hahn 92f87787b3
Recommit "[ConstraintElimination] Transfer info from ULT to signed system."
This reverts commit 94ed2caf70.

The issue with no-determinism with the test has been fixed in
d9526e8a52.
2022-06-24 09:27:14 +02:00
Valentin Clement aeb2cd3176
[flang] Keep PURE in IEEE functions
PURE keyword should be kept in `__fortran_ieee_exceptions.f90`
and `ieee_arithmetic.f90` and not removed as done in
https://reviews.llvm.org/D128431

Reviewed By: vdonaldson

Differential Revision: https://reviews.llvm.org/D128498
2022-06-24 09:10:18 +02:00
Valentin Clement 753b766dea
[flang] Fix forall issue with substring operation
When there is a substring operation on a scalar assignment in a FORALL
context, we have to lower the entire substring and not the entire
CHARACTER variable.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld, klausler

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-06-24 09:07:49 +02:00
Fangrui Song 124d9fc958 [llvm-readobj] Simplify startswith+drop_front pattern with consume_front. NFC 2022-06-24 00:04:55 -07:00
Craig Topper c579ab53bd [RISCV] Move vfma_vl+fneg_vl matching to DAG combine.
This patch adds 3 new _VL RISCVISD opcodes to represent VFMA_VL with
different portions negated. It also adds a DAG combine to peek
through FNEG_VL to create these new opcodes.

This is modeled after similar code from X86.

This makes the isel patterns more regular and reduces the size of
the isel table by ~37K.

The test changes look like regressions, but they point to a bug that
was already there. We aren't able to commute a masked FMA instruction
to improve register allocation because we always use a mask undisturbed
policy. Prior to this patch we matched two multiply operands in a
different order and hid this issue for these test cases, but a different
test still could have encountered it.

Reviewed By: frasercrmck

Differential Revision: https://reviews.llvm.org/D128310
2022-06-24 00:00:37 -07:00
Petr Hosek 30dfe016d4 [CMake][compiler-rt] Use COMPILE_OPTIONS and LINK_OPTIONS
This avoids the need for string-ification and lets CMake deduplicate
potentially duplicate flags.

Differential Revision: https://reviews.llvm.org/D122750
2022-06-24 06:55:10 +00:00
Fangrui Song 44ee3efb93 [CodeGen] Simplify isVirtualRegister. NFC 2022-06-23 23:26:02 -07:00
Hui Xie 16719cd011 [libc++] P2321R2 section [tuple.tuple]. Adding C++23 constructors, assignment operators and swaps to `tuple`
1. for constructors that takes cvref variation of tuple<UTypes...>, there
used to be two SFINAE helper _EnableCopyFromOtherTuple,
_EnableMoveFromOtherTuple. And the implementations of these two helpers
seem to slightly differ from the spec. But now, we need 4 variations.
Instead of adding another two, this change refactored it to a single one
_EnableCtrFromUTypesTuple, which directly maps to the spec without
changing the C++11 behaviour. However, we need the helper __copy_cvref_t
to get the type of std::get<i>(cvref tuple<Utypes...>) for different
cvref, so I made __copy_cvref_t to be available in C++11.

2. for constructors that takes variations of std::pair, there used to be
four helpers _EnableExplicitCopyFromPair, _EnableImplicitCopyFromPair,
_EnableImplicitMoveFromPair, _EnableExplicitMoveFromPair. Instead of
adding another four, this change refactored into two helper
_EnableCtrFromPair and _BothImplicitlyConvertible. This also removes the
need to use _nat

3. for const member assignment operator, since the requirement is very
simple, I haven't refactored the old code but instead directly adding
the new c++23 code.

4. for const swap, I pretty much copy pasted the non-const version to make
these overloads look consistent

5. while doing these change, I found two of the old constructors wasn't
marked constexpr for C++20 but they should. fixed them and added unit
tests

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D116621
2022-06-24 07:12:53 +01:00
Venkata Ramanaiah Nalamothu 5d2cc4d838 [AMDGPU][NFC] Correct typo in DWARF Extensions For Heterogeneous Debugging
The `DW_AT_LLVM_address_space` attribute is mentioned as `DW_AT_address_space` in
one of the notes.

Reviewed By: scott.linder

Differential Revision: https://reviews.llvm.org/D128210
2022-06-24 11:05:08 +05:30
Amir Ayupov d2c8769936 [BOLT][NFC] Use range-based STL wrappers
Replace `std::` algorithms taking begin/end iterators with `llvm::` counterparts
accepting ranges.

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D128154
2022-06-23 22:16:27 -07:00
Serguei Katkov 9ffe1b0a79 [GuardWidening] Update all tests with update_test_checks.py 2022-06-24 12:04:50 +07:00
Carl Ritson 874fbe2cbb [MachineSink] Clear kill flags on operands outside loop
If an instruction is sunk into a loop then any kill flags on
operands declared outside the loop must be cleared as these
will be live for all loop iterations.

Fixes #46827

Reviewed By: MatzeB

Differential Revision: https://reviews.llvm.org/D126754
2022-06-24 14:02:48 +09:00
Douglas Yung f401dd6f43 Revert "Add support for decoding base64."
This reverts commit 8b987ca5e3.

This change breaks several Windows bots
 - https://lab.llvm.org/buildbot/#/builders/123/builds/11371
 - https://lab.llvm.org/buildbot/#/builders/117/builds/7685
 - https://lab.llvm.org/buildbot/#/builders/42/builds/6077
 - https://lab.llvm.org/buildbot/#/builders/216/builds/6340
2022-06-23 21:47:20 -07:00
Kai Luo 106657df4c [PowerPC][AIX] Fix assertion message on AIX. NFC.
Fixes build https://lab.llvm.org/buildbot/#/builders/214/builds/1980.
2022-06-24 12:03:57 +08:00