#include "llvm/DerivedTypes.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/CallGraph.h"
-#include "llvm/Support/InstIterator.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/InstIterator.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/SCCIterator.h"
#include <set>
/// function in the program. Later, the entries for these functions are
/// removed if the function is found to call an external function (in which
/// case we know nothing about it.
- struct FunctionRecord {
+ struct VISIBILITY_HIDDEN FunctionRecord {
/// GlobalInfo - Maintain mod/ref info for all of the globals without
/// addresses taken that are read or written (transitively) by this
/// function.
};
/// GlobalsModRef - The actual analysis pass.
- class GlobalsModRef : public ModulePass, public AliasAnalysis {
+ class VISIBILITY_HIDDEN GlobalsModRef
+ : public ModulePass, public AliasAnalysis {
/// NonAddressTakenGlobals - The globals that do not have their addresses
/// taken.
std::set<GlobalValue*> NonAddressTakenGlobals;
std::map<Function*, FunctionRecord> FunctionInfo;
public:
+ static char ID;
+ GlobalsModRef() : ModulePass((intptr_t)&ID) {}
+
bool runOnModule(Module &M) {
InitializeAliasAnalysis(this); // set up super class
AnalyzeGlobals(M); // find non-addr taken globals
bool AnalyzeIndirectGlobalMemory(GlobalValue *GV);
};
+ char GlobalsModRef::ID = 0;
RegisterPass<GlobalsModRef> X("globalsmodref-aa",
"Simple mod/ref analysis for globals");
RegisterAnalysisGroup<AliasAnalysis> Y(X);
// Okay, easy case.
} else if (CallInst *CI = dyn_cast<CallInst>(Ptr)) {
Function *F = CI->getCalledFunction();
- if (!F || !F->isExternal()) return false; // Too hard to analyze.
+ if (!F || !F->isDeclaration()) return false; // Too hard to analyze.
if (F->getName() != "calloc") return false; // Not calloc.
} else {
return false; // Too hard to analyze.
if ((*I).size() != 1) {
AnalyzeSCC(*I);
} else if (Function *F = (*I)[0]->getFunction()) {
- if (!F->isExternal()) {
+ if (!F->isDeclaration()) {
// Nonexternal function.
AnalyzeSCC(*I);
} else {