Dmitry Vyukov [Fri, 13 Aug 2021 15:16:27 +0000 (17:16 +0200)]
tsan/dd: fix format strings
Reviewed By: melver
Differential Revision: https://reviews.llvm.org/D108040
David Spickett [Fri, 13 Aug 2021 15:25:32 +0000 (16:25 +0100)]
Revert "[clang-format] Distinguish K&R C function definition and attribute"
This reverts commit
de763c4037157e60551ba227ccd0ed02e109c317.
Causing test failures on the Arm/AArch64 quick bots:
https://lab.llvm.org/buildbot/#/builders/188/builds/2202
Jamie Schmeiser [Fri, 13 Aug 2021 14:53:24 +0000 (10:53 -0400)]
Fix bad assert in print-changed code
Summary:
The assertion that both functions were not missing was incorrect and would
fail when one of the functions was missing. Fixed it and moved the
assertion earlier to check the input parameters to better capture
first-failure. Added lit test.
Author: Jamie Schmeiser <schmeise@ca.ibm.com>
Reviewed By: aeubanks (Arthur Eubanks)
Differential Revision: https://reviews.llvm.org/D107989
Roman Lebedev [Fri, 13 Aug 2021 14:38:36 +0000 (17:38 +0300)]
Revert "[SCEV] Remove premature assert. PR46786"
Since then, the SCEV pointer handling as been improved,
so the assertion should now hold.
This reverts commit
b96114c1e1fc4448ea966bce013706359aee3fa9,
relanding the assertion from commit
141e845da5dda6743a09f858b4aec0133a931453.
Peixin Qiao [Fri, 13 Aug 2021 14:20:38 +0000 (10:20 -0400)]
[flang][OpenMP] Add semantic check for teams nesting
This patch implements the following check for TEAMS construct:
```
OpenMP Version 5.0 Teams construct restriction: A teams region can
only be strictly nested within the implicit parallel region or a target
region. If a teams construct is nested within a target construct, that
target construct must contain no statements, declarations or directives
outside of the teams construct.
```
Also add one test case for the check.
Reviewed By: kiranchandramohan, clementval
Differential Revision: https://reviews.llvm.org/D106335
Dmitry Vyukov [Fri, 13 Aug 2021 13:24:23 +0000 (15:24 +0200)]
tsan: fix latent bug in shadow computation
We use kShadowCnt (number of shadow cells per application granule)
when computing shadow, but it's wrong. We need the ratio
between shadow and app memory (how much shadow is larger than app memory),
which is kShadowMultiplier.
Currently both are equal to 4, so it works fine.
Use the correct constant.
Reviewed By: melver
Differential Revision: https://reviews.llvm.org/D108033
Kristóf Umann [Fri, 13 Aug 2021 13:46:32 +0000 (15:46 +0200)]
[analyzer][NFC] Make test/Analysis/self-assign.cpp readable
Peixin Qiao [Fri, 13 Aug 2021 12:19:01 +0000 (08:19 -0400)]
[flang][OpenMP] Add semantic checks for cancellation nesting
This patch implements the following semantic checks for cancellation constructs:
```
OpenMP Version 5.0 Section 2.18.1: CANCEL construct restriction:
If construct-type-clause is taskgroup, the cancel construct must be
closely nested inside a task or a taskloop construct and the cancel
region must be closely nested inside a taskgroup region. If
construct-type-clause is sections, the cancel construct must be closely
nested inside a sections or section construct. Otherwise, the cancel
construct must be closely nested inside an OpenMP construct that matches
the type specified in construct-type-clause of the cancel construct.
OpenMP Version 5.0 Section 2.18.2: CANCELLATION POINT restriction:
A cancellation point construct for which construct-type-clause is
taskgroup must be closely nested inside a task or taskloop construct,
and the cancellation point region must be closely nested inside a
taskgroup region. A cancellation point construct for which
construct-type-clause is sections must be closely nested inside a
sections or section construct. A cancellation point construct for which
construct-type-clause is neither sections nor taskgroup must be closely
nested inside an OpenMP construct that matches the type specified in
construct-type-clause.
```
Also add test cases for the check.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D106538
Alexey Bader [Fri, 13 Aug 2021 06:04:09 +0000 (09:04 +0300)]
[NFC] Drop idle compiler option from the test.
Differential Revision: https://reviews.llvm.org/D108020
Justas Janickas [Fri, 6 Aug 2021 12:50:13 +0000 (13:50 +0100)]
[OpenCL] Clang diagnostics allow reporting C++ for OpenCL version.
Some Clang diagnostics could only report OpenCL C version. Because
C++ for OpenCL can be used as an alternative to OpenCL C, the text
for diagnostics should reflect that.
Desrciptions modified for these diagnostics:
`err_opencl_unknown_type_specifier`
`warn_option_invalid_ocl_version`
`err_attribute_requires_opencl_version`
`warn_opencl_attr_deprecated_ignored`
`ext_opencl_ext_vector_type_rgba_selector`
Differential Revision: https://reviews.llvm.org/D107648
Roman Lebedev [Fri, 13 Aug 2021 12:08:10 +0000 (15:08 +0300)]
Reland "[NFCI][SimplifyCFG] simplifyCondBranch(): assert that branch is non-tautological""
The commit originally unearthed a problem, reported as
https://reviews.llvm.org/rGf30a7dff8a5b32919951dcbf92e4a9d56c4679ff#1019890
Now that the problem has been fixed, and the assertion no longer fires,
let's see if there are other cases it fires on.
This reverts commit
5c8c24d2decae4a76047777271d60411fc3316eb,
relanding commit
f30a7dff8a5b32919951dcbf92e4a9d56c4679ff.
Roman Lebedev [Fri, 13 Aug 2021 12:35:01 +0000 (15:35 +0300)]
[SimplifyCFG] Restart if `removeUndefIntroducingPredecessor()` made changes
It might changed the condition of a branch into a constant,
so we should restart and constant-fold terminator,
instead of continuing with the tautological "conditional" branch.
This fixes the issue reported at https://reviews.llvm.org/rGf30a7dff8a5b32919951dcbf92e4a9d56c4679ff
Roman Lebedev [Fri, 13 Aug 2021 12:08:00 +0000 (15:08 +0300)]
[NFC][SimplifyCFG] Add test for failed assertion
This would trigger an assertion that was added in rGf30a7dff8a5b.
Need to fix that before relanding.
Reduced from https://reviews.llvm.org/rGf30a7dff8a5b#1019890
Rainer Orth [Fri, 13 Aug 2021 12:31:32 +0000 (14:31 +0200)]
[MC][ELF] Mark Solaris objects as ELFOSABI_SOLARIS
Prompted by D107747 <https://reviews.llvm.org/D107747>, it seems prudent to
mark objects as `ELFOSABI_SOLARIS` on Solaris.
Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.
Differential Revision: https://reviews.llvm.org/D107748
Owen [Thu, 12 Aug 2021 13:12:25 +0000 (06:12 -0700)]
[clang-format] Distinguish K&R C function definition and attribute
This is a follow-up to https://reviews.llvm.org/D107950 which
missed user-defined types in K&R C.
Differential Revision: https://reviews.llvm.org/D107961
Adrian Kuegel [Fri, 13 Aug 2021 11:43:58 +0000 (13:43 +0200)]
[mlir] Remove unused header include.
Also adjust BUILD.bazel and remove an unused dependency.
Differential Revision: https://reviews.llvm.org/D108027
Dmitry Vyukov [Fri, 13 Aug 2021 05:29:41 +0000 (07:29 +0200)]
scudo/standalone: prepare for enabling format string checking
Move __attribute__((format)) to the function declarations in the header file.
It's almost pointless in the source file.
But disable the warning with -Wno-format for now
since there is a number of existing warnings.
Depends on D107984.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D108014
Dmitry Vyukov [Thu, 12 Aug 2021 18:00:16 +0000 (20:00 +0200)]
ubsan: fix few format string bugs
This fixes just a few of the warnings.
Ubsan is not completely clean yet,
but these somehow pop up while I was
fixing other sanitizers.
Depends on D107983.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D107984
Dmitry Vyukov [Thu, 12 Aug 2021 17:57:31 +0000 (19:57 +0200)]
tsan: clean up and enable format string checking
Depends on D107982.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D107983
Dmitry Vyukov [Thu, 12 Aug 2021 17:55:59 +0000 (19:55 +0200)]
msan: clean up and enable format string checking
Depends on D107981.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D107982
Dmitry Vyukov [Thu, 12 Aug 2021 17:52:24 +0000 (19:52 +0200)]
sanitizer_common: enable format string checking
Enable -Wformat in sanitizer_common now that it's
cleaned up from existing warnings.
But disable it in all sanitizers for now since
they are not cleaned up yet, but inherit sanitizer_common CFLAGS.
Depends on D107980.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D107981
Dmitry Vyukov [Thu, 12 Aug 2021 17:47:23 +0000 (19:47 +0200)]
sanitizer_common: fix format strings
Fix existing -Wformat warnings.
Depends on D107979.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D107980
Dmitry Vyukov [Fri, 13 Aug 2021 05:36:56 +0000 (07:36 +0200)]
sanitizer_common: declare vars more locally in VSNPrintf
No point in declaring variables separately before use.
Depends on D107979.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D108015
Dmitry Vyukov [Thu, 12 Aug 2021 18:07:05 +0000 (20:07 +0200)]
Revert "sanitizer_common: support printing __m128i type"
This reverts commits
"sanitizer_common: support printing __m128i type"
and "[sanitizer] Fix VSNPrintf %V on Windows".
Unfortunately, custom "%V" is inherently incompatible with -Wformat,
it produces both:
warning: invalid conversion specifier 'V' [-Wformat-invalid-specifier]
warning: data argument not used by format string [-Wformat-extra-args]
If we disable both of these warnings we lose lots of useful warnings as well.
Depends on D107978.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D107979
Dmitry Vyukov [Thu, 12 Aug 2021 17:59:12 +0000 (19:59 +0200)]
scudo: fix __attribute__((format))
The attribute should be in the header on declaration.
It's almost pointless in the source file.
Depends on D107977.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D107978
Dmitry Vyukov [Thu, 12 Aug 2021 17:37:29 +0000 (19:37 +0200)]
sanitizer_common: prepare for enabling format string checking
The __attribute__((format)) was added somewhere in 2012,
the lost during refactoring, then re-added in 2014 but
to te source files, which is a no-op.
Move it back to header files so that it actually takes effect.
But over the past 7 years we've accumulated whole lot of
format string bugs of different types, so disable the warning
with -Wno-format for now for incremental clean up.
Among the bugs that it warns about are all kinds of bad things:
- wrong sizes of arguments
- missing/excessive arguments
- printing wrong things (e.g. *ptr instead of ptr)
- completely messed up format strings
- security issues where external string is used as format
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D107977
Florian Mayer [Fri, 13 Aug 2021 10:50:52 +0000 (11:50 +0100)]
[hwasan] Fix wild free tests on x86.
Jan Svoboda [Fri, 13 Aug 2021 10:48:14 +0000 (12:48 +0200)]
[clang][deps] Move `SingleCommandCompilationDatabase` to a header
This makes `SingleCommandCompilationDatabase` reusable.
Roman Lebedev [Fri, 13 Aug 2021 10:15:24 +0000 (13:15 +0300)]
Revert "[NFCI][SimplifyCFG] simplifyCondBranch(): assert that branch is non-tautological"
The assertion does not hold on a provided reproducer.
Reverting until after fixing the problem.
This reverts commit
f30a7dff8a5b32919951dcbf92e4a9d56c4679ff.
Dylan Fleming [Fri, 13 Aug 2021 08:36:31 +0000 (09:36 +0100)]
[SVE] Add folds for truncation of vscale
Reviewed By: david-arm
Differential Revision: https://reviews.llvm.org/D107453
Rosie Sumpter [Mon, 9 Aug 2021 11:51:17 +0000 (12:51 +0100)]
[LoopFlatten] Fix assertion failure in checkOverflow
There is an assertion failure in computeOverflowForUnsignedMul
(used in checkOverflow) due to the inner and outer trip counts
having different types. This occurs when the IV has been widened,
but the loop components are not successfully rediscovered.
This is fixed by some refactoring of the code in findLoopComponents
which identifies the trip count of the loop.
Alexey Bader [Mon, 24 May 2021 08:38:16 +0000 (11:38 +0300)]
[NFC] Add commas in code comments.
Sam McCall [Fri, 13 Aug 2021 08:38:42 +0000 (10:38 +0200)]
[clangd] Guard against null Attrs in the AST
Andrzej Warzynski [Thu, 12 Aug 2021 19:17:39 +0000 (19:17 +0000)]
[flang][nfc] Remove `flang-new-driver` from LIT
After merging https://reviews.llvm.org/D105811, `flang-new-driver` is no
longer required.
Differential Revision: https://reviews.llvm.org/D107990
Pushpinder Singh [Thu, 12 Aug 2021 08:46:24 +0000 (14:16 +0530)]
[AMDGPU][OpenMP] Use llvm-link to link ocml libraries
This fixes the 'unused linker option: -lm' warning when compiling
program with -c.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D107952
Florian Mayer [Thu, 5 Aug 2021 16:03:09 +0000 (17:03 +0100)]
[hwasan] Add report for wild frees.
Reviewed By: eugenis
Differential Revision: https://reviews.llvm.org/D107577
Adrian Kuegel [Fri, 13 Aug 2021 06:22:19 +0000 (08:22 +0200)]
[clang] Adjust BUILD.bazel file to also generate AttrDocTable.
Differential Revision: https://reviews.llvm.org/D108017
luxufan [Fri, 13 Aug 2021 04:40:34 +0000 (12:40 +0800)]
[JITLink] Update ELF_x86_64 's edge kind to generic edge kind
This patch uses a switch statement to map the ELF_x86_64's edge kind to generic edge kind, and merge the ELF_x86_64 's applyFixup function to the x86_64 's applyFixup function. Some edge kinds were not have corresponding generic edge kinds, so I added three generic edge kinds asa follows:
1. RequestGOTAndTransformToDelta64, which is similar to RequestGOTAndTransformToDelta32.
2. GOTDelta64. This generic kind is similar to Delta64, except the GOTDelta64 computes the delta relative to GOTSymbol
3. RequestGOTAndTransformToGOTDelta64. This edge kind was used to deal with ELF_x86_64's GOT64 edge kind, it request the fixGOTEdge function to change the target to GOT entry, and set the edge kind to generic edge kind GOTDelta64.
These added generic edge kinds may named haphazardly, or can't express its meaning well.
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D107967
Sarah Purohit [Fri, 13 Aug 2021 04:41:35 +0000 (21:41 -0700)]
[clang][Arm] Fix the default floating point ABI for
'armv7-pc-win32-macho'
It is incorrect to select the hardware floating point ABI on Mach-O
platforms using the Windows triple if the ABI is "apcs-gnu".
rdar://
81810554
Differential Revision: https://reviews.llvm.org/D107939
Shivam Gupta [Fri, 13 Aug 2021 04:10:39 +0000 (12:10 +0800)]
[AVR] Enable machine verifier
Reviewed By: mhjacobson, benshi001
Differential Revision: https://reviews.llvm.org/D107853
Qiu Chaofan [Fri, 13 Aug 2021 04:02:32 +0000 (12:02 +0800)]
Pre-commit two-way clamp tests
Wael Yehia [Fri, 13 Aug 2021 02:02:10 +0000 (02:02 +0000)]
Add PowerPC AIX triple to indirect call VP testcase.
Michael Kruse [Fri, 13 Aug 2021 01:07:55 +0000 (20:07 -0500)]
[OMPIRBuilder] Clarify CanonicalLoopInfo. NFC.
Add in-source documentation on how CanonicalLoopInfo is intended to be used. In particular, clarify what parts of a CanonicalLoopInfo is considered part of the loop, that those parts must be side-effect free, and that InsertPoints to instructions outside those parts can be expected to be preserved after method calls implementing loop-associated directives.
CanonicalLoopInfo are now invalidated after it does not describe canonical loop anymore and asserts when trying to use it afterwards.
In addition, rename `createXYZWorkshareLoop` to `applyXYZWorkshareLoop` and remove the update location to avoid that the impression that they insert something from scratch at that location where in reality its InsertPoint is ignored. createStaticWorkshareLoop does not return a CanonicalLoopInfo anymore. First, it was not a canonical loop in the clarified sense (containing side-effects in form of calls to the OpenMP runtime). Second, it is ambiguous which of the two possible canonical loops it should actually return. It will not be needed before a feature expected to be introduced in OpenMP 6.0
Also see discussion in D105706.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D107540
Nico Weber [Fri, 13 Aug 2021 01:59:54 +0000 (21:59 -0400)]
[mailmap] Add entry for the GN LLVM syncbot
The bot did its first 43 commits under the name "GN Syncbot" before
it switched to "LLVM GN Syncbot". Use the latter as canonical name.
LLVM GN Syncbot [Fri, 13 Aug 2021 01:31:18 +0000 (01:31 +0000)]
[gn build] Port
2ff7ca98a99b
Nico Weber [Fri, 13 Aug 2021 01:29:12 +0000 (21:29 -0400)]
[gn build] manually port
18f9e25ce1fa43 (AttrDocTable)
Also clang ClangAttrEmitter for -gen-clang-attr-doc-table to be
like all other tablegen: Produce a .inc file with the generated bits
and put the static parts into a regular .cpp file that includes the
.inc file.
Giorgis Georgakoudis [Thu, 12 Aug 2021 21:47:24 +0000 (14:47 -0700)]
[OpenMP][Fix] Fix disable spmdization option
Besides SPMDization, other analysis and optimization for original, frontend-generated SPMD regions uses information from the AAKernelInfoFunction attribute. This fix makes sure disabling SPMDization through the corresponding option applies only to generic mode regions, which should not be SPMDized, while it leaves unaffected the attribute state of original SPMD regions.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D108001
Ruiling Song [Tue, 10 Aug 2021 07:59:44 +0000 (15:59 +0800)]
SplitKit: Don't further split subrange mask in buildCopy
We may use several COPY instructions to copy the needed sub-registers
during split. But the way we split the lanes during the COPYs may be
different from the subranges of the old register. This would fail when we
extend the subranges of the new register because the LaneMasks do not
match exactly between subranges of new register and old register.
Since we are bundling the COPYs, I think there is no need to further refine the
subranges of the new register based on the set of LaneMasks of the inserted COPYs.
I am not sure if there will be further breaking cases. But as the subranges of
new register are created based on the LaneMasks of the subranges of old register,
it will be highly possible we will always find an exact LaneMask match.
We can think about how to make the extendPHIKillRanges() work for
subrange mask mismatch case if we meet more such cases in the future.
The test case was from D105065 by @arsenm.
Differential Revision: https://reviews.llvm.org/D107829
Yonghong Song [Mon, 19 Jul 2021 05:58:37 +0000 (22:58 -0700)]
[Clang] add btf_tag attribute
A new attribute btf_tag is added. The syntax looks like
__attribute__((btf_tag(<string>)))
Users may tag a particular structure/member/function/func_parameter/variable
declaration with an arbitrary string and the intention is
that this string is passed to dwarf so it is available for
post-compilation analysis. The string will be also passed
to .BTF section if the target is BPF. For each permitted
declaration, multiple btf_tag's are allowed.
For detailed use cases, please see
https://lists.llvm.org/pipermail/llvm-dev/2021-June/151009.html
In case that there exist redeclarations, the btf_tag attributes
will be accumulated along with different declarations, and the
last declaration will contain all attributes.
Differential Revision: https://reviews.llvm.org/D106614
Heejin Ahn [Mon, 9 Aug 2021 04:16:55 +0000 (21:16 -0700)]
[WebAssembly] Fix leak in Emscripten SjLj
For SjLj, we allocate a table to record setjmp buffer info in the entry
of each setjmp-calling function by inserting a `malloc` call, and insert
a `free` call to free the buffer before each `ret` instruction.
But this is not sufficient; we have to free the buffer before we throw.
In SjLj handling, normal functions that can possibly throw or longjmp
are wrapped with an invoke and caught within the function so they don't
end up escaping the function. But three functions throw and escape the
function:
- `__resumeException` (Emscripten library function used for Emscripten
EH)
- `emscripten_longjmp` (Emscripten library function used for Emscripten
SjLj)
- `__cxa_throw` (libc++abi function called when for C++ `throw` keyword)
The first two functions are used to rethrow the current
exception/longjmp when the caught exception/longjmp is not for the
current function. `__cxa_throw` is used for exception, and because we
consider that a function that cannot longjmp, it escapes the function
right away, before which we should free the buffer.
Currently `lsan.test_longjmp3` and `lsan.test_exceptions_longjmp3` fail
in Emscripten; this CL fixes these.
Reviewed By: dschuff
Differential Revision: https://reviews.llvm.org/D107852
Heejin Ahn [Sat, 7 Aug 2021 04:43:55 +0000 (21:43 -0700)]
[WebAssembly] Error out when Emscripten SjLj setjmp is used with Wasm EH
Currently, when Wasm EH is used with Emscripten SjLj, Emscripten SjLj
cannot handle `invoke` instructions - it assumes all `invoke`s have been
lowered away with Emscripten EH. But in Wasm EH they are lowered in
instruction selection, so they are still present in the IR stage. This
happens when
1. Wasm EH and Emscripten SjLj are used together
2. A function that calls `setjmp` uses exceptions, i.e., has `invoke`s
We were already erroring out with an assertion failure in this case, but
this CL makes it error out more properly with a valid error message.
Wasm EH + Wasm SjLj will not have this restrictions. (it will have
another restriction though, e.g., `setjmp` cannot be called within
`catch`. But why would anyone do that..)
Reviewed By: dschuff
Differential Revision: https://reviews.llvm.org/D107687
Vitaly Buka [Thu, 12 Aug 2021 22:37:07 +0000 (15:37 -0700)]
[sanitizer] Fix the test on Solaris
On Solaris sem_open on the same name returns the same pointer, and
then sem_close fails the call.
Duncan P. N. Exon Smith [Thu, 28 Jan 2021 02:50:54 +0000 (18:50 -0800)]
Frontend: Add -f{,no-}implicit-modules-uses-lock and -Rmodule-lock
Add -cc1 flags `-fmodules-uses-lock` and `-fno-modules-uses-lock` to
allow the lock manager to be turned off when building implicit modules.
Add `-Rmodule-lock` so that we can see when it's being used.
Differential Revision: https://reviews.llvm.org/D95583
natashaknk [Thu, 12 Aug 2021 22:37:34 +0000 (15:37 -0700)]
[mlir][tosa] Fix depthwise_conv2D strides/dilation and name
Reviewed By: rsuderman
Differential Revision: https://reviews.llvm.org/D107997
Sam McCall [Fri, 6 Aug 2021 10:07:13 +0000 (12:07 +0200)]
[clangd] Avoid "expected one compiler job" by picking the first eligible job.
This happens in createInvocationWithCommandLine but only clangd currently passes
ShouldRecoverOnErorrs (sic).
One cause of this (with correct command) is several -arch arguments for mac
multi-arch support.
Fixes https://github.com/clangd/clangd/issues/827
Differential Revision: https://reviews.llvm.org/D107632
Christian Kandeler [Thu, 12 Aug 2021 22:15:03 +0000 (00:15 +0200)]
clangd: Make documentation property of completion items more similar
... to the one of signature hints.
In particular, completion items now also carry annotations, which client
code might be interested in.
Reviewed By: sammccall
Differential Revision: https://reviews.llvm.org/D107365
Duncan P. N. Exon Smith [Thu, 28 Jan 2021 02:16:51 +0000 (18:16 -0800)]
Frontend: Refactor compileModuleAndReadAST, NFC
This renames `compileModuleAndReadAST`, adding a `BehindLock` suffix,
and refactors it to significantly reduce nesting.
- Split out helpers `compileModuleAndReadASTImpl` and
`readASTAfterCompileModule` which have straight-line code that doesn't
worry about locks.
- Use `break` in the interesting cases of `switch` statements to reduce
nesting.
- Use early `return`s to reduce nesting.
Detangling the compile-and-read logic from the check-for-locks logic
should be a net win for readability, although I also have a side
motivation of making the locks optional in a follow-up.
No functionality change here.
Differential Revision: https://reviews.llvm.org/D95581
Christian Kandeler [Thu, 12 Aug 2021 22:04:19 +0000 (00:04 +0200)]
clangd: Provide hover info for include directives
It's quite useful to be able to hover over an #include and see the full
path to the header file.
Reviewed By: sammccall
Differential Revision: https://reviews.llvm.org/D107137
Sam McCall [Sat, 7 Aug 2021 15:36:26 +0000 (17:36 +0200)]
[CodeComplete] Basic code completion for attribute names.
Only the bare name is completed, with no args.
For args to be useful we need arg names. These *are* in the tablegen but
not currently emitted in usable form, so left this as future work.
C++11, C2x, GNU, declspec, MS syntax is supported, with the appropriate
spellings of attributes suggested.
`#pragma clang attribute` is supported but not terribly useful as we
only reach completion if parens are balanced (i.e. the line is not truncated)
There's no filtering of which attributes might make sense in this
grammatical context (e.g. attached to a function). In code-completion context
this is hard to do, and will only work in few cases :-(
There's also no filtering by langopts: this is because currently the
only way of checking is to try to produce diagnostics, which requires a
valid ParsedAttr which is hard to get.
This should be fairly simple to fix but requires some tablegen changes
to expose the logic without the side-effect.
Differential Revision: https://reviews.llvm.org/D107696
Sam McCall [Tue, 10 Aug 2021 15:56:32 +0000 (17:56 +0200)]
[Attributes]: refactor to expose ParsedAttrInfo::acceptsLangOpts. NFC
We will use this function to filter code completion of attributes.
Differential Revision: https://reviews.llvm.org/D107836
Sam McCall [Tue, 2 Mar 2021 21:26:29 +0000 (22:26 +0100)]
[clangd] Overload bundles are only deprecated if each overloads is.
Fixes https://github.com/clangd/clangd/issues/705
Differential Revision: https://reviews.llvm.org/D97803
Jason Molenda [Thu, 12 Aug 2021 21:29:30 +0000 (14:29 -0700)]
Symbolicate aarch64 adrp+add pc-relative addr in disass
On aarch64 a two instruction sequence is used to calculate a
pc-relative address, add some state to the DisassemblerLLVMC
symbolicator so it can track the necessary data across the
two instructions and compute the address being calculated.
Differential Revision: https://reviews.llvm.org/D107213
rdar://
49119253
Lei Huang [Wed, 28 Jul 2021 20:34:17 +0000 (15:34 -0500)]
[PowerPC] Implement XL compatibility builtin __addex
Add builtin and intrinsic for `__addex`.
This patch is part of a series of patches to provide builtins for
compatibility with the XL compiler.
Reviewed By: stefanp, nemanjai, NeHuang
Differential Revision: https://reviews.llvm.org/D107002
Michael Jones [Thu, 12 Aug 2021 18:29:58 +0000 (18:29 +0000)]
[libc][nfc] add CPP Limits.h for numeric_limits
Add an implementation of numeric_limits for use in str_conv_utils.
It currently only supports the basic integer types, with more types
coming as needed.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D107987
Chia-hung Duan [Thu, 12 Aug 2021 17:35:00 +0000 (17:35 +0000)]
[mlir-tblgen] Minor Refactor for StaticVerifierFunctionEmitter.
Move StaticVerifierFunctionEmitter to CodeGenHelper.h so that it can be
used for both ODS and DRR.
Reviewed By: jpienaar
Differential Revision: https://reviews.llvm.org/D106636
Vyacheslav Zakharin [Thu, 12 Aug 2021 18:14:41 +0000 (11:14 -0700)]
[openmp][ELF] Recognize LLVM OpenMP offload specific notes
The new ELF notes are added in clang-offload-wrapper, and llvm-readobj has to visualize them properly.
Differential Revision: https://reviews.llvm.org/D99552
Heejin Ahn [Thu, 12 Aug 2021 01:18:13 +0000 (18:18 -0700)]
[WebAssembly] Disable offset folding for function addresses
Wasm does not support function addresses with offsets, but isel can
generate folded SDValues in the form of (@func + offset) without this
patch.
Fixes https://bugs.llvm.org/show_bug.cgi?id=43133.
Reviewed By: dschuff, sbc100
Differential Revision: https://reviews.llvm.org/D107940
Thomas Preud'homme [Fri, 6 Aug 2021 20:53:19 +0000 (21:53 +0100)]
[clang/test] Run thinlto-clang-diagnostic-handler-in-be.c on x86
Clang test CodeGen/thinlto-clang-diagnostic-handler-in-be.c fails on
some non x86 targets, e.g. hexagon. Since the test already requires x86
to be available as a target this commit forces the target to x86_64.
Reviewed By: steven_wu
Differential Revision: https://reviews.llvm.org/D107667
Sanjay Patel [Thu, 12 Aug 2021 20:18:13 +0000 (16:18 -0400)]
[InstCombine] factorize min/max intrinsic ops with common operand (2nd try)
This is a re-try of
6de1dbbd09c1 which was reverted because
it missed a null check. Extra test for that failure added.
Original commit message:
This is an adaptation of D41603 and another step on the way
to canonicalizing to the intrinsic forms of min/max.
See D98152 for status.
peter klausler [Thu, 12 Aug 2021 18:10:53 +0000 (11:10 -0700)]
[flang] Correct off-by-one error in SET_EXPONENT
SET_EXPONENT is returning values that are too large by a factor
of two.
Differential Revision: https://reviews.llvm.org/D107986
Craig Topper [Thu, 12 Aug 2021 19:33:54 +0000 (12:33 -0700)]
[RISCV] Improve check prefixes in B extension tests. NFC
-Add Z for the B extension subextensions.
-Don't mention I along with B or its sub extensions.
This is based on comments in D107817.
Differential Revision: https://reviews.llvm.org/D107992
Amy Huang [Thu, 12 Aug 2021 19:34:14 +0000 (12:34 -0700)]
Revert "[InstCombine] factorize min/max intrinsic ops with common operand"
This reverts commit
6de1dbbd09c12abbec7eb187ffa1afbd47302dfa because it causes a
compiler crash.
Andrzej Warzynski [Thu, 12 Aug 2021 16:11:54 +0000 (16:11 +0000)]
[flang] Disable Plugins in out-of-tree builds
https://reviews.llvm.org/D106137 added support for plugins in Flang. The
CMake configuration for plugins requires some LLVM variables that are
not available in out-of-tree builds (e.g. `LLVM_SHLIB_OUTPUT_INTDIR`).
This has caused the out-of-tree BuildBot worker to start failing:
* https://lab.llvm.org/buildbot/#/builders/175
This patch effectively disables plugins in out-of-tree builds and fixes
the configuration error. In order to support plugins in out-of-tree
builds, we would have to find a way to access the missing CMake
variables from LLVM. This could be implemented at a later time.
Differential Revision: https://reviews.llvm.org/D107973
Sam McCall [Sat, 7 Aug 2021 22:41:40 +0000 (00:41 +0200)]
[AST][clangd] Expose documentation of Attrs on hover.
This adds a method to Attr to get at the documentation programmatically.
Differential Revision: https://reviews.llvm.org/D107703
Vitaly Buka [Wed, 11 Aug 2021 17:35:23 +0000 (10:35 -0700)]
[unwind] Handle UNW_X86_64_RIP register
In some binaries, built with clang/lld, libunwind crashes
with "unsupported x86_64 register" for regNum == 16:
Differential Revision: https://reviews.llvm.org/D107919
Michael Kruse [Thu, 12 Aug 2021 18:34:02 +0000 (13:34 -0500)]
[Polly] Fix compiler warnings. NFC.
Bill Wendling [Thu, 12 Aug 2021 18:29:48 +0000 (11:29 -0700)]
[llvm-diff] correct variable typo
Bill Wendling [Thu, 12 Aug 2021 18:23:57 +0000 (11:23 -0700)]
[llvm-diff] add "reset" method to DiffConsumer
A DiffConsumer object may be reused, but we'd like to reset it before
the next use.
No functionality change intended.
Differential Revision: https://reviews.llvm.org/D107985
Aart Bik [Thu, 12 Aug 2021 01:23:10 +0000 (18:23 -0700)]
[mlir][sparse][python] add an "exhaustive" sparse test using python
Using the python API to easily set up sparse kernels, this test
exhaustively builds, compilers, and runs SpMM for all annotations
on a sparse tensor, making sure every version generates the correct
result. This test also illustrates using the python API to set up
a sparse kernel and sparse compilation.
Reviewed By: bixia
Differential Revision: https://reviews.llvm.org/D107943
Vyacheslav Zakharin [Thu, 12 Aug 2021 18:01:41 +0000 (11:01 -0700)]
[NFC] Enumerate LLVMOMPOFFLOAD note types.
It is a NFC to enumerate types of LLVMOMPOFFLOAD ELF notes.
Differential Revision: https://reviews.llvm.org/D99612
Ivan Zhechev [Thu, 12 Aug 2021 17:04:29 +0000 (18:04 +0100)]
[Flang] Fix error messages on Windows.
Flang uses positional arguments for `messages::say()`, such as "%1$s" which is only supported in MS Compilers with the `_*printf_p` form of the function. This uses a conditional macro to convert the existing `vsnprintf` used to the one needed in MS-World.
7 tests in D107575 rely on this change.
Reviewed By: Meinersbur
Differential Revision: https://reviews.llvm.org/D107654
Florian Hahn [Thu, 12 Aug 2021 12:21:35 +0000 (13:21 +0100)]
Recommit "[Matrix] Overload stride arg in matrix.columnwise.load/store."
This reverts the revert
28c04794df74ad3c38155a244729d1f8d57b9400.
The failing MLIR test that caused the revert should be fixed in this
version.
Also includes a PPC test fix previously in
1f87c7c478a6.
Louis Dionne [Mon, 9 Aug 2021 22:08:39 +0000 (18:08 -0400)]
[libc++] Remove Lit annotations for unsupported GCC versions from the test suite
Since we officially don't support several older compilers now, we can
drop a lot of the markup in the test suite. This helps keep the test
suite simple and makes sure that UNSUPPORTED annotations don't rot.
This is the first patch of a series that will remove annotations for
compilers that are now unsupported.
Differential Revision: https://reviews.llvm.org/D107787
LLVM GN Syncbot [Thu, 12 Aug 2021 17:16:05 +0000 (17:16 +0000)]
[gn build] Port
4ac87e33785e
Kiran Chandramohan [Thu, 12 Aug 2021 16:42:29 +0000 (17:42 +0100)]
[Flang] Fix build failure on MacOS
std::clock_t can be an unsigned value on some platforms like MacOS and
therefore needs a cast when initializing an std::clock_t value with -1.
Reviewed By: klausler
Differential Revision: https://reviews.llvm.org/D107972
Craig Topper [Thu, 12 Aug 2021 17:08:07 +0000 (10:08 -0700)]
[RISCV] Add test cases showing inefficient materialization for stores of immediates. NFC
DAGCombiner::visitStore can call GetDemandedBits which will remove
upper bits from immediates. The upper bits are important for good
materialization of negative constants on RISCV. GetDemandedBits is a
different mechanism than SimplifyDemandedBits so
TargetShrinkDemandedConstant can't block it.
As far as I know this behavior is unique to stores.
I think we can fix this in isel using a concept similar to D107658.
Reviewed By: frasercrmck
Differential Revision: https://reviews.llvm.org/D107860
zoecarver [Wed, 11 Aug 2021 18:16:27 +0000 (11:16 -0700)]
[libcxx][ranges] Add `unreachable_sentinel`.
Differential Revision: https://reviews.llvm.org/D107920
Craig Topper [Thu, 12 Aug 2021 16:39:55 +0000 (09:39 -0700)]
[RISCV] Teach vsetvli insertion pass that it doesn't need to insert vsetvli for unit-stride or strided loads/stores in some cases.
For unit-stride and strided load/stores we set the SEW operand of
the pseudo instruction equal the EEW in the opcode. The LMUL
of the pseudo instruction is the LMUL we want.
These instructions calculate EMUL=(EEW/SEW) * LMUL. We can use
this to avoid changing vtype if the SEW/LMUL of the previous
vtype matches the EEW/EMUL ratio we need for the instruction.
Due to how the global analysis works, we can only do this
optimization when the previous vsetvli was produced in the block
containing the store. We need to know in the first phase if the
vsetvli will be inserted so we can propagate information to
the successors in the second phase correctly. This means we can't
depend on predecessors.
Reviewed By: rogfer01
Differential Revision: https://reviews.llvm.org/D106601
Craig Topper [Thu, 12 Aug 2021 16:03:41 +0000 (09:03 -0700)]
[Sema] Fix -Wparentheses warning from gcc. NFC
Craig Topper [Thu, 12 Aug 2021 15:52:20 +0000 (08:52 -0700)]
[RISCV] Use getNaturalPointeeTypeAlignment to get alignment for stores created for vector builtins.
Instead of using scalar size divided by 8 for segment loads, get
the alignment from clang's type system.
Make vleff match for consistency.
Also replace uses of getPointerElementType() which will be removed as part of the OpaquePtr changes.
Reviewed By: HsiangKai
Differential Revision: https://reviews.llvm.org/D106738
Roman Lebedev [Thu, 12 Aug 2021 17:02:48 +0000 (20:02 +0300)]
[NFCI][SimplifyCFG] simplifyCondBranch(): assert that branch is non-tautological
We really shouldn't deal with a conditional branch that can be trivially
constant-folded into an unconditional branch.
Indeed, barring failure to trigger BB reprocessing, that should be true,
so let's assert as much, and hope the assertion never fires.
If it does, we have a bug to fix.
Roman Lebedev [Thu, 12 Aug 2021 16:45:11 +0000 (19:45 +0300)]
[SimplifyCFG] If FoldTwoEntryPHINode() changed things, restart
Mainly, i want to add an assertion that `SimplifyCFGOpt::simplifyCondBranch()`
doesn't get asked to deal with non-unconditional branches,
and if i do that, then said assertion fires on existing tests,
and this is what prevents it from firing.
Kazu Hirata [Thu, 12 Aug 2021 16:53:49 +0000 (09:53 -0700)]
[DWARF] Remove getMaxLineIncrementForSpecialOpcode (NFC)
The function was introduced without a use on Sep 16, 2011 in
commit
5acab501de113acb4c0d28b48e76c27631ba0904.
Jon Chesterfield [Thu, 12 Aug 2021 16:44:36 +0000 (17:44 +0100)]
Revert "[openmp] Annotate tmp variables with omp_thread_mem_alloc"
This reverts commit
b6113548c9217fb8a6d0e9ac5bef5584c1aa614d.
Sanjay Patel [Thu, 12 Aug 2021 16:35:39 +0000 (12:35 -0400)]
[InstCombine] fold umax/umin intrinsics based on demanded bits
This is a direct translation of the select folds added with
D53033 / D53036 and another step towards canonicalization
using the intrinsics (see D98152).
Sanjay Patel [Thu, 12 Aug 2021 16:18:21 +0000 (12:18 -0400)]
[InstCombine] add test for umax/umin intrinsic demanded bits; NFC
peter klausler [Tue, 10 Aug 2021 19:16:40 +0000 (12:16 -0700)]
[flang] Fix crash in runtime-type-info.cpp
Recent work in runtime assignments failed an assertion in fir-dev
while running tests (flang/test/Semantics/defined-ops.f90). This
test didn't fail in llvm-project/main because only the "new" Arm
driver is used now, and that only builds runtime derived type information
tables when some debug dumping options are enabled.
So add a reproducing test case to another test that is run with
-fdebug-dump-symbols, and fix the crash by emitting special procedure
binding information only for type-bound generic ASSIGNMENT(=) bindings
that are relevant to the runtime support library for use in intrinsic
assignment of derived types.
Differential Revision: https://reviews.llvm.org/D107918
Fangrui Song [Thu, 12 Aug 2021 16:31:31 +0000 (09:31 -0700)]
[crt][test] Make ctor_dtor.c robust if DT_INIT/DT_FINI is disabled
New ports in glibc typically don't define ELF_INITFINI, so
DT_INIT/DT_FINI support is disabled.
(rhel ppc64le likely patches their glibc this way as well.)
musl can disable DT_INIT/DT_FINI via -DNO_LEGACY_INITFINI.
So we cannot guarantee ctor()/dtor() will be printed.
Jon Chesterfield [Thu, 12 Aug 2021 16:30:22 +0000 (17:30 +0100)]
[openmp] Annotate tmp variables with omp_thread_mem_alloc
Fixes miscompile of calls into ocml. Bug 51445.
The stack variable `double __tmp` is moved to dynamically allocated shared
memory by CGOpenMPRuntimeGPU. This is usually fine, but when the variable
is passed to a function that is explicitly annotated address_space(5) then
allocating the variable off-stack leads to a miscompile in the back end,
which cannot decide to move the variable back to the stack from shared.
This could be fixed by removing the AS(5) annotation from the math library
or by explicitly marking the variables as thread_mem_alloc. The cast to
AS(5) is still a no-op once IR is reached.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D107971
maekawatoshiki [Thu, 12 Aug 2021 15:53:03 +0000 (00:53 +0900)]
[LICM] Support sinking in LNICM
Currently, LNICM pass does not support sinking instructions out of loop nest.
This patch enables LNICM to sink down as many instructions to the exit block of outermost loop as possible.
Reviewed By: Whitney
Differential Revision: https://reviews.llvm.org/D107219