diff options
Diffstat (limited to 'lib/Transforms/IPO/GlobalOpt.cpp')
-rw-r--r-- | lib/Transforms/IPO/GlobalOpt.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 1761d7faff57..3005aafd06b1 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -1710,19 +1710,25 @@ static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) { assert(isa<LoadInst>(StoreVal) && "Not a load of NewGV!"); } } - new StoreInst(StoreVal, NewGV, false, 0, - SI->getOrdering(), SI->getSyncScopeID(), SI); + StoreInst *NSI = + new StoreInst(StoreVal, NewGV, false, 0, SI->getOrdering(), + SI->getSyncScopeID(), SI); + NSI->setDebugLoc(SI->getDebugLoc()); } else { // Change the load into a load of bool then a select. LoadInst *LI = cast<LoadInst>(UI); LoadInst *NLI = new LoadInst(NewGV, LI->getName()+".b", false, 0, LI->getOrdering(), LI->getSyncScopeID(), LI); - Value *NSI; + Instruction *NSI; if (IsOneZero) NSI = new ZExtInst(NLI, LI->getType(), "", LI); else NSI = SelectInst::Create(NLI, OtherVal, InitVal, "", LI); NSI->takeName(LI); + // Since LI is split into two instructions, NLI and NSI both inherit the + // same DebugLoc + NLI->setDebugLoc(LI->getDebugLoc()); + NSI->setDebugLoc(LI->getDebugLoc()); LI->replaceAllUsesWith(NSI); } UI->eraseFromParent(); @@ -2107,6 +2113,13 @@ static bool hasChangeableCC(Function *F) { if (CC != CallingConv::C && CC != CallingConv::X86_ThisCall) return false; + // Don't break the invariant that the inalloca parameter is the only parameter + // passed in memory. + // FIXME: GlobalOpt should remove inalloca when possible and hoist the dynamic + // alloca it uses to the entry block if possible. + if (F->getAttributes().hasAttrSomewhere(Attribute::InAlloca)) + return false; + // FIXME: Change CC for the whole chain of musttail calls when possible. // // Can't change CC of the function that either has musttail calls, or is a |