Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,13 +779,15 @@ class GlobalVariablePattern
auto linkage = storageClass == spirv::StorageClass::Private
? LLVM::Linkage::Private
: LLVM::Linkage::External;
StringAttr locationAttrName = op.getLocationAttrName();
IntegerAttr locationAttr = op.getLocationAttr();
auto newGlobalOp = rewriter.replaceOpWithNewOp<LLVM::GlobalOp>(
op, dstType, isConstant, linkage, op.getSymName(), Attribute(),
/*alignment=*/0, storageClassToAddressSpace(clientAPI, storageClass));

// Attach location attribute if applicable
if (op.getLocationAttr())
newGlobalOp->setAttr(op.getLocationAttrName(), op.getLocationAttr());
if (locationAttr)
newGlobalOp->setAttr(locationAttrName, locationAttr);

return success();
}
Expand Down Expand Up @@ -1426,7 +1428,6 @@ class SelectionPattern : public SPIRVToLLVMConversion<spirv::SelectionOp> {
headerBlock->getOperations().front());
if (!condBrOp)
return failure();
rewriter.eraseBlock(headerBlock);

// Branch from merge block to continue block.
auto *mergeBlock = op.getMergeBlock();
Expand All @@ -1444,6 +1445,7 @@ class SelectionPattern : public SPIRVToLLVMConversion<spirv::SelectionOp> {
falseBlock,
condBrOp.getFalseTargetOperands());

rewriter.eraseBlock(headerBlock);
rewriter.inlineRegionBefore(op.getBody(), continueBlock);
rewriter.replaceOp(op, continueBlock->getArguments());
return success();
Expand Down