[PATCH] D109109: [MC] Recursively calculate symbol offset
Leonard Grey via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 1 16:22:24 PDT 2021
lgrey created this revision.
lgrey added a reviewer: grosbach.
Herald added a subscriber: hiraditya.
lgrey requested review of this revision.
Herald added a project: LLVM.
This is speculative since I'm not sure if there's some implicit contract that a variable symbol must not have another variable symbol in its evaluation tree.
Downstream bug: https://bugs.chromium.org/p/chromium/issues/detail?id=471146#c23.
Test is based on alias.s (removed checks since we just need to know it didn't crash).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D109109
Files:
llvm/lib/MC/MCFragment.cpp
llvm/test/MC/MachO/chained-alias-offset.s
Index: llvm/test/MC/MachO/chained-alias-offset.s
===================================================================
--- /dev/null
+++ llvm/test/MC/MachO/chained-alias-offset.s
@@ -0,0 +1,5 @@
+// RUN: llvm-mc -triple x86_64-apple-macos %s -filetype=obj -o -
+l_a:
+l_b = l_a + 1
+l_c = l_b
+ .long l_c
Index: llvm/lib/MC/MCFragment.cpp
===================================================================
--- llvm/lib/MC/MCFragment.cpp
+++ llvm/lib/MC/MCFragment.cpp
@@ -128,7 +128,7 @@
const MCSymbolRefExpr *A = Target.getSymA();
if (A) {
uint64_t ValA;
- if (!getLabelOffset(Layout, A->getSymbol(), ReportError, ValA))
+ if (!getSymbolOffsetImpl(Layout, A->getSymbol(), ReportError, ValA))
return false;
Offset += ValA;
}
@@ -136,7 +136,7 @@
const MCSymbolRefExpr *B = Target.getSymB();
if (B) {
uint64_t ValB;
- if (!getLabelOffset(Layout, B->getSymbol(), ReportError, ValB))
+ if (!getSymbolOffsetImpl(Layout, B->getSymbol(), ReportError, ValB))
return false;
Offset -= ValB;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109109.370103.patch
Type: text/x-patch
Size: 1054 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210901/b68b4c50/attachment.bin>
More information about the llvm-commits
mailing list