Skip to content

Commit 4d1b7bb

Browse files
committed
[Autobackout][FuncReg]Revert of change: 89fc074
Partial revert to remove changes that adds external global variables to the symbol table. Change-Id: I01d80ac9903e96bf962ef00f4586e130a713f9ec
1 parent b134d82 commit 4d1b7bb

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4632,18 +4632,26 @@ namespace IGC
46324632
for (auto global : modMD->inlineProgramScopeOffsets)
46334633
{
46344634
GlobalVariable* pGlobal = global.first;
4635-
bool needRelocation = false;
4636-
for (auto ui = pGlobal->user_begin(), ue = pGlobal->user_end(); ui != ue; ui++)
4635+
4636+
// Create symbol for external globals
4637+
bool needSymbol = (pGlobal->getLinkage() == GlobalValue::ExternalLinkage) || (pGlobal->getLinkage() == GlobalValue::CommonLinkage);
4638+
if (!needSymbol)
46374639
{
4638-
// Check if need relocation
4639-
Instruction* inst = dyn_cast<Instruction>(*ui);
4640-
if (inst && inst->getParent()->getParent()->hasFnAttribute("EnableGlobalRelocation"))
4640+
pGlobal->removeDeadConstantUsers();
4641+
// Also need to create symbol if it requires relocation
4642+
for (auto ui = pGlobal->user_begin(), ue = pGlobal->user_end(); ui != ue; ui++)
46414643
{
4642-
needRelocation = true;
4643-
break;
4644+
// Check if need relocation
4645+
Instruction* inst = dyn_cast<Instruction>(*ui);
4646+
if (inst && inst->getParent()->getParent()->hasFnAttribute("EnableGlobalRelocation"))
4647+
{
4648+
needSymbol = true;
4649+
break;
4650+
}
46444651
}
46454652
}
4646-
if (needRelocation)
4653+
4654+
if (needSymbol)
46474655
{
46484656
StringRef name = pGlobal->getName();
46494657
unsigned addrSpace = pGlobal->getType()->getAddressSpace();

IGC/Compiler/Optimizer/OpenCLPasses/ProgramScopeConstants/ProgramScopeConstantAnalysis.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,10 @@ bool ProgramScopeConstantAnalysis::runOnModule(Module& M)
110110
continue;
111111
}
112112

113-
// If this variable isn't used, don't add it to the buffer.
114-
if (globalVar->use_empty())
113+
// If this variable isn't used and not exposed externally, don't add it to the buffer.
114+
if (globalVar->use_empty() &&
115+
globalVar->getLinkage() != GlobalValue::CommonLinkage &&
116+
globalVar->getLinkage() != GlobalValue::ExternalLinkage)
115117
{
116118
continue;
117119
}

0 commit comments

Comments
 (0)