diff --git a/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp b/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp index 25988f58ea76d..5cc55bca85d5b 100644 --- a/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp +++ b/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp @@ -563,10 +563,11 @@ SPIRVFunction *LLVMToSPIRV::transFunctionDecl(Function *F) { // Order of integer numbers in MD node follows the order of function // parameters on which we shall attach the appropriate decoration. Add // decoration only if MD value is not negative. - BM->addCapability(CapabilityFPGABufferLocationINTEL); int LocID = getMDOperandAsInt(BufferLocation, ArgNo); - if (LocID >= 0) + if (LocID >= 0) { + BM->addCapability(CapabilityFPGABufferLocationINTEL); BA->addDecorate(DecorationBufferLocationINTEL, LocID); + } } } if (Attrs.hasAttribute(AttributeList::ReturnIndex, Attribute::ZExt))