Commit Graph

411001 Commits

Author SHA1 Message Date
Mehdi Amini dc9f18da86 Partially revert cac7aabbd82: some APIs don't have in-tree users and some build breaks weren't caught 2022-01-14 06:16:38 +00:00
Stella Laurenzo b93eded7b9 [bazel] Separate capi_deps from deps in mlir_c_api_cc_library.
This is important because *Objects targets need to only depend on other *Objects targets, not on the unsuffixed CAPI rules. Depending on how it is linked in the current setup, it can cause duplicate symbols.

Differential Revision: https://reviews.llvm.org/D117176
2022-01-14 06:08:01 +00:00
jacquesguan 88c0e0806b [RISCV] Improve i64 splat vector lowering in RV32.
We could use vmv.v.i/vmv.v.x whose eew is 32 to lower the i64 splat vector if the i64 constant scalar could be splitted into two same i32 scalar.

Differential Revision: https://reviews.llvm.org/D117079
2022-01-14 14:06:01 +08:00
jacquesguan 3e241353e1 [RISCV] Add more i64 splat vector test.
Precommit test for D117079.

Differential Revision: https://reviews.llvm.org/D117081
2022-01-14 14:04:01 +08:00
Craig Topper 7b7210291a [RISCV] Remove unused check prefixes. NFC 2022-01-13 22:02:16 -08:00
Vitaly Buka 71a4fde397 [NFC][msan] Init few vars later 2022-01-13 22:00:37 -08:00
Craig Topper d72ebafda0 [RISCV] Add basic Zfh inline assembly tests. NFC
The abi name test shows incorrect fcvt.d.h, fcvt.h.d, fcvt.f.h,
and fcvt.h.f instructions around the inline assembly.
2022-01-13 21:52:46 -08:00
Craig Topper 3174525516 [RISCV] Add inline asm f32 test cases with D extension. NFC
Using named registers as input or output constraints creates fcvt.d.s
and fcvt.s.d instructions around the inline assembly.

This makes the data unusable by the inline assembly and corrupts
the results of the inline assembly.
2022-01-13 21:52:46 -08:00
Nenad Mikša 0c391133c9 Fix registers for Windows on ARM64
Reviewed By: #sanitizers, vitalybuka

Differential Revision: https://reviews.llvm.org/D116376
2022-01-13 21:39:01 -08:00
Vitaly Buka 36138d8252 [NFC][msan] Declare some getShadow vars later 2022-01-13 21:36:37 -08:00
John Ericson e68215c0c1 [Polly][CMake] Make PollyConfig.cmake relocatable like other projects'
This builds on D116521 to add this functionality to Polly without more copy-pasted code.

Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D116555
2022-01-14 05:27:21 +00:00
Maurice Heumann 072e2a7c67 [MS] Implement on-demand TLS initialization for Microsoft CXX ABI
TLS initializers, for example constructors of thread-local variables, don't necessarily get called. If a thread was created before a module is loaded, the module's TLS initializers are not executed for this particular thread.

This is why Microsoft added support for dynamic TLS initialization. Before every use of thread-local variables, a check is added that runs the module's TLS initializers on-demand.

To do this, the method `__dyn_tls_on_demand_init` gets called. Internally, it simply calls `__dyn_tls_init`.

No additional TLS initializer that sets the guard needs to be emitted, as the guard always gets set by `__dyn_tls_init`.
The guard is also checked again within `__dyn_tls_init`. This makes our check redundant, however, as Microsoft's compiler also emits this check, the behaviour is adopted here.

Reviewed By: majnemer

Differential Revision: https://reviews.llvm.org/D115456
2022-01-13 21:23:23 -08:00
River Riddle 11067d711b [mlir] Optimize OperationName construction and usage
When constructing an OperationName, the overwhelming majority of
cases are from registered operations. This revision adds a non-locked
lookup into the currently registered operations, which prevents locking
in the common case. This revision also optimizes several uses of
RegisteredOperationName that expect the operation to be registered,
e.g. such as in OpBuilder.

These changes provides a reasonable speedup (5-10%) in some
compilations, especially on platforms where locking is expensive.

Differential Revision: https://reviews.llvm.org/D117187
2022-01-13 21:14:36 -08:00
James Y Knight a97e20a3a8 Revert "GlobalISel: Add G_ASSERT_ALIGN hint instruction"
This commit sometimes causes a crash when compiling a vtable thunk. E.g.:

clang '--target=aarch64-grtev4-linux-gnu' -xc++ - -c -o /dev/null <<EOF
struct a {
  virtual int f();
};
struct c {
  virtual int &g() const;
};
struct d : a, c {
  int &g() const;
};
int &d::g() const {}
EOF

Some follow-up commits have been reverted as well:
Revert "IR: Make getRetAlign check callee function attributes"
Revert "Fix MSVC "32-bit shift implicitly converted to 64 bits" warning. NFC."
Revert "Fix MSVC "32-bit shift implicitly converted to 64 bits" warning. NFC."

This reverts commit 4f414af6a7.
This reverts commit a5507d2e25.
This reverts commit 3d2d208f6a.
This reverts commit 07ddfa95e3.
2022-01-14 04:50:07 +00:00
Konstantin Varlamov b6d87773fe [libc++] LWG3171: implement operator<< for filesystem::directory_entry.
Differential Revision: https://reviews.llvm.org/D116642
2022-01-13 20:44:18 -08:00
wren romano cf35825388 [mlir][sparse] Moving the sort from factory method to the constructor.
This guarantees the preconditions of fromCOO; whereas prior to this, one could call the constructor directly with an unsorted tensor, which would cause fromCOO to misbehave.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D117167
2022-01-13 19:44:51 -08:00
Peixin-Qiao 2291413554 [NFC] Apply the fix for different signedness warning in OpenMPIRBuilderTest.cpp
Differential Revision: https://reviews.llvm.org/D116300
2022-01-14 10:49:21 +08:00
Tue Ly c386d6eb2d [libc] Fix precision constants for long double in MPFRUtils.cpp. 2022-01-13 21:33:05 -05:00
Mehdi Amini 58ec17cb4e Apply clang-tidy fixes for readability-simplify-boolean-expr to MLIR (NFC) 2022-01-14 02:26:28 +00:00
Mehdi Amini cac7aabbd8 Apply clang-tidy fixes for readability-identifier-naming to MLIR (NFC) 2022-01-14 02:26:28 +00:00
Mehdi Amini d1b63c603a Apply clang-tidy fixes for readability-avoid-const-params-in-decls to MLIR (NFC) 2022-01-14 02:26:28 +00:00
Mehdi Amini e8d073951b Apply clang-tidy fixes for performance-unnecessary-value-param to MLIR (NFC) 2022-01-14 02:26:27 +00:00
Mehdi Amini 8e5f112c05 Apply clang-tidy fixes for performance-move-const-arg to MLIR (NFC) 2022-01-14 02:26:27 +00:00
Mehdi Amini a68c8d3009 Apply clang-tidy fixes for performance-for-range-copy to MLIR (NFC) 2022-01-14 02:26:27 +00:00
Mehdi Amini 2071e7204d Apply clang-tidy fixes for modernize-use-using to MLIR (NFC) 2022-01-14 02:26:27 +00:00
Mehdi Amini bd87241c44 Apply clang-tidy fixes for modernize-use-override to MLIR (NFC) 2022-01-14 02:26:27 +00:00
Mehdi Amini 9940dcfa4a Apply clang-tidy fixes for modernize-use-equals-default to MLIR (NFC) 2022-01-14 02:26:27 +00:00
Mehdi Amini 59d8740f2f Apply clang-tidy fixes for modernize-use-default-member-init to MLIR (NFC) 2022-01-14 02:26:26 +00:00
Mehdi Amini d19f89b5d2 Apply clang-tidy fixes for llvm-qualified-auto to MLIR (NFC) 2022-01-14 02:26:26 +00:00
Chuanqi Xu 4f8916cfdd [C++20] [Modules] Exit early if export decl is not valid
This patch fixes a crash due to following simple program:
> export struct Unit {
>    bool operator<(const Unit&);
> };

It would crash since the compiler would set the module ownership for
Unit. And the declaration with a module ownership is assumed to own a
module. But here isn't one. So here is the crash.

This patch fixes this by exiting early if it finds the export decl is
already invalid.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D117093
2022-01-14 10:21:42 +08:00
LLVM GN Syncbot b8367518e7 [gn build] Port d3729bb384 2022-01-14 01:58:03 +00:00
Nikolas Klauser d3729bb384 [libc++][ranges] Add ranges::in_in_result
Add `std::ranges::in_in_result`

Reviewed By: Quuxplusone, Mordante, #libc

Spies: ldionne, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D116278
2022-01-14 02:56:33 +01:00
Peixin-Qiao f52805539b [OMPIRBuilder] Fix store inst alignment for ordered depend directive
OpenMP runtime requires depend vec with i64 type and the alignment of
store instruction should be set as 8.

Reviewed By: kiranchandramohan, shraiysh

Differential Revision: https://reviews.llvm.org/D116300
2022-01-14 09:47:11 +08:00
Bryce Wilson 83338d5032
[MemoryBuiltins] [NFC] Add missing section comments 2022-01-13 17:43:43 -08:00
Casey Carter cb71d77cc8 [libcxx][test] Add missing includes and suppress warnings
... from testing with MSVC's STL. Mostly truncation warnings and variables that are only used in `LIBCPP_ASSERT`.

Differential Revision: https://reviews.llvm.org/D116878
2022-01-13 17:34:04 -08:00
Peter Klausler d393ce3b3e [flang] Support extension intrinsic function variations on ABS
Accept the legacy specific intrinsic names BABS, IIABS, JIABS,
KIABS, and ZABS as well.

Differential Revision: https://reviews.llvm.org/D117155
2022-01-13 17:10:44 -08:00
Dave Lee 1441ffe6a6 [lldb] Use __lldb_init_module instead of "if lldb.debugger" idiom
Update examples and docs to demonstrate using `__lldb_init_module` instead of
the idiom that checks for `lldb.debugger` at the top-level.

```
if __name__ == '__main__':
    ...
elif lldb.debugger:
    ...
```

Is replaced with:

```
if __name__ == '__main__':
    ...

def __lldb_init_module(debugger, internal_dict):
    ...
```

This change is for two reasons. First, it's generally encouraged not to only
use the convenience singletons (`lldb.{debugger,process,target,etc}`)
interactively from the `script` command. Second, there's a bug where
registering a python class as a command (using `command script add -c ...`),
result in the command not being runnable. Note that registering function-backed
commands does not have this bug.

Differential Revision: https://reviews.llvm.org/D117237
2022-01-13 16:37:49 -08:00
Fangrui Song bc56097817 [GlobalValue] Make dso_local function work with comdat nodeduplicate
This fixes -fno-semantic-interposition -fsanitize-coverage incompatibility.

-fPIC -fno-semantic-interposition may add dso_local to an external linkage
function. -fsanitize-coverage instrumentation does not clear dso_local when
adding comdat nodeduplicate. This causes a compatibility issue: the function
symbol may be referenced by a PC-relative relocation without using the local
alias. In -shared mode, ld will report a relocation error.

The fix is to either clear dso_local when adding comdat nodeduplicate, or
supporting comdat nodeduplicate. The latter is more appropriate, because a
comdat nodeduplicate is like not using comdat.

Note: The comdat condition was originally added by D77429 to not use local alias
for a hidden external linkage function in a deduplicate comdat. The condition
has been unused since the code was refactored to only use local alias for
default visibility symbols.
Note: `canBenefitFromLocalAlias` is used by clang/lib/CodeGen/CodeGenModule.cpp
and we don't want to add dso_local to default visibility external linkage comdat any
(clang/test/CodeGenCUDA/usual-deallocators.cu).

Differential Revision: https://reviews.llvm.org/D117190
2022-01-13 16:37:14 -08:00
Peter Klausler 0f500d3dae [flang] Downgrade benign error message to a warning
It's not conforming to specify the SAVE attribute more than
once for a variable, but it also doesn't hurt anything and
isn't fatal in other Fortran compilers.  Downgrade the
message to a warning for better portability.

Differential Revision: https://reviews.llvm.org/D117153
2022-01-13 16:27:40 -08:00
James Y Knight 073c27b5e5 Revert "[LV] Inline CreateSplatIV call for scalar VFs (NFC)."
Causes a crash with the following (creduce'd) test-case:

clang -O3 '--target=aarch64-grtev4-linux-gnu' -xc - -c -o /dev/null <<EOF
int *e;
int f;
int g() {
  int h;
  int *j = 0;
  while (&f - j > 0) {
    int k;
    k = j;
    if (e == j && *e)
      k = 5;
    h = k;
    j++;
  }
  return h;
}
EOF

This reverts commit 7ce48be0fd.
2022-01-14 00:00:02 +00:00
Philip Reames ee02cf0797 [MemoryBuiltins] Demote isCallocLikeFn and isAlignedAllocLikeFn to local helpers after removal of last external use [NFC] 2022-01-13 15:51:17 -08:00
Fangrui Song e289561205 [Driver][Fuchsia] -r: imply -nostdlib like GCC
Similar to D116843.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D116844
2022-01-13 15:49:19 -08:00
Fangrui Song 1661c8cfcd [CMake] Don't use -fno-semantic-interposition with Clang<=13
Clang 13 has a -fsanitize-coverage -fno-semantic-interposition bug (D117190)
which may lead to
`relocation R_X86_64_PC32 cannot be used against symbol` linker error
in -DLLVM_USE_SANITIZE_COVERAGE=ON build when a shared object is built (e.g.
-DLLVM_BUILD_LLVM_DYLIB=on).

For simplicity, just disallow Clang 13 entirely.

Note: GCC -fPIC performance benefits from -fno-semantic-interposition
dramatically. Clang benefits little. Using this option is more for a dogfood
purpose to test correctness of this option, because in the wild some important
packages like CPython uses this option.

Differential Revision: https://reviews.llvm.org/D117183
2022-01-13 15:38:02 -08:00
Philip Reames 5d5d4d94f0 [Attributor] Generalize heap to stack to any allocator with relevant properties
This completes removal of the isXLike queries, and depends on a whole series of earlier patches which have already landed.

Differential Revision: https://reviews.llvm.org/D117242
2022-01-13 15:33:24 -08:00
Philip Reames cf66f01ec1 [Attributor] Share code for abstract interpretation of allocation sizes with getObjectSize [NFC-ish]
The basic idea is that we can parameterize the getObjectSize implementation with a callback which lets us replace the operand before analysis if desired. This is what Attributor is doing during it's abstract interpretation, and allows us to have one copy of the code.

Note this is not NFC for two reasons:
* The existing attributor code is wrong. (Well, this is under-specified to be honest, but at least inconsistent.) The intermediate math needs to be done in the index type of the pointer space. Imagine e.g. i64 arguments in a 32 bit address space.
* I did not preserve the behavior in getAPInt where we return 0 for a partially analyzed value. This looks simply wrong in the original code, and nothing test wise contradicts that.

Differential Revision: https://reviews.llvm.org/D117241
2022-01-13 15:33:24 -08:00
Jonas Devlieghere 049ae93097 [lldb] Fix that the embedded Python REPL crashes if it receives SIGINT
When LLDB receives a SIGINT while running the embedded Python REPL it
currently just crashes in ScriptInterpreterPythonImpl::Interrupt with an
error such as the one below:

  Fatal Python error: PyThreadState_Get: the function must be called
  with the GIL held, but the GIL is released (the current Python thread
  state is NULL)

The faulty code that causes this error is this part of
ScriptInterpreterPythonImpl::Interrupt:

  PyThreadState *state = PyThreadState_GET();
  if (!state)
    state = GetThreadState();
  if (state) {
    long tid = state->thread_id;
    PyThreadState_Swap(state);
    int num_threads = PyThreadState_SetAsyncExc(tid, PyExc_KeyboardInterrupt);

The obvious fix I tried is to just acquire the GIL before this code is
running which fixes the crash but the KeyboardInterrupt we want to raise
immediately is actually just queued and would only be raised once the
next line of input has been parsed (which e.g. won't interrupt Python
code that is currently waiting on a timer or IO from what I can see).
Also none of the functions we call here is marked as safe to be called
from a signal handler from what I can see, so we might still end up
crashing here with some bad timing.

Python 3.2 introduced PyErr_SetInterrupt to solve this and the function
takes care of all the details and avoids doing anything that isn't safe
to do inside a signal handler. The only thing we need to do is to
manually setup our own fake SIGINT handler that behaves the same way as
the standalone Python REPL signal handler (which raises a
KeyboardInterrupt).

From what I understand the old code used to work with Python 2 so I kept
the old code around until we officially drop support for Python 2.

There is a small gap here with Python 3.0->3.1 where we might still be
crashing, but those versions have reached their EOL more than a decade
ago so I think we don't need to bother about them.

Differential revision: https://reviews.llvm.org/D104886
2022-01-13 15:27:38 -08:00
Mehdi Amini ba37c3b152 Apply clang-tidy fixes for llvm-namespace-comment in ToolUtilities.h (NFC) 2022-01-13 23:25:49 +00:00
Mehdi Amini b0aea19813 Apply clang-tidy fixes for llvm-namespace-comment in ParallelLoopMapper.h (NFC) 2022-01-13 23:25:49 +00:00
Mehdi Amini 63edb563a1 Apply clang-tidy fixes for llvm-namespace-comment in GPUToNVVMPass.h (NFC) 2022-01-13 23:25:49 +00:00
Mehdi Amini e4f5d47296 Apply clang-tidy fixes for llvm-namespace-comment in MemoryPromotion.h (NFC) 2022-01-13 23:25:49 +00:00