Skip to content

[llvm] prepare explicit template instantiations in llvm/CodeGen for DLL export annotations #140653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions llvm/include/llvm/CodeGen/MachineBasicBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "llvm/ADT/SparseBitVector.h"
#include "llvm/ADT/ilist.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/CodeGen/MachineFunctionAnalysisManager.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBundleIterator.h"
#include "llvm/IR/DebugLoc.h"
Expand Down Expand Up @@ -46,8 +47,6 @@ class LiveIntervals;
class LiveVariables;
class TargetRegisterClass;
class TargetRegisterInfo;
template <typename IRUnitT, typename... ExtraArgTs> class AnalysisManager;
using MachineFunctionAnalysisManager = AnalysisManager<MachineFunction>;

// This structure uniquely identifies a basic block section.
// Possible values are
Expand Down
31 changes: 16 additions & 15 deletions llvm/include/llvm/CodeGen/MachineDomTreeUpdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@
namespace llvm {

class MachinePostDominatorTree;
class MachineDomTreeUpdater;

extern template class GenericDomTreeUpdater<
MachineDomTreeUpdater, MachineDominatorTree, MachinePostDominatorTree>;

extern template void
GenericDomTreeUpdater<MachineDomTreeUpdater, MachineDominatorTree,
MachinePostDominatorTree>::recalculate(MachineFunction
&MF);

extern template void GenericDomTreeUpdater<
MachineDomTreeUpdater, MachineDominatorTree,
MachinePostDominatorTree>::applyUpdatesImpl</*IsForward=*/true>();
extern template void GenericDomTreeUpdater<
MachineDomTreeUpdater, MachineDominatorTree,
MachinePostDominatorTree>::applyUpdatesImpl</*IsForward=*/false>();

class MachineDomTreeUpdater
: public GenericDomTreeUpdater<MachineDomTreeUpdater, MachineDominatorTree,
Expand Down Expand Up @@ -61,20 +77,5 @@ class MachineDomTreeUpdater
/// Returns true if at least one MachineBasicBlock is deleted.
bool forceFlushDeletedBB();
};

extern template class GenericDomTreeUpdater<
MachineDomTreeUpdater, MachineDominatorTree, MachinePostDominatorTree>;

extern template void
GenericDomTreeUpdater<MachineDomTreeUpdater, MachineDominatorTree,
MachinePostDominatorTree>::recalculate(MachineFunction
&MF);

extern template void GenericDomTreeUpdater<
MachineDomTreeUpdater, MachineDominatorTree,
MachinePostDominatorTree>::applyUpdatesImpl</*IsForward=*/true>();
extern template void GenericDomTreeUpdater<
MachineDomTreeUpdater, MachineDominatorTree,
MachinePostDominatorTree>::applyUpdatesImpl</*IsForward=*/false>();
} // namespace llvm
#endif // LLVM_CODEGEN_MACHINEDOMTREEUPDATER_H
6 changes: 0 additions & 6 deletions llvm/include/llvm/CodeGen/MachineDominators.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ class MachineFunction;
class Module;
class raw_ostream;

template <>
inline void DominatorTreeBase<MachineBasicBlock, false>::addRoot(
MachineBasicBlock *MBB) {
this->Roots.push_back(MBB);
}

extern template class DomTreeNodeBase<MachineBasicBlock>;
extern template class DominatorTreeBase<MachineBasicBlock, false>; // DomTree

Expand Down
27 changes: 27 additions & 0 deletions llvm/include/llvm/CodeGen/MachineFunctionAnalysisManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//===- llvm/CodeGen/MachineFunctionAnalysisManager.h ------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Typedef for MachineFunctionAnalysisManager as an explicit instantiation of
// AnalysisManager<MachineFunction>.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CODEGEN_MACHINEFUNCTIONANALYSISMANAGER
#define LLVM_CODEGEN_MACHINEFUNCTIONANALYSISMANAGER

#include "llvm/IR/PassManager.h"

namespace llvm {

class MachineFunction;

extern template class AnalysisManager<MachineFunction>;
using MachineFunctionAnalysisManager = AnalysisManager<MachineFunction>;

} // namespace llvm

#endif
5 changes: 1 addition & 4 deletions llvm/include/llvm/CodeGen/MachinePassManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@
#include "llvm/ADT/FunctionExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionAnalysisManager.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/PassManagerInternal.h"
#include "llvm/Support/Error.h"

namespace llvm {
class Module;
class Function;
class MachineFunction;

extern template class AnalysisManager<MachineFunction>;
using MachineFunctionAnalysisManager = AnalysisManager<MachineFunction>;

/// An RAII based helper class to modify MachineFunctionProperties when running
/// pass. Define a MFPropsModifier in PassT::run to set
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Support/GenericDomTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ class DominatorTreeBase {
}

protected:
void addRoot(NodeT *BB) { this->Roots.push_back(BB); }
inline void addRoot(NodeT *BB) { this->Roots.push_back(BB); }

DomTreeNodeBase<NodeT> *createNode(NodeT *BB,
DomTreeNodeBase<NodeT> *IDom = nullptr) {
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/CodeGen/MachinePassManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManagerImpl.h"

using namespace llvm;
Expand Down