Commit Graph

429612 Commits

Author SHA1 Message Date
Fangrui Song 6b1d151fe3 [ELF] Fix displacement computation for intra-section branch after D127611
D127611 computed st_value is inaccurate:

* For a backward branch, the destination address may be wrong if there is no
  relaxable relocation between it and the current location due to `if (remove)`.
  We may incorrectly relax a branch to c.j which ends up an overflow.
* For a forward branch, the destination address may be overestimated
  and lose relaxation opportunities.

To fix the issues,

* Don't reset st_value to the original value.
* Save the st_value delta from the previous iteration into valueDelta, and use
  `sa[0].d->value -= delta - valueDelta.find(sa[0].d)->second`.
2022-07-13 00:17:17 -07:00
Adrian Kuegel aabfaf901b [mlir] Allow empty lists for DenseArrayAttr.
Differential Revision: https://reviews.llvm.org/D129552
2022-07-13 09:16:09 +02:00
Siva Chandra Reddy 3c5d6312c4 [libc][NFC] Move thread platform data pointer to thread attributes.
Along the way, added constexpr constructors to the Thread data
structures.
2022-07-13 07:09:40 +00:00
jacquesguan 9049c46b9d [RISCV][test] Add test of binop followed by extractelement.
Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D129544
2022-07-13 14:33:56 +08:00
Monk Chiang 2b045324b2 [RISCV] Add scheduling resources for vector segment instructions.
Add scheduling resources for vector segment instructions

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D128886
2022-07-12 22:51:58 -07:00
Kazu Hirata 53daa177f8 [clang, clang-tools-extra] Use has_value instead of hasValue (NFC) 2022-07-12 22:47:41 -07:00
Kazu Hirata 3361a364e6 [llvm] Use has_value instead of hasValue (NFC) 2022-07-12 22:25:42 -07:00
Fangrui Song 67d760dd49 [ELF][test] Remove unneeded --mcpu=future from llvm-objdump commands 2022-07-12 21:08:52 -07:00
Fangrui Song 4864aba631 [ELF][test] Remove unneeded --mcpu=pwr10 from llvm-objdump commands
llvm-objdump has defaulted to decode all known instructions for PPC64.
2022-07-12 21:07:45 -07:00
Anlun Xu 033b9f21b0 [mlir][sparse]Replace redundant indices checks in sparse_tensor.conversion
Replace some redundant indices checks with the correct checks

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D129101
2022-07-12 21:04:31 -07:00
Jonas Devlieghere a17c90daf2
Re-land "[dsymutil] Account for DW_OP_convert being CU relative"
Currently, dsymutil treats the DW_OP_convert operand as absolute instead
of CU relative, as described by in the DWARFv5 spec, 2.5.1.6:

  "[DW_OP_convert] takes one operand, which is an unsigned LEB128 integer
  that represents the offset of a debugging information entry in the current
  compilation unit"

This patch makes dsymutil correctly treat the offset as CU relative,
preventing a crash when there are multiple compilation units.

Big thanks to Akira Hatanaka for figuring out this issue and providing
both a reduced test case and a proposed fix.
2022-07-12 18:46:23 -07:00
Jorge Gorbe Moya d6071fa52d [bazel] add missing gmock dependency to //clang/unittests:format_tests 2022-07-12 18:13:42 -07:00
Konstantin Varlamov 295b951ebc [lib++][ranges][NFC] Refactor `iterator_operations.h` to use tags.
Change the mechanism in `iterator_operations.h` to pass around a generic
policy tag indicating whether an internal function is being invoked from
a "classic" STL algorithm or a ranges algorithm. `IterOps` is now
a template class specialized on the policy tag.

The advantage is that this mechanism is more generic and allows defining
arbitrary conditions in a clean manner.

Also add a few more iterator functions to `IterOps`.

Differential Revision: https://reviews.llvm.org/D129390
2022-07-12 17:53:58 -07:00
Jorge Gorbe Moya fcbb4e1fa4 [NFCI] Fix unused variable warning with asserts off in clang/lib/Sema/TypeLocBuilder.cpp 2022-07-12 17:40:41 -07:00
Matheus Izvekov bdc6974f92
[clang] Implement ElaboratedType sugaring for types written bare
Without this patch, clang will not wrap in an ElaboratedType node types written
without a keyword and nested name qualifier, which goes against the intent that
we should produce an AST which retains enough details to recover how things are
written.

The lack of this sugar is incompatible with the intent of the type printer
default policy, which is to print types as written, but to fall back and print
them fully qualified when they are desugared.

An ElaboratedTypeLoc without keyword / NNS uses no storage by itself, but still
requires pointer alignment due to pre-existing bug in the TypeLoc buffer
handling.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Differential Revision: https://reviews.llvm.org/D112374
2022-07-13 02:10:09 +02:00
Jorge Gorbe Moya ee88c0cf09 [NFCI] Fix unused variable/function warnings in MacroCallReconstructorTest.cpp when asserts are disabled. 2022-07-12 16:46:58 -07:00
Joseph Huber a3cbb158a2 [LinkerWrapper] Tweak save-temps output name
Summary:
A previous patch added the Task to the output filename when doing
`save-temps` the majority of cases there is only a single task so we
only add the task explicitly to differentiate it from the first one.
2022-07-12 19:42:04 -04:00
Nico Weber b93119aad7 Revert "[dsymutil] Account for DW_OP_convert being CU relative"
This reverts commit 7f3000fa8b.
Breaks tests on Windows, see commits on https://reviews.llvm.org/rG7f3000fa
2022-07-12 19:36:21 -04:00
Walter Erquinigo dbc0cb0198 [trace] Avoid a crash in the dumper when disassembling fails
In rare situations, disassemblying would fail that produce an invalid
InstructionSP object. We need to check that it's valid before using.

With this change, now the dumper doesn't crash with dumping instructions of
ioctl. In fact, it now dumps this output

 {
    "id": 6135,
    "loadAddress": "0x7f4bfe5c7515",
    "module": "libc.so.6",
    "symbol": "ioctl",
    "source": "glibc/2.34/src/glibc-2.34/sysdeps/unix/syscall-template.S",
    "line": 120,
    "column": 0
 }

Anyway, we need to investigate why the diassembler failed disassembling that
instruction. From over 2B instructions I was disassembling today, just this
one failed, so this could be a bug in LLVM's core disassembler.

Differential Revision: https://reviews.llvm.org/D129588
2022-07-12 16:23:03 -07:00
Walter Erquinigo ad7bcda940 [trace] Add a flag to the decoder to output the instruction type
To build complex binding upon instruction trace, additional metadata 'instruction type' is needed.

This diff has followings:
 - Add a flag -k  / --kind for instruction dump
 - Remove SetGranularity and SetIgnoreErros from Trace cursor

Sample output:

```
(lldb) thread trace dump instruction -k
thread #1: tid = 3198805
  libc.so.6`_IO_puts + 356
    2107: 0x00007ffff7163594 (    return)     retq
    2106: 0x00007ffff7163592 (     other)     popq   %r13
    2105: 0x00007ffff7163590 (     other)     popq   %r12
    2104: 0x00007ffff716358f (     other)     popq   %rbp
    2103: 0x00007ffff716358e (     other)     popq   %rbx
    2102: 0x00007ffff716358c (     other)     movl   %ebx, %eax
    2101: 0x00007ffff7163588 (     other)     addq   $0x8, %rsp
    2100: 0x00007ffff7163570 ( cond jump)     je     0x89588                   ; <+344>
    2099: 0x00007ffff716356e (     other)     decl   (%rdx)
    2098: 0x00007ffff7163565 ( cond jump)     je     0x8956e                   ; <+318>
    2097: 0x00007ffff716355e (     other)     cmpl   $0x0, 0x33c02b(%rip)      ; __libc_multiple_threads
    2096: 0x00007ffff7163556 (     other)     movq   $0x0, 0x8(%rdx)
    2095: 0x00007ffff7163554 ( cond jump)     jne    0x89588                   ; <+344>
    2094: 0x00007ffff7163550 (     other)     subl   $0x1, 0x4(%rdx)
    2093: 0x00007ffff7163549 (     other)     movq   0x88(%rbp), %rdx
    2092: 0x00007ffff7163547 ( cond jump)     jne    0x89588                   ; <+344>
    2091: 0x00007ffff7163540 (     other)     testl  $0x8000, (%rbp)           ; imm = 0x8000
    2090: 0x00007ffff716353c (     other)     cmovaq %rax, %rbx
    2089: 0x00007ffff7163535 (     other)     cmpq   $0x7fffffff, %rbx         ; imm = 0x7FFFFFFF
    2088: 0x00007ffff7163530 (     other)     movl   $0x7fffffff, %eax         ; imm = 0x7FFFFFFF
```

Reviewed By: wallace

Differential Revision: https://reviews.llvm.org/D128477
2022-07-12 16:23:03 -07:00
Thomas Raoux 5f8cefebd9 [mlir][vector] Fix crash in vector.reduction canonicalization
since vector.reduce support accumulator in all the cases remove the
assert assuming old definition.

Differential Revision: https://reviews.llvm.org/D129602
2022-07-12 23:15:30 +00:00
Philip Reames cc7d966511 Add coverage for missing (urem x, (lshr pow2, y)) -> (and x, (add (lshr pow2, y), -1)) transform 2022-07-12 16:04:57 -07:00
Nathan James a565509308
[ADT] Use Empty Base Optimization for Allocators
In D94439, BumpPtrAllocator changed its implementation to use an empty base optimization for the underlying allocator.
This patch builds on that by extending its functionality to more classes as well as enabling the underlying allocator to be a reference type, something not currently possible as you can't derive from a reference.

The main place this sees use is in StringMaps which often use the default MallocAllocator, yet have to pay the size of a pointer for no reason.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D129206
2022-07-12 23:57:04 +01:00
Philip Reames 1ce3f94570 {RISCV] Test coverage for improved lowering assuming vscale is pow-of-two 2022-07-12 15:40:30 -07:00
Jonas Devlieghere a262f4dbd7 Revert "[Clang] Add a warning on invalid UTF-8 in comments."
This reverts commit cc309721d2 because it
breaks the following tests on GreenDragon:

  TestDataFormatterObjCCF.py
  TestDataFormatterObjCExpr.py
  TestDataFormatterObjCKVO.py
  TestDataFormatterObjCNSBundle.py
  TestDataFormatterObjCNSData.py
  TestDataFormatterObjCNSError.py
  TestDataFormatterObjCNSNumber.py
  TestDataFormatterObjCNSURL.py
  TestDataFormatterObjCPlain.py
  TestDataFormatterObjNSException.py

https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/45288/
2022-07-12 15:22:29 -07:00
Thomas Raoux 8fe076ffe0 [mlir][VectorToLLVM] Fix bug in lowering of vector.reduce fmax/fmin
The lowering of fmax/fmin reduce was ignoring the optional accumulator.

Differential Revision: https://reviews.llvm.org/D129597
2022-07-12 22:03:39 +00:00
Jonas Devlieghere 7f3000fa8b
[dsymutil] Account for DW_OP_convert being CU relative
Currently, dsymutil treats the DW_OP_convert operand as absolute instead
of CU relative, as described by in the DWARFv5 spec, 2.5.1.6:

  "[DW_OP_convert] takes one operand, which is an unsigned LEB128 integer
  that represents the offset of a debugging information entry in the current
  compilation unit"

This patch makes dsymutil correctly treat the offset as CU relative,
preventing a crash when there are multiple compilation units.

Big thanks to Akira Hatanaka for figuring out this issue and providing
both a reduced test case and a proposed fix.
2022-07-12 15:03:15 -07:00
Jez Ng 61ace8f78b [lld-macho][nfc] Change force-load.s test to actually test
I'd forgotten to change a copypasted line...
2022-07-12 17:57:09 -04:00
Kai Nacke 4ae254e488 Revert "[GISel] Unify use of getStackGuard"
This reverts commit e60b4fb2b7.
2022-07-12 17:00:43 -04:00
Simon Pilgrim 66bfd1ba8c [X86] Move isInRange(ArrayRef<int>) inside assert to fix NDEBUG builds. NFC.
Fix unused static function warning introduced by D129207
2022-07-12 21:51:07 +01:00
Kai Nacke e60b4fb2b7 [GISel] Unify use of getStackGuard
Some rework of getStackGuard() based on comments in
https://reviews.llvm.org/D129505.

- getStackGuard() now creates and returns the destination
  register, simplifying calls
- the pointer type is passed to getStackGuard() to avoid
  recomputation
- removed PtrMemTy in emitSPDescriptorParent(), because
  this type is only used here when loading the value but
  not when storing the value

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D129576
2022-07-12 16:46:37 -04:00
Augie Fackler 9029bda041 [Attributor] Don't crash if getAnalysisResultForFunction() returns null LoopInfo
I have no idea what's going on here. This code was moved
around/introduced in change cb26b01d57 and starts crashing with a NULL
dereference once I apply https://reviews.llvm.org/D123090. I assume that
I've unwittingly taught the attributor enough that it's able to do more
clever things than in the past, and it's able to trip on this case. I
make no claims about the correctness of this patch, but it passes tests
and seems to fix all the crashes I've been seeing.

Differential Revision: https://reviews.llvm.org/D129589
2022-07-12 16:44:06 -04:00
Jonas Devlieghere 5edfc0b928
[lldb] Fix macOS Ventura version number checks
Unlike Python 2 which reports 10.16 on any recent macOS, Python 3
correctly reports Ventura as macOS 13.
2022-07-12 13:29:46 -07:00
Jacques Pienaar 0db084d4c7 [mlir] Switch create to use NamedAttrList&&
Avoids needing the two parallel functions as NamedAttrList already takes care
of caching DictionaryAttr and implicitly can convert from either.

Differential Revision: https://reviews.llvm.org/D129527
2022-07-12 13:24:09 -07:00
Sunho Kim 2a0aa98c8d [ORC] Remove unused function declaration. (NFC)
Differential Revision: https://reviews.llvm.org/D129582
2022-07-13 05:13:31 +09:00
Jonas Devlieghere b620852d23
[lldb] Make the g_arguments_data constexpr and fix the static assert
This fixes the static assert that's meant to keep the g_arguments_data
table in sync with the CommandArgumentType enumeration. Indeed, the
assert didn't fire even though the current code is missing an entry.
This patches fixes that as well.

Differential revision: https://reviews.llvm.org/D129529
2022-07-12 13:12:36 -07:00
Simon Pilgrim 42ca354cb5 [AMDGPU] Regenerate local-memory.amdgcn.ll test checks 2022-07-12 21:09:47 +01:00
Sam McCall 93cd159ca9 [clangd] Remove `allCommitCharacters`
This was added in 2a095ff6f5, however it never worked with VSCode
due to bugs in vscode-languageclient
(https://github.com/microsoft/vscode-languageserver-node/issues/673).
Now that it does work, we can tell the interactions with text editing, with
snippets, and vscode's select-first-completion behavior are bad.

The spec is vague and clients could do something reasonable with the
current values. However they could clearly do something unreasonable
too, and over time behavior+spec tends to converge on VSCode's behavior.

This addresses https://github.com/clangd/vscode-clangd/pull/358
See also https://github.com/clangd/vscode-clangd/pull/358 which hotfixes
this on the client-side (as we can't apply this change retroactively to
clangd 12-14).

Differential Revision: https://reviews.llvm.org/D129579
2022-07-12 21:42:38 +02:00
David Blaikie 63f4cfe267 Pretty printer test fixes 2022-07-12 19:29:38 +00:00
sunho e5ff1a7f56 [JITLink][COFF] Fix compiler warnings. 2022-07-13 04:29:05 +09:00
Aaron Ballman 2346d19a26 Speculatively fix this C DR test
There is a failing bot:
http://45.33.8.238/macm1/40002/step_7.txt

It looks to be failing because of a regex and how it handles whitespace,
so modifying the CHECK line slightly to account for that.
2022-07-12 15:18:03 -04:00
Mark de Wever 984f5f3f62 [libc++][test] Adds spaceship support to macros.
This was already reviewed as D128603. This contains only the updates to
the test script.

Differential Revision: https://reviews.llvm.org/D129578
2022-07-12 21:10:23 +02:00
Nico Weber 953ba18fda [clang/ios] Make -mios-version-min the canonical spelling over -miphoneos-version-min
Like https://reviews.llvm.org/D129226, but for iOS.

No behavior change.

Differential Revision: https://reviews.llvm.org/D129569
2022-07-12 15:09:04 -04:00
Sunho Kim e8f52b8c49 [JITLink][COFF] Add missing REQUIRES: asserts.
This fixes the buildbot failure in release only buildbots.
2022-07-13 04:05:56 +09:00
LLVM GN Syncbot 1032d34c42 [gn build] Port db995d72db 2022-07-12 18:54:07 +00:00
Sunho Kim db995d72db [JITLink][COFF] Initial COFF support.
Adds initial COFF support in JITLink. This is able to run a hello world c program in x86 windows successfully.

Implemented
- COFF object loader
- Static local symbols
- Absolute symbols
- External symbols
- Weak external symbols
- Common symbols
- COFF jitlink-check support
- All COMDAT selection type execpt largest
- Implicit symobl size calculation
- Rel32 relocation with PLT stub.
- IMAGE_REL_AMD64_ADDR32NB relocation

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D128968
2022-07-13 03:52:43 +09:00
Craig Topper 8eaf00e04d [TargetLowering][RISCV] Make expandCTLZ work for non-power of 2 types.
To convert CTLZ to popcount we do

x = x | (x >> 1);
x = x | (x >> 2);
...
x = x | (x >>16);
x = x | (x >>32); // for 64-bit input
return popcount(~x);

This smears the most significant set bit across all of the bits
below it then inverts the remaining 0s and does a population count.

To support non-power of 2 types, the last shift amount must be
more than half of the size of the type. For i15, the last shift
was previously a shift by 4, with this patch we add another shift
of 8.

Fixes PR56457.

Differential Revision: https://reviews.llvm.org/D129431
2022-07-12 11:36:37 -07:00
Craig Topper 866be0aa8a [RISCV] Pre-commit test for PR56457. NFC 2022-07-12 11:36:37 -07:00
YongKang Zhu 2324c2e3c3 [LLD] Two tweaks to symbol ordering scheme
When `--symbol-ordering-file` is specified, the linker today will always put
hot contributions in the middle of cold ones when targeting RISC machine, so
to minimize the chances that branch thunks need be generated for hot code
calling into cold code. This is not necessary when user specifies an ordering
of read-only data (vs. function) symbols, or when output section is small such
that no branch thunk would ever be required. The latter is common for mobile
apps. For example, among all the native ARM64 libraries in Facebook Instagram
App for Android, 80% of them have text section smaller than 64KB and the
largest text section seen is less than 8MB, well below the distance that a
BRANCH26 can reach.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D128382
2022-07-12 11:34:17 -07:00
David Tenty 4a009797ec [libc++][NFC] Add MVS guard for locale_mgmt_zos.h
This header need not be included on non-z/OS IBM platforms (and indeed
will add nothing when it is), so add a guard. This let's us remove the
header without things breaking when shipping libc++ for AIX.

Reviewed By: hubert.reinterpretcast, fanbo-meng

Differential Revision: https://reviews.llvm.org/D129493
2022-07-12 14:15:42 -04:00