[llvm] d3718f1 - [LLVM] remove extern template declarations of GenericCycleInfo

Sameer Sahasrabuddhe via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 1 06:23:13 PDT 2023


Author: Sameer Sahasrabuddhe
Date: 2023-08-01T18:52:45+05:30
New Revision: d3718f1e4f10b89ab56c6c394e2eaec897798bba

URL: https://github.com/llvm/llvm-project/commit/d3718f1e4f10b89ab56c6c394e2eaec897798bba
DIFF: https://github.com/llvm/llvm-project/commit/d3718f1e4f10b89ab56c6c394e2eaec897798bba.diff

LOG: [LLVM] remove extern template declarations of GenericCycleInfo

Having an extern template declaration prevents implicit instantiation of
templates, which causes linker errors when building with shared libraries. For
example, the sources in libAnalysis do not contain any explicit instantiation of
the CycleInfo, which is a specialization of GenericCycleInfo. Thus, any calls to
functions defined in the body of GenericCycleInfo produce undefined references.
The absence of any extern template declaration allows a local instance of these
functions to be created.

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/CycleAnalysis.h
    llvm/include/llvm/CodeGen/MachineCycleAnalysis.h
    llvm/include/llvm/IR/CycleInfo.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/CycleAnalysis.h b/llvm/include/llvm/Analysis/CycleAnalysis.h
index f9f5e5b95b1d94..099d7611dedc48 100644
--- a/llvm/include/llvm/Analysis/CycleAnalysis.h
+++ b/llvm/include/llvm/Analysis/CycleAnalysis.h
@@ -21,11 +21,6 @@
 #include "llvm/Pass.h"
 
 namespace llvm {
-extern template class GenericCycleInfo<SSAContext>;
-extern template class GenericCycle<SSAContext>;
-
-using CycleInfo = GenericCycleInfo<SSAContext>;
-using Cycle = CycleInfo::CycleT;
 
 /// Legacy analysis pass which computes a \ref CycleInfo.
 class CycleInfoWrapperPass : public FunctionPass {

diff  --git a/llvm/include/llvm/CodeGen/MachineCycleAnalysis.h b/llvm/include/llvm/CodeGen/MachineCycleAnalysis.h
index 1c210632f9e1a5..1888dd053ce65e 100644
--- a/llvm/include/llvm/CodeGen/MachineCycleAnalysis.h
+++ b/llvm/include/llvm/CodeGen/MachineCycleAnalysis.h
@@ -20,9 +20,6 @@
 
 namespace llvm {
 
-extern template class GenericCycleInfo<MachineSSAContext>;
-extern template class GenericCycle<MachineSSAContext>;
-
 using MachineCycleInfo = GenericCycleInfo<MachineSSAContext>;
 using MachineCycle = MachineCycleInfo::CycleT;
 

diff  --git a/llvm/include/llvm/IR/CycleInfo.h b/llvm/include/llvm/IR/CycleInfo.h
index 02b25e5abe1ad1..79867fe3a043da 100644
--- a/llvm/include/llvm/IR/CycleInfo.h
+++ b/llvm/include/llvm/IR/CycleInfo.h
@@ -20,9 +20,6 @@
 
 namespace llvm {
 
-extern template class GenericCycleInfo<SSAContext>;
-extern template class GenericCycle<SSAContext>;
-
 using CycleInfo = GenericCycleInfo<SSAContext>;
 using Cycle = CycleInfo::CycleT;
 


        


More information about the llvm-commits mailing list