@@ -57,6 +57,7 @@ SPDX-License-Identifier: MIT
57
57
#include " llvm/IR/DiagnosticPrinter.h"
58
58
#include " llvm/IR/Dominators.h"
59
59
#include " llvm/IR/Function.h"
60
+ #include " llvm/IR/GlobalVariable.h"
60
61
#include " llvm/IR/IRBuilder.h"
61
62
#include " llvm/IR/InstIterator.h"
62
63
#include " llvm/IR/InstVisitor.h"
@@ -313,8 +314,6 @@ struct CMABI : public CallGraphSCCPass {
313
314
314
315
bool runOnSCC (CallGraphSCC &SCC) override ;
315
316
316
- bool doFinalization (CallGraph &CG) override ;
317
-
318
317
private:
319
318
320
319
CallGraphNode *ProcessNode (CallGraphNode *CGN);
@@ -390,21 +389,6 @@ bool CMABIAnalysis::runOnCallGraph(CallGraph &CG) {
390
389
return false ;
391
390
}
392
391
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
-
408
392
bool CMABI::runOnSCC (CallGraphSCC &SCC) {
409
393
Info = &getAnalysis<CMABIAnalysis>();
410
394
bool Changed = false ;
@@ -1383,14 +1367,6 @@ void CMABIAnalysis::defineGVDirectUsers(GlobalVariable &GV) {
1383
1367
// copy-in and copy-out arguments.
1384
1368
void CMABIAnalysis::analyzeGlobals (CallGraph &CG) {
1385
1369
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
- }
1394
1370
for (auto & F : M.getFunctionList ()) {
1395
1371
if (F.isDeclaration () || F.hasDLLExportStorageClass ())
1396
1372
continue ;
0 commit comments