Remove two unused includes and C++11 rangify for loops.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246865 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Yaron Keren 2015-09-04 20:24:24 +00:00
parent 51a8f7d972
commit e0517c5848

View File

@ -15,9 +15,7 @@
#include "llvm/Transforms/IPO.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
#include "llvm/Transforms/Utils/CtorUtils.h"
#include "llvm/Transforms/Utils/GlobalStatus.h"
#include "llvm/Pass.h"
using namespace llvm;
@ -54,29 +52,28 @@ bool EliminateAvailableExternally::runOnModule(Module &M) {
bool Changed = false;
// Drop initializers of available externally global variables.
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
I != E; ++I) {
if (!I->hasAvailableExternallyLinkage())
for (GlobalVariable &GV :M.globals()) {
if (!GV.hasAvailableExternallyLinkage())
continue;
if (I->hasInitializer()) {
Constant *Init = I->getInitializer();
I->setInitializer(nullptr);
if (GV.hasInitializer()) {
Constant *Init = GV.getInitializer();
GV.setInitializer(nullptr);
if (isSafeToDestroyConstant(Init))
Init->destroyConstant();
}
I->removeDeadConstantUsers();
I->setLinkage(GlobalValue::ExternalLinkage);
GV.removeDeadConstantUsers();
GV.setLinkage(GlobalValue::ExternalLinkage);
NumVariables++;
}
// Drop the bodies of available externally functions.
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
if (!I->hasAvailableExternallyLinkage())
for (Function &F : M) {
if (!F.hasAvailableExternallyLinkage())
continue;
if (!I->isDeclaration())
if (!F.isDeclaration())
// This will set the linkage to external
I->deleteBody();
I->removeDeadConstantUsers();
F.deleteBody();
F.removeDeadConstantUsers();
NumFunctions++;
}