ARM: Use the PICADD opcode calculated.
authorJim Grosbach <grosbach@apple.com>
Tue, 10 Sep 2013 17:21:39 +0000 (17:21 +0000)
committerJim Grosbach <grosbach@apple.com>
Tue, 10 Sep 2013 17:21:39 +0000 (17:21 +0000)
We were figuring out whether to use tPICADD or PICADD, then just using
tPICADD unconditionally anyway. Oops.

A testcase from someone familiar enough with ELF to produce one would
be appreciated. The existing PIC testcase correctly verifies the .s
generated, but that doesn't catch this bug, which only showed up in
direct-to-object mode.

http://llvm.org/bugs/show_bug.cgi?id=17180

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

lib/Target/ARM/ARMInstrInfo.cpp

index 3508795ddcc98c9a54f2e5e44b75cfb187baf018..df867b49ab570ac6b55ae960638992afa71fbaa3 100644 (file)
@@ -136,8 +136,12 @@ namespace {
       unsigned GlobalBaseReg = AFI->getGlobalBaseReg();
       Opc = TM->getSubtarget<ARMSubtarget>().isThumb2() ? ARM::tPICADD
                                                         : ARM::PICADD;
-      BuildMI(FirstMBB, MBBI, DL, TII.get(ARM::tPICADD), GlobalBaseReg)
-          .addReg(TempReg).addImm(ARMPCLabelIndex);
+      MIB = BuildMI(FirstMBB, MBBI, DL, TII.get(Opc), GlobalBaseReg)
+                .addReg(TempReg)
+                .addImm(ARMPCLabelIndex);
+      if (Opc == ARM::PICADD)
+        AddDefaultPred(MIB);
+
 
       return true;
     }