]> granicus.if.org Git - llvm/commitdiff
[AVR] When lowering shifts into loops, put newly generated MBBs in the same
authorDylan McKay <me@dylanmckay.io>
Tue, 26 Sep 2017 00:51:03 +0000 (00:51 +0000)
committerDylan McKay <me@dylanmckay.io>
Tue, 26 Sep 2017 00:51:03 +0000 (00:51 +0000)
spot as the original MBB

Discovered in avr-rust/rust#62
https://github.com/avr-rust/rust/issues/62

Patch by Gergo Erdi.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314180 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AVR/AVRISelLowering.cpp

index ab49cf9de897cd0a5598dd5e03854560951896cc..50255f3ae676598030c14510c1a01da5edad72dd 100644 (file)
@@ -1469,8 +1469,10 @@ MachineBasicBlock *AVRTargetLowering::insertShift(MachineInstr &MI,
   }
 
   const BasicBlock *LLVM_BB = BB->getBasicBlock();
-  MachineFunction::iterator I = BB->getParent()->begin();
-  ++I;
+
+  MachineFunction::iterator I;
+  for (I = F->begin(); I != F->end() && &(*I) != BB; ++I);
+  if (I != F->end()) ++I;
 
   // Create loop block.
   MachineBasicBlock *LoopBB = F->CreateMachineBasicBlock(LLVM_BB);