Commit Graph

428393 Commits

Author SHA1 Message Date
Sam Estep 2adaca532d [clang][dataflow] Use diagnosis API in optional checker
Followup to D127898. This patch updates `bugprone-unchecked-optional-access` to use the new `diagnoseCFG` function instead of just looking at the exit block.

A followup to this will update the optional model itself to use a noop lattice rather than redundantly computing the diagnostics in both phases of the analysis.

Reviewed By: ymandel, sgatev, gribozavr2, xazax.hun

Differential Revision: https://reviews.llvm.org/D128352
2022-06-29 19:50:36 +00:00
Sam Estep 2a33d12642 Revert "[clang][dataflow] Use diagnosis API in optional checker"
This reverts commit cafb8b4ff2.
2022-06-29 19:34:44 +00:00
Sam Estep 8361877b10 Revert "[clang][dataflow] Use NoopLattice in optional model"
This reverts commit 335c05f5d1.
2022-06-29 19:34:30 +00:00
Florian Hahn 6d5f814357
[LoopUnrollRuntime] Invalidate SCEV for exit phi in ConnectProlog.
ConnectProlog adds new incoming values to exit phi nodes which can
change the SCEV for the phi after 20d798bd47.

Fix is analog to cfc741bc0e.

Fixes #56286.
2022-06-29 20:28:43 +01:00
Muhammad Omair Javaid 9c6e043592 [LLDB] Allow API tests to override -gdwarf on Windows
This patch fixes LLDB API tests MakeFile.rules to allow overriding of
debug symbol flags when compiling tests for Windows.
Previously windows tests were forced to emit only dwarf debug symbols
as majority of the tests rely on dwarf debug info. After this patch
any test can override debug symbol flag by setting DEBUG_INFO_FLAG
variable in its make file.
2022-06-29 23:24:18 +04:00
River Riddle 0d9e51ea42 [mlir] Update the pass crash reproducer documentation
The reproducer is now encoded using an external resource, instead
of a comment at the top of the file.
2022-06-29 12:23:11 -07:00
Muhammad Omair Javaid f5ba0a3d05 Fix inline-record.test for Arm/Windows
This patch fixes inline-record.test to run on multiple platforms
including Arm/Windows. Test is fixed to expect any value for id
fields of functions and blocks returned by 'image lookup' command.
This field can be any value as it is internally generated id.
2022-06-29 23:21:02 +04:00
Sam Estep 335c05f5d1 [clang][dataflow] Use NoopLattice in optional model
Followup to D128352. This patch pulls the `NoopLattice` class out from the `NoopAnalysis.h` test file into its own `NoopLattice.h` source file, and uses it to replace usage of `SourceLocationsLattice` in `UncheckedOptionalAccessModel`.

Reviewed By: ymandel, sgatev, gribozavr2, xazax.hun

Differential Revision: https://reviews.llvm.org/D128356
2022-06-29 19:20:58 +00:00
Sam Estep cafb8b4ff2 [clang][dataflow] Use diagnosis API in optional checker
Followup to D127898. This patch updates `bugprone-unchecked-optional-access` to use the new `diagnoseCFG` function instead of just looking at the exit block.

A followup to this will update the optional model itself to use a noop lattice rather than redundantly computing the diagnostics in both phases of the analysis.

Reviewed By: ymandel, sgatev, gribozavr2, xazax.hun

Differential Revision: https://reviews.llvm.org/D128352
2022-06-29 19:20:09 +00:00
Sam Estep 58fe7f9683 [clang][dataflow] Add API to separate analysis from diagnosis
This patch adds an optional `PostVisitStmt` parameter to the `runTypeErasedDataflowAnalysis` function, which does one more pass over all statements in the CFG after a fixpoint is reached. It then defines a `diagnose` method for the optional model in a new `UncheckedOptionalAccessDiagnosis` class, but only integrates that into the tests and not the actual optional check for `clang-tidy`. That will be done in a followup patch.

The primary motivation is to separate the implementation of the unchecked optional access check into two parts, to allow for further refactoring of just the model part later, while leaving the checking part alone. Currently there is duplication between the `transferUnwrapCall` and `diagnoseUnwrapCall` functions, but that will be dealt with in the followup.

Because diagnostics are now all gathered into one collection rather than being populated at each program point like when computing a fixpoint, this patch removes the usage of `Pair` and `UnorderedElementsAre` from the optional model tests, and instead modifies all their expectations to simply check the stringified set of diagnostics against a single string, either `"safe"` or some concatenation of `"unsafe: input.cc:y:x"`. This is not ideal as it loses any connection to the `/*[[check]]*/` annotations in the source strings, but it does still retain the source locations from the diagnostic strings themselves.

Reviewed By: sgatev, gribozavr2, xazax.hun

Differential Revision: https://reviews.llvm.org/D127898
2022-06-29 19:18:39 +00:00
River Riddle 361acbb362 [mlir] Refactor pass crash reproducer generation to be an assembly resource
We currently generate reproducer configurations using a comment placed at
the top of the generated .mlir file. This is kind of hacky given that comments
have no semantic context in the source file and can easily be dropped. This
strategy also wouldn't work if/when we have a bitcode format. This commit
switches to using an external assembly resource, which is verifiable/can
work with a hypothetical bitcode naturally/and removes the awkward processing
from mlir-opt for splicing comments and re-applying command line options. With
the removal of command line munging, this opens up new possibilities for
executing reproducers in memory.

Differential Revision: https://reviews.llvm.org/D126447
2022-06-29 12:14:02 -07:00
River Riddle ea488bd6e1 [mlir] Allow for attaching external resources to .mlir files
This commit enables support for providing and processing external
resources within MLIR assembly formats. This is a mechanism with which
dialects, and external clients, may attach additional information when
printing IR without that information being encoded in the IR itself.
External resources are not uniqued within the MLIR context, are not
attached directly to any operation, and are solely intended to live and be
processed outside of the immediate IR. There are many potential uses of this
functionality, for example MLIR's pass crash reproducer could utilize this to
attach the pass resource executing when a crash occurs. Other types of
uses may be embedding large amounts of binary data, such as weights in ML
applications, that shouldn't be copied directly into the MLIR context, but
need to be kept adjacent to the IR.

External resources are encoded using a key-value pair nested within a
dictionary anchored by name either on a dialect, or an externally registered
entity. The key is an identifier used to disambiguate the data. The value
may be stored in various limited forms, but general encodings use a string
(human readable) or blob format (binary). Within the textual format, an
example may be of the form:

```mlir
{-#
  // The `dialect_resources` section within the file-level metadata
  // dictionary is used to contain any dialect resource entries.
  dialect_resources: {
    // Here is a dictionary anchored on "foo_dialect", which is a dialect
    // namespace.
    foo_dialect: {
      // `some_dialect_resource` is a key to be interpreted by the dialect,
      // and used to initialize/configure/etc.
      some_dialect_resource: "Some important resource value"
    }
  },
  // The `external_resources` section within the file-level metadata
  // dictionary is used to contain any non-dialect resource entries.
  external_resources: {
    // Here is a dictionary anchored on "mlir_reproducer", which is an
    // external entity representing MLIR's crash reproducer functionality.
    mlir_reproducer: {
      // `pipeline` is an entry that holds a crash reproducer pipeline
      // resource.
      pipeline: "func.func(canonicalize,cse)"
    }
  }
```

Differential Revision: https://reviews.llvm.org/D126446
2022-06-29 12:14:01 -07:00
Craig Topper 75095e6281 [RISCV] Pre-commit tests for D128843. NFC 2022-06-29 12:12:42 -07:00
Joseph Huber f892ddb3be [OpenMP] Add variant extension that applies to declarations
This patch adds a new extension to the `omp begin / end declare variant`
support that causes it to apply to function declarations as well. This
is explicitly not done in the standard, but can be useful in some
situations so we should provide it as an extension. This will allow us
to uniquely bind and overload existing definitions with a simple
declaration using variants.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D124624
2022-06-29 15:04:26 -04:00
Matt Arsenault 0bdaef38c9 AMDGPU: Add gfx11 feature to force initializing 16 input SGPRs
The total user+system SGPR count needs to be padded out to 16 if fewer
inputs are enabled.
2022-06-29 14:52:19 -04:00
Joseph Huber 34fc1db9a8 [LinkerWrapper] Change wrapping to include jumps for other variables
Summary:
We don't currently support other variable types, like managed or
surface. This patch simply adds code that checks the flags and does
nothing. This prevents us from registering a surface as a variable as we
do now. In the future, registering these will require adding the flags
to the entry struct.
2022-06-29 14:48:39 -04:00
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