Skip to content

Commit 7f349ad

Browse files
dmitryryinteligcbot
authored andcommitted
Stop changing global variable linkage in CMABI
Also only private or internal global variables can be removed by CMABI now.
1 parent bc879c7 commit 7f349ad

File tree

1 file changed

+1
-25
lines changed
  • IGC/VectorCompiler/lib/GenXOpts/CMTrans

1 file changed

+1
-25
lines changed

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

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ SPDX-License-Identifier: MIT
5757
#include "llvm/IR/DiagnosticPrinter.h"
5858
#include "llvm/IR/Dominators.h"
5959
#include "llvm/IR/Function.h"
60+
#include "llvm/IR/GlobalVariable.h"
6061
#include "llvm/IR/IRBuilder.h"
6162
#include "llvm/IR/InstIterator.h"
6263
#include "llvm/IR/InstVisitor.h"
@@ -313,8 +314,6 @@ struct CMABI : public CallGraphSCCPass {
313314

314315
bool runOnSCC(CallGraphSCC &SCC) override;
315316

316-
bool doFinalization(CallGraph &CG) override;
317-
318317
private:
319318

320319
CallGraphNode *ProcessNode(CallGraphNode *CGN);
@@ -390,21 +389,6 @@ bool CMABIAnalysis::runOnCallGraph(CallGraph &CG) {
390389
return false;
391390
}
392391

393-
bool CMABI::doFinalization(CallGraph &CG) {
394-
bool Changed = false;
395-
for (Module::global_iterator I = CG.getModule().global_begin();
396-
I != CG.getModule().global_end();
397-
/*empty*/) {
398-
GlobalVariable *GV = &*I++;
399-
if (GV->use_empty()) {
400-
GV->eraseFromParent();
401-
Changed = true;
402-
}
403-
}
404-
405-
return Changed;
406-
}
407-
408392
bool CMABI::runOnSCC(CallGraphSCC &SCC) {
409393
Info = &getAnalysis<CMABIAnalysis>();
410394
bool Changed = false;
@@ -1383,14 +1367,6 @@ void CMABIAnalysis::defineGVDirectUsers(GlobalVariable &GV) {
13831367
// copy-in and copy-out arguments.
13841368
void CMABIAnalysis::analyzeGlobals(CallGraph &CG) {
13851369
Module &M = CG.getModule();
1386-
// assuming the device module is self-contained,
1387-
// set internal-linkage for global variables
1388-
// and functions so globla-DCE can remove them
1389-
// if there is no use in the module.
1390-
for (auto& Global : M.getGlobalList()) {
1391-
if (!Global.isDeclaration())
1392-
Global.setLinkage(GlobalValue::InternalLinkage);
1393-
}
13941370
for (auto& F : M.getFunctionList()) {
13951371
if (F.isDeclaration() || F.hasDLLExportStorageClass())
13961372
continue;

0 commit comments

Comments
 (0)