Commit Graph

511311 Commits

Author SHA1 Message Date
Weining Lu
34cab2ed82 [Driver][test] Remove useless LoongArch test checks in mcmodel.c 2024-09-11 16:10:38 +08:00
Nikita Popov
2afe678f0a [MemCpyOpt] Allow memcpy elision for non-noalias arguments (#107860)
We currently elide memcpys for readonly nocapture noalias arguments.
noalias is checked to make sure that there are no other ways to write
the memory, e.g. through a different argument or an escaped pointer.

In addition to the current noalias check, also query alias analysis, in
case it can prove that modification is not possible through other means.

This fixes the problem reported in
https://discourse.llvm.org/t/problem-about-memcpy-elimination/81121.
2024-09-11 10:04:37 +02:00
Michael Buch
19f604edfc [lldb][test] Add test for printing std::string through expression evaluator
This would've caught the failures in
https://github.com/llvm/llvm-project/pull/105865 in the libc++
data-formatter CI.
2024-09-11 08:58:03 +01:00
Nikita Popov
1e3a24d2e4 [InitUndef] Don't use largest super class (#107885)
The InitUndef pass currently uses the getLargestSuperClass() hook (which
is only used by that pass) to chose the register to initialize. This was done
to reduce the number of undef init pseudos needed, e.g. so that the vrnov0
regclass would use the same pseudo as v0. After #106744 we use a single
generic pseudo, so this is no longer necessary.
2024-09-11 09:36:20 +02:00
Nikolas Klauser
748023dc32 [libc++][NFC] Replace _LIBCPP_NORETURN and TEST_NORETURN with [[noreturn]] (#80455)
`[[__noreturn__]]` is now always available, so we can simply use the
attribute directly instead of through a macro.
2024-09-11 08:59:46 +02:00
David Green
cd0e867756 [AArch64] Update and cleanup arm64-vector-imm.ll test. NFC 2024-09-11 07:50:39 +01:00
Nikolas Klauser
6dbdb8430b [Clang] Fix crash due to invalid source location in __is_trivially_equality_comparable (#107815)
Fixes #107777
2024-09-11 08:47:24 +02:00
Prabhuk
bc152fbf43 [llvm-debuginfod-find] Enable multicall driver (#108082)
Migrate llvm-debuginfod-find tool to use GenericOptTable. 
Enable multicall driver.
2024-09-10 23:04:05 -07:00
AdityaK
3c9022c965 Bail out jump threading on indirect branches (#103688)
The bug was introduced by
https://github.com/llvm/llvm-project/pull/68473

Fixes: #102351
2024-09-10 22:39:02 -07:00
Ryosuke Niwa
203a2ca8cd [webkit.RefCntblBaseVirtualDtor] Make ThreadSafeRefCounted not generate warnings (#107676)
This PR makes WebKit's RefCntblBaseVirtualDtor checker not generate a
warning for ThreadSafeRefCounted when the destruction thread is a
specific thread.

Prior to this PR, we only allowed CRTP classes without a virtual
destructor if its deref function had an explicit cast to the derived
type, skipping any lambda declarations which aren't invoked. This ends
up generating a warning for ThreadSafeRefCounted when a specific thread
is used to destruct the object because there is no inline body /
definition for ensureOnMainThread and ensureOnMainRunLoop and
DerefFuncDeleteExprVisitor concludes that there is no explicit delete of
the derived type.

This PR relaxes the condition DerefFuncDeleteExprVisitor checks by
allowing a delete expression to appear within a lambda declaration if
it's an argument to an "opaque" function; i.e. a function without
definition / body.
2024-09-10 22:25:03 -07:00
ChiaHungDuan
323911de27 Reapply "[scudo] Fix the logic of MaxAllowedFragmentedPages" (#108130) (#108134)
This reverts commit 76151c4490.

Also changed to check MaxAllowedFragmentedPages.
2024-09-10 22:24:06 -07:00
Timm Baeder
d03822d888 [clang][bytecode] Fix lookup of source locations in implicit ctors (#107992)
Implicit functions may still have a body. The !hasBody() check is
enough.
2024-09-11 07:21:49 +02:00
Heejin Ahn
6bbf7f06d8 [WebAssembly] Add assembly support for final EH proposal (#107917)
This adds the basic assembly generation support for the final EH
proposal, which was newly adopted in Sep 2023 and advanced into Phase 4
in Jul 2024:

https://github.com/WebAssembly/exception-handling/blob/main/proposals/exception-handling/Exceptions.md

This adds support for the generation of new `try_table` and `throw_ref`
instruction in .s asesmbly format. This does NOT yet include
- Block annotation comment generation for .s format
- .o object file generation
- .s assembly parsing
- Type checking (AsmTypeCheck)
- Disassembler
- Fixing unwind mismatches in CFGStackify

These will be added as follow-up PRs.

---

The format for `TRY_TABLE`, both for `MachineInstr` and `MCInst`, is as
follows:
```
TRY_TABLE type number_of_catches catch_clauses*
```
where `catch_clause` is
```
catch_opcode tag+ destination
```
`catch_opcode` should be one of 0/1/2/3, which denotes
`CATCH`/`CATCH_REF`/`CATCH_ALL`/`CATCH_ALL_REF` respectively. (See
`BinaryFormat/Wasm.h`) `tag` exists when the catch is one of `CATCH` or
`CATCH_REF`.
The MIR format is printed as just the list of raw operands. The
(stack-based) assembly instruction supports pretty-printing, including
printing `catch` clauses by name, in InstPrinter.

In addition to the new instructions `TRY_TABLE` and `THROW_REF`, this
adds four pseudo instructions: `CATCH`, `CATCH_REF`, `CATCH_ALL`, and
`CATCH_ALL_REF`. These are pseudo instructions to simulate block return
values of `catch`, `catch_ref`, `catch_all`, `catch_all_ref` clauses in
`try_table` respectively, given that we don't support block return
values except for one case (`fixEndsAtEndOfFunction` in CFGStackify).
These will be omitted when we lower the instructions to `MCInst` at the
end.

LateEHPrepare now will have one more stage to covert
`CATCH`/`CATCH_ALL`s to `CATCH_REF`/`CATCH_ALL_REF`s when there is a
`RETHROW` to rethrow its exception. The pass also converts `RETHROW`s
into `THROW_REF`. Note that we still use `RETHROW` as an interim pseudo
instruction until we convert them to `THROW_REF` in LateEHPrepare.

CFGStackify has a new `placeTryTableMarker` function, which places
`try_table`/`end_try_table` markers with a necessary `catch` clause and
also `block`/`end_block` markers for the destination of the `catch`
clause.

In MCInstLower, now we need to support one more case for the multivalue
block signature (`catch_ref`'s destination's `(i32, exnref)` return
type).

InstPrinter has a new routine to print the `catch_list` type, which is
used to print `try_table` instructions.

The new test, `exception.ll`'s source is the same as
`exception-legacy.ll`, with the FileCheck expectations changed. One
difference is the commands in this file have `-wasm-enable-exnref` to
test the new format, and don't have `-wasm-disable-explicit-locals
-wasm-keep-registers`, because the new custom InstPrinter routine to
print `catch_list` only works for the stack-based instructions (`_S`),
and we can't use `-wasm-keep-registers` for them.

As in `exception-legacy.ll`, the FileCheck lines for the new tests do
not contain the whole program; they mostly contain only the control flow
instructions for readability.
2024-09-10 21:32:24 -07:00
Kazu Hirata
3dad29b677 [LTO] Remove unused includes (NFC) (#108110)
clangd reports these as unused headers.  My manual inspection agrees
with the findings.
2024-09-10 19:36:04 -07:00
Valentin Clement (バレンタイン クレメン)
e67a6667dc [flang][cuda] Avoid extra load in c_f_pointer lowering with c_devptr (#108090)
Remove unnecessary load of the `cptr` component when getting the
`__address`. `fir.coordinate_of` operation can be chained so the load is
not needed.
2024-09-10 19:33:33 -07:00
Sterling-Augustine
3b4e7c9c45 [SandboxIR] Implement ScalableVectorType (#108124)
As in the heading.
2024-09-10 19:11:14 -07:00
Peter Klausler
c5711130be [flang] Fix cycle of build dependencies (#108132)
While trying to fix one build problem, I made things worse. This should
clear things up.
2024-09-10 19:00:32 -07:00
ChiaHungDuan
76151c4490 Revert "[scudo] Fix the logic of MaxAllowedFragmentedPages" (#108130)
Reverts llvm/llvm-project#107927

We are supposed to check the MaxAllowedFragmentedPages instead.
2024-09-10 18:56:49 -07:00
YunQiang Su
5773adb0bf SelectionDAG: Remove unneeded getSelectCC in expandFMINIMUMNUM_FMAXIMUMNUM (#107416)
ISD::FCANONICALIZE is enough, which can process NaN or non-NaN
correctly, thus getSelectCC is not needed here.
2024-09-11 09:53:04 +08:00
Philip Reames
12530015a4 [RISCV] Add reductions to list of roots in tryToReduceVL (#107595)
This allows us to reduce VLs feeding reduction instructions. In
particular, this means that <3 x Ty> reduce(load) like sequences no
longer require a VL toggle.

This was waiting on 3d72957; now that the latent correctness issue is
fixed, we can expand this transform.
2024-09-10 18:47:20 -07:00
Peter Klausler
901006f238 [flang] Make flang module hidden dependency explicit to correct build… (#108129)
… failure

Any flang module with a derived type definition implicitly depends on
flang/module/__fortran_type_info.f90. Make this dependency explicit so
that an unlucky build order doesn't cause a crash.
2024-09-10 18:45:06 -07:00
Luke Lau
933fc63a1d [RISCV] Rematerialize vmv.s.x and vfmv.s.f (#108012)
Continuing with #107993 and #108007, this handles the last of the main
rematerializable vector instructions.

There's an extra spill in one of the test cases, but it's likely noise
from the spill weights and isn't an issue in practice.
2024-09-11 09:44:57 +08:00
Luke Lau
21a0176c58 [RISCV] Rematerialize vfmv.v.f (#108007)
This is the same principle as vmv.v.x in #107993, but for floats.
2024-09-11 09:38:29 +08:00
YunQiang Su
c641b611f8 MIPSr6: Add llvm.is.fpclasss intrinsic support (#107857)
MIPSr6 has class.s/class.d instructions.
Let's use them for llvm.is.fpclass intrinsic.
2024-09-11 09:37:12 +08:00
Jim Lin
69ed73380b [RISCV] Add testcase for -mcmodel= (#107816)
This is a pre-commit test for #107817
2024-09-11 09:17:05 +08:00
Luke Lau
77fc8dae22 [RISCV] Rematerialize vmv.v.x (#107993)
Even though vmv.v.x has a non constant scalar operand, we can still
rematerialize it because we have split register allocation between
vectors and scalars.

InlineSpiller will check to make sure that the scalar operand is live at
the point where the rematerialization occurs, so this won't extend any
scalar live ranges. However this also means we may not be able to
rematerialize in some cases, as shown in @vmv.v.x_needs_extended.

It might be worthwhile teaching InlineSpiller to extend scalar live
ranges in a future patch. I experimented with this locally and it
reduced spills on 531.deepsjeng_r by a further 3%.
2024-09-11 09:13:23 +08:00
SahilPatidar
68f31aaae9 [ORC][Runtime] Add dlupdate for MachO (#97441)
With the help of @lhames, This pull request introduces the `dlupdate`
function in the ORC runtime. `dlupdate` enables incremental execution of
new initializers introduced in the REPL environment. Unlike traditional
`dlopen`, which manages initializers, code mapping, and library
reference counts, `dlupdate` focuses exclusively on running new
initializers.
2024-09-11 10:50:01 +10:00
ChiaHungDuan
6e854a6a01 [scudo] Fix the logic of MaxAllowedFragmentedPages (#107927)
MTE doesn't support MaxReleasedCachePages which may break the assumption
that only the first 4 pages will have memory tagged.
2024-09-10 17:46:02 -07:00
Arthur Eubanks
db7e8f2ae8 [compiler-rt] Hardcode uptr/sptr typedefs on Linux Arm (#108105)
After #106155, Android arm32 asan builds stopped working with missing
definition linker errors. This is due to inconsistent definitions of
`uptr` of either `unsigned long` or `unsigned int` even between TUs in
compiler-rt. This is caused by Linux arm32 headers redefining
`__UINTPTR_TYPE__` (see `arch/arm/include/uapi/asm/types.h` in the Linux
kernel repo), meaning include order/whether or not the Linux header is
included changes compiler-rt symbol mangling.

As a workaround, this hardcodes `uptr`/`sptr` in compiler-rt to
`unsigned int`/`int` on Linux arm32, matching clang/gcc.
2024-09-10 17:02:15 -07:00
Craig Topper
d2f25e5405 [LegalizeTypes] Avoid creating an unused node in ExpandIntRes_ADDSUB. NFC
The Hi result is sometimes calculated a different way and this
node goes unused. Defer creation until we know for sure it is neeeded.

The test changes is because the node creation order changed the names
in the debug output.
2024-09-10 16:39:19 -07:00
Teresa Johnson
ae5f1a78d3 [MemProf] Convert CallContextInfo to a struct (NFC) (#108086)
As suggested in #107918, improve readability by converting this tuple to
a struct.
2024-09-10 16:27:56 -07:00
Reid Kleckner
829ea59dda [docs] Add a section on AI-generated content to the developer policy (#91014)
Governments around the world are starting to require labelling for
AI-generated content, and some LLVM stakeholders have asked if LLVM
contains AI-generated content. Defining a policy on the use of AI tools
allows us to answer that question affirmatively, one way of the other.

The policy proposed here allows the use of AI tools in LLVM
contributions, flowing from the idea that any contribution is fine
regardless of how it is made, as long as the contributor has the right
to license it under the project license.

I gathered input from the community in this RFC and incorporated it into the policy:
https://discourse.llvm.org/t/rfc-define-policy-on-ai-tool-usage-in-contributions/78758
2024-09-10 16:21:01 -07:00
Florian Mayer
5804193e38 Revert "[sanitizer] Add CHECKs to validate calculated TLS range" (#108112)
Reverts llvm/llvm-project#107941

Broke PPC bot
2024-09-10 16:14:07 -07:00
Sterling-Augustine
bb7286515c [SandboxIR] Implement FixedVectorType (#107930) 2024-09-10 15:44:30 -07:00
vporpo
d14a600b1e [SandboxIR] Implement BlockAddress (#107940)
This patch implements sandboxir::BlockAddress mirroring
llvm:BlockAddress.
2024-09-10 15:28:21 -07:00
Henrik G. Olsson
6007ad79af Revert "[llvm-lit] Process ANSI color codes in test output when formatting" (#108104)
Reverts llvm/llvm-project#106776 because of a test failure on Windows.
2024-09-10 15:19:52 -07:00
Jacob Lalonde
10c04d9873 [LLDB]Skip Summary Statistics Tests for Windows (#108079)
Follow up to #102708, the tests are failing for windows. There is a
large variance in these tests between summary strings and built in
types. I'm disabling these test for windows, and will add windows
specific tests as a follow up to this.
2024-09-10 15:12:56 -07:00
Vitaly Buka
957af73738 [sanitizer] Add CHECKs to validate calculated TLS range (#107941) 2024-09-10 15:07:13 -07:00
Peter Klausler
d452429821 [flang] Fix shared library flang build (#108101)
I broke the shared library builds a few minutes ago by introducing a
cyclic dependency between two parts of the compiler. Fix.
2024-09-10 15:00:42 -07:00
vporpo
2ddf21bc70 [SandboxIR] Pass registry (#108084)
This patch implements a simple Pass Registry class, which takes
ownership of the passes registered with it and provides an interface to
get the pass pointer by its name.
2024-09-10 14:42:09 -07:00
Philip Reames
0fc4147c6d [RISCV] Add test coverage for mul X, C where C=2^N*(3,5,9)*(3,5,9) 2024-09-10 14:37:33 -07:00
Jorge Gorbe Moya
ace6d5f2ce [SandboxIR] Fix base class of FenceInst. Verify instructions when building a BB in debug mode. (#108078)
@vporpo suggested in an offline conversation that verifying all
instructions during `BasicBlock::buildBasicBlockFromLLVMIR` would be a
good way to get coverage for errors like this during testing. He also
suggested not gating it on `SBVEC_EXPENSIVE_CHECKS` for now as the
checks are pretty basic at the moment and they only affect Debug builds.
2024-09-10 14:33:04 -07:00
Heejin Ahn
5495c36104 [WebAssembly] Misc. refactoring in AsmTypeCheck (NFC) (#107978)
Existing methods in AsmTypeCheck assumes symbol operand is the 0th
operand; they take a `MCInst` and take `getOperand(0)` on it. I think
passing a `MCOperand` removes this assumption and also is more
intuitive. This was motivated by a new `try_table` instruction, whose
support is going to be added to AsmTypeCheck soon, which has tag symbol
operands in any position, depending on the number and the kinds of catch
clauses. This PR changes all methods' signature that assumes the 0th
operand is the relevant one, even if it's not the symbol operand.

This also adds `getSignature` method, which factors out the common task
when getting a `WasmSignature` from a `MCOperand`.
2024-09-10 14:22:57 -07:00
Chris Apple
5a2071b184 [compiler-rt][rtsan] Improve error message wording to match ASan style (#107620) 2024-09-10 14:20:32 -07:00
Peter Klausler
d418a03e01 [flang] Fix error from semantics on use associated procedure pointer (#107928)
Use associated procedure pointers were eliciting bogus errors from
semantics if their modules also contained generic procedure interfaces
of the same name. (The compiler handles this case correctly when the
specific procedure of the same name is not a pointer.)

With this fix, the test case in
  https://github.com/llvm/llvm-project/issues/107784
no longer experiences semantic errors; however, it now crashes
unexpectedly in lowering.
2024-09-10 14:15:20 -07:00
Peter Klausler
37f94cd99a [flang] Accept KIND(x) when x is assumed-rank (#107787)
Don't emit a bogus error about being unable to forward an assumed-rank
dummy argument as an actual argument in the case of the KIND intrinsic
function.

Fixes https://github.com/llvm/llvm-project/issues/107782.
2024-09-10 14:14:33 -07:00
Peter Klausler
15106c2666 [flang][runtime] Fix odd "invalid descriptor" runtime crash (#107785)
A defined assignment generic interface for a given LHS/RHS type & rank
combination may have a specific procedure with LHS dummy argument that
is neither allocatable nor pointer, or specific procedure(s) whose LHS
dummy arguments are allocatable or pointer. It is possible to have two
specific procedures if one's LHS dummy argument is allocatable and the
other's is pointer.

However, the runtime doesn't work with LHS dummy arguments that are
allocatable, and will crash with a mysterious "invalid descriptor" error
message.

Extend the list of special bindings to include
ScalarAllocatableAssignment and ScalarPointerAssignment, use them when
appropriate in the runtime type information tables, and handle them in
Assign() in the runtime support library.
2024-09-10 14:14:08 -07:00
Peter Klausler
ea858e39bf [flang][runtime] Accept '\n' as space in internal list-directed input (#107716)
When scanning ahead for the first character in the next input item in
list-directed internal input, allow a newline character to appear and
treat it as a space, matching the behavior of nearly all other Fortran
compilers.
2024-09-10 14:13:47 -07:00
Peter Klausler
cd92c42555 [flang][runtime] Don't emit runtime error for "AA" editing (#107714)
Commas are optional between edit descriptors in a format, so treat "AA"
as if it were "A,A".
2024-09-10 14:13:28 -07:00
Peter Klausler
26ac30bcec [flang] Accept initialized SAVE local in specification expression (#107656)
Specification expressions may contain references to dummy arguments,
host objects, module variables, and variables in COMMON blocks, since
they will have values on entry to the scope. A local variable with a
initializer and the SAVE attribute (which will always be implied by an
explicit initialization) will also always work, and is accepted by at
least one other compiler, so accept it with a warning.
2024-09-10 14:13:09 -07:00