llvm.org GIT mirror llvm / 93639fb
Merge from mainline. Pre-alloc splitting needs to be more careful to avoid inserting spills/restores between call frame setup/restore points. Unfortunately, this regresses code size a bit, but at least it's correct now! git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_25@64508 91177308-0d34-0410-b5e6-96231b3b80d8 Tanya Lattner 11 years ago
1 changed file(s) with 73 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
227227 ++MII;
228228 unsigned Index = LIs->getInstructionIndex(MII);
229229 unsigned Gap = LIs->findGapBeforeInstr(Index);
230 if (Gap) {
230
231 // We can't insert the spill between the barrier (a call), and its
232 // corresponding call frame setup/teardown.
233 if (prior(MII)->getOpcode() == TRI->getCallFrameSetupOpcode()) {
234 bool reachedBarrier = false;
235 do {
236 if (MII == EndPt) {
237 reachedBarrier = true;
238 break;
239 }
240 ++MII;
241 } while (MII->getOpcode() != TRI->getCallFrameDestroyOpcode());
242
243 if (reachedBarrier) break;
244 } else if (Gap) {
231245 Pt = MII;
232246 SpillIndex = Gap;
233247 break;
234
235 // We can't insert the spill between the barrier (a call), and its
236 // corresponding call frame setup.
237 } else if (prior(MII)->getOpcode() == TRI->getCallFrameSetupOpcode() &&
238 MII == MachineBasicBlock::iterator(MI))
239 break;
248 }
240249 } while (MII != EndPt);
241250 } else {
242251 MachineBasicBlock::iterator MII = MI;
243252 MachineBasicBlock::iterator EndPt = DefMI
244253 ? MachineBasicBlock::iterator(DefMI) : MBB->begin();
245254
246 // We can't insert the spill between the barrier (a call), and its
247 // corresponding call frame setup.
248 if (prior(MII)->getOpcode() == TRI->getCallFrameSetupOpcode()) --MII;
249255 while (MII != EndPt && !RefsInMBB.count(MII)) {
250256 unsigned Index = LIs->getInstructionIndex(MII);
251 if (LIs->hasGapBeforeInstr(Index)) {
257
258 // We can't insert the spill between the barrier (a call), and its
259 // corresponding call frame setup.
260 if (prior(MII)->getOpcode() == TRI->getCallFrameSetupOpcode()) {
261 --MII;
262 continue;
263 } if (MII->getOpcode() == TRI->getCallFrameDestroyOpcode()) {
264 bool reachedBarrier = false;
265 while (MII->getOpcode() != TRI->getCallFrameSetupOpcode()) {
266 --MII;
267 if (MII == EndPt) {
268 reachedBarrier = true;
269 break;
270 }
271 }
272
273 if (reachedBarrier) break;
274 else continue;
275 } else if (LIs->hasGapBeforeInstr(Index)) {
252276 Pt = MII;
253277 SpillIndex = LIs->findGapBeforeInstr(Index, true);
254278 }
282306 do {
283307 unsigned Index = LIs->getInstructionIndex(MII);
284308 unsigned Gap = LIs->findGapBeforeInstr(Index);
285 if (Gap) {
309
310 // We can't insert a restore between the barrier (a call) and its
311 // corresponding call frame teardown.
312 if (MII->getOpcode() == TRI->getCallFrameDestroyOpcode()) {
313 bool reachedBarrier = false;
314 while (MII->getOpcode() != TRI->getCallFrameSetupOpcode()) {
315 --MII;
316 if (MII == EndPt) {
317 reachedBarrier = true;
318 break;
319 }
320 }
321
322 if (reachedBarrier) break;
323 else continue;
324 } else if (Gap) {
286325 Pt = MII;
287326 RestoreIndex = Gap;
288327 break;
289
290 // We can't insert a restore between the barrier (a call) and its
291 // corresponding call frame teardown.
292 } else if (MII->getOpcode() == TRI->getCallFrameDestroyOpcode() &&
293 prior(MII) == MachineBasicBlock::iterator(MI))
294 break;
328 }
329
295330 --MII;
296331 } while (MII != EndPt);
297332 } else {
298333 MachineBasicBlock::iterator MII = MI;
299334 MII = ++MII;
300 // We can't insert a restore between the barrier (a call) and its
301 // corresponding call frame teardown.
302 if (MII->getOpcode() == TRI->getCallFrameDestroyOpcode())
303 ++MII;
304335
305336 // FIXME: Limit the number of instructions to examine to reduce
306337 // compile time?
309340 if (Index > LastIdx)
310341 break;
311342 unsigned Gap = LIs->findGapBeforeInstr(Index);
312 if (Gap) {
343
344 // We can't insert a restore between the barrier (a call) and its
345 // corresponding call frame teardown.
346 if (MII->getOpcode() == TRI->getCallFrameDestroyOpcode()) {
347 ++MII;
348 continue;
349 } else if (prior(MII)->getOpcode() == TRI->getCallFrameSetupOpcode()) {
350 bool reachedBarrier = false;
351 do {
352 if (MII == MBB->getFirstTerminator() || RefsInMBB.count(MII)) {
353 reachedBarrier = true;
354 break;
355 }
356
357 ++MII;
358 } while (MII->getOpcode() != TRI->getCallFrameDestroyOpcode());
359
360 if (reachedBarrier) break;
361 } else if (Gap) {
313362 Pt = MII;
314363 RestoreIndex = Gap;
315364 }
365
316366 if (RefsInMBB.count(MII))
317367 break;
318368 ++MII;