Commit Graph

475445 Commits

Author SHA1 Message Date
Jie Fu
da57ced76d [examples] Remove unused variable 'BB' in BrainF.cpp (NFC)
/Users/jiefu/llvm-project/llvm/examples/BrainF/BrainF.cpp:92:15: error: unused variable 'BB' [-Werror,-Wunused-variable]
  BasicBlock* BB = builder->GetInsertBlock();
              ^
1 error generated.
2023-09-19 15:46:08 +08:00
David Spickett
ca723f2d40
[lldb][Docs] Document our major differences from the LLVM style (#66345)
Running:
$ clang-format -i $(find -regex "\./lldb/.*\.c") $(find -regex
"\./lldb/.*\.cpp") $(find -regex "\./lldb/.*\.h")

Resulted in:
 1602 files changed, 25090 insertions(+), 25849 deletions(-)
(note: this includes tests which we wouldn't format, just using this as
an example)

The vast majority of which were whitespace changes. So as far as
formatting we're not deviating from llvm for any reason other than not
churning old code.

Formatting aside, the major features of lldb (single line if, early
return) are all reflected in llvm's style. We differ mainly on variable
naming (proposed to change in
https://llvm.org/docs/Proposals/VariableNames.html anyway) and use of
asserts. Which was already documented.
2023-09-19 08:23:00 +01:00
Matthias Springer
6923a31542
[mlir][IR] Change MutableArrayRange to enumerate OpOperand & (#66622)
In line with #66515, change `MutableArrayRange::begin`/`end` to
enumerate `OpOperand &` instead of `Value`. Also remove
`ForOp::getIterOpOperands`/`setIterArg`, which are now redundant.

Note: `MutableOperandRange` cannot be made a derived class of
`indexed_accessor_range_base` (like `OperandRange`), because
`MutableOperandRange::assign` can change the number of operands in the
range.
2023-09-19 09:09:21 +02:00
Konrad Kleine
45bb45f2ae [llvm] Move CallInst::CreateMalloc to IRBuilderBase::CreateMalloc
This removes `CreateMalloc` from `CallInst` and adds it to the `IRBuilderBase`
class.

We no longer needed the `Instruction *InsertBefore` and
`BasicBlock *InsertAtEnd` arguments of the `createMalloc` helper
function because we're using `IRBuilder` now. That's why I we also don't
need 4 `CreateMalloc` functions, but only two.

Differential Revision: https://reviews.llvm.org/D158861
2023-09-19 09:05:48 +02:00
martinboehme
1d7b59ca8d
[clang][dataflow] Fix two null pointer dereferences in getMemberForAccessor(). (#66742)
The additions to the test trigger crashes without the fixes.
2023-09-19 09:03:20 +02:00
Konstantina Mitropoulou
3583d40b3c
[NFC][NewGVN] Update assume_dominating_icmp.ll (#66711) 2023-09-18 23:47:48 -07:00
Matt Arsenault
1328a8534b
AMDGPU: Fix handling of -0 in round lowering (#65761) 2023-09-19 09:14:17 +03:00
Christian Sigg
b9a6b28a58
[mlir][bazel] Small adjustment to 7db4a6f278 2023-09-19 08:08:59 +02:00
LLVM GN Syncbot
69ae904f6a [gn build] Port 44532a9dd4 2023-09-19 05:57:24 +00:00
ur4t
7ac1f60f01
[llvm-libgcc][CMake] Refactor llvm-libgcc (#65455)
There are some issues in `llvm-libgcc` before this patch:

Commit c5a20b5182 ([llvm-libgcc] initial
commit)
uses `$<TARGET_OBJECTS:unwind_static>` to get libunwind objects, which
is empty.
The built library is actually a shared version of libclang_rt.builtins.

When configuring with `llvm/CMakeLists.txt`, target `llvm-libgcc`
requires a
corresponding target in `llvm-libgcc/CMakeLists.txt`.

Per target installation is not handled by `llvm-libgcc`, which is not
consistent
with `libunwind`.


This patch fixes those issues by:

Reusing target `unwind_shared` in `libunwind`, linking
`compiler-rt.builtins`
objects into it, and applying version script.

Adding target `llvm-libgcc`, creating symlinks, and utilizing cmake's
dependency
and component mechanism to ensure link targets will be built and
installed along
with symlinks.

Mimicking `libunwind` to handle per target installation.


It is quite hard to set necessary options without further modifying the
order of
runtime projects in `runtimes/CMakeLists.txt`. So though this patch
reveals the
possibility of co-existence of `llvm-libgcc` and
`compiler-rt`/`libunwind` in
`LLVM_ENABLE_RUNTIMES`, we still inhibit it to minimize influence on
other
projects, considering that `llvm-libgcc` is only intended for toolchain
vendors,
and not for casual use.
2023-09-18 22:56:03 -07:00
Jason Molenda
44532a9dd4 Revert "[lldb] Add 'modify' type watchpoints, make it default (#66308)"
TestStepOverWatchpoint.py and TestUnalignedWatchpoint.py are failing
on the ubuntu and debian bots
https://lab.llvm.org/buildbot/#/builders/68/builds/60204
https://lab.llvm.org/buildbot/#/builders/96/builds/45623

and the newly added test TestModifyWatchpoint.py does not
work on windows bot
https://lab.llvm.org/buildbot/#/builders/219/builds/5708

I will debug tomorrow morning and reland.

This reverts commit 3692267ca8.
2023-09-18 22:50:39 -07:00
Fangrui Song
af935cf0ee
[CodeLayout] Fix X1_Y_X2 and Y_X2_X1 testing for jumps from Y (#66592)
The CHECK2 test in code_placement_ext_tsp_large.ll now has the same
result as
the CHECK test: when chain(0,2,3,4,1) is merged with chain(8), the
result is now
chain(0,2,3,4,8,1).

Ideally we should have test coverage for
-ext-tsp-chain-split-threshold=1, but
it seems challenging to craft one. Perhaps the default value of
-ext-tsp-chain-split-threshold can be decreased as the
-ext-tsp-enable-chain-split-along-jumps heuristic is now more powerful.
2023-09-18 22:50:17 -07:00
Fangrui Song
345f532f3f [ELF][test] Improve relocations referencing STT_SECTION tests for -r
Also add a --compress-debug-sections=zlib test to demonstrate issue #66738
2023-09-18 22:46:56 -07:00
Stella Laurenzo
33df617dfd
[mlir] Quality of life improvements to python API types. (#66723)
* Moves several orphaned methods from Operation/OpView -> _OperationBase
so that both hierarchies share them (whether unknown or known to ODS).
* Adds typing information for missing `MLIRError` exception.
* Adds `DiagnosticInfo` typing.
* Adds `DenseResourceElementsAttr` typing that was missing.
2023-09-18 21:30:41 -07:00
Jeff Bailey
acfb99d9fd
[libc] Specify path for making include/ subdirs (#66589)
When doing a clean build from vscode, it makes the subdirectories in the
source tree rather than in the build folder. Elsehwere in LLVM, they
prefix the MAKE_DIRECTORY calls, so this appears to be the correct
approach.
2023-09-18 21:00:51 -07:00
Wang Pengcheng
3017545e63
[RISCV] Fix inline asm error for block address (#66640)
After commit cedf2ea, `RISCVMergeBaseOffset` can handle `BlockAddress`
currently. But we didn't handle it in `PrintAsmMemoryOperand` so we
get `invalid operand in inline asm` error.

This patch fixes the error.
2023-09-19 11:46:43 +08:00
Amir Ayupov
6a1cf545cc [BOLT][YAML] Only read first profile per function
D159460 regressed the bugfix in D156644. Fix that and emit a warning.
Add a test case.

Reviewed By: #bolt, maksfb

Differential Revision: https://reviews.llvm.org/D159529
2023-09-18 20:40:47 -07:00
Yingwei Zheng
4ea883cbbb
[InstCombine] Add pre-commit tests for PR66606. NFC. 2023-09-19 11:13:16 +08:00
Jacques Pienaar
31ebe98e48
[mlir][c] Expose AsmState. (#66693)
Enable usage where capturing AsmState is good (e.g., avoiding creating AsmState over and over again when walking IR and printing).

This also only changes one C API to verify plumbing. But using the AsmState makes the cost more explicit than the flags interface (which hides the traversals and construction here) and also enables a more efficient usage C side.
2023-09-18 20:12:12 -07:00
Yeting Kuo
6af39d914c
[RISCV][NFC] Simplify the sp-offset reduction by spimm of CM.PUSH/POP. (#66667)
When inserting prolgue/epilogue, we use the spimm of CM.PUSH/POP to
reduce the following offset for sp. Previously, we tried to use the free
space of the push stack to minimize the following sp-offset. But it's
useless, since the free space must be less than 16 and required stack should
be aligned to 16 before/after the adjustment.
2023-09-19 11:01:47 +08:00
Yunze Zhu
544535976d [RISCV][MC]Add support for Binary MCExpr
There is an issue: https://github.com/llvm/llvm-project/issues/64612
This issue happens because in RISCVMCCodeEmitter::getImmOpValue it only handles MCExpr kind Target and SymbolRef.
When code with format like .+ comes in, it comes with MCExpr kind Binary, the fixupkind remains fixup_riscv_invalid and reports error.

This patch make MCExpr kind Binary handled with the same way as MCExpr kind SymbolRef,
so code with binary expression can get correct fixupkind and be used to generate more complex relocation.

Differential Revision: https://reviews.llvm.org/D157694
2023-09-19 10:35:16 +08:00
LLVM GN Syncbot
4b7a08f0f8 [gn build] Port 3692267ca8 2023-09-19 02:17:16 +00:00
Jason Molenda
3692267ca8
[lldb] Add 'modify' type watchpoints, make it default (#66308)
Watchpoints in lldb can be either 'read', 'write', or 'read/write'. This
is exposing the actual behavior of hardware watchpoints. gdb has a
different behavior: a "write" type watchpoint only stops when the
watched memory region *changes*.

A user is using a watchpoint for one of three reasons:

1. Want to find what is changing/corrupting this memory.
2. Want to find what is writing to this memory.
3. Want to find what is reading from this memory.

I believe (1) is the most common use case for watchpoints, and it
currently can't be done in lldb -- the user needs to continue every time
the same value is written to the watched-memory manually. I think gdb's
behavior is the correct one. There are some use cases where a developer
wants to find every function that writes/reads to/from a memory region,
regardless of value, I want to still allow that functionality.

This is also a bit of groundwork for my large watchpoint support
proposal
https://discourse.llvm.org/t/rfc-large-watchpoint-support-in-lldb/72116
where I will be adding support for AArch64 MASK watchpoints which watch
power-of-2 memory regions. A user might ask to watch 24 bytes, and a
MASK watchpoint stub can do this with a 32-byte MASK watchpoint if it is
properly aligned. And we need to ignore writes to the final 8 bytes of
that watched region, and not show those hits to the user.

This patch adds a new 'modify' watchpoint type and it is the default.

rdar://108234227
2023-09-18 19:16:45 -07:00
Piotr Fusik
c724ac9330
[clang] Fix null dereference on return in lambda attribute statement expr (#66643)
clang was crashing on a lambda attribute with a statement expression
that contained a `return`.
It attempted to access the lambda type which was unknown at that point.

Fixes https://github.com/llvm/llvm-project/issues/48527
2023-09-19 04:02:04 +02:00
Fangrui Song
7db4a6f278 [bazel] Port cbd475040f (mlir/lib/Dialect/MLProgram) 2023-09-18 18:47:21 -07:00
Vitaly Buka
dc810e880f [NFC][hwasan] Collect heap related data early (#66682) 2023-09-18 18:41:00 -07:00
Danila Malyutin
a668c0f687
[LoopPredication] Fix division by zero in case of zero branch weights (#66506)
Treat the case where all branch weights are zero as if there was no
profile.
Fixes #66382
2023-09-19 04:38:29 +03:00
Vitaly Buka
d307d20717 [NFC][hwasan] Make PrintAddressDescription method of BaseReport (#66682) 2023-09-18 18:34:12 -07:00
Vitaly Buka
13deda4f22 [NFC][hwasan] Remove default argument 2023-09-18 18:28:24 -07:00
Vitaly Buka
8519d4fda1 [NFC][hwasan] Add access_size into base report (#66682) 2023-09-18 18:21:40 -07:00
Allen
48caa0723c
[LAA] Analyze pointers forked by a phi (#65834)
Given a function like the following: https://godbolt.org/z/T9c99fr88
```c
1161_noReadWrite(int *Preds) {
  for (int i = 0; i < LEN_1D-1; ++i) {
    if (Preds[i] != 0)
      b[i] = c[i] + 1;
    else
      a[i] = i * i;
  }
}
```

LLVM will optimize the IR to a single store by a phi instruction:

   ```llvm
      %1 = load ptr, ptr @a, align 64
      %2 = load ptr, ptr @b, align 64
      ...
    for.inc:
      %.sink = phi ptr [ %1, %if.then ], [ %2, %if.else ]
      %add.sink = phi double [ %add, %if.then ], [ %conv8, %if.else ]
%arrayidx7 = getelementptr inbounds double, ptr %.sink, i64 %indvars.iv
      store double %add.sink, ptr %arrayidx7, align 8
   ```

LAA is currently unable to analyze such IR, since ScalarEvolution will
return a SCEVUnknown for the forked pointer operand of the store.

This patch adds initial optional support for analyzing both
possibilities for the pointer and allowing LAA to generate runtime
checks for the bounds if required, refers to D108699, but here address
the phi node.

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

Reviewed By: huntergr-arm, fhahn
Differential Revision: https://reviews.llvm.org/D158965
2023-09-19 09:16:47 +08:00
Vitaly Buka
542f91f755 [NFC][hwasan] Store thread id in SavedStackAllocations (#66682) 2023-09-18 18:13:57 -07:00
Spenser Bauman
0a0c7e8978
[mlir][tensor] Bufferize tensor.reshape with non-identity layouts (#65654)
Bufferization of tensor.reshape generates a memref.reshape operation.
memref.reshape requires the source memref to have an identity layout.
The bufferization process may result in the source memref having a
non-identity layout, resulting in a verification failure.

This change causes the bufferization interface for tensor.reshape to
copy the source memref to a new buffer when the source has a
non-identity layout.
2023-09-19 09:50:43 +09:00
Vitaly Buka
810bca56f0 [NFC][hwasan] Move PrintAddressDescription (#66682) 2023-09-18 17:20:50 -07:00
Vitaly Buka
9094b3b4ae [NFC][hwasan] Extract BaseReport (#66682) 2023-09-18 17:19:53 -07:00
MaheshRavishankar
170a25a793
[mlir][TilingInterface] Make the tiling set tile sizes function use OpFoldResult. (#66566) 2023-09-18 17:18:51 -07:00
Vitaly Buka
75fdf2e7b6 [NFC][hwasan] Move Report classes together (#66682) 2023-09-18 17:16:01 -07:00
Vitaly Buka
d39d86da4a [NFC][hwasan] Use unnamed namespace and static (#66682) 2023-09-18 17:16:01 -07:00
Vitaly Buka
0fb6da8bab [NFC][hwasan] Create *Report classes (#66682)
This prepare the code for rework to collect all nececcecary data before
symbolization. Symbolization as any untrivial computations may affect
hwasan metadata.
2023-09-18 17:14:44 -07:00
Rob Suderman
cbd475040f [mlir][mlprogram] Add mlprogram-pipeline-globals optimization pass
Added pass optimizes MLProgram global operations by reducing to only
the minimal load/store operations for global tensors. This avoids
unnecessary global operations throughout a program and potentially
improves operation gusion.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D159228
2023-09-18 17:11:29 -07:00
Vitaly Buka
b2ef297b6e [NFC][hwasan] Remove default argument 2023-09-18 17:09:55 -07:00
Philip Reames
928564caa5
[RISCV] Combine a gather to a larger element type (#66694)
If we have a gather load whose indices correspond to valid offsets for a
gather with element type twice that our source, we can reduce the number
of indices and perform the operation at the larger element type.

This is generally profitable since we half VL - and these operations are
linear in VL. This may require some additional VL/VTYPE toggles, but
this appears to be worthwhile on the whole.
2023-09-18 16:55:38 -07:00
Shoaib Meenai
915ebb07df [driver] Address missed feedback from https://reviews.llvm.org/D158476
I missed this before I committed.
2023-09-18 16:28:04 -07:00
Shoaib Meenai
58288c6c12 [driver] Search for compatible Android runtime directories
Android triples include a version number, which makes direct triple
comparisons for per-target runtime directory searching not always work.
Instead, look for the triple with the highest compatible version number
and use that per-target runtime directory instead. This maintains the
existing fallback to a triple without any version number, but I'm hoping
we can remove that in the future. https://discourse.llvm.org/t/62717
discusses this further.

The one remaining triple mismatch after this is that Android armv7
triples usually have an environment of `androideabi`, which Clang
normalizes to `android`. If you use the `androideabi` triple when
building the runtimes with a per-target runtimes dir, the directory will
get created with `androideabi` in its name, but Clang's triple search
uses the normalized triple and will look for an `android` directory
instead. https://reviews.llvm.org/D140925 will fix that by normalizing
triples when creating the per-target runtimes directories as well.

Reviewed By: phosek, pirama

Differential Revision: https://reviews.llvm.org/D158476
2023-09-18 16:14:18 -07:00
weiguozhi
9a04bc4c43
[AArch64] Move LDR_PXI from isStoreToStackSlot to isLoadFromStackSlot (#65658)
LDR_PXI is a load instruction, so it should be in isLoadFromStackSlot.
2023-09-18 15:52:41 -07:00
modimo
272bd6f9cc [WPD][LLD] Add option to validate RTTI is enabled on all native types and prevent devirtualization on types with native RTTI
Discussion about this approach: https://discourse.llvm.org/t/rfc-safer-whole-program-class-hierarchy-analysis/65144/18

When enabling WPD in an environment where native binaries are present, types we want to optimize can be derived from inside these native files and devirtualizing them can lead to correctness issues. RTTI can be used as a way to determine all such types in native files and exclude them from WPD providing a safe checked way to enable WPD.

The approach is:
1. In the linker, identify if RTTI is available for all native types. If not, under `--lto-validate-all-vtables-have-type-infos` `--lto-whole-program-visibility` is automatically disabled. This is done by examining all .symtab symbols in object files and .dynsym symbols in DSOs for vtable (_ZTV) and typeinfo (_ZTI) symbols and ensuring there's always a match for every vtable symbol.
2. During thinlink, if `--lto-validate-all-vtables-have-type-infos` is set and RTTI is available for all native types, identify all typename (_ZTS) symbols via their corresponding typeinfo (_ZTI) symbols that are used natively or outside of our summary and exclude them from WPD.

Testing:
ninja check-all
large Meta service that uses boost, glog and libstdc++.so runs successfully with WPD via --lto-whole-program-visibility. Previously, native types in boost caused incorrect devirtualization that led to crashes.

Reviewed By: MaskRay, tejohnson

Differential Revision: https://reviews.llvm.org/D155659
2023-09-18 15:51:49 -07:00
Peiming Liu
4176ce61f1
[mlir][sparse] fix logical error when generating sort_coo. (#66690)
To fix issue: https://github.com/llvm/llvm-project/issues/66664
2023-09-18 15:26:01 -07:00
cor3ntin
cacdb90bd7
[Clang] Fix a crash in the diagnostic emission of invalid immediate calls (#66699)
`CXXCtorInitializer` may not refer to a FieldDecl because it might also
denote another constructor call.

Fixes #66324
2023-09-19 00:24:43 +02:00
Walter Erquinigo
266630cffc [LLDB] Attempt to fix DumpDataExtractorTest
In 014c41d688 I tried to fix these tests,
but it seems that I needed to change TEST for TEST_F to make that work.
It's a pain that these failures don't repro on any of my machines, but I
verified thta the initialization code for the tests is invoked.
2023-09-18 22:02:05 +00:00
Mitch Phillips
6b7c402774
Ignore out-of-bounds printf() format string in ASan test (#66695)
This warning needs to be disabled. The format string is deliberately too
large.
2023-09-18 14:47:00 -07:00