[PATCH] D74213: [AVR] Don't adjust addresses by 2 for absolute values

Ayke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 26 11:32:59 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG165f707f9d0f: [AVR] Don't adjust addresses by 2 for absolute values (authored by aykevl).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74213/new/

https://reviews.llvm.org/D74213

Files:
  llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
  llvm/test/MC/AVR/relocations-abs.s


Index: llvm/test/MC/AVR/relocations-abs.s
===================================================================
--- /dev/null
+++ llvm/test/MC/AVR/relocations-abs.s
@@ -0,0 +1,8 @@
+; RUN: llvm-mc -filetype=obj -triple=avr %s | llvm-objdump -dr - | FileCheck %s
+
+; CHECK: bar:
+; CHECK-NEXT: 00 00 nop
+; CHECK-NEXT: R_AVR_16 .text+0x2
+bar:
+    .short 1f
+1:
Index: llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
===================================================================
--- llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
+++ llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp
@@ -244,8 +244,18 @@
   // To handle both cases, we simply un-adjust the temporary label
   // case so it acts like all other labels.
   if (const MCSymbolRefExpr *A = Target.getSymA()) {
-    if (A->getSymbol().isTemporary())
-      Value += 2;
+    if (A->getSymbol().isTemporary()) {
+      switch (Kind) {
+      case FK_Data_1:
+      case FK_Data_2:
+      case FK_Data_4:
+      case FK_Data_8:
+        // Don't shift value for absolute addresses.
+        break;
+      default:
+        Value += 2;
+      }
+    }
   }
 
   switch (Kind) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74213.246801.patch
Type: text/x-patch
Size: 1148 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200226/e8e11d45/attachment.bin>


More information about the llvm-commits mailing list