Commit Graph

449843 Commits

Author SHA1 Message Date
Michael Liao
cd61d2abe0 [clang][CodeGen][NFC] Fix llvm-else-after-return 2023-01-25 13:53:35 -05:00
Rob Suderman
b67b024d58 [mlir][tosa] Update tosa.avg_pool2d for bit-exact TOSA behavior
The normalization component of average pool has a very specific
rounding behavior for compouting the division for floating
point values. Updated so that the bit-exact version is implemented.

Also includes a fix for computing the stride part of the average pool
operation.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D141339
2023-01-25 18:51:12 +00:00
Shafik Yaghmour
6ec446ddce [Clang] Add sanity check in Sema::getDestructorName to prevent nullptr dereference
Currently in Sema::getDestructorName we call SS.getScopeRep()->getPrefix() but
SS.getScopeRep() can return nullptr because LookupInNestedNameSpec(...) called a
little before can invalidate SS.

This fixes: https://github.com/llvm/llvm-project/issues/59446

Differential Revision: https://reviews.llvm.org/D140598
2023-01-25 10:49:04 -08:00
Matt Arsenault
5a4a8eb2b6 AMDGPU: Convert some tests to opaque pointers 2023-01-25 14:33:20 -04:00
Matt Arsenault
a686ea7ba8 LangRef: Fix extra spaces in udec_wrap description 2023-01-25 14:33:04 -04:00
Arthur Eubanks
1270879376 [llvm-c] Remove LLVMContextSetOpaquePointers
Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D139441
2023-01-25 10:28:58 -08:00
Florian Hahn
531756b954 Revert "Recommit "[SCCP] Use range info to prove AddInst has NUW flag.""
This reverts commit 366e1faa2f.

It looks like this exposes another set of crashes on the buildbots.
Revert while I investigate.
2023-01-25 18:22:24 +00:00
Florian Hahn
366e1faa2f Recommit "[SCCP] Use range info to prove AddInst has NUW flag."
The recommitted version fixes a crash when one of the operands is a
constant other than a ConstantInt. Test for that case have been added
in 5b16cd97b8.

It splits off the new logic into a separate function because setting the
flags is quite different compared to the other cases handled in replaceSignedInst
which all require replacing an existing instruction. Instructions are
now refined before any replacements are done, which has the advantage
that we should have lattice values for all operands (fixing the crashes
and simplifies the logic) and also allows optimizing more cases where one
of the operands also gets replaced (see improvements in
@sge_with_sext_to_zext_conversion).

It also guards makeGuaranteedNoWrapRegion by `if (!Inst.hasNoUnsignedWrap())`
as discussed in the review.

Fixes #60280.
Fixes #60278.

Original message:
    This patch updates SCCP to use the value ranges of AddInst operands to
    try to prove the AddInst does not overflow in the unsigned sense and
    adds the NUW flag. The reasoning is done with
    makeGuaranteedNoWrapRegion (thanks @nikic for point it out!).

    Follow-ups will include adding NSW and extension to more
    OverflowingBinaryOperators.

    Reviewed By: nikic

    Differential Revision: https://reviews.llvm.org/D142387
2023-01-25 18:07:25 +00:00
Austin Kerbow
913837eaa3 [ScheduleDAG] Fix removing edges with weak deps
In SUnit::removePred edges are removed from the Preds and Succs lists before
updating the bookkeeping. This could result in incorrect values for
NumPreds/SuccsLeft and cause WeakPreds/SuccsLeft to underflow, since the
incorrect SDep will be used to update these values.

Reviewed By: rampitec

Differential Revision: https://reviews.llvm.org/D142325
2023-01-25 10:05:50 -08:00
She Dongrui
a253a0bbe5 Avoid removing useful loop metadata when stripping debug info
The stripDebugLocFromLoopID() may mistakenly remove useful metadata nodes
when they are operands of a child node, which also has DILocation operands.

It can be reproduced by the output of clang for code similar to the following:

for(int i = 0; i < n; i++)
  x[i] = 10;
-strip-debug removes the child node of llvm.loop.vectorize.followup_all,
which contains llvm.loop.isvectorized and llvm.loop.unroll.count.

This patch fixes by checking all children nodes and only remove a metadata
node if all its children are DILocation.

Differential Revision: https://reviews.llvm.org/D141909
2023-01-25 10:05:27 -08:00
Advenam Tacet
4905550268 [ASan][libcxx] Annotating std::vector with all allocators
This revision is a part of a series of patches extending
AddressSanitizer C++ container overflow detection
capabilities by adding annotations, similar to those existing
in std::vector, to std::string and std::deque collections.
These changes allow ASan to detect cases when the instrumented
program accesses memory which is internally allocated by
the collection but is still not in-use (accesses before or
after the stored elements for std::deque, or between the size and
capacity bounds for std::string).

The motivation for the research and those changes was a bug,
found by Trail of Bits, in a real code where an out-of-bounds read
could happen as two strings were compared via a std::equals function
that took iter1_begin, iter1_end, iter2_begin iterators
(with a custom comparison function).
When object iter1 was longer than iter2, read out-of-bounds on iter2
could happen. Container sanitization would detect it.

In revision D132522, support for non-aligned memory buffers (sharing
first/last granule with other objects) was added, therefore the
check for standard allocator is not necessary anymore.
This patch removes the check in std::vector annotation member
function (__annotate_contiguous_container) to support
different allocators.

If you have any questions, please email:
 - advenam.tacet@trailofbits.com
 - disconnect3d@trailofbits.com

Reviewed By: #libc, #sanitizers, philnik, vitalybuka

Spies: EricWF, philnik, #sanitizers, libcxx-commits

Differential Revision: https://reviews.llvm.org/D136765
2023-01-25 19:04:15 +01:00
Alex Brachet
741021de32 [libc] Implement strcasestr
Differential Revision: https://reviews.llvm.org/D142518
2023-01-25 17:58:13 +00:00
Campbell Suter
7092dae032 [RS4GC] Remove the hardcoded GC strategy names (v2)
Previously, RewriteStatepointsForGC had a hardcoded list of GC
strategies for which it would run, and using it with a custom strategy
required patching LLVM.

The logic for selecting the variables that are considered managed was
also hardcoded to use pointers in address space 1, rather than
delegating to GCStrategy::isGCManagedPointer.

This patch fixes both of these flaws: this pass now applies to all
functions whose GCStrategy returns true for useStatepoints, and checking
if a pointer is managed or not is also now done by the strategy.

One potentially questionable design decision in this change: the pass will
be enabled for all GC strategies that use statepoints. It seems unlikely
this would be a problem - consumers that don't use this pass probably
aren't adding it to the pass manager anyway - but if you had two different
GC strategies and only one wants this pass enabled then that'd need a new
flag in GCStrategy, which I can add if anyone thinks it's necessary.

This is an updated version of D140458, rebased to account for LLVM's
changes since D140504 (required by this patch) landed.

Reviewed By: dantrushin

Differential Revision: https://reviews.llvm.org/D141110
2023-01-25 20:47:16 +03:00
Denis Antrushin
7564a9ad30 Fix assertion in GCStrategy.
It meant to check that `UseRS4GC` requires `UseStatepoints`.
Instead it always required `UseStatepoints` when `useRS4GC()`
was called.
2023-01-25 20:46:51 +03:00
Sergei Barannikov
1799a714a7 [llvm-ml] Disallow '{' and '}' at the start of a statement
'{', '}' and (conditionally) '*' were allowed at the start of a
statement. This behavior was copied from AsmParser, where they were
added to support Hexagon bundles (braces) and BFP memory instructions
(the star).
MASM dialect is x86-specific and does not allow these symbols to be
used at the beginning of an instruction.

Worth noting that '{' is a valid first character in AT&T syntax
(e.g. "{vex} vpmadd52huq ..."); MASM variant is to omit the braces.

Reviewed By: epastor

Differential Revision: https://reviews.llvm.org/D142321
2023-01-25 20:44:00 +03:00
Valentin Clement
b1a34b242f [flang] Fix element indexing in derived type default initialization
Derived type default initialization was not taking the step into
consideration.

```
module dt_init
  type p1
    integer :: a
  end type
  type, extends(p1) :: p2
    integer :: b = 10
  end type
contains
  subroutine init_dt(z)
    class(p1), intent(out) :: z(:)
    select type(z)
    type is (p2)
      print*,z
    end select
  end subroutine
end module
program test
  use dt_init
  type(p2) :: t(6) = [ p2(1,2),p2(3,4),p2(5,6),p2(7,8),p2(9,10),p2(11,12) ]
  print*,t
  call init_dt(t(::2))
  print*,t
end program
```

Without the fix, the three first elements are initialized

```
 1 2 3 4 5 6 7 8 9 10 11 12
 1 10 5 10 9 10
 1 10 3 10 5 10 7 8 9 10 11 12
```

Where it should be element number 1,3,5

```
 1 2 3 4 5 6 7 8 9 10 11 12
 1 10 5 10 9 10
 1 10 3 4 5 10 7 8 9 10 11 12
```

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D142527
2023-01-25 18:39:03 +01:00
Jay Foad
fbb003378b [BOLT] Use MCInstrDesc::operands() instead of OpInfo
operands() is the preferred accessor since D142213. OpInfo will be
removed in D142219.

Differential Revision: https://reviews.llvm.org/D142530
2023-01-25 17:26:48 +00:00
Michael Kruse
d327667d8a [Polly] Remove failing Polly-ACC test.
The test has been failing since after last update of ISL (a749e09e).
2023-01-25 11:11:45 -06:00
Kirill Stoimenov
3348699221 [LSAN] Attempt to fix the ppc64 build by excluding unsupported test
Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D142561
2023-01-25 17:06:24 +00:00
Mateja Marjanovic
f84d3dd0fd [AMDGPU] Make flat_offset a 32-bit operand instead of 16-bits
Differential Revision: https://reviews.llvm.org/D142549
2023-01-25 17:52:26 +01:00
Alex Brachet
c623a6865f [libc] Fix warning in ExecuteFunctionUnix.cpp
WIFEXITED and friends expect an `int *` but these methods
were marked `const` so they instead got a `const int *`.
This macros aren't actually modifying their argument, but
we were never using these functions on an immutable
`ProcessStatus` type anyway.
2023-01-25 16:51:56 +00:00
Michael Kruse
a749e09e18 [Polly] Update ISL to isl-0.25-193-g8621c60c.
The bugfix https://reviews.llvm.org/D142308 might already have been
fixed upstream.
2023-01-25 10:47:37 -06:00
Alex Brachet
eebb2e31b4 [libc] Templatize strstr
Differential Revision: https://reviews.llvm.org/D142517
2023-01-25 16:42:34 +00:00
Florian Hahn
b6b3d20d06 [VPlan] Use VPDominatorTree in VPlanVerifier .
Use VPDominatorTree to generalize def-use verification.

Depends on D140513.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D140514
2023-01-25 16:32:40 +00:00
Timm Bäder
93aa412306 [clang][Interp][NFC] Refector OffsetHelper
There was a FIXME comment for this. Stop getting the values in
OffsetHelper and let the caller do that instead, so we can control
whether the value(s) are removed from the stack at all.

Also use ArithOp instead of the unclear boolean for Add.
2023-01-25 17:22:59 +01:00
Kazu Hirata
c4c5e79dd4 Fix warnings
This patch fixes:

  clang-tools-extra/clangd/Hover.cpp:1036:28: warning: unused variable
  ‘MTE’ [-Wunused-variable]

  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:22295:19: error:
  unused variable 'AN' [-Werror,-Wunused-variable]
2023-01-25 08:21:29 -08:00
Timm Bäder
c68af565ff [clang][Interp][NFC] Cast in InterpFrame::localBlock
We know we save a Block* here, so do the cast there instead of
everywhere we're calling this function.
2023-01-25 17:09:34 +01:00
Timm Bäder
eee8075f57 [clang][Interp][NFCI] Remove an unnecessary DupPtr op
When initializing a primitive array, we don't need to dup the base
pointer for every element.
2023-01-25 17:09:33 +01:00
Xiang Li
4ef085c572 [mlir] fix crash when call a function decl
Check region before use it.
Fixes #60215  https://github.com/llvm/llvm-project/issues/60215

Differential Revision: https://reviews.llvm.org/D142544
2023-01-25 11:06:13 -05:00
Timm Bäder
cb703434cb [clang][Interp] Add back Run() call
We need to run the functions we compiled immediately after to check if
they can ever be a constant expression.

Differential Revision: https://reviews.llvm.org/D140724
2023-01-25 17:01:55 +01:00
Timm Bäder
8b70d97c39 [clang][Interp][NFC] Use InitThisField in initializers
This creates fewer instructions, makes the bytecode easier to read and
InitThisField also cares about checkingPotentialConstantExpression()
cases.
2023-01-25 16:59:19 +01:00
Timm Bäder
0a6c8c1b25 [clang][Interp][NFC] Add a helper function for local variables
... in EvalEmitter.
2023-01-25 16:57:59 +01:00
Timm Bäder
5de6b94f85 [clang][Interp][NFC] Replace remaining dyn_cast_or_null uses 2023-01-25 16:39:26 +01:00
David Green
bbe352d8f0 [AArch64] Remove HasCrypto tablegen predicate. NFC
This is unused, with all relevant patterns and instructions using the
HasAES / HasSHA2 / HasSHA3 / HasSM4 predicates.
2023-01-25 15:36:01 +00:00
Joseph Huber
d5fe78d939 [Clang] Make the linker wrapper test require Linux
Summary:
We only support this offloading on Linux currently, and this handling of
static libraries is mostly based on Linux systems. So we should only
test those systems for now until we expland to other operating systems
in the future.
2023-01-25 09:31:59 -06:00
Timm Bäder
af3a171dcf [clang][Interp] Compound assign operators for FP values
Differential Revision: https://reviews.llvm.org/D140377
2023-01-25 16:25:04 +01:00
Timm Bäder
c61fe188a7 [clang][Interp][NFC] Get rid of InterpSize 2023-01-25 16:03:33 +01:00
Timm Bäder
df33d17b38 [clang][Interp][NFC] Remove an unused function 2023-01-25 16:03:33 +01:00
Siu Chi Chan
56184bb3ad [AMDGCN] Fix device lib test to work with lib64
This change fixes an issue introduced by
https://reviews.llvm.org/D140315.  A new unit test was added to validate
the search for the device libraries being placed in Clang's resource
directory; however, the test didn't take into account that certain
platforms use lib64 for 64-bit library directory.

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

Change-Id: I9c31a4f08fbc383350d82d6aba01987a3ef63e51
2023-01-25 09:55:35 -05:00
Christian Ulmann
56880fd257 [mlir][LLVM] Add result attribute import support
This commit introduces support for importing result attributes.

Depends on D142372

Reviewed By: gysit

Differential Revision: https://reviews.llvm.org/D142476
2023-01-25 15:53:19 +01:00
LLVM GN Syncbot
77bdad06de [gn build] Port cb7f582211 2023-01-25 14:40:30 +00:00
MarcoFalke
007b353695 doc: Fix typo in clang-tidy no-automatic-move doc
The latter version is called NotCool in the source code and on godbolt.
2023-01-25 15:39:41 +01:00
Mehdi Amini
a988a1f81d Replace use of sprintf with snprint in SparseTensorRuntime.cpp (NFC)
This fixes a warning on MacOS:

warning: 'sprintf' is deprecated: This function is provided for compatibility
reasons only.  Due to security concerns inherent in the design of sprintf(3),
it is highly recommended that you use snprintf(3) instead.
2023-01-25 06:32:44 -08:00
Mehdi Amini
ddc496d184 Exclude running MLIR tests for Toy example Ch6 and Ch7 when JIT is unavailable 2023-01-25 06:32:44 -08:00
Simon Pilgrim
7c1621296a [ADT] FloatingPointMode.h - add missing closing namespace comment. NFC.
Fixes clang-tidy warning
2023-01-25 14:28:17 +00:00
Timm Bäder
611a748b22 [clang][Interp] Add empty messages to static_asserts
To satisfy builders:
https://lab.llvm.org/buildbot/#/builders/216/builds/16264
2023-01-25 15:20:46 +01:00
Xiang Li
2ecf2c0df7 [mlir][doc] Fix syntax for affine.dam_wait
Change dma_Start to dma_wait for affine.dma_wait.
Also change dma_Start to dma_start for affine.dma_start.

Differential Revision: https://reviews.llvm.org/D141887
2023-01-25 09:14:38 -05:00
Timm Bäder
cb7f582211 Re-apply "[clang][Interp] Support floating-point values"
Don't move the Repr struct into Integral this time.

Differential Revision: https://reviews.llvm.org/D134859
2023-01-25 15:13:09 +01:00
Christian Ulmann
be4b87353e [mlir][LLVM] Add param attr verifiers
This commit introduces unified parameter attribute verifiers to the LLVM
dialect and removes according checks in the export. As LLVM does not
verify the validity of certain attributes on return values, this commit
unifies the handling of argument and result attributes wherever possible.

Depends on D142212

Reviewed By: gysit

Differential Revision: https://reviews.llvm.org/D142372
2023-01-25 15:04:45 +01:00
Erich Keane
228462f755 Fix one of the regressions found in revert of concept sugaring
It seems that the sugaring patches had some pretty significant
interdependencies, and at least one issue exists that requires part of
the concept-sugaring patch.  I don't believe this to have anything to do
with the increased compile-times that were seen, so hopefully this will
fix our problems without further regressions.

See https://reviews.llvm.org/rG12cb1cb3720de8d164196010123ce1a8901d8122
for discussion.

Differential Revision: https://reviews.llvm.org/D142500
2023-01-25 06:01:44 -08:00