Skip to content

Commit f6d9d44

Browse files
mateuszchudykigcbot
authored andcommitted
PromoteBools pass - duplicate globalVariable's metadatas after promotion
PromoteBools pass - duplicate globalVariable's metadatas after promotion
1 parent dd37e5b commit f6d9d44

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

IGC/AdaptorOCL/preprocess_spvir/PromoteBools.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ GlobalVariable* PromoteBools::promoteGlobalVariable(GlobalVariable* globalVariab
582582
return globalVariable;
583583
}
584584

585-
return new GlobalVariable(
585+
auto newGlobalVariable = new GlobalVariable(
586586
*globalVariable->getParent(),
587587
getOrCreatePromotedType(IGCLLVM::getNonOpaquePtrEltTy(globalVariable->getType())),
588588
globalVariable->isConstant(),
@@ -592,6 +592,15 @@ GlobalVariable* PromoteBools::promoteGlobalVariable(GlobalVariable* globalVariab
592592
nullptr,
593593
GlobalValue::ThreadLocalMode::NotThreadLocal,
594594
globalVariable->getType()->getPointerAddressSpace());
595+
596+
// Clone metadatas
597+
SmallVector<std::pair<unsigned, MDNode*>, 8> metadatas;
598+
globalVariable->getAllMetadata(metadatas);
599+
for (const auto& metadata : metadatas)
600+
{
601+
newGlobalVariable->addMetadata(metadata.first, *metadata.second);
602+
}
603+
return newGlobalVariable;
595604
}
596605

597606
Constant* PromoteBools::promoteConstant(Constant* constant)

0 commit comments

Comments
 (0)