[PATCH] D25366: AMDGPU/SI: Emit fixups for long branches

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 7 10:46:33 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL283570: AMDGPU/SI: Emit fixups for long branches (authored by tstellar).

Changed prior to commit:
  https://reviews.llvm.org/D25366?vs=73924&id=73951#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25366

Files:
  llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp


Index: llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
===================================================================
--- llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
+++ llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp
@@ -107,6 +107,24 @@
                                          const MCFixup &Fixup, const MCFragment *DF,
                                          const MCValue &Target, uint64_t &Value,
                                          bool &IsResolved) {
+  MCValue Res;
+
+  // When we have complex expressions like: BB0_1 + (BB0_2 - 4), which are
+  // used for long branches, this function will be called with
+  // IsResolved = false and Value set to some pre-computed value.  In
+  // the example above, the value would be:
+  // (BB0_1 + (BB0_2 - 4)) - CurrentOffsetFromStartOfFunction.
+  // This is not what we want.  We just want the expression computation
+  // only.  The reason the MC layer subtracts the current offset from the
+  // expression is because the fixup is of kind FK_PCRel_4.
+  // For these scenarios, evaluateAsValue gives us the computation that we
+  // want.
+  if (!IsResolved && Fixup.getValue()->evaluateAsValue(Res, Layout) &&
+      Res.isAbsolute()) {
+    Value = Res.getConstant();
+    IsResolved = true;
+
+  }
   if (IsResolved)
     Value = adjustFixupValue(Fixup, Value, &Asm.getContext());
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25366.73951.patch
Type: text/x-patch
Size: 1406 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161007/8d085c3e/attachment.bin>


More information about the llvm-commits mailing list