Skip to content

Commit 093cf27

Browse files
authored
[Backport to 13] Skip adding decorations for OpForward (#2529) (#2542)
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)
1 parent 3e7de94 commit 093cf27

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/SPIRV/SPIRVWriter.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,8 +1025,13 @@ SPIRVValue *LLVMToSPIRVBase::transValue(Value *V, SPIRVBasicBlock *BB,
10251025
isa<BinaryOperator>(V) || BB) &&
10261026
"Invalid SPIRV BB");
10271027

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

0 commit comments

Comments
 (0)