For PR1136: Rename GlobalVariable::isExternal as isDeclaration to avoid

confusion with external linkage types.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33663 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer 2007-01-30 20:08:39 +00:00
parent 2574fe5a22
commit 5cbf985dcb
72 changed files with 1197 additions and 1372 deletions

View File

@ -89,11 +89,11 @@ public:
/// arguments.
bool isVarArg() const;
/// isExternal - Is the body of this function unknown? (The basic block list
/// is empty if so.) This is true for external functions, defined as forward
/// "declare"ations
/// isDeclaration - Is the body of this function unknown? (The basic block
/// list is empty if so.) This is true for function declarations, but not
/// true for function definitions.
///
virtual bool isExternal() const { return BasicBlocks.empty(); }
virtual bool isDeclaration() const { return BasicBlocks.empty(); }
/// getIntrinsicID - This method returns the ID number of the specified
/// function, or Intrinsic::not_intrinsic if the function is not an

View File

@ -113,9 +113,9 @@ public:
/// Override from Constant class.
virtual void destroyConstant();
/// isExternal - Return true if the primary definition of this global value is
/// outside of the current translation unit...
virtual bool isExternal() const = 0;
/// isDeclaration - Return true if the primary definition of this global
/// value is outside of the current translation unit...
virtual bool isDeclaration() const = 0;
/// getParent - Get the module that this global value is contained inside
/// of...

View File

@ -58,17 +58,16 @@ public:
Constant *Initializer, const std::string &Name,
GlobalVariable *InsertBefore);
/// isExternal - Is this global variable lacking an initializer? If so, the
/// global variable is defined in some other translation unit, and is thus
/// externally defined here.
///
virtual bool isExternal() const { return getNumOperands() == 0; }
/// isDeclaration - Is this global variable lacking an initializer? If so,
/// the global variable is defined in some other translation unit, and is thus
/// only a declaration here.
virtual bool isDeclaration() const { return getNumOperands() == 0; }
/// hasInitializer - Unless a global variable isExternal(), it has an
/// initializer. The initializer for the global variable/constant is held by
/// Initializer if an initializer is specified.
///
inline bool hasInitializer() const { return !isExternal(); }
inline bool hasInitializer() const { return !isDeclaration(); }
/// getInitializer - Return the initializer for this global variable. It is
/// illegal to call this method if the global is external, because we cannot

View File

@ -48,7 +48,7 @@ namespace {
for(Module::iterator I = M.begin(),
E = M.end(); I != E; ++I){
Vals.insert(&*I);
if(!I->isExternal()) {
if(!I->isDeclaration()) {
for (Function::arg_iterator AI = I->arg_begin(), AE = I->arg_end();
AI != AE; ++AI)
Vals.insert(&*AI);

View File

@ -823,7 +823,7 @@ static ManagedStatic<std::vector<const char*> > OnlyReadsMemoryTable;
AliasAnalysis::ModRefBehavior
BasicAliasAnalysis::getModRefBehavior(Function *F, CallSite CS,
std::vector<PointerAccessInfo> *Info) {
if (!F->isExternal()) return UnknownModRefBehavior;
if (!F->isDeclaration()) return UnknownModRefBehavior;
static bool Initialized = false;
if (!Initialized) {

View File

@ -367,7 +367,7 @@ Andersens::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
// program and modify stuff. We ignore this technical niggle for now. This
// is, after all, a "research quality" implementation of Andersen's analysis.
if (Function *F = CS.getCalledFunction())
if (F->isExternal()) {
if (F->isDeclaration()) {
Node *N1 = getNode(P);
if (N1->begin() == N1->end())
@ -599,7 +599,7 @@ void Andersens::AddConstraintsForNonInternalLinkage(Function *F) {
/// constraints and return true. If this is a call to an unknown function,
/// return false.
bool Andersens::AddConstraintsForExternalCall(CallSite CS, Function *F) {
assert(F->isExternal() && "Not an external function!");
assert(F->isDeclaration() && "Not an external function!");
// These functions don't induce any points-to constraints.
if (F->getName() == "atoi" || F->getName() == "atof" ||
@ -724,7 +724,7 @@ void Andersens::CollectConstraints(Module &M) {
if (!F->hasInternalLinkage())
AddConstraintsForNonInternalLinkage(F);
if (!F->isExternal()) {
if (!F->isDeclaration()) {
// Scan the function body, creating a memory object for each heap/stack
// allocation in the body of the function and a node to represent all
// pointer values defined by instructions and used as operands.
@ -883,7 +883,7 @@ void Andersens::visitVAArg(VAArgInst &I) {
void Andersens::AddConstraintsForCall(CallSite CS, Function *F) {
// If this is a call to an external function, handle it directly to get some
// taste of context sensitivity.
if (F->isExternal() && AddConstraintsForExternalCall(CS, F))
if (F->isDeclaration() && AddConstraintsForExternalCall(CS, F))
return;
if (isa<PointerType>(CS.getType())) {

View File

@ -133,7 +133,7 @@ private:
// If this function is not defined in this translation unit, it could call
// anything.
if (F->isExternal() && !F->getIntrinsicID())
if (F->isDeclaration() && !F->getIntrinsicID())
Node->addCalledFunction(CallSite(), CallsExternalNode);
// Loop over all of the users of the function... looking for callers...

View File

@ -300,7 +300,7 @@ bool GlobalsModRef::AnalyzeIndirectGlobalMemory(GlobalValue *GV) {
// 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.
@ -341,7 +341,7 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) {
if ((*I).size() != 1) {
AnalyzeSCC(*I);
} else if (Function *F = (*I)[0]->getFunction()) {
if (!F->isExternal()) {
if (!F->isDeclaration()) {
// Nonexternal function.
AnalyzeSCC(*I);
} else {

View File

@ -164,7 +164,7 @@ void ProfileInfoLoader::getFunctionCounts(std::vector<std::pair<Function*,
unsigned Counter = 0;
for (Module::iterator I = M.begin(), E = M.end();
I != E && Counter != FunctionCounts.size(); ++I)
if (!I->isExternal())
if (!I->isDeclaration())
Counts.push_back(std::make_pair(I, FunctionCounts[Counter++]));
}

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,7 @@
/* A Bison parser, made by GNU Bison 2.3. */
/* A Bison parser, made by GNU Bison 2.1. */
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -20,18 +18,10 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
@ -304,10 +294,9 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 885 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y"
{
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 885 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
typedef union YYSTYPE {
llvm::Module *ModuleVal;
llvm::Function *FunctionVal;
llvm::BasicBlock *BasicBlockVal;
@ -351,10 +340,9 @@ typedef union YYSTYPE
llvm::Instruction::OtherOps OtherOpVal;
llvm::ICmpInst::Predicate IPredicate;
llvm::FCmpInst::Predicate FPredicate;
}
/* Line 1489 of yacc.c. */
#line 357 "llvmAsmParser.tab.h"
YYSTYPE;
} YYSTYPE;
/* Line 1447 of yacc.c. */
#line 346 "llvmAsmParser.tab.h"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
@ -362,3 +350,5 @@ typedef union YYSTYPE
extern YYSTYPE llvmAsmlval;

View File

@ -2088,11 +2088,11 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
(Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
// If this is the case, either we need to be a forward decl, or it needs
// to be.
if (!CurFun.isDeclare && !Fn->isExternal())
if (!CurFun.isDeclare && !Fn->isDeclaration())
GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
// Make sure to strip off any argument names so we can't get conflicts.
if (Fn->isExternal())
if (Fn->isDeclaration())
for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
AI != AE; ++AI)
AI->setName("");

View File

@ -2088,11 +2088,11 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
(Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
// If this is the case, either we need to be a forward decl, or it needs
// to be.
if (!CurFun.isDeclare && !Fn->isExternal())
if (!CurFun.isDeclare && !Fn->isDeclaration())
GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
// Make sure to strip off any argument names so we can't get conflicts.
if (Fn->isExternal())
if (Fn->isDeclaration())
for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
AI != AE; ++AI)
AI->setName("");

View File

@ -298,13 +298,13 @@ bool llvm::GetBytecodeDependentLibraries(const std::string &fname,
static void getSymbols(Module*M, std::vector<std::string>& symbols) {
// Loop over global variables
for (Module::global_iterator GI = M->global_begin(), GE=M->global_end(); GI != GE; ++GI)
if (!GI->isExternal() && !GI->hasInternalLinkage())
if (!GI->isDeclaration() && !GI->hasInternalLinkage())
if (!GI->getName().empty())
symbols.push_back(GI->getName());
// Loop over functions.
for (Module::iterator FI = M->begin(), FE = M->end(); FI != FE; ++FI)
if (!FI->isExternal() && !FI->hasInternalLinkage())
if (!FI->isDeclaration() && !FI->hasInternalLinkage())
if (!FI->getName().empty())
symbols.push_back(FI->getName());
}

View File

@ -1030,12 +1030,12 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
unsigned CC = I->getCallingConv()+1;
unsigned ID = (Slot << 5) | (CC & 15);
if (I->isExternal()) // If external, we don't have an FunctionInfo block.
if (I->isDeclaration()) // If external, we don't have an FunctionInfo block.
ID |= 1 << 4;
if (I->getAlignment() || I->hasSection() || (CC & ~15) != 0 ||
(I->isExternal() && I->hasDLLImportLinkage()) ||
(I->isExternal() && I->hasExternalWeakLinkage())
(I->isDeclaration() && I->hasDLLImportLinkage()) ||
(I->isDeclaration() && I->hasExternalWeakLinkage())
)
ID |= 1 << 31; // Do we need an extension word?
@ -1046,7 +1046,7 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
// convention, bit 10 = hasSectionID., bits 11-12 = external linkage type
unsigned extLinkage = 0;
if (I->isExternal()) {
if (I->isDeclaration()) {
if (I->hasDLLImportLinkage()) {
extLinkage = 1;
} else if (I->hasExternalWeakLinkage()) {
@ -1103,7 +1103,7 @@ void BytecodeWriter::outputInstructions(const Function *F) {
void BytecodeWriter::outputFunction(const Function *F) {
// If this is an external function, there is nothing else to emit!
if (F->isExternal()) return;
if (F->isDeclaration()) return;
BytecodeBlock FunctionBlock(BytecodeFormat::FunctionBlockID, *this);
unsigned rWord = (getEncodedVisibility(F) << 16) | getEncodedLinkage(F);

View File

@ -61,7 +61,7 @@ static CallInst *ReplaceCallWith(const char *NewFn, CallInst *CI,
void IntrinsicLowering::AddPrototypes(Module &M) {
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
if (I->isExternal() && !I->use_empty())
if (I->isDeclaration() && !I->use_empty())
switch (I->getIntrinsicID()) {
default: break;
case Intrinsic::setjmp:

View File

@ -2107,7 +2107,7 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
void SelectionDAGLowering::visitCall(CallInst &I) {
const char *RenameFn = 0;
if (Function *F = I.getCalledFunction()) {
if (F->isExternal())
if (F->isDeclaration())
if (unsigned IID = F->getIntrinsicID()) {
RenameFn = visitIntrinsicCall(I, IID);
if (!RenameFn)

View File

@ -194,7 +194,7 @@ void ExecutionEngine::runStaticConstructorsDestructors(bool isDtors) {
// an old-style (llvmgcc3) static ctor with __main linked in and in use. If
// this is the case, don't execute any of the global ctors, __main will do
// it.
if (!GV || GV->isExternal() || GV->hasInternalLinkage()) continue;
if (!GV || GV->isDeclaration() || GV->hasInternalLinkage()) continue;
// Should be an array of '{ int, void ()* }' structs. The first value is
// the init priority, which we ignore.
@ -746,7 +746,7 @@ void ExecutionEngine::emitGlobals() {
for (Module::const_global_iterator I = M.global_begin(),
E = M.global_end(); I != E; ++I) {
const GlobalValue *GV = I;
if (GV->hasInternalLinkage() || GV->isExternal() ||
if (GV->hasInternalLinkage() || GV->isDeclaration() ||
GV->hasAppendingLinkage() || !GV->hasName())
continue;// Ignore external globals and globals with internal linkage.
@ -791,7 +791,7 @@ void ExecutionEngine::emitGlobals() {
}
}
if (!I->isExternal()) {
if (!I->isDeclaration()) {
// Get the type of the global.
const Type *Ty = I->getType()->getElementType();
@ -829,7 +829,7 @@ void ExecutionEngine::emitGlobals() {
// and initialize their contents.
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
I != E; ++I) {
if (!I->isExternal()) {
if (!I->isDeclaration()) {
if (!LinkedGlobalsMap.empty()) {
if (const GlobalValue *GVEntry =
LinkedGlobalsMap[std::make_pair(I->getName(), I->getType())])

View File

@ -1137,7 +1137,7 @@ void Interpreter::visitCallSite(CallSite CS) {
// Check to see if this is an intrinsic function call...
if (Function *F = CS.getCalledFunction())
if (F->isExternal ())
if (F->isDeclaration ())
switch (F->getIntrinsicID()) {
case Intrinsic::not_intrinsic:
break;
@ -1726,7 +1726,7 @@ void Interpreter::callFunction(Function *F,
StackFrame.CurFunction = F;
// Special handling for external functions.
if (F->isExternal()) {
if (F->isDeclaration()) {
GenericValue Result = callExternalFunction (F, ArgVals);
// Simulate a 'ret' instruction of the appropriate type.
popStackAndReturnValueToCaller (F->getReturnType (), Result);

View File

@ -291,7 +291,7 @@ void *JIT::getPointerToFunction(Function *F) {
}
}
if (F->isExternal()) {
if (F->isDeclaration()) {
void *Addr = getPointerToNamedFunction(F->getName());
addGlobalMapping(F, Addr);
return Addr;
@ -314,7 +314,7 @@ void *JIT::getOrEmitGlobalVariable(const GlobalVariable *GV) {
if (Ptr) return Ptr;
// If the global is external, just remember the address.
if (GV->isExternal()) {
if (GV->isDeclaration()) {
#if defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_4) && \
((MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4) || \
(MAC_OS_X_VERSION_MIN_REQUIRED == MAC_OS_X_VERSION_10_4 && \

View File

@ -543,7 +543,7 @@ void *JITResolver::getFunctionStub(Function *F) {
// Call the lazy resolver function unless we already KNOW it is an external
// function, in which case we just skip the lazy resolution step.
void *Actual = (void*)(intptr_t)LazyResolverFn;
if (F->isExternal() && !F->hasNotBeenReadFromBytecode())
if (F->isDeclaration() && !F->hasNotBeenReadFromBytecode())
Actual = TheJIT->getPointerToFunction(F);
// Otherwise, codegen a new stub. For now, the stub will call the lazy
@ -746,7 +746,7 @@ void *JITEmitter::getPointerToGlobal(GlobalValue *V, void *Reference,
void *ResultPtr = TheJIT->getPointerToGlobalIfAvailable(F);
if (ResultPtr) return ResultPtr;
if (F->isExternal() && !F->hasNotBeenReadFromBytecode()) {
if (F->isDeclaration() && !F->hasNotBeenReadFromBytecode()) {
// If this is an external function pointer, we can force the JIT to
// 'compile' it, which really just adds it to the map.
if (DoesntNeedStub)

View File

@ -44,12 +44,12 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
// This is needed for programs where the main function is defined in an
// archive, such f2c'd programs.
Function *Main = M->getMainFunction();
if (Main == 0 || Main->isExternal())
if (Main == 0 || Main->isDeclaration())
UndefinedSymbols.insert("main");
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
if (I->hasName()) {
if (I->isExternal())
if (I->isDeclaration())
UndefinedSymbols.insert(I->getName());
else if (!I->hasInternalLinkage()) {
assert(!I->hasDLLImportLinkage()
@ -60,7 +60,7 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
for (Module::global_iterator I = M->global_begin(), E = M->global_end();
I != E; ++I)
if (I->hasName()) {
if (I->isExternal())
if (I->isDeclaration())
UndefinedSymbols.insert(I->getName());
else if (!I->hasInternalLinkage()) {
assert(!I->hasDLLImportLinkage()

View File

@ -365,12 +365,12 @@ static bool GetLinkageResult(GlobalValue *Dest, GlobalValue *Src,
// Linking something to nothing.
LinkFromSrc = true;
LT = Src->getLinkage();
} else if (Src->isExternal()) {
} else if (Src->isDeclaration()) {
// If Src is external or if both Src & Drc are external.. Just link the
// external globals, we aren't adding anything.
if (Src->hasDLLImportLinkage()) {
// If one of GVs has DLLImport linkage, result should be dllimport'ed.
if (Dest->isExternal()) {
if (Dest->isDeclaration()) {
LinkFromSrc = true;
LT = Src->getLinkage();
}
@ -382,7 +382,7 @@ static bool GetLinkageResult(GlobalValue *Dest, GlobalValue *Src,
LinkFromSrc = false;
LT = Dest->getLinkage();
}
} else if (Dest->isExternal() && !Dest->hasDLLImportLinkage()) {
} else if (Dest->isDeclaration() && !Dest->hasDLLImportLinkage()) {
// If Dest is external but Src is not:
LinkFromSrc = true;
LT = Src->getLinkage();
@ -536,7 +536,7 @@ static bool LinkGlobals(Module *Dest, Module *Src,
DGV->setInitializer(0);
} else {
if (SGV->isConstant() && !DGV->isConstant()) {
if (DGV->isExternal())
if (DGV->isDeclaration())
DGV->setConstant(true);
}
SGV->setLinkage(GlobalValue::ExternalLinkage);
@ -637,18 +637,18 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
// ... and remember this mapping...
ValueMap.insert(std::make_pair(SF, NewDF));
} else if (SF->isExternal()) {
} else if (SF->isDeclaration()) {
// If SF is external or if both SF & DF are external.. Just link the
// external functions, we aren't adding anything.
if (SF->hasDLLImportLinkage()) {
if (DF->isExternal()) {
if (DF->isDeclaration()) {
ValueMap.insert(std::make_pair(SF, DF));
DF->setLinkage(SF->getLinkage());
}
} else {
ValueMap.insert(std::make_pair(SF, DF));
}
} else if (DF->isExternal() && !DF->hasDLLImportLinkage()) {
} else if (DF->isDeclaration() && !DF->hasDLLImportLinkage()) {
// If DF is external but SF is not...
// Link the external functions, update linkage qualifiers
ValueMap.insert(std::make_pair(SF, DF));
@ -691,7 +691,7 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
static bool LinkFunctionBody(Function *Dest, Function *Src,
std::map<const Value*, Value*> &GlobalMap,
std::string *Err) {
assert(Src && Dest && Dest->isExternal() && !Src->isExternal());
assert(Src && Dest && Dest->isDeclaration() && !Src->isDeclaration());
// Go through and convert function arguments over, remembering the mapping.
Function::arg_iterator DI = Dest->arg_begin();
@ -737,11 +737,11 @@ static bool LinkFunctionBodies(Module *Dest, Module *Src,
// Loop over all of the functions in the src module, mapping them over as we
// go
for (Module::iterator SF = Src->begin(), E = Src->end(); SF != E; ++SF) {
if (!SF->isExternal()) { // No body if function is external
if (!SF->isDeclaration()) { // No body if function is external
Function *DF = cast<Function>(ValueMap[SF]); // Destination function
// DF not external SF external?
if (DF->isExternal()) {
if (DF->isDeclaration()) {
// Only provide the function body if there isn't one already.
if (LinkFunctionBody(DF, SF, ValueMap, Err))
return true;

View File

@ -264,7 +264,7 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
bool isCallOp = Modifier && !strcmp(Modifier, "call");
GlobalValue *GV = MO.getGlobal();
std::string Name = Mang->getValueName(GV);
bool isExt = (GV->isExternal() || GV->hasWeakLinkage() ||
bool isExt = (GV->isDeclaration() || GV->hasWeakLinkage() ||
GV->hasLinkOnceLinkage());
if (isExt && isCallOp && Subtarget->isTargetDarwin() &&
TM.getRelocationModel() != Reloc::Static) {

View File

@ -467,7 +467,7 @@ SDOperand ARMTargetLowering::LowerCALL(SDOperand Op, SelectionDAG &DAG) {
GlobalValue *GV = G->getGlobal();
Callee = DAG.getTargetGlobalAddress(GV, getPointerTy());
isDirect = true;
bool isExt = (GV->isExternal() || GV->hasWeakLinkage() ||
bool isExt = (GV->isDeclaration() || GV->hasWeakLinkage() ||
GV->hasLinkOnceLinkage());
bool isStub = (isExt && Subtarget->isTargetDarwin()) &&
getTargetMachine().getRelocationModel() != Reloc::Static;
@ -632,7 +632,7 @@ static SDOperand LowerConstantPool(SDOperand Op, SelectionDAG &DAG) {
/// even in dynamic-no-pic mode.
static bool GVIsIndirectSymbol(GlobalValue *GV) {
return (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
(GV->isExternal() && !GV->hasNotBeenReadFromBytecode()));
(GV->isDeclaration() && !GV->hasNotBeenReadFromBytecode()));
}
SDOperand ARMTargetLowering::LowerGlobalAddress(SDOperand Op,

View File

@ -427,7 +427,7 @@ SDOperand AlphaTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
GlobalValue *GV = GSDN->getGlobal();
SDOperand GA = DAG.getTargetGlobalAddress(GV, MVT::i64, GSDN->getOffset());
// if (!GV->hasWeakLinkage() && !GV->isExternal() && !GV->hasLinkOnceLinkage()) {
// if (!GV->hasWeakLinkage() && !GV->isDeclaration() && !GV->hasLinkOnceLinkage()) {
if (GV->hasInternalLinkage()) {
SDOperand Hi = DAG.getNode(AlphaISD::GPRelHi, MVT::i64, GA,
DAG.getNode(ISD::GLOBAL_OFFSET_TABLE, MVT::i64));

View File

@ -305,7 +305,7 @@ bool CBackendNameAllUsedStructsAndMergeFunctions::runOnModule(Module &M) {
std::map<std::string, GlobalValue*> ExtSymbols;
for (Module::iterator I = M.begin(), E = M.end(); I != E;) {
Function *GV = I++;
if (GV->isExternal() && GV->hasName()) {
if (GV->isDeclaration() && GV->hasName()) {
std::pair<std::map<std::string, GlobalValue*>::iterator, bool> X
= ExtSymbols.insert(std::make_pair(GV->getName(), GV));
if (!X.second) {
@ -321,7 +321,7 @@ bool CBackendNameAllUsedStructsAndMergeFunctions::runOnModule(Module &M) {
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
I != E;) {
GlobalVariable *GV = I++;
if (GV->isExternal() && GV->hasName()) {
if (GV->isDeclaration() && GV->hasName()) {
std::pair<std::map<std::string, GlobalValue*>::iterator, bool> X
= ExtSymbols.insert(std::make_pair(GV->getName(), GV));
if (!X.second) {
@ -1525,7 +1525,7 @@ bool CWriter::doInitialization(Module &M) {
Out << "\n\n/* Global Variable Declarations */\n";
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
I != E; ++I)
if (!I->isExternal()) {
if (!I->isDeclaration()) {
// Ignore special globals, such as debug info.
if (getGlobalVariableClass(I))
continue;
@ -1554,7 +1554,7 @@ bool CWriter::doInitialization(Module &M) {
Out << "\n\n/* Global Variable Definitions and Initialization */\n";
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
I != E; ++I)
if (!I->isExternal()) {
if (!I->isDeclaration()) {
// Ignore special globals, such as debug info.
if (getGlobalVariableClass(I))
continue;
@ -1777,7 +1777,7 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
FunctionInnards << Mang->getValueName(F) << '(';
bool PrintedArg = false;
if (!F->isExternal()) {
if (!F->isDeclaration()) {
if (!F->arg_empty()) {
Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end();

View File

@ -193,17 +193,17 @@ void IA64AsmPrinter::printOp(const MachineOperand &MO,
bool Needfptr=false; // if we're computing an address @ltoff(X), do
// we need to decorate it so it becomes
// @ltoff(@fptr(X)) ?
if (F && !isBRCALLinsn /*&& F->isExternal()*/)
if (F && !isBRCALLinsn /*&& F->isDeclaration()*/)
Needfptr=true;
// if this is the target of a call instruction, we should define
// the function somewhere (GNU gas has no problem without this, but
// Intel ias rightly complains of an 'undefined symbol')
if (F /*&& isBRCALLinsn*/ && F->isExternal())
if (F /*&& isBRCALLinsn*/ && F->isDeclaration())
ExternalFunctionNames.insert(Mang->getValueName(MO.getGlobal()));
else
if (GV->isExternal()) // e.g. stuff like 'stdin'
if (GV->isDeclaration()) // e.g. stuff like 'stdin'
ExternalObjectNames.insert(Mang->getValueName(MO.getGlobal()));
if (!isBRCALLinsn)

View File

@ -183,7 +183,7 @@ namespace {
if (TM.getRelocationModel() != Reloc::Static) {
if (MO.getType() == MachineOperand::MO_GlobalAddress) {
GlobalValue *GV = MO.getGlobal();
if (((GV->isExternal() || GV->hasWeakLinkage() ||
if (((GV->isDeclaration() || GV->hasWeakLinkage() ||
GV->hasLinkOnceLinkage()))) {
// Dynamically-resolved functions need a stub for the function.
std::string Name = Mang->getValueName(GV);
@ -381,7 +381,7 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
// External or weakly linked global variables need non-lazily-resolved stubs
if (TM.getRelocationModel() != Reloc::Static) {
if (((GV->isExternal() || GV->hasWeakLinkage() ||
if (((GV->isDeclaration() || GV->hasWeakLinkage() ||
GV->hasLinkOnceLinkage()))) {
GVStubs.insert(Name);
O << "L" << Name << "$non_lazy_ptr";

View File

@ -137,5 +137,5 @@ bool PPCSubtarget::hasLazyResolverStub(const GlobalValue *GV) const {
return false;
return GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
(GV->isExternal() && !GV->hasNotBeenReadFromBytecode());
(GV->isDeclaration() && !GV->hasNotBeenReadFromBytecode());
}

View File

@ -281,7 +281,7 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
if (printStub(TM, Subtarget)) {
// Link-once, External, or Weakly-linked global variables need
// non-lazily-resolved stubs
if (GV->isExternal() ||
if (GV->isDeclaration() ||
GV->hasWeakLinkage() ||
GV->hasLinkOnceLinkage()) {
// Dynamically-resolved functions need a stub for the function.
@ -310,10 +310,10 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
if (isCallOp && isa<Function>(GV)) {
if (printGOT(TM, Subtarget)) {
// Assemble call via PLT for non-local symbols
if (!GV->hasHiddenVisibility() || GV->isExternal())
if (!GV->hasHiddenVisibility() || GV->isDeclaration())
O << "@PLT";
}
if (Subtarget->isTargetCygMing() && GV->isExternal())
if (Subtarget->isTargetCygMing() && GV->isDeclaration())
// Save function name for later type emission
FnStubs.insert(Name);
}

View File

@ -347,7 +347,7 @@ bool X86IntelAsmPrinter::doInitialization(Module &M) {
// Emit declarations for external functions.
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
if (I->isExternal()) {
if (I->isDeclaration()) {
std::string Name = Mang->getValueName(I);
X86SharedAsmPrinter::decorateName(Name, I);
@ -362,7 +362,7 @@ bool X86IntelAsmPrinter::doInitialization(Module &M) {
// external globals to have type byte, and if that's good enough for VC++...
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
I != E; ++I) {
if (I->isExternal()) {
if (I->isDeclaration()) {
std::string Name = Mang->getValueName(I);
O << "\textern " ;
@ -382,7 +382,7 @@ bool X86IntelAsmPrinter::doFinalization(Module &M) {
// Print out module-level global variables here.
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
I != E; ++I) {
if (I->isExternal()) continue; // External global require no code
if (I->isDeclaration()) continue; // External global require no code
// Check to see if this is a special global used by LLVM, if so, emit it.
if (EmitSpecialLLVMGlobal(I))

View File

@ -40,11 +40,11 @@ bool X86Subtarget::GVRequiresExtraLoad(const GlobalValue* GV,
if (isTargetDarwin()) {
return (!isDirectCall &&
(GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
(GV->isExternal() && !GV->hasNotBeenReadFromBytecode())));
(GV->isDeclaration() && !GV->hasNotBeenReadFromBytecode())));
} else if (TM.getRelocationModel() == Reloc::PIC_ && isPICStyleGOT()) {
// Extra load is needed for all non-statics.
return (!isDirectCall &&
(GV->isExternal() || !GV->hasInternalLinkage()));
(GV->isDeclaration() || !GV->hasInternalLinkage()));
} else if (isTargetCygMing() || isTargetWindows()) {
return (GV->hasDLLImportLinkage());
}

View File

@ -114,7 +114,7 @@ ModulePass *llvm::createDeadArgHackingPass() { return new DAH(); }
/// llvm.vastart is never called, the varargs list is dead for the function.
bool DAE::DeleteDeadVarargs(Function &Fn) {
assert(Fn.getFunctionType()->isVarArg() && "Function isn't varargs!");
if (Fn.isExternal() || !Fn.hasInternalLinkage()) return false;
if (Fn.isDeclaration() || !Fn.hasInternalLinkage()) return false;
// Ensure that the function is only directly called.
for (Value::use_iterator I = Fn.use_begin(), E = Fn.use_end(); I != E; ++I) {

View File

@ -63,7 +63,7 @@ namespace {
Named->setLinkage(GlobalValue::ExternalLinkage);
Named->deleteBody();
assert(Named->isExternal() && "This didn't make the function external!");
assert(Named->isDeclaration() && "This didn't make the function external!");
return true;
}
@ -73,7 +73,7 @@ namespace {
// Mark all global variables internal
for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I)
if (!I->isExternal()) {
if (!I->isDeclaration()) {
I->setInitializer(0); // Make all variables external
I->setLinkage(GlobalValue::ExternalLinkage);
}

View File

@ -174,13 +174,13 @@ static bool ProcessGlobalsWithSameName(Module &M, TargetData &TD,
// to 'int (int)' or 'int ()' or whatever else is not completely generic.
//
Function *F = cast<Function>(Globals[i]);
if (!F->isExternal()) {
if (Concrete && !Concrete->isExternal())
if (!F->isDeclaration()) {
if (Concrete && !Concrete->isDeclaration())
return false; // Found two different functions types. Can't choose!
Concrete = Globals[i];
} else if (Concrete) {
if (Concrete->isExternal()) // If we have multiple external symbols...
if (Concrete->isDeclaration()) // If we have multiple external symbols...
if (F->getFunctionType()->getNumParams() >
cast<Function>(Concrete)->getFunctionType()->getNumParams())
Concrete = F; // We are more concrete than "Concrete"!
@ -190,7 +190,7 @@ static bool ProcessGlobalsWithSameName(Module &M, TargetData &TD,
}
} else {
GlobalVariable *GV = cast<GlobalVariable>(Globals[i]);
if (!GV->isExternal()) {
if (!GV->isDeclaration()) {
if (Concrete) {
cerr << "WARNING: Two global variables with external linkage"
<< " exist with the same name: '" << GV->getName()
@ -211,7 +211,7 @@ static bool ProcessGlobalsWithSameName(Module &M, TargetData &TD,
unsigned NumInstancesWithExternalLinkage = 0;
for (unsigned i = 0, e = Globals.size(); i != e; ++i) {
if (Globals[i]->isExternal())
if (Globals[i]->isDeclaration())
HasExternal = true;
else if (!Globals[i]->hasInternalLinkage())
NumInstancesWithExternalLinkage++;
@ -306,7 +306,7 @@ bool FunctionResolvingPass::runOnModule(Module &M) {
bool Changed = false;
for (Module::iterator I = M.begin(), E = M.end(); I != E; ) {
Function *F = I++;
if (F->use_empty() && F->isExternal()) {
if (F->use_empty() && F->isDeclaration()) {
M.getFunctionList().erase(F);
Changed = true;
} else if (!F->hasInternalLinkage() && !F->getName().empty() &&
@ -317,7 +317,7 @@ bool FunctionResolvingPass::runOnModule(Module &M) {
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
I != E; ) {
GlobalVariable *GV = I++;
if (GV->use_empty() && GV->isExternal()) {
if (GV->use_empty() && GV->isDeclaration()) {
M.getGlobalList().erase(GV);
Changed = true;
} else if (!GV->hasInternalLinkage() && !GV->getName().empty())
@ -337,7 +337,7 @@ bool FunctionResolvingPass::runOnModule(Module &M) {
// dead. If so, remove them now.
for (Module::iterator I = M.begin(), E = M.end(); I != E; )
if (I->isExternal() && I->use_empty()) {
if (I->isDeclaration() && I->use_empty()) {
Function *F = I;
++I;
M.getFunctionList().erase(F);
@ -349,7 +349,7 @@ bool FunctionResolvingPass::runOnModule(Module &M) {
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
I != E; )
if (I->isExternal() && I->use_empty()) {
if (I->isDeclaration() && I->use_empty()) {
GlobalVariable *GV = I;
++I;
M.getGlobalList().erase(GV);

View File

@ -57,7 +57,7 @@ bool GlobalDCE::runOnModule(Module &M) {
Changed |= RemoveUnusedGlobalValue(*I);
// Functions with external linkage are needed if they have a body
if ((!I->hasInternalLinkage() && !I->hasLinkOnceLinkage()) &&
!I->isExternal())
!I->isDeclaration())
GlobalIsNeeded(I);
}
@ -66,7 +66,7 @@ bool GlobalDCE::runOnModule(Module &M) {
// Externally visible & appending globals are needed, if they have an
// initializer.
if ((!I->hasInternalLinkage() && !I->hasLinkOnceLinkage()) &&
!I->isExternal())
!I->isDeclaration())
GlobalIsNeeded(I);
}
@ -89,7 +89,7 @@ bool GlobalDCE::runOnModule(Module &M) {
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
if (!AliveGlobals.count(I)) {
DeadFunctions.push_back(I); // Keep track of dead globals
if (!I->isExternal())
if (!I->isDeclaration())
I->deleteBody();
}

View File

@ -1553,7 +1553,7 @@ static bool isSimpleEnoughPointerToCommit(Constant *C) {
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C)) {
if (!GV->hasExternalLinkage() && !GV->hasInternalLinkage())
return false; // do not allow weak/linkonce/dllimport/dllexport linkage.
return !GV->isExternal(); // reject external globals.
return !GV->isDeclaration(); // reject external globals.
}
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C))
// Handle a constantexpr gep.
@ -1773,7 +1773,7 @@ static bool EvaluateFunction(Function *F, Constant *&RetVal,
for (unsigned i = 1, e = CI->getNumOperands(); i != e; ++i)
Formals.push_back(getVal(Values, CI->getOperand(i)));
if (Callee->isExternal()) {
if (Callee->isDeclaration()) {
// If this is a function we can constant fold, do it.
if (Constant *C = ConstantFoldCall(Callee, Formals)) {
InstResult = C;

View File

@ -51,7 +51,7 @@ bool IPCP::runOnModule(Module &M) {
while (LocalChange) {
LocalChange = false;
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
if (!I->isExternal()) {
if (!I->isDeclaration()) {
// Delete any klingons.
I->removeDeadConstantUsers();
if (I->hasInternalLinkage())

View File

@ -45,7 +45,7 @@ bool IndMemRemPass::runOnModule(Module &M) {
//happen through intrinsics.
bool changed = false;
if (Function* F = M.getNamedFunction("free")) {
assert(F->isExternal() && "free not external?");
assert(F->isDeclaration() && "free not external?");
if (!F->use_empty()) {
Function* FN = new Function(F->getFunctionType(),
GlobalValue::LinkOnceLinkage,
@ -60,7 +60,7 @@ bool IndMemRemPass::runOnModule(Module &M) {
}
}
if (Function* F = M.getNamedFunction("malloc")) {
assert(F->isExternal() && "malloc not external?");
assert(F->isDeclaration() && "malloc not external?");
if (!F->use_empty()) {
Function* FN = new Function(F->getFunctionType(),
GlobalValue::LinkOnceLinkage,

View File

@ -84,7 +84,7 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) {
for (BasicBlock::iterator I = BB->begin(); I != BB->end(); ++I) {
CallSite CS = CallSite::get(I);
if (CS.getInstruction() && (!CS.getCalledFunction() ||
!CS.getCalledFunction()->isExternal()))
!CS.getCalledFunction()->isDeclaration()))
CallSites.push_back(CS);
}
@ -109,7 +109,7 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) {
for (unsigned CSi = 0; CSi != CallSites.size(); ++CSi)
if (Function *Callee = CallSites[CSi].getCalledFunction()) {
// Calls to external functions are never inlinable.
if (Callee->isExternal() ||
if (Callee->isDeclaration() ||
CallSites[CSi].getInstruction()->getParent()->getParent() ==Callee){
if (SCC.size() == 1) {
std::swap(CallSites[CSi], CallSites.back());

View File

@ -96,7 +96,7 @@ bool InternalizePass::runOnModule(Module &M) {
//
if (ExternalNames.empty()) {
Function *MainFunc = M.getMainFunction();
if (MainFunc == 0 || MainFunc->isExternal())
if (MainFunc == 0 || MainFunc->isDeclaration())
return false; // No main found, must be a library...
// Preserve main, internalize all else.
@ -107,7 +107,7 @@ bool InternalizePass::runOnModule(Module &M) {
// Found a main function, mark all functions not named main as internal.
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
if (!I->isExternal() && // Function must be defined here
if (!I->isDeclaration() && // Function must be defined here
!I->hasInternalLinkage() && // Can't already have internal linkage
!ExternalNames.count(I->getName())) {// Not marked to keep external?
I->setLinkage(GlobalValue::InternalLinkage);
@ -129,7 +129,7 @@ bool InternalizePass::runOnModule(Module &M) {
// Mark all global variables with initializers as internal as well.
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
I != E; ++I)
if (!I->isExternal() && !I->hasInternalLinkage() &&
if (!I->isDeclaration() && !I->hasInternalLinkage() &&
!ExternalNames.count(I->getName())) {
// Special case handling of the global ctor and dtor list. When we
// internalize it, we mark it constant, which allows elimination of

View File

@ -72,11 +72,11 @@ bool PruneEH::runOnSCC(const std::vector<CallGraphNode *> &SCC) {
for (unsigned i = 0, e = SCC.size();
(!SCCMightUnwind || !SCCMightReturn) && i != e; ++i) {
Function *F = SCC[i]->getFunction();
if (F == 0 || (F->isExternal() && !F->getIntrinsicID())) {
if (F == 0 || (F->isDeclaration() && !F->getIntrinsicID())) {
SCCMightUnwind = true;
SCCMightReturn = true;
} else {
if (F->isExternal())
if (F->isDeclaration())
SCCMightReturn = true;
// Check to see if this function performs an unwind or calls an

View File

@ -109,8 +109,8 @@ void RaiseAllocations::doInitialization(Module &M) {
}
// Don't mess with locally defined versions of these functions...
if (MallocFunc && !MallocFunc->isExternal()) MallocFunc = 0;
if (FreeFunc && !FreeFunc->isExternal()) FreeFunc = 0;
if (MallocFunc && !MallocFunc->isDeclaration()) MallocFunc = 0;
if (FreeFunc && !FreeFunc->isDeclaration()) FreeFunc = 0;
}
// run - Transform calls into instructions...

View File

@ -177,7 +177,7 @@ public:
// because they live in a runtime library somewhere and were (probably)
// not compiled by LLVM. So, we only act on external functions that
// have external or dllimport linkage and non-empty uses.
if (!FI->isExternal() ||
if (!FI->isDeclaration() ||
!(FI->hasExternalLinkage() || FI->hasDLLImportLinkage()) ||
FI->use_empty())
continue;

View File

@ -54,7 +54,7 @@ bool FunctionProfiler::runOnModule(Module &M) {
unsigned NumFunctions = 0;
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
if (!I->isExternal())
if (!I->isDeclaration())
++NumFunctions;
const Type *ATy = ArrayType::get(Type::Int32Ty, NumFunctions);
@ -65,7 +65,7 @@ bool FunctionProfiler::runOnModule(Module &M) {
// Instrument all of the functions...
unsigned i = 0;
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
if (!I->isExternal())
if (!I->isDeclaration())
// Insert counter at the start of the function
IncrementCounterInBlock(I->begin(), i++, Counters);

View File

@ -81,7 +81,7 @@ bool EmitFunctionTable::runOnModule(Module &M){
unsigned int counter = 0;
for(Module::iterator MI = M.begin(), ME = M.end(); MI != ME; ++MI)
if (!MI->isExternal()) {
if (!MI->isDeclaration()) {
vType.push_back(MI->getType());
//std::cerr<<MI;

View File

@ -499,7 +499,7 @@ void ProfilerRS::ProcessBackEdge(BasicBlock* src, BasicBlock* dst, Function& F)
}
bool ProfilerRS::runOnFunction(Function& F) {
if (!F.isExternal()) {
if (!F.isDeclaration()) {
std::set<std::pair<BasicBlock*, BasicBlock*> > BackEdges;
RSProfilers& LI = getAnalysis<RSProfilers>();

View File

@ -7234,7 +7234,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
// Check to see if we are changing the return type...
if (OldRetTy != FT->getReturnType()) {
if (Callee->isExternal() && !Caller->use_empty() &&
if (Callee->isDeclaration() && !Caller->use_empty() &&
OldRetTy != FT->getReturnType() &&
// Conversion is ok if changing from pointer to int of same size.
!(isa<PointerType>(FT->getReturnType()) &&
@ -7270,11 +7270,11 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
ParamTy->getPrimitiveSizeInBits() >= ActTy->getPrimitiveSizeInBits()) ||
(c && ParamTy->getPrimitiveSizeInBits() >= ActTy->getPrimitiveSizeInBits()
&& c->getSExtValue() > 0);
if (Callee->isExternal() && !isConvertible) return false;
if (Callee->isDeclaration() && !isConvertible) return false;
}
if (FT->getNumParams() < NumActualArgs && !FT->isVarArg() &&
Callee->isExternal())
Callee->isDeclaration())
return false; // Do not delete arguments unless we have a function body...
// Okay, we decided that this is a safe thing to do: go ahead and start
@ -8102,14 +8102,14 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) {
// Instcombine load (constant global) into the value loaded.
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Op))
if (GV->isConstant() && !GV->isExternal())
if (GV->isConstant() && !GV->isDeclaration())
return ReplaceInstUsesWith(LI, GV->getInitializer());
// Instcombine load (constantexpr_GEP global, 0, ...) into the value loaded.
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Op))
if (CE->getOpcode() == Instruction::GetElementPtr) {
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(CE->getOperand(0)))
if (GV->isConstant() && !GV->isExternal())
if (GV->isConstant() && !GV->isDeclaration())
if (Constant *V =
ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE))
return ReplaceInstUsesWith(LI, V);

View File

@ -130,7 +130,7 @@ bool LowerGC::doInitialization(Module &M) {
GlobalValue::LinkOnceLinkage,
Constant::getNullValue(PRLTy),
"llvm_gc_root_chain", &M);
} else if (RootChain->hasExternalLinkage() && RootChain->isExternal()) {
} else if (RootChain->hasExternalLinkage() && RootChain->isDeclaration()) {
RootChain->setInitializer(Constant::getNullValue(PRLTy));
RootChain->setLinkage(GlobalValue::LinkOnceLinkage);
}

View File

@ -49,7 +49,7 @@ namespace {
}
virtual bool runOnFunction(Function &F) {
if (!F.isExternal()) {
if (!F.isDeclaration()) {
//give us a clean block
BasicBlock* bbold = &F.getEntryBlock();
BasicBlock* bbnew = new BasicBlock("allocablock", &F, &F.getEntryBlock());

View File

@ -1021,7 +1021,7 @@ void SCCPSolver::visitLoadInst(LoadInst &I) {
// Transform load (constant global) into the value loaded.
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Ptr)) {
if (GV->isConstant()) {
if (!GV->isExternal()) {
if (!GV->isDeclaration()) {
markConstant(IV, &I, GV->getInitializer());
return;
}
@ -1040,7 +1040,7 @@ void SCCPSolver::visitLoadInst(LoadInst &I) {
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Ptr))
if (CE->getOpcode() == Instruction::GetElementPtr)
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(CE->getOperand(0)))
if (GV->isConstant() && !GV->isExternal())
if (GV->isConstant() && !GV->isDeclaration())
if (Constant *V =
ConstantFoldLoadThroughGEPConstantExpr(GV->getInitializer(), CE)) {
markConstant(IV, &I, V);
@ -1088,7 +1088,7 @@ void SCCPSolver::visitCallSite(CallSite CS) {
return;
}
if (F == 0 || !F->isExternal() || !canConstantFoldCallTo(F)) {
if (F == 0 || !F->isDeclaration() || !canConstantFoldCallTo(F)) {
markOverdefined(IV, I);
return;
}
@ -1486,7 +1486,7 @@ bool IPSCCP::runOnModule(Module &M) {
hash_map<Value*, LatticeVal> &Values = Solver.getValueMapping();
for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F)
if (!F->hasInternalLinkage() || AddressIsTaken(F)) {
if (!F->isExternal())
if (!F->isDeclaration())
Solver.MarkBlockExecutable(F->begin());
for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end();
AI != E; ++AI)

View File

@ -87,7 +87,7 @@ Module *llvm::CloneModule(const Module *M, std::map<const Value*, Value*> &Value
//
for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) {
Function *F = cast<Function>(ValueMap[I]);
if (!I->isExternal()) {
if (!I->isDeclaration()) {
Function::arg_iterator DestI = F->arg_begin();
for (Function::const_arg_iterator J = I->arg_begin(); J != I->arg_end();
++J) {

View File

@ -184,7 +184,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG) {
const Function *CalledFunc = CS.getCalledFunction();
if (CalledFunc == 0 || // Can't inline external function or indirect
CalledFunc->isExternal() || // call, or call to a vararg function!
CalledFunc->isDeclaration() || // call, or call to a vararg function!
CalledFunc->getFunctionType()->isVarArg()) return false;

View File

@ -925,7 +925,7 @@ void AssemblyWriter::printFunction(const Function *F) {
if (AnnotationWriter) AnnotationWriter->emitFunctionAnnot(F, Out);
if (F->isExternal())
if (F->isDeclaration())
switch (F->getLinkage()) {
case GlobalValue::DLLImportLinkage: Out << "declare dllimport "; break;
case GlobalValue::ExternalWeakLinkage: Out << "declare extern_weak "; break;
@ -996,7 +996,7 @@ void AssemblyWriter::printFunction(const Function *F) {
if (F->getAlignment())
Out << " align " << F->getAlignment();
if (F->isExternal()) {
if (F->isDeclaration()) {
Out << "\n";
} else {
Out << " {";

View File

@ -170,8 +170,8 @@ void Mangler::InsertName(GlobalValue *GV,
GV->hasDLLImportLinkage()) &&
(ExistingValue->hasExternalLinkage() ||
ExistingValue->hasDLLImportLinkage()) &&
GV->isExternal() &&
ExistingValue->isExternal()) {
GV->isDeclaration() &&
ExistingValue->isDeclaration()) {
// If the two globals both have external inkage, and are both external,
// don't mangle either of them, we just have some silly type mismatch.
} else {

View File

@ -250,7 +250,7 @@ Function *Module::getNamedFunction(const std::string &Name) const {
const Function *Found = 0;
for (const_iterator I = begin(), E = end(); I != E; ++I)
if (I->getName() == Name)
if (I->isExternal())
if (I->isDeclaration())
Found = I;
else
return const_cast<Function*>(&(*I));

View File

@ -76,7 +76,7 @@ bool FunctionPass::runOnModule(Module &M) {
bool Changed = doInitialization(M);
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
if (!I->isExternal()) // Passes are not run on external functions!
if (!I->isDeclaration()) // Passes are not run on external functions!
Changed |= runOnFunction(*I);
return Changed | doFinalization(M);
@ -85,7 +85,7 @@ bool FunctionPass::runOnModule(Module &M) {
// run - On a function, we simply initialize, run the function, then finalize.
//
bool FunctionPass::run(Function &F) {
if (F.isExternal()) return false;// Passes are not run on external functions!
if (F.isDeclaration()) return false;// Passes are not run on external functions!
bool Changed = doInitialization(*F.getParent());
Changed |= runOnFunction(F);

View File

@ -751,7 +751,7 @@ Pass *AnalysisResolver::getAnalysisToUpdate(AnalysisID ID, bool dir) const {
bool
BBPassManager::runOnFunction(Function &F) {
if (F.isExternal())
if (F.isDeclaration())
return false;
bool Changed = doInitialization(F);
@ -952,7 +952,7 @@ bool FPPassManager::runOnFunction(Function &F) {
bool Changed = false;
if (F.isExternal())
if (F.isDeclaration())
return false;
std::string Msg1 = "Executing Pass '";

View File

@ -255,11 +255,11 @@ void SymbolTable::refineAbstractType(const DerivedType *OldType,
GlobalValue *NewGV = dyn_cast<GlobalValue>(V.second);
if (ExistGV && NewGV) {
assert((ExistGV->isExternal() || NewGV->isExternal()) &&
assert((ExistGV->isDeclaration() || NewGV->isDeclaration()) &&
"Two planes folded together with overlapping value names!");
// Make sure that ExistGV is the one we want to keep!
if (!NewGV->isExternal())
if (!NewGV->isDeclaration())
std::swap(NewGV, ExistGV);
// Ok we have two external global values. Make all uses of the new

View File

@ -132,7 +132,7 @@ namespace { // Anonymous namespace for class
visitGlobalValue(*I);
// Check to make sure function prototypes are okay.
if (I->isExternal()) visitFunction(*I);
if (I->isDeclaration()) visitFunction(*I);
}
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
@ -274,14 +274,14 @@ namespace { // Anonymous namespace for class
void Verifier::visitGlobalValue(GlobalValue &GV) {
Assert1(!GV.isExternal() ||
Assert1(!GV.isDeclaration() ||
GV.hasExternalLinkage() ||
GV.hasDLLImportLinkage() ||
GV.hasExternalWeakLinkage(),
"Global is external, but doesn't have external or dllimport or weak linkage!",
&GV);
Assert1(!GV.hasDLLImportLinkage() || GV.isExternal(),
Assert1(!GV.hasDLLImportLinkage() || GV.isDeclaration(),
"Global is marked as dllimport, but not external", &GV);
Assert1(!GV.hasAppendingLinkage() || isa<GlobalVariable>(GV),
@ -369,7 +369,7 @@ void Verifier::visitFunction(Function &F) {
"Functions cannot take aggregates as arguments by value!", I);
}
if (!F.isExternal()) {
if (!F.isDeclaration()) {
// Verify that this function (which has a body) is not named "llvm.*". It
// is not legal to define intrinsics.
if (F.getName().size() >= 5)
@ -968,7 +968,7 @@ void Verifier::visitInstruction(Instruction &I) {
///
void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
Function *IF = CI.getCalledFunction();
Assert1(IF->isExternal(), "Intrinsic functions should never be defined!", IF);
Assert1(IF->isDeclaration(), "Intrinsic functions should never be defined!", IF);
#define GET_INTRINSIC_VERIFIER
#include "llvm/Intrinsics.gen"
@ -1070,7 +1070,7 @@ FunctionPass *llvm::createVerifierPass(VerifierFailureAction action) {
// verifyFunction - Create
bool llvm::verifyFunction(const Function &f, VerifierFailureAction action) {
Function &F = const_cast<Function&>(f);
assert(!F.isExternal() && "Cannot verify external functions");
assert(!F.isDeclaration() && "Cannot verify external functions");
FunctionPassManager FPM(new ExistingModuleProvider(F.getParent()));
Verifier *V = new Verifier(action);

View File

@ -219,7 +219,7 @@ bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &Funcs) {
// Loop over and delete any functions which we aren't supposed to be playing
// with...
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
if (!I->isExternal() && !Functions.count(I))
if (!I->isDeclaration() && !Functions.count(I))
DeleteFunctionBody(I);
// Try running the hacked up program...
@ -406,7 +406,7 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) {
std::vector<Function*> Functions;
for (Module::iterator I = BD.getProgram()->begin(),
E = BD.getProgram()->end(); I != E; ++I)
if (!I->isExternal())
if (!I->isDeclaration())
Functions.push_back(I);
if (Functions.size() > 1 && !BugpointIsInterrupted) {
@ -459,7 +459,7 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) {
unsigned CurInstructionNum = 0;
for (Module::const_iterator FI = BD.getProgram()->begin(),
E = BD.getProgram()->end(); FI != E; ++FI)
if (!FI->isExternal())
if (!FI->isDeclaration())
for (Function::const_iterator BI = FI->begin(), E = FI->end(); BI != E;
++BI)
for (BasicBlock::const_iterator I = BI->begin(), E = --BI->end();

View File

@ -170,7 +170,7 @@ Module *BugDriver::ExtractLoop(Module *M) {
void llvm::DeleteFunctionBody(Function *F) {
// delete the body of the function...
F->deleteBody();
assert(F->isExternal() && "This didn't make the function external!");
assert(F->isDeclaration() && "This didn't make the function external!");
}
/// GetTorInit - Given a list of entries for static ctors/dtors, return them
@ -195,7 +195,7 @@ static Constant *GetTorInit(std::vector<std::pair<Function*, int> > &TorList) {
/// prune appropriate entries out of M1s list.
static void SplitStaticCtorDtor(const char *GlobalName, Module *M1, Module *M2){
GlobalVariable *GV = M1->getNamedGlobal(GlobalName);
if (!GV || GV->isExternal() || GV->hasInternalLinkage() ||
if (!GV || GV->isDeclaration() || GV->hasInternalLinkage() ||
!GV->use_empty()) return;
std::vector<std::pair<Function*, int> > M1Tors, M2Tors;
@ -217,7 +217,7 @@ static void SplitStaticCtorDtor(const char *GlobalName, Module *M1, Module *M2){
if (CE->isCast())
FP = CE->getOperand(0);
if (Function *F = dyn_cast<Function>(FP)) {
if (!F->isExternal())
if (!F->isDeclaration())
M1Tors.push_back(std::make_pair(F, Priority));
else {
// Map to M2's version of the function.

View File

@ -320,7 +320,7 @@ static bool ExtractLoops(BugDriver &BD,
std::vector<std::pair<std::string, const FunctionType*> > MisCompFunctions;
for (Module::iterator I = ToOptimizeLoopExtracted->begin(),
E = ToOptimizeLoopExtracted->end(); I != E; ++I)
if (!I->isExternal())
if (!I->isDeclaration())
MisCompFunctions.push_back(std::make_pair(I->getName(),
I->getFunctionType()));
@ -460,7 +460,7 @@ static bool ExtractBlocks(BugDriver &BD,
std::vector<std::pair<std::string, const FunctionType*> > MisCompFunctions;
for (Module::iterator I = Extracted->begin(), E = Extracted->end();
I != E; ++I)
if (!I->isExternal())
if (!I->isDeclaration())
MisCompFunctions.push_back(std::make_pair(I->getName(),
I->getFunctionType()));
@ -502,7 +502,7 @@ DebugAMiscompilation(BugDriver &BD,
std::vector<Function*> MiscompiledFunctions;
Module *Prog = BD.getProgram();
for (Module::iterator I = Prog->begin(), E = Prog->end(); I != E; ++I)
if (!I->isExternal())
if (!I->isDeclaration())
MiscompiledFunctions.push_back(I);
// Do the reduction...
@ -637,7 +637,7 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
// the Test module to call into it. Thus, we create a new function `main'
// which just calls the old one.
if (Function *oldMain = Safe->getNamedFunction("main"))
if (!oldMain->isExternal()) {
if (!oldMain->isDeclaration()) {
// Rename it
oldMain->setName("llvm_bugpoint_old_main");
// Create a NEW `main' function with same type in the test module.
@ -680,12 +680,12 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
// Use the function we just added to get addresses of functions we need.
for (Module::iterator F = Safe->begin(), E = Safe->end(); F != E; ++F) {
if (F->isExternal() && !F->use_empty() && &*F != resolverFunc &&
if (F->isDeclaration() && !F->use_empty() && &*F != resolverFunc &&
F->getIntrinsicID() == 0 /* ignore intrinsics */) {
Function *TestFn = Test->getNamedFunction(F->getName());
// Don't forward functions which are external in the test module too.
if (TestFn && !TestFn->isExternal()) {
if (TestFn && !TestFn->isDeclaration()) {
// 1. Add a string constant with its name to the global file
Constant *InitArray = ConstantArray::get(F->getName());
GlobalVariable *funcName =

View File

@ -260,7 +260,7 @@ int main(int argc, char **argv) {
// Run our queue of passes all at once now, efficiently.
// TODO: this could lazily stream functions out of the module.
for (Module::iterator I = mod.begin(), E = mod.end(); I != E; ++I)
if (!I->isExternal())
if (!I->isDeclaration())
Passes.run(*I);
Passes.doFinalization();

View File

@ -67,7 +67,7 @@ namespace {
}
static char TypeCharForSymbol(GlobalValue &GV) {
if (GV.isExternal()) return 'U';
if (GV.isDeclaration()) return 'U';
if (GV.hasLinkOnceLinkage()) return 'C';
if (GV.hasWeakLinkage()) return 'W';
if (isa<Function>(GV) && GV.hasInternalLinkage()) return 't';

View File

@ -5113,11 +5113,11 @@ yyreduce:
(Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
// If this is the case, either we need to be a forward decl, or it needs
// to be.
if (!CurFun.isDeclare && !Fn->isExternal())
if (!CurFun.isDeclare && !Fn->isDeclaration())
error("Redefinition of function '" + FunctionName + "'");
// Make sure to strip off any argument names so we can't get conflicts.
if (Fn->isExternal())
if (Fn->isDeclaration())
for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
AI != AE; ++AI)
AI->setName("");

View File

@ -2619,11 +2619,11 @@ FunctionHeaderH
(Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
// If this is the case, either we need to be a forward decl, or it needs
// to be.
if (!CurFun.isDeclare && !Fn->isExternal())
if (!CurFun.isDeclare && !Fn->isDeclaration())
error("Redefinition of function '" + FunctionName + "'");
// Make sure to strip off any argument names so we can't get conflicts.
if (Fn->isExternal())
if (Fn->isDeclaration())
for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
AI != AE; ++AI)
AI->setName("");

View File

@ -2619,11 +2619,11 @@ FunctionHeaderH
(Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
// If this is the case, either we need to be a forward decl, or it needs
// to be.
if (!CurFun.isDeclare && !Fn->isExternal())
if (!CurFun.isDeclare && !Fn->isDeclaration())
error("Redefinition of function '" + FunctionName + "'");
// Make sure to strip off any argument names so we can't get conflicts.
if (Fn->isExternal())
if (Fn->isDeclaration())
for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
AI != AE; ++AI)
AI->setName("");

View File

@ -1452,7 +1452,7 @@ void CppWriter::printFunctionHead(const Function* F) {
Out << ",";
nl(Out) << "/*Name=*/\"";
printEscapedString(F->getName());
Out << "\", mod); " << (F->isExternal()? "// (external, no body)" : "");
Out << "\", mod); " << (F->isDeclaration()? "// (external, no body)" : "");
nl(Out,-1);
printCppName(F);
Out << "->setCallingConv(";
@ -1476,7 +1476,7 @@ void CppWriter::printFunctionHead(const Function* F) {
}
void CppWriter::printFunctionBody(const Function *F) {
if (F->isExternal())
if (F->isDeclaration())
return; // external functions have no bodies.
// Clear the DefinedValues and ForwardRefs maps because we can't have
@ -1550,7 +1550,7 @@ void CppWriter::printInline(const std::string& fname, const std::string& func) {
error(std::string("Function '") + func + "' not found in input module");
return;
}
if (F->isExternal()) {
if (F->isDeclaration()) {
error(std::string("Function '") + func + "' is external!");
return;
}
@ -1611,7 +1611,7 @@ void CppWriter::printModuleBody() {
nl(Out) << "// Function Definitions"; nl(Out);
for (Module::const_iterator I = TheModule->begin(), E = TheModule->end();
I != E; ++I) {
if (!I->isExternal()) {
if (!I->isDeclaration()) {
nl(Out) << "// Function: " << I->getName() << " (" << getCppName(I)
<< ")";
nl(Out) << "{";

View File

@ -164,7 +164,7 @@ LTO::readLLVMObjectFile(const std::string &InputFilename,
LTOLinkageTypes lt = getLTOLinkageType(f);
if (!f->isExternal() && lt != LTOInternalLinkage
if (!f->isDeclaration() && lt != LTOInternalLinkage
&& strncmp (f->getName().c_str(), "llvm.", 5)) {
int alignment = ( 16 > f->getAlignment() ? 16 : f->getAlignment());
LLVMSymbol *newSymbol = new LLVMSymbol(lt, f, f->getName(),
@ -186,7 +186,7 @@ LTO::readLLVMObjectFile(const std::string &InputFilename,
for (Module::global_iterator v = m->global_begin(), e = m->global_end();
v != e; ++v) {
LTOLinkageTypes lt = getLTOLinkageType(v);
if (!v->isExternal() && lt != LTOInternalLinkage
if (!v->isDeclaration() && lt != LTOInternalLinkage
&& strncmp (v->getName().c_str(), "llvm.", 5)) {
const TargetData *TD = Target->getTargetData();
LLVMSymbol *newSymbol = new LLVMSymbol(lt, v, v->getName(),
@ -324,7 +324,7 @@ LTO::optimize(Module *M, std::ostream &Out,
// Run the code generator, if present.
CodeGenPasses->doInitialization();
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) {
if (!I->isExternal())
if (!I->isDeclaration())
CodeGenPasses->run(*I);
}
CodeGenPasses->doFinalization();

View File

@ -32,7 +32,7 @@ namespace {
struct ExternalFunctionsPassedConstants : public ModulePass {
virtual bool runOnModule(Module &M) {
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
if (I->isExternal()) {
if (I->isDeclaration()) {
bool PrintedFn = false;
for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
UI != E; ++UI)