[llvm] 8cb8428 - [M68k] Fix ODR violation in GISel code (#72797)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 14 01:41:26 PST 2023
Author: Vadim Petrochenkov
Date: 2023-12-14T10:41:22+01:00
New Revision: 8cb842879d44ba7b5c1d3e158b8824cae1db6092
URL: https://github.com/llvm/llvm-project/commit/8cb842879d44ba7b5c1d3e158b8824cae1db6092
DIFF: https://github.com/llvm/llvm-project/commit/8cb842879d44ba7b5c1d3e158b8824cae1db6092.diff
LOG: [M68k] Fix ODR violation in GISel code (#72797)
It prevents LLVM from being linked with LLD at least on Windows, with
errors like this:
```
= note: ld.lld: error: duplicate symbol: vtable for llvm::FormalArgHandler
>>> defined at librustc_llvm-a81737dd65a7c126.rlib(M68kCallLowering.cpp.obj)
>>> defined at librustc_llvm-a81737dd65a7c126.rlib(PPCCallLowering.cpp.obj)
```
Binutils linker also complains about this, but only with warnings.
`FormalArgHandler` has a base class `M68kIncomingValueHandler` which
doesn't have a virtual method `markPhysRegUsed` like
`IncomingValueHandler`s for all other targets including PPC, so it
results in a conflict.
The simplest fix is to rename the `FormalArgHandler` structure (rather
than to add virtual methods for compatibility).
cc https://github.com/rust-lang/rust/issues/107668
Added:
Modified:
llvm/lib/Target/M68k/GISel/M68kCallLowering.cpp
llvm/lib/Target/M68k/GISel/M68kCallLowering.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/M68k/GISel/M68kCallLowering.cpp b/llvm/lib/Target/M68k/GISel/M68kCallLowering.cpp
index bb63516e957fd5..e7e62951649416 100644
--- a/llvm/lib/Target/M68k/GISel/M68kCallLowering.cpp
+++ b/llvm/lib/Target/M68k/GISel/M68kCallLowering.cpp
@@ -25,6 +25,27 @@
using namespace llvm;
+namespace {
+
+struct M68kFormalArgHandler : public M68kIncomingValueHandler {
+ M68kFormalArgHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI)
+ : M68kIncomingValueHandler(MIRBuilder, MRI) {}
+};
+
+struct CallReturnHandler : public M68kIncomingValueHandler {
+ CallReturnHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI,
+ MachineInstrBuilder &MIB)
+ : M68kIncomingValueHandler(MIRBuilder, MRI), MIB(MIB) {}
+
+private:
+ void assignValueToReg(Register ValVReg, Register PhysReg,
+ const CCValAssign &VA) override;
+
+ MachineInstrBuilder &MIB;
+};
+
+} // end anonymous namespace
+
M68kCallLowering::M68kCallLowering(const M68kTargetLowering &TLI)
: CallLowering(&TLI) {}
@@ -119,7 +140,7 @@ bool M68kCallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder,
CCAssignFn *AssignFn =
TLI.getCCAssignFn(F.getCallingConv(), false, F.isVarArg());
IncomingValueAssigner ArgAssigner(AssignFn);
- FormalArgHandler ArgHandler(MIRBuilder, MRI);
+ M68kFormalArgHandler ArgHandler(MIRBuilder, MRI);
return determineAndHandleAssignments(ArgHandler, ArgAssigner, SplitArgs,
MIRBuilder, F.getCallingConv(),
F.isVarArg());
diff --git a/llvm/lib/Target/M68k/GISel/M68kCallLowering.h b/llvm/lib/Target/M68k/GISel/M68kCallLowering.h
index 7644e6cffbb1bc..53696df21794cc 100644
--- a/llvm/lib/Target/M68k/GISel/M68kCallLowering.h
+++ b/llvm/lib/Target/M68k/GISel/M68kCallLowering.h
@@ -63,23 +63,6 @@ struct M68kIncomingValueHandler : public CallLowering::IncomingValueHandler {
MachinePointerInfo &MPO,
ISD::ArgFlagsTy Flags) override;
};
-
-struct FormalArgHandler : public M68kIncomingValueHandler {
- FormalArgHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI)
- : M68kIncomingValueHandler(MIRBuilder, MRI) {}
-};
-
-struct CallReturnHandler : public M68kIncomingValueHandler {
- CallReturnHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI,
- MachineInstrBuilder &MIB)
- : M68kIncomingValueHandler(MIRBuilder, MRI), MIB(MIB) {}
-
-private:
- void assignValueToReg(Register ValVReg, Register PhysReg,
- const CCValAssign &VA) override;
-
- MachineInstrBuilder &MIB;
-};
} // end namespace llvm
#endif // LLVM_LIB_TARGET_M68K_GLSEL_M68KCALLLOWERING_H
More information about the llvm-commits
mailing list