Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Transforms/IPO/GlobalOpt.cpp
Show First 20 Lines • Show All 885 Lines • ▼ Show 20 Lines | new GlobalVariable(Type::getInt1Ty(GV->getContext()), false, | ||||
ConstantInt::getFalse(GV->getContext()), | ConstantInt::getFalse(GV->getContext()), | ||||
GV->getName()+".init", GV->getThreadLocalMode()); | GV->getName()+".init", GV->getThreadLocalMode()); | ||||
bool InitBoolUsed = false; | bool InitBoolUsed = false; | ||||
// Loop over all uses of GV, processing them in turn. | // Loop over all uses of GV, processing them in turn. | ||||
while (!GV->use_empty()) { | while (!GV->use_empty()) { | ||||
if (StoreInst *SI = dyn_cast<StoreInst>(GV->user_back())) { | if (StoreInst *SI = dyn_cast<StoreInst>(GV->user_back())) { | ||||
// The global is initialized when the store to it occurs. | // The global is initialized when the store to it occurs. | ||||
new StoreInst(ConstantInt::getTrue(GV->getContext()), InitBool, false, 0, | new StoreInst(ConstantInt::getTrue(GV->getContext()), InitBool, false, | ||||
SI->getOrdering(), SI->getSyncScopeID(), SI); | None, SI->getOrdering(), SI->getSyncScopeID(), SI); | ||||
SI->eraseFromParent(); | SI->eraseFromParent(); | ||||
continue; | continue; | ||||
} | } | ||||
LoadInst *LI = cast<LoadInst>(GV->user_back()); | LoadInst *LI = cast<LoadInst>(GV->user_back()); | ||||
while (!LI->use_empty()) { | while (!LI->use_empty()) { | ||||
Use &LoadUse = *LI->use_begin(); | Use &LoadUse = *LI->use_begin(); | ||||
ICmpInst *ICI = dyn_cast<ICmpInst>(LoadUse.getUser()); | ICmpInst *ICI = dyn_cast<ICmpInst>(LoadUse.getUser()); | ||||
▲ Show 20 Lines • Show All 817 Lines • ▼ Show 20 Lines | if (StoreInst *SI = dyn_cast<StoreInst>(UI)) { | ||||
} else { | } else { | ||||
assert((isa<CastInst>(StoredVal) || isa<SelectInst>(StoredVal)) && | assert((isa<CastInst>(StoredVal) || isa<SelectInst>(StoredVal)) && | ||||
"This is not a form that we understand!"); | "This is not a form that we understand!"); | ||||
StoreVal = StoredVal->getOperand(0); | StoreVal = StoredVal->getOperand(0); | ||||
assert(isa<LoadInst>(StoreVal) && "Not a load of NewGV!"); | assert(isa<LoadInst>(StoreVal) && "Not a load of NewGV!"); | ||||
} | } | ||||
} | } | ||||
StoreInst *NSI = | StoreInst *NSI = | ||||
new StoreInst(StoreVal, NewGV, false, 0, SI->getOrdering(), | new StoreInst(StoreVal, NewGV, false, None, SI->getOrdering(), | ||||
SI->getSyncScopeID(), SI); | SI->getSyncScopeID(), SI); | ||||
NSI->setDebugLoc(SI->getDebugLoc()); | NSI->setDebugLoc(SI->getDebugLoc()); | ||||
} else { | } else { | ||||
// Change the load into a load of bool then a select. | // Change the load into a load of bool then a select. | ||||
LoadInst *LI = cast<LoadInst>(UI); | LoadInst *LI = cast<LoadInst>(UI); | ||||
LoadInst *NLI = new LoadInst(NewGV->getValueType(), NewGV, | LoadInst *NLI = new LoadInst(NewGV->getValueType(), NewGV, | ||||
LI->getName() + ".b", false, None, | LI->getName() + ".b", false, None, | ||||
LI->getOrdering(), LI->getSyncScopeID(), LI); | LI->getOrdering(), LI->getSyncScopeID(), LI); | ||||
▲ Show 20 Lines • Show All 1,309 Lines • Show Last 20 Lines |