1609 Commits

Author SHA1 Message Date
0547781257 Add require_assert_buffer and require_sync_buffer to zeinfo
Add require_assert_buffer and require_sync_buffer to zeinfo
2025-10-28 11:25:40 +01:00
53a472d310 optimize i64 built-in variables to i32
OpenCL represents built-in variables like `get_global_id` with generic
type `size_t`, which translates to i64. This change adds a new
optimization that simplifies built-in calculation to i32 if built-in's
use has an assumption hinting that value fits in i32 range.
2025-10-24 11:31:59 +02:00
94f2cb27d9 Fix OCL atomic benchmark regression
More investigation is needed. Currently, we don't apply atomic_iadd to
atomic_inc/dec optimization to OCL cases.
2025-10-21 21:16:48 +02:00
0e95445170 Extend TargetExtTy retyping to instructions and structs
The LLVM IR that IGC receives from the LLVM 16-based SPIR-V Reader
contains OpenCL/SPIR-V builtins represented as TargetExtTy types.
Unfortunately, Clang 16 does not emit TargetExtTy and hence the modules
coming from Clang and SPIR-V Reader are not compatible and cannot be
linked together. The solution/workaround is to retype TargetExtTy types
as pointers of correct address space. This approach works since the
mangling/OpenCL builtin call resolution is already done by the SPIR-V
Reader and IGC does not need to work on TargetExtTy types directly.
Such retyping also ensures that all the current pointer-based
optimizations continue to work.

This patch extends the retyping beyond just function arguments and
return types. It now also retypes TargetExtTy used in:
- local variables (alloca instructions)
- loads and stores of TargetExtTy values
- struct types containing TargetExtTy fields
- function attributes (byval, sret, byref)
The retyping is done in a single pass over the module.
2025-10-17 19:39:07 +02:00
ae461354fd Use data structures in STB_TranslateOutputArgs.
This commit changes STB_TranslateOutputArgs to use data structures
instead of pointers to arrays of char. This is done for the purpose of
preventing memory leaks.

For `pOutput` field, llvm::SmallVector is used, as it works with
ZEBinaryBuilder::getBinaryObject(llvm::raw_pwrite_stream).
2025-10-09 14:57:26 +02:00
d53ffddcbc Adjust ConvertUserSemanticDecoratorOnFunctions pass for opaque-pointers
When we handle annotations with opaque pointers, we can call only single getOperand()
on annotation struct, because we don't need to use e.g. bitcast instruction
like for typed pointers.
2025-10-09 14:08:38 +02:00
d895809a52 Add no-inline and targeted code removal for testing
Adds new pass to disable inlining, and passes to remove/drop specific
functions and basic blocks.
This is for testing purposes only.
2025-10-06 14:18:52 +02:00
8b7ee37523 Adding support for opaque pointers in HandleSpirvDecorationMetadata
For `opaque pointers` we cannot deduce a type for `Prefetch` call with `ptr`.
We need this information to create appropriate builtins. To achieve this,
we can use `llvm::demangle()` method and find appropriate type.

This change is compatible with both typed and opaque pointers.
2025-10-03 12:25:49 +02:00
67faf6c1d4 Enable has_printf_calls zeinfo field
This commit enables previously added has_printf_calls field and test for it.
2025-09-23 08:58:00 +02:00
17c1de9abc Remove igc metrics
Remove igc metrics
2025-09-22 20:11:41 +02:00
035b1f3d39 Minor fixes and refactors.
Change args to const ref where makes sense.

Put std::move where makes sense

Apply rule of three

Change usage of unique_ptr and ptrs to unique_ptr to use just shared_ptr

Update comment in CodeSinking

Use saved boolean value instead of calling method over and over.
2025-09-22 15:49:55 +02:00
e64fdad3ab Handle missing single quotes for -igc_opts.
In igc_ocl_tranlation_ctx_impl there is handling of -igc_opts passed to
ocloc. The implementation however doesn't handle improper format, which
results in an infinite loop in case no single quotes were provided, or
the second single quote is missing.

This commit adds handling of these cases.
2025-09-22 12:33:22 +02:00
e02a9666f6 Support opaque pointers in PromoteBools pass
PromoteBools was wrongly skipping RAUW operation on ptr function calls
after promoting their signature and adding their users to promotion
queue which lead to cleaning those users and creating undef values in
subsequent users, which then in turn created dead code which was
eliminated and caused wrong test results. Essentially this pass was
wrongly skipping RAUW when neccessary.

In cases like these:
```llvm
  @call = call ptr @some-function(i1 true)
  @bitcast = bitcast ptr @call to ptr
  @ptrtoint = ptrtoint ptr @bitcast to i64
```

After pass pre fix:
```llvm
  @0 = call ptr @some-function(i8 1)
  @ptrtoint = ptrtoint ptr undef to i64
```

Proper pass behaviour:
```llvm
  @0 = call ptr @some-function(i8 1)
  @bitcast = bitcast ptr @0 to ptr
  @ptrtoin = ptrtoint ptr @bitcast to i64
```
2025-09-19 12:25:46 +02:00
eb7d24be22 Refactor removing dead code for LLVM versions < 14
Refactor removing dead code for LLVM versions < 14
2025-09-10 18:50:31 +02:00
133bd77d00 Reenable Shader Debug Hash Code functionality for OCL
Reenable Shader Debug Hash Code functionality for OCL
2025-09-03 09:58:37 +02:00
6cdf4a7232 Workaround for prefetch_cache_control failing due to unknown type size on opaque pointers
Currently `handleCacheControlINTELForPrefetch` requires type size to perform call conversion correctly,
but on opaque pointers such size is not available and we cannot just extract it anyhow.

We're waiting for "OpUntypedPrefetch" extension which will support opaque pointers in such cases.

Meanwhile as of today I'm adding skip of the whole prefetch conversion when opaque pointer type is involved
and we're waiting for update about the status of "OpUntypedPrefetch"
2025-08-29 13:21:43 +02:00
c1d34755f1 Support aggregate with bools promotion in functions
This PR enables support of structs and arrays with bools in function
arguments and return types.
2025-08-22 21:16:25 +02:00
5e4a7b9e87 Drop preprocessor checks for unsupported LLVM versions (#23491)
Drop preprocessor checks for unsupported LLVM versions


Delete all #if LLVM_VERSION_MAJOR checks which were about LLVM versions older than 14.
2025-08-21 15:02:07 +02:00
9ae78bef34 Apply rule-of-three
Applies rule-of-three by removing missing copy ctors.
2025-08-20 11:36:17 +02:00
0b5f9e11eb Add has_printf_calls to zeinfo
zeinfo now contains information if kernel/function has printf calls
and function pointer calls. This allows neo to create printf_buffer when
it is really used.
2025-08-20 10:30:06 +02:00
d3ca4a545c Add -vc-codegen option handling for VLD
.
2025-08-12 17:00:51 +02:00
b799e7c1f2 Add GenericCastToPtrOpt pass
In cases where we have no local casts to generics and we allocate
private memory in global space, we can replace GenericCastToPtrExplicit
with simple address space cast.
2025-08-12 15:45:04 +02:00
d0a9af74c2 Revert Don't partially set signal handlers
Don't partially set signal handlers
2025-08-06 11:37:54 +02:00
885fc99b4b small refactor
small refactor
2025-08-05 09:58:43 +02:00
86120427ff [Autobackout][FunctionalRegression]Revert of change: 0a4d70f134: Add GenericCastToPtrOpt pass
In cases where we have no local casts to generics and we allocate
    private memory in global space, we can replace GenericCastToPtrExplicit
    with simple address space cast.
2025-08-04 23:17:27 +02:00
0a4d70f134 Add GenericCastToPtrOpt pass
In cases where we have no local casts to generics and we allocate
private memory in global space, we can replace GenericCastToPtrExplicit
with simple address space cast.
2025-08-04 14:55:51 +02:00
420b632df9 Update IGC code format
Update IGC code format
2025-07-20 06:20:11 +02:00
92d6114445 Opaque pointer fixes in LegalizeFunctionSignatures, PromoteBools
In LegalizeFunctionSignatures don't call `getFunction()` which
returns parent function. Add support for llvm15+ which works
with opaque pointers and a legacy llvm 14 path.

In PromoteBools:
- Call `getType()` on load instruction - calling `getType()` on src
returns an opaque pointer.
- Use getValueType() in promoteGlobalVariable to work with
opaque pointers.
2025-07-18 12:51:53 +02:00
7fd0952833 Fix kernel_arg_base_type for OpenCL type arguments
The metadata node !kernel_arg_base_type must mirror !kernel_arg_type for
OpenCL builtin types (e.g. image1d_t). Unfortunately, this is
inconsistent with LLVM 16-based Common Clang.

This patch ensures that every OpenCL builtin type (*_t) listed in
!kernel_arg_type is also present in !kernel_arg_base_type at the same
position.
2025-07-18 05:45:28 +02:00
b727832427 Refactor SIMDInfo
Refactor SIMDInfo
2025-07-16 18:43:54 +02:00
6b8e1e040c Move PromoteToPredicatedMemoryAccess pass to OPT stage
Move the PromoteToPredicatedMemoryAccess pass to
the optimization stage of the compiler.
This allows to keep standard LLVM passes to optimize the IR before
the predication pass is applied.
Change the pass to support scalarized loads and stores.
Add a new pass to hoist conversion operations
to the common dominator to unblock the predication pass.
Fix generation of predicated stores, in case address is uniform
and stored value is not.
2025-07-15 21:15:57 +02:00
4c0406ad9f Clean up dead code related to patch token binary format deprecation
Cleaned up dead code that's related to patch token binary format deprecation. Removed unused code, adjusted some comments.
Most of these changes are related to previous commits that deprecated the format in VC and OCL.

Some parts are still to be refactored, this doesn't cover all patch token code.
2025-07-11 14:45:04 +02:00
Y
ecfdb20fa8 Update SPIR-V Decoration Handling
Updated the IGC to handle the new SPIR-V extension decoration IDs for HostAccessINTEL. The code now supports both the old (6147) and new (6190) enum values, ensuring backward compatibility while accommodating the latest extension updates.
2025-07-08 13:23:02 +02:00
adf0ae2f13 Clean up unused program debug functionality
Removed ZEBinaryBuilder::addKernelDebugEnv and its usages, as it was obsolete. The debug_env section in ze_info is meant to be empty as of this moment. Also, removed obsolete program debug functionality that was based on the patch token binary format (debugDataSize is always 0).
2025-07-08 11:32:34 +02:00
4045c427f9 [Autobackout][FunctionalRegression]Revert of change: 08106ff1cf: Add GenericCastToPtrOpt pass
In cases where we have no local casts to generics and we allocate
    private memory in global space, we can replace GenericCastToPtrExplicit
    with simple address space cast.
2025-07-04 05:28:20 +02:00
08106ff1cf Add GenericCastToPtrOpt pass
In cases where we have no local casts to generics and we allocate
private memory in global space, we can replace GenericCastToPtrExplicit
with simple address space cast.
2025-07-03 15:04:40 +02:00
85043cae61 Add "iab_version" field to zebinary
This change adds a new field INTELGT section of ZeBinary,
that will mark the version of the IAB layout.
This is needed for runtime to distinguish between non-backwards-compatible
changes to the layout.
2025-07-02 10:07:46 +02:00
5542ef599a Support opaque pointers in PromoteBools pass
Fixed issue with opaque pointers in PromoteBools pass
2025-06-30 11:51:10 +02:00
3b7490ecab Exclude JointMatrix types from TargetExtTy retyping
While OpenCL builtin types need retyping to correctly link with
Clang 16-generated BIF module, this is unecessary for any other builtin
types (e.g. JointMatrix types).

This patch excludes JointMatrix types from retyping. Other non-OpenCL
types will be excluded in the next patches.
2025-06-26 04:30:03 +02:00
2326f2dba7 Refactor enableZEBinary() conditions in OCL
Refactor OCL code paths depending on the enableZEBinary() as if zebin format was always supported and used.

The OpenCLPrintfResolution/basic.ll test was targeting older platforms using the patch token format, so it had to be adjusted for differences in pointer sizes. Specifically, pointers to printf string literals are 64-bit instead of 32-bit.

Some dead code will be left-over after merging, it will be removed in a later PR.
2025-06-23 13:18:04 +02:00
4d3ca7bc23 Retype TargetExtTy args to opaque pointers to match Clang-emitted OpenCL built-ins
Clang 16 still lowers OpenCL/SPIR-V built-ins as ptr to opaque structs,
while SPIR-V Reader uses TargetExtTy values. This helper transparently
converts any value-typed TargetExtTy function parameter to an opaque
pointer, rewrites call-sites, and updates metadata, ensuring the two IR
dialects link cleanly. The builtin function resolution is already done
earlier by SPIR-V Reader.
2025-06-23 12:19:21 +02:00
701168ed18 [Autobackout][FunctionalRegression]Revert of change: 7b3aea3289: Remove OCL driverInfo control for LscStoresWithNonDefaultL1Cache
With NEO version has been updated to have the
    zebin feature for LscStoresWithNonDefaultL1Cache, we can remove the
    workaround by driver info control check.
2025-06-21 19:34:36 +02:00
7b3aea3289 Remove OCL driverInfo control for LscStoresWithNonDefaultL1Cache
With NEO version has been updated to have the
zebin feature for LscStoresWithNonDefaultL1Cache, we can remove the
workaround by driver info control check.
2025-06-20 19:53:39 +02:00
52c9f18cb2 disable clang-format on tables
disable clang-format on tables
2025-06-13 03:15:38 +02:00
6426d949b4 Refactor MergeAllocas
Refactor MergeAllocas
2025-06-05 18:21:35 +02:00
d748a15874 Disable lsc sampler routing for OCL
Disable lsc sampler routing for ocl due to new regression found.
2025-06-03 19:30:07 +02:00
acaa2b17ac [Autobackout][FunctionalRegression]Revert of change: 6ac7b02bb5: Disable lsc sampler routing for OCL
Disable lsc sampler routing for ocl due to new regression found.
2025-06-01 11:25:38 +02:00
6ac7b02bb5 Disable lsc sampler routing for OCL
Disable lsc sampler routing for ocl due to new regression found.
2025-05-29 18:53:34 +02:00
256bc8296c Enable LSC sampler routing for OCL
Enable lsc sampler routing for OCL upon fixes available.
2025-05-27 18:27:57 +02:00
8e58ffcb87 Update RTDispatchGlobals struct
Update RTDispatchGlobals struct
2025-05-26 13:45:23 +02:00