Commit Graph

487539 Commits

Author SHA1 Message Date
DianQK
a58dcc5e08 Reland "[SimplifyCFG] Improve the precision of PtrValueMayBeModified"
This relands commit f890f010f6.

The result value of `getelementptr inbounds (TY, null, not zero)` is a poison value.
We can think of it as undefined behavior.
2024-01-25 06:42:14 +08:00
DianQK
a0c1b5bdda Reland "[SimplifyCFG] Check if the return instruction causes undefined behavior"
This relands commit b6a0be8ce3.

Return undefined to a noundef return value is undefined.

Example:

```
define noundef i32 @test_ret_noundef(i1 %cond) {
entry:
  br i1 %cond, label %bb1, label %bb2
bb1:
  br label %bb2
bb2:
  %r = phi i32 [ undef, %entry ], [ 1, %bb1 ]
  ret i32 %r
}
```
2024-01-25 06:42:14 +08:00
Stanislav Mekhanoshin
6384b6239b [AMDGPU] Simplify VOP3PWMMA_Profile. NFC. (#79377) 2024-01-24 14:33:00 -08:00
Micah Weston
23faa81d3f [SHT_LLVM_BB_ADDR_MAP] Avoids side-effects in addition since order is unspecified. (#79168)
Turns out the problem with
https://github.com/llvm/llvm-project/issues/60013 is due to the fact
that order of operation is unspecified in C++:
https://en.cppreference.com/w/cpp/language/eval_order. A small example
of where this manifests with MSVC can be seen here
https://ooo.godbolt.org/z/bxqKeqzqn.

This patch does the following:
* Removes the addition operations where we sequence more than one
side-effect based expression.
* Removes test guards to now run on Windows
2024-01-24 17:26:48 -05:00
lntue
3a92b20cb0 [libc] Add backup definition for LONG_WIDTH in limits-macros.h. (#79375) 2024-01-24 17:04:11 -05:00
arthurqiu
ce21721d1d [MLIR] Fix tblgen properties printing to filter them out of discardable attrs dict (#79243)
This is to fix the bug reported in
https://discourse.llvm.org/t/whats-the-recommended-way-to-use-prop-dict/75921

When `prop-dict` is used in the assembly format, `attr-dict` should
print discardable attributes only.

Co-authored-by: Arthurq Qiu <arthurq@nvidia.com>
2024-01-24 13:53:52 -08:00
Alexey Bataev
36e4a7ecca [SLP]Fix PR79321: SLPVectorizer's PHICompare doesn't provide a strict
weak ordering.
Try to make PHICompare to meat strict weak ordering criteria.
2024-01-24 13:46:05 -08:00
erichkeane
62a384ca66 [OpenACC} Implement 'async' parsing.
async just takes an integral value, but it has a little bit of special
rules in sema, so it is implemented slightly differently than int-expr.

This patch implements async parsing.
2024-01-24 13:43:32 -08:00
lntue
72ce629415 [libc] Add C23 limits.h header. (#78887) 2024-01-24 16:08:56 -05:00
Jay Foad
fe9f3903f2 [AMDGPU] Update isLegalAddressingMode for GFX12 SMEM loads (#78728) 2024-01-24 21:04:43 +00:00
Michael Maitland
3967510032 [RISCV][GISel] First mask argument placed in v0 according to RISCV Ve… (#79343)
…ctor CC.
2024-01-24 16:03:38 -05:00
Alexander Kornienko
6e4930c675 Revert "[SemaCXX] Implement CWG2137 (list-initialization from objects of the same type) (#77768)"
This reverts commit 924701311a. Causes compilation
errors on valid code, see
https://github.com/llvm/llvm-project/pull/77768#issuecomment-1908062472.
2024-01-24 21:42:38 +01:00
Tom Stellard
f6ca6ed528 Revert "compiler-rt: Fix FLOAT16 feature detection"
This reverts commit aaa93ce732.

This commit was not properly reviewed.
2024-01-24 12:38:09 -08:00
Fangrui Song
48570a6feb [Driver,test] Add --target= to unsupported-option-gpu.c 2024-01-24 12:32:10 -08:00
Schrodinger ZHU Yifan
22c22d6182 [libc][NFC] mark hashtable as resizable (#79354)
It is not fix-sized anymore.
2024-01-24 15:18:40 -05:00
Schrodinger ZHU Yifan
4a9b5aa116 [libc][NFC] remove TODO about AppProperties (#79356)
```
AppProperties app;
```
is marked as a weak symbol in header now. One can just use `&app !=
nullptr` to check if `app` is defined. There is no need to define it for
overlay mode.
2024-01-24 15:18:11 -05:00
Peiming Liu
260e45cff0 [mlir][sparse] fix stack UAF (#79353) 2024-01-24 12:12:55 -08:00
erichkeane
e3ee376230 Fix comparison of Structural Values
Fixes a regression from #78041 as reported in the review.  The original
patch failed to compare the canonical type, which this adds.  A slightly
modified test of the original report is added.
2024-01-24 12:09:08 -08:00
Craig Topper
e6f576b0c3 [Docs] Mention RISC-V in the introductory paragraph in ShadowCallStack.rst. (#79241)
RISC-V is mentioned elsewhere in the document it seems like it should be
mentioned in the introduction.
2024-01-24 12:06:58 -08:00
Eric
04ce0baf01 Unconditionally lower std::string's alignment requirement from 16 to 8. (#68925)
Unconditionally change std::string's alignment to 8.

This change saves memory by providing the allocator more freedom to
allocate the most
efficient size class by dropping the alignment requirements for
std::string's
pointer from 16 to 8. This changes the output of std::string::max_size,
which makes it ABI breaking.

That said, the discussion concluded that we don't care about this ABI
break. and would like this change enabled universally.

The ABI break isn't one of layout or "class size", but rather the value
of "max_size()" changes, which in turn changes whether `std::bad_alloc`
or `std::length_error` is thrown for large allocations.

This change is the child of PR #68807, which enabled the change behind
an ABI flag.
2024-01-24 13:52:46 -06:00
Joseph Huber
a551703cb5 [Offload] Fix the offloading wrapper when merged multiple times. (#79231)
Summary:
The offloading wrapper is a object file that contains code necessary to
register offloading entries for the given runtime. Currently, we
expected only one of these to be present when we make the final
executable. However, in the case of redistributable linking with `-r` we
can end up with multiple of these being generated before finally
creating the executable.

This patch simply changes the defintiions of these globals to be
mergable. This allows multiples of these to participate in a single link
job. For ELF, we just make the dummy variable internal and used so it
sets up the section as expected. For COFF we make the entries weak_odr
so they merge to a single symbol
2024-01-24 13:50:35 -06:00
Joseph Huber
0f8b52955c [LinkerWrapper] Do not link device code under a relocatable link (#79314)
Summary:
A relocatable link through `clang -r` can go through the
clang-linker-wrapper if offloading is enabled. This will have the effect
of linking the device code and creating the wrapper module. It will then
be merged into the final file. This is useful behavior on its own, but
is likely not what is expected for a `-r` job.

This patch makes the linker wrapper ignore the device code when doing a
reloctable link. This has the effect of the linker merging the
`.llvm.offloading` sections in the output object. These will then be
parsed as normal when the executable is finally created.

Even though this doesn't actually perform a reloctable link on the
device code itself, it has a similar effect of combining multiple files
into a single one.
2024-01-24 13:50:19 -06:00
Peiming Liu
298412b578 [mlir][sparse] setup SparseIterator to help generating code to traverse a sparse tensor level. (#78345) 2024-01-24 11:33:06 -08:00
Alexey Bataev
48bbd76587 [SLP]Fix PR79229: Check that extractelement is used only in a single node
before erasing.

Before trying to erase the extractelement instruction, not enough to
check for single use, need to check that it is not used in several nodes
because of the preliminary nodes reordering.
2024-01-24 11:22:22 -08:00
Andy Kaylor
bb65f5a5d9 Move raw_string_ostream back to raw_ostream.cpp (#79224)
The implementation of raw_string_ostream::write_impl() was moved to
raw_socket_stream.cpp when the raw_socket_ostream support was separated.
This patch moves it back to facilitate disabling socket support in
downstream projects.
2024-01-24 11:20:23 -08:00
Jonas Paulsson
84dcf3d35b [SystemZ] Require D12 for i128 accesses in isLegalAddressingMode() (#79221)
Machines with vector support handle i128 in vector registers and
therefore only have the small displacement available for memory
accesses. Update isLegalAddressingMode() to reflect this.
2024-01-24 20:16:05 +01:00
Schrodinger ZHU Yifan
7b11c08c66 [libc] remove unstable mincore test for invalid vec (#79348)
The faults on invalid vec range in mincore seems to be handled
differently by the OS (it is an erroneous edge case after all). Remove
the tests for now.
2024-01-24 14:11:27 -05:00
Reid Kleckner
4b4763ffeb [lld][WebAssembly] Fix test on Windows, use llvm-ar instead of ar 2024-01-24 11:11:04 -08:00
Nico Weber
d8a34c25bc [opt] Remove trailing space that accidentally got added 2024-01-24 14:09:54 -05:00
Wei Wang
2e52e13c1e [clang] Make sure the same UsingType is searched and inserted (#79182)
When creating a new UsingType, the underlying type may change if it is a
declaration. This creates an inconsistency between the type searched and
type created. Update member and non-member Profile functions so that
they return the same ID.
2024-01-24 11:06:20 -08:00
Mircea Trofin
123c83ddc7 [mlgo] bazel rules for mlgo-utils (#79217)
Akin the `py_binary` rules for `lit`, these are scoped to binaries,
rather than exposing the library - binary split. The latter is available
to the package (pip package) users.

Tested:

```
cd utils/bazel
bazel build @llvm-project//llvm:extract_ir
bazel-bin/external/llvm-project/llvm/extract_ir --help
```
...and observed expected output (rather than import not found errors)

(Same for the other 2 targets).
2024-01-24 11:04:06 -08:00
Nico Weber
609695b23e [gn] port 32f7922646 (LLVMOptDriver) 2024-01-24 14:03:33 -05:00
Nico Weber
3135984024 Reland "[CMake/Bazel] Support usage of opt driver as a library (#79205)"
This reverts commit be08be5d5d.
The build error was due to a different change, apologies!
2024-01-24 13:57:07 -05:00
Michael Maitland
d2d42dcfde [CodeGen][MISched] Rename instance of Cycle -> ReleaseAtCycle
b1ae461a53 renamed Cycle ->
ReleaseAtCycle.

7e09239e24 was committed without rebasing
but used the old Cycle syntax.

This caused a build failure when
7e09239e24 was squash-and-merged. This
patch fixes this problem.
2024-01-24 10:54:14 -08:00
Nico Weber
be08be5d5d Revert "[CMake/Bazel] Support usage of opt driver as a library (#79205)"
This reverts commit 32f7922646.

Doesn't build, see
https://github.com/llvm/llvm-project/pull/79205#issuecomment-1908730527
2024-01-24 13:52:10 -05:00
Schrodinger ZHU Yifan
048041f197 [libc] reland mincore (#79309) 2024-01-24 13:47:56 -05:00
Michael Maitland
7e09239e24 [CodeGen][MISched] Handle empty sized resource usage. (#75951)
TargetSchedule.td explicitly allows the usage of a ProcResource for zero
cycles, in order to represent that the ProcResource must be available
but is not consumed by the instruction. On the other hand,
ResourceSegments explicitly does not allow for a zero sized interval. In
order to remedy this, this patch handles the special case of when there
is an empty interval usage of a resource by not adding an empty
interval.

We ran into this issue downstream, but it makes sense to have
this upstream since it is explicitly allowed by TargetSchedule.td.
2024-01-24 13:40:23 -05:00
William Moses
32f7922646 [CMake/Bazel] Support usage of opt driver as a library (#79205)
In Bazel, Clang current separates the clang executable into a
clang-driver library, and the actual clang executable. This allows
downstream users to make their own variations of clang, without having
to redo/maintain separate build pipelines.

This adds the same for opt for both CMake and Bazel.
2024-01-24 13:39:27 -05:00
lntue
c1cb0b80f0 [libc][NFC] Fix -DSHOW_INTERMEDIATE_OBJECTS=DEPS to work properly for entry points and unit tests. (#79254) 2024-01-24 13:34:13 -05:00
Nikolas Klauser
e099e7b278 [Clang] Fix the signature of __builtin___stpncpy_chk 2024-01-24 19:25:01 +01:00
Fangrui Song
ed7cee90f7 [Driver] Test ignored target-specific options for AMDGPU/NVPTX (#79222)
Fix missing test coverage after #70740 #70760

When compiling for CUDA/HIP, the driver creates a cc1 job to compile for
amdgcn/nvptx triple using most options.
Certain target-specific options should be ignored, not lead to an error
(`err_drv_unsupported_opt_for_target`).
2024-01-24 10:06:27 -08:00
Jeremy Morse
604a6c409e [BPI] Transfer value-handles when assign/move constructing BPI (#77774)
Background: BPI stores a collection of edge branch-probabilities, and
also a set of Callback value-handles for the blocks in the
edge-collection. When a block is deleted, BPI's eraseBlock method is
called to clear the edge-collection of references to that block, to
avoid dangling pointers.

However, when move-constructing or assigning a BPI object, the
edge-collection gets moved, but the value-handles are discarded. This
can lead to to stale entries in the edge-collection when blocks are
deleted without the callback -- not normally a problem, but if a new
block is allocated with the same address as an old block, spurious
branch probabilities will be recorded about it. The fix is to transfer
the handles from the source BPI object.

This was exposed by an unrelated debug-info change, it probably just
shifted around allocation orders to expose this. Detected as
nondeterminism and reduced by Zequan Wu:


f1b0a54451 (commitcomment-136737090)

(No test because IMHO testing for a behaviour that varies with memory
allocators is likely futile; I can add the reproducer with a CHECK for
the relevant branch weights if it's desired though)
2024-01-24 17:45:43 +00:00
Nico Weber
4a9a1d83be [gn build] port 4a58284559 (tablegen'd clang builtins) 2024-01-24 12:43:35 -05:00
Vojislav Tomasevic
2a77d92e2e [clang] Incorrect IR involving the use of bcopy (#79298)
This patch addresses the issue regarding the call of bcopy function in a
conditional expression.
It is analogous to the already accepted patch which deals with the same
problem, just regarding the bzero function [0].

Here is the testcase which illustrates the issue:

```
void bcopy(const void *, void *, unsigned long);
void foo(void);

void test_bcopy() {
  char dst[20];
  char src[20];
  int _sz = 20, len = 20;
  return (_sz
          ? ((_sz >= len)
             ? bcopy(src, dst, len)
             : foo())
          : bcopy(src, dst, len));
}
```

When processing it with clang, following issue occurs:

Instruction does not dominate all uses!
%arraydecay2 = getelementptr inbounds [20 x i8], ptr %dst, i64 0, i64 0,
!dbg !38
%cond = phi ptr [ %arraydecay2, %cond.end ], [ %arraydecay5,
%cond.false3 ], !dbg !33
fatal error: error in backend: Broken module found, compilation aborted!

This happens because an incorrect phi node is created. It is created
because bcopy function call is lowered to the call of llvm.memmove
intrinsic and function memmove returns void *. Since llvm.memmove is
called in two places in the same return statement, clang creates a phi
node in the final basic block for the return value and that phi node is
incorrect. However, bcopy function should return void in the first
place, so this phi node is unnecessary. This is what this patch
addresses. An appropriate test is also added and no existing tests fail
when applying this patch.

Also, this crash only happens when LLVM is configured with
-DLLVM_ENABLE_ASSERTIONS=On option.

[0] https://reviews.llvm.org/D39746
2024-01-24 09:39:36 -08:00
Alexey Bataev
ca654acc16 [SLP]Fix PR79321: SLPVectorizer's PHICompare doesn't provide a strict
weak ordering.

Compared NumUses to meet the reaquirements of the strict weak ordering.
2024-01-24 09:36:25 -08:00
Alex MacLean
3b8539c9dc [NVPTX] use incomplete aggregate initializers (#79062)
The PTX ISA specifies that initializers may be incomplete ([5.4.4.
Initializers](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#initializers))
> As in C, array initializers may be incomplete, i.e., the number of
initializer elements may be less than the extent of the corresponding
array dimension, with remaining array locations initialized to the
default value for the specified array type.

Emitting initializers in this form is preferable because it reduces the
size of the PTX, in some cases significantly, and can improve compile
time of ptxas as a result.
2024-01-24 09:24:28 -08:00
Kazu Hirata
1605bf5815 [ConstraintElimination] Use std::move in the constructor (NFC) (#79259)
Moving the contents of Coefficients saves 0.43% of heap allocations
during the compilation of a large preprocessed file, namely
X86ISelLowering.cpp, for the X86 target.
2024-01-24 09:18:57 -08:00
Philip Reames
e9311f9c5a [RISCV] Separate single source and dual source lowering code [nfc]
The two single source cases aren't effected by the swap or select matching
as those are dual operand specific.  Similarly, a two source shuffle can't
be a rotate.

We can extend this idea for some of the shuffle types above, but some of
them are validly either single or dual source.  We don't want to loose that
and the code complexity of versioning early and having to repeat some shuffle
kinds doesn't (currently) seem worth it.
2024-01-24 09:16:50 -08:00
Jan Svoboda
b801b607e3 [clangd] Make sure ninja can clean "ClangdXPC.framework" (#75669)
After building the ClangdXPC target, `ninja clean` fails with the
following error:

```
ninja: error: remove(lib/ClangdXPC.framework): Directory not empty
ninja: error: remove(<build>/lib/ClangdXPC.framework): Directory not empty
```

I did not find better way to make this work. I guess we could list all
generated files (and directories) in `OUTPUT` of the custom command, but
that seems fairly tedious/fragile.
2024-01-24 09:12:00 -08:00
ostannard
56602a48c7 [TableGen] Include source location in JSON dump (#79028)
This adds a '!loc' field to each record containing the file name and
line number of the record declaration.
2024-01-24 17:07:20 +00:00