}
};
+} // End llvm namespace
+
// Because of the way .a files work, we must force the BasicAA implementation to
// be pulled in if the AliasAnalysis header is included. Otherwise we run
// the risk of AliasAnalysis being used, but the default implementation not
// being linked into the tool that uses it.
-//
-extern int BasicAAStub;
-static IncludeFile HDR_INCLUDE_BASICAA_CPP(&BasicAAStub);
-
-} // End llvm namespace
+FORCE_DEFINING_FILE_TO_BE_LINKED(AliasAnalysis)
+FORCE_DEFINING_FILE_TO_BE_LINKED(BasicAliasAnalysis)
#endif
static nodes_iterator nodes_end (const CallGraph *CG) { return CG->end(); }
};
-// Make sure that any clients of this file link in CallGraph.cpp
-static IncludeFile
-CALLGRAPH_INCLUDE_FILE(&CallGraph::stub);
-
-extern int BasicCallGraphStub;
-static IncludeFile HDR_INCLUDE_CALLGRAPH_CPP(&BasicCallGraphStub);
-
} // End llvm namespace
+// Make sure that any clients of this file link in CallGraph.cpp
+FORCE_DEFINING_FILE_TO_BE_LINKED(CallGraph)
+
#endif
};
-// Make sure that any clients of this file link in Dominators.cpp
-static IncludeFile
-DOMINATORS_INCLUDE_FILE(&DominatorSet::stub);
} // End llvm namespace
+// Make sure that any clients of this file link in Dominators.cpp
+FORCE_DEFINING_FILE_TO_BE_LINKED(DominatorSet)
+
#endif
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
}
-
- // stub - dummy function, just ignore it
- static int stub;
};
-// Make sure that any clients of this file link in PostDominators.cpp
-static IncludeFile
-FIND_USED_TYPES_INCLUDE_FILE(&FindUsedTypes::stub);
-
} // End llvm namespace
+// Make sure that any clients of this file link in PostDominators.cpp
+FORCE_DEFINING_FILE_TO_BE_LINKED(FindUsedTypes)
+
#endif
/// BasicBlocks to loops.
void removeBlock(BasicBlock *BB);
- static int stub; // Noop
private:
void Calculate(ETForest &EF);
Loop *ConsiderForLoop(BasicBlock *BB, ETForest &EF);
};
-// Make sure that any clients of this file link in LoopInfo.cpp
-static IncludeFile
-LOOP_INFO_INCLUDE_FILE(&LoopInfo::stub);
-
// Allow clients to walk the list of nested loops...
template <> struct GraphTraits<const Loop*> {
typedef const Loop NodeType;
} // End llvm namespace
+// Make sure that any clients of this file link in LoopInfo.cpp
+FORCE_DEFINING_FILE_TO_BE_LINKED(LoopInfo)
+
#endif
AU.addRequired<PostDominatorTree>();
}
- // stub - dummy function, just ignore it
- static int stub;
-
private:
const DomSetType &calculate(const PostDominatorTree &DT,
const DominatorTree::Node *Node);
};
-// Make sure that any clients of this file link in PostDominators.cpp
-static IncludeFile
-POST_DOMINATOR_INCLUDE_FILE(&PostDominanceFrontier::stub);
-
} // End llvm namespace
+// Make sure that any clients of this file link in PostDominators.cpp
+FORCE_DEFINING_FILE_TO_BE_LINKED(PostDominanceFrontier)
+
#endif
}
};
-extern int BasicValueNumberingStub;
-static IncludeFile
-HDR_INCLUDE_VALUENUMBERING_CPP(&BasicValueNumberingStub);
-
} // End llvm namespace
+// Force any file including this header to get the implementation as well
+FORCE_DEFINING_FILE_TO_BE_LINKED(BasicValueNumbering)
+
#endif
}
};
-// A hack to ensure that the IntrinsicInst.cpp file gets added as a dependency
-// of any file that
-extern char LinkIntrinsicInstStub;
-static IncludeFile LinkIntrinsicInst(&LinkIntrinsicInstStub);
-
}
+// Ensure that the IntrinsicInst.cpp file gets added as a dependency of any
+// file that includes this header
+FORCE_DEFINING_FILE_TO_BE_LINKED(IntrinsicInst)
+
#endif
/// And, foo.cp would use:<br/>
/// <tt>DEFINING_FILE_FOR(foo)</tt><br/>
#define FORCE_DEFINING_FILE_TO_BE_LINKED(name) \
- extern char name ## LinkVar; \
- static IncludeFile name ## LinkObj ( &name ## LinkVar )
+ namespace llvm { \
+ extern char name ## LinkVar; \
+ static IncludeFile name ## LinkObj ( &name ## LinkVar ); \
+ }
/// This macro is the counterpart to FORCE_DEFINING_FILE_TO_BE_LINKED. It should
/// be used in a .cpp file to define the name referenced in a header file that
/// will cause linkage of the .cpp file. It should only be used at extern level.
-#define DEFINING_FILE_FOR(name) char name
+#define DEFINING_FILE_FOR(name) namespace llvm { char name ## LinkVar; }
namespace llvm {
/// And, foo.cp would use:<br/>
/// <tt>DEFINING_FILE_FOR(foo)</tt><br/>
#define FORCE_DEFINING_FILE_TO_BE_LINKED(name) \
- extern char name ## LinkVar; \
- static IncludeFile name ## LinkObj ( &name ## LinkVar )
+ namespace llvm { \
+ extern char name ## LinkVar; \
+ static IncludeFile name ## LinkObj ( &name ## LinkVar ); \
+ }
/// This macro is the counterpart to FORCE_DEFINING_FILE_TO_BE_LINKED. It should
/// be used in a .cpp file to define the name referenced in a header file that
/// will cause linkage of the .cpp file. It should only be used at extern level.
-#define DEFINING_FILE_FOR(name) char name
+#define DEFINING_FILE_FOR(name) namespace llvm { char name ## LinkVar; }
namespace llvm {
// be pulled in if the AliasAnalysis classes are pulled in. Otherwise we run
// the risk of AliasAnalysis being used, but the default implementation not
// being linked into the tool that uses it.
-//
-namespace llvm {
- extern int BasicAAStub;
-}
-static IncludeFile INCLUDE_BASICAA_CPP((void*)&BasicAAStub);
+DEFINING_FILE_FOR(AliasAnalysis)
#include <algorithm>
using namespace llvm;
-// Make sure that anything that uses AliasAnalysis pulls in this file...
-int llvm::BasicAAStub;
-
namespace {
/// NoAA - This class implements the -no-aa pass, which always returns "I
/// don't know" for alias queries. NoAA is unlike other alias analysis
return UnknownModRefBehavior;
}
+
+// Make sure that anything that uses AliasAnalysis pulls in this file...
+DEFINING_FILE_FOR(BasicAliasAnalysis)
#include <iostream>
using namespace llvm;
-int llvm::BasicCallGraphStub;
-
static bool isOnlyADirectCall(Function *F, CallSite CS) {
if (!CS.getInstruction()) return false;
for (CallSite::arg_iterator I = CS.arg_begin(), E = CS.arg_end(); I != E; ++I)
return CGN = new CallGraphNode(const_cast<Function*>(F));
}
-
-
-int CallGraph::stub; // to ensure linkage of this file.
-
void CallGraphNode::print(std::ostream &OS) const {
if (Function *F = getFunction())
OS << "Call graph node for function: '" << F->getName() <<"'\n";
--i; --e;
}
}
+
+// Enuse that users of CallGraph.h also link with this file
+DEFINING_FILE_FOR(CallGraph)
static RegisterAnalysis<FindUsedTypes>
X("printusedtypes", "Find Used Types");
-// stub to help linkage
-int FindUsedTypes::stub; // to ensure linkage of this file
-
// IncorporateType - Incorporate one type and all of its subtypes into the
// collection of used types.
//
E = UsedTypes.end(); I != E; ++I)
o << " " << **I << "\n";
}
+
+// Ensure that this file gets linked in when FindUsedTypes.h is used.
+DEFINING_FILE_FOR(FindUsedTypes)
//===----------------------------------------------------------------------===//
// LoopInfo implementation
//
-int LoopInfo::stub;
-
bool LoopInfo::runOnFunction(Function &) {
releaseMemory();
Calculate(getAnalysis<ETForest>()); // Update
void Loop::removeBlockFromLoop(BasicBlock *BB) {
RemoveFromVector(Blocks, BB);
}
+
+// Ensure this file gets linked when LoopInfo.h is used.
+DEFINING_FILE_FOR(LoopInfo)
return S;
}
-// stub - a dummy function to make linking work ok.
-int PostDominanceFrontier::stub;
-
+// Ensure that this .cpp file gets linked when PostDominators.h is used.
+DEFINING_FILE_FOR(PostDominanceFrontier)
}
-int llvm::BasicValueNumberingStub; // to ensure linkage of this file
+// Ensure that users of ValueNumbering.h will link with this file
+DEFINING_FILE_FOR(BasicValueNumbering)
return false;
}
-int DominatorSet::stub;
-
namespace llvm {
static std::ostream &operator<<(std::ostream &o,
const std::set<BasicBlock*> &BBs) {
}
o << "\n";
}
+
+DEFINING_FILE_FOR(DominatorSet)
}
//===----------------------------------------------------------------------===//
-/// LinkIntrinsicInstStub -- This is a hack to make sure that programs that
-/// #include IntrinsicInst.h also link this file. See Support/IncludeFile.h
-/// for further details.
-char llvm::LinkIntrinsicInstStub;
+/// Ensure that users of IntrinsicInst.h will link with this module.
+DEFINING_FILE_FOR(IntrinsicInst)