Commit Graph

390142 Commits

Author SHA1 Message Date
peter klausler f8f7002828 [flang] Catch procedure pointer interface error
A procedure pointer is allowed to name a specific intrinsic function
from F'2018 table 16.2 as its interface, but not other intrinsic
procedures.  Catch this error, and thereby also fix a crash resulting
from a failure later in compilation from failed characteristics;
while here, also catch the similar error with initializers.

Differential Revision: https://reviews.llvm.org/D103570
2021-06-03 14:02:42 -07:00
Fangrui Song da3ed58b97 [test] Update more clang/test/Profile tests 2021-06-03 13:43:19 -07:00
Julien Pagès 37821155c9 [AMDGPU] Fix a crash when selecting a particular case of buffer_load_format_d16
In this particular example, we had a crash when compiling it
for several architectures. This patch extends the legalization
of extract_subvector to avoid this problem.

Differential Revision: https://reviews.llvm.org/D103344
2021-06-03 16:40:18 -04:00
Fangrui Song ba1fb0ff8c [test] Update c-linkage-available_externally.c 2021-06-03 13:40:01 -07:00
peter klausler e7a53f1e04 [flang] Accept BOZ in array constructors w/o types
As a benign extension common to other Fortran compilers,
accept BOZ literals in array constructors w/o explicit
types, treating them as integers.

Differential Revision: https://reviews.llvm.org/D103569
2021-06-03 13:37:11 -07:00
Jinsong Ji cd9e1a020c [Constants][PowerPC] Check exactlyValue for ppc_fp128 in isNullValue
PPC_FP128 determines isZero/isNan/isInf using high-order double value
 only. Checking isZero/isNegative might return the isNullValue unexpectedly.
 eg:
   0xM0000000000000000FFFFFFFFFFFFFFFFF

isZero, but it is not NullValue.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D103634
2021-06-03 20:31:01 +00:00
Fangrui Song a14fc749aa [InstrProfiling] If no value profiling, make data variable private and (for Windows) use one comdat
`__profd_*` variables are referenced by code only when value profiling is
enabled. If disabled (e.g. default -fprofile-instr-generate), the symbols just
waste space on ELF/Mach-O. We change the comdat symbol from `__profd_*` to
`__profc_*` because an internal symbol does not provide deduplication features
on COFF. The choice doesn't matter on ELF.

(In -DLLVM_BUILD_INSTRUMENTED_COVERAGE=on build, there is now no `__profd_*` symbols.)

On Windows this enables further optimization. We are no longer affected by the
link.exe limitation: an external symbol in IMAGE_COMDAT_SELECT_ASSOCIATIVE can
cause duplicate definition error.
https://lists.llvm.org/pipermail/llvm-dev/2021-May/150758.html
We can thus use llvm.compiler.used instead of llvm.used like ELF (D97585).
This avoids many `/INCLUDE:` directives in `.drectve`.

Here is rnk's measurement for Chrome:
```
This reduced object file size of base_unittests.exe, compiled with coverage, optimizations, and gmlt debug info by 10%:

#BEFORE

$ find . -iname '*.obj' | xargs du -b | awk '{ sum += $1 } END { print sum}'
1047758867

$ du -cksh base_unittests.exe
82M     base_unittests.exe
82M     total

# AFTER

$ find . -iname '*.obj' | xargs du -b | awk '{ sum += $1 } END { print sum}'
937886499

$ du -cksh base_unittests.exe
78M     base_unittests.exe
78M     total
```

Reviewed By: davidxl, rnk

Differential Revision: https://reviews.llvm.org/D103372
2021-06-03 13:16:13 -07:00
Kevin Athey 41b3088c3f Update and improve compiler-rt tests for -mllvm -asan_use_after_return=(never|[runtime]|always).
In addition:
  - optionally add global flag to capture compile intent for UAR:
    __asan_detect_use_after_return_always.
    The global is a SANITIZER_WEAK_ATTRIBUTE.

for issue: https://github.com/google/sanitizers/issues/1394

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D103304
2021-06-03 13:13:51 -07:00
peter klausler 6fa5353a56 [flang] Fix folding of CMPLX
The code for folding calls to the intrinsic function CMPLX was
incorrectly dependent on the number of arguments to distinguish its
two cases (conversion from one kind of complex to another, and
composition of a complex value from real & imaginary parts).
This was wrong since the optional KIND= argument has already been
taken into account by intrinsic processing; instead, the type of
the first argument should decide the issue.

Differential Revision: https://reviews.llvm.org/D103568
2021-06-03 13:11:31 -07:00
Brendon Cahoon 53ab2d821e [GlobalISel] Add G_SBFX/G_UBFX to computeKnownBits
Differential Revision: https://reviews.llvm.org/D102969
2021-06-03 16:01:47 -04:00
Nikita Popov 33e41eaecd [LoopUnroll] Add additional test with one unpredictable exit (NFC)
One exit is unpredictable, the other has a known trip count. For
one function the predictable exit is the latch exit, for the other
the non-latch exit. Currently they are treated differently.
2021-06-03 21:58:51 +02:00
Louis Dionne e4d3a993c2 [libc++] Implement LWG3435 (constraints on reverse_iterator and move_iterator) 2021-06-03 15:49:41 -04:00
peter klausler 1dff8637b1 [flang] Fix crashes due to failure to find a subprogram
In error recovery situations, the mappings from source locations
to scopes were failing in a way that tripped some asserts.
Specifically, FindPureProcedureContaining() wasn't coping well
when starting at the global scope.  (And since the global scope
no longer has a source range, clean up the Semantics constructor
to avoid confusion.)

Differential Revision: https://reviews.llvm.org/D103567
2021-06-03 12:45:43 -07:00
Fangrui Song a3fd40b955 [docs] Update llvm-cov gcov
Mention some new options.

Remove outdated information about -g and -O0. -g0 works. -O1/-O2/-O3 work.
2021-06-03 12:36:27 -07:00
Louis Dionne 10d3869952 [libc++] NFC: Tidy up the reverse_iterator tests
Incidentally, that fixes an error with the modules build.
2021-06-03 15:00:13 -04:00
Alex Richardson 90344499ae [lld-macho] Fix BUILD_SHARED_LIBS build
ca6751043d added a dependency on XAR (at
least for the shared libs build), so without this change we get the
following linker error:

Undefined symbols for architecture x86_64:
  "_xar_close", referenced from:
      lld::macho::BitcodeBundleSection::finalize() in SyntheticSections.cpp.o

Reviewed By: #lld-macho, int3, thakis

Differential Revision: https://reviews.llvm.org/D100999
2021-06-03 19:58:43 +01:00
Sam Powell d1d36f7ad2 [llvm] llvm-tapi-diff
This patch introduces a new tool, llvm-tapi-diff, that compares and returns the diff of two TBD files.

Reviewed By: ributzka, JDevlieghere

Differential Revision: https://reviews.llvm.org/D101835
2021-06-03 11:38:00 -07:00
Eli Friedman 44cdf771fe [AtomicExpand] Merge cmpxchg success and failure ordering when appropriate.
If we're not emitting separate fences for the success/failure cases, we
need to pass the merged ordering to the target so it can emit the
correct instructions.

For the PowerPC testcase, we end up with extra fences, but that seems
like an improvement over missing fences.  If someone wants to improve
that, the PowerPC backed could be taught to emit the fences after isel,
instead of depending on fences emitted by AtomicExpand.

Fixes https://bugs.llvm.org/show_bug.cgi?id=33332 .

Differential Revision: https://reviews.llvm.org/D103342
2021-06-03 11:34:35 -07:00
Artur Pilipenko 5a2aec3f27 NFC. Mark DOTFuncInfo getters as const
This is a preparatory refactoring for introducing new
types of hidden blocks.
2021-06-03 11:27:06 -07:00
Artur Pilipenko a06e63fa52 NFC. Refactor DOTGraphTraits::isNodeHidden
Restructure handling of cfg-hide-unreachable-paths and
cfg-hide-deoptimize-paths options so as to make it easier
to introduce new types of hidden blocks.
2021-06-03 11:27:06 -07:00
Adrian Prantl a8099b4778 Remove redundant Begin/End form signpost format strings.
The os_signpost API already captures the begin/end part and in
Instruments, this just adds visual noise that gets in the way of the
interesting data. By removing the redundant end text, the display in
Instruments gets even less cluttered.

rdar://78636200

Differential Revision: https://reviews.llvm.org/D103577
2021-06-03 11:24:13 -07:00
Christopher Di Bella f1417eb9b1 [libcxx][module-map] creates submodules for private headers
Most of our private headers need to be treated as submodules so that
Clang modules can export things correctly. Previous commits that split
monolithic headers into smaller chunks were unaware of this requirement,
and so this is being addressed in one fell swoop. Moving forward, most
new headers will need to have their own submodule (anything that's
conditionally included is exempt from this rule, which means `__support`
headers aren't made into submodules).

This hasn't been marked NFC, since I'm not 100% sure that's the case.

Differential Revision: https://reviews.llvm.org/D103551
2021-06-03 18:18:30 +00:00
Chris Bieneman 13a9b2220f Don't delete the module you're inspecting
Prior to this patch when you used `clang -module-file-info` clang would
delete the module on completion because the module was treated as an
output file.

This fixes the issue so you don't need to invoke cc1 directly to get
module file information.

Reviewed By: steven_wu, phosek

Differential Revision: https://reviews.llvm.org/D103547
2021-06-03 13:00:09 -05:00
Sanjay Patel b865eead76 [InstCombine] eliminate sext and/or trunc if value has enough signbits
If we have enough signbits in a source value, we can skip an
intermediate cast for a trunc+sext pair:
https://alive2.llvm.org/ce/z/A_mQt-

This is the original problem shown in:
https://llvm.org/PR49543

There's a test that shows we transformed what used to be
a pair of shifts, so that suggests we could add another
ComputeNumSignBits fold starting from a shift.

There does not appear to be any change in compile-time
from the extra analysis:
https://llvm-compile-time-tracker.com/compare.php?from=3d2c9069dcafd0cbb641841aa3dd6e851fb7d760&to=b9513cdf2419704c7bb0c3a02a9ca06aae13d902&stat=instructions

Differential Revision: https://reviews.llvm.org/D103617
2021-06-03 13:58:19 -04:00
Victor Kuznetsov 3e55f55048 Fully-qualify template args of outer types in getFullyQualifiedType
Template args of outer types were not fully-qualified when calling getFullyQualifiedType() for inner types.

For simplicity the patch is a copy-paste of the same call from getFullyQualifiedType().

Reviewed at: https://reviews.llvm.org/D103039
2021-06-03 10:50:00 -07:00
Philip Reames 44d70d298a [LoopUnroll] Eliminate PreserveOnlyFirst parameter [nfc]
This is a first step towards simplifying the transform interface to be less error prone. The basic idea is that querying SCEV is cheap (since it's cached) and we can just check for properties related to branch folding in the transform method instead of relying on the heuristic part to pass everything in correctly.

Differential Revision: https://reviews.llvm.org/D103584
2021-06-03 10:33:14 -07:00
Alexey Bataev 8c48d77cdf [SLP]Improve cost estimation/emission of externally used extractelements.
No need to recalculate the cost of extractelements, just no need to
compensate the cost of all extractelements, need to check before if this
is actually going to be removed at the vectorization. Also, no need to
 generate new extractelement instruction, we may just regenerate the
 original one. It may improve the final vectorization.

Differential Revision: https://reviews.llvm.org/D102933
2021-06-03 10:26:59 -07:00
Philip Reames bb5e1c6dcb [LoopUnroll] Reorder code to max dom tree update more obvious [nfc]
This cleans up the unroll action into two phases. Phase 1 does the mechanical act of unrolling, and leaves all conditional branches in place. Phase 2 optimizes away some of the conditional branches and then simplifies the loop. The primary benefit of the reordering is that we can delete some special cases dom tree update logic.

Differential Revision: https://reviews.llvm.org/D103561
2021-06-03 10:19:56 -07:00
Jinsong Ji c8279e8acd add ppc_fp128 bitcode writer testcase 2021-06-03 17:18:11 +00:00
Alexey Bataev 89f3bc7698 [SLP]Allow to reorder nodes with >2 scalar values.
tryToVectorizeList function allows to reorder only 2 scalars. Patch
allows to reorder >2 scalars. Also, to avoid possible regressions, it
allows extra vectorization of the remaining parts of the scalars
elements if possible.

Part of D57059.

Differential Revision: https://reviews.llvm.org/D103247
2021-06-03 10:01:36 -07:00
Nikita Popov 20be54cb1f [Tests] Add missing include (NFC)
Fix one more missing include in a unit test after
983565a6fe.
2021-06-03 18:58:29 +02:00
Nikita Popov d93b678abb [lld] Add missing includes (NFC)
Fix lld build after 983565a6fe.
2021-06-03 18:55:18 +02:00
Harald van Dijk 5d2b3de284
[SLP] Avoid std::stable_sort(properlyDominates()).
As noticed by NAKAMURA Takumi back in 2017, we cannot use
properlyDominates for std::stable_sort as properlyDominates only
partially orders blocks. That is, for blocks A, B, C, D, where A
dominates B and C dominates D, we have A == C, B == C, but A < B. This
is not a valid comparison function for std::stable_sort and causes
different results between libstdc++ and libc++. This change uses DFS
numbering to give deterministic results for all reachable blocks.
Unreachable blocks are ignored already, so do not need special
consideration.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D103441
2021-06-03 17:51:52 +01:00
Nikita Popov b0ab79ee2d [MC] Add missing include (NFC)
Try to fix buildbots after 983565a6fe.
2021-06-03 18:50:00 +02:00
Fangrui Song f026e891b2 [mailmap] Add my entry 2021-06-03 09:45:20 -07:00
Nikita Popov 983565a6fe [ADT] Move DenseMapInfo for ArrayRef/StringRef into respective headers (NFC)
This is a followup to D103422. The DenseMapInfo implementations for
ArrayRef and StringRef are moved into the ArrayRef.h and StringRef.h
headers, which means that these two headers no longer need to be
included by DenseMapInfo.h.

This required adding a few additional includes, as many files were
relying on various things pulled in by ArrayRef.h.

Differential Revision: https://reviews.llvm.org/D103491
2021-06-03 18:34:36 +02:00
Mark de Wever fd3a526085 [libc++][nfc] Add more nasty macros.
D101613 added some macros used by Microsofts SAL. D103425 uses `__pre`
and `__post`. They are also used by SAL and cause issues when used on
Windows. Add them to the blacklist making it easier to figure out what
the issue is.

Differential Revision: https://reviews.llvm.org/D103541
2021-06-03 18:22:52 +02:00
Jeremy Morse 0507fc2ffc Revert "[DebugInstrRef][2/3] Track PHI values through register coalescing"
This reverts commit ae4303b42c.

Expensive checks buildbot has found a problem with this:

  https://lab.llvm.org/buildbot/#/builders/16/builds/11863
2021-06-03 17:16:58 +01:00
Rosie Sumpter 2e3636f974 [CostModel][AArch64] Add tests for ctlz, ctpop and cttz. NFC.
Differential Revision: https://reviews.llvm.org/D103601
2021-06-03 17:12:22 +01:00
Jeremy Morse ae4303b42c [DebugInstrRef][2/3] Track PHI values through register coalescing
In the instruction referencing variable location model, we store variable
locations that point at PHIs in MachineFunction during register
allocation. Unfortunately, register coalescing can substantially change
the locations of registers, and so that PHI-variable-location side table
needs maintenence during the pass.

This patch builds an index from the side table, and whenever a vreg gets
coalesced into another vreg, update the index to record the new vreg that
the PHI happens in. It also accepts a limited range of subregister
coalescing, for example merging a subregister into a larger class.

Differential Revision: https://reviews.llvm.org/D86813
2021-06-03 17:06:51 +01:00
Jez Ng 6881f29a36 [lld-macho] Parse re-exports of nested TAPI documents
D103423 neglected to call `parseReexports()` for nested TBD
documents, leading to symbol resolution failures when trying to look up
a symbol nested more than one level deep in a TBD file. This fixes the
regression and adds a test.

It also appears that `umbrella` wasn't being set properly when calling
`parseLoadCommands` -- it's supposed to resolve to `this` if `nullptr`
is passed. I didn't write a failing test case for this but I've made
`umbrella` a member so the previous behavior should be preserved.

Reviewed By: #lld-macho, thakis

Differential Revision: https://reviews.llvm.org/D103586
2021-06-03 12:02:30 -04:00
Gerhard Gappmeier 6f605b8d0b [clang-format] Add PPIndentWidth option
This allows to set a different indent width for preprocessor statements.

Example:

 #ifdef __linux_
 # define FOO
 #endif

int main(void)
{
    return 0;
}

Differential Revision: https://reviews.llvm.org/D103286
2021-06-03 17:55:11 +02:00
Gerhard Gappmeier 3e333cc82e [clang-format] Fix PointerAlignmentRight with AlignConsecutiveDeclarations
This re-applies the old patch D27651, which was never landed, into the
latest "main" branch, without understanding the code. I just applied
the changes "mechanically" and made it compiling again.

This makes the right pointer alignment working as expected.
Fixes https://llvm.org/PR27353

For instance

const char* const* v1;
float const* v2;
SomeVeryLongType const& v3;

was formatted as

const char *const *     v1;
float const *           v2;
SomeVeryLongType const &v3;

This patch keep the *s or &s aligned to the right, next to their variable.
The above example is now formatted as

const char *const      *v1;
float const            *v2;
SomeVeryLongType const &v3;

It is a pity that this still does not work with clang-format in 2021,
even though there was a fix available in 2016. IMHO right pointer alignment
is the default case in C, because syntactically the pointer belongs to the
variable.

See

int* a, b, c; // wrong, just the 1st variable is a pointer

vs.

int *a, *b, *c; // right

Prominent example is the Linux kernel coding style.

Some styles argue the left pointer alignment is better and declaration
lists as shown above should be avoided. That's ok, as different projects
can use different styles, but this important style should work too.

I hope that somebody that has a better understanding about the code,
can take over this patch and land it into main.

For now I must maintain this fork to make it working for our projects.

Cheers,
Gerhard.

Differential Revision: https://reviews.llvm.org/D103245
2021-06-03 17:55:11 +02:00
Aart Bik 12db09d7f3 [mlir][sparse] add more type combinations to sparse storage scheme
Useful for "exhaustively" testing and benchmarking annotation combinations
to verify correctness and perform state space search for best performing.

Reviewed By: penpornk

Differential Revision: https://reviews.llvm.org/D103566
2021-06-03 08:34:10 -07:00
Tobias Gysi 5a9c91b223 [mlir][linalg] Cleanup LinalgOp usage in capi.
Replace the uses of deprecated Structured Op Interface methods in Linalg.cpp. This patch is based on https://reviews.llvm.org/D103394.

Differential Revision: https://reviews.llvm.org/D103619
2021-06-03 15:32:28 +00:00
Hsiangkai Wang 9d4922eab4 [RISCV] Precommit a test case to show overwriting vector frame objects. 2021-06-03 23:25:45 +08:00
Alexander Belyaev 89df483d30 [mlir] Fix warnings. 2021-06-03 17:09:09 +02:00
Tobias Gysi f44e90b93a [mlir][linalg] Cleanup LinalgOp usage in scalar inlining.
Replace the uses of deprecated Structured Op Interface methods in InlineScalarOperands.cpp. This patch is based on https://reviews.llvm.org/D103394.

Differential Revision: https://reviews.llvm.org/D103518
2021-06-03 14:45:14 +00:00
Peter Steinfeld 22d7e298dc [flang] Check for duplicate definitions of defined input/output procedures
It's possible to specify defined input/output procedures either as a
type-bound procedure of a derived type or as a defined-io-generic-spec.  This
means that you can specify the same procedure in both mechanisms, which does
not cause problems.  Alternatively, you can specify two different procedures to
be the defined input/output procedure for the same derived type.  This is an
error.  This change catches this error.  The situation is slightly complicated
by parameterized derived types.  Types with the same value for a KIND parameter
are treated as the same type while types with different KIND parameters are
treated as different types.

I implemented this check by adding a vector to keep track of which defined
input/output procedures had been seen for which derived types along with the
kind of procedure (read vs write and formatted vs unformatted).  I also added
tests for non-parameterized types and types parameterized by KIND and LEN type
parameters.

I also removed an erroneous check from the code that creates runtime type
information.

Differential Revision: https://reviews.llvm.org/D103560
2021-06-03 07:39:27 -07:00
Hamza Mahfooz 83235b07e3
[Matrix] Preserve existing fast-math flags during lowering
This patch makes it so, floating-point instructions created in
LowerMatrixIntrinsics retain fast-math flags from instructions that are
higher up the chain.

Fixes https://bugs.llvm.org/show_bug.cgi?id=49738

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D103233
2021-06-03 15:29:31 +01:00