Balazs Benics [Mon, 14 Feb 2022 15:55:55 +0000 (16:55 +0100)]
[analyzer] Add failing test case demonstrating buggy taint propagation
Recently we uncovered a serious bug in the `GenericTaintChecker`.
It was already flawed before D116025, but that was the patch that turned
this silent bug into a crash.
It happens if the `GenericTaintChecker` has a rule for a function, which
also has a definition.
char *fgets(char *s, int n, FILE *fp) {
nested_call(); // no parameters!
return (char *)0;
}
// Within some function:
fgets(..., tainted_fd);
When the engine inlines the definition and finds a function call within
that, the `PostCall` event for the call will get triggered sooner than the
`PostCall` for the original function.
This mismatch violates the assumption of the `GenericTaintChecker` which
wants to propagate taint information from the `PreCall` event to the
`PostCall` event, where it can actually bind taint to the return value
**of the same call**.
Let's get back to the example and go through step-by-step.
The `GenericTaintChecker` will see the `PreCall<fgets(..., tainted_fd)>`
event, so it would 'remember' that it needs to taint the return value
and the buffer, from the `PostCall` handler, where it has access to the
return value symbol.
However, the engine will inline fgets and the `nested_call()` gets
evaluated subsequently, which produces an unimportant
`PreCall<nested_call()>`, then a `PostCall<nested_call()>` event, which is
observed by the `GenericTaintChecker`, which will unconditionally mark
tainted the 'remembered' arg indexes, trying to access a non-existing
argument, resulting in a crash.
If it doesn't crash, it will behave completely unintuitively, by marking
completely unrelated memory regions tainted, which is even worse.
The resulting assertion is something like this:
Expr.h: const Expr *CallExpr::getArg(unsigned int) const: Assertion
`Arg < getNumArgs() && "Arg access out of range!"' failed.
The gist of the backtrace:
CallExpr::getArg(unsigned int) const
SimpleFunctionCall::getArgExpr(unsigned int)
CallEvent::getArgSVal(unsigned int) const
GenericTaintChecker::checkPostCall(const CallEvent &, CheckerContext&) const
Prior to D116025, there was a check for the argument count before it
applied taint, however, it still suffered from the same underlying
issue/bug regarding propagation.
This path does not intend to fix the bug, rather start a discussion on
how to fix this.
---
Let me elaborate on how I see this problem.
This pre-call, post-call juggling is just a workaround.
The engine should by itself propagate taint where necessary right where
it invalidates regions.
For the tracked values, which potentially escape, we need to erase the
information we know about them; and this is exactly what is done by
invalidation.
However, in the case of taint, we basically want to approximate from the
opposite side of the spectrum.
We want to preserve taint in most cases, rather than cleansing them.
Now, we basically sanitize all escaping tainted regions implicitly,
since invalidation binds a fresh conjured symbol for the given region,
and that has not been associated with taint.
IMO this is a bad default behavior, we should be more aggressive about
preserving taint if not further spreading taint to the reachable
regions.
We have a couple of options for dealing with it (let's call it //tainting
policy//):
1) Taint only the parameters which were tainted prior to the call.
2) Taint the return value of the call, since it likely depends on the
tainted input - if any arguments were tainted.
3) Taint all escaped regions - (maybe transitively using the cluster
algorithm) - if any arguments were tainted.
4) Not taint anything - this is what we do right now :D
The `ExprEngine` should not deal with taint on its own. It should be done
by a checker, such as the `GenericTaintChecker`.
However, the `Pre`-`PostCall` checker callbacks are not designed for this.
`RegionChanges` would be a much better fit for modeling taint propagation.
What we would need in the `RegionChanges` callback is the `State` prior
invalidation, the `State` after the invalidation, and a `CheckerContext` in
which the checker can create transitions, where it would place `NoteTags`
for the modeled taint propagations and report errors if a taint sink
rule gets violated.
In this callback, we could query from the prior State, if the given
value was tainted; then act and taint if necessary according to the
checker's tainting policy.
By using RegionChanges for this, we would 'fix' the mentioned
propagation bug 'by-design'.
Reviewed By: Szelethus
Differential Revision: https://reviews.llvm.org/D118987
Guillaume Chatelet [Mon, 14 Feb 2022 15:55:27 +0000 (15:55 +0000)]
[libc][benchmark] Fix change in JSon API
Arthur O'Dwyer [Mon, 14 Feb 2022 15:30:36 +0000 (10:30 -0500)]
[libc++] Remove U+2009 THIN SPACE from comments in tests. NFC.
Arthur O'Dwyer [Mon, 14 Feb 2022 15:26:25 +0000 (10:26 -0500)]
[libc++] Remove U+00AD SOFT HYPHEN from comments in tests. NFC.
git grep $(printf '\xc2\xad') ../libcxx
phyBrackets [Mon, 14 Feb 2022 15:24:21 +0000 (20:54 +0530)]
[analyzer][NFCi] Use the correct BugType in CStringChecker.
There is different bug types for different types of bugs but the **emitAdditionOverflowbug** seems to use bugtype **BT_NotCSting** but actually it have to use **BT_AdditionOverflow** .
Reviewed By: steakhal
Differential Revision: https://reviews.llvm.org/D119462
Aaron Ballman [Mon, 14 Feb 2022 14:43:47 +0000 (09:43 -0500)]
Fix the Sphinx build
Add a heading to appease the Sphinx bot, and add some basic
documentation for [[_Noreturn]].
Aaron Ballman [Mon, 14 Feb 2022 14:33:48 +0000 (09:33 -0500)]
Implement WG14 N2764 the [[noreturn]] attribute
This adds support for http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2764.pdf,
which was adopted at the Feb 2022 WG14 meeting. That paper adds
[[noreturn]] and [[_Noreturn]] to the list of supported attributes in
C2x. These attributes have the same semantics as the [[noreturn]]
attribute in C++.
The [[_Noreturn]] attribute was added as a deprecated feature so that
translation units which include <stdnoreturn.h> do not get an error on
use of [[noreturn]] because the macro expands to _Noreturn. Users can
use -Wno-deprecated-attributes to silence the diagnostic.
Use of <stdnotreturn.h> or the noreturn macro were both deprecated.
Users can define the _CLANG_DISABLE_CRT_DEPRECATION_WARNINGS macro to
suppress the deprecation diagnostics coming from the header file.
Momchil Velikov [Mon, 14 Feb 2022 13:41:34 +0000 (13:41 +0000)]
Extend the `uwtable` attribute with unwind table kind
We have the `clang -cc1` command-line option `-funwind-tables=1|2` and
the codegen option `VALUE_CODEGENOPT(UnwindTables, 2, 0) ///< Unwind
tables (1) or asynchronous unwind tables (2)`. However, this is
encoded in LLVM IR by the presence or the absence of the `uwtable`
attribute, i.e. we lose the information whether to generate want just
some unwind tables or asynchronous unwind tables.
Asynchronous unwind tables take more space in the runtime image, I'd
estimate something like 80-90% more, as the difference is adding
roughly the same number of CFI directives as for prologues, only a bit
simpler (e.g. `.cfi_offset reg, off` vs. `.cfi_restore reg`). Or even
more, if you consider tail duplication of epilogue blocks.
Asynchronous unwind tables could also restrict code generation to
having only a finite number of frame pointer adjustments (an example
of *not* having a finite number of `SP` adjustments is on AArch64 when
untagging the stack (MTE) in some cases the compiler can modify `SP`
in a loop).
Having the CFI precise up to an instruction generally also means one
cannot bundle together CFI instructions once the prologue is done,
they need to be interspersed with ordinary instructions, which means
extra `DW_CFA_advance_loc` commands, further increasing the unwind
tables size.
That is to say, async unwind tables impose a non-negligible overhead,
yet for the most common use cases (like C++ exceptions), they are not
even needed.
This patch extends the `uwtable` attribute with an optional
value:
- `uwtable` (default to `async`)
- `uwtable(sync)`, synchronous unwind tables
- `uwtable(async)`, asynchronous (instruction precise) unwind tables
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D114543
Florian Hahn [Mon, 14 Feb 2022 14:28:49 +0000 (14:28 +0000)]
[DSE] Add additional tests with unreachable exits.
Adds tests for #53800.
Simon Pilgrim [Mon, 14 Feb 2022 14:14:16 +0000 (14:14 +0000)]
[InstCombine] Add test coverage for Issue #53610
Nikita Popov [Mon, 14 Feb 2022 14:14:41 +0000 (15:14 +0100)]
[ItaniumCXXABI] Avoid pointer element type accesses
Serguei Katkov [Mon, 14 Feb 2022 13:12:24 +0000 (20:12 +0700)]
[Safepoint Verifier] Add a false positive test.
Nikita Popov [Mon, 14 Feb 2022 13:18:04 +0000 (14:18 +0100)]
[CGBuilder] Remove CreateBitCast() method
Use CreateElementBitCast() instead, or don't work on Address
where not necessary.
Aaron Ballman [Mon, 14 Feb 2022 13:53:36 +0000 (08:53 -0500)]
Check for the overloadable attribute in all the appropriate syntactic locations
When forming the function type from a declarator, we look for an
overloadable attribute before issuing a diagnostic in C about a
function signature containing only .... When the attribute is present,
we allow such a declaration for compatibility with the overloading
rules in C++. However, we were not looking for the attribute in all of
the places it is legal to write it on a declarator and so we only
accepted the signature in some forms and incorrectly rejected the
signature in others.
We now check for the attribute preceding the declarator instead of only
being applied to the declarator directly.
David Spickett [Mon, 14 Feb 2022 13:36:51 +0000 (13:36 +0000)]
[compiler-rt][xray] Disable fdr-reinit test on Arm
This test is still seemingly randomly segfaulting on Arm:
https://lab.llvm.org/buildbot/#/builders/178/builds/1547
Though it seems to fail earlier in the test than on AArch64.
Investigation continues.
gysit [Mon, 14 Feb 2022 13:02:11 +0000 (13:02 +0000)]
[mlir][linalg] Add attributes to region builder (NFC).
Adapt the region builder signature to hand in the attributes of the created ops. The revision is a preparation step the support named ops that need access to the operation attributes during op creation.
Depends On D119692
Reviewed By: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D119693
Nikita Popov [Mon, 14 Feb 2022 13:07:22 +0000 (14:07 +0100)]
[DeadArgElim] Check that function type is the same
If the function types differ, the call arguments don't necessarily
correspon to the function arguments. It's likely not worthwhile to
handle this more precisely, but at least we shouldn't crash.
Marek Kurdej [Mon, 14 Feb 2022 13:05:05 +0000 (14:05 +0100)]
[clang-format] Reformat. NFC.
gysit [Mon, 14 Feb 2022 12:55:48 +0000 (12:55 +0000)]
[mlir][OpDSL] Restructure comprehension.py (NFC).
Group and reorder the classed defined by comprehension.py and add type annotations.
Depends On D119126
Reviewed By: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D119692
gysit [Mon, 14 Feb 2022 12:12:15 +0000 (12:12 +0000)]
[mlir][OpDSL] Add default value to index attributes.
Index attributes had no default value, which means the attribute values had to be set on the operation. This revision adds a default parameter to `IndexAttrDef`. After the change, every index attribute has to define a default value. For example, we may define the following strides attribute:
```
```
When using the operation the default stride is used if the strides attribute is not set. The mechanism is implemented using `DefaultValuedAttr`.
Additionally, the revision uses the naming index attribute instead of attribute more consistently, which is a preparation for follow up revisions that will introduce function attributes.
Depends On D119125
Reviewed By: stellaraccident
Differential Revision: https://reviews.llvm.org/D119126
Nathan Sidwell [Fri, 11 Feb 2022 13:54:40 +0000 (05:54 -0800)]
[demangler][NFC] Tweak legacy uuidof handling
We have to special-case 'u 8__uuidof [tz]' demangling for legacy
support. That handling is a little duplicative.
* It seems better to just push the single expected node.
* We can also use 'consumeIf' rather than open-coding the peeking and increment.
* We don't need the numLeft < 2 check, as if there are few than that
other paths will end up with detecting the error.
FWIW This simplifies a future change adding operator precedence.
Reviewed By: ChuanqiXu
Differential Revision: https://reviews.llvm.org/D119543
Nathan Sidwell [Mon, 7 Feb 2022 19:33:08 +0000 (11:33 -0800)]
[demangler] Fix buffer growth
The output buffer growth algorithm had a few issues:
a) An off-by-one error in the initial size check, which uses
'>='. This error was safe, but could cause us to reallocate when there
was no need.
b) An inconsistency between the initial size check (>=) and the
post-doubling check (>). The latter was somewhat obscured by the
swapped operands.
c) There would be many reallocs with an initially-small buffer. Add a
little initialization hysteresis.
Reviewed By: ChuanqiXu
Differential Revision: https://reviews.llvm.org/D119177
Nikita Popov [Mon, 14 Feb 2022 11:55:07 +0000 (12:55 +0100)]
[Docs] Update OpaquePointers transition state (NFC)
We're at a point where working optimized binaries can be produced
in opaque pointer mode.
David Green [Mon, 14 Feb 2022 11:55:40 +0000 (11:55 +0000)]
[ARM] MVE hadd and rhadd
This uses the nodes from D106237 to add MVE HADD and RHADD lowering.
Differential Revision: https://reviews.llvm.org/D106238
Anton Afanasyev [Sat, 12 Feb 2022 08:46:49 +0000 (11:46 +0300)]
[SLP] Simplify indices processing for insertelements
Get rid of non-constant and undef indices of insertelements
at `buildTree()` stage. Fix bugs.
Differential Revision: https://reviews.llvm.org/D119623
LLVM GN Syncbot [Mon, 14 Feb 2022 11:30:41 +0000 (11:30 +0000)]
[gn build] Port
55bd22f853d8
Konstantin Varlamov [Mon, 14 Feb 2022 11:29:18 +0000 (03:29 -0800)]
[libc++][ranges] Implement rbegin, rend, crbegin and crend.
Differential Revision: https://reviews.llvm.org/D119057
gysit [Mon, 14 Feb 2022 10:55:23 +0000 (10:55 +0000)]
[mlir][OpDSL] Consistently use the term op_def (NFC).
... and remove unused type aliases.
Depends On D119003
Reviewed By: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D119125
David Green [Mon, 14 Feb 2022 11:18:35 +0000 (11:18 +0000)]
[DAGCombine] Basic combines for AVG nodes.
This adds very basic combines for AVG nodes, mostly for constant folding
and handling degenerate (zero) cases. The code performs mostly the same
transforms as visitMULHS, adjusted for AVG nodes.
Constant folding extends to a higher bitwidth and drops the lowest bit.
For undef nodes, `avg undef, x` is transformed to x. There is also a
transform for `avgfloor x, 0` transforming to `shr x, 1`.
Differential Revision: https://reviews.llvm.org/D119559
Tim Northover [Thu, 10 Feb 2022 13:28:50 +0000 (13:28 +0000)]
Reapply: StackProtector: ignore debug insts when splitting blocks.
When deciding where to split a block to insert stack guard checks, we should
move past any debug instructions we see that might (e.g.) be separating a tail
call from its frame wrangling.
This time, also don't run off the front of a basic block.
Peter Waller [Tue, 8 Feb 2022 16:26:58 +0000 (16:26 +0000)]
[gn build] Add host_cpu=arm64 & current_os=linux => aarch64-unknown-linux-gnu
I've been using this triple in development for a while without issues,
it's passing check-llvm and check-clang.
(The above is the commit message, but the build is currently broken since
D114639, I intend to submit this once it's passing again and it's accepted in
review)
Differential Revision: https://reviews.llvm.org/D119331
Nikita Popov [Mon, 14 Feb 2022 10:46:07 +0000 (11:46 +0100)]
[InstCombine] Check GEP source type in select of gep fold
This is no longer implicitly checked through the pointer type
with opaque pointers.
Evgeny Shulgin [Mon, 14 Feb 2022 10:28:22 +0000 (11:28 +0100)]
[clang-tidy] Ignore variable template partial specializations in `misc-definitions-in-headers`
Variable template partial specializations are inline and can't lead
to ODR-violations. The checker now ignores them.
Fixes https://github.com/llvm/llvm-project/issues/53519
Reviewed By: hokein
Differential Revision: https://reviews.llvm.org/D119098
Jean Perier [Mon, 14 Feb 2022 10:36:32 +0000 (11:36 +0100)]
[flang] Fail at link time if derived type descriptors were not generated
Currently, code generation was creating weak symbols for derived type
descriptor global it could not find in the current compilation unit.
The rational is that:
- the derived type descriptors of external module derived types are
generated in the compilation unit that compiled the module so that
the type descriptor address is uniquely associated with the type.
- some types do not have derived type descriptors: the builtin derived
types used to create derived type descriptors. The runtime knows
about them and does not need them to accomplish the feat of
describing themselves. Hence, all unresolved derived type descriptors
in codegen cannot be assumed to be resolved at link time.
However, this caused immense debugging pain when, for some reasons, derived
type descriptor that should be generated were not. This caused random
runtime failures instead of a much cleaner link time failure.
Improve this situation by allowing codegen to detect the builtin derived
types that have no derived type descriptors and requiring the other
unresolved derived type descriptor to be resolved at link time.
Also make derived type descriptor constant data since this was a TODO
and makes the situation even cleaner. This requiring telling lowering
which compiler created symbols can be placed in read only memory. I
considered using PARAMETER, but I have mixed feeling using it since that
would cause the initializer expressions of derived type descriptor to
be invalid from a Fortran point of view since pointer targets cannot be
parameters. I do not want to start misusing Fortran attributes, even if
I think it is quite unlikely semantics would currently complain. I also
do not want to rely on the fact that all object symbols with the
CompilerCreated flags are currently constant data. This could easily
change in the future and cause runtime bugs if lowering rely on this
while the assumption is not loud and clear in semantics.
Instead, add a ReadOnly symbol flag to tell lowering that a compiler
generated symbol can be placed in read only memory.
Differential Revision: https://reviews.llvm.org/D119555
David Green [Mon, 14 Feb 2022 10:19:34 +0000 (10:19 +0000)]
[AArch64] Additional tests for AVG node combines. NFC
Nikita Popov [Mon, 14 Feb 2022 10:15:43 +0000 (11:15 +0100)]
[BitcodeReader] Rename method for element type by ID (NFC)
Make it clearer that this method is specifically for pointer
element types, and not other element types. This distinction will
be relevant in the future.
The somewhat unusual spelling is to make sure this does not show
up when grepping for getPointerElementType.
Nikita Popov [Mon, 14 Feb 2022 10:05:10 +0000 (11:05 +0100)]
[InstCombine] Remove manual debug loc transfer
While this might be marginally more precise, we generally don't
bother with this in InstCombine, and let the IRBuilder assign the
debug location. I don't see why this one fold, out of the thousands
done in InstCombine, should be treated specially.
Jay Foad [Mon, 14 Feb 2022 09:57:29 +0000 (09:57 +0000)]
[AMDGPU] Fix line endings. NFC.
Nikita Popov [Mon, 14 Feb 2022 09:50:27 +0000 (10:50 +0100)]
[CVP] Extract helper from phi processing (NFC)
So we can use early returns and avoid those awkward !V checks.
Nikita Popov [Mon, 14 Feb 2022 09:22:41 +0000 (10:22 +0100)]
[polly] Remove uses of PointerType::getElementType()
This method has been removed. I missed these uses in conditionally-
compiled code previously.
Marek Kurdej [Mon, 14 Feb 2022 09:11:53 +0000 (10:11 +0100)]
[llvm] Don't use LLVM_ATTRIBUTE_UNUSED for variables. NFC.
At least on MSVC, it does nothing and still causes a warning.
Marek Kurdej [Sun, 13 Feb 2022 20:56:37 +0000 (21:56 +0100)]
[clang-format] Fix SpacesInLineCommentPrefix deleting tokens.
Fixes https://github.com/llvm/llvm-project/issues/53799.
Reviewed By: HazardyKnusperkeks, owenpan
Differential Revision: https://reviews.llvm.org/D119680
Ivan Butygin [Sun, 13 Feb 2022 13:28:29 +0000 (16:28 +0300)]
[mlir][arith] Do not limit arith-expand pass to FuncOp
This pass doesn't have any limitations specific to FuncOp and it will be useful to be able to run it on other ops (e.g. gpu.func).
Differential Revision: https://reviews.llvm.org/D119662
Nikita Popov [Mon, 14 Feb 2022 08:43:59 +0000 (09:43 +0100)]
[lldb] Remove some uses of getPointerElementType()
While in the area, remove some uses of getPointerElementType()
that have obvious replacements.
Marek Kurdej [Sat, 12 Feb 2022 21:17:47 +0000 (22:17 +0100)]
[clang-format] Fix PointerAlignment within lambdas in a multi-variable declaration statement.
Fixes https://github.com/llvm/llvm-project/issues/43115.
Also, handle while loops with initializers (C++20) the same way as for loops.
Reviewed By: HazardyKnusperkeks, owenpan
Differential Revision: https://reviews.llvm.org/D119648
Nikita Popov [Mon, 14 Feb 2022 08:31:27 +0000 (09:31 +0100)]
[lldb] Remove uses of PointerType::getElementType()
This method has been deprecated and removed. I missed these usages
in lldb previously.
Dávid Bolvanský [Mon, 14 Feb 2022 08:32:41 +0000 (09:32 +0100)]
[AlwaysInliner] Check for callsite noinline attribute simplified
Nikita Popov [Thu, 10 Feb 2022 11:45:32 +0000 (12:45 +0100)]
[FastISel] Reuse register for bitcast that does not change MVT
The current FastISel code reuses the register for a bitcast that
doesn't change the IR type, but uses a reg-to-reg copy if it
changes the IR type without changing the MVT. However, we can
simply reuse the register in that case as well.
In particular, this avoids unnecessary reg-to-reg copies for pointer
bitcasts. This was found while inspecting O0 codegen differences
between typed and opaque pointers.
Differential Revision: https://reviews.llvm.org/D119432
Nikita Popov [Mon, 14 Feb 2022 07:49:01 +0000 (08:49 +0100)]
[IR] Remove deprecated PointerType::getElementType()
This was deprecated before the LLVM 14 branch cut, remove the
method now.
As a temporary workaround, Type::getPointerElementType() can be
used instead.
See https://llvm.org/docs/OpaquePointers.html for information on
the opaque pointers migration.
jacquesguan [Tue, 8 Feb 2022 03:32:42 +0000 (11:32 +0800)]
[RISCV] Recover the implication between Zve* extensions and the V extension.
This revision recover the implication between Zve* extensions and the V extension.
Differential Revision: https://reviews.llvm.org/D119210
Simon Moll [Mon, 14 Feb 2022 07:46:55 +0000 (08:46 +0100)]
[VE] v256i1 and|or|xor isel and tests
Reviewed By: kaz7
Differential Revision: https://reviews.llvm.org/D119239
Balázs Kéri [Wed, 22 Dec 2021 11:11:50 +0000 (12:11 +0100)]
[clang][AST][ASTImporter] Set record to complete during import of its members.
At import of a member it may require that the record is already set to complete.
(For example 'computeDependence' at create of some Expr nodes.)
The record at this time may not be completely imported, the result of layout
calculations can be incorrect, but at least no crash occurs this way.
A good solution would be if fields of every encountered record are imported
before other members of all records. This is much more difficult to implement.
Differential Revision: https://reviews.llvm.org/D116155
Chuanqi Xu [Mon, 14 Feb 2022 06:35:37 +0000 (14:35 +0800)]
[NFC] Precommit for PR53357
Due to there are other required changes in
https://reviews.llvm.org/D118094, precommit these changes to ease
reviewing. Including:
- Remove *_thwart tests.
- Remove test for (x & y) + (~x & ~y)
- Fix incorrect uniitest committeed before
Chuanqi Xu [Mon, 14 Feb 2022 06:09:26 +0000 (14:09 +0800)]
[NFC] [ValueTracking] Add unittest for haveNoCommonBitsSet
Phoebe Wang [Mon, 14 Feb 2022 04:55:43 +0000 (12:55 +0800)]
[X86][MS] Add 80bit long double support for Windows
MSVC currently doesn't support 80 bits long double. But ICC does support
it on Windows. Besides, there're also some users asked for this feature.
We can find the discussions from stackoverflow, msdn etc.
Given Clang has already support `-mlong-double-80`, extending it to
support for Windows seems worthwhile.
Reviewed By: rnk, erichkeane
Differential Revision: https://reviews.llvm.org/D115441
Haowei Wu [Wed, 12 Jan 2022 05:16:49 +0000 (21:16 -0800)]
[ifs] Allow llvm-ifs to generate text stub from elf stub
ELF stubs generated from llvm-ifs lacks program headers, which prevents
llvm-ifs from parsing them properly as program headers are required by
llvm's own ELF libraries. This patch adds a few workaround bypass this
limitation.
Differential Revision: https://reviews.llvm.org/D116769
Haowei Wu [Tue, 11 Jan 2022 22:45:57 +0000 (14:45 -0800)]
[ifs] Added missing DT_STRSZ to the .dynamic section
This patch adds DT_STRSZ into the dynamic section, which was absent
previously. This was a bug and caused failures in other tools.
Differential Revision: https://reviews.llvm.org/D117058
eopXD [Fri, 11 Feb 2022 12:41:12 +0000 (04:41 -0800)]
[RISCV] Fix RISCVTargetInfo::initFeatureMap, add non-ISA features back after implication
Previously D113336 makes RISCVTargetInfo::initFeatureMap return the results
processed by RISCVISAInfo, which only consists of ISA features and misses
non-ISA features like `relax` and `save-restore`.
This patch fixes the problem.
Reviewed By: junparser
Differential Revision: https://reviews.llvm.org/D119541
Teresa Johnson [Mon, 14 Feb 2022 03:38:50 +0000 (19:38 -0800)]
[sanitizer] Skip test on Android where chmod is not working
Third attempt to fix a bot failure from
634da7a1c61ee8c173e90a841eb1f4ea03caa20b on an Android bot:
https://lab.llvm.org/buildbot#builders/77/builds/14339
My last attempt used an approach from another test where chmod was not
working of using a bad character in the path name. But it looks like
this trick only works on Windows.
Instead, restore the original version of this test before my change at
634da7a1c61ee8c173e90a841eb1f4ea03caa20b and move the bad path test to
a new test file, marking it unsupported on Android.
Shao-Ce SUN [Mon, 14 Feb 2022 03:37:41 +0000 (11:37 +0800)]
[NFC][RISCV] Remove redundant `Returned`
Lang Hames [Fri, 11 Feb 2022 07:45:45 +0000 (23:45 -0800)]
[llvm-jitlink] Fix a bug in llvm-jitlink's Slab allocator.
The slab delta (used to link as if allocated at a specified address) should
remain constant.The update to the delta was accidentally introduced in
962a2479b57f5, but hasn't caused any failures as it only breaks in an obvious
way for multi-file exec uses (our regression tests are all -noexec, and tend to
be single-file).
No testcase here: this is an obscure utility for testing support, and an
uncommon use-case. If the slab allocator is ever moved into LLVM we could add
a unit test to catch this.
Craig Topper [Mon, 14 Feb 2022 02:56:18 +0000 (18:56 -0800)]
[DAGCombiner] Use getShiftAmountConstant in DAGCombiner::foldSelectOfConstants.
This enables fshl to be matched earlier on X86
%6 = lshr i32 %3, 1
%7 = select i1 %4, i32 -
2147483648, i32 0
%8 = or i32 %6, %7
X86 uses i8 for shift amounts. SelectionDAGBuilder creates the
ISD::SRL with an i8 shift type. DAGCombiner turns the select into
an ISD::SHL. Prior to this patch it would use i32 for the shift
amount. fshl matching failed because the shift amounts have different
types. LegalizeDAG fixes the ISD::SHL shift amount to i8. This
allowed fshl matching to succeed.
With this patch, the ISD::SHL will be created with an i8 shift
amount. This allows the fshl to match immediately.
No test case beause we still end up with a fshl either way.
zhongyunde [Mon, 14 Feb 2022 01:27:49 +0000 (09:27 +0800)]
[IVDescriptors] Support FOR where we have multiple sink pointed
Handles the case where Previous doesn't come before LastPrev incorrectly.
Fix https://github.com/llvm/llvm-project/issues/53483
Reviewed By: fhahn
Differential Revision: https://reviews.llvm.org/D118558
Teresa Johnson [Mon, 14 Feb 2022 01:00:04 +0000 (17:00 -0800)]
[sanitizer] Second test fix to tolerate chmod not working as intended
Second attempt to fix a bot failure from
634da7a1c61ee8c173e90a841eb1f4ea03caa20b on an Android bot:
https://lab.llvm.org/buildbot#builders/77/builds/14339
With the fix in
986afe847951a59cd66783e1377b13cec6412972 there was a
different issue, because we need the fully qualified path name to the
binary, which is only available in arg[0]. New failure:
https://lab.llvm.org/buildbot/#/builders/77/builds/14346/steps/16/logs/stdio
Restructure the test so both attempts are made from the same invocation,
which sets up the bad paths directly.
Simon Pilgrim [Sun, 13 Feb 2022 20:49:52 +0000 (20:49 +0000)]
[X86] combineArithReduction - pull out (near) duplicate v4i8/v8i8 widening code. NFC.
Marek Kurdej [Sun, 13 Feb 2022 21:01:06 +0000 (22:01 +0100)]
Avoid a vulgarism. NFC.
Marek Kurdej [Sat, 12 Feb 2022 21:46:14 +0000 (22:46 +0100)]
[clang-format] Handle PointerAlignment in `if` and `switch` statements with initializers (C++17) the same way as in `for` loops.
Reviewed By: MyDeveloperDay, owenpan
Differential Revision: https://reviews.llvm.org/D119650
Marek Kurdej [Fri, 11 Feb 2022 13:53:36 +0000 (14:53 +0100)]
[clang-format] Correctly format loops and `if` statements even if preceded with comments.
Fixes https://github.com/llvm/llvm-project/issues/53758.
Braces in loops and in `if` statements with leading (block) comments were formatted according to `BraceWrapping.AfterFunction` and not `AllowShortBlocksOnASingleLine`/`AllowShortLoopsOnASingleLine`/`AllowShortIfStatementsOnASingleLine`.
Previously, the code:
```
while (true) {
f();
}
/*comment*/ while (true) {
f();
}
```
was incorrectly formatted to:
```
while (true) {
f();
}
/*comment*/ while (true) { f(); }
```
when using config:
```
BasedOnStyle: LLVM
BreakBeforeBraces: Custom
BraceWrapping:
AfterFunction: false
AllowShortBlocksOnASingleLine: false
AllowShortLoopsOnASingleLine: false
```
and it was (correctly but by chance) formatted to:
```
while (true) {
f();
}
/*comment*/ while (true) {
f();
}
```
when using enabling brace wrapping after functions:
```
BasedOnStyle: LLVM
BreakBeforeBraces: Custom
BraceWrapping:
AfterFunction: true
AllowShortBlocksOnASingleLine: false
AllowShortLoopsOnASingleLine: false
```
Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan
Differential Revision: https://reviews.llvm.org/D119649
Teresa Johnson [Sun, 13 Feb 2022 16:39:59 +0000 (08:39 -0800)]
[sanitizer] Fix test to tolerate chmod not working as intended
Attempts to fix a bot failure from
634da7a1c61ee8c173e90a841eb1f4ea03caa20b on an Android bot:
https://lab.llvm.org/buildbot#builders/77/builds/14339
It appears that the chmod is not making the directory unwritable as
expected on this system for some reason. Adopt an approach used in
compiler-rt/test/fuzzer/fuzzer-dirs.test for systems with
non-functioning chmod by including illegal characters in directory.
Simon Pilgrim [Sun, 13 Feb 2022 19:40:01 +0000 (19:40 +0000)]
[X86] vector-reduce-add-sext - add sum of (sign-extended) bool vector tests
Markus Böck [Sun, 13 Feb 2022 10:14:42 +0000 (11:14 +0100)]
[llvm][doc] Add Aarch64 to list of architectures supporting statepoints
Fixes https://github.com/llvm/llvm-project/issues/53655
Differential Revision: https://reviews.llvm.org/D119659
Simon Pilgrim [Sun, 13 Feb 2022 19:23:16 +0000 (19:23 +0000)]
[X86] Add AVX512 tests to AVX common check prefix
Dmitry Vassiliev [Sun, 13 Feb 2022 18:47:37 +0000 (21:47 +0300)]
[NFC][IR] Value: assert this->takeName(this)
Need to add an assert about this->takeName(this). This restriction is already documented, so this is just an NFC check.
Without this assertion (as prescribed by original comments for this API), name deletion or down-stream assert failures may occur in other routines: e.g. at the beginning of replaceAllUsesWith() below.
Reviewed By: aeubanks
Differential Revision: https://reviews.llvm.org/D119636
Ivan Butygin [Sun, 13 Feb 2022 14:51:59 +0000 (17:51 +0300)]
[mlir][tensor] Check ops generated by InsertSliceOpCastFolder are valid
Fixes https://github.com/llvm/llvm-project/issues/53099
Differential Revision: https://reviews.llvm.org/D119663
Arthur Eubanks [Sun, 13 Feb 2022 01:37:20 +0000 (17:37 -0800)]
[OpaquePtr][ValueTracking] Check GEP source element type in isPointerOffset()
Fixes a MemCpyOpt miscompile with opaque pointers.
This function can be further cleaned up, but let's just fix the miscompile first.
Reviewed By: #opaque-pointers, nikic
Differential Revision: https://reviews.llvm.org/D119652
Kazu Hirata [Sun, 13 Feb 2022 18:34:05 +0000 (10:34 -0800)]
[IR] Use default member initialization in IRBuilderBase (NFC)
Kazu Hirata [Sun, 13 Feb 2022 18:34:03 +0000 (10:34 -0800)]
[Transforms] Use default member initialization in MemmoveVerifier (NFC)
Kazu Hirata [Sun, 13 Feb 2022 18:34:02 +0000 (10:34 -0800)]
[Transforms] Use default member initialization in Prefetch (NFC)
Kazu Hirata [Sun, 13 Feb 2022 18:34:00 +0000 (10:34 -0800)]
[Transforms] Use default member initialization in ConditionInfo (NFC)
Kazu Hirata [Sun, 13 Feb 2022 18:33:58 +0000 (10:33 -0800)]
[Support] Use default member initialization in circular_raw_ostream (NFC)
Kazu Hirata [Sun, 13 Feb 2022 18:33:56 +0000 (10:33 -0800)]
[Transforms] Use default member initialization in CHRStats (NFC)
Keith Smiley [Sun, 13 Feb 2022 18:05:50 +0000 (10:05 -0800)]
[test][ObjectYAML][MachO] Fix assertion syntax
This wasn't running because of the missing colon
Nathan Chancellor [Sun, 13 Feb 2022 17:23:32 +0000 (10:23 -0700)]
Revert "[AArch64] Adds SUBS and ADDS instructions to the MIPeepholeOpt."
This reverts commit
af45d0fd94b21620b61c8c4900b81486fd85aeb7.
This causes assertions failures when compiling the Linux kernel. See
https://reviews.llvm.org/D118663 for a reduced reproducer.
Keith Smiley [Tue, 8 Feb 2022 01:33:32 +0000 (17:33 -0800)]
[ObjectYAML][MachO] Add LC_FUNCTION_STARTS support
This adds support for encoding and decoding the LC_FUNCTION_STARTS load
command payload.
Differential Revision: https://reviews.llvm.org/D119205
Benjamin Kramer [Sun, 13 Feb 2022 15:57:48 +0000 (16:57 +0100)]
[Shape] Simplify getShapeVec a bit. NFCI.
Teresa Johnson [Thu, 10 Feb 2022 23:42:38 +0000 (15:42 -0800)]
[sanitizer] Check if directory exists before trying to create
Add a DirExists mechanism, modeled after FileExists. Use it to guard
creation of the report path directory.
This should avoid failures running the sanitizer in a sandbox where the
file creation attempt causes hard failures, even for an existing
directory. Problem reported on D109794 for ChromeOS in sandbox
(https://issuetracker.google.com/
209296420).
Differential Revision: https://reviews.llvm.org/D119495
Simon Pilgrim [Sun, 13 Feb 2022 13:43:22 +0000 (13:43 +0000)]
[X86] Add test for PR38788 missing PTEST fold
Sanjay Patel [Sun, 13 Feb 2022 13:21:57 +0000 (08:21 -0500)]
[x86] try harder to scalarize a vector load with extracted integer op uses
This is a retry of
b4b97ec813a0 - that was reverted because it
could cause miscompiles by illegally reordering memory operations.
A new test based on #53695 is added here to verify we do not have
that same problem.
extract_vec_elt (load X), C --> scalar load (X+C)
As noted in the comment, DAGCombiner has this fold -- and the code in this
patch is adapted from DAGCombiner::scalarizeExtractedVectorLoad() -- but
x86 should benefit even if the loaded vector has other uses as long as we
apply some other x86-specific conditions. The motivating example from #50310
is shown in vec_int_to_fp.ll.
Fixes #50310
Fixes #53695
Differential Revision: https://reviews.llvm.org/D118376
Simon Pilgrim [Sun, 13 Feb 2022 13:27:00 +0000 (13:27 +0000)]
[X86] Add some add reduction tests when we're extending from a smaller type
This often occurs when the accumulator is larger than the source vector element, such as some of the tests mentioned in Issue #42019
Simon Pilgrim [Sun, 13 Feb 2022 13:14:00 +0000 (13:14 +0000)]
[clang][sema] Use castAs<> instead of getAs<> to avoid dereference of nullptr
The pointers are referenced immediately, so assert the cast is correct instead of returning nullptr
Aaron Ballman [Sun, 13 Feb 2022 13:02:46 +0000 (08:02 -0500)]
A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,
void func();
becomes
void func(void);
This is the ninth batch of tests being updated (there are a
significant number of other tests left to be updated).
Florian Hahn [Sun, 13 Feb 2022 11:36:54 +0000 (11:36 +0000)]
[LV] Drop noalias from check lines from test (NFC).
The noalias metadata checks re not really relevant for the test and
slight changes to metadata numbering can have large knock-on effects
causing large noise in test diff.
Harshil Jain [Sun, 13 Feb 2022 11:18:59 +0000 (16:48 +0530)]
The device expression must evaluate to a non-negative integer value.
Device clause when it occurs with **target enter data** and **target exit data** must be declared with some non negative value. So some changes were made to evaluate the device clause argument to non negative value and throw the expected error when it takes negative value as argument.
Reviewed By: clementval
Differential Revision: https://reviews.llvm.org/D119141
Florian Hahn [Sun, 13 Feb 2022 09:52:49 +0000 (09:52 +0000)]
[LV] Add real uses in some tests, to make them more robust.
Add real uses to some tests, to ensure dead instructions cannot be directly
removed.
Sheng [Sun, 13 Feb 2022 05:15:05 +0000 (13:15 +0800)]
[NFC][RFC][TableGen] Improve the comment about variable len encoder
When, for example, using "ascend" operator, I was wondering whether
the bit order of the dag argument will be reversed in ascend order
as well.
This patch clarifies it.
Reviewed By: myhsu
Differential Revision: https://reviews.llvm.org/D119653
Sheng [Sun, 13 Feb 2022 05:09:33 +0000 (13:09 +0800)]
[NFC][M68k] Fix typo
Fangrui Song [Sun, 13 Feb 2022 04:43:39 +0000 (20:43 -0800)]
[ELF] demoteSharedSymbols: make binding more appropriate for lazy symbols. NFC
The binding will matter if we remove the `sym->replace(und)` kludge from
initializeSymbols.
While here, rename the function to be more appropriate.
Sheng [Sun, 13 Feb 2022 03:47:02 +0000 (11:47 +0800)]
[NFC][M68k] Fix indentation
Shilei Tian [Sun, 13 Feb 2022 03:02:47 +0000 (22:02 -0500)]
[OpenMP][Offloading] Fix infinite loop in applyToShadowMapEntries
This patch fixes the issue that the for loop in `applyToShadowMapEntries`
is infinite because `Itr` is not incremented in `CB`. Fixes #53727.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D119471
Phoebe Wang [Sun, 13 Feb 2022 01:37:36 +0000 (09:37 +0800)]
[X86][MS] Fix the wrong alignment of vector variable arguments on Win32
D108887 fixed alignment mismatch by changing the caller's alignment in
ABI. However, we found some cases that still assume the alignment is
vector size. This patch fixes them to avoid the runtime crash.
Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D114536