]> granicus.if.org Git - llvm/commitdiff
[Hexagon] Fix relocation kind for extended predicated calls
authorKrzysztof Parzyszek <kparzysz@codeaurora.org>
Thu, 2 Feb 2017 20:21:56 +0000 (20:21 +0000)
committerKrzysztof Parzyszek <kparzysz@codeaurora.org>
Thu, 2 Feb 2017 20:21:56 +0000 (20:21 +0000)
Patch by Sid Manning.

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

lib/Target/Hexagon/MCTargetDesc/HexagonMCCodeEmitter.cpp
test/MC/Hexagon/ext-callt-rel.s [new file with mode: 0644]

index d7159b069c9a9a1b4e38891b215fa817a2974da6..cfb5165e590f5daafa6221bc766cdfd7f68f6de3 100644 (file)
@@ -253,14 +253,16 @@ Hexagon::Fixups HexagonMCCodeEmitter::getFixupNoBits(
       return Hexagon::fixup_Hexagon_B32_PCREL_X;
     case MCSymbolRefExpr::VK_None: {
       auto Insts = HexagonMCInstrInfo::bundleInstructions(**CurrentBundle);
-      for (auto I = Insts.begin(), N = Insts.end(); I != N; ++I)
+      for (auto I = Insts.begin(), N = Insts.end(); I != N; ++I) {
         if (I->getInst() == &MI) {
-          if (HexagonMCInstrInfo::getDesc(MCII, *(I + 1)->getInst()).isBranch() ||
-            (HexagonMCInstrInfo::getType(MCII, *(I + 1)->getInst()) == HexagonII::TypeCR))
+          const MCInst &NextI = *(I+1)->getInst();
+          const MCInstrDesc &D = HexagonMCInstrInfo::getDesc(MCII, NextI);
+          if (D.isBranch() || D.isCall() ||
+              HexagonMCInstrInfo::getType(MCII, NextI) == HexagonII::TypeCR)
             return Hexagon::fixup_Hexagon_B32_PCREL_X;
-          else
-            return Hexagon::fixup_Hexagon_32_6_X;
+          return Hexagon::fixup_Hexagon_32_6_X;
         }
+      }
       raise_relocation_error(0, kind);
     }
     default:
diff --git a/test/MC/Hexagon/ext-callt-rel.s b/test/MC/Hexagon/ext-callt-rel.s
new file mode 100644 (file)
index 0000000..344a8fb
--- /dev/null
@@ -0,0 +1,6 @@
+# RUN: llvm-mc -arch=hexagon -filetype=obj %s -o - | llvm-objdump -r - | FileCheck %s
+
+if (p0) call foo
+#CHECK: R_HEX_B32_PCREL_X
+#CHECK: R_HEX_B15_PCREL_X
+