452866 Commits

Author SHA1 Message Date
Kadir Cetinkaya
385c8cd3cd
[Tooling][Inclusions] Add c-header and global namespace alternatives for size_t
Differential Revision: https://reviews.llvm.org/D144646
2023-02-24 10:44:33 +01:00
Kadir Cetinkaya
f393e1f6b3
[clangd] Fix UB in scanPreamble
getMemBufferCopy triggers an UB when it receives a default constructed
StringRef. Make sure that we're always passing the null-terminated string
created in ParseInputs throughout the scanPreamble.

Differential Revision: https://reviews.llvm.org/D144708
2023-02-24 10:43:12 +01:00
Nathan Ridge
c4972d3729 [clangd] Avoid using CompletionItemKind.Text for macro completions
Fixes https://github.com/clangd/clangd/issues/1484

Differential Revision: https://reviews.llvm.org/D144703
2023-02-24 04:41:27 -05:00
Matthias Springer
bc8de519ea [mlir][IR] Add Iterator template option to IR walkers
This allows users to specify a  top-down or bottom-up traversal of the IR, in addition to the already existing WalkOrder.

Certain transformations work better with a forward traversal. E.g., when cloning a piece of IR, operations should be cloned top-down so that all uses are defined when creating an op.

Certain transformations work better with a reverse traversal. E.g., when erasing a piece of IR, operations should be erased bottom-up to avoid erasing operations that still have users.

Differential Revision: https://reviews.llvm.org/D144257
2023-02-24 10:24:47 +01:00
Florian Hahn
eddecd3ade
[SCEV] Increase FoldID bits size cover common cases.
This should fix the regressions introduced by a53d940cee6f by making
sure no dynamic allocations are needed in the common case, while
retaining support for arbitrary SCEV expressions.

Alternative to D144335.

Compile-time impact:
* NewPM-O3: -0.11%
* NewPM-ReleaseThinLTO: -0.10%
*NewPM-ReleaseLTO-g: -0.08%

https://llvm-compile-time-tracker.com/compare.php?from=df016a9525e5722dfd1e1e1632cec3ed7b33bc8a&to=c1c64de4a973bcecaddbc4038a539234eb39413b&stat=instructions:u

Reviewed By: vitalybuka, nikic

Differential Revision: https://reviews.llvm.org/D144382
2023-02-24 09:41:53 +01:00
Valentin Clement
3e20f9aa14
[flang] Perform default value initialization on abstract type if needed
Abstract derived-type components can have default value so perform
the default value initialization if necessary.

```
type, abstract :: a
  integer :: b = 10
end type

type, extends(a) :: b
  integer :: d
end type
```

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D144668
2023-02-24 09:22:30 +01:00
Jean Perier
bc991d940f [flang][hlfir] Array constructor lowering [part 4/4]
Enable character and derived type array constructor lowering.
Nothing special needs to be done other than lowering the types
before the array constructor lowering.
Derived type are forced to use the runtime for now to avoid
undesired usage of user defined assignment that hlfir.assign
may trigger when using the runtime.

Differential Revision: https://reviews.llvm.org/D144548
2023-02-24 09:18:27 +01:00
Serge Pavlov
7f81dd4dd6 [NFC] Make FPClassTest a bitmask enumeration
This is recommit of 2e416cdd52, fixed to be accepatble by GCC.
The original commit message is below.

With this change bitwise operations are allowed for FPClassTest
enumeration, it must simplify using this type. Also some functions
changed to get argument of type FPClassTest instead of unsigned.

Differential Revision: https://reviews.llvm.org/D144241
2023-02-24 15:12:16 +07:00
Jean Perier
9683a9c998 [flang][hlfir] Array constructor lowering [part 3/4]
Lower the cases that require runtime support to deal
with the allocation, reallocation, or copy of ac-values to
the array constructor storage.

Differential Revision: https://reviews.llvm.org/D144513
2023-02-24 09:11:28 +01:00
Martin Liska
8f5962b1cc ASAN: keep support for Global::location
We as GCC still emit __asan_global_source_location for global variables
and we would like to use it in the future. On other hand, we don't
support llvm-symbolizer and the default libbacktraace symbolizer
does not support location info.

Differential Revision: https://reviews.llvm.org/D144424
2023-02-24 09:10:56 +01:00
Jean Perier
ce8dbe3c25 [flang] Do not include dangling ac-implied-do-index in folded shape inquiry
The current code was replacing inquiry to array constructor whose
ac-value shape depends on ac-implied-do-index with an expression
using the ac-implied-do-index without the implied-do (folding the
first case added in the test as in the second case with a regular
symbol).

Differential Revision: https://reviews.llvm.org/D144655
2023-02-24 09:08:34 +01:00
Jean Perier
91bd4c6e81 [flang] Preserve useResultSymbolShape_ option when folding array constructor shape
By default evaluate::GetShape(expr) may return a compiler generated expression
using symbols that are part of function interfaces if there are function
references in "expr".
It is not right to replace an inquiry of "expr" with such compiler
generated expression since the call context would be lost, along with
the meaning of the inquiry expression.
Inquiry folding uses GetContextFreeShape(expr) that sets-up
useResultSymbolShape_ in GetShapeHelper to prevent such bad rewrites. But this did not
work properly with array constructor: GetShapeHelper made a call to
GetShape, ignoring and losing the "useResultSymbolShape_" instruction.

Differential Revision: https://reviews.llvm.org/D144512
2023-02-24 09:06:30 +01:00
LLVM GN Syncbot
0630bd6c30 [gn build] Port fffbfe7c0ca8 2023-02-24 07:34:42 +00:00
Julian Lettner
361bb47378 Restore "[Darwin] Apply workaround to make symbolication in iOS simulators work"
This reverts commit d8b8911d58dba73fd7a28210d8d3e780ae881179.
2023-02-23 23:31:02 -08:00
Craig Topper
fffbfe7c0c [WebAssembly] Split WebAssemblyUtils to fix library layering for MC tools.
WebAssemblyUtils depends on CodeGen which depends on all middle end
optimization libraries.

This component is used by WebAssembly's AsmParser, Disassembler, and
MCTargetDesc libraries. Because of this, any MC layer tool built with
WebAssembly support includes a larger portion of LLVM than it should.

To fix this I've created an MC only version of WebAssemblyTypeUtilities.cpp
in MCTargetDesc to be used by the MC components.

This shrinks llvm-objdump and llvm-mc on my local release+asserts
build by 5-6 MB.

Reviewed By: MaskRay, aheejin

Differential Revision: https://reviews.llvm.org/D144354
2023-02-23 23:25:23 -08:00
Alexis Murzeau
87447bedac [clang-tidy] Fix readability-identifer-naming Hungarian CString options
When reading readability-identifier-naming.HungarianNotation.CString
options, correctly use the type string stored in CStr.second instead of
the option name (CStr.first) as the HNOption.CString map key.

This will make CString options really working and properly parsed by the
checker.

Reviewed By: carlosgalvezp

Differential Revision: https://reviews.llvm.org/D144431
2023-02-24 07:15:19 +00:00
Vikram
64fc892cda [AMDGPU] Autogenerate carryout-selection.ll, uaddo.ll, usubo.ll (NFC)
Differential Revision: https://reviews.llvm.org/D143987
2023-02-24 02:03:56 -05:00
Chuanqi Xu
255b2d8162 Add test for issue 60486
Close https://github.com/llvm/llvm-project/issues/60486.

When I look back at this problem again, it only appears if we specify it
with `-fmodule-file=<BMI-path>`. And it disappears after we specify it
as `-fmodule-file=<module-name>=<BMI-path>`. Since we want to depreacate
the form `-fmodule-file=<BMI-path>`, we can think the problem goes
away.
2023-02-24 14:32:05 +08:00
Mehdi Amini
ab2b73dd48 Fix internal link in the MLIR doc 2023-02-23 23:29:28 -07:00
Fangrui Song
f53de29862 [FunctionImport] Change IRMover report_fatal_error to a proper error
Conflicting module flags leads to a proper error for regular LTO but a crash
(report_fatal_error) for ThinLTO. Switch to createStringError to fix the crash
and match regular LTO.
2023-02-23 21:45:14 -08:00
Chia-hung Duan
6860d1c6e4 [scudo] Accessing PossibleRegions requires lock
It is preferable to use `std::shared_mutex` style mutex. Will switch to
using it when it's available.

Differential Revision: https://reviews.llvm.org/D144691
2023-02-24 04:15:33 +00:00
Ben Shi
366d34b39e [AVR][MC] Add ELF flag 'EF_AVR_LINKRELAX_PREPARED' to OBJ files
This is in accordance with avr-gcc, even '-mno-relax' is specified
to avr-gcc, this flag will also be added to the output relocatables.

With this flag set, the GNU ld will perform long call -> short call
optimization for AVR, otherwise not.

Fixes https://github.com/llvm/llvm-project/issues/54508

Reviewed By: MaskRay, jacquesguan, aykevl

Differential Revision: https://reviews.llvm.org/D144617
2023-02-24 11:16:42 +08:00
Siva Chandra Reddy
e758215e06 [libc] Remove a now uneccesary CMake policy.
Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D143139
2023-02-24 03:03:23 +00:00
Michael Liao
fe6ca54682 [LangRef] Correct value ranges for address space, vector, and float bit sizes.
- The current implementation checks them for 24-bit inegers but the
  document says 23-bit one effectively by listing the range as [1,2^23).
- Minor error message correction.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D144685
2023-02-23 21:54:50 -05:00
Siva Chandra Reddy
17a2434bd6 [libc] Introduce a target named libc-unit-tests to run just the unit tests.
The target "check-libc" now runs all enabled tests which, depending on
the build mode, includes the unit tests, the integration tests and the api
test.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D144663
2023-02-24 02:53:36 +00:00
Julian Lettner
d8b8911d58 Revert "[Darwin] Apply workaround to make symbolication in iOS simulators work"
This reverts commit ebd8eee62a431a6744c3f187fcda58e5dea08499.
2023-02-23 18:12:52 -08:00
Noah Goldstein
4fcfff4f2d Use analyzeKnownBitsFromAndXorOr in SimplifyDemandedUseBits for and/xor/or
There are extra patterns that have for these three logic operations
that aren't covered in `SimplifyDemandedUseBits`. To avoid duplicating
the code, just use `analyzeKnownBitsFromAndXorOr` in
`SimplifyDemandedUseBits` to get full coverage.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D142429
2023-02-23 19:52:17 -06:00
Noah Goldstein
196d3e3965 Add logic for tracking lowbit of (and/xor/or X, (add/sub X, Odd))
Any case of logicop + add/sub(Odd) we can prove the low bit is either
zero/non-zero.

Alive2 Links:
    xor:
        sub x, C: https://alive2.llvm.org/ce/z/aaABdS
        sub C, x: https://alive2.llvm.org/ce/z/2W-ZJ7
        add C, x: https://alive2.llvm.org/ce/z/pzDkte
    or:
        sub x, C: https://alive2.llvm.org/ce/z/xd-bcP
        sub C, x: https://alive2.llvm.org/ce/z/p8hXJF
        add C, x: https://alive2.llvm.org/ce/z/osmkB6
    and:
        sub x, C: https://alive2.llvm.org/ce/z/D_NNxR
        sub C, x: https://alive2.llvm.org/ce/z/N_5C62
        add C, x: https://alive2.llvm.org/ce/z/4cy7a4

Differential Revision: https://reviews.llvm.org/D142427
2023-02-23 19:52:17 -06:00
Noah Goldstein
6ad6f9c579 Add helper for handling computeKnownBits for and/xor/or; NFC
This change just factors out the existing logic for and/xor/or and
puts them in a publicly available helper.  functionality is the same.

Differential Revision: https://reviews.llvm.org/D142849
2023-02-23 19:52:16 -06:00
Noah Goldstein
5fe70be799 Add tests for KnownBits of (and/xor/or X, (add/sub X, OddV)); NFC
Differential Revision: https://reviews.llvm.org/D142426
2023-02-23 19:52:16 -06:00
Min-Yih Hsu
058f7449cf [M68k] Provide exception pointer and selector registers
Using d0 for exception pointer and d1 for selector, as suggested by GCC.
2023-02-23 16:25:34 -08:00
Kadir Cetinkaya
5a623c2a08
Revert "Revert "[Tooling/Inclusion] Handle std::get symbol.""
This reverts commit 7c9b15fbaeb2846ad25e797d55ffe1ccef9e1379. Breakage
was in downstream code.
2023-02-24 01:24:53 +01:00
Shilei Tian
22cd105a66 [OpenMP] Fix the wrong use of fopen
This patch fixes the wrong use of `fopen`.

Fix https://github.com/llvm/llvm-project/issues/60934

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D144601
2023-02-23 19:12:58 -05:00
Qiongsi Wu
401f768061 [PGO] Setting ValueProfNode Array's Alignment
`instrprof` currently does not set `__llvm_prf_vnds`'s alignment after creating it. The consequence is that the alignment is set to 16 later (c0f3ac1d00/llvm/lib/IR/DataLayout.cpp (L1019)). This can lead to undefined behaviour when we calculate `NumVNodes` in `lprofGetLoadModuleSignature` (c0f3ac1d00/compiler-rt/lib/profile/InstrProfilingMerge.c (L32)). The reason is that when the `__llvm_prf_vnds` array is 16 byte aligned, `__llvm_profile_end_vnodes() - __llvm_profile_begin_vnodes()` may not be a multiple of the size of ValueProfNode (which is 24, 20 on 32 bit targets).

This patch sets `__llvm_prf_vnds`'s alignment to its ABI alignment, which always divides its size. Then `__llvm_profile_end_vnodes() - __llvm_profile_begin_vnodes()` will be a multiple of `sizeof(ValueProfNode)`.

Reviewed By: w2yehia, MaskRay

Differential Revision: https://reviews.llvm.org/D144302
2023-02-23 19:07:29 -05:00
Alex Lorenz
21631b567e [clang] fix intendation in newly added release note
This fixes the llvm docs build bot.
2023-02-23 15:53:07 -08:00
Markus Böck
59343943cf [mlir][doc] Remove section about now removed useFoldAPI option 2023-02-24 00:36:14 +01:00
Manolis Tsamis
7b79e8d455 [RISCV] Add vendor-defined XTheadFMemIdx (FP Indexed Memory Operations) extension
The vendor-defined XTHeadFMemIdx (no comparable standard extension exists
at the time of writing) extension adds indexed load/store instructions
for floating-point registers.

It is supported by the C9xx cores (e.g., found in the wild in the
Allwinner D1) by Alibaba T-Head.

The current (as of this commit) public documentation for this
extension is available at:
  https://github.com/T-head-Semi/thead-extension-spec/releases/download/2.2.2/xthead-2023-01-30-2.2.2.pdf

Support for these instructions has already landed in GNU Binutils:
  https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=f511f80fa3fcaf6bcbe727fb902b8bd5ec8f9c20

Depends on D144249

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D144647
2023-02-24 00:35:37 +01:00
Chia-hung Duan
a78805f3cb [scudo] Mark all blocks in a range without visiting each of them
When all the blocks in the group are known to be used, we should just
mark the pages in the range as all counted instead of visiting each of
them. This will reduce the time of marking free blocks especially for
smaller size class.

Reviewed By: cferris

Differential Revision: https://reviews.llvm.org/D141958
2023-02-23 23:26:03 +00:00
Caroline Tice
7c9b15fbae Revert "[Tooling/Inclusion] Handle std::get symbol."
This reverts commit cbcb3eef70def3509bdffd4fe1ebfb6422afeaa2.

Causing many clangd test breakages, similar to:

error: no matching constructor for initialization of 'llvm::SmallVector<clang::tooling::stdlib::Header>'
                : llvm::SmallVector<clang::tooling::stdlib::Header>(
                  ^
2023-02-23 15:18:17 -08:00
Manolis Tsamis
f6262201d8 [RISCV] Add vendor-defined XTheadMemIdx (Indexed Memory Operations) extension
The vendor-defined XTHeadMemIdx (no comparable standard extension exists
at the time of writing) extension adds indexed load/store instructions
as well as load/store and update register instructions.

It is supported by the C9xx cores (e.g., found in the wild in the
Allwinner D1) by Alibaba T-Head.

The current (as of this commit) public documentation for this
extension is available at:
  https://github.com/T-head-Semi/thead-extension-spec/releases/download/2.2.2/xthead-2023-01-30-2.2.2.pdf

Support for these instructions has already landed in GNU Binutils:
  https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=27cfd142d0a7e378d19aa9a1278e2137f849b71b

Depends on D144002

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D144249
2023-02-24 00:17:58 +01:00
Ben Shi
9161043390 [clang][driver] Handle '-mrelax' and '-mno-relax' for AVR
Reviewed By: MaskRay, aykevl

Fixes https://github.com/llvm/llvm-project/issues/54508

Differential Revision: https://reviews.llvm.org/D144620
2023-02-24 07:16:31 +08:00
Leonard Chan
86dbcafd0c [llvm] Teach GlobalDCE about dso_local_equivalent
This way, C++ relative-vtables can also participate in GlobalDCE. This
depends on some TypeMetadataUtils.cpp bits in D134320, but that
dependency can be removed and included here if necessary.

Differential Revision: https://reviews.llvm.org/D135928
2023-02-23 23:13:57 +00:00
Fangrui Song
ab9b2fe2a5 [Driver] Define BareMetal::HasNativeLLVMSupport to return true
D33259 switched the default linker to ld.lld which supports LLVM LTO.
We can support LTO compile/link in one command and drop the
`unable to pass LLVM bit-code files to linker` error.

Fix https://github.com/llvm/llvm-project/issues/52807
2023-02-23 15:06:02 -08:00
Ziqing Luo
cd2652963b [-Wunsafe-buffer-usage] Fixits for assignments to array subscript expressions
Let generate fix-its to make assignments' left-hand side of the form
`dre[e]` safe if `e` is known to be non-negative.

Commit on behalf of jkorous (Jan Korous)

Reviewed by: NoQ (Artem Dergachev)

Differential revision: https://reviews.llvm.org/D142794
2023-02-23 15:02:46 -08:00
Alex Lorenz
c8b37e48f6 [clang] extend external_source_symbol attribute with USR clause
Allow the user to specify a concrete USR in the external_source_symbol attribute.
That will let Clang's indexer to use Swift USRs for Swift declarations that are
represented with C++ declarations.

This new clause is used by Swift when generating a C++ header representation
of a Swift module:
https://github.com/apple/swift/pull/63002

Differential Revision: https://reviews.llvm.org/D141324
2023-02-23 14:59:26 -08:00
Krzysztof Drewniak
5a4f193afa Add tests to reproduce pointer/index width confusion crashes
Some calls to GEPOperator::accumulateConstantOffset(APInt) passed the
pointer bitwidth as the width of the APInt, while the function asserts
that the width of its argument is equal to the index width of the GEP
pointer input. These values are almost always the same, so mixing up
which call to use doesn't usually cause issues. However, when dealing
with data layouts where these values are different, the passes tested
here can crash.

This will be fixed in D143437 .

Differential Revision: https://reviews.llvm.org/D144673
2023-02-23 22:50:43 +00:00
Ziqing Luo
f78c343466 [-Wunsafe-buffer-usage] Create Fix-Its only if they are emitted
`-Wunsafe-buffer-usage` diagnostics shall not emit fix-its if fix-its
are globally disabled.

Commit on behalf of jkorous (Jan Korous)

Reviewed by: NoQ (Artem Dergachev)

Differential revision: https://reviews.llvm.org/D143697
2023-02-23 14:47:43 -08:00
Quentin Colombet
17b2e73cb4 [mlir][LinAlg][Transform] Add a transform op for conv2d to im2col
This patch adds patterns to convert `linalg.conv_2d_xxx` operations
into `linalg.generic` (for img2col packing) and `linalg.matmul`.

The meat of the patch comes straight from IREE
(https://github.com/iree-org/iree).
(To the original authors are you okay with that?)

What this patch adds is proper plumbing of the im2col patterns into the
transform dialect.

PS: Feel free to add more reviewers. I wanted to cover the original contributors of im2col in IREE but I'm not sure I got all of them.

Reviewed By: nicolasvasilache, ThomasRaoux

Differential Revision: https://reviews.llvm.org/D144108
2023-02-23 22:27:16 +00:00
Leonard Chan
db28818476 [llvm] Teach whole program devirtualization about relative vtables
Prior to this patch, WPD was not acting on relative-vtables in C++. This
involves teaching WPD about these things:

- llvm.load.relative which is how relative-vtables are indexed (instead of GEP)
- dso_local_equivalent which is used in the vtable itself when taking the
  offset between a virtual function and vtable
- Update llvm/test/ThinLTO/X86/devirt.ll to use opaque pointers and add
  equivalent tests for RV

Differential Revision: https://reviews.llvm.org/D134320
2023-02-23 22:18:43 +00:00
Leonard Chan
bbddaad6e8 Add REQUIRES: riscv to riscv test
This should fix builders like
https://lab.llvm.org/buildbot/#/builders/139/builds/36522
2023-02-23 22:16:49 +00:00