Skip to content

Commit a278313

Browse files
authored
Skip adding decorations for OpForward (#2529)
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
1 parent 3dd108b commit a278313

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/SPIRV/SPIRVWriter.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,12 @@ SPIRVValue *LLVMToSPIRVBase::transValue(Value *V, SPIRVBasicBlock *BB,
14541454
"Invalid SPIRV BB");
14551455

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

0 commit comments

Comments
 (0)