Commit Graph

423179 Commits

Author SHA1 Message Date
Sam McCall ba0d50ad7e [Support] Fix UB in BumpPtrAllocator when first allocation is zero.
BumpPtrAllocator::Allocate() is marked __attribute__((returns_nonnull)) when the
compiler supports it, which makes it UB to return null.

When there have been no allocations yet, the current slab is [nullptr, nullptr).
A zero-sized allocation fits in this range, and so Allocate(0, 1) returns null.

There's no explicit docs whether Allocate(0) is valid. I think we have to assume
that it is:
 - the implementation tries to support it (e.g. >= tests instead of >)
 - malloc(0) is allowed
 - requiring each callsite to do a check is bug-prone
 - I found real LLVM code that makes zero-sized allocations

Differential Revision: https://reviews.llvm.org/D125040
2022-05-06 08:57:27 +02:00
Sam McCall 232cc446ff [pseudo] Only expand UCNs for raw_identifiers
It turns out clang::expandUCNs only works on tokens that contain valid UCNs
and no other random escapes, and clang only uses it on raw_identifiers.

Currently we can hit an assertion by creating tokens with stray non-valid-UCN
backslashes in them.

Fortunately, expanding UCNs in raw_identifiers is actually all we need.
Most tokens (keywords, punctuation) can't have them. UCNs in literals can be
treated as escape sequences like \n even this isn't the standard's
interpretation. This more or less matches how clang works.
(See https://isocpp.org/files/papers/P2194R0.pdf which points out that the
standard's description of how UCNs work is misaligned with real implementations)

Differential Revision: https://reviews.llvm.org/D125049
2022-05-06 08:53:31 +02:00
Sam McCall 817550919e [Lex] Don't assert when decoding invalid UCNs.
Currently if a lexically-valid UCN encodes an invalid codepoint, then we
diagnose that, and then hit an assertion while trying to decode it.

Since there isn't anything preventing us reaching this state, remove the
assertion. expandUCNs("X\UAAAAAAAAY") will produce "XY".

Differential Revision: https://reviews.llvm.org/D125059
2022-05-06 08:51:42 +02:00
Ben Shi e2ed3fd71e [AVR][NFC] Eliminate warning 'unused variable'
Reviewed By: Patryk27, aykevl

Differential Revision: https://reviews.llvm.org/D125066
2022-05-06 06:15:28 +00:00
Chuanqi Xu 2d037873a3 [Coroutines] Don't re-materialize for debug instructions
Re-materialize for debug instructions would cause a different code
generated if we enabled `-g`. This is bad. So we disable to
re-materialize for debug instructions.
2022-05-06 13:52:19 +08:00
Mehdi Amini be310632d0 Apply clang-tidy fixes for llvm-else-after-return in OpenMPDialect.cpp (NFC) 2022-05-06 05:40:02 +00:00
Mehdi Amini 6e32535078 Apply clang-tidy fixes for bugprone-argument-comment in AffineOps.cpp (NFC) 2022-05-06 05:40:02 +00:00
Chenbing Zheng 53069de6aa [InstCombine] precommit tests for D124590 2022-05-06 10:53:12 +08:00
Chenbing Zheng 4c8c101b49 [InstCombine] try to narrow more shifted bswap-of-zext
Try to narrow more bswap, if the shift amount is less than the zext
(bswap (zext X)) >> C --> (zext (bswap X)) << C'

https://alive2.llvm.org/ce/z/i7ddjn

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D124598
2022-05-06 10:45:10 +08:00
Volodymyr Sapsai 3b762b3ab8 [clang][NFC] In parts of Objective-C Sema use Obj-C-specific types instead of `Decl`.
Differential Revision: https://reviews.llvm.org/D124285
2022-05-05 19:19:41 -07:00
Lian Wang fb0d636f28 [RISCV][SelectionDAG] Support VP_REDUCE_ADD mask operation.
Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D124986
2022-05-06 01:49:21 +00:00
Wael Yehia 93bb2f16e8 XFAIL some PGO tests on AIX until the new linker becomes publicly available. 2022-05-06 01:35:32 +00:00
Jason Molenda 2be791e32a Insert crashing stack frame when call to null func ptr
On arm64 targets, when the crashing pc is 0, the caller
frame can be found by looking at $lr, but the crash
reports don't use that trick to show the actual crashing
frame.  This patch adds that stack frame that lldb shows.

Also fix an issue where some register names were printed
as having a prefix of 'None'.

Differential Revision: https://reviews.llvm.org/D125042
rdar://92631787
2022-05-05 17:55:22 -07:00
Nico Weber 21ab2b6ca8 [gn build] (semi-manually) port 70a66c08fc 2022-05-05 20:34:49 -04:00
Sheng 9c2121b843 [NFC][test] Replace hardcoded number with numeric substitution blocks
In VarLenDecoder.td, the opcode in CHECK line is hardcoded, which
causes chaos in several downstream projects. This patch is trying
to fix that.
2022-05-06 08:08:34 +08:00
Chengji Yao e5a4cf6743 [mlir] Fix printer when it is a DenseElementsAttr of i1
A large DenseElementsAttr of i1could trigger a bug in printer/parser roundtrip.

Ex. A DenseElementsAttr of i1 with 200 elements will print as Hex format of length 400 before the fix. However, when parsing the printed text, an error will be triggered. After fix, the printed length will be 50.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D122925
2022-05-05 16:56:43 -07:00
Florian Mayer 6ca1df61d2 [HWASan] Clean up hwasan_symbolize.
The globals are better expressed as members of the Symbolizer, and all
functions operating on it should be methods instead.

Also using the standard idiom of wrapping the main code in
`if __name__ == '__main__'`.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D125032
2022-05-05 16:41:11 -07:00
Florian Mayer 4af9392e13 [HWASan] Allow to linkify symbolizer output.
Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D124950
2022-05-05 16:40:09 -07:00
Ben Shi 70a66c08fc [compiler-rt][builtins] Add helper functions for uint16/sint16/uint8/sint8 div and mod
__udivmodhi4 : uint16 div and mod
__udivmodqi4 : uint8 div and mod
__divmodhi4  : sint16 div and mod
__divmodqi4  : sint8 div and mod

The above helper functions in libgcc have special ABI as described at
https://gcc.gnu.org/wiki/avr-gcc#Exceptions_to_the_Calling_Convention .

Reviewed By: aykevl

Differential Revision: https://reviews.llvm.org/D124600
2022-05-05 23:29:14 +00:00
Ilia Diachkov 0098f2aebb [SPIRV] Add SPIR-V specific intrinsics, two passes and tests
The patch adds SPIR-V specific intrinsics required to keep information
critical to SPIR-V consistency (types, constants, etc.) during translation
from IR to MIR.

Two related passes (SPIRVEmitIntrinsics and SPIRVPreLegalizer) and several
LIT tests (passed with this change) have also been added.

It also fixes the issue with opaque pointers in SPIRVGlobalRegistry.cpp
and the mismatch of the data layout between the SPIR-V backend and clang
(Issue #55122).

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

Co-authored-by: Aleksandr Bezzubikov <zuban32s@gmail.com>
Co-authored-by: Michal Paszkowski <michal.paszkowski@outlook.com>
Co-authored-by: Andrey Tretyakov <andrey1.tretyakov@intel.com>
Co-authored-by: Konrad Trifunovic <konrad.trifunovic@intel.com>
2022-05-06 03:02:00 +03:00
Richard Smith f6c74932b5 [docs] Fix uses of `foo` that should be ``foo`` throughout release notes. 2022-05-05 16:04:19 -07:00
Richard Smith c2572d8b1f [docs] Add blank lines to help Sphinx parse nested bullets. 2022-05-05 15:58:26 -07:00
Aaron Ballman 1c50909f6f Revert "Pedantically warn about // comments in gnu89 mode"
This reverts commit f6dff93641.

This diagnostic is also in the -Wcomment group, which is in the -Wall
group, so the diagnostic is enabled in a wider context than GCC does.
That turns out to be disruptive for the Linux kernel builds still using
-std=gnu89 because the kernel requires C source files to start with //
comments: https://kernel.org/doc/html/v5.18-rc5/process/license-rules.html#license-identifier-syntax
2022-05-05 18:39:13 -04:00
Aart Bik 952fa3018e [mlir][sparse] add more zero-preserving unary ops to sparse compiler
Although we now have semi-rings to deal with arbitrary ops,
it is still good to convey zero-preserving semantics of
ops to the sparse compiler.

Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D125043
2022-05-05 15:35:19 -07:00
Peter Steinfeld ebe24a2a31 [flang] Change "unsupported" messages in the runtime to "not yet implemented"
If a programmer is able to compile and link a program that contains types that
are not yet supported by the runtime, it must be because they're not yet
implemented.

This change will make it easier to find unimplemented code in tests.

Differential Revision: https://reviews.llvm.org/D125046
2022-05-05 15:20:01 -07:00
owenca e7aed737eb [clang-format][NFC] Add a few regression tests 2022-05-05 15:12:24 -07:00
River Riddle 6609c1cc59 [mlir] Add a better error message when failing to parse an attribute
The fallback attribute parse path is parsing a Type attribute, but this results
in a really unintuitive error message: `expected non-function type`, which
doesn't really hint at tall that we were trying to parse an attribute. This
commit fixes this by trying to optionally parse a type, and on failure
emitting an error that we were expecting an attribute.

Differential Revision: https://reviews.llvm.org/D124870
2022-05-05 15:06:11 -07:00
Alexander Yermolovich ba1ac98c62 [BOLT][DWARF] Add version 5 split dwarf support
Added support for DWARF5 Split Dwarf.

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D122988
2022-05-05 14:59:05 -07:00
Richard Smith c4f95ef86a Reimplement `__builtin_dump_struct` in Sema.
Compared to the old implementation:

* In C++, we only recurse into aggregate classes.
* Unnamed bit-fields are not printed.
* Constant evaluation is supported.
* Proper conversion is done when passing arguments through `...`.
* Additional arguments are supported and are injected prior to the
  format string; this directly supports use with `fprintf`, for example.
* An arbitrary callable can be passed rather than only a function
  pointer. In particular, in C++, a function template or overload set is
  acceptable.
* All text generated by Clang is printed via `%s` rather than directly;
  this avoids issues where Clang's pretty-printing output might itself
  contain a `%` character.
* Fields of types that we don't know how to print are printed with a
  `"*%p"` format and passed by address to the print function.
* No return value is produced.

Reviewed By: aaron.ballman, erichkeane, yihanaa

Differential Revision: https://reviews.llvm.org/D124221
2022-05-05 14:55:47 -07:00
owenca 8b626a2caa [clang-format] Fix another bug in AlignConsecutiveAssignments
The ShouldShiftBeAdded lambda checks if extra space should be
added before the wrapped part of a braced list. If the first
element of the list is wrapped, no extra space should be added.

Fixes #55161.

Differential Revision: https://reviews.llvm.org/D124956
2022-05-05 14:48:56 -07:00
River Riddle 8bb5b657fe [mlir:ExecutionEngine] Update use of getAddress now that lookup returns ExecutorAddr
This was changed in 16dcbb53dc
2022-05-05 14:24:32 -07:00
Jason Molenda b6388e4a00 Decr return pc mid-stack when picking UnwindPlan row
When picking the UnwindPlan row to use to backtrace,
off of the zeroth frame, decrement the return pc so
we're in the address range of the call instruction.
If this is a noretrun function call, the instruction
at the "return address" is likely an entirely different
basic block with possibly very different unwind rules,
and this can cause the backtrace to be incorrect.

Differential Revision: https://reviews.llvm.org/D124957
rdar://84651805
2022-05-05 14:18:21 -07:00
Amara Emerson 586802eb72 [GlobalISel] Re-generate some tests. 2022-05-05 14:14:36 -07:00
Lang Hames 16dcbb53dc [ORC] Return ExecutorAddrs rather than JITEvaluatedSymbols from LLJIT::lookup.
Clients don't care about linkage, and ExecutorAddr is much more ergonomic.
2022-05-05 13:56:00 -07:00
H.J. Lu b226894d47 [sanitizer] Correct GetTls for x32
Since x32 pointer size is 4 bytes, the self pointer offset in TCB:

struct
{
  void *tcb;
  dtv_t *dtv;
  void *self;
  ...

should be 8, not 16.

Fixes https://github.com/llvm/llvm-project/issues/55288

Differential Revision: https://reviews.llvm.org/D125025
2022-05-05 13:55:19 -07:00
Stella Stamenova d4555698f8 [mlir] Fix the names of exported functions
The names of the functions that are supposed to be exported do not match the implementations. This is due in part to cac7aabbd8.

This change makes the implementations and declarations match and adds a couple missing declarations.

The new names follow the pattern of the existing `verify` functions where the prefix is maintained as `_mlir_ciface_` but the suffix follows the new naming convention.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D124891
2022-05-05 13:46:15 -07:00
Eric Li 45643cfcc1 [clang][dataflow] Centralize expression skipping logic
A follow-up to 62b2a47 to centralize the logic that skips expressions
that the CFG does not emit. This allows client code to avoid
sprinkling this logic everywhere.

Add redirects in the transfer function to similarly skip such
expressions by forwarding the visit to the sub-expression.

Differential Revision: https://reviews.llvm.org/D124965
2022-05-05 20:28:11 +00:00
Martin Storsjö 07c96a3113 [libcxx] [test] Narrow down an XFAIL for clang-cl configurations
This test only fails on x86_64 clang-cl, not for i386.

(The root cause is still not explored, thus the FIXME is still
relevant.)

Differential Revision: https://reviews.llvm.org/D124994
2022-05-05 23:21:19 +03:00
Martin Storsjö 9dfbccf052 [libcxx] [test] Extend the UNSUPPORTED lines in strong_order_long_double.verify.cpp for non-x86_64 Windows
Differential Revision: https://reviews.llvm.org/D124992
2022-05-05 23:21:19 +03:00
Martin Storsjö aeb4907ed6 [libcxxabi] Use the right calling convention for exception destructors on i386 Windows
On Windows on i386, C++ member functions use a different calling
convention (`__thiscall`) than the default one for regular functions
(`__cdecl`). (On Windows on architectures other than i386, both calling
convention attributes are no-ops.)

This matches how libstdc++ declares these types.

This fixes the std/thread/futures/futures.{shared,unique}_future/dtor.pass.cpp
tests on i386 mingw.

Differential Revision: https://reviews.llvm.org/D124990
2022-05-05 23:21:18 +03:00
Martin Storsjö 448eabd754 [libcxx] [test] Fix max_size.pass.cpp for other Windows architectures
All current Windows architectures (i386, x86_64, arm, arm64) get
the full_size() behaviour here. x86_64 (the only one tested in CI
currently) is handled by the first ifdef at the top, but handle
Windows in general on all other architectures later.

Differential Revision: https://reviews.llvm.org/D124989
2022-05-05 23:21:18 +03:00
Craig Topper 5140e0d219 [SelectionDAGISel] Add back a comment to MergeInputChains handling. NFC
This comment used to exist, but was lost in a refactor over 10 years
ago, but still seems relevant and improves readability.
2022-05-05 12:59:21 -07:00
Lang Hames 98616cfc02 [ORC] Add an ExecutorAddr::toPtr overload for function types.
In the common case of converting an ExecutorAddr to a function pointer type,
this eliminates the need for the '(*)' boilerplate to explicitly specify a
function pointer. E.g.:

auto *F = A.toPtr<int(*)()>();

can now be written as

auto *F = A.toPtr<int()>();
2022-05-05 12:37:23 -07:00
Simon Pilgrim c2a5a87500 [X86] Add some test coverage for Issue #55271
We needed something that would delay the creation of the undef until after the rem-by-constant expansion, so I used a SSE shift of undef by zero which will expand to undef.
2022-05-05 20:06:23 +01:00
phyBrackets dcb906757a [clang][ASTImporter][NFC]: Move clang::ImportError into own header.
Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D124774
2022-05-06 00:14:32 +05:30
Rahman Lavaee 733dc3e50b [BOLT] Report per-section hotness in bolt-heatmap.
This patch adds a new feature to bolt heatmap to print the hotness of each section in terms of the percentage of samples within that section.

Sample output generated for the clang binary:

Section Name, Begin Address, End Address, Percentage Hotness
.text, 0x1a7b9b0, 0x20a2cc0, 1.4709
.init, 0x20a2cc0, 0x20a2ce1, 0.0001
.fini, 0x20a2ce4, 0x20a2cf2, 0.0000
.text.unlikely, 0x20a2d00, 0x431990c, 0.3061
.text.hot, 0x4319910, 0x4bc6927, 97.2197
.text.startup, 0x4bc6930, 0x4c10c89, 0.0058
.plt, 0x4c10c90, 0x4c12010, 0.9974

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D124412
2022-05-05 11:37:46 -07:00
Aaron Ballman f6dff93641 Pedantically warn about // comments in gnu89 mode
GCC warns with a pedantic warning when -std=gnu89, but Clang would only
diagnose in -std=c89 mode. Clang now matches the GCC behavior in both
modes.

Fixes #18427
2022-05-05 14:35:47 -04:00
Alexandre Perez eb3136f022 Fix debugserver translation check
Currently, debugserver has a test to check if it was launched in
translation. The intent was to cover the case where an x86_64
debugserver attempts to control an arm64/arm64e process, returning
an error. However, this check also covers the case where users
are attaching to an x86_64 process, exiting out before attempting
to hand off control to the translated debugserver at
`/Library/Apple/usr/libexec/oah/debugserver`.

This diff delays the debugserver translation check until after
determining whether to hand off control to
`/Library/Apple/usr/libexec/oah/debugserver`. Only when the
process is not translated and thus has not been handed off do we
check if the debugserver is translated, erroring out in that case.

Reviewed By: jasonmolenda

Differential Revision: https://reviews.llvm.org/D124814
2022-05-05 11:31:23 -07:00
Florian Hahn f9f7aa30f8
[VPlan] Remove dead code to create VPWidenPHIRecipes (NFCI).
After introducing VPWidenPointerInductionRecipe, VPWidenPHIRecipes
should not be created at this point. Turn check into an assert.
2022-05-05 19:29:02 +01:00
David Blaikie 0d8cb8b399 DWARFVerifier: Verify CU/TU index overlap issues
Discovered in a large object that would need a 64 bit index (but the
cu/tu index format doesn't include a 64 bit offset/length mode in
DWARF64 - a spec bug) but instead binutils dwp overflowed the offsets
causing overlapping regions.
2022-05-05 18:18:53 +00:00