[llvm] [WebAssembly] Implement the `.reloc` directive for WASM (PR #146952)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 3 12:40:33 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp -- llvm/lib/MC/WasmObjectWriter.cpp llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index 90a615b14..c11c80a08 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -531,9 +531,10 @@ void WasmObjectWriter::recordRelocation(const MCFragment &F,
 
   unsigned Type;
   if (mc::isRelocRelocation(Fixup.getKind()))
-      Type = Fixup.getKind() - FirstLiteralRelocationKind;
+    Type = Fixup.getKind() - FirstLiteralRelocationKind;
   else
-      Type = TargetObjectWriter->getRelocType(Target, Fixup, FixupSection, IsLocRel);
+    Type =
+        TargetObjectWriter->getRelocType(Target, Fixup, FixupSection, IsLocRel);
 
   // Absolute offset within a section or a function.
   // Currently only supported for metadata sections.
diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp
index 84a49b0e1..772b5c4cf 100644
--- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp
+++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp
@@ -51,15 +51,16 @@ public:
                     const MCSubtargetInfo *STI) const override;
 };
 
-std::optional<MCFixupKind> WebAssemblyAsmBackend::getFixupKind(StringRef Name) const {
-     unsigned Type = llvm::StringSwitch<unsigned>(Name)
+std::optional<MCFixupKind>
+WebAssemblyAsmBackend::getFixupKind(StringRef Name) const {
+  unsigned Type = llvm::StringSwitch<unsigned>(Name)
 #define WASM_RELOC(NAME, ID) .Case(#NAME, ID)
 #include "llvm/BinaryFormat/WasmRelocs.def"
 #undef WASM_RELOC
-        .Default(-1u);
-    if (Type != -1u)
-        return static_cast<MCFixupKind>(FirstLiteralRelocationKind + Type);
-    return std::nullopt;
+                      .Default(-1u);
+  if (Type != -1u)
+    return static_cast<MCFixupKind>(FirstLiteralRelocationKind + Type);
+  return std::nullopt;
 }
 
 MCFixupKindInfo

``````````

</details>


https://github.com/llvm/llvm-project/pull/146952


More information about the llvm-commits mailing list