[PATCH] D58759: [RISCV][MC] Fixed error: could not find corresponding %pcrel_hi

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 4 17:14:15 PST 2019


efriedma added a comment.

> I guess the difficulty there is that you wouldn't know which fragment the symbol offset (AUIPCSymbol->getOffset()) relates to.

Either the label is in the same fragment as the fixup, so the current code works, or the label points to the end of a fragment and the fixup is at offset zero in the next fragment.  Otherwise, they can't match because there's data in between the label and the fixup.  (I guess it's a little more complicated if you consider the possibility of zero-size fragments, but that doesn't make it a lot more complicated.)

I'm concerned the approach in current patch can't be generalized to handle all cases, for example:

  .option push
  .option norelax
  nop
  2:
  .option pop
  auipc   a1, %pcrel_hi(another_symbol)
  addi    a1, a1, %pcrel_lo(2b)



================
Comment at: include/llvm/MC/MCStreamer.h:443
+  /// can be emitted in the current fragment.
+  virtual void EmitLabelEx(MCSymbol *Symbol, SMLoc Loc = SMLoc(),
+                           const MCSubtargetInfo *STI = nullptr);
----------------
If we're going to do this, we should give this a better name... maybe something like "EmitLabelInNextFragment" or something like that, to indicate that it's actually doing something unusual.


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

https://reviews.llvm.org/D58759





More information about the llvm-commits mailing list