Skip to content

Commit 7c5e2ed

Browse files
svenvhsys-ce-bb
authored andcommitted
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 KhronosGroup/SPIRV-LLVM-Translator#2509 Original commit: KhronosGroup/SPIRV-LLVM-Translator@a2783135be3f37f
1 parent 8fa9b4e commit 7c5e2ed

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

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

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

0 commit comments

Comments
 (0)