AArch64: Stop using MachineInstr::getNextNode()
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 8 Oct 2015 22:43:26 +0000 (22:43 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 8 Oct 2015 22:43:26 +0000 (22:43 +0000)
Stop using `getNextNode()` to get an insertion point (at least, in this
one place).  Instead, use iterator logic directly.

The `getNextNode()` interface isn't actually supposed to work for
creating iterators; it's supposed to return `nullptr` (not a real
iterator) if this is the last node.  It's currently broken and will
"happen" to work, but if we ever fix the function, we'll get some
strange failures in places like this.

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

lib/Target/AArch64/AArch64CleanupLocalDynamicTLSPass.cpp

index 06ff9af37fd7a4df73a1a91b6cae4456a6075d69..2499b2c8875e9e68102d7bde7410d675638221bb 100644 (file)
@@ -117,10 +117,10 @@ struct LDTLSCleanup : public MachineFunctionPass {
     *TLSBaseAddrReg = RegInfo.createVirtualRegister(&AArch64::GPR64RegClass);
 
     // Insert a copy from X0 to TLSBaseAddrReg for later.
-    MachineInstr *Next = I->getNextNode();
-    MachineInstr *Copy = BuildMI(*I->getParent(), Next, I->getDebugLoc(),
-                                 TII->get(TargetOpcode::COPY),
-                                 *TLSBaseAddrReg).addReg(AArch64::X0);
+    MachineInstr *Copy =
+        BuildMI(*I->getParent(), ++MachineBasicBlock::iterator(I),
+                I->getDebugLoc(), TII->get(TargetOpcode::COPY), *TLSBaseAddrReg)
+            .addReg(AArch64::X0);
 
     return Copy;
   }