Remove useless statistic, fix some slightly broken logic

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14958 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2004-07-18 07:22:58 +00:00
parent 5827aebe64
commit 25c6d68029

View File

@ -26,7 +26,6 @@ using namespace llvm;
namespace { namespace {
Statistic<> NumFunctions("globaldce","Number of functions removed"); Statistic<> NumFunctions("globaldce","Number of functions removed");
Statistic<> NumVariables("globaldce","Number of global variables removed"); Statistic<> NumVariables("globaldce","Number of global variables removed");
Statistic<> NumGVs("globaldce", "Number of global values removed");
struct GlobalDCE : public Pass { struct GlobalDCE : public Pass {
// run - Do the GlobalDCE pass on the specified module, optionally updating // run - Do the GlobalDCE pass on the specified module, optionally updating
@ -171,13 +170,10 @@ void GlobalDCE::MarkUsedGlobalsAsNeeded(Constant *C) {
// might make it deader. // might make it deader.
// //
bool GlobalDCE::RemoveUnusedGlobalValue(GlobalValue &GV) { bool GlobalDCE::RemoveUnusedGlobalValue(GlobalValue &GV) {
for (Value::use_iterator I = GV.use_begin(), E = GV.use_end(); I != E; ++I) if (GV.use_empty()) return false;
if (GlobalValue* User = dyn_cast<GlobalValue>(*I)) GV.removeDeadConstantUsers();
if (User->removeDeadConstantUsers()) { // Only if unreferenced... return GV.use_empty();
++NumGVs; }
}
return false;
}
// SafeToDestroyConstant - It is safe to destroy a constant iff it is only used // SafeToDestroyConstant - It is safe to destroy a constant iff it is only used
// by constants itself. Note that constants cannot be cyclic, so this test is // by constants itself. Note that constants cannot be cyclic, so this test is