[llvm] [CodeGen] Hacks solution to X86 CodeGen extern symbol duplication issue (PR #106737)

via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 30 07:22:47 PDT 2024


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 f4ea19b47e1e5af6682d94ad05ac2e7bca64cf73 6b1e2eda0da1f08cc75bb741cfb1b79f58630358 --extensions h,cpp -- llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h llvm/lib/Target/X86/X86MCInstLower.cpp
``````````

</details>

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

``````````diff
diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
index 8d4daa8a77..94ae7438ee 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
@@ -1212,8 +1212,8 @@ public:
   /// of 0.
   Symbol &addExternalSymbol(StringRef Name, orc::ExecutorAddrDiff Size,
                             bool IsWeaklyReferenced) {
-    if(ExternalSymbols.contains(Name))
-       llvm::dbgs() << "Duplicate external symbol: " << Name << "\n";
+    if (ExternalSymbols.contains(Name))
+      llvm::dbgs() << "Duplicate external symbol: " << Name << "\n";
     assert(!ExternalSymbols.contains(Name) && "Duplicate external symbol");
 
     auto &Sym = Symbol::constructExternal(
diff --git a/llvm/lib/Target/X86/X86MCInstLower.cpp b/llvm/lib/Target/X86/X86MCInstLower.cpp
index d01085fd5a..2f1312c1b7 100644
--- a/llvm/lib/Target/X86/X86MCInstLower.cpp
+++ b/llvm/lib/Target/X86/X86MCInstLower.cpp
@@ -80,7 +80,8 @@ public:
                                 const MachineOperand &MO) const;
   void Lower(const MachineInstr *MI, MCInst &OutMI) const;
 
-  MCSymbol *GetSymbolFromOperand(const MachineOperand &MO, MCContext* ExternalContext=nullptr) const;
+  MCSymbol *GetSymbolFromOperand(const MachineOperand &MO,
+                                 MCContext *ExternalContext = nullptr) const;
   MCOperand LowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym) const;
 
 private:
@@ -152,7 +153,9 @@ MachineModuleInfoMachO &X86MCInstLower::getMachOMMI() const {
 
 /// GetSymbolFromOperand - Lower an MO_GlobalAddress or MO_ExternalSymbol
 /// operand to an MCSymbol.
-MCSymbol *X86MCInstLower::GetSymbolFromOperand(const MachineOperand &MO, MCContext* ExternalContext) const {
+MCSymbol *
+X86MCInstLower::GetSymbolFromOperand(const MachineOperand &MO,
+                                     MCContext *ExternalContext) const {
   const Triple &TT = TM.getTargetTriple();
   if (MO.isGlobal() && TT.isOSBinFormatELF())
     return AsmPrinter.getSymbolPreferLocal(*MO.getGlobal());
@@ -356,7 +359,8 @@ MCOperand X86MCInstLower::LowerMachineOperand(const MachineInstr *MI,
   case MachineOperand::MO_MachineBasicBlock:
   case MachineOperand::MO_GlobalAddress:
   case MachineOperand::MO_ExternalSymbol:
-    return LowerSymbolOperand(MO, GetSymbolFromOperand(MO, &AsmPrinter.OutContext));
+    return LowerSymbolOperand(MO,
+                              GetSymbolFromOperand(MO, &AsmPrinter.OutContext));
   case MachineOperand::MO_MCSymbol:
     return LowerSymbolOperand(MO, MO.getMCSymbol());
   case MachineOperand::MO_JumpTableIndex:

``````````

</details>


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


More information about the llvm-commits mailing list