KhronosGroup / SPIRV-LLVM-Translator

A tool and a library for bi-directional translation between SPIR-V and LLVM IR
Other
464 stars 208 forks source link

[Backport to 14] Avoid duplicate Alignment decorations (#2537) #2553

Closed svenvh closed 2 months ago

svenvh commented 2 months ago

The SPIR-V Validator has recently started checking for duplicate decorations. This commit fixes duplicate Alignment decorations that affected the test/read_image.cl test.

Alignment decorations have two potential sources during LLVM to SPIR-V translation: the instruction's alignment property and spirv.Decorations metadata. Handle both of these through the setAlignment method, so that duplicates can be avoided.

Calling setAlignment with different alignments for the same entity is probably an error, so add an assert.

Contributes to https://github.com/KhronosGroup/SPIRV-LLVM-Translator/issues/2509

(cherry picked from commit 926ca2ae84971661589c4f39ddff816618adc73c)