mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-15 19:24:33 +00:00
Assert on duplicate registration. Don't depend on function pointer equality.
Before this patch we would assert when building llvm as multiple shared libraries (cmake's BUILD_SHARED_LIBS). The problem was the line if (T.AsmStreamerCtorFn == Target::createDefaultAsmStreamer) which returns false because of -fvisibility-inlines-hidden. It is easy to fix just this one case, but I decided to try to also make the registration more strict. It looks like the old logic for ignoring followup registration was just a temporary hack that outlived its usefulness. This patch converts the ifs to asserts, fixes the few cases that were registering twice and makes sure all the asserts compare with null. Thanks for Joerg for reporting the problem and reviewing the patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192803 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -235,22 +235,10 @@ namespace llvm {
|
|||||||
/// MCSymbolizer, if registered (default = llvm::createMCSymbolizer)
|
/// MCSymbolizer, if registered (default = llvm::createMCSymbolizer)
|
||||||
MCSymbolizerCtorTy MCSymbolizerCtorFn;
|
MCSymbolizerCtorTy MCSymbolizerCtorFn;
|
||||||
|
|
||||||
static MCStreamer *
|
|
||||||
createDefaultAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
|
||||||
bool isVerboseAsm, bool useLoc, bool useCFI,
|
|
||||||
bool useDwarfDirectory, MCInstPrinter *InstPrint,
|
|
||||||
MCCodeEmitter *CE, MCAsmBackend *TAB,
|
|
||||||
bool ShowInst) {
|
|
||||||
return llvm::createAsmStreamer(Ctx, 0, OS, isVerboseAsm, useLoc, useCFI,
|
|
||||||
useDwarfDirectory, InstPrint, CE, TAB,
|
|
||||||
ShowInst);
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Target()
|
Target()
|
||||||
: AsmStreamerCtorFn(createDefaultAsmStreamer),
|
: AsmStreamerCtorFn(0), MCRelocationInfoCtorFn(0),
|
||||||
MCRelocationInfoCtorFn(llvm::createMCRelocationInfo),
|
MCSymbolizerCtorFn(0) {}
|
||||||
MCSymbolizerCtorFn(llvm::createMCSymbolizer) {}
|
|
||||||
|
|
||||||
/// @name Target Information
|
/// @name Target Information
|
||||||
/// @{
|
/// @{
|
||||||
@@ -452,9 +440,13 @@ namespace llvm {
|
|||||||
MCCodeEmitter *CE,
|
MCCodeEmitter *CE,
|
||||||
MCAsmBackend *TAB,
|
MCAsmBackend *TAB,
|
||||||
bool ShowInst) const {
|
bool ShowInst) const {
|
||||||
// AsmStreamerCtorFn is default to llvm::createAsmStreamer
|
if (AsmStreamerCtorFn)
|
||||||
return AsmStreamerCtorFn(Ctx, OS, isVerboseAsm, useLoc, useCFI,
|
return AsmStreamerCtorFn(Ctx, OS, isVerboseAsm, useLoc, useCFI,
|
||||||
useDwarfDirectory, InstPrint, CE, TAB, ShowInst);
|
useDwarfDirectory, InstPrint, CE, TAB,
|
||||||
|
ShowInst);
|
||||||
|
return llvm::createAsmStreamer(Ctx, 0, OS, isVerboseAsm, useLoc, useCFI,
|
||||||
|
useDwarfDirectory, InstPrint, CE, TAB,
|
||||||
|
ShowInst);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// createMCRelocationInfo - Create a target specific MCRelocationInfo.
|
/// createMCRelocationInfo - Create a target specific MCRelocationInfo.
|
||||||
@@ -463,7 +455,10 @@ namespace llvm {
|
|||||||
/// \param Ctx The target context.
|
/// \param Ctx The target context.
|
||||||
MCRelocationInfo *
|
MCRelocationInfo *
|
||||||
createMCRelocationInfo(StringRef TT, MCContext &Ctx) const {
|
createMCRelocationInfo(StringRef TT, MCContext &Ctx) const {
|
||||||
return MCRelocationInfoCtorFn(TT, Ctx);
|
MCRelocationInfoCtorTy Fn = MCRelocationInfoCtorFn
|
||||||
|
? MCRelocationInfoCtorFn
|
||||||
|
: llvm::createMCRelocationInfo;
|
||||||
|
return Fn(TT, Ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// createMCSymbolizer - Create a target specific MCSymbolizer.
|
/// createMCSymbolizer - Create a target specific MCSymbolizer.
|
||||||
@@ -480,8 +475,9 @@ namespace llvm {
|
|||||||
LLVMSymbolLookupCallback SymbolLookUp,
|
LLVMSymbolLookupCallback SymbolLookUp,
|
||||||
void *DisInfo,
|
void *DisInfo,
|
||||||
MCContext *Ctx, MCRelocationInfo *RelInfo) const {
|
MCContext *Ctx, MCRelocationInfo *RelInfo) const {
|
||||||
return MCSymbolizerCtorFn(TT, GetOpInfo, SymbolLookUp, DisInfo,
|
MCSymbolizerCtorTy Fn =
|
||||||
Ctx, RelInfo);
|
MCSymbolizerCtorFn ? MCSymbolizerCtorFn : llvm::createMCSymbolizer;
|
||||||
|
return Fn(TT, GetOpInfo, SymbolLookUp, DisInfo, Ctx, RelInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
@@ -602,9 +598,8 @@ namespace llvm {
|
|||||||
/// @param T - The target being registered.
|
/// @param T - The target being registered.
|
||||||
/// @param Fn - A function to construct a MCAsmInfo for the target.
|
/// @param Fn - A function to construct a MCAsmInfo for the target.
|
||||||
static void RegisterMCAsmInfo(Target &T, Target::MCAsmInfoCtorFnTy Fn) {
|
static void RegisterMCAsmInfo(Target &T, Target::MCAsmInfoCtorFnTy Fn) {
|
||||||
// Ignore duplicate registration.
|
assert(!T.MCAsmInfoCtorFn);
|
||||||
if (!T.MCAsmInfoCtorFn)
|
T.MCAsmInfoCtorFn = Fn;
|
||||||
T.MCAsmInfoCtorFn = Fn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RegisterMCCodeGenInfo - Register a MCCodeGenInfo implementation for the
|
/// RegisterMCCodeGenInfo - Register a MCCodeGenInfo implementation for the
|
||||||
@@ -618,9 +613,8 @@ namespace llvm {
|
|||||||
/// @param Fn - A function to construct a MCCodeGenInfo for the target.
|
/// @param Fn - A function to construct a MCCodeGenInfo for the target.
|
||||||
static void RegisterMCCodeGenInfo(Target &T,
|
static void RegisterMCCodeGenInfo(Target &T,
|
||||||
Target::MCCodeGenInfoCtorFnTy Fn) {
|
Target::MCCodeGenInfoCtorFnTy Fn) {
|
||||||
// Ignore duplicate registration.
|
assert(!T.MCCodeGenInfoCtorFn);
|
||||||
if (!T.MCCodeGenInfoCtorFn)
|
T.MCCodeGenInfoCtorFn = Fn;
|
||||||
T.MCCodeGenInfoCtorFn = Fn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RegisterMCInstrInfo - Register a MCInstrInfo implementation for the
|
/// RegisterMCInstrInfo - Register a MCInstrInfo implementation for the
|
||||||
@@ -633,18 +627,16 @@ namespace llvm {
|
|||||||
/// @param T - The target being registered.
|
/// @param T - The target being registered.
|
||||||
/// @param Fn - A function to construct a MCInstrInfo for the target.
|
/// @param Fn - A function to construct a MCInstrInfo for the target.
|
||||||
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn) {
|
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn) {
|
||||||
// Ignore duplicate registration.
|
assert(!T.MCInstrInfoCtorFn);
|
||||||
if (!T.MCInstrInfoCtorFn)
|
T.MCInstrInfoCtorFn = Fn;
|
||||||
T.MCInstrInfoCtorFn = Fn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RegisterMCInstrAnalysis - Register a MCInstrAnalysis implementation for
|
/// RegisterMCInstrAnalysis - Register a MCInstrAnalysis implementation for
|
||||||
/// the given target.
|
/// the given target.
|
||||||
static void RegisterMCInstrAnalysis(Target &T,
|
static void RegisterMCInstrAnalysis(Target &T,
|
||||||
Target::MCInstrAnalysisCtorFnTy Fn) {
|
Target::MCInstrAnalysisCtorFnTy Fn) {
|
||||||
// Ignore duplicate registration.
|
assert(!T.MCInstrAnalysisCtorFn);
|
||||||
if (!T.MCInstrAnalysisCtorFn)
|
T.MCInstrAnalysisCtorFn = Fn;
|
||||||
T.MCInstrAnalysisCtorFn = Fn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RegisterMCRegInfo - Register a MCRegisterInfo implementation for the
|
/// RegisterMCRegInfo - Register a MCRegisterInfo implementation for the
|
||||||
@@ -657,9 +649,8 @@ namespace llvm {
|
|||||||
/// @param T - The target being registered.
|
/// @param T - The target being registered.
|
||||||
/// @param Fn - A function to construct a MCRegisterInfo for the target.
|
/// @param Fn - A function to construct a MCRegisterInfo for the target.
|
||||||
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn) {
|
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn) {
|
||||||
// Ignore duplicate registration.
|
assert(!T.MCRegInfoCtorFn);
|
||||||
if (!T.MCRegInfoCtorFn)
|
T.MCRegInfoCtorFn = Fn;
|
||||||
T.MCRegInfoCtorFn = Fn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for
|
/// RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for
|
||||||
@@ -673,9 +664,8 @@ namespace llvm {
|
|||||||
/// @param Fn - A function to construct a MCSubtargetInfo for the target.
|
/// @param Fn - A function to construct a MCSubtargetInfo for the target.
|
||||||
static void RegisterMCSubtargetInfo(Target &T,
|
static void RegisterMCSubtargetInfo(Target &T,
|
||||||
Target::MCSubtargetInfoCtorFnTy Fn) {
|
Target::MCSubtargetInfoCtorFnTy Fn) {
|
||||||
// Ignore duplicate registration.
|
assert(!T.MCSubtargetInfoCtorFn);
|
||||||
if (!T.MCSubtargetInfoCtorFn)
|
T.MCSubtargetInfoCtorFn = Fn;
|
||||||
T.MCSubtargetInfoCtorFn = Fn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RegisterTargetMachine - Register a TargetMachine implementation for the
|
/// RegisterTargetMachine - Register a TargetMachine implementation for the
|
||||||
@@ -689,9 +679,8 @@ namespace llvm {
|
|||||||
/// @param Fn - A function to construct a TargetMachine for the target.
|
/// @param Fn - A function to construct a TargetMachine for the target.
|
||||||
static void RegisterTargetMachine(Target &T,
|
static void RegisterTargetMachine(Target &T,
|
||||||
Target::TargetMachineCtorTy Fn) {
|
Target::TargetMachineCtorTy Fn) {
|
||||||
// Ignore duplicate registration.
|
assert(!T.TargetMachineCtorFn);
|
||||||
if (!T.TargetMachineCtorFn)
|
T.TargetMachineCtorFn = Fn;
|
||||||
T.TargetMachineCtorFn = Fn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RegisterMCAsmBackend - Register a MCAsmBackend implementation for the
|
/// RegisterMCAsmBackend - Register a MCAsmBackend implementation for the
|
||||||
@@ -704,8 +693,8 @@ namespace llvm {
|
|||||||
/// @param T - The target being registered.
|
/// @param T - The target being registered.
|
||||||
/// @param Fn - A function to construct an AsmBackend for the target.
|
/// @param Fn - A function to construct an AsmBackend for the target.
|
||||||
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn) {
|
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn) {
|
||||||
if (!T.MCAsmBackendCtorFn)
|
assert(!T.MCAsmBackendCtorFn);
|
||||||
T.MCAsmBackendCtorFn = Fn;
|
T.MCAsmBackendCtorFn = Fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RegisterMCAsmParser - Register a MCTargetAsmParser implementation for
|
/// RegisterMCAsmParser - Register a MCTargetAsmParser implementation for
|
||||||
@@ -718,8 +707,8 @@ namespace llvm {
|
|||||||
/// @param T - The target being registered.
|
/// @param T - The target being registered.
|
||||||
/// @param Fn - A function to construct an MCTargetAsmParser for the target.
|
/// @param Fn - A function to construct an MCTargetAsmParser for the target.
|
||||||
static void RegisterMCAsmParser(Target &T, Target::MCAsmParserCtorTy Fn) {
|
static void RegisterMCAsmParser(Target &T, Target::MCAsmParserCtorTy Fn) {
|
||||||
if (!T.MCAsmParserCtorFn)
|
assert(!T.MCAsmParserCtorFn);
|
||||||
T.MCAsmParserCtorFn = Fn;
|
T.MCAsmParserCtorFn = Fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RegisterAsmPrinter - Register an AsmPrinter implementation for the given
|
/// RegisterAsmPrinter - Register an AsmPrinter implementation for the given
|
||||||
@@ -732,9 +721,8 @@ namespace llvm {
|
|||||||
/// @param T - The target being registered.
|
/// @param T - The target being registered.
|
||||||
/// @param Fn - A function to construct an AsmPrinter for the target.
|
/// @param Fn - A function to construct an AsmPrinter for the target.
|
||||||
static void RegisterAsmPrinter(Target &T, Target::AsmPrinterCtorTy Fn) {
|
static void RegisterAsmPrinter(Target &T, Target::AsmPrinterCtorTy Fn) {
|
||||||
// Ignore duplicate registration.
|
assert(!T.AsmPrinterCtorFn);
|
||||||
if (!T.AsmPrinterCtorFn)
|
T.AsmPrinterCtorFn = Fn;
|
||||||
T.AsmPrinterCtorFn = Fn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RegisterMCDisassembler - Register a MCDisassembler implementation for
|
/// RegisterMCDisassembler - Register a MCDisassembler implementation for
|
||||||
@@ -748,8 +736,8 @@ namespace llvm {
|
|||||||
/// @param Fn - A function to construct an MCDisassembler for the target.
|
/// @param Fn - A function to construct an MCDisassembler for the target.
|
||||||
static void RegisterMCDisassembler(Target &T,
|
static void RegisterMCDisassembler(Target &T,
|
||||||
Target::MCDisassemblerCtorTy Fn) {
|
Target::MCDisassemblerCtorTy Fn) {
|
||||||
if (!T.MCDisassemblerCtorFn)
|
assert(!T.MCDisassemblerCtorFn);
|
||||||
T.MCDisassemblerCtorFn = Fn;
|
T.MCDisassemblerCtorFn = Fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RegisterMCInstPrinter - Register a MCInstPrinter implementation for the
|
/// RegisterMCInstPrinter - Register a MCInstPrinter implementation for the
|
||||||
@@ -763,8 +751,8 @@ namespace llvm {
|
|||||||
/// @param Fn - A function to construct an MCInstPrinter for the target.
|
/// @param Fn - A function to construct an MCInstPrinter for the target.
|
||||||
static void RegisterMCInstPrinter(Target &T,
|
static void RegisterMCInstPrinter(Target &T,
|
||||||
Target::MCInstPrinterCtorTy Fn) {
|
Target::MCInstPrinterCtorTy Fn) {
|
||||||
if (!T.MCInstPrinterCtorFn)
|
assert(!T.MCInstPrinterCtorFn);
|
||||||
T.MCInstPrinterCtorFn = Fn;
|
T.MCInstPrinterCtorFn = Fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the
|
/// RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the
|
||||||
@@ -778,8 +766,8 @@ namespace llvm {
|
|||||||
/// @param Fn - A function to construct an MCCodeEmitter for the target.
|
/// @param Fn - A function to construct an MCCodeEmitter for the target.
|
||||||
static void RegisterMCCodeEmitter(Target &T,
|
static void RegisterMCCodeEmitter(Target &T,
|
||||||
Target::MCCodeEmitterCtorTy Fn) {
|
Target::MCCodeEmitterCtorTy Fn) {
|
||||||
if (!T.MCCodeEmitterCtorFn)
|
assert(!T.MCCodeEmitterCtorFn);
|
||||||
T.MCCodeEmitterCtorFn = Fn;
|
T.MCCodeEmitterCtorFn = Fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RegisterMCObjectStreamer - Register a object code MCStreamer
|
/// RegisterMCObjectStreamer - Register a object code MCStreamer
|
||||||
@@ -793,8 +781,8 @@ namespace llvm {
|
|||||||
/// @param Fn - A function to construct an MCStreamer for the target.
|
/// @param Fn - A function to construct an MCStreamer for the target.
|
||||||
static void RegisterMCObjectStreamer(Target &T,
|
static void RegisterMCObjectStreamer(Target &T,
|
||||||
Target::MCObjectStreamerCtorTy Fn) {
|
Target::MCObjectStreamerCtorTy Fn) {
|
||||||
if (!T.MCObjectStreamerCtorFn)
|
assert(!T.MCObjectStreamerCtorFn);
|
||||||
T.MCObjectStreamerCtorFn = Fn;
|
T.MCObjectStreamerCtorFn = Fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RegisterAsmStreamer - Register an assembly MCStreamer implementation
|
/// RegisterAsmStreamer - Register an assembly MCStreamer implementation
|
||||||
@@ -807,8 +795,8 @@ namespace llvm {
|
|||||||
/// @param T - The target being registered.
|
/// @param T - The target being registered.
|
||||||
/// @param Fn - A function to construct an MCStreamer for the target.
|
/// @param Fn - A function to construct an MCStreamer for the target.
|
||||||
static void RegisterAsmStreamer(Target &T, Target::AsmStreamerCtorTy Fn) {
|
static void RegisterAsmStreamer(Target &T, Target::AsmStreamerCtorTy Fn) {
|
||||||
if (T.AsmStreamerCtorFn == Target::createDefaultAsmStreamer)
|
assert(!T.AsmStreamerCtorFn);
|
||||||
T.AsmStreamerCtorFn = Fn;
|
T.AsmStreamerCtorFn = Fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RegisterMCRelocationInfo - Register an MCRelocationInfo
|
/// RegisterMCRelocationInfo - Register an MCRelocationInfo
|
||||||
@@ -822,8 +810,8 @@ namespace llvm {
|
|||||||
/// @param Fn - A function to construct an MCRelocationInfo for the target.
|
/// @param Fn - A function to construct an MCRelocationInfo for the target.
|
||||||
static void RegisterMCRelocationInfo(Target &T,
|
static void RegisterMCRelocationInfo(Target &T,
|
||||||
Target::MCRelocationInfoCtorTy Fn) {
|
Target::MCRelocationInfoCtorTy Fn) {
|
||||||
if (T.MCRelocationInfoCtorFn == llvm::createMCRelocationInfo)
|
assert(!T.MCRelocationInfoCtorFn);
|
||||||
T.MCRelocationInfoCtorFn = Fn;
|
T.MCRelocationInfoCtorFn = Fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RegisterMCSymbolizer - Register an MCSymbolizer
|
/// RegisterMCSymbolizer - Register an MCSymbolizer
|
||||||
@@ -837,8 +825,8 @@ namespace llvm {
|
|||||||
/// @param Fn - A function to construct an MCSymbolizer for the target.
|
/// @param Fn - A function to construct an MCSymbolizer for the target.
|
||||||
static void RegisterMCSymbolizer(Target &T,
|
static void RegisterMCSymbolizer(Target &T,
|
||||||
Target::MCSymbolizerCtorTy Fn) {
|
Target::MCSymbolizerCtorTy Fn) {
|
||||||
if (T.MCSymbolizerCtorFn == llvm::createMCSymbolizer)
|
assert(!T.MCSymbolizerCtorFn);
|
||||||
T.MCSymbolizerCtorFn = Fn;
|
T.MCSymbolizerCtorFn = Fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
@@ -57,9 +57,6 @@ extern "C" void LLVMInitializeNVPTXTarget() {
|
|||||||
RegisterTargetMachine<NVPTXTargetMachine32> X(TheNVPTXTarget32);
|
RegisterTargetMachine<NVPTXTargetMachine32> X(TheNVPTXTarget32);
|
||||||
RegisterTargetMachine<NVPTXTargetMachine64> Y(TheNVPTXTarget64);
|
RegisterTargetMachine<NVPTXTargetMachine64> Y(TheNVPTXTarget64);
|
||||||
|
|
||||||
RegisterMCAsmInfo<NVPTXMCAsmInfo> A(TheNVPTXTarget32);
|
|
||||||
RegisterMCAsmInfo<NVPTXMCAsmInfo> B(TheNVPTXTarget64);
|
|
||||||
|
|
||||||
// FIXME: This pass is really intended to be invoked during IR optimization,
|
// FIXME: This pass is really intended to be invoked during IR optimization,
|
||||||
// but it's very NVPTX-specific.
|
// but it's very NVPTX-specific.
|
||||||
initializeNVVMReflectPass(*PassRegistry::getPassRegistry());
|
initializeNVVMReflectPass(*PassRegistry::getPassRegistry());
|
||||||
|
@@ -721,16 +721,4 @@ TEST(LazyLoadedJITTest, EagerCompiledRecursionThroughGhost) {
|
|||||||
}
|
}
|
||||||
#endif // !defined(__arm__) && !defined(__powerpc__) && !defined(__s390__)
|
#endif // !defined(__arm__) && !defined(__powerpc__) && !defined(__s390__)
|
||||||
|
|
||||||
// This code is copied from JITEventListenerTest, but it only runs once for all
|
|
||||||
// the tests in this directory. Everything seems fine, but that's strange
|
|
||||||
// behavior.
|
|
||||||
class JITEnvironment : public testing::Environment {
|
|
||||||
virtual void SetUp() {
|
|
||||||
// Required to create a JIT.
|
|
||||||
InitializeNativeTarget();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
testing::Environment* const jit_env =
|
|
||||||
testing::AddGlobalTestEnvironment(new JITEnvironment);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user