Commit graph

421204 commits

Author SHA1 Message Date
Peter Klausler 625dedc3fe [flang] Allow modification of construct entities
Construct entities from ASSOCIATE, SELECT TYPE, and SELECT RANK
are modifiable if the are associated with modifiable variables
without vector subscripts.  Update WhyNotModifiable() to accept
construct entities that are appropriate.

A need for more general error reporting from one overload of
WhyNotModifiable() caused its result type to change to
std::optional<parser::Message> instead of ::MessageFixedText,
and this change had some consequences that rippled through
call sites.

Some test results that didn't allow for modifiable construct
entities needed to be updated.

Differential Revision: https://reviews.llvm.org/D123722
2022-04-14 16:58:08 -07:00
Jonas Devlieghere af91446aa2
[lldb] Show the DBGError if dsymForUUID can't find a dSYM
Show the user the DBGError (if available) when dsymForUUID fails.

rdar://90949180

Differential revision: https://reviews.llvm.org/D123743
2022-04-14 16:54:00 -07:00
Thomas Raoux 894a591cf6 [mlir][nvgpu] Move mma.sync and ldmatrix in nvgpu dialect
Move gpu operation mma.sync and ldmatrix in nvgpu as they are specific
to nvidia target.

Differential Revision: https://reviews.llvm.org/D123824
2022-04-14 23:44:52 +00:00
Bill Wendling 8c77a75fb6 [randstruct] Add test for "-frandomize-layout-seed-file" flag
This test makes sure that the "-frandomize-layout-seed" and
"-frandomize-layout-seed-file" flags generate the same layout for the
record.

Reviewed By: aaron.ballman, MaskRay

Differential Revision: https://reviews.llvm.org/D123636
2022-04-14 16:35:41 -07:00
Jonas Devlieghere 03049c5125
Revert "[lldb] Pin the shared cache when iterating over its images"
This reverts commit af969141fa because it
didn't have the intended performance benefit to offset the increase in
our (virtual) memory usage.
2022-04-14 16:23:56 -07:00
Peter Klausler 142cbd500b [flang] Fix TYPE/CLASS IS (T(...)) in SELECT TYPE
TYPE IS and CLASS IS guards in SELECT TYPE constructs are
allowed to specify the same type as the type of the selector
but f18's implementation of that predicate required strict
equality of the derived type representations.  We need to
allow for assumed values of LEN type parameters to match
explicit and deferred type parameter values in the selector
and require equality for KIND type parameters.  Implement
DerivedTypeSpec::Match() to perform this more relaxed type
comparison, and use it in check-select-type.cpp.

Differential Revision: https://reviews.llvm.org/D123721
2022-04-14 16:20:37 -07:00
Bill Wendling 27dead3e3a Revert "[randstruct] Add test for "-frandomize-layout-seed-file" flag"
There's a test failure.

This reverts commit 31ea4798ad.
2022-04-14 16:07:00 -07:00
Mehdi Amini 72e2b4e7a7 Apply clang-tidy fixes for modernize-use-default-member-init in PDLLServer.cpp (NFC) 2022-04-14 22:59:14 +00:00
Mehdi Amini db6796dfa8 Apply clang-tidy fixes for modernize-use-default-member-init in SparseTensorUtils.cpp (NFC) 2022-04-14 22:59:14 +00:00
Peter Klausler 95199af4ae [flang] Local generics must not shadow host-associated generics
It is possible for generic interfaces of equivalent (but not necessarily
identical -- operator(.eq.) is equivalent to operator(==)) names to
be declared in a host scope and a nested scope, and the nested declaration
should function as an extension of the host's.

Differential Revision: https://reviews.llvm.org/D123719
2022-04-14 15:43:59 -07:00
Peter Klausler 8065e48218 [flang] Inner INTRINSIC must not shadow host generic
A generic interface (however spelled) can have the same name as
an intrinsic procedure in the same scope.  When an explicit INTRINSIC
attribute statement appears in a nested scope, semantics was
unconditionally declaring a new symbol that hid the generic entirely.
Catch this case and create instead a host association symbol for
the generic that can then be decorated with the INTRINSIC attribute.

Differential Revision: https://reviews.llvm.org/D123718
2022-04-14 15:42:44 -07:00
Bill Wendling 31ea4798ad [randstruct] Add test for "-frandomize-layout-seed-file" flag
This test makes sure that the "-frandomize-layout-seed" and
"-frandomize-layout-seed-file" flags generate the same layout for the
record.

Reviewed By: aaron.ballman, MaskRay

Differential Revision: https://reviews.llvm.org/D123636
2022-04-14 15:41:25 -07:00
Peter Klausler a68612a964 [flang][runtime] Preserve effect of positioning in record in non-advancing output
When formatted non-advancing output ends in a control edit descriptor
like nX or Tn or TRn that effectively extends the record, fill any
gap with explicit blanks at the completion of the WRITE.

Differential Revision: https://reviews.llvm.org/D123716
2022-04-14 15:33:15 -07:00
Peter Klausler 724709e09d [flang] Make F0.1 output editing of zero edge case consistent
The statement
  PRINT '(2F0.1)', 0.0, 0.5
should emit consistent ".0 .5" output, not "0.0 .5".

Differential Revision: https://reviews.llvm.org/D123715
2022-04-14 15:31:47 -07:00
Fangrui Song f20968e006 [Driver] Remove unneeded -f[no-]pascal-strings translation. NFC
They used to translate to -m[no-]pascal-strings.
This is unneeded after 28c96319c8 or some point in
2009 when -m[no-]pascal-strings became aliases for -f[no-]pascal-strings.
2022-04-14 15:20:58 -07:00
Bixia Zheng cb6f8d77a2 [mlir][sparse][taco] Use the SparseCompiler from python/tools.
Copy the implementation of SparseCompiler from python/tools to taco/tools until we have a common place to install it. Modify TACO to use this SparseCompiler for compilation and jitting.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D123696
2022-04-14 15:17:18 -07:00
Peter Klausler de026aeb8e [flang] Raise FP exceptions from runtime conversion to binary
Formatted READs of REAL should convert the exception flags from
the decimal-to-binary conversion library into real runtime FP
exceptions so that they at least show up in the termination message
of a STOP statement.

Differential Revision: https://reviews.llvm.org/D123714
2022-04-14 14:49:36 -07:00
Igor Chebykin eb156cb25e [NVPTX][tests] Do not run the test CodeGen/Generic/2010-11-04-BigByval.ll
NVPTX does not support the testcase llvm/test/CodeGen/Generic/2010-11-04-BigByval.ll
There are NVPTX specific testcases for byval args in the llvm/test/CodeGen/NVPTX
The test is marked as UNSUPPORTED for NVPTX due to unacceptable run time when using XFAIL

Differential Revision: https://reviews.llvm.org/D122939
2022-04-14 14:22:12 -07:00
Andrew Browne cddcf2170a [DFSan] Avoid replacing uses of functions in comparisions.
This can cause crashes by accidentally optimizing out checks for
extern_weak_func != nullptr, when replaced with a known-not-null wrapper.

This solution isn't perfect (only avoids replacement on specific patterns)
but should address common cases.

Internal reference: b/185245029

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D123701
2022-04-14 14:14:52 -07:00
Eli Friedman 6cf0b1b3da Comment out assertions about initializer size added in D123649.
They're causing failures in LLVM test-suite.  Added some regression
tests that explain the issue.
2022-04-14 13:58:17 -07:00
Peter Klausler eb14135e35 [flang] Correct interaction between generics and intrinsics
Fortran allows a generic interface to have he same name as an
intrinsic procedure.  If the intrinsic is explicitly marked with
the INTRINSIC attribute, restrictions apply (C848) - the generic
must contain only functions or subroutines, depending on the
intrinsic.  Explicit or not, the generic overrides the intrinsic,
but the intrinsic behavior must still be available for calls
whose actual arguments do not match any of the specific procedures.

Semantics was not checking constraint C848, and it didn't allow
an explicit INTRINSIC attribute on a name of a generic interface.

Differential Revision: https://reviews.llvm.org/D123713
2022-04-14 13:56:04 -07:00
Jameson Nash 753aabeaae [X86] Fix test case for SoftPromoteHalf of STRICT_FP_EXTEND/STRICT_FP_ROUND.
Tests that should have been with
33b9f3abd7
when writing the tests that should have been with
0daf9b8e41.

Differential Revision: https://reviews.llvm.org/D123739
2022-04-14 16:18:37 -04:00
Louis Dionne c4f059e509 [libc++][NFC] Add missing 'return 0' to test 2022-04-14 16:08:43 -04:00
Michael Jones f14334ffa1 [libc][docs] Add doc for libc string functions
This patch adds a document describing the status of the string functions
in LLVM-libc.

Reviewed By: sivachandra, jeffbailey

Differential Revision: https://reviews.llvm.org/D123645
2022-04-14 13:03:01 -07:00
V Donaldson 96e45a8958 [flang] Use full result range for clock_gettime implementation of SYSTEM_CLOCK
Update the primary clock_gettime implementation of SYSTEM_CLOCK to use
the full range of values, dependent on the type kind of the requested
result.  Counts/sec and count max for supported kinds become:

 kind          counts/sec             count max

    1                  10                   127
    2                1000                 32767
    4                1000            2147483647
    8          1000000000   9223372036854775807
   16          1000000000   9223372036854775807

The secondary "fallback" implementation is not changed.

Real valued COUNT_RATE arguments are not changed.

The test program below has calls for kinds 1, 2, 4, 8, 16.  Support for
these types varies by compiler.  The code as given can be restricted to
accommodate these variations, with results shown below.

subroutine c
  integer(1) c1, r1, m1
  integer(2) c2, r2, m2
  integer(4) c4, r4, m4
  integer(8) c8, r8, m8
  integer(16) c16, r16, m16

  print*
  print '(a5,3a22)', 'kind', 'counts/sec', 'count max', 'count'
  print*

  call system_clock(c1, r1, m1)
  print '(i5,3i22)', 1, r1, m1, c1

  call system_clock(c2, r2, m2)
  print '(i5,3i22)', 2, r2, m2, c2

  call system_clock(c4, r4, m4)
  print '(i5,3i22)', 4, r4, m4, c4

  call system_clock(c8, r8, m8)
  print '(i5,3i22)', 8, r8, m8, c8

  call system_clock(c16, r16, m16)
  print '(i5,3i22)', 16, r16, m16, c16
end

subroutine k(j)
  j = 0
  do i=1,1000000000
    j = j + i
  enddo
end

program p
  do i=1,1 ! increase loop count to check for (kind=1) wraparound
    call k(j)
    call c
  enddo
end

=== flang output without change (last column counts vary per run) ===

 kind          counts/sec             count max                 count

    1                 -24                   127                    83
    2                1000                   290                   211
    4                1000                   290                   211
    8          1000000000             290448383             211631452
   16          1000000000             290448383             211633853

=== flang output with change (last column counts vary per run) ===

    1                  10                   127                    21
    2                1000                 32767                  2100
    4                1000            2147483647                  2100
    8          1000000000   9223372036854775807            2100183374
   16          1000000000   9223372036854775807            2100185353

Other compilers; kind support varies (last column counts vary per run).
Test and ouput modified to avoid crashes and normalize results.
Some negative values indicate unsupported kinds; others are bugs.

 kind          counts/sec             count max                 count

    1                   0                     0                  -127
    2                   0                     0                -32767
    4                1000            2147483647              69271692
    8          1000000000   9223372036854775807        69271692353290
   16          1000000000   9223372036854775807        69271692354794

=======

    1                  10                   127                     0
    2                1000                 32767                     0
    4             1000000            2147483647                     0
    8            10000000   9223372036854775807                     9

=======

    1                   0                     0                  -127
    2                1000                 32767                  3263
    4               10000            2147483647            1788192630
    8             1000000   9223372036854775807      1649443459263095

=======

    1                 -24                    -1                    36
    2                1000                    -1                -10716
    4                1000            2147483647             176018980
    8                1000   9223372036854775807         1649443460644

=======

    2                 100                 28799                 23080
    4                 100               8639999               4285480
    8                 100               8639999               4285480
   16                 100               8639999               4285480

=======

    1                 -24                    -1                     4
    2                1000                 23551                -26108
    4                1000              86399999              67541508
    8             1000000   9223372036854775807      1649443541508087
2022-04-14 13:01:32 -07:00
Brad Smith 8cf83e9659 [VE][compiler-rt] Correct location of VE support in clear_cache function, NFC
Looks like when the VE support was added it was added a few lines below where it should have been.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D123439
2022-04-14 15:50:26 -04:00
Paul Robinson 7726ad04e2 [PS5] Add basic PS5 driver behavior
This adds a PS5-specific ToolChain subclass, which defines some basic
PS5 driver behavior. Future patches will add more target-specific
driver behavior.
2022-04-14 12:45:33 -07:00
Jonas Devlieghere 428775d518
[lldb] Remove TestShell.test
Remove TestShell.test because it's failing on the bot with "this is a
non-interactive debug session, cannot get permission to debug
processes." The only thing that's special about this test is the shell
we're launching with. I need to do a bit of digging to understand why
that's causing this error.

rdar://91766931
2022-04-14 12:10:54 -07:00
Peter Klausler d054959786 [flang] Fix shape analysis of RESHAPE result
Shape analysis of RESHAPE(..., SHAPE=s) should of course return
the SHAPE= actual argument when it is constant; but when it is
not, its length is still known, and thus so is the rank of the
result of RESHAPE(), and shape analysis should at least return
a shape vector of the right length rather than a result that
makes the result appear to be a scalar, which can lead to some
bogus error messages.

Also, while here: rename a private GetShapeHelper::AsShape()
routine so that it can't be confused with the ones in the API
of shape.h.

Differential Revision: https://reviews.llvm.org/D123712
2022-04-14 12:07:48 -07:00
Eli Friedman 5955a0f937 Allow flexible array initialization in C++.
Flexible array initialization is a C/C++ extension implemented in many
compilers to allow initializing the flexible array tail of a struct type
that contains a flexible array. In clang, this is currently restricted
to C. But this construct is used in the Microsoft SDK headers, so I'd
like to extend it to C++.

For now, this doesn't handle dynamic initialization; probably not hard
to implement, but it's extra code, and I don't think it's necessary for
the expected uses.  And we explicitly fail out of constant evaluation.

I've added some additional code to assert that initializers have the
correct size, with or without flexible array init. This might catch
issues unrelated to flexible array init.

Differential Revision: https://reviews.llvm.org/D123649
2022-04-14 11:56:40 -07:00
LLVM GN Syncbot 234678fbf9 [gn build] Port b9ca972b1f 2022-04-14 18:36:20 +00:00
Yonghong Song 6ee71e53e5 [BPF] handle opaque-pointer for __builtin_preserve_enum_value
Opaque pointer [1] is enabled as the default with commit [2].
Andrii found that current __builtin_preserve_enum_value() can only handle
non opaque pointer code pattern and will segfault with latest
llvm main branch where opaque-pointer is enabled by default.

This patch added the opaque pointer support.
Besides llvm selftests, also verified with bpf-next bpf selftests.

  [1] https://llvm.org/docs/OpaquePointers.html
  [2] https://reviews.llvm.org/D123122

Differential Revision: https://reviews.llvm.org/D123800
2022-04-14 11:34:32 -07:00
Chris Bieneman 3efad612d2 [HLSL] Pointers are unsupported in HLSL
HLSL does not support pointers or references. This change generates
errors in sema for generating pointer, and reference types as well as
common operators (address-of, dereference, arrow), which are used with
pointers and are unsupported in HLSL.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D123167
2022-04-14 13:32:51 -05:00
Fangrui Song 02eab52866 [ELF][AArch64] Fix unneeded thunk for branches to hidden undefined weak
Similar to D119787 for PPC64.

A hidden undefined weak may change its binding to local before some
`isUndefinedWeak` code, so some `isUndefinedWeak` code needs to be changed to
`isUndefined`. The undefined non-weak case has been errored, so just using
`isUndefined` is fine.

The Linux kernel recently has a usage that a branch from 0xffff800008491ee0
references a hidden undefined weak symbol `vfio_group_set_kvm`.
It relies on the behavior that a branch to undefined weak resolving to the next
instruction, otherwise it'd see spurious relocation out of range errors.

Fixes https://github.com/ClangBuiltLinux/linux/issues/1624

Differential Revision: https://reviews.llvm.org/D123750
2022-04-14 11:32:30 -07:00
Sanjay Patel 2c2568f39e [InstCombine] canonicalize select with signbit test
This is part of solving issue #54750 - in that example
we have both forms of the compare and do not recognize
the equivalence.
2022-04-14 14:28:47 -04:00
Andrew Savonichev 5193f2a558 Revert "[NVPTX] Disable parens for identifiers starting with '$'"
This reverts commit 78d70a1c97.

Failed on Mips32:
https://lab.llvm.org/buildbot#builders/109/builds/36628

   # CHECK: # fixup A - offset: 0, value: ($tmp0), kind: fixup_Mips_26
   <stdin>:580:2: note: possible intended match here
   # fixup A - offset: 0, value: $tmp0, kind: fixup_Mips_26
2022-04-14 21:25:31 +03:00
Peter Klausler 664c111c95 [flang] Always encode multi-byte output in UTF-8
A recent change to implement UTF-8 encoding should have
made the encoding conditional only for CHARACTER(KIND=1)
to enable UTF-8 output vs. Latin-1 or whatever.  UTF-8 output
of wider CHARACTER kinds should not be conditional (until we choose
to support UCS-16, maybe).  So wider CHARACTER kinds are being
emitted with extra zero bytes; this patch fixes them.

Differential Revision: https://reviews.llvm.org/D123711
2022-04-14 11:13:51 -07:00
Fangrui Song b9ca972b1f [clang-tidy] Add portability-std-allocator-const check
Report use of `std::vector<const T>` (and similar containers of const
elements). These are now allowed in standard C++ due to undefined
`std::allocator<const T>`. They do not compile with libstdc++ or MSVC.
Future libc++ will remove the extension (D120996).
See docs/clang-tidy/checks/portability-std-allocator-const.rst for detail.

I have attempted clean-up in a large code base. Here are some statistics:

* 98% are related to the container `std::vector`, among `deque/forward_list/list/multiset/queue/set/stack/vector`.
* 24% are related to `std::vector<const std::string>`.
* Both `std::vector<const absl::string_view>` and `std::vector<const int>` contribute 2%. The other contributors spread over various class types.

The check can be useful to other large code bases and may serve as an example
for future libc++ strictness improvement.

Note: on MSVC where -fdelayed-template-parsing is the default, the check cannot
catch cases in uninstantiated templates.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D123655
2022-04-14 11:13:41 -07:00
Andrew Savonichev 78d70a1c97 [NVPTX] Disable parens for identifiers starting with '$'
ptxas fails to parse such syntax:

    mov.u64 %rd1, ($str);
    fatal   : Parsing error near '$str': syntax error

A new MCAsmInfo option was added because InParens parameter of
MCExpr::print is not sufficient to disable parens
completely. MCExpr::print resets it to false for a recursive call in
case of unary or binary expressions.

Differential Revision: https://reviews.llvm.org/D123702
2022-04-14 21:07:43 +03:00
Zequan Wu 3dbf524ad7 [LLDB][NativePDB] Fix a crash when S_DEFRANGE_SUBFIELD_REGISTER descirbes a simple type
When a variable is simple type and has 64 bits, the debug info may look like the following when targeting 32bit windows. The variable's content is split into two 32bits registers.
```
480 | S_LOCAL [size = 12] `x`
      type=0x0013 (__int64), flags = param
492 | S_DEFRANGE_SUBFIELD_REGISTER [size = 20]
      register = EAX, may have no name = true, offset in parent = 0
      range = [0001:0073,+7), gaps = []
512 | S_DEFRANGE_SUBFIELD_REGISTER [size = 20]
      register = ECX, may have no name = true, offset in parent = 4
      range = [0001:0073,+7), gaps = []
```

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D122943
2022-04-14 11:06:21 -07:00
Zequan Wu ef7cba7148 [LLDB][NativePDB] Fix inline line info in line table
It fixes the following case:
```
0602      line 1 (+1)
0315      code 0x15 (+0x15)
0B2B      code 0x20 (+0xB) line 2 (+1)
0602      line 3 (+1)
0311      code 0x31 (+0x11)
...
```

Inline ranges should have following mapping:
`[0x15, 0x20) -> line 1`
`[0x20, 0x31) -> line 2`
Inline line entries:
`0x15, line 1`, `0x20, line 2`, `0x31, line 3`.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D123092
2022-04-14 11:00:56 -07:00
Jonas Devlieghere 99d9c44434
[lldb] Port Process::PrintWarning* to use the new diagnostic events
Port the two Process::PrintWarning functions to use the new diagnostic
events through Debugger::ReportWarning. I kept the wrapper function in
the process, but delegated the work to the Module. Consistent with the
current code, the Module ensures the warning is only printed once per
module.

Differential revision: https://reviews.llvm.org/D123698
2022-04-14 11:00:21 -07:00
Jonas Devlieghere 64d9b233b9
[lldb] Prevent crash when adding a stop hook with --shlib
Currently, lldb crashes when adding a stop hook with --shlib because we
unconditionally use the target in SymbolContextSpecifier::AddSpecification.
This patch prevents the crash and add a test.

rdar://68524781

Differential revision: https://reviews.llvm.org/D123746
2022-04-14 11:00:21 -07:00
Martin Sebor 104e086a4f Use descriptive register names for readability (NFC). 2022-04-14 11:59:04 -06:00
Maksim Panchenko 77b75ca53f [BOLT][perf2bolt] Fix base address calculation for shared objects
When processing profile data for shared object or PIE, perf2bolt needs
to calculate base address of the binary based on the map info reported
by the perf tool. When the mapping data provided is for the second
(or any other than the first) segment and the segment's file offset
does not match its memory offset, perf2bolt uses wrong assumption
about the binary base address.

Add a function to calculate binary base address using the reported
memory mapping and use the returned base for further address
adjustments.

Reviewed By: yota9

Differential Revision: https://reviews.llvm.org/D123755
2022-04-14 10:29:53 -07:00
Mark de Wever 48fbcedb38 [libc++] Adds a missing include.
This fixes the modular build.
2022-04-14 19:28:00 +02:00
Peter Klausler 6111ddedc8 [flang] Defer all function result type processing
When a type specification appears in the prefix of a FUNCTION statement,
defer its processing as late as possible so that any symbols in the
tpe specification can be resolved in the function's scope to local
declarations, including use-associated symbols.  f18 was already doing
this deferral in a limited form for derived types, and this patch
makes it work for intrinsic type parameter values as well.

In short, "real(kind(x)) function foo(x)" now works as it should.

"As late as possible" means the end of the specification part, or
the first appearance of the function result name in the specification
part.

Differential Revision: https://reviews.llvm.org/D123705
2022-04-14 10:25:57 -07:00
Andrew Litteken 6f8eba06c2 Revert "[IROutliner] Ensure that phi values that are passed in as arguments are remapped as arguments"
Failing test due to typo

This reverts commit d6eb480afb.
2022-04-14 12:23:33 -05:00
Andrew Litteken d6eb480afb [IROutliner] Ensure that phi values that are passed in as arguments are remapped as arguments
Issue: https://github.com/llvm/llvm-project/issues/54430

For incoming values of phi nodes added to an outlined function to accommodate different exit paths in the function, when a value is a constant that is passed into the outlined function as an argument, we find the corresponding value in the first extracted function used to fill the overall outlined function. When this value is an argument, the corresponding value used will be the old value, prior to outlining. This patch maintains a mapping from these values to arguments, and uses this mapping to update the added phi node accordingly.

Reviewers: paquette

Differential Revision: https://reviews.llvm.org/D122206
2022-04-14 12:16:23 -05:00
Paul Robinson 7ef9dd3c61 [PS4] Fix a couple of typos 2022-04-14 10:14:17 -07:00