Deleted Added
full compact
GlobalOpt.cpp (193323) GlobalOpt.cpp (193630)
1//===- GlobalOpt.cpp - Optimize Global Variables --------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 918 unchanged lines hidden (view full) ---

927/// ValueIsOnlyUsedLocallyOrStoredToOneGlobal - Scan the use-list of V checking
928/// to make sure that there are no complex uses of V. We permit simple things
929/// like dereferencing the pointer, but not storing through the address, unless
930/// it is to the specified global.
931static bool ValueIsOnlyUsedLocallyOrStoredToOneGlobal(Instruction *V,
932 GlobalVariable *GV,
933 SmallPtrSet<PHINode*, 8> &PHIs) {
934 for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E;++UI){
1//===- GlobalOpt.cpp - Optimize Global Variables --------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 918 unchanged lines hidden (view full) ---

927/// ValueIsOnlyUsedLocallyOrStoredToOneGlobal - Scan the use-list of V checking
928/// to make sure that there are no complex uses of V. We permit simple things
929/// like dereferencing the pointer, but not storing through the address, unless
930/// it is to the specified global.
931static bool ValueIsOnlyUsedLocallyOrStoredToOneGlobal(Instruction *V,
932 GlobalVariable *GV,
933 SmallPtrSet<PHINode*, 8> &PHIs) {
934 for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E;++UI){
935 Instruction *Inst = dyn_cast<Instruction>(*UI);
936 if (Inst == 0) return false;
935 Instruction *Inst = cast(*UI);
937
938 if (isa<LoadInst>(Inst) || isa<CmpInst>(Inst)) {
939 continue; // Fine, ignore.
940 }
941
942 if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) {
943 if (SI->getOperand(0) == V && SI->getOperand(1) != GV)
944 return false; // Storing the pointer itself... bad.

--- 1541 unchanged lines hidden ---
936
937 if (isa<LoadInst>(Inst) || isa<CmpInst>(Inst)) {
938 continue; // Fine, ignore.
939 }
940
941 if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) {
942 if (SI->getOperand(0) == V && SI->getOperand(1) != GV)
943 return false; // Storing the pointer itself... bad.

--- 1541 unchanged lines hidden ---