[PATCH] D96659: [WebAssembly] Add new relocation for pc-rel data

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 14 12:28:34 PST 2021


sbc100 added a comment.

Is the "pc-rel" in the title a little misleading?  How about just "relative" or "location relative"?

Thinking a little more about this, would it not make sense to have these relative relocations in the code section instead (or in addition)?     I assume the idea is to do stuff like this:

  i32.load <some_base_pointer>
  i32.load <selfrel_location>
  i32.add
  .. use absolute pointer ..

In that case wouldn't it be better to just do:

  i32.load <some_base_pointer>
  i32.const <relative_relocation>
  i32.add
  .. use absolute pointer ..

This would save using memory at all and just embed the relative offset into the i32.const instruction.



================
Comment at: llvm/test/MC/WebAssembly/selfrel.ll:48
+    i32 ptrtoint (i32* @x_sec to i32)
+), section ".sec1"
+
----------------
What happens today with this code?  (without this change would this fail in some way?).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96659



More information about the llvm-commits mailing list