Skip to content

Commit 30ae5f0

Browse files
dmitryryinteligcbot
authored andcommitted
Handle attributes in printf legalization
VCPrintfStringVariable attribute must be moved to cloned GV during printf legalization as now this variable is used in printf the original variable is no longer used in printf.
1 parent efee891 commit 30ae5f0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

IGC/VectorCompiler/lib/GenXOpts/CMTrans/GenXPrintfLegalization.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,16 @@ static GlobalVariable &cloneString(GlobalVariable &OrigGV) {
175175
// Avoiding constants merging.
176176
OrigGV.setUnnamedAddr(GlobalValue::UnnamedAddr::None);
177177
ClonedGV->setAlignment(IGCLLVM::getAlign(OrigGV));
178+
179+
// Handle attributes.
180+
IGC_ASSERT_MESSAGE(
181+
OrigGV.hasAttribute(PrintfStringVariable),
182+
"original GV must already have the attribute before the cloning");
183+
auto OrigAttrs = OrigGV.getAttributes();
184+
OrigAttrs =
185+
OrigAttrs.removeAttribute(OrigGV.getContext(), PrintfStringVariable);
186+
OrigGV.setAttributes(OrigAttrs);
187+
ClonedGV->addAttribute(PrintfStringVariable);
178188
return *ClonedGV;
179189
}
180190

0 commit comments

Comments
 (0)