Commit Graph

86826 Commits

Author SHA1 Message Date
Aaron En Ye Shi cd5897d559 [HIP] Fix static-lib test CHECK bug
Fix hip test failures that were introduced by
previous changes to hip-toolchain-rdc-static-lib.hip
test. The .*lld.* is matching a longer string than
expected.

Differential Revision: https://reviews.llvm.org/D92342
2020-12-01 15:49:39 +00:00
Sven van Haastregt 523775f967 [OpenCL] Allow pointer-to-pointer kernel args beyond CL 1.2
The restriction on pointer-to-pointer kernel arguments has been
relaxed in OpenCL 2.0.  Apply the same address space restrictions for
pointer argument types to the inner pointer types.

Differential Revision: https://reviews.llvm.org/D92091
2020-12-01 11:33:10 +00:00
Kadir Cetinkaya e98d3be11c
[clang] Enable code completion of designated initializers in Compound Literal Expressions
PreferedType were not set when parsing compound literals, hence
designated initializers were not available as code completion suggestions.

This patch sets the preferedtype to parsed type for the following initializer
list.

Fixes https://github.com/clangd/clangd/issues/142.

Differential Revision: https://reviews.llvm.org/D92370
2020-12-01 12:06:48 +01:00
Jan Svoboda 398b729243 [clang][cli] Port HeaderSearch option flags to new option parsing system
Depends on D83697.

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D83940
2020-12-01 10:52:00 +01:00
David Chisnall d1ed67037d [GNU ObjC] Fix a regression listing methods twice.
Methods synthesized from declared properties were being added to the
method lists twice.  This came from the change to list them in the
class's method list, which missed removing the place in CGObjCGNU that
added them again.

Reviewed By: lanza

Differential Revision: https://reviews.llvm.org/D91874
2020-12-01 09:50:18 +00:00
Jan Svoboda 8e41a688a5 [clang][cli] Port DependencyOutput option flags to new option parsing system
Depends on D91861.

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D83694
2020-12-01 10:36:12 +01:00
Jan Svoboda 2b84efa000 [clang][cli] Port Frontend option flags to new option parsing system
Depends on D91861.

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D83697
2020-12-01 10:02:08 +01:00
Jan Svoboda 88ab38449b [clang][cli] Split DefaultAnyOf into a default value and ImpliedByAnyOf
This makes the options API composable, allows boolean flags to imply non-boolean values and makes the code more logical (IMO).

Differential Revision: https://reviews.llvm.org/D91861
2020-12-01 09:50:11 +01:00
Jan Svoboda 973843681b [clang][cli] Factor out call to EXTRACTOR in generateCC1CommandLine (NFC)
Reviewed By: Bigcheese, dexonsmith

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D83211
2020-12-01 09:24:04 +01:00
Wei Wang 93dc1b5b8c [Remarks][2/2] Expand remarks hotness threshold option support in more tools
This is the #2 of 2 changes that make remarks hotness threshold option
available in more tools. The changes also allow the threshold to sync with
hotness threshold from profile summary with special value 'auto'.

This change expands remarks hotness threshold option
-fdiagnostics-hotness-threshold in clang and *-remarks-hotness-threshold in
other tools to utilize hotness threshold from profile summary.

Remarks hotness filtering relies on several driver options. Table below lists
how different options are correlated and affect final remarks outputs:

| profile | hotness | threshold | remarks printed |
|---------|---------|-----------|-----------------|
| No      | No      | No        | All             |
| No      | No      | Yes       | None            |
| No      | Yes     | No        | All             |
| No      | Yes     | Yes       | None            |
| Yes     | No      | No        | All             |
| Yes     | No      | Yes       | None            |
| Yes     | Yes     | No        | All             |
| Yes     | Yes     | Yes       | >=threshold     |

In the presence of profile summary, it is often more desirable to directly use
the hotness threshold from profile summary. The new argument value 'auto'
indicates threshold will be synced with hotness threshold from profile summary
during compilation. The "auto" threshold relies on the availability of profile
summary. In case of missing such information, no remarks will be generated.

Differential Revision: https://reviews.llvm.org/D85808
2020-11-30 21:55:50 -08:00
Yaxun (Sam) Liu 011bf4f556 Add help text for -nogpuinc
Differential Revision: https://reviews.llvm.org/D92339
2020-11-30 22:31:16 -05:00
Leonard Chan 7bc944c102 Revert "[clang][Fuchsia] Add relative-vtables multilib"
This reverts commit fdbd84c6c8.

Reverting due to failing CI builders for Fuchsia's toolchain:
https://luci-milo.appspot.com/p/fuchsia/builders/ci/clang-linux-x64/b8862150211240186992?
2020-11-30 19:21:35 -08:00
Leonard Chan fdbd84c6c8 [clang][Fuchsia] Add relative-vtables multilib
This adds multilibs for Fuchsia that is built with the relative vtables ABI,
one with and another without exceptions.

Differential Revision: https://reviews.llvm.org/D85576
2020-11-30 18:21:10 -08:00
Leonard Chan a160189c5d Revert "[clang][Fuchsia] Add relative-vtables multilib"
This reverts commit 7c2bc3b71d.

Forgot to add the ifferential revision.
2020-11-30 18:20:01 -08:00
Leonard Chan 7c2bc3b71d [clang][Fuchsia] Add relative-vtables multilib
This adds a multilib for Fuchsia that is built with the relative vtables
ABI.
2020-11-30 18:17:38 -08:00
Duncan P. N. Exon Smith f85db7f7ba Lex: Update Module::findHeader to return FileEntryRef, NFC
Update `Module::findHeader` to return `Optional<FileEntryRef>` and
fix its one caller.

Differential Revision: https://reviews.llvm.org/D90485
2020-11-30 17:13:03 -08:00
Nico Weber 61da501b6a clang/test: Remove platform-linker feature
By explicitly requesting the system linker with `-fuse-ld=`, the
tests are able to CHECK for the system linker even with
CLANG_DEFAULT_LINKER=lld.

Alternative to D74704.

Differential Revision: https://reviews.llvm.org/D92291
2020-11-30 20:00:46 -05:00
Reid Kleckner 43b5b485a2 Fix GCC 5.3 compile error in ASTImporter code
Try to simplify this code a different way: use less Expected, more
outparams.
2020-11-30 16:29:29 -08:00
Leonard Chan cf8ff75bad [clang][RelativeVTablesABI] Use dso_local_equivalent rather than emitting stubs
Thanks to D77248, we can bypass the use of stubs altogether and use PLT
relocations if they are available for the target. LLVM and LLD support the
R_AARCH64_PLT32 relocation, so we can also guarantee a static PLT relocation on AArch64.
Not emitting these stubs saves a lot of extra binary size.

Differential Revision: https://reviews.llvm.org/D83812
2020-11-30 16:02:35 -08:00
Duncan P. N. Exon Smith 94f537c6b2 Remove dead code added in ac49500cd0, NFC
This was a copy/paste bug; `M0` is never referenced later.
2020-11-30 14:50:46 -08:00
Duncan P. N. Exon Smith 1b042de5b2 FileManager: Add FileEntryRef::getDir, returning DirectoryEntryRef
Add `FileEntryRef::getDir`, which returns a `DirectoryEntryRef`. This
includes a few changes:

- Customize `OptionalStorage` so that `Optional<DirectoryEntryRef>` is
  pointer-sized (like the change made to `Optional<FileEntryRef>`).
  Factored out a common class, `FileMgr::MapEntryOptionalStorage`, to
  reduce the code duplication.
- Store an `Optional<DirectoryEntryRef>` in `FileEntryRef::MapValue`.
  This is set if and only if `MapValue` has a real `FileEntry`.
- Change `FileManager::getFileRef` and `getVirtualFileRef` to use
  `getDirectoryRef` and store it in the `StringMap` for `FileEntryRef`.

Differential Revision: https://reviews.llvm.org/D90484
2020-11-30 14:50:46 -08:00
Duncan P. N. Exon Smith ac40a2d8f1 Serialization: Change InputFile to use FileEntryRef and add getVirtualFileRef, NFC
Change the `InputFile` class to store `Optional<FileEntryRef>` instead
of `FileEntry*`. This paged in a few API changes:

- Added `FileManager::getVirtualFileRef`, and converted `getVirtualFile`
  to a wrapper of it.
- Updated `SourceManager::bypassFileContentsOverride` to take
  `FileEntryRef` and return `Optional<FileEntryRef>`
  (`ASTReader::getInputFile` is the only caller).

Differential Revision: https://reviews.llvm.org/D90053
2020-11-30 14:04:48 -08:00
Aaron En Ye Shi f89e9c8201 [HIP] Fix HIP test on windows due to lld suffix
On Windows, lld is instead named lld.exe, therefore
a few HIP tests are failing. Instead the wildcard should
be modified to .*lld.* to handle .exe. This fixes the
bug: https://bugs.llvm.org/show_bug.cgi?id=48289.

Differential Revision: https://reviews.llvm.org/D92342
2020-11-30 21:05:26 +00:00
Fangrui Song 164410324d [CodeGen] -fno-delete-null-pointer-checks: change dereferenceable to dereferenceable_or_null
After D17993, with -fno-delete-null-pointer-checks we add the dereferenceable attribute to the `this` pointer.

We have observed that one internal target which worked before fails even with -fno-delete-null-pointer-checks.
Switching to dereferenceable_or_null fixes the problem.

dereferenceable currently does not always respect NullPointerIsValid and may
imply nonnull and lead to aggressive optimization. The optimization may be
related to `CallBase::isReturnNonNull`, `Argument::hasNonNullAttr`, or
`Value::getPointerDereferenceableBytes`. See D66664 and D66618 for some discussions.

Reviewed By: bkramer, rsmith

Differential Revision: https://reviews.llvm.org/D92297
2020-11-30 12:44:35 -08:00
Yitzhak Mandelbaum fdff677a95 [libTooling] Remove deprecated Clang Transformer declarations
A number of declarations were leftover after the move from `clang::tooling` to
`clang::transformer`. This patch removes those declarations and upgrades the
handful of references to the deprecated declarations.

Differential Revision: https://reviews.llvm.org/D92340
2020-11-30 20:15:26 +00:00
Mircea Trofin 5fe10263ab [llvm][inliner] Reuse the inliner pass to implement 'always inliner'
Enable performing mandatory inlinings upfront, by reusing the same logic
as the full inliner, instead of the AlwaysInliner. This has the
following benefits:
- reduce code duplication - one inliner codebase
- open the opportunity to help the full inliner by performing additional
function passes after the mandatory inlinings, but before th full
inliner. Performing the mandatory inlinings first simplifies the problem
the full inliner needs to solve: less call sites, more contextualization, and,
depending on the additional function optimization passes run between the
2 inliners, higher accuracy of cost models / decision policies.

Note that this patch does not yet enable much in terms of post-always
inline function optimization.

Differential Revision: https://reviews.llvm.org/D91567
2020-11-30 12:03:39 -08:00
Hongtao Yu c083fededf [CSSPGO] A Clang switch -fpseudo-probe-for-profiling for pseudo-probe instrumentation.
This change introduces a new clang switch `-fpseudo-probe-for-profiling` to enable AutoFDO with pseudo instrumentation. Please refer to https://reviews.llvm.org/D86193 for the whole story.

One implication from pseudo-probe instrumentation is that the profile is now sensitive to CFG changes. We perform the pseudo instrumentation very early in the pre-LTO pipeline, before any CFG transformation. This ensures that the CFG instrumented and annotated is stable and optimization-resilient.

The early instrumentation also allows the inliner to duplicate probes for inlined instances. When a probe along with the other instructions of a callee function are inlined into its caller function, the GUID of the callee function goes with the probe. This allows samples collected on inlined probes to be reported for the original callee function.

Reviewed By: wmi

Differential Revision: https://reviews.llvm.org/D86502
2020-11-30 10:16:54 -08:00
Zarko Todorovski bc7b2688d6 Add -fintegrated-as to second invocation of clang in test case. 2020-11-30 12:15:25 -05:00
Balazs Benics ee073c7985 [analyzer][StdLibraryFunctionsChecker] Fix typos in summaries of mmap and mmap64
The fd parameter of
```
void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
```
should be constrained to the range [0, IntMax] as that is of type int.
Constraining to the range [0, Off_tMax] would result in a crash as that is
of a signed type with the value of 0xff..f (-1).

The crash would happen when we try to apply the arg constraints.
At line 583: assert(Min <= Max), as 0 <= -1 is not satisfied

The mmap64 is fixed for the same reason.

Reviewed By: martong, vsavchenko

Differential Revision: https://reviews.llvm.org/D92307
2020-11-30 18:06:28 +01:00
Kevin P. Neal abfbc5579b [FPEnv] clang should get from the AST the metadata for constrained FP builtins
Currently clang is not correctly retrieving from the AST the metadata for
constrained FP builtins. This patch fixes that for the non-target specific
builtins.

Differential Revision: https://reviews.llvm.org/D92122
2020-11-30 11:59:37 -05:00
Gabor Marton 70eb2ce395 [ASTImporter] Support import of CXXDeductionGuideDecl
CXXDeductionGuideDecl is a FunctionDecl, but its constructor should be called
appropriately, at least to set the kind variable properly.

Differential Revision: https://reviews.llvm.org/D92109
2020-11-30 17:55:25 +01:00
Ben Dunbobbin d5aaf60214 [windows-itanium] handle dllimport/export code paths separately and share with PS4
Similar to Windows Itanium, PS4 is also an Itanium C++ ABI variant
which shares the goal of semantic compatibility with Microsoft C++
code that uses dllimport/export.

This change introduces a new function to determine from the triple
if an environment aims for compatibility with MS C++ code w.r.t to
these attributes and guards the relevant code paths using that
function.

Differential Revision: https://reviews.llvm.org/D90299
2020-11-30 14:36:39 +00:00
Kazushi (Jam) Marukawa 33eac0f283 [VE] Specify vector alignments
Specify alignments for all vector types.  Update a regression test also.

Reviewed By: simoll

Differential Revision: https://reviews.llvm.org/D92256
2020-11-30 22:09:21 +09:00
David Spickett b5fbc60e4d [clang-format] State where clang-format-diff.py should be run from
At least with git, file paths in a diff will be relative
to the repo root. So if you are in "llvm-project/lldb"
and the diff shows "clang/foo" modified you get:
No such file or directory

From clang-format-diff.py, since clang-format was
asked to read:
llvm-project/lldb/clang/foo

Add a note to the docs to explain this.

(there is `git diff --relative` but that excludes
changes outside of the current dir)

Reviewed By: sylvestre.ledru

Differential Revision: https://reviews.llvm.org/D91799
2020-11-30 10:00:49 +00:00
Haojian Wu c219282854 [AST][RecoveryAST] Preseve more invalid return stmt.
suppress the diagnostics for missing return stmt in constexpr func.

Differential Revision: https://reviews.llvm.org/D82284
2020-11-30 09:26:41 +01:00
Haojian Wu ec6c5e920a [clang] Improve diagnostics for auto-return-type function if the return expr had an error.
Given the following case:

```
auto k() {
  return undef();
  return 1;
}
```

Prior to the patch, clang emits an `cannot initialize return object of type
'auto' with an rvalue of type 'int'` diagnostic on the second return
(because the return type of the function cannot be deduced from the first contain-errors return).

This patch suppresses this error.

Differential Revision: https://reviews.llvm.org/D92211
2020-11-30 09:19:15 +01:00
Richard Smith 1db60c1307 Remove redundant check for access in the conversion from the naming
class to the declaring class in a class member access.

This check does not appear to be backed by any rule in the standard (the
rule in question was likely removed over the years), and only ever
produces duplicate diagnostics. (It's also not meaningful because there
isn't a unique declaring class after the resolution of core issue 39.)
2020-11-29 19:21:59 -08:00
Juneyoung Lee 53040a968d [ConstantFold] Fold more operations to poison
This patch folds more operations to poison.

Alive2 proof: https://alive2.llvm.org/ce/z/mxcb9G (it does not contain tests about div/rem because they fold to poison when raising UB)

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D92270
2020-11-29 21:19:48 +09:00
Zarko Todorovski 979bcbd3a6 Add -fintegrated-as to clang invocation
On platforms where the integrated as isn't called by default this
test fails since the output is not what it expects.  Adding this
option generates the expected output on those platforms as well.
2020-11-27 15:54:37 -05:00
Andre Vieira a4b80efea9 [AArch64] Define __ARM_FEATURE_{CRC32,ATOMICS}
This patch implements the definition of __ARM_FEATURE_ATOMICS and fixes the
missing definition of __ARM_FEATURE_CRC32 for Armv8.1-A.

Differential Revision: https://reviews.llvm.org/D91438
2020-11-27 17:42:43 +00:00
Zarko Todorovski ff8e8c1b14 [AIX] Enabling vector type arguments and return for AIX
This patch enables vector type arguments on AIX.  All non-aggregate Altivec vector types are 16bytes in size and are 16byte aligned.

Reviewed By: Xiangling_L

Differential Revision: https://reviews.llvm.org/D92117
2020-11-27 09:55:52 -05:00
Hans Wennborg 0ce32a7982 Revert "[ASTMatchers] Matcher macros with params move params instead of copying"
This broke some clang matcher tests in 32-bit MSVC builds; see PR46781.

> Summary: Use move semantics instead of copying for AST Matchers with parameters
>
> Reviewers: aaron.ballman, gribozavr2
>
> Reviewed By: gribozavr2
>
> Subscribers: cfe-commits
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D75096

This reverts commit 3e9a7b2ba4.
2020-11-27 14:51:27 +01:00
Erik Tomusk 7793db35ca [OpenCL] Check for extension string extension lookup
Calling any of the OpenCLOptions::is*() functions (except isKnown())
with an unknown extension string results in a seg fault. This patch
checks that the extension exists in the map before attempting to access
it.

Reviewed By: Anastasia

Differential Revision: https://reviews.llvm.org/D90928
2020-11-27 13:16:39 +00:00
Raphael Isemann 89c1a7a67d [ASTImporter] Import the default argument of NonTypeTemplateParmDecl
The test case isn't using the AST matchers for all checks as there doesn't seem to be support for
matching NonTypeTemplateParmDecl default arguments. Otherwise this is simply importing the
default arguments.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D92106
2020-11-27 11:40:07 +01:00
Richard Sandiford a2d561f1a3 [SVE] Add a couple of extra sizeless type tests
This patch adds tests for things that happened to be fixed by previous
patches, but that should continue working if we do decide to treat
sizeless types as incomplete types.

Differential Revision: https://reviews.llvm.org/D79584
2020-11-27 10:33:47 +00:00
Raphael Isemann 3f6c856bb5 [ASTImporter] Import the default argument of TemplateTypeParmDecl
The test case isn't using the AST matchers for all checks as there doesn't seem to be support for
matching TemplateTypeParmDecl default arguments. Otherwise this is simply importing the
default arguments.

Also updates several LLDB tests that now as intended omit the default template
arguments of several std templates.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D92103
2020-11-26 18:01:30 +01:00
Jan Svoboda a325856686 [clang][cli] Port Target option flags to new option parsing system
Depends on D83697

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D83698
2020-11-26 15:32:38 +01:00
Raphael Isemann 39a5dd164c [ASTImporter] Import the default argument of TemplateTemplateParmDecl
Same idea as in D92103 and D92106, but I realised after creating those reviews that there are
also TemplateTemplateParmDecls that can have default arguments, so here's hopefully the
last patch for default template arguments.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D92119
2020-11-26 15:12:45 +01:00
Hafiz Abid Qadeer 45ba2392d7 [clang][Driver] Handle risvc in Baremetal.cpp.
I am working on a baremetal riscv toolchain using LLVM runtime and
LLD linker. Baremetal.cpp provides most of the things needed for such
toolchain. So I have modified it to also handle riscv64/32-unknown-elf
 targets alongside arm-none-eabi.

Currently, targets like riscv64-unknown-elf are handled by RISCVToolChain
which mostly expects a gcc toolchain to be present. If you dont
want the dependency on gcc-toolchain/libgloss or want to use LLD, then
RISCVToolChain is not a good fit.

So in the toolchain selection code, I have made this dependency of
RISCVToolChain on gcc toolchain explicit. It is created if gcc-toolchain
option is present. Otherwise Baremetal toolchain is created. I will be
happy to hear if there is a better way to choose between these two
toolchains.

Reviewed By: jroelofs

Differential Revision: https://reviews.llvm.org/D91442
2020-11-26 11:43:17 +00:00
Richard Smith 7c327db3ef Part of C++ DR 39: a class member lookup is not ambiguous if it finds the
same type in multiple base classes.

Not even if the type is introduced by distinct declarations (for
example, two typedef declarations, or a typedef and a class definition).
2020-11-25 17:03:11 -08:00