Граф коммитов

2366 Коммитов

Автор SHA1 Сообщение Дата
Xiang Li 5a90ffd72b
Change default type for 1<<x to int. (#3400) 2021-01-27 19:28:24 -08:00
Adam Yang d08b307146
Fixed global constructors evaluated at codegen aren't removed (#3389) 2021-01-26 13:35:48 -08:00
Helena Kotas 3d918a239d
Remove extra argument from END_TEST_METHOD macro invocation (#3394) 2021-01-26 12:39:29 -08:00
Helena Kotas d1700eed47
Update highest shader model in Execution test (#3392) 2021-01-25 21:54:02 -08:00
Xiang Li f532d0a7f1
Remove empty loop. (#3391)
* Remove empty loop.
2021-01-25 20:15:53 -08:00
Tex Riddell 318f0ea52c
Enable ISHELPERLANE_PLACEHOLDER in test until implementations catch up. (#3388)
* Enable ISHELPERLANE_PLACEHOLDER in test until implementations catch up.
* HelperLaneTestWave to Pri2 to avoid warp problems in default run for now
2021-01-25 18:38:06 -08:00
Ehsan a233960c3f
[spirv] Don't apply RelaxedPrecision to ops operating on bools (#3364)
* [spirv] Don't apply RelaxedPrecision to Unary/Binary ops operating on booleans

* Address code review comments.
2021-01-25 10:05:31 -06:00
Ehsan f11daf7d42
[spirv] Fix storage class for ptr-to-ptr in Vulkan 1.2. (#3344)
* [spirv] Fix storage class for ptr-to-ptr in Vulkan 1.2.

* [spirv] Add one more test case.

* Address code review comments.
2021-01-25 10:04:48 -06:00
Greg Roth e99a6a9f91
silence sign warning on some systems (#3384)
A recent change produces a warning, which is sometimes interpretted as
an error, causing builds to fail
2021-01-22 23:08:43 -08:00
Jaebaek Seo a3c52dbbbc
[spirv] Fix failure caused by multiplying size() and int (#3379)
The code `int foo; .. size(float) * foo` causes failure because
`getElementSpirvBitwidth()` in AstTypeProbe.cpp does not handle the type
of `sizeof()` which is the "unsigned long" type. This commit handles it.

Fixes #2814
2021-01-22 15:54:13 -06:00
Tex Riddell 7c9e487afd
Implement IsHelperLane() (#3382) 2021-01-22 12:45:18 -08:00
Helena Kotas e2af267152
IsHelperLane() Execution Tests (#3367) 2021-01-22 10:34:30 -08:00
Xiang Li 8dd1bc1959
When create annotateHandle, put it near to input handle so it could be optimized. (#3381)
* When create annotateHandle, put it near to input handle so it could easier to be optimized.
2021-01-21 22:23:34 -08:00
Xiang Li 797d4b8adc
Mutate resource to handle for shader model 6.6+. (#3374)
* Mutate resource to handle for sm_6_6+.

* Use bitcast to save global symbol and HLSL type for DxilResourceBase.
2021-01-21 17:16:06 -08:00
Ehsan bcf56f2670
[spirv] Fix target env error message. (#3346) 2021-01-21 10:22:11 -06:00
Adam Yang 43d430650f
Added the missing thread local IMalloc for possible memory allocation in some implementations (#3373) 2021-01-20 14:12:13 -08:00
Adam Yang 2b8ef5b57e
Removed source from debug module. Support slim PDB. (#3348) 2021-01-20 12:25:28 -08:00
Xiang Li ac60ae1f4d
Add annotateHandle when link lower shader model to shader model 6.6. (#3368)
* Add annotateHandle when link lower shader model to shader model 6.6.
2021-01-19 18:15:58 -08:00
Adam Yang 2f40325448
Don't crash when querying hash when hash is empty (#3366)
Co-authored-by: Adam Yang <laevus.y@gmail.com>
2021-01-19 12:35:30 -08:00
Greg Roth 9152bb39fa
Lifetime test: UAVcreation/raytracing conditionals (#3356)
The lifetime test had parameters for UAV creation in the wrong order so
they were misassigned. The use of lib creation also didn't depend on
raytracing support as it should.

correct some other sm66 cap bit checks too
2021-01-15 07:40:27 -08:00
Xiang Li 50981cdefe
Support CallInst when ReplaceStaticIndexingOnVector. (#3354)
* Support CallInst when ReplaceStaticIndexingOnVector.
2021-01-13 20:02:28 -08:00
Xiang Li 83e538ecc3
Use IsEntry when LowerStaticGlobalIntoAlloca. (#3353) 2021-01-13 16:14:09 -08:00
Greg Roth cb3b54fdc8
Refactor resource creation in resources exec test (#3349)
Various resources have been created inconsistently with the shader
representation. After running out of bandaids, this refactors that code
to give the caller the tools necessary to create the resources
correctly.
2021-01-12 16:25:11 -08:00
Xiang Li 8e3a21c417
Call init function for entry of lib profiles. (#3350)
* Call init function for entry of lib profiles.
2021-01-12 11:29:13 -08:00
Helena Kotas cf044cc960
Minor changes to tests to silence warnings (#3342)
* Minor changes to tests to silence warnings

* Remove unused arguments
2021-01-11 20:59:39 -08:00
Greg Roth 11f07659a7
Allow adding object methods when in namespace (#3284)
Builtin object types such as Texture2D add all their object methods
to the associated decl context when they are first seen. However,
previously, if the code meant to effect that was found in a namespace
it would skip this addition. This removes that restriction so that
the methods can be added and then found when needed.

Fixes #2472
2021-01-11 16:00:01 -08:00
Greg Roth b90095fc87
Don't create static global for uninited local const (#3345)
Previously, codegen attempted to skip the alloca creation that would
be encountered below and just emit the constant init. However, the
code in EmitAutoVarDecl() first checks whether the Init is null using
isTrivialInitializer() and just bails if it is.

This adds the isTrivialInitializer() call to the conditions here
since we fallback to the alloca if there is no constant initializer.
2021-01-11 15:06:07 -08:00
Greg Roth 442cac1a44
Fix mesh and groupshared in ExecutionTest (#3339)
The ShaderOpTest code for mesh shaders had a lot of problems. This
corrects the initialization of the pipeline and the dispatch.

In addition, there were various problems with ExecutionTests for atomics
where mesh shaders were used. This adds testing for mesh results that
was being skipped. This required adjustment of the indices.

Also required was proper accumulation of groupshared values between
amplification and mesh shaders.

Various and sundry indexing corrections were also required.
2021-01-08 13:26:34 -08:00
Adam Yang 897fee8ba9
PDB Util shouldn't fail on DXIL with no debug info (#3337) 2021-01-06 14:48:55 -08:00
Adam Yang 4c66d72760
Enabled loop exit structurizer by default. (#3334)
* Fixed a bug in loop exit structurizer where exit values don't dominate users. Replaced the undef with 0 for numeric types. Enabled it by default.
* No longer using a separate list
2021-01-05 12:46:23 -08:00
Greg Roth 3d1d575461
Update dxexp to 6.6 (#3328)
To report support correctly, it needs to start with 6.6 and work
backward.
2021-01-04 13:06:05 -08:00
Greg Roth 645bb78d13
Skip gpudescriptorhandles where there is no RTV (#3329)
Where there's no render target, the runtime throws errors if you try to
retrieve the gpu descriptor handle.
2021-01-04 13:02:29 -08:00
Xiang Li f894295c3b
Support NonUniformResourceIndex for dynamic resource. (#3333) 2021-01-04 11:29:50 -08:00
Adam Yang 3ae6c7df39
PDB Utils returns hash struct and handles DXIL program header. (#3318) 2021-01-04 10:46:56 -08:00
Ehsan 20a7c685cc
[spirv] Add SM 6.6 8-bit packed types and intrinsics (#3325)
* [spirv] Support for SM 6.6 pack_u8 and pack_s8.

* [spirv] Add support for SM 6.6 pack_clamp_{u|s}8.

* [spirv] Support SM 6.6 unpack intrinsics.

* [spirv] Remove unused variable.

* Remove comment.
2020-12-30 13:03:16 -06:00
Ehsan cb2a5e1355
[spirv] Support 64-bit interlocked intrinsics. (#3321)
* [spirv] Support 64-bit interlocked intrinsics.

* Fix build error.
2020-12-30 12:08:19 -06:00
Xiang Li 2903170ac5
Fix crash in Sema::CheckDerivedToBaseConversion when Paths is empty. (#3327) 2020-12-18 15:03:53 -08:00
Marijn Suijten f3ba78bf6b
SPIR-V: Emit RayTmaxKHR builtin for RayTCurrent IOP (#3320)
* SPIR-V: Emit RayTmaxKHR builtin for RayTCurrent IOP

HitTKHR was [removed] from the spec as it merely shadows RayTmaxKHR.
Emitting it results in invalid SPIR-V:

    generated SPIR-V is invalid: Operand 3 of Decorate requires one of these capabilities: RayTracingNV
      OpDecorate %6 BuiltIn HitTNV

Replace the builtin by RayTmaxKHR if NV_ray_tracing enabled to resolve
this.

[removed]: bdd2aa34c4

* test/CodeGenSPIRV: Test RayTCurrent for RayTmax or HitT builtin
2020-12-17 15:48:53 -06:00
Ehsan d99be810ad
[spirv] Forward declaration of function inside another. (#3310)
* [spirv] Forward declaration of function inside another.

Fixes #3214.

* Add struct to test shader.
2020-12-10 13:59:29 -06:00
Greg Roth f83a0c2e2e
Correct ComputeSample Execution Test (#3300)
Corrected disabling compute shader and incorrect indices.

Removed test that attempted to confirm that the indepenent samples would
match where the derivatives were the same. First of all, they weren't as
the same as intended. Second, even with that corrected, position in
quads affected the LOD calculation. The check was beyond the intended
scope of this test anyway.

Improved comments describing the function of this test
2020-12-09 14:08:14 -08:00
Greg Roth 424d0a2ac6
Correct QuadRead index (#3298)
Corrected quadread index calculation which was not fully updated

Also ups priority only skipping when warp is used so this won't be
missed again and improves the error output by using equals macros
2020-12-09 14:07:19 -08:00
Greg Roth 9934e70011
Resources test Tex/Buffer mismatch fix (#3309)
A resource being treated like a texture in the shader was being created
as a buffer. This caused problems on some platforms including warp,
which required an ugly workaround that this removes
2020-12-08 14:49:41 -08:00
Adam Yang 4d40670ef3
Fixed writing to RWTexture generating a load and store for each component (#3304) 2020-12-07 22:51:53 -08:00
Greg Roth 55ea804d12
Correct Resource Views in Resource Execution Test (#3303)
Buffers were being created as Texture1D Views, which causes problems on
some hardware.
2020-12-04 18:35:34 -08:00
JiaoluAMD ce2ec2f654
[SPIR-V]Support KHR_Ray_tracing terminate Ops (#3295)
* [SPIR-V]Support KHR_Ray_tracing terminate Ops

Add OpIgnoreIntersectionKHR/OpTerminateRayKHR related
https://github.com/microsoft/DirectXShaderCompiler/issues/3285

* Remove redudant message in the header of check hlsl

* rebase against master (fix merge conflict)

* Create a new basic block after termination.

* Don't change the SPIRV-Headers hash.

* Add unit tests and add assertion.

* Fix missing ==

Co-authored-by: Ehsan Nasiri <ehsannas@gmail.com>
2020-12-04 11:00:53 -06:00
Greg Roth 9b39d2e934
Make lifetimes test use 6.6 (#3297)
Presently, lifetime markers are only generated for 6.6
2020-12-03 12:58:51 -08:00
Greg Roth d574d27c1f
Implement Shader Model 6.6 (#3293)
This is the work of many contributors from Microsoft and our partners.
Thank you all!

Add support for 64-bit atomics, compute shader derivatives, dynamic
resources (from heap), 8-bit Packed Operations, and Wave Size.
All of these require compiling with 6_6 targets with just a few
exceptions. Each of these features include unittests and Execution
tests.

64-bit atomics add 64-bit variants of all Interlocked* intrinsic
operations. This involves changing some of the code that matches
intrinsic overloads to call instructions. Also adds a few float
intrinsics for compare and exchange interlocked ops which are available
for all shader models 6.0 and up.

Compute shader derivatives adds dd[x|y], CalculateLevelOfDetail, and
Sample operations that require derivatives to compute. QuadRead
operations have been allowed in compute from 6.0+ and tests are added
for them here.

Dynamic resources introduce global arrays that represent the resource
and sampler heaps that can be indexed without requiring root signature
representations. This involves a new way of creating and annotating
resource handles.

8-bit Packed operations introduces a set of intrinsics to pack and
unpack 8-bit values into and out of new 32-bit unsigned types that can
be trivially converted to and from uints.

WaveSize introduces a shader attribute that indicates what size the
shader depends on the wave being. If the runtime has a different wave
size, trying to create a pipeline with this size will fail.
2020-12-02 21:10:44 -08:00
Adam Yang 747ee519eb
Added new PDB interface (#3288) 2020-12-02 14:25:09 -08:00
Adam Yang ee3303f61d
Fixed debug info alignment in min16 types. (#3257) 2020-12-02 08:57:37 -08:00
Greg Roth d658b86b70
Add conditionals around vk namespace usage (#3291)
the VK namespace change introduced some variables and defines that are
used in areas not protected by the same ifdefs that protect the
declarations. As a result, where this wasn't defined, builds and hearts
were broken. </3
2020-12-01 18:28:40 -08:00
Jeff Noyle 265492784b
PIX: Update debugging passes for certain language features (#3289)
A customer provided a shader that uses many language features that the value-to-declare pass couldn't handle:
-member functions
-resource variables
-arguments passed by pointer
-struct inheritance

Note the highly "creative" method used to determine if a type is a resource- by name string compare. Unfortunately there isn't a cleaner way to do this based on type alone.

These changes aren't the end of this road: GS output payloads aren't covered. Resource types are merely worked-around, not turned into debuggable variables that PIX can display.

Also, these changes disturbed the DIA debug lines reporting, which isn't used by PIX anymore so I just deleted that test case rather than fix it. (A future checkin will delete the DIA implementation properly.)
2020-12-01 12:56:49 -08:00
Ehsan d7bb9ee170
Introduce the implicit 'vk' namespace (#3133)
* [spirv] Introduce the implicit 'vk' namespace

If any of these are used for DXIL code generation, the compiler will
report an error about the unknown "vk" namespace.

* [spirv] Introduce vk::ReadClock intrinsic.

The following Vulkan specific intrinsic functions are added:

```hlsl
uint64_t vk::ReadClock(in uint32 scope);
```

Also the following Vulkan-specific implicit constants are added:

```
vk::CrossDeviceScope; // defined as uint 0
vk::DeviceScope       // defined as uint 1
vk::WorkgroupScope    // defined as uint 2
vk::SubgroupScope     // defined as uint 3
vk::InvocationScope   // defined as uint 4
vk::QueueFamilyScope  // defined as uint 5
```

Sample usage looks as follows:

```hlsl
uint64_t clock = vk::ReadClock(vk::WorkgroupScope);
```

If any of these are used for DXIL code generation, the compiler will
report an error about the unknown "vk" namespace.

* [spirv] Add documentation.

* Address code review comments.

* Test: Validate vk namespace is not allowed for dxil.

* Fix usage of DXASSERT.

* Move ValidateVkNamespaceNotAllowed test to HlslFileCheck.
2020-12-01 14:04:14 -06:00
Jaebaek Seo a30d76ab78
[spirv] do not use WorkGroup storage class for hull shader output patch (#3271)
* [spirv] do not use WorkGroup storage class for hull shader output patch

* Code review
2020-11-26 10:23:15 -06:00
JiaoluAMD 5ae95866ea
[SPIRV] Add support hlsl export function attribute (#3234)
* [SPIRV] support hlsl export function attribute

DXIL could export functions with export attribute while spirv would
ignore such functions. Currently glsl spirv does not have linkage
export decorate. so the exported function would be treated as normal
function while add dummy entry point according to the spirv validations

* Remove use of dummy entrypoint function.

* Add Linkage capability if needed.

* Add SPV_ENV_UNIVERSAL_1_5 as a possible target env.

* Get target environment for tests from the test file.

* Transition last test to using target env in test file.

* Remove unused variable.

* Address code review.

Co-authored-by: Ehsan Nasiri <ehsannas@gmail.com>
2020-11-25 19:38:13 -06:00
Ehsan e41ac97e5e
[spirv] Fix issues related to struct inheritance memory layout (#3273)
* [spirv] Fix reconstructValue for struct inheritance.

* [spirv] Fix memory layout for a derived empty struct.
2020-11-25 09:57:09 -06:00
JiaoluAMD 4ced9bdf05
[SPIRV]Updates to final RayTracing semantics (#3279)
1. Add OpTraceRayKHR
2. Remove "provisional" in files
3. Update the SPIRV Headers/Tools to latest version
2020-11-24 10:03:41 -06:00
Marijn Suijten af14220b45
[linux-port] Support full IID comparison on GCC (#3062)
The fallback layer for GCC currently uses pointer comparison to match
IIDs as uuid tagging for types is not supported.
Thus, when an external program dlopens libdxcompiler and calls
with a proper REFIID these will not match internal pointers and result
in E_NOINTERFACE.

Note that the reverted patches before this commit alleviated the
situation somewhat by replacing the pointer with a hash of the interface
name. While this again grants a stable value to be used when called from
external binaries these (usually FFI wrappers) now need to understand
whether the library has been compiled with full IID support (as a binary
compiled with Clang has no such limitations), and then pass the hash
anywhere they'd otherwise pass an IID.

WIP: Not all IIDs are added yet, which requires the extra "empty-GUID"
check in IsEqualIID.
2020-11-20 15:18:05 -08:00
Marijn Suijten 11e04d8d2b
Remove unnecessary whitespace in files touched by #3062 (#3272) 2020-11-19 14:22:42 -08:00
Greg Roth 471e0ae40b
Reword misleading type buffer atomic error message (#3268)
Saying that typed buffers are not supported is inaccurate. Scalar types
are required for it to work though.
2020-11-19 10:25:11 -08:00
Ehsan 753e2a4c0a
[spirv] Fix read/write to base struct member from derived struct (#3263)
* [spirv] Support base struct member access.

* [spirv] Bug fix for non-overridden methods.
2020-11-19 12:19:10 -06:00
Jaebaek Seo 09a4d3c1ef
[spirv] convert return type if memory layout is different (#3262)
For a function `ReturnType foo( .. ) { .. return value; }`, if the type
of value has a memory layout, `value` cannot be used for the operand of
OpReturnValue because of the type mis-match. Note that the `ReturnType`
for the return value must have a void memory layout (i.e., unknown).

This CL converts the type of the return value if it has an explicit
physical memory layout.
2020-11-19 12:02:28 -05:00
Xiang Li f7377da305
Propagate memcpy src on srv. (#3270) 2020-11-18 19:56:25 -08:00
rkarrenberg 489c2e4d32
Move force-zero-store-lifetimes flag to help-hidden, remove accidental check from test. (#3264) 2020-11-17 04:56:52 -07:00
Marijn Suijten 5f835c4506
dxcisense: Allocate "TM" classes using IMalloc instead of new (#3258)
When running valgrind over a program using `DxcIntelliSense` (to
validate our own deallocations [1]) a bunch of mismatching `new` with
`free()` show up:

    Mismatched free() / delete / delete []
       at 0x483B9AB: free (vg_replace_malloc.c:538)
       by 0x52B06A8: IMalloc::Free(void*) (WinAdapter.cpp:34)
       by 0x6DC7D19: DxcTranslationUnit::Release() (dxcisenseimpl.h:308)
       by 0x14278E: com_rs::unknown::IUnknown::release (unknown.rs:55)
       [...]
     Address 0x4c3c930 is 0 bytes inside a block of size 40 alloc'd
       at 0x483B07F: operator new(unsigned long, std::nothrow_t const&) (vg_replace_malloc.c:385)
       by 0x6DC06EB: DxcIndex::ParseTranslationUnit(char const*, char const* const*, int, IDxcUnsavedFile**, unsigned int, DxcTranslationUnitFlags, IDxcTranslationUnit**) (dxcisenseimpl.cpp:1192)
       by 0x13020A: hassle_rs::intellisense::ffi::IDxcIndex::parse_translation_unit (macros.rs:108)
       by 0x119B74: hassle_rs::intellisense::wrapper::DxcIndex::parse_translation_unit (wrapper.rs:101)
       [...]

And so on for the other intellisense classes.  All these classes have
`DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL` which deallocates `this` on the
associated `m_pMalloc` with `free()`:

    The "TM" version keep an IMalloc field that, if not null, indicate
    ownership of 'this' and of any allocations used during release.

Yet are allocated using `new`, resulting in this mismatch.  The solution
is to follow a similar approach as the introduction of `IMalloc` to
`DxcIntelliSense` in d5bb308 by rewriting all classes to take an
`IMalloc *` in the constructor and invoking it either through `::Alloc`
from `DXC_MICROCOM_TM_ALLOC` or `CreateOnMalloc`.

[1]: https://github.com/microsoft/DirectXShaderCompiler/pull/3250#issuecomment-726216850
2020-11-16 18:39:14 -08:00
rkarrenberg eaa7f95d07
Enable generation of llvm.lifetime.start/.end intrinsics (#3034)
* Enable generation of llvm.lifetime.start/.end intrinsics.

- Remove HLSL change from CGDecl.cpp::EmitLifetimeStart() that disabled
- generation of lifetime markers in the front end.
- Enable generation of lifetime intrinsics when inlining functions
- (PassManagerBuilder.cpp).
- Both of these cover a different set of situations that can lead to
- inefficient code without lifetime intrinsics (see examples below):
  - Assume a struct is created inside a loop but some or all of its
    fields are only initialized conditionally before the struct is being
    used. If the alloca of that struct does not receive lifetime intrinsics
    before being lowered to SSA its definition will effectively be hoisted
    out of the loop, which changes the original semantics: Since the
    initialization is conditional, the correct SSA form for this code
    requires a phi node in the loop header that persists the value of the
    struct field throughout different iterations because the compiler
    doesn't know anymore that the field can't be initialized in a different
    iteration than when it is used.
  - If the lifetime of an alloca in a function is the entire function it
    doesn't need lifetime intrinsics. However, when inlining that function,
    the alloca's lifetime will then suddenly span the entire caller, causing
    similar issues as described above.
- For backwards compatibility, replace lifetime.start/.end intrinsics
  with a store of undef in DxilPreparePasses.cpp, or, for validator
  version < 1.6, with a store of 0 (undef store is disallowed). This is
  slightly inconvenient but achieves the same goal as the lifetime
  intrinsics. The zero initialization is actually the current manual
  workaround for developers that hit one of the above issues.
- Allow lifetime intrinsics to pass DXIL validation.
- Allow undef stores to pass DXIL validation.
- Allow bitcast to i8* to pass DXIL validation.
- Make various places in the code aware of lifetime intrinsics and their
- related bitcasts to i8*.
- Adjust ScalarReplAggregatesHLSL so it generates new intrinsics for
  each element once a structure is broken up. Also make sure that lifetime
  intrinsics are removed when replacing one pointer by another upon seeing
  a memcpy. This is required to prevent a pointer accidentally
  "inheriting" wrong lifetimes.
- Adjust PromoteMemoryToRegister to treat an existing lifetime.start
- intrinsic as a definition.
- Since lifetime intrinsics require a cleanup, the logic in
  CGStmt.cpp:EmitBreakStmt() had to be changed: EmitHLSLCondBreak() now
  returns the generated BranchInst. That branch is then passed into
  EmitBranchThroughCleanup(), which uses it instead of creating a new one.
  This way, the cleanup is generated correctly and the wave handling also
  still works as intended.
- Adjust a number of tests that now behave slightly differently.
  memcpy_preuser.hlsl was actually exhibiting exactly the situation
  explained above and relied on the struct definition of "oStruct" to be
  hoisted out to produce the desired IR. And entry_memcpy() in
  cbuf_memcpy_replace.hlsl required an explicit initialization: With
  lifetime intrinsics, the original code correctly collapsed to returning
  undef. Without lifetime intrinsics, the compiler could not prove this.
  With proper initialization, the test now has the intended effect, even
  though the collapsing to undef could be a desireable test for lifetime
  intrinsics.

Example 1:

Original code:
for( ;; ) {
  func();
  MyStruct s;
  if( c ) {
    s.x = ...;
    ... = s.x;
  }
  ... = s.x;
}

Without lifetime intrinsics, this is equivalent to:
MyStruct s;
for( ;; ) {
  func();
  if( c ) {
    s.x = ...;
    ... = s.x;
  }
  ... = s.x;
}

After SROA, we now have a value live across the function call, which will cause a spill:
for( ;; ) {
  x_p = phi( undef, x_p2 );
  func();
  if( c ) {
    x1 = ...;
    ... = x1;
  }
  x_p2 = phi( x_p, x1 );
  ... = x_p2;
}

Example 2:

void consume(in Data data);
void expensiveComputation();

bool produce(out Data data) {
    if (condition) {
        data = ...; // <-- conditional assignment of out-qualified parameter
        return true;
    }
    return false; // <-- out-qualified parameter left uninitialized
}
void foo(int N) {
    for (int i=0; i<N; ++i) {
        Data data;
        bool valid = produce(data); // <-- generates a phi to prior iteration's value when inlined. There should be none
        if (valid)
            consume(data);
        expensiveComputation(); // <-- said phi is alive here, inflating register pressure
    }
}

* Implement lifetime intrinsic execution test.

- Test SM 6.0, 6.3, and 6.5. The 6.5 test behaves exactly the same way
  as 6.3, it is meant a placeholder for 6.6.
- Test validator versions 1.5 and 1.6.
- Abstract a few things in the ExecutionTest infrastructure to enable
  better code sharing, e.g. for lib compilation.

* Make memcpy replacement conservative by removing lifetimes of both src and dst. Add regression test for this case.

* Allow to force replacing lifetime intrinsics by zeroinitializer stores via compile option.

* Fix regression where lifetimes caused code that was not cleaned up properly.

- Add SROA and Jump Threading passes as early in the optimization
  pipeline as possible without interfering with lowering. These two are
  required to fully remove redundant code due to insertion of cleanup blocks
  for lifetimes. Previously, SROA ran much too late, and Jump Threading
  was disabled everywhere.
- A side effect of this is that we can now have unstructured control
  flow more often. This also breaks one test that was originally written
  when a part of SimplifyCFG that could also create unstructured control
  flow was disabled. That part is still disabled, but jump threading has
  the same effect. I don't know why unstructured control flow is a
  problem for the optimization pipeline.
- Add a regression test that requires the two phases to be cleaned up properly.
- Disable the simplifycfg test which now fails even though simplifycfg
  still does what it should.

* Disable lifetime intrinsics for SM < 6.6, add flag to enable explicitly.

- Add missing default value for unrelated option StructurizeLoopExitsForUnroll.
- Re-enable simplify cfg test disabled in a previous commit.
2020-11-16 15:48:05 -08:00
Ehsan 22dc78f4c3
[spirv] Fix compound MulAssign with type mismatches. (#3255)
* [spirv] Fix compound MulAssign with type mismatches.

Fixes #2810

* [spirv] fix for matrices.
2020-11-16 10:04:33 -06:00
Ehsan c294ebf2c1
[spirv] Use isResourceType to cover SubpassInput. (#3253)
Fixes #3169.

hlsl::IsResourceType does not cover SubpassInput (which is
vulkan-specific).
2020-11-16 10:04:05 -06:00
Ehsan 78515c284c
[spirv] Move descriptor scalar replacement to legalization stage. (#3261)
* [spirv] `-fspv-flatten-resource-arrays` is not needed for flattening global struct of resources.

* [spirv] Move descriptor scalar replacement to legalization stage.
2020-11-16 09:15:49 -06:00
Greg Roth 35fda6914e
Handle scalar args to out vector params (#3246)
Previously, trying to pass a scalar to a vector out parameter would
cause an assert and no truncation warning. This scales back the assert
and adds the missing warning.

Trying to pass a scalar to an inout parameter would cause a crash. This
allows for the necessary splat and avoids the erroneous attempts to
create a cast that leads to the crash.

Finally, as an incidental, this adds output parameter information to an
error that ostensibly required it, but never had it.
2020-11-10 15:13:48 -08:00
Jaebaek Seo a8d9780046
[spirv] emit OpLine at the end of entry function (#3244)
For some cases, spirv-opt removes all line information because of the
optimization. Emitting at least a single OpLine helps debuggers know it
is the end of the shader execution.
2020-11-09 14:01:29 -05:00
Tex Riddell e27ae363e1
Fix lost debug info on DispatchMesh payload in AS (#3243) 2020-11-04 13:58:43 -08:00
Jaebaek Seo b17cce22d3
Revert "[spirv] add location for DebugDeclare (#3230)" (#3242)
This reverts commit 07ebfcff52.
2020-11-04 15:24:12 -06:00
Greg Roth 4a0d84f369
Initialize conversion remarks result (#3241)
When not initialized, an unlikely, but possible set of circumstances
could produce spurious warnings.
2020-11-04 11:14:40 -07:00
Adam Yang 4b975c13f0
Made exit values not have to dominate latch in structurize loop exit (#3220) 2020-11-03 18:16:08 -08:00
Jaebaek Seo 07ebfcff52
[spirv] add location for DebugDeclare (#3230)
This commit adds the SourceLocation to SpirvDebugDeclare class that will
result in emitting the OpLine for the declaration (where the declaration
happens). It will help the spirv-opt to preserve the value assignment
location. In particular, it will be useful for simple shaders that
spirv-opt almost strips out all the instructions and keeps only
DebugValue instructions. We can recognize the location of value
assignments based on OpLine.
2020-11-02 16:02:33 -05:00
Jaebaek Seo 8fea615e3c
[spirv] wrap instructions with OpNoLine (#3229)
The current DXC emits `OpLine` for the first instruction in the location
and does not emit the same `OpLine` for the following instructions.
However, it does not specify the end of the effectiveness of the
`OpLine`, which is technically wrong based on the spec of OpLine and
OpNoLine. We have to specify the `OpLine` is not applied to the
following instructions when we meet an instruction without the location
information.
2020-11-02 14:11:29 -05:00
Junda Liu 6c34f5f7f5
[spirv] Fix [[vk::push_constant]] on ConstantBuffer part II (#3216)
I wasn't noticing that the last fix #3215 only fixed the error-checking. It was generating an OpTypeStruct without any member.

This commit fixes that push constant should use the templated type of constant buffer to create the struct.
2020-11-02 09:24:30 -06:00
Junda Liu c7a225a0a3
[spirv] globallycoherent should generate SPIR-V decoration Coherent (#3217)
globallycoherent on resource variables should result in decoration Coherent in generated SPIR-V.
2020-11-02 09:19:26 -06:00
Tex Riddell f6076e38c5
Fix precise propagation through various missing paths (#3224)
propagate through:
- non-FP paths that might have been dependent on FP paths
- intrinsics that aren't simple FP math intrinsics (such as Sample)
- pointers to matching GEPs
- conditions for control dependent branches
2020-10-30 23:17:55 -07:00
Tex Riddell 600c06a3f5
Fix regression in lib vector arg case when skipping copy-out (#3232) 2020-10-30 19:03:59 -07:00
Helena Kotas 6a1138a055
Add caps check for optional 16bit ops support to several execution tests. (#3222) 2020-10-29 12:37:09 -07:00
Adam Yang 99840a506f
Make sure bitpiece not generated that covers the entire variable (#3223) 2020-10-28 17:26:54 -07:00
Junda Liu b126db950c
Fix [[vk::push_constant]] on ConstantBuffer (#3215)
This commit fix a regression introduced by #3147: when`[[vk::push_constant]]` is apply to a  ConstantBuffer, error shows that `'push_constant' attribute only applies to global variables of struct type`.
2020-10-21 15:53:32 -05:00
Jaebaek Seo da6a6740a8
[spirv] handle sizeof using Clang's const folding (#3208)
* [spirv] handle sizeof using clang's const folding

* Code review
2020-10-21 11:45:54 -05:00
Adam Yang 3be547b67c
Fixing store undef later in the compilation. (#3212) 2020-10-20 21:15:49 -07:00
Tex Riddell 141a5c2ec5
Skip extra argument copying at callsite for library targets (#3203)
Skip extra arg copies in codegen, but copy when matrix orientation change
must be captured for call.
Copy what's necessary for translation around external calls, like cbuffer,
in HLLegalizeParameter.
This fixes cbuffer RayDesc case as well.
Also fixes issue with -file-check-dump.
2020-10-16 13:52:00 -07:00
Adam Yang e6b313b6ab
remove-dead-blocks handles switch. Split resource array before finalize. (#3184) 2020-10-15 13:05:39 -07:00
Jaebaek Seo 12fa61c61b
[spirv] allow debug info generation to use full optmization (#3201)
As SPIRV-Tools supports the debug info preservation for the full
optimization, we want to allow DXC users to use the full optimization
for the debug info generation.

This change updates SPIRV-Tools and SPIRV-Headers.
2020-10-15 12:04:39 -05:00
Adam Yang d8dec0efd7
Fixed some cases where O0 fails compilation (#3205)
- Fixed value tracking for dxil intrinsics
- Fixed some selects holding on to invalid resource uses
- Fixed some cases where unused globals hold on to invalid resource uses
- Fixed some cases where stores of undefs stick around
2020-10-14 22:41:03 -07:00
Junda Liu e39d1397ca
[SPIR-V] Add noinline support for SPIR-V generation (#3163)
This PR will add `DontInline` function control flag to the OpFunction in generated SPIR-V if the function has `[noinline]` in HLSL shader.

This is the first step of work for #3158.
After the `DontInline` flag is added, spirv-opt needs an option to control whether it should honor the flag or not (it ignores the flag currently), and the option should be passed down by DXC.
2020-10-14 16:47:27 -04:00
Jeff Noyle 57292120b7
Fix tests (#3195)
Co-authored-by: Jeff Noyle <jeffno@ntdev.microsoft.com>
2020-10-13 17:21:04 -07:00
Helena Kotas c565b3d20b
Cleanup and minor changes to improve integration with internal projects (#3199)
* Cleanup and minor changes to improve integration with internal projects

Adds -Debug option to hcttest.cmd

* Case insensitive compare for -Debug and -Release flags in hctbuild and hcttest
2020-10-13 16:22:50 -07:00
Ehsan 56430de609
[spirv] Use sm 6.5 as 6.6 is not fully supported yet. (#3191) 2020-10-07 15:12:00 -07:00
Jaebaek Seo 21cec7e90b
[spirv] add DebugScope after compound statement (#3182)
Before/after handling a compound statement i.e., `{ .. }`, we have to
add DebugScope for the lexical scope updates. We added it before
handling a compound statement, but we did not add it after doing it.
This commit adds a DebugScope after handling a compound statement.
2020-10-07 14:58:08 -04:00
Greg Roth 51ea81fcc6
Correct GV error message crash (#3161)
When reporting a globalvariable associated error message without -Zi,
an attempt is made to report the associated function, but there was no
check to see if that function existed, so it crashed.

Fixes #2989
2020-10-06 13:29:48 -07:00
Greg Roth 754e99b405
Revert "Optimize compile times by not skipping allocas (#3168)" (#3183)
This reverts commit 9459577e8f.
2020-10-05 16:23:12 -07:00
Adam Yang e0d1f5d123
Disabled FoldCondBranchOnPHI in simplify cfg (#3180) 2020-10-05 12:00:33 -07:00
Xiang Li d0fa5e301b
Not dup barrier in HL level. (#3181) 2020-10-02 20:43:40 -07:00
Jaebaek Seo 7b5d547ea3
[spirv] report error for invalid tex2d multiplication (#3175)
Calling tex2D must report an error but the multiplication using it
crashes instead of an error report.
2020-10-01 16:54:06 -04:00
JiaoluAMD 1450ea8630
[spirv] Fix issues of RWByteAddressBuffer in the InitList (#3145)
RWByteAddressBuffer object in the initList should be handled like
OpaqueType RWBuffer or Texture2D.
2020-10-01 10:21:01 -04:00
Jaebaek Seo b793c337a3
[spirv] support non-existing header file include (#3167) 2020-09-30 13:39:01 -04:00
Greg Roth 9459577e8f
Optimize compile times by not skipping allocas (#3168)
Instead of skipping past allocas whenever inserting a new insruction,
which ate up a lot of compilation time, they are inserted at the default
insertion point.

The result is that allocas that would have coallesced just after the
global load an input loads are dispersed throughout the commands. So as
part of dxil finalization, the allocas are moved to the beginning of the
entry block of each function. This results in some minor changes to a
couple tests due to the allocas preceding the loads.
2020-09-29 18:11:28 -07:00
Xiang Li 8e3b9e7ed5
Update Constant/TextureBuffer implementation. (#3147)
* Update Constant/TextureBuffer implementation.

* [spirv] Fixes needed for new Constant/TextureBuffer representation.


Co-authored-by: Ehsan Nasiri <ehsannas@gmail.com>
2020-09-25 18:04:33 -07:00
Jaebaek Seo 7f985ff472
[spirv] generate OpenCL.DebugInfo.100 instructions (#3155)
OpenCL.DebugInfo.100
is a SPIR-V extended instruction set that provides DWARF style debug information.
This PR allows DXC SPIR-V backend to generate the rich HLSL debug information
using OpenCL.DebugInfo.100 instructions.
2020-09-22 16:50:29 -04:00
Xiang Li 8266d38b23
Not init undef when recover init value for patch constant function. (#3141)
* Not init undef when recover init value for patch constant function.
Also lower ConstantAggregateZero directly when lower matrix.
2020-09-17 09:22:32 -07:00
Jeff Noyle 7e92bbc072
PIX value-to-declare pass: subprogram type members (#3140) 2020-09-17 09:17:51 -07:00
Tex Riddell c3fa785435
Remove assert.h include from DxilPipelineStateValidation.h (#3129)
Also:
- fixed size_t to uint32_t error when building with other tools.
- removed DxilPipelineStateValidation.h where unused.
2020-09-16 23:15:08 -07:00
Jeff Noyle 28499c66d9
autofilesys (#3120)
Co-authored-by: Jeff Noyle <jeffno@ntdev.microsoft.com>
2020-09-15 14:33:30 -07:00
luckyxxl e3a8344747
[spirv] Error on implicit-lod sampling in non-fragment shaders (#3128)
* [spirv] Error on implicit-lod sampling in non-fragment shaders

* formatting
2020-09-14 13:36:03 -05:00
Ehsan c2afcb7e81
[spirv] Handle corner cases of transpose and mul. (#3127)
Fixes #3109.
2020-09-14 10:44:13 -05:00
Ehsan 5adc55c72d
[spirv] CHECK for extensions in the user-type decoration test. (#3124) 2020-09-10 15:44:33 -05:00
Adam Yang 05115ab926
Taught [unroll] that barriers are safe to unroll (#3123) 2020-09-09 17:09:05 -07:00
Xiang Li 4446237655
Call ctor function for static globals in patch constant function. (#3122)
* Call ctor function for static globals in patch constant function.

* Also copy static globals which has const initialize value at beginning of patch constant.
2020-09-09 12:51:10 -07:00
Tex Riddell 8d9e1cbb86
Dxil.dll <= 1.5 compat: Fix RDAT break and validation tests (#3117)
Fix compatibility with released DXIL.dll binaries:
- 1.4: 18362 SDK
- 1.5: GitHub release v1.5.2003

There are expected test failures when run against 1.5 19041 SDK DXIL.dll,
due to later fixes in the GitHub v1.5.2003 release.  Tests that fail by
design on this DLL have a comment added.

Also moved readme text to more discoverable readme.
2020-09-08 13:52:14 -07:00
Ehsan c5e4626cf2
[spirv] Fix codegen for inout resource function parameters. (#3112) 2020-09-08 11:19:42 -05:00
Greg Roth 861a5a0e8e
Enhance ShaderOpTest (#3116)
Add support for mipmaps and mesh shaders
2020-09-05 07:03:30 -07:00
Xiang Li a730e27ade
Create global_ctor when link to lib target. (#3118) 2020-09-04 21:14:25 -07:00
Adam Yang 5d6674ad0a
Hoist exits out of loops when unrolling to make code structured. (#3103) 2020-09-04 13:57:36 -07:00
Ehsan fd65d32733
[spirv] Handle resource templated by vecc1. (#3098) 2020-09-03 14:26:43 -05:00
Ehsan 19d8514c8a
[spirv] Add needed capabilities for Raytracing AccelerationStructure. (#3104)
* [spirv] Add needed capabilities for Raytracing AccelerationStructure.

* Address code review comments.
2020-09-03 12:58:14 -05:00
Ehsan d2ecfeb065
[spirv] Error out if SV_InnerCoverage is not uint. (#3102) 2020-09-01 09:23:56 -05:00
Ehsan 8ffccecea1
[spirv] Support UnaryOperator for negating a matrix. (#3099) 2020-09-01 09:21:18 -05:00
Ehsan 2667e538d6
[spirv] Support boolean matrix as ternary condition. (#3096) 2020-09-01 09:19:22 -05:00
Adam Yang 0e77209223
Moved unroll to after dxilgen and scalarizer. (#3094) 2020-08-28 09:09:53 -07:00
Tex Riddell 530958e4b7
Fix NonUniform indexing of CBV array (#3095)
CBV array index uses special HL CreateHandle intrinsic for indexing
instead of GEP.  When TranslateNonUniformResourceIndex is marking GEPs
with metadata, there was no GEP to mark for CBV array.  This change
also marks HL CreateHandle calls when direct users of this intrinsic.
Later, in DxilGenerationPass, this HL CreateHandle call with the index
is translated to a GEP + CreateHandleForLib call.  This now adds the
non-uniform metadata to the GEP if the indexed HL CreateHandle call
being translated had it.
2020-08-21 19:35:30 -07:00
Greg Roth b3c14b2a7a
Remove unneeded rawbuf Ld/St return type reassign (#3086)
Prior to a more robust mechanism of handling types determined by
explicit templates in MatchArguments, a special case was made for
ByteAddressBuffer Loads that explicitly assigned the return type. When
the more reobust mechanism was added as part of support for
ByteAddressBuffer Store, not only was this explicit assignment left in,
but it was also applied to the new Store method. The result was an
assert later on a store operation that is expected to return void.

By removing this now unneeded assignment, the assert no longer fires and
nothing else is changed sonce the return value was never read apart from
that anyway.

Fixes #2438
2020-08-20 14:09:14 -07:00
Ehsan 0e04763f9e
[spirv] Handle invalid arg for residency code. (#3064)
* [spirv] Handle invalid arg for residency code.

Fixes #3045

* add comments about residencyCode.
2020-08-20 13:27:44 -05:00
Ehsan 3da289217c
[spirv] Fix memory leaks in the SPIR-V backend. (#3091)
* [spirv] Fix memory leaks in the SPIR-V backend.

* [spirv] Avoid leaking memory if there are failures during AST traversal.
2020-08-20 11:36:59 -05:00
Jaebaek Seo 0fb58c61ad
[spirv] support sizeof() (#3080)
* [spirv] support sizeof()

* Code review
2020-08-14 13:32:32 -05:00
Helena Kotas bb0295fcf7
Update highest shader model to 6.6 in execution tests (#3083) 2020-08-13 16:09:07 -07:00
David Peixotto 55b9194ccc
Modify the extension mechansim to handle custom lowering for resource… (#3081)
* Modify the extension mechansim to handle custom lowering for resource methods

The goal is to allow resource extension intrinsics to be handled the same way
as the core hlsl resource intrinsics.

Specifically, we want to support:

 1. Multiple hlsl overloads map to a single dxil intrinsic
 2. The hlsl overloads can take different parameters for a given resource type
 3. The hlsl overloads are not consistent across different resource types

To achieve these goals we need a more complex mechanism for describing how
to translate the high-level arguments to arguments for a dxil function.

This commit implements custom lowering by allowing the mapping from high-level
args to dxil args to be specified as extra information along with the
lowering strategy.

The custom lowering info describes this lowering using the following format.

* Add missing virtual destructors
2020-08-12 14:13:44 -07:00
Helena Kotas 467ee06124
Update highest supported shader model definition with newest Windows releases and move behind marker for shared DxilConf tests (#3075) 2020-08-12 11:22:22 -07:00
Greg Roth efc14a6c40
Sundry code cleanups (#3073)
refactor usage of resourceparams to just use RP

create common way of extracting res properties

make getoverloadtype static

so it can be used to determine version
requirements

Disallow literals where not included

Previously, whether an intrinsic parameter type included an entry for
literals or not, a literal was permitted to be cast to it.

By moving up the explicit per-param check to before this cast takes
place, these implicit casts won't be added
2020-08-12 08:16:12 -07:00
Jaebaek Seo b94ee767cc
[spirv] Hull shader output patch must be shared between threads (#3059)
The existing code uses the Function storage class for the output patch
of a hull shader that will be used by the patch constant function.
DirectX automatically transmits the output patch to the all threads,
which are identical between threads. Even though Vulkan does not have
the patch constant function, we can simulate it using the execution
barrier and the variable with WorkGroup storage class.
2020-08-07 10:10:44 -04:00
Greg Roth 03676eb639
Add load for argument matrix subscript lowering (#3065)
Matrix lowering was not handling subscript oeprations when the matrix
was a shader input. copying the matrix to a temporary explicitly or
implicitly as part of a copy in function call worked around the problem.
When the argument copy was eliminated, this problem was exposed.

By adding a load for the indicated matrix for a subscript of a shader
input matrix, the lowering can procede using the lowered matrix from the
load.

Additionally, hull shaders with their uninlineable functions were
failing to detect the constanthull function as a graphics function so
the subscript lowering was being treated as if it were in a library.
Even when it got to signature lowering, there was no support for
lowering matrix loads.

The test for shaderism now tests the function attributes of the module's
entry function. The signature lowering for matrix loads is moved into a
function that is called by input lowering for both the constant hull and
entry functions.

Added general tests for matrix subscripts from different memory types as
well as specific tests for the argument passing problem in pixel and
domain shaders.

A more correct way to identify functions that should delay the lowering
of their matrix parameters to signature lowering time is to query
whether the function has a signature. This covers entry functions for
graphics shaders and also constant patch functions.

Fixes #2958
2020-08-07 06:28:40 -07:00
Helena Kotas 55b847a221
Remove duplicate code for clipplanes attribute arguments parsing (#3067) 2020-08-05 19:20:30 -07:00
Xiang Li 3dfed82446
Remove 4 byte align on struct. (#3063) 2020-08-04 10:34:05 -07:00
Adam Yang c684cc0421
Added mechanism for extra file outputs (#3060) 2020-08-03 13:25:19 -07:00
Greg Roth cb0191d8db
Correct codegenoption assigning from semantic defines (#3061)
For structurize-returns, the codegenopts assigned were a copy of those
the compiler possesses. This is by design in clang as explicitly stated
in comments. As a result, when the compiler codegenopts are updated, the
codegenmodule's are not.

By adding the ability to query the optimization enables from the hlsl
extension helper, these options can be reflected.

Additionally, the structurize-returns flag would have required a define
with a '-' in it, which isn't possible. So now it converts between '_'
for defines and '-' for options, which is consistent with how other
flags are interpretted.

Adds a unit test similar to that of disable gvn that makes a simple
check to verify that the resturn structurization is enabled.
2020-08-01 19:53:24 -06:00
JiaoluAMD a17bd0e347
[SPIRV] Fix missing implicit decls (#3054)
* Add astcontext const decls to the astDecl table if not inserted before

Fix [SPIRV] Inline ray tracing doesn't compile #3047
1)Trying to add astcontext decls to the astDecls tables if decl is not
inserted before
2) Add the unit test of previously failed cs shader.

* [spirv] Create implicit constant VarDecls lazily.

Co-authored-by: Ehsan Nasiri <ehsannas@gmail.com>
2020-07-30 13:22:27 -05:00
Greg Roth 6971d25e1e
Restrict parameters to Interlocked* Intrinsics (#3057)
Because the defined types of Interlocked* Parameters do not restrict
type casting, they can result in late errors that cause crashes due to
reference params with casts that aren't actually respected by dxil
generation.

By constraining the parameters as they should be, instead of crashes, we
get errors.

Fixes #2077
Fixes #2483
2020-07-28 12:56:50 -07:00
Greg Roth b605355c3a
Verify valid intrinsic parameter casts (#3050)
In a couple of cases, intrinsics with parameters that weren't supposed
to allow casts were getting at least one parameter cast to a type not in
the accepted list.

Where an intrinsic referred to another parameter to determine
acceptable types, all parameters fed into a single parameter
representing the common type. If the first parameter was acceptable, but
the second wasn't, the second would get merged with the first regardless
of allowable casts. By checking the parameters before the merging is
performed, these failures are detected.

If an intrinsic call with valid arguments is followed by one
with invalid arguments, the second will be accepted and casts added to
convert to the existing intrinsic because it has already been added to
the list of possible overloads. By disallowing the function matching
code to match intrinsics, this can't happen. What's more, it prevents
confusing error messages when the overload is invalid but existing
overloads have already been seen. The failed overload is all that is
processed so the error is the same as if it were the first use of that
intrinsic.

Even when failures are correctly detected, the messages produced were
less than helpful. By fully defining HLSL intrinsic candidates even if
they fail and adding them to the candidateset, with an indication of
which parameter was faulty, the existing code will report about these
faulty candidates when no others are available.

Reshuffle some type lists to make literals not the default, which leads
to confusing error messages.

Add a bunch of tests for various ways intrinsics can fail due to
parameters.

Fixes #2693
Fixes #818
2020-07-28 09:26:52 -07:00
Greg Roth 41e5ba4448
Modify structurize returns option to use opt-enable (#3052)
This conforms to the established -opt-enable -opt-disable flag standard
to enable this optimization as well as tying in with the semantic
defines mechanism.
2020-07-27 22:19:45 -07:00
Ehsan 28af56515a
[spirv] Fix translation for WaveReadLaneAt. (#3056)
* [spirv] Fix translation for WaveReadLaneAt

WaveReadLaneAt should be translated to OpGroupNonUniformShuffle, not OpGroupNonUniformBroadcast.

* Add comments.
2020-07-27 15:30:33 -05:00
Adam Yang 9db52a7f01
Added hidden option to print after all passes (#3051) 2020-07-23 11:09:54 -07:00
Greg Roth 174fb21fa9
Allow double to WaveReadLaneFirst (#3053)
A single character omission made WaveReadLaneFirst lack double support.
This corrects that omission, evading the unneeded validation error and
adds a test that covers various types for various wave and quad
intrinsics.

Fixes #2501
2020-07-22 22:54:42 -06:00
Greg Roth 7fcb79be5c
Avoid constant expr from GEP create (#3046)
In SROA, we create a GEP and later expect it to be an Instruction.
However, if the indices are all constant, it will return a constant
expression, which crashes hard. By setting the flag added for just this
purpose, this is avoided.

This situation results when a second bitcast of a non POD type follows a
pair of memcpy replacements that propagate the global variable to the
bitcast operation. This test contrives a memcpy by assigning the global
to a local and then the bitcasts by passing the local into a function
call.
2020-07-22 12:58:09 -07:00
Greg Roth 92328d817a
Propagate CodeGen Options and Semantic Defines (#3040)
Adds to -opt-enable and -opt-select flags to the -opt-disable flag and
broadens the utility of all by storing the settings as strings instead
of booleans. -opt-select requires a parameter indicating the setting
name and another indicating the value.

options are repesented as lowercase until they are converted into
semantic defines in metadata. presence of semantic define prefixes
is no longer assumed when trying to write semantic defines to
metadata.

Semantic defines with the user-specified prefix will be propagated to
the corresponding -opt-<enable|disable|select> CodeGen option. 
This allows either way of specifying these options to have the
same effect.

Adds two tests to verify that semantic defines will be
detectable as codegen flags. Another verifies that correct errors are
produced for contradictory flags.
2020-07-21 08:50:42 -07:00
Helena Kotas 13961cfe1f
Removing unnecessary DisableThreadLibraryCalls() calls (#3042) 2020-07-15 21:03:05 -07:00
Jaebaek Seo 1ca25d515b
[spirv] Remove BufferBlock for array types (#3039)
* [spirv] Remove BufferBlock for array types

* Add a unit test

* code review
2020-07-15 11:12:05 -05:00