Commit Graph

463173 Commits

Author SHA1 Message Date
Martin Storsjö
fcbbd9649a [libcxx] Fix using std::wcout/wcin on Windows with streams configured in wide mode
On Windows, the underlying file descriptors for stdout/stdin/stderr
can be reconfigured to wide mode. In the default (narrow) mode, the
charset usually isn't utf8 (as libcxx assumes), but normally a locale
specific codepage (where each codepage only can represent a small
subset of unicode characters).

By configuring the stdout file descriptor to wide mode, the user can
output wchar_t based strings without convesion to the narrow charset.
Within libcxx, don't try to use codecvt to convert this to a narrow
character encoding, but output these strings as such with fputwc.

In wide mode, such strings could be output directly with fwrite too,
but if the file descriptor hasn't been configured in wide mode, that
breaks the output (which currently works reasonably). By always
outputting one character at a time with fputwc, it works regardless
of mode of the stdout file descriptor.

For the narrow output stream, std::cout, outputting (via fwrite)
does fail when the file descriptor is set to wide mode. This matches
how it behaves with both MS STL and GNU libstdc++ too, so this is
probably acceptable.

This fixes https://github.com/llvm/llvm-project/issues/46646, and
the downstream bugs https://github.com/mstorsjo/llvm-mingw/issues/145
and https://github.com/mstorsjo/llvm-mingw/issues/222.

Differential Revision: https://reviews.llvm.org/D146398
2023-06-03 23:11:39 +03:00
Owen Pan
4b9764959d [clang-format] Fix overlapping replacements before PPDirectives
If the first token of an annotated line is finalized, reuse its
NewlinesBefore value to avoid potential overlapping whitespace
replacements before preprocessor branching directives.

Fixes #62892.

Differential Revision: https://reviews.llvm.org/D151954
2023-06-03 12:33:03 -07:00
Kazu Hirata
797564104a [MCA] Modernize Stage (NFC) 2023-06-03 11:01:18 -07:00
Kazu Hirata
83d4f681c8 [MCA] Modernize RAWHazard (NFC) 2023-06-03 11:01:17 -07:00
Kazu Hirata
6d4d019654 [MCA] Modernize MemoryGroup (NFC) 2023-06-03 11:01:15 -07:00
Kazu Hirata
b48ebad561 [MCA] Modernize StallInfo (NFC) 2023-06-03 10:38:55 -07:00
Kazu Hirata
87709b719c [llvm-mca] Modernize MCACommentConsumer (NFC) 2023-06-03 10:38:53 -07:00
Kazu Hirata
064b98fc5f [MCA] Modernize IncrementalSourceMgr (NFC) 2023-06-03 10:38:51 -07:00
Simon Pilgrim
4dcd66a005 [GlobalIsel][X86] Update legalization of G_MUL
Replace the legacy G_MUL legalizer, this handles all scalar promotion and vector clamping, however we still need to add custom legalization for many vector multiplies.
2023-06-03 18:22:02 +01:00
eopXD
1cb382718a [Clang][RISCV] Avoid generating MaskedPrototype if the intrinsic does not have a masked version. NFC
The function should not be called if an intrinsic does not have a masked version.

Signed-off by: eop Chen <eop.chen@sifive.com>
2023-06-03 10:20:04 -07:00
Kazu Hirata
2a8c1fd20b [MCA] Modernize Pipeline (NFC) 2023-06-03 09:37:39 -07:00
Kazu Hirata
8e6e659cc8 [Serialization] Remove unused function getKnownModules
The last use was removed by:

  commit 603cd869f7
  Author: Douglas Gregor <dgregor@apple.com>
  Date:   Fri Mar 22 18:50:14 2013 +0000
2023-06-03 09:37:37 -07:00
Kazu Hirata
8dc7647845 [AST] Use DenseMapBase::lookup (NFC) 2023-06-03 09:37:36 -07:00
Corentin Jabot
684f3c968d [Clang] Fix status of P0960
P0960R3 and P1975R0 were marked not implemented because
of #61145,

This issue has been fixed and backported to LLVM 16,
the status page should reflect that.

Reviewed By: #clang-language-wg, ayzhao, erichkeane

Differential Revision: https://reviews.llvm.org/D150122
2023-06-03 17:03:42 +02:00
zhongyunde
34d380e1f6 [IndVars] Add check of loop invariant for indirect use
We usually only check direct use instruction of IV, while the
bitcast of 'ptrtoint ptr to i64' doesn't affect the result, so go
a step further.
Fix https://github.com/llvm/llvm-project/issues/59633.

Reviewed By: markoshorro
Differential Revision: https://reviews.llvm.org/D151877
2023-06-03 22:29:09 +08:00
Hussain Kadhem
287f201f9d [flang] Fix for 541f5c4a6d (D140524) breaking out-of-tree flang build. 2023-06-03 15:19:01 +02:00
paperchalice
0beffb8542 [CMake] Ensure CLANG_RESOURCE_DIR is respected.
re-commit of 39aa0f5c43 with missing file:
cmake/Modules/GetClangResourceDir.cmake.
2023-06-03 04:21:35 -07:00
Sheng
4c2ec08ebc [m68k] Add TLS Support
This patch introduces TLS (Thread-Local Storage) support to the LLVM m68k backend.

Reviewed By: glaubitz

Differential Revision: https://reviews.llvm.org/D144941
2023-06-03 19:09:47 +08:00
Sheng
40d89de4c5 [m68k] Implement absolution long addressing mode for ADDA instruction
Reviewed By: myhsu

Differential Revision: https://reviews.llvm.org/D143316
2023-06-03 19:09:47 +08:00
Sheng
6595cb1dbb [m68k] Implement BSR Instruction
Reviewed By: myhsu

Differential Revision: https://reviews.llvm.org/D143315
2023-06-03 19:09:47 +08:00
Sheng
2f62803ea4 coach UpdateTestChecks to filter out certain symbol aliases for m68k
This patch coaches UpdateTestChecks to filter out these symbol aliases in llc test for m68k
- .L<function name>$local:
- .type .L<function name>$local,@function

Reviewed By: myhsu

Differential Revision: https://reviews.llvm.org/D151526
2023-06-03 19:09:47 +08:00
Simon Pilgrim
41f8b6fe74 [GlobalIsel][X86] Regenerate G_MUL scalar legalization tests
Add i8 test coverage
2023-06-03 11:18:51 +01:00
Martin Storsjö
d072d11022 Revert "[CMake] Ensure CLANG_RESOURCE_DIR is respected."
This reverts commit 39aa0f5c43.

This is missing the new GetClangResourceDir.cmake that is being included,
so all clang builds are broken.
2023-06-03 11:47:57 +03:00
Mike Hommey
57dc16fbe3
[llvm] Strip stabs symbols in Mach-O when stripping debug info 2023-06-03 09:31:42 +02:00
luxufan
1ac99bc452 [InstSimplify] Simplify select i1 ConstExpr, i1 true, i1 false to ConstExpr
`select i1 non-const, i1 true, i1 false` has been optimized to
`non-const`. There is no reason that we can not optimize `select i1
ConstExpr, i1 true, i1 false` to `ConstExpr`.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D151631
2023-06-03 15:09:00 +08:00
paperchalice
39aa0f5c43 [CMake] Ensure CLANG_RESOURCE_DIR is respected. 2023-06-02 23:29:44 -07:00
Nitin John Raj
aa7eace843 [TableGen][GlobalISel] Account for HwMode in RegisterBank register sizes
This patch adds logic for determining RegisterBank size to RegisterBankInfo, which allows accounting for the HwMode of the target. Individual RegisterBanks cannot be constructed with HwMode information as construction is generated by TableGen, but a RegisterBankInfo subclass can provide the HwMode as a constructor argument. The HwMode is used to select the appropriate RegisterBank size from an array relating sizes to RegisterBanks.

Targets simply need to provide the HwMode argument to the <target>GenRegisterBankInfo constructor. The RISC-V RegisterBankInfo constructor has been updated accordingly (plus an unused argument removed).

Reviewed By: simoncook, craig.topper

Differential Revision: https://reviews.llvm.org/D76007
2023-06-02 23:14:17 -07:00
Austin Kerbow
e501ed84aa [AMDGPU] Don't flush vmcnt for loops with use/def pairs
Conditions for hoisting vmcnt with flat instructions should be similar to VMEM.
If there are use/def pairs in a loop body we cannot guarantee that hosting the
waitcnt will be profitable. Better heuristics are needed to analyse whether
gains from avoiding waitcnt in loop bodys outweighs waiting for loads in the
preheader.

Reviewed By: foad

Differential Revision: https://reviews.llvm.org/D151126
2023-06-02 22:55:12 -07:00
Kazu Hirata
fb7f50a0c3 [CodeGen] Use DenseMapBase::lookup (NFC)
Note that DenseMapBase::lookup and Reg2MIMap::get do exactly the same
thing.
2023-06-02 21:05:13 -07:00
Yeting Kuo
84ee08c6a8 [RISCV] Avoid illegal DAG combination for strict-fp nodes.
Those combines may change the exception behavior and rounding behavior.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D151992
2023-06-03 10:29:30 +08:00
Peiming Liu
e7b4c93f5e [mlir][sparse] fix crash when using sparse_tensor::UnaryOp and ReduceOp.
Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D152048
2023-06-03 01:19:05 +00:00
Tue Ly
5a4e344bd9 [libc][NFC] Add LIBC_INLINE and attribute.h header includes to targets' FMA.h.
Targets' FMA.h headers are missing LIBC_INLINE and attributes.h header.

Reviewed By: brooksmoses

Differential Revision: https://reviews.llvm.org/D152024
2023-06-02 21:15:58 -04:00
Aart Bik
6a38c772d4 [mlir][sparse] fixed bug with unary op, dense output
Note that by sparse compiler convention, dense output
is zerod out when not set, so complement results in
zeros where elements were present.

Reviewed By: wrengr

Differential Revision: https://reviews.llvm.org/D152046
2023-06-02 18:15:33 -07:00
Caslyn Tonelli
0a168131b4 [scudo] Add 'inline' to static secondary.h function
This patches an error flaged by Fuchsia builds e.g.
https://ci.chromium.org/ui/p/turquoise/builders/global.try/core.x64-asan/b8779376650819379137/overview)

```
build failed:

[87176/332302](525) CXX user.libc_x64-asan-ubsan/obj/zircon/system/ulib/c/scudo/gwp-asan-info.gwp_asan_info.cc.o
FAILED: user.libc_x64-asan-ubsan/obj/zircon/system/ulib/c/scudo/gwp-asan-info.gwp_asan_info.cc.o
../../prebuilt/third_party/python3/linux-x64/bin/python3.8 -S ../../build/rbe/cxx_remote_wrapper.py --exec_strategy=remote_local_fallback --  ../../prebuilt/third_party/clang/linux-x64/bin/clang++ -MD -MF user.libc_x64-asan-ubsan/obj/zircon/system/ulib/c/scudo/gwp-asan-info.gwp_asan_info.cc.o.d -o user.libc_x64-asan-ubsan/obj/zircon/system/ulib/c/scudo/gwp-asan-info.gwp_asan_info.cc.o -D_LIBCPP...
In file included from ../../zircon/system/ulib/c/scudo/gwp_asan_info.cc:7:
In file included from ../../third_party/scudo/src/allocator_config.h:12:
In file included from ../../third_party/scudo/src/combined.h:22:
../../third_party/scudo/src/secondary.h:67:13: error: 'static' function 'unmap' declared in header file should be declared 'static inline' [-Werror,-Wunneeded-internal-declaration]
static void unmap(LargeBlock::Header *H) {
            ^
1 error generated.
```

Differential Revision: https://reviews.llvm.org/D152038
2023-06-02 23:47:27 +00:00
Nico Weber
ddc7625e3d [gn] port 6b3ae49d32 2023-06-02 19:37:10 -04:00
Kazu Hirata
d6f994acb3 [InlineCost] Check for conflicting target attributes early
When we inline a callee into a caller, the compiler needs to make sure
that the caller supports a superset of instruction sets that the
callee is allowed to use.  Normally, we check for the compatibility of
target features via functionsHaveCompatibleAttributes, but that
happens after we decide to honor call site attribute
Attribute::AlwaysInline.  If the caller contains a call marked with
Attribute::AlwaysInline, which can happen with
__attribute__((flatten)) placed on the caller, the caller could end up
with code that cannot be lowered to assembly code.

This patch fixes the problem by checking the target feature
compatibility before we honor Attribute::AlwaysInline.

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

Differential Revision: https://reviews.llvm.org/D150396
2023-06-02 16:00:47 -07:00
Matt Arsenault
14c44dfbcf clang: Update tests after InstSimplify change
Update tests after 1536e299e6
2023-06-02 18:47:58 -04:00
Teresa Johnson
456468a08a [ThinLTO] Fix internalization decisions for weak/linkonce ODR
This fixes a runtime error that occurred due to incorrect
internalization of linkonce_odr functions where function pointer
equality was broken. This was hit because the prevailing copy was in a
native object, so the IR copies were not exported, and the existing code
internalized all of the IR copies. It could be fixed by guarding this
internalization on whether the defs are (local_)unnamed_addr, meaning
that their address is not significant (which we have in the summary
currently for linkonce_odr via the CanAutoHide flag). Or we can
propagate reference attributes as we do when determining whether a
global variable is read or write-only (reference edges are annotated
with whether they are read-only, write-only, or neither, and taking the
address of a function would result in a reference edge to the function
that is not read or write-only).

However, this exposed a larger issue with the internalization handling.
Looking at test cases, it appears the intent is to internalize when
there is a single definition of a linkonce/weak ODR symbol (that isn't
exported). This makes sense in the case of functions, because the
inliner can apply its last call to static heuristic when appropriate. In
the case where there is no prevailing copy in IR, internalizing all of
the IR copies of a linkonce_odr, even if legal, just increases binary
size. In that case it is better to fall back to the normal handling of
converting all non-prevailing copies to available_externally so that
they are eliminated after inlining.

In the case of variables, the existing code was attempting to
internalize the non-exported linkonce/weak ODR variables if they were
read or write-only. While this is legal (we propagate reference
attributes to determine this information), we don't even need to
internalize these here as there is later separate handling that
internalizes read and write-only variables when we process the module at
the start of the ThinLTO backend (processGlobalForThinLTO). Instead, we
can also internalize any non-exported variable when there is only one
(IR) definition, which is prevailing. And in that case, we don't need to
require that it is read or write-only, since we are guaranteed that all
uses must use that single definition.

In the new LTO API, if there are multiple defs of a linkonce or weak ODR
it will be marked exported, but it isn't clear that this will always be
true for the legacy LTO API. Therefore, require that there is only a
single (non-local) def, and that it is prevailing.

The test cases changes are both to reflect the change in the handling of
linkonce_odr IR copies where the prevailing def is not in IR (the main
correctness bug fix here), and to reflect the more aggressive
internalization of variables when there is only a single def, it is in
IR, and not exported.

I've also added some additional testing via the new LTO API.

Differential Revision: https://reviews.llvm.org/D151965
2023-06-02 15:34:14 -07:00
Florian Mayer
6a2e0cb418 Properly restore SP tag on exceptions
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D152036
2023-06-02 15:33:14 -07:00
Nick Desaulniers
f5371eb3d3 [Damangle] convert dlangDemangle to use std::string_view
I was doing this API conversion to use std::string_view top-down in
D149104, but this exposed issues in individual demanglers that needed to
get fixed first. There's no issue with the conversion for the D language
demangler, so convert it.

I have a more aggressive refactoring of the entire D language demangler
to use std::string_view more extensively, but the interface with
llvm::nonMicrosoftDemangle is the more interesting one.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D151003
2023-06-02 15:19:41 -07:00
Matt Arsenault
2ca21e8775 InstSimplify: Remove null parent checks
The feature to operate on incomplete IR was barely used
an poorly tested.
2023-06-02 18:14:28 -04:00
Matt Arsenault
1536e299e6 InstSimplify: Require instruction be parented
Unlike every other analysis and transform, simplifyInstruction
permitted operating on instructions which are not inserted
into a function. This created an edge case no other code needs
to really worry about, and limited transforms in cases that
can make use of the context function. Only the inliner and a handful
of other utilities were making use of this, so just fix up these
edge cases. Results in some IR ordering differences since
cloned blocks are inserted eagerly now. Plus some additional
simplifications trigger (e.g. some add 0s now folded out that
previously didn't).
2023-06-02 18:14:28 -04:00
Nick Desaulniers
12d967c95f [Damangle] convert rustDemangle to use std::string_view
I was doing this API conversion to use std::string_view top-down in
D149104, but this exposed issues in individual demanglers that needed to
get fixed first. There's no issue with the conversion for the Rust
demangler, so convert it first.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D149784
2023-06-02 15:08:14 -07:00
Nick Desaulniers
61e1c3d80d [Demangle] convert itaniumDemangle and nonMicrosoftDemangle to use std::string_view
D149104 converted llvm::demangle to use std::string_view. Enabling
"expensive checks" (via -DLLVM_ENABLE_EXPENSIVE_CHECKS=ON) causes
lld/test/wasm/why-extract.s to fail. The reason for this is obscure:

Reason #10007 why std::string_view is dangerous:
Consider the following pattern:

  std::string_view s = ...;
  const char *c = s.data();
  std::strlen(c);

Is c a NUL-terminated C style string? It depends; but if it's not then
it's not safe to call std::strlen on the std::string_view::data().
std::string_view::length() should be used instead.

Fixing this fixes the one lone test that caught this.

microsoftDemangle, rustDemangle, and dlangDemangle should get this same
treatment, too. I will do that next.

Reviewed By: MaskRay, efriedma

Differential Revision: https://reviews.llvm.org/D149675
2023-06-02 14:53:49 -07:00
Kun Wu
fa98bdbd95 [mlir][sparse][gpu] make computeType mandatory
Differential Revision: https://reviews.llvm.org/D152018
2023-06-02 21:47:44 +00:00
Slava Zakharin
1c8b7c5299 [flang][hlfir] Added allocatable/pointer support in hlfir::convertToValue.
The code is used, for example, when passing arguments to IO or intrinsic
calls as value. The allocatable/pointer boxes must be dereferenced,
and trivial values have to be loaded. Character and derived values
have to stay boxed.
I am not sure what to do for the array cases, and I have not seen
any test triggering it, so I leave it as a TODO.

Reviewed By: tblah, clementval

Differential Revision: https://reviews.llvm.org/D151925
2023-06-02 14:45:34 -07:00
Vitaly Buka
99dc68387b [NFC][lsan] Use hash table to track root regions
This avoid O(N) in __lsan_unregister_root_region.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D151784
2023-06-02 14:38:01 -07:00
Vitaly Buka
0375a2dc7d [NFC][sanitizer] Avoid O(N^2) algorithm
Usually root_regions size is small so unlikey
this change will provide a noticable difference.

However it's easy to make sure that even with
large number of root_regions it works reasonably
fast.

Differential Revision: https://reviews.llvm.org/D151781
2023-06-02 14:32:03 -07:00
Vitaly Buka
c42e555dc2 [NFC][sanitizer] Delegate ArrayRef constructors 2023-06-02 14:32:03 -07:00
Artem Belevich
0f49116e26 [CUDA] Update Kepler(sm_3*) support info.
sm_30 and sm_32 were removed in cuda-11.0
sm_35 and sm_37 were removed in cuda-12.0

Differential Revision: https://reviews.llvm.org/D152027
2023-06-02 14:16:13 -07:00