Skip to content

Commit

Permalink
[Backport to 13] Skip adding decorations for OpForward (#2529) (#2542)
Browse files Browse the repository at this point in the history
When a temporary `OpForward` instruction is needed during translation
to SPIR-V, do not add the decorations yet, as that would result in
duplicate decorations when the actual instruction is visited and the
`OpForward` is replaced by a real SPIR-V instruction.

The SPIR-V Validator has recently started checking for duplicate
decorations; this fixes some but not all issues arising from the new
checks.

Contributes to #2509

(cherry picked from commit a278313)
  • Loading branch information
svenvh authored Apr 25, 2024
1 parent 3e7de94 commit 093cf27
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/SPIRV/SPIRVWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,13 @@ SPIRVValue *LLVMToSPIRVBase::transValue(Value *V, SPIRVBasicBlock *BB,
isa<BinaryOperator>(V) || BB) &&
"Invalid SPIRV BB");

auto BV = transValueWithoutDecoration(V, BB, CreateForward, FuncTrans);
if (!BV || !transDecoration(V, BV))
auto *BV = transValueWithoutDecoration(V, BB, CreateForward, FuncTrans);
if (!BV)
return nullptr;
// Only translate decorations for non-forward instructions. Forward
// instructions will have their decorations translated when the actual
// instruction is seen and rewritten to a real SPIR-V instruction.
if (!BV->isForward() && !transDecoration(V, BV))
return nullptr;
StringRef Name = V->getName();
if (!Name.empty()) // Don't erase the name, which BM might already have
Expand Down

0 comments on commit 093cf27

Please sign in to comment.