56938 Commits

Author SHA1 Message Date
Adam Yang
3a1228a543
[SPIRV] Add GroupMemoryBarrierWithGroupSync intrinsic (#111888)
partially fixes #70103

### Changes
* Added int_spv_group_memory_barrier_with_group_sync intrinsic in
IntrinsicsSPIRV.td
* Added lowering for int_spv_group_memory_barrier_with_group_sync in
SPIRVInstructionSelector.cpp
* Added SPIRV backend test case

### Related PRs
* [[clang][HLSL] Add GroupMemoryBarrierWithGroupSync intrinsic
#111883](https://github.com/llvm/llvm-project/pull/111883)
* [[DXIL] Add GroupMemoryBarrierWithGroupSync intrinsic
#111884](https://github.com/llvm/llvm-project/pull/111884)
2024-10-29 12:40:01 -07:00
Ellis Hoag
9cc5a4bf66
Remove llvm::shouldOptForSize() from Utils.h (#112630)
Remove `llvm::shouldOptForSize()` from `Utils.h` since we can use
`llvm::shouldOptimizeForSize()` from `SizeOpts.h` instead.

Depends on https://github.com/llvm/llvm-project/pull/112626
2024-10-29 14:23:47 -05:00
Lang Hames
f22c9ddb36 [ORC] Single-symbol convenience method does not need to be virtual.
This convenience method just calls the general case which is already virtual.
2024-10-29 11:12:48 -07:00
Steven Wu
b510cdb895
[ADT] Add TrieRawHashMap (#69528)
Implement TrieRawHashMap can be used to store object with its associated
hash. User needs to supply a strong hashing function to guarantee the
uniqueness of the hash of the objects to be inserted. A hash collision
is not supported and will lead to error or failed to insert.

TrieRawHashMap is thread-safe and lock-free and can be used as
foundation data structure to implement a content addressible storage.
TrieRawHashMap owns the data stored in it and is designed to be:
* Fast to lookup.
* Fast to "insert" if the data has already been inserted.
* Can be used without lock and doesn't require any knowledge of the
participating threads or extra coordination between threads.

It is not currently designed to be used to insert unique new data with
high contention, due to the limitation on the memory allocator.
2024-10-29 10:29:39 -07:00
Adam Yang
9a5b3a1bbc
[DXIL] Add GroupMemoryBarrierWithGroupSync intrinsic (#111884)
fixes #112974
partially fixes #70103

### Changes
- Added new tablegen based way of lowering dx intrinsics to DXIL ops.
- Added int_dx_group_memory_barrier_with_group_sync intrinsic in
IntrinsicsDirectX.td
- Added expansion for int_dx_group_memory_barrier_with_group_sync in
DXILIntrinsicExpansion.cpp`
- Added DXIL backend test case

### Related PRs
* [[clang][HLSL] Add GroupMemoryBarrierWithGroupSync intrinsic
#111883](https://github.com/llvm/llvm-project/pull/111883)
* [[SPIRV] Add GroupMemoryBarrierWithGroupSync intrinsic
#111888](https://github.com/llvm/llvm-project/pull/111888)
2024-10-29 10:17:35 -07:00
Jorge Gorbe Moya
4df71ab78e
[SandboxIR] Add callbacks for instruction insert/remove/move ops (#112965) 2024-10-29 09:25:51 -07:00
Hari Limaye
e19a5fc6d3
[FuncSpec] Improve accounting of specialization codesize growth (#113448)
Only accumulate the codesize increase of functions that are actually
specialized, rather than for every candidate specialization that we
analyse.

This fixes a subtle bug where prior analysis of candidate
specializations that were deemed unprofitable could prevent subsequent
profitable candidates from being recognised.
2024-10-29 11:53:12 +00:00
Hari Limaye
06664fdc76
[FuncSpec] Enable SpecializeLiteralConstant by default (#113442)
Enable specialization on literal constant arguments by default in
Function Specialization.

---------

Co-authored-by: Alexandros Lamprineas <alexandros.lamprineas@arm.com>
2024-10-29 11:41:25 +00:00
Benjamin Maxwell
c3260c65e8
[IR] Add llvm.sincos intrinsic (#109825)
This adds the `llvm.sincos` intrinsic, legalization, and lowering.

The `llvm.sincos` intrinsic takes a floating-point value and returns
both the sine and cosine (as a struct).

```
declare { float, float }          @llvm.sincos.f32(float  %Val)
declare { double, double }        @llvm.sincos.f64(double %Val)
declare { x86_fp80, x86_fp80 }    @llvm.sincos.f80(x86_fp80  %Val)
declare { fp128, fp128 }          @llvm.sincos.f128(fp128 %Val)
declare { ppc_fp128, ppc_fp128 }  @llvm.sincos.ppcf128(ppc_fp128  %Val)
declare { <4 x float>, <4 x float> } @llvm.sincos.v4f32(<4 x float>  %Val)
```

The lowering is built on top of the existing FSINCOS ISD node, with
additional type legalization to allow for f16, f128, and vector values.
2024-10-29 10:52:20 +00:00
Rohit Aggarwal
dfb60bb919
Adding more vector calls for -fveclib=AMDLIBM (#109662)
AMD has it's own implementation of vector calls.
New vector calls are introduced in the library for exp10, log10, sincos and finite asin/acos
Please refer [https://github.com/amd/aocl-libm-ose]

---------

Co-authored-by: Rohit Aggarwal <Rohit.Aggarwal@amd.com>
2024-10-29 10:09:55 +00:00
NAKAMURA Takumi
828467a54e Fix warnings introduced in #111434 [-Wnontrivial-memaccess] 2024-10-29 14:18:24 +09:00
c8ef
0c1c37bfbe
[TLI] Add support for the tgamma libcall. (#113791)
This patch adds the `tgamma` libcall.
2024-10-29 10:08:38 +08:00
Lang Hames
6128ff6630 [JITLink][MachO] Add convenience functions for default text/data sections.
The getMachODefaultTextSection and getMachODefaultRWDataSection functions
return the "__TEXT,__text" and "__DATA,__data" sections respectively, creating
empty sections if the default sections are not already present in the graph.
These functions can be used by utilities that want to add code or data to these
standard sections (e.g. these functions can be used to supply the section
argument to the createAnonymousPointerJumpStub and
createPointerJumpStubBlock functions in the various targets).
2024-10-28 18:05:40 -07:00
vporpo
a461869db3
[SandboxIR][Pass] Implement Analyses class (#113962)
The Analyses class provides a way to pass around commonly used Analyses
to SandboxIR passes throught `runOnFunction()` and `runOnRegion()`
functions.
2024-10-28 18:00:52 -07:00
Matt Arsenault
1ceccbb0dd
VirtRegRewriter: Add implicit register defs for live out undef lanes (#112679)
If an undef subregister def is live into another block, we need to
maintain a physreg def to track the liveness of those lanes. This
would manifest a verifier error after branch folding, when the cloned
tail block use no longer had a def.

We need to detect interference with other assigned intervals to avoid
clobbering the undef lanes defined in other intervals, since the undef
def didn't count as interference. This is pretty ugly and adds a new
dependency on LiveRegMatrix, keeping it live for one more pass. It also
adds a lot of implicit operand spam (we really should have a better
representation for this).

There is a missing verifier check for this situation. Added an xfailed
test that demonstrates this. We may also be able to revert the changes
in 47d3cbcf842a036c20c3f1c74255cdfc213f41c2.

It might be better to insert an IMPLICIT_DEF before the instruction
rather than using the implicit-def operand.

Fixes #98474
2024-10-28 17:33:53 -07:00
Chengjun
6233346895
[GenericCycle] Add a Cache for getExitBlocks in GenericCycle (#112290)
In `UniformityAnalysis`, we need to get the exit blocks of cycles in the
`DivergencePropagator` and currently, we have to do a search for the
exit blocks every time. In this change, we add a cache of the results in
the `GenericCycle` so that it can save the compile time. By testing, for
some large cases, this can save about 60% compile time in the
`UniformityAnalysis`.
2024-10-28 17:22:48 -07:00
Igor Kudrin
757d0e4764
Revert "[CFI][LowerTypeTests] Fix indirect call with alias" (#113978)
Reverts llvm/llvm-project#106185

This is breaking Sanitizer bots:
https://lab.llvm.org/buildbot/#/builders/66/builds/5449/steps/8/logs/stdio
2024-10-28 16:13:32 -07:00
vporpo
bf4b31ad54
[SandboxVec][Legality] Check Fastmath flags (#113967) 2024-10-28 15:32:20 -07:00
Krzysztof Parzyszek
09a4bcf1a5
[flang][OpenMP] Update handling of DEPEND clause (#113620)
Parse the locator list in OmpDependClause as an OmpObjectList (instead
of a list of Designators). When a common block appears in the locator
list, show an informative message.
Implement resolving symbols in DependSinkVec in a dedicated visitor
instead of having a visitor for OmpDependClause.
Resolve unresolved names common blocks in OmpObjectList.

Minor changes to the code organization:
- rename OmpDependenceType to OmpTaskDependenceType (to follow 5.2
terminology),
- rename Depend::WithLocators to Depend::DepType,
- add comments with more detailed spec references to parse-tree.h.

---------

Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com>
2024-10-28 16:06:22 -05:00
vporpo
5ea694816b
[SandboxVec][Legality] Check opcodes and types (#113741) 2024-10-28 14:05:58 -07:00
Igor Kudrin
67bcce2141
[CFI][LowerTypeTests] Fix indirect call with alias (#106185)
Motivation example:
```
> cat test.cpp
extern "C" [[gnu::weak]] void f() {}
void alias() __attribute__((alias("f")));
int main() { auto p = alias; p(); }
> clang test.cpp -fsanitize=cfi-icall -flto=thin -fuse-ld=lld
> ./a.out
[1]    1868 illegal hardware instruction  ./a.out
```

If the address of a function was only taken through its alias, the
function was not considered exported and therefore was not included
in the CFI jumptable. This resulted in `@llvm.type.test()` being lowered
to `false`, and consequently the indirect call to the function was
eventually optimized to `ubsantrap()`.
2024-10-28 13:14:42 -07:00
tf2spi
f23bdbbaff
Add DILabel functions for LLVM-C (#112840)
Addresses #112799
2024-10-28 10:59:53 -07:00
Boaz Brickner
80f38fbdcf
[clang] [NFC] Deduplicate the logic between StringMapEntry.first() and StringMapEntry.getKey() (#113735) 2024-10-28 09:10:07 -07:00
Haojian Wu
9090430d41
Add clang::lifetimebound annotation to StringRef constructors. (#113878)
Adding the lifetimebound annotation to the ArrayRef's array constructor
can enable us to detect the following use-after-free issues:

```
llvm::StringRef TestZoneName() {
   char test[] = "foo"; // oops, missing static
   return test; // use-after-free.
}
```

See #113533
2024-10-28 14:28:07 +01:00
Vassil Vassilev
f6b513a785 Revert "Add explicit symbol visibility macros to InstrProfData.inc (#110732)"
This reverts commit d7ca703eab7997814de425eaa4fd888563d78831 in llvm/llvm-project#110732
2024-10-28 08:57:57 +00:00
Thomas Fransham
14171b0b13
[Remarks] Fix missing include in HotnessThresholdParser for Expected (#113755)
The use of Expected<> requires llvm/Support/Error.h to be included.
2024-10-28 10:52:22 +02:00
Thomas Fransham
d7ca703eab
Add explicit symbol visibility macros to InstrProfData.inc (#110732)
Add explicit symbol visibility macros to InstrProfData.inc

Annotating these symbols will fix missing symbols for InstrProfTest when
using shared library builds on windows with explicit visibility macros
enabled.
Add a empty fallback definition for LLVM_ABI macro so the code works in
compiler-rt.

This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on
window.

```
llvm\lld-link : error : undefined symbol: public: void ValueProfData::deserializeTo(InstrProfRecord&,  InstrProfSymtab*)
>>> referenced by unittests\ProfileData\InstrProfTest.cpp:1372 void ValueProfileReadWriteTest_value_prof_data_read_write_Test::TestBody()
```
2024-10-28 10:47:40 +02:00
Jack Styles
86f76c3b17
[AArch64][Libunwind] Add Support for FEAT_PAuthLR DWARF Instruction (#112171)
As part of FEAT_PAuthLR, a new DWARF Frame Instruction was introduced,
`DW_CFA_AARCH64_negate_ra_state_with_pc`. This instructs Libunwind that
the PC has been used with the signing instruction. This change includes
three commits
- Libunwind support for the newly introduced DWARF Instruction
- CodeGen Support for the DWARF Instructions
- Reversing the changes made in #96377. Due to
`DW_CFA_AARCH64_negate_ra_state_with_pc`'s requirements to be placed
immediately after the signing instruction, this would mean the CFI
Instruction location was not consistent with the generated location when
not using FEAT_PAuthLR. The commit reverses the changes and makes the
location consistent across the different branch protection options.
While this does have a code size effect, this is a negligible one.

For the ABI information, see here:
853286c7ab/aadwarf64/aadwarf64.rst (id23)
2024-10-28 08:22:38 +00:00
Haojian Wu
e7f422d5c2
Add clang::lifetimebound annotation to ArrayRef constructors. (#113547)
This enables clang to detect more dangling issues.

```
ArrayRef<int> func() {
   constexpr int array[] = {...}; // oops, missing the static
   return array; // return a dangling reference, bomb.
}
```

See #113533.
2024-10-28 08:38:56 +01:00
Freddy Ye
5aa1275d03
[X86] Support SM4 EVEX version intrinsics/instructions. (#113402)
Ref.: https://cdrdv2.intel.com/v1/dl/getContent/671368
2024-10-28 10:46:16 +08:00
Alex MacLean
fb33af08e4
[NVPTX] Remove nvvm.ldg.global.* intrinsics (#112834)
Remove these intrinsics which can be better represented by load
instructions with `!invariant.load` metadata:

- llvm.nvvm.ldg.global.i
- llvm.nvvm.ldg.global.f
- llvm.nvvm.ldg.global.p
2024-10-27 16:14:13 -07:00
Thorsten Schütt
7b3da7b3b2
[GlobalISel][AArch64] Legalize G_ADD, G_SUB, G_AND, G_OR, and G_XOR for SVE (#110561)
Credits: https://github.com/llvm/llvm-project/pull/72976

LLVM ERROR: cannot select: %3:zpr(<vscale x 2 x s64>) = G_MUL %0:fpr,
%1:fpr (in function: xmulnxv2i64)

;; mul
define void @xmulnxv2i64(<vscale x 2 x i64> %a, <vscale x 2 x i64> %b,
ptr %p) {
entry:
  %c = mul <vscale x 2 x i64> %a, %b
  store <vscale x 2 x i64> %c, ptr %p, align 16
   ret void
}

define void @mulnxv4i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b,
ptr %p) {
entry:
  %c = mul <vscale x 4 x i32> %a, %b
  store <vscale x 4 x i32> %c, ptr %p, align 16
   ret void
}

define void @mulnxv8i16(<vscale x 8 x i16> %a, <vscale x 8 x i16> %b,
ptr %p) {
entry:
  %c = mul <vscale x 8 x i16> %a, %b
  store <vscale x 8 x i16> %c, ptr %p, align 16
  ret void
}

define void @mulnxv16i8(<vscale x 16 x i8> %a, <vscale x 16 x i8> %b,
ptr %p) {
entry:
  %c = mul <vscale x 16 x i8> %a, %b
  store <vscale x 16 x i8> %c, ptr %p, align 16
  ret void
}
2024-10-27 23:14:07 +01:00
Kiran Chandramohan
5621929f7f
[Flang][OpenMP] Add parser support for grainsize and num_tasks clause (#113136)
These clauses are applicable only for the taskloop directive. Since the
directive has a TODO error, skipping the addition of TODOs for these
clauses.
2024-10-27 20:16:24 +00:00
Kyungwoo Lee
0dd9fdcf83
[StructuralHash] Support Differences (#112638)
This computes a structural hash while allowing for selective ignoring of
certain operands based on a custom function that is provided. Instead of
a single hash value, it now returns FunctionHashInfo which includes a
hash value, an instruction mapping, and a map to track the operand
location and its corresponding hash value that is ignored.

Depends on https://github.com/llvm/llvm-project/pull/112621.
This is a patch for
https://discourse.llvm.org/t/rfc-global-function-merging/82608.
2024-10-26 20:02:05 -07:00
Kazu Hirata
89b5d88fb8
[ADT] Use std::string_view inside StringRef (#113775)
This patch makes minimum changes to replace Data and Length with an
instance of std::string_view.

Previously, I opted for public inheritance (#113752), but I
encountered a lot of errors from gcc stemming from ambiguity between
std::string_view and StringRef.

The composition approach in this patch gives us greater control at the
expense of forwarder functions.
2024-10-26 19:13:56 -07:00
Justin Fargnoli
597ccb8008
[NFC] Fix typo in description of AfterPassInvalidatedCallbacks (#113779) 2024-10-26 17:15:19 -07:00
Kyungwoo Lee
1941c5180b Reland (2nd attempt) [StructuralHash] Refactor (#112621)
This is largely NFC, and it prepares for #112638.
 - Use stable_hash instead of uint64_t
 - Rename update* to hash* functions. They compute stable_hash locally and return it.

This is a patch for
https://discourse.llvm.org/t/rfc-global-function-merging/82608.
2024-10-26 16:12:28 -07:00
Kyungwoo Lee
d104b8e827 Revert "Reland [StructuralHash] Refactor (#112621)"
This reverts commit 98ca9a635bd2fb98cee473a9558687a5b522e219.
2024-10-26 13:55:46 -07:00
Fangrui Song
d78d030b31 [MC] Export llvm::XCOFFObjectwriter and access it from MCXCOFFStreamer
Similar to commit 9539a7796094ff5fb59d9c685140ea2e214b945c for
WinCOFFObjectWriter.

Close #100412
2024-10-26 12:26:11 -07:00
Kyungwoo Lee
98ca9a635b Reland [StructuralHash] Refactor (#112621)
This is largely NFC, and it prepares for #112638.
 - Use stable_hash instead of uint64_t
 - Rename update* to hash* functions. They compute stable_hash locally and return it.

This is a patch for
https://discourse.llvm.org/t/rfc-global-function-merging/82608.
2024-10-26 12:07:57 -07:00
Fangrui Song
ef886a2580
Revert "[ADT] Teach StringRef to derive from std::string_view" (#113767)
Reverts llvm/llvm-project#113752

Many build bot failures
2024-10-26 10:32:09 -07:00
Kazu Hirata
a3181b11b5
[ADT] Teach StringRef to derive from std::string_view (#113752)
This patch makes minimum changes to have StringRef derive from
std::string_view, with an eventual goal of removing StringRef
completely.  Subsequent patches will further clean up the remaining
bits.

I've chosen public inheritance over private one because our codebase
relies on implicit conversions to std::string_view, which is currently
provided by:

  constexpr operator std::string_view() const {
    return std::string_view(data(), size());
  }

This implicit conversion stops applying once we use std::string_view
as a base class, public or private.  If we chose a private base class,
we would lose the implicit conversion.
2024-10-26 10:02:11 -07:00
Kyungwoo Lee
9672375623 Revert "[StructuralHash] Refactor (#112621)"
This reverts commit b667d161f0a9ff6b29cda0ccdb0081610c1e8b8c.
2024-10-26 09:55:21 -07:00
Kyungwoo Lee
b667d161f0
[StructuralHash] Refactor (#112621)
This is largely NFC, and it prepares for #112638.
 - Use stable_hash instead of uint64_t
- Rename update* to hash* functions. They compute stable_hash locally and return it.
 
This is a patch for
https://discourse.llvm.org/t/rfc-global-function-merging/82608.
2024-10-26 09:20:26 -07:00
davidtrevelyan
4102625380
[rtsan][llvm][NFC] Rename sanitize_realtime_unsafe attr to sanitize_realtime_blocking (#113155)
# What

This PR renames the newly-introduced llvm attribute
`sanitize_realtime_unsafe` to `sanitize_realtime_blocking`. Likewise,
sibling variables such as `SanitizeRealtimeUnsafe` are renamed to
`SanitizeRealtimeBlocking` respectively. There are no other functional
changes.


# Why?

- There are a number of problems that can cause a function to be
real-time "unsafe",
- we wish to communicate what problems rtsan detects and *why* they're
unsafe, and
- a generic "unsafe" attribute is, in our opinion, too broad a net -
which may lead to future implementations that need extra contextual
information passed through them in order to communicate meaningful
reasons to users.
- We want to avoid this situation and make the runtime library boundary
API/ABI as simple as possible, and
- we believe that restricting the scope of attributes to names like
`sanitize_realtime_blocking` is an effective means of doing so.

We also feel that the symmetry between `[[clang::blocking]]` and
`sanitize_realtime_blocking` is easier to follow as a developer.

# Concerns

- I'm aware that the LLVM attribute `sanitize_realtime_unsafe` has been
part of the tree for a few weeks now (introduced here:
https://github.com/llvm/llvm-project/pull/106754). Given that it hasn't
been released in version 20 yet, am I correct in considering this to not
be a breaking change?
2024-10-26 13:06:11 +01:00
Kazu Hirata
ec2da0ca19
[ADT] Use data() and size() within StringRef (NFC) (#113657)
This patch uses data() and size() within StringRef instead of Data and
Length.  This makes it easier to replace Data and Length with
std::string_view in the future, which in turn allows us to forward
most of StringRef functions to the counterparts in std::string_view.
2024-10-25 19:37:55 -07:00
Jon Roelofs
75c1c2614a
[llvm][TLI] Sort a switch's cases. NFC 2024-10-25 16:15:55 -07:00
Vasileios Porpodas
1540f772c7 Reapply "[SandboxVec][Legality] Reject non-instructions (#113190)"
This reverts commit eb9f4756bc3daaa4b19f4f46521dc05180814de4.
2024-10-25 12:55:58 -07:00
Vasileios Porpodas
eb9f4756bc Revert "[SandboxVec][Legality] Reject non-instructions (#113190)"
This reverts commit 6c9bbbc818ae8a0d2849dbc1ebd84a220cc27d20.
2024-10-25 12:52:31 -07:00
vporpo
6c9bbbc818
[SandboxVec][Legality] Reject non-instructions (#113190) 2024-10-25 12:47:19 -07:00