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

Ayke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 7 04:16:30 PST 2020


aykevl created this revision.
aykevl added a reviewer: dylanmckay.
Herald added subscribers: Jim, hiraditya, aprantl.
Herald added a project: LLVM.
aykevl edited the summary of this revision.

Adjusting by 2 breaks DWARF output. With this fix, programs start to compile and produce valid DWARF output.

---

I'm not quite sure whether this is the correct fix. I feel like this patches over a bug somewhere else. Feel free to suggest a different way to do it.
Also, I still need to add tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74213

Files:
  llvm/lib/Target/AVR/MCTargetDesc/AVRAsmBackend.cpp


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.243133.patch
Type: text/x-patch
Size: 787 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200207/46817d11/attachment.bin>


More information about the llvm-commits mailing list