Skip to content

Commit a4ac292

Browse files
committed
Enforce UserSemantic decoration if no FPGA decorations found
Signed-off-by: Dmitry Sidorov <[email protected]>
1 parent 2f81f31 commit a4ac292

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

lib/SPIRV/SPIRVReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3425,7 +3425,7 @@ void SPIRVToLLVM::transIntelFPGADecorations(SPIRVValue *BV, Value *V) {
34253425
isStaticMemoryAttribute
34263426
? llvm::Intrinsic::getDeclaration(M, Intrinsic::var_annotation)
34273427
: llvm::Intrinsic::getDeclaration(M, Intrinsic::ptr_annotation,
3428-
AllocatedTy);
3428+
BaseInst->getType());
34293429

34303430
llvm::Value *Args[] = {BaseInst,
34313431
Builder.CreateBitCast(GS, Int8PtrTyPrivate),

lib/SPIRV/SPIRVWriter.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2313,6 +2313,11 @@ AnnotationDecorations tryParseAnnotationString(SPIRVModule *BM,
23132313
RegexIterT DecorationsIt(AnnotatedCode.begin(), AnnotatedCode.end(),
23142314
DecorationRegex);
23152315
RegexIterT DecorationsEnd;
2316+
// If we didn't find any FPGA specific annotations then add a UserSemantic
2317+
// decoration
2318+
if (DecorationsIt == DecorationsEnd)
2319+
Decorates.MemoryAttributesVec.emplace_back(DecorationUserSemantic,
2320+
AnnotatedCode.str());
23162321
for (; DecorationsIt != DecorationsEnd; ++DecorationsIt) {
23172322
// Drop the braces surrounding the actual decoration
23182323
const StringRef AnnotatedDecoration = AnnotatedCode.substr(
@@ -2360,7 +2365,7 @@ AnnotationDecorations tryParseAnnotationString(SPIRVModule *BM,
23602365
.Case("force_pow2_depth", DecorationForcePow2DepthINTEL)
23612366
.Default(DecorationUserSemantic);
23622367
if (Dec == DecorationUserSemantic)
2363-
Annotation = AnnotatedDecoration;
2368+
Annotation = AnnotatedCode;
23642369
else
23652370
Annotation = ValueStr;
23662371
}

test/transcoding/annotate_attribute.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
66
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
77

8+
; Check that even when FPGA memory extensions are enabled - yet we have
9+
; UserSemantic decoration be generated
10+
; RUN: llvm-as %s -o %t.bc
11+
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_fpga_memory_accesses,+SPV_INTEL_fpga_memory_attributes -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
12+
813
; Check SPIR-V versions in a format magic number + version
914
; CHECK-SPIRV: 119734787 66560
1015

0 commit comments

Comments
 (0)