Skip to content

Commit 9381d84

Browse files
mshelegoArtem Gindinson
authored andcommitted
Show warning on @llvm.global.annotations usage
In case @llvm.global.annotations is used, parse its contents and show a warning about ignored annotations. Also update the function pointer in the structure when the function is rewritten
1 parent b099f34 commit 9381d84

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXCisaBuilder.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6296,6 +6296,27 @@ void GenXKernelBuilder::buildStackCallLight(CallInst *CI,
62966296
}
62976297
}
62986298

6299+
static void dumpGlobalAnnotations(Module &M) {
6300+
auto *GV = M.getGlobalVariable("llvm.global.annotations");
6301+
if (!GV)
6302+
return;
6303+
auto *Array = dyn_cast<ConstantArray>(GV->getOperand(0));
6304+
for (const auto &Op : Array->operands()) {
6305+
auto *Struct = dyn_cast<ConstantStruct>(Op.get());
6306+
auto *Func = dyn_cast<Function>(Struct->getOperand(0)->getOperand(0));
6307+
if (!Func)
6308+
continue;
6309+
auto FuncName = Func->getName();
6310+
assert(!FuncName.empty() && "Annotated function must have a name");
6311+
auto *GlobalStr =
6312+
dyn_cast<GlobalVariable>(Struct->getOperand(1)->getOperand(0));
6313+
auto *Str = dyn_cast<ConstantDataArray>(GlobalStr->getInitializer());
6314+
auto FuncAnnotation = Str->getAsString();
6315+
errs() << "Warning: Annotation \"" << FuncAnnotation << "\" for function "
6316+
<< FuncName << " is ignored\n";
6317+
}
6318+
}
6319+
62996320
namespace {
63006321

63016322
class GenXFinalizer : public ModulePass {
@@ -6338,6 +6359,8 @@ class GenXFinalizer : public ModulePass {
63386359

63396360
Out << ss.str();
63406361

6362+
dumpGlobalAnnotations(M);
6363+
63416364
// Collect some useful statistics
63426365
for (auto *FG: FGA) {
63436366
VISAKernel *Kernel = CisaBuilder->GetVISAKernel(FG->getName().str());

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,9 @@ CMImpParam::processKernelParameters(Function *F,
12131213
KM.updateArgKindsMD(std::move(ArgKinds));
12141214
KM.updateLinearizationMD(std::move(LinearizedArgs));
12151215

1216+
F->mutateType(NF->getType());
1217+
F->replaceAllUsesWith(NF);
1218+
12161219
// Now that the old function is dead, delete it. If there is a dangling
12171220
// reference to the CallGraphNode, just leave the dead function around
12181221
NF_CGN->stealCalledFunctionsFrom(CG[F]);

0 commit comments

Comments
 (0)