[llvm] [M68k] Fix ODR violation in GISel code (PR #72797)
Vadim Petrochenkov via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 23 09:30:36 PST 2023
https://github.com/petrochenkov updated https://github.com/llvm/llvm-project/pull/72797
>From 0f7858f17b5ee775d4a2172762ec2f207aa6a829 Mon Sep 17 00:00:00 2001
From: Vadim Petrochenkov <vadim.petrochenkov at gmail.com>
Date: Sun, 19 Nov 2023 16:08:05 +0300
Subject: [PATCH] [M68k] Fix ODR violation in GISel code
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 adding virtual methods for compatibility).
---
llvm/lib/Target/M68k/GISel/M68kCallLowering.cpp | 7 ++++++-
llvm/lib/Target/M68k/GISel/M68kCallLowering.h | 5 -----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/llvm/lib/Target/M68k/GISel/M68kCallLowering.cpp b/llvm/lib/Target/M68k/GISel/M68kCallLowering.cpp
index bb63516e957fd5e..bbba485a481e356 100644
--- a/llvm/lib/Target/M68k/GISel/M68kCallLowering.cpp
+++ b/llvm/lib/Target/M68k/GISel/M68kCallLowering.cpp
@@ -25,6 +25,11 @@
using namespace llvm;
+struct M68kFormalArgHandler : public M68kIncomingValueHandler {
+ M68kFormalArgHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI)
+ : M68kIncomingValueHandler(MIRBuilder, MRI) {}
+};
+
M68kCallLowering::M68kCallLowering(const M68kTargetLowering &TLI)
: CallLowering(&TLI) {}
@@ -119,7 +124,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 7644e6cffbb1bc1..309a2e51a3cf2c0 100644
--- a/llvm/lib/Target/M68k/GISel/M68kCallLowering.h
+++ b/llvm/lib/Target/M68k/GISel/M68kCallLowering.h
@@ -64,11 +64,6 @@ struct M68kIncomingValueHandler : public CallLowering::IncomingValueHandler {
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)
More information about the llvm-commits
mailing list