Commit Graph

428377 Commits

Author SHA1 Message Date
Peter Klausler 53dca2e6ec [flang][runtime] Emit "0.0E+0" for (1PG0.0) editing of 0.0
When a scale factor is in effect, respect it for G0.0 output editing.

Differential Revision: https://reviews.llvm.org/D128761
2022-06-29 11:42:39 -07:00
Egor Zhdan 5f2cf3a21f [Clang][Preprocessor] Fix inconsistent `FLT_EVAL_METHOD` when compiling vs preprocessing
When running `clang -E -Ofast` on macOS, the `__FLT_EVAL_METHOD__` macro is `0`, which causes the following typedef to be emitted into the preprocessed source: `typedef float float_t`.

However, when running `clang -c -Ofast`, `__FLT_EVAL_METHOD__` is `-1`, and `typedef long double float_t` is emitted.

This causes build errors for certain projects, which are not reproducible when compiling from preprocessed source.

The issue is that `__FLT_EVAL_METHOD__` is configured in `Sema::Sema` which is not executed when running in `-E` mode.

This change moves that logic into the preprocessor initialization method, which is invoked correctly in `-E` mode.

rdar://96134605
rdar://92748429

Differential Revision: https://reviews.llvm.org/D128814
2022-06-29 19:36:22 +01:00
Peter Klausler f161964e1c [flang] Better error recovery for bad submodules
When a submodule appears in a source file and the compiler can't find the
named ancestor module (and submodule, if one appears), crashes may occur
later due to the absence of a scope.  For better resilience, a dummy
ancestral scope should be generated within which the submodule scope
can be created.

Differential Revision: https://reviews.llvm.org/D128760
2022-06-29 11:34:51 -07:00
Valentin Clement 649439e7ae
[flang] Fix lowering issue with character temp
- Add verifiers that determine if an Op requires type parameters or
  not and checks that the correct number of parameters is specified.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D128828

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-06-29 20:06:54 +02:00
Benoit Jacob 694ad3eaef Fix CombineContractBroadcast folding reduction iterators.
Fix CombineContractBroadcast folding reduction iterators.

Differential Revision: https://reviews.llvm.org/D128739
2022-06-29 18:01:56 +00:00
Pavel Labath 079c8ccb33 [lldb] Attempt to fix TestStepThroughTrampoline on windows 2022-06-29 19:59:24 +02:00
Fangrui Song 45ae553109 [llvm-objcopy] Remove support for legacy .zdebug sections
clang 14 removed -gz=zlib-gnu support and ld.lld removed linker input support
for zlib-gnu in D126793. Now let's remove zlib-gnu from llvm-objcopy.

* .zdebug* sections are no longer recognized as debug sections. --strip* don't remove them.
  They are copied like other opaque sections
* --decompress-debug-sections does not uncompress .zdebug* sections
* --compress-debug-sections=zlib-gnu is not supported

It is very rare but in case a user has object files using .zdebug . They can use
llvm-objcopy<15 or GNU objcopy for uncompression.
--compress-debug-sections=zlib-gnu is unlikely ever used by anyone, so I do not
add a custom diagnostic.

Differential Revision: https://reviews.llvm.org/D128688
2022-06-29 10:42:55 -07:00
Philip Reames dd48d3ad0e Revert "[RISCV] Avoid changing etype for splat of 0 or -1"
This reverts commit 755c84c62c.  A bug was reported on the original review thread (https://reviews.llvm.org/D128006), and on inspection this patch is simply wrong.  It needs to be checking for VLInBytes, not MaxVL.  These happen to be the same when using AVL=VLMAX (which is quite common), but this does not fold when AVL != VLMAX.
2022-06-29 10:27:02 -07:00
Florian Hahn 9a35f19e3e
[UnrollRuntime] Invalidate SCEVs for modified phis in ConnectEpilog.
ConnectEpilog adds new incoming values to exit phi nodes which can
change the SCEV for the phi after 20d798bd47.

Fix is analog to cfc741bc0e.

Fixes #56282.
2022-06-29 18:26:00 +01:00
Peter Klausler b70f507c75 [flang] Fix folding of LEN(f(...))
LEN(f(...)), where "f" is a non-intrinsic function, should not be folded
to anything else unless the result is a known constant value.  While there
are conceivable cases in which we could do better (e.g., an internal function
whose length is a host-associated INTENT(IN) dummy argument), there are
other cases that we're getting wrong.

Differential Revision: https://reviews.llvm.org/D128759
2022-06-29 10:25:07 -07:00
Kevin Cadieux a9bef0707d [clang-format] Fix incorrect isspace input (NFC)
This change fixes a clang-format unit test failure introduced by [D124748](https://reviews.llvm.org/D124748). The `countLeadingWhitespace` function was calling `isspace` with values that could fall outside the valid input range. The valid input range for `isspace` is unsigned 0-255. Values outside this range produce undefined behavior, which on Windows manifests as an assertion being raised in the debug runtime libraries. `countLeadingWhitespace` was calling `isspace` with a signed char that could produce a negative value if the underlying byte's value was 128 or above, which can happen for non-ASCII encodings. The fix is to use `StringRef`'s `bytes_begin` and `bytes_end` iterators to read the values as unsigned chars instead.

This bug can be reproduced by building the `check-clang-unit` target with a DEBUG configuration under Windows. This change is already covered by existing unit tests.

Reviewed By: MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D128786
2022-06-29 10:20:46 -07:00
Fangrui Song bf223e43fe [llvm-ar] Add --output to specify output directory
From binutils 2.34 onwards, ar supports --output to specify a directory
where archive members should be extracted to. Port this feature.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D128626
2022-06-29 10:00:43 -07:00
Martin Sebor d515211a0c [InstCombine] Relax test to avoid Darwin failure.
Avoid testing folding of atoi calls with out-of-bounds pointers.
2022-06-29 10:51:27 -06:00
Sanjay Patel d4f39d8333 [InstCombine] add fold for (ShiftC >> X) >u C
This is the 'ugt' sibling to:
0399473de8

Decrement the input compare constant (and implicitly
decrement the new compare constant):
https://alive2.llvm.org/ce/z/iELmct
2022-06-29 12:30:01 -04:00
Sanjay Patel 905b6b3edd [InstCombine] add tests for (pow2 >> X) <u C; NFC
Adapted from af5e64df72
2022-06-29 12:30:01 -04:00
Corentin Jabot a9a60f20e6 [Clang] Rename StringLiteral::isAscii() => isOrdinary() [NFC]
"Ascii" StringLiteral instances are actually narrow strings
that are UTF-8 encoded and do not have an encoding prefix.
(UTF8 StringLiteral are also UTF-8 encoded strings, but with
the u8 prefix.

To avoid possible confusion both with actuall ASCII strings,
and with future works extending the set of literal encodings
supported by clang, this rename StringLiteral::isAscii() to
isOrdinary(), matching C++ standard terminology.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D128762
2022-06-29 18:28:51 +02:00
Walter Erquinigo a7d6c3effe [trace] Make events first class items in the trace cursor and rework errors
We want to include events with metadata, like context switches, and this
requires the API to handle events with payloads (e.g. information about
such context switches). Besides this, we want to support multiple
similar events between two consecutive instructions, like multiple
context switches. However, the current implementation is not good for this because
we are defining events as bitmask enums associated with specific
instructions. Thus, we need to decouple instructions from events and
make events actual items in the trace, just like instructions and
errors.

- Add accessors in the TraceCursor to know if an item is an event or not
- Modify from the TraceDumper all the way to DecodedThread to support
- Renamed the paused event to disabled.
- Improved the tsc handling logic. I was using an API for getting the tsc from libipt, but that was an overkill that should be used when not processing events manually, but as we are already processing events, we can more easily get the tscs.
event items. Fortunately this simplified many things
- As part of this refactor, I also fixed and long stating issue, which is that some non decoding errors were being inserted in the decoded thread. I changed this so that TraceIntelPT::Decode returns an error if the decoder couldn't be set up proplerly. Then, errors within a trace are actual anomalies found in between instrutions.

All test pass

Differential Revision: https://reviews.llvm.org/D128576
2022-06-29 09:19:51 -07:00
Craig Topper 7cbfb4eb7a [RISCV] Select (srl (and X, C2) as (slli (srliw X, C3), C3-C).
If C2 has 32 leading zeros and C3 trailing zeros.
2022-06-29 09:15:09 -07:00
Matt Arsenault ffd6aaf5b6 AMDGPU: Make packed 32-bit instructions rematerializable 2022-06-29 11:57:54 -04:00
Matt Arsenault 4c400dc103 AMDGPU: Make 16-bit pk instructions rematerializable 2022-06-29 11:57:53 -04:00
Matt Arsenault 03c0695fd8 AMDGPU: Add rematerialize tests for 16-bit pk instructions 2022-06-29 11:57:53 -04:00
Michał Górny 4a95861d73 [lldb] [test] Avoid relying on signos in other fork tests
Sponsored by: The FreeBSD Foundation
2022-06-29 17:48:36 +02:00
Florian Hahn 476f9c909c
[LV] Add test case showing dead recipe blocking region merging. 2022-06-29 16:34:12 +01:00
Matt Arsenault da6d7728d4 AMDGPU: Mark more instructions as rematerializable
D106023 excluded 16-bit instructions from rematerialization, with the
justification that we can't rematerialize instructions that preserve
the high bits (plus the instructions which do are a confusing mess
between different subtargets). This doesn't make sense to me as a
problem since cases where we would rely on the high bit behavior would
still need to be represented as a register value constraint with a
tied operand. It's not a hidden side effect and should still be
rematerializable.
2022-06-29 11:19:15 -04:00
Matt Arsenault 3ea812bb1b AMDGPU: Add more rematerialization tests for 16-bit instructions 2022-06-29 11:19:15 -04:00
Nikita Popov bdba8278d9 [VectorCombine] Avoid ConstantExpr::get() (NFC)
Use IRBuilder APIs instead, which will still constant fold.
2022-06-29 17:17:52 +02:00
Guillaume Chatelet 98007e9753 Revert "[libc][test] Remove dependency on sstream in algorithm_test.cpp"
This reverts commit 292b281caf.
2022-06-29 15:12:24 +00:00
Guillaume Chatelet 292b281caf [libc][test] Remove dependency on sstream in algorithm_test.cpp
Bots have been failing in full build mode because ´#include <sstream>´ would pull pthread which is not possible when code is compiled with ´-freestanding´.

Differential Revision: https://reviews.llvm.org/D128809
2022-06-29 14:53:53 +00:00
Nicolas Vasilache 0fb24a85cb [mlir][Tensor] Improve documentation of verification behavior of InsertSliceOp. 2022-06-29 07:52:54 -07:00
Nikita Popov 2124b2f0e6 [JumpThreading] Avoid ConstantExpr::get() (NFCI)
This code requires the result to be an UndefValue/ConstantInt
anyway (checked by getKnownConstant), so we are only interested
in the case where this folds.
2022-06-29 16:43:05 +02:00
Nicolas Vasilache 741f8f2bed [mlir][Tensor][NFC] Better document rank-reducing behavior of ExtractSliceOp and cleanup 2022-06-29 07:37:58 -07:00
Lei Huang caf7243a6b [PowerPC] Fix signatures for vec_replace_unaligned builtin
``vec_replace_unaligned`` is meant to return vuc to emphasize that elements
are being inserted on unnatural boundaries.

Reviewed By: amyk, quinnp

Differential Revision: https://reviews.llvm.org/D128288
2022-06-29 09:35:52 -05:00
Matt Arsenault d342d130da AMDGPU: Use isMeta flags on pseudoinstructions 2022-06-29 10:31:29 -04:00
Nikita Popov df698a5762 [InstCombine] Avoid some calls to ConstantExpr::get() (NFCI)
Replace some calls to ConstantExpr::get() with IRBuilder APIs
(which will also constant fold if possible).
2022-06-29 16:26:02 +02:00
Michał Górny e60ed2401b [lldb] [test] Un-XFAIL fork tests on arm as well
Sponsored by: The FreeBSD Foundation
2022-06-29 16:05:12 +02:00
Stephen Long f382545b2b [clang-cl] Handle some pragma alloc_text corner cases handled by MSVC
MSVC's pragma alloc_text accepts a function that was redeclared in
a non extern-C context if the previous declaration was in an extern-C
context. i.e.

```
extern "C" { static void f(); }
static void f();
```

MSVC's pragma alloc_text also rejects non-functions.

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D128649
2022-06-29 06:45:59 -07:00
Jay Foad 7758f3aa96 [AMDGPU] Remove FIXMEs that were resolved by D30134 2022-06-29 14:43:11 +01:00
Michał Górny 251165b2e4 [lldb] [test] Use raise(SIGSTOP) instead of trap in fork tests
Replace the use of "trap" with a new "stop" command in fork tests,
that maps to `raise(SIGSTOP)`.  Since traps do not increment PC on some
architectures (notably ARM), using traps would require special logic
to increment it while testing.  Using SIGSTOP avoids the problem
and is probably more logical, given that the purpose of the "trap"s
was to simply stop the inferior at a synchronization point.  This fixes
tests on AArch64 (and possibly ARM, I'll update XFAILs when it is
confirmed by the buildbot).

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D128780
2022-06-29 15:37:26 +02:00
Joseph Huber 56ab966a04 [CUDA] Stop adding CUDA features twice
We currently call the `addNVPTXFeatures` function in two places, inside
of the CUDA Toolchain and inside of Clang in the standard entry point.
We normally add features to the job in Clang, so the call inside of the
CUDA toolchain is redundant and results in `+ptx` features being added.
Since we remove this call, we no longer will have a cached CUDA
installation so we will usually create it twice.

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D128752
2022-06-29 09:34:09 -04:00
Haojian Wu 1ba7f5218c [pseudo] Update the cxx.bnf path in comments to reflect the new
location, NFC
2022-06-29 15:10:39 +02:00
Corentin Jabot 64ab2b1dcc Improve handling of static assert messages.
Instead of dumping the string literal (which
quotes it and escape every non-ascii symbol),
we can use the content of the string when it is a
8 byte string.

Wide, UTF-8/UTF-16/32 strings are still completely
escaped, until we clarify how these entities should
behave (cf https://wg21.link/p2361).

`FormatDiagnostic` is modified to escape
non printable characters and invalid UTF-8.

This ensures that unicode characters, spaces and new
lines are properly rendered in static messages.
This make clang more consistent with other implementation
and fixes this tweet
https://twitter.com/jfbastien/status/1298307325443231744 :)

Of note, `PaddingChecker` did print out new lines that were
later removed by the diagnostic printing code.
To be consistent with its tests, the new lines are removed
from the diagnostic.

Unicode tables updated to both use the Unicode definitions
and the Unicode 14.0 data.

U+00AD SOFT HYPHEN is still considered a print character
to match existing practices in terminals, in addition of
being considered a formatting character as per Unicode.

Reviewed By: aaron.ballman, #clang-language-wg

Differential Revision: https://reviews.llvm.org/D108469
2022-06-29 14:57:35 +02:00
Valentin Clement 62e907e9f9
[Flang] fix some types in error message 2022-06-29 14:55:53 +02:00
Pavel Labath 5e39198570 [lldb] Replace linux/uio.h with sys/uio.h in NativeRegisterContextLinux_s390x
Fixes PR56280.
2022-06-29 14:50:06 +02:00
Max Kazantsev abb8bf3671 [Test] Add XFAIL test for PR56243
This test demonstrates how sinking down gc.relocate may lead to breach
of LCSSA form by tokens and, consecutively, end up with SSA breach by
LoopSimplifyCFG which creates fake edges and is unable to update missing
LCSSA phis for tokens used outside of the loop.
2022-06-29 19:46:17 +07:00
Nikita Popov 1271b8f57a [Bitcode] Restore bitcast expression auto-upgrade
Restore the autoupgrade from bitcast to ptrtoint+inttoptr, which
was lost as part of D127729.

This fixes the backwards compatibility issue noted in:
https://reviews.llvm.org/D127729#inline-1236519
2022-06-29 14:35:56 +02:00
Nikita Popov 30ea6a0636 [SCEV] Don't create udiv constant expression (NFC)
Work on APInts to make it clear that this will not create a
constant expression.

This code path is not reached if the RHS is zero.
2022-06-29 14:35:05 +02:00
Valentin Clement be80c6d1b1
[flang][NFC] Cosmetic changes to make the file more homogenous
This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier

Differential Revision: https://reviews.llvm.org/D128799
2022-06-29 14:21:19 +02:00
Valentin Clement 7c65e62a51
[flang] Switch attr name to bindc_name
This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier

Differential Revision: https://reviews.llvm.org/D128788

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-06-29 14:20:35 +02:00
Mehdi Amini 84124ff891 Apply clang-tidy fixes for readability-simplify-boolean-expr in ViewLikeInterface.cpp (NFC) 2022-06-29 12:15:39 +00:00
Mehdi Amini be7997221d Apply clang-tidy fixes for readability-identifier-naming in Float16bits.cpp (NFC) 2022-06-29 12:13:57 +00:00