Commit Graph

435274 Commits

Author SHA1 Message Date
yronglin 6ed21fc515 Avoid __builtin_assume_aligned crash when the 1st arg is array type
Avoid __builtin_assume_aligned crash when the 1st arg is array type (or
string literal).

Fixes Issue #57169

Differential Revision: https://reviews.llvm.org/D133202
2022-09-07 12:46:20 -04:00
Mark de Wever e5d2d3eafb [libc++][chrono] Implements formatter day.
This implements the enabled specializaton
template<class charT> struct formatter<chrono::day, charT>;

and
template<class charT, class traits>
    basic_ostream<charT, traits>&
      operator<<(basic_ostream<charT, traits>& os, const day& d);

Implements:
- LWG 3241 chrono-spec grammar ambiguity in §[time.format]

Partially implements:
- P1361 Integration of chrono with text formatting

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D128577
2022-09-07 18:44:04 +02:00
Mark de Wever b490c8a662 [libc++][format] Updates feature-test macros.
During the discussion on the SG-10 mailinglist regarding the format
feature-test macros voted in during the last plenary it turns out libc++
can't mark the format feature-test macro as implemented.

According to
  https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#__cpp_lib_format
the not yet implemented paper
  P1361R2 Integration of chrono with text formatting
affects the feature test macro.

Note that P1361R2 doesn't mention the feature-test macro nor is there an
LWG-issue to address the issue. The reporter of the issue didn't recall
where this requirement exactly has been decided.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D133271
2022-09-07 18:39:39 +02:00
Philip Reames a4a29438f4 [RISCV][MC] Add minimal support for Ztso extension
This is a minimalist implementation which simply adds the extension (in the experimental namespace since its not ratified), and wires up the setting of the required ELF header flag. Future changes will include codegen changes to exploit the stronger memory model.

This is intended to implement v0.1 of the proposed specification which can be found in Chapter 25 of https://github.com/riscv/riscv-isa-manual/releases/download/draft-20220723-10eea63/riscv-spec.pdf.

Differential Revision: https://reviews.llvm.org/D133239
2022-09-07 09:30:57 -07:00
Sanjay Patel 85b289377b [SCCP] convert signed div/rem to unsigned for non-negative operands, 2nd try
The original commit ( fe1f3cfc26 ) was reverted because it could
crash / assert when trying to fold a value that was replaced
by a constant. In that case, there might not be an entry for the
constant in the solver yet.

This version adds a check for that possibility along with tests to
exercise that pattern (they used to crash).

Original commit message:
This extends the transform added with D81756 to handle div/rem opcodes.
For example:
https://alive2.llvm.org/ce/z/cX6za6

This replicates part of what CVP already does, but the motivating example
from issue #57472 demonstrates a phase ordering problem - we convert
branches to select before CVP runs and miss the transform.

Differential Revision: https://reviews.llvm.org/D133198
2022-09-07 11:56:29 -04:00
Joe Loser e5a8f50ab1 [mlir] Use std::size instead of llvm::array_lengthof
LLVM contains a helpful function for getting the size of a C-style
array: `llvm::array_lengthof`. This is useful prior to C++17, but not as
helpful for C++17 or later: `std::size` already has support for C-style
arrays.

Change call sites to use `std::size` instead.

Differential Revision: https://reviews.llvm.org/D133387
2022-09-07 09:54:51 -06:00
Qingyuan Zheng 44bbf20965 [clangd] Add Macro Expansion to Hover
This patch adds macro expansion preview to hover info. Basically, the refactor infrastructure for expanding macro is used for this purpose. The following steps are added to getHoverContents for macros:
1. calling AST.getTokens().expansionStartingAt(...) to get expanded tokens
2. calling reformat(...) to format expanded tokens

Some opinions are wanted:
1. Should we present macro expansion before definition in the hover card?
2. Should we truncate/ignore macro expansion if it's too long? For performance and presentation reason, it might not be a good idea to expand pages worth of tokens in hover card. If so, what's the preferred threshold?

Also, some limitation applies:
1. Expansion isn't available in macro definition/arguments as the refactor code action isn't either.

Differential Revision: https://reviews.llvm.org/D127082
2022-09-07 17:49:45 +02:00
Eric Schweitz a1c4dedd34 Removing myself from the CODE_OWNERS.TXT file as I am no longer working
on the flang project. Ownership reverts to Steve Scalpone for now.
2022-09-07 08:40:55 -07:00
Georg Kotheimer 72142fbac4 [clangd] Fix hover crashing on integral or enumeral casts
When pretty printing the value of an expression, we cannot infer from
the type of the expression the type of the constant that the expression
evaluates to, as the expression might contain a type cast.
2022-09-07 16:43:22 +02:00
Sam McCall 8af74da5bd [clangd] Improve Selection testcase, pin to C++17
17 vs 14 have different ASTs, this causes D131465 to have to touch this test.
While here, make sure we're being clear about *which* nodes we're matching.

Differential Revision: https://reviews.llvm.org/D133423
2022-09-07 16:32:04 +02:00
Sam McCall 897f3ddc61 [Sema] Move Diags.isIgnored() checks off hot paths, it's not free. NFC
This speeds up clangd's buildAST() (i.e. parsing with a preamble) by 5% on
clangd/AST.cpp, by avoiding filling up the diagnostic state map with entries for
all the files where templates are being instantiated from.

(I would assume it has a similar effect on PCH and modules compiles).

This approach is obviously pretty fragile, and we should find ways to make
isIgnored() cheaper instead. But these changes in particular don't seem to make
the code worse in any case.

Differential Revision: https://reviews.llvm.org/D129683
2022-09-07 16:18:31 +02:00
Johannes Reifferscheid fb9fc79809 One-shot-bufferize: allow non-tensor arguments in scg.while/for.
Currently, one-shot-bufferize crashes as soon as there's
a mixture of tensor and non-tensor arguments. This seems
to happen for no good reason.

Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D133419
2022-09-07 15:54:25 +02:00
Kai Sasaki ccf975059c [mlir][complex] Canonicalization for complex.sub adding same numbers
Canonicalization for complex.sub adding same numbers. This canonicalization supports the case like complex.sub(complex.add(a, b), b) -> a.

Reviewed By: pifon2a

Differential Revision: https://reviews.llvm.org/D133397
2022-09-07 14:55:46 +02:00
jacquesguan 238e08d643 [mlir][Math] Fix RoundEven constant folder.
Use roundToIntegral instead roundeven of libm to avoid window build failed.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D133402
2022-09-07 12:46:05 +00:00
Sanjay Patel 7c57180900 [InstCombine] fold add+negate through select into sub
This transform came up as a potential DAGCombine in D133282,
so I wanted to see how it escaped in IR too.

We do general folds in InstCombiner::SimplifySelectsFeedingBinaryOp()
by checking if either arm of a select simplifies when the trailing
binop is threaded into the select.

So as long as one side simplifies, it's a good fold to combine a
negate and add into 1 subtract.

This is an example with a zero arm in the select:
https://alive2.llvm.org/ce/z/Hgu_Tj

And this models the tests with a cancelling 'not' op:
https://alive2.llvm.org/ce/z/BuzVV_

Differential Revision: https://reviews.llvm.org/D133369
2022-09-07 08:23:35 -04:00
Sanjay Patel e6c5d13ac7 [InstCombine] add tests for SimplifySelectsFeedingBinaryOp(); NFC 2022-09-07 08:23:35 -04:00
Aaron Kogon ae05b9dc30 Sink/hoist memory instructions between loop fusion candidates
Currently, instructions in the preheader of the second of two fusion
candidates are sunk and hoisted whenever possible, to try to allow the
loops to fuse. Memory instructions are skipped, and are never sunk or
hoisted. This change adds memory instructions for sinking/hoisting
consideration.

This change uses DependenceAnalysis to check if a mem inst in the
preheader of FC1 depends on an instruction in FC0's header, across
which it will be hoisted, or FC1's header, across which it will be
sunk. We reject cases where the dependency is a data hazard.

Differential Revision: https://reviews.llvm.org/D131606
2022-09-07 07:42:00 -04:00
Oleg Shyshkov fcab0a04c5 [mlir] Change CombiningKind in Vector dialect to EnumAttr.
CombiningKind was implemented before EnumAttr, so it reimplements the same behaviour with the custom code. Except for a few places, EnumAttr is a drop-in replacement.

Reviewed By: nicolasvasilache, pifon2a

Differential Revision: https://reviews.llvm.org/D133343
2022-09-07 13:40:45 +02:00
Andrea Di Biagio 3262794804 [MCA] Correctly check pipeline availability for partially overlapping resource groups.
This patch mostly reverts commit 70b37f4c03 which fixed PR50725.

In case of explicit consumption of multiple partially overlapping group
resources, the ResourceManager was not correctly checking pipeline
esources availability.

The fix for PR50725 only partially addressed a few instances of that issue.
This is a more general (although, technically slower) fix for that same issue.

It also fixes Issue #57548

Thanks to Haohai Wen for the small reproducible.
2022-09-07 12:17:59 +01:00
Tom Praschan 8019b46bc7 [clangd] Support renaming virtual methods
Fixes https://github.com/clangd/clangd/issues/706

Differential Revision: https://reviews.llvm.org/D132797
2022-09-07 13:15:50 +02:00
Simon Pilgrim e74102a963 [CostModel][X86] Merge getTypeBasedIntrinsicInstrCost into getIntrinsicInstrCost
For the few non type based intrinsic cases we can just check for !isTypeBasedOnly() to access the args directly.

I don't think we have a need to keep getTypeBasedIntrinsicInstrCost in BasicTTIImpl.h any more and can do a similar merge there as well - but it's a messier refactor and will take a while.
2022-09-07 12:04:09 +01:00
Dmitry Preobrazhensky efa65ef281 [AMDGPU][MC][GFX11][NFC] Update disassembler tests for VOP3 instructions
Differential Revision: https://reviews.llvm.org/D133350
2022-09-07 13:55:27 +03:00
Dmitry Preobrazhensky a95b45d380 [AMDGPU][MC][GFX11][NFC] Update disassembler tests for VOP3.DPP8 instructions
Differential Revision: https://reviews.llvm.org/D133353
2022-09-07 13:51:31 +03:00
Dmitry Preobrazhensky c777c8f022 [AMDGPU][MC][GFX11][NFC] Update disassembler tests for VOP3.DPP16 instructions
Differential Revision: https://reviews.llvm.org/D133356
2022-09-07 13:47:55 +03:00
Nikita Popov d452d5e2de [Bitcode] Fix constexpr autoupgrade for arrays and structs
While vectors use insertelement, structs and arrays should use
insertvalue.
2022-09-07 12:47:21 +02:00
Dmitry Preobrazhensky 973fec78e9 [AMDGPU][MC][GFX11][NFC] Update assembler tests for VOPD instructions
Differential Revision: https://reviews.llvm.org/D133205
2022-09-07 13:42:59 +03:00
Nikita Popov 0c40651f69 [Bitcode] Convert constexpr-to-instr.ll to use bitcode input (NFC)
We can't use an IR input once the relevant constant expressions
are no longer supported. Use a bitcode file instead, which will
be auto-upgraded (the whole point of this code...)
2022-09-07 12:29:32 +02:00
Jay Foad 01c53d7d80 [AMDGPU] Add an operand folding test case from D114232 2022-09-07 11:16:40 +01:00
Jay Foad 96dfa523c2 [AMDGPU] Refactor SIFoldOperands. NFC.
Refactor static functions into class methods so they have access to TII, MRI
etc.
2022-09-07 11:05:01 +01:00
Nikita Popov e047a4ab55 [ConstantFold] Avoid unary ConstantExpr::get()
Call ConstantFoldUnaryInstruction() instead, to only produce a
result if it folds.
2022-09-07 12:00:26 +02:00
Mehdi Amini b285d708a7 Apply clang-tidy fixes for performance-for-range-copy in TileUsingInterface.cpp (NFC) 2022-09-07 09:40:59 +00:00
Mehdi Amini 8eab900170 Apply clang-tidy fixes for llvm-qualified-auto in Bufferize.cpp (NFC) 2022-09-07 09:40:59 +00:00
Marco Elver 343700358f [AsmPrinter] Emit PCs into requested PCSections
Interpret MD_pcsections in AsmPrinter emitting the requested metadata to
the associated sections. Functions and normal instructions are handled.

Differential Revision: https://reviews.llvm.org/D130879
2022-09-07 11:36:02 +02:00
Marco Elver 31a548021b [GlobalISel] Propagate PCSections metadata to MachineInstr
Propagate (most) PC sections metadata to MachineInstr when GlobalISel is
doing instruction selection.

This change results in support for architectures using GlobalISel (such
as -O0 with AArch64). Not all instructions may be supported yet, and
requires further target-specific handling (such as done for AArch64
pseudo-atomics). Expanding supported instructions is planned on a
case-by-case basis and new use cases for PC sections metadata.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D130886
2022-09-07 11:36:02 +02:00
Marco Elver f0d6709e4a [AtomicExpandPass] Always copy pcsections Metadata to expanded atomics
When expanding IR atomics to target-specific atomics, copy all
!pcsections Metadata to expanded atomics automatically.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D130885
2022-09-07 11:36:01 +02:00
Marco Elver 0ba8886af5 [FastISel] Propagate PCSections metadata to MachineInstr
Propagate PC sections metadata to MachineInstr when FastISel is doing
instruction selection.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D130884
2022-09-07 11:36:01 +02:00
Nikita Popov 98a3a340c3 [ConstantExpr] Don't create fneg expressions
Don't create fneg expressions unless explicitly requested by IR or
bitcode.
2022-09-07 11:27:25 +02:00
Marco Elver da695de628 [MachineInstrBuilder] Introduce MIMetadata to simplify metadata propagation
In many places DebugLoc and PCSections metadata are just copied along to
propagate them through MachineInstrs. Simplify doing so by bundling them
up in a MIMetadata class that replaces the DebugLoc argument to most
BuildMI() variants.

The DebugLoc-only constructors allow implicit construction, so that
existing usage of `BuildMI(.., DL, ..)` works as before, and the rest of
the codebase using BuildMI() does not require changes.

NFC.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D130883
2022-09-07 11:22:50 +02:00
Marco Elver 4c58b00801 [SelectionDAG] Propagate PCSections through SDNodes
Add a new entry to SDNodeExtraInfo to propagate PCSections through
SelectionDAG.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D130882
2022-09-07 11:22:50 +02:00
Jay Foad 5291c3dd36 [AMDGPU] Simplify mad/mac patterns. NFC.
Simplify instruction selection patterns for mad/mac:
- Use any_fmad consistently to make it clear that all patterns treat
  fmad and AMDGPUfmad_ftz identically.
- For mad, put the patterns on the instruction definitions. For mac the
  patterns are still out-of-line because we want to set AddedComplexity
  and to have special handling of the source modifiers.

Differential Revision: https://reviews.llvm.org/D133305
2022-09-07 09:58:28 +01:00
Jay Foad 1427d55d70 [TableGen] Document sequence with stride
Document (in comments) the optional fourth "stride" argument to the
sequence operator, which was added in svn r157416.

Differential Revision: https://reviews.llvm.org/D133297
2022-09-07 09:58:22 +01:00
Jay Foad 9b8b1ac436 [AMDGPU] Add a comment for a missing fold 2022-09-07 09:57:18 +01:00
Nikita Popov f42d92611d [Reassociate] Avoid ConstantExpr::getFNeg() (NFCI)
Use ConstantFoldUnaryOpOperand() instead. Also make the code below
robust against non-instruction users, just in case it doesn't fold.
2022-09-07 10:48:08 +02:00
Alexander Belyaev 4bf84e433d [mlir] Remove `materializeOpFoldResult` functions.
We can use `getValueOrCreateConstantIndexOp` instead.

Differential Revision: https://reviews.llvm.org/D133403
2022-09-07 10:22:42 +02:00
chenglin.bi 5fa13212d1 [AArch64] add tests for non-power2 int types; NFC 2022-09-07 16:07:26 +08:00
serge-sans-paille 1546df49f5 [clang][doc] Do not keep a copy of ClangCommandLineReference.rst in tree
This file is auto-generated, it's a bit confusing for the maintainers to have it
in tree while it shouldn't be modified *and* already have a rule to be
generated.

Differential Revision: https://reviews.llvm.org/D133349
2022-09-07 09:06:47 +02:00
Uday Bondhugula 8d7f270186 [MLIR] NFC. Introduce mlir::hasEffect and refactor usages dialect util
Introduce mlir::hasEffect and refactor existing usage to use utility.
NFC.

Reviewed By: rriddle, mehdi_amini

Differential Revision: https://reviews.llvm.org/D132117
2022-09-07 12:21:57 +05:30
Zi Xuan Wu (Zeson) 162131257f [CSKY] Fix the compiling error about missing Log2 function with Log2_64 2022-09-07 14:49:40 +08:00
Xiang1 Zhang c836ddaf72 [X86][NFC] Refine load/store reg to StackSlot for extensibility
Reviewed By: LuoYuanke

Differential Revision: https://reviews.llvm.org/D133078
2022-09-07 14:35:42 +08:00
Jan Ole Hüser 4e5a59a383 [LLD][COFF] Fix writing a map file when range extension thunks are inserted
Bug: An assertion fails:

    Assertion failed: isa<To>(Val) && "cast<Ty>() argument of incompatible type!",
    file C:\Users\<user>\prog\llvm\llvm-git-lld-bug\llvm\include\llvm/Support/Casting.h, line 578

Bug is triggered, if

    - a map file is requested with /MAP, and
    - Architecture is ARMv7, Thumb, and
    - a relative jump (branch instruction) is greater than 16 MiB (2^24)

The reason for the Bug is:

    - a Thunk is created for the jump
    - a Symbol for the Thunk is created
        - of type `DefinedSynthetic`
        - in file `Writer.cpp`
        - in function `getThunk`
    - the Symbol has no name
    - when creating the map file, the name of the Symbol is queried
    - the function `Symbol::computeName` of the base class `Symbol`
      casts the `this` pointer to type `DefinedCOFF` (a derived type),
      but the acutal type is `DefinedSynthetic`
    - The in the llvm::cast an assertion fails

Changes:

- Modify regression test to trigger this bug
- Give the symbol pointing to the thunk a name, to fix the bug
- Add assertion, that only DefinedCOFF symbols are allowed to have an
  empty name, when the constructor of the base class Symbol is executed

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D133201
2022-09-07 09:26:41 +03:00