2003-09-30 20:37:50 +02:00
|
|
|
//===-- llvm/GlobalValue.h - Class to represent a global value --*- C++ -*-===//
|
2005-04-21 22:19:05 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:59:42 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 22:19:05 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-10-03 16:53:21 +02:00
|
|
|
//
|
|
|
|
// This file is a common base class of all globally definable objects. As such,
|
2007-04-30 21:14:56 +02:00
|
|
|
// it is subclassed by GlobalVariable, GlobalAlias and by Function. This is
|
|
|
|
// used because you can do certain things with these global objects that you
|
|
|
|
// can't do to anything else. For example, use the address of one as a
|
|
|
|
// constant.
|
2001-10-03 16:53:21 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_GLOBALVALUE_H
|
|
|
|
#define LLVM_GLOBALVALUE_H
|
|
|
|
|
2004-07-18 01:28:28 +02:00
|
|
|
#include "llvm/Constant.h"
|
2003-11-11 23:41:34 +01:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2001-10-03 16:53:21 +02:00
|
|
|
class PointerType;
|
2002-04-28 06:45:05 +02:00
|
|
|
class Module;
|
2001-10-03 16:53:21 +02:00
|
|
|
|
2004-07-18 01:28:28 +02:00
|
|
|
class GlobalValue : public Constant {
|
2001-10-03 16:53:21 +02:00
|
|
|
GlobalValue(const GlobalValue &); // do not implement
|
2003-04-16 22:28:45 +02:00
|
|
|
public:
|
2007-01-27 05:42:50 +01:00
|
|
|
/// @brief An enumeration for the kinds of linkage for global values.
|
2003-04-16 22:28:45 +02:00
|
|
|
enum LinkageTypes {
|
2007-04-17 06:31:29 +02:00
|
|
|
ExternalLinkage = 0,///< Externally visible function
|
2009-04-13 07:44:34 +02:00
|
|
|
AvailableExternallyLinkage, ///< Available for inspection, not emission.
|
Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr. These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global. In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time. This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function. If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body. The
code generators on the other hand map weak and weak_odr linkage
to the same thing.
llvm-svn: 66339
2009-03-07 16:45:40 +01:00
|
|
|
LinkOnceAnyLinkage, ///< Keep one copy of function when linking (inline)
|
|
|
|
LinkOnceODRLinkage, ///< Same, but only replaced by something equivalent.
|
|
|
|
WeakAnyLinkage, ///< Keep one copy of named function when linking (weak)
|
|
|
|
WeakODRLinkage, ///< Same, but only replaced by something equivalent.
|
2007-01-27 05:42:50 +01:00
|
|
|
AppendingLinkage, ///< Special purpose, only applies to global arrays
|
|
|
|
InternalLinkage, ///< Rename collisions when linking (static functions)
|
2009-01-15 21:18:42 +01:00
|
|
|
PrivateLinkage, ///< Like Internal, but omit from symbol table
|
2007-01-27 05:42:50 +01:00
|
|
|
DLLImportLinkage, ///< Function to be imported from DLL
|
|
|
|
DLLExportLinkage, ///< Function to be accessible from DLL
|
2009-03-11 09:08:06 +01:00
|
|
|
ExternalWeakLinkage,///< ExternalWeak linkage description
|
2008-05-14 22:12:51 +02:00
|
|
|
GhostLinkage, ///< Stand-in functions for streaming fns from BC files
|
2009-03-11 21:14:15 +01:00
|
|
|
CommonLinkage ///< Tentative definitions
|
2003-04-16 22:28:45 +02:00
|
|
|
};
|
2007-01-27 05:42:50 +01:00
|
|
|
|
|
|
|
/// @brief An enumeration for the kinds of visibility of global values.
|
2007-01-12 20:20:47 +01:00
|
|
|
enum VisibilityTypes {
|
2007-04-17 06:31:29 +02:00
|
|
|
DefaultVisibility = 0, ///< The GV is visible
|
2007-04-29 20:35:00 +02:00
|
|
|
HiddenVisibility, ///< The GV is hidden
|
|
|
|
ProtectedVisibility ///< The GV is protected
|
2007-01-12 20:20:47 +01:00
|
|
|
};
|
2007-01-27 05:42:50 +01:00
|
|
|
|
2001-10-03 16:53:21 +02:00
|
|
|
protected:
|
2008-05-19 22:15:12 +02:00
|
|
|
GlobalValue(const Type *ty, ValueTy vty, Use *Ops, unsigned NumOps,
|
2005-01-29 01:33:00 +01:00
|
|
|
LinkageTypes linkage, const std::string &name = "")
|
2008-05-19 22:15:12 +02:00
|
|
|
: Constant(ty, vty, Ops, NumOps), Parent(0),
|
2007-02-12 06:18:08 +01:00
|
|
|
Linkage(linkage), Visibility(DefaultVisibility), Alignment(0) {
|
|
|
|
if (!name.empty()) setName(name);
|
|
|
|
}
|
2001-10-03 21:28:15 +02:00
|
|
|
|
|
|
|
Module *Parent;
|
2007-04-21 17:29:13 +02:00
|
|
|
// Note: VC++ treats enums as signed, so an extra bit is required to prevent
|
|
|
|
// Linkage and Visibility from turning into negative values.
|
|
|
|
LinkageTypes Linkage : 5; // The linkage of this global
|
2007-04-29 20:35:00 +02:00
|
|
|
unsigned Visibility : 2; // The visibility style of this global
|
2007-04-17 06:31:29 +02:00
|
|
|
unsigned Alignment : 16; // Alignment of this symbol, must be power of two
|
|
|
|
std::string Section; // Section to emit this into, empty mean default
|
2007-12-09 23:46:10 +01:00
|
|
|
public:
|
2007-12-10 03:14:30 +01:00
|
|
|
~GlobalValue() {
|
|
|
|
removeDeadConstantUsers(); // remove any dead constants using this.
|
|
|
|
}
|
|
|
|
|
2005-11-06 07:44:42 +01:00
|
|
|
unsigned getAlignment() const { return Alignment; }
|
|
|
|
void setAlignment(unsigned Align) {
|
|
|
|
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
|
|
|
|
Alignment = Align;
|
|
|
|
}
|
2007-01-12 20:20:47 +01:00
|
|
|
|
2007-08-12 10:12:35 +02:00
|
|
|
VisibilityTypes getVisibility() const { return VisibilityTypes(Visibility); }
|
2007-01-12 20:20:47 +01:00
|
|
|
bool hasHiddenVisibility() const { return Visibility == HiddenVisibility; }
|
2007-04-29 20:35:00 +02:00
|
|
|
bool hasProtectedVisibility() const {
|
|
|
|
return Visibility == ProtectedVisibility;
|
|
|
|
}
|
2007-01-12 20:20:47 +01:00
|
|
|
void setVisibility(VisibilityTypes V) { Visibility = V; }
|
2005-11-06 07:44:42 +01:00
|
|
|
|
2005-11-12 01:09:49 +01:00
|
|
|
bool hasSection() const { return !Section.empty(); }
|
|
|
|
const std::string &getSection() const { return Section; }
|
|
|
|
void setSection(const std::string &S) { Section = S; }
|
|
|
|
|
2004-07-18 01:28:28 +02:00
|
|
|
/// If the usage is empty (except transitively dead constants), then this
|
2005-04-21 22:19:05 +02:00
|
|
|
/// global value can can be safely deleted since the destructor will
|
2004-07-18 01:28:28 +02:00
|
|
|
/// delete the dead constants as well.
|
2005-04-21 22:19:05 +02:00
|
|
|
/// @brief Determine if the usage of this global value is empty except
|
2004-07-18 01:28:28 +02:00
|
|
|
/// for transitively dead constants.
|
|
|
|
bool use_empty_except_constants();
|
2001-10-03 16:53:21 +02:00
|
|
|
|
2002-10-10 01:11:33 +02:00
|
|
|
/// getType - Global values are always pointers.
|
2001-10-03 16:53:21 +02:00
|
|
|
inline const PointerType *getType() const {
|
2003-11-16 21:21:15 +01:00
|
|
|
return reinterpret_cast<const PointerType*>(User::getType());
|
2001-10-03 16:53:21 +02:00
|
|
|
}
|
|
|
|
|
Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr. These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global. In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time. This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function. If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body. The
code generators on the other hand map weak and weak_odr linkage
to the same thing.
llvm-svn: 66339
2009-03-07 16:45:40 +01:00
|
|
|
static LinkageTypes getLinkOnceLinkage(bool ODR) {
|
|
|
|
return ODR ? LinkOnceODRLinkage : LinkOnceAnyLinkage;
|
|
|
|
}
|
|
|
|
static LinkageTypes getWeakLinkage(bool ODR) {
|
|
|
|
return ODR ? WeakODRLinkage : WeakAnyLinkage;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasExternalLinkage() const { return Linkage == ExternalLinkage; }
|
2009-04-13 07:44:34 +02:00
|
|
|
bool hasAvailableExternallyLinkage() const {
|
|
|
|
return Linkage == AvailableExternallyLinkage;
|
|
|
|
}
|
Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr. These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global. In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time. This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function. If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body. The
code generators on the other hand map weak and weak_odr linkage
to the same thing.
llvm-svn: 66339
2009-03-07 16:45:40 +01:00
|
|
|
bool hasLinkOnceLinkage() const {
|
|
|
|
return Linkage == LinkOnceAnyLinkage || Linkage == LinkOnceODRLinkage;
|
|
|
|
}
|
|
|
|
bool hasWeakLinkage() const {
|
|
|
|
return Linkage == WeakAnyLinkage || Linkage == WeakODRLinkage;
|
|
|
|
}
|
|
|
|
bool hasAppendingLinkage() const { return Linkage == AppendingLinkage; }
|
|
|
|
bool hasInternalLinkage() const { return Linkage == InternalLinkage; }
|
|
|
|
bool hasPrivateLinkage() const { return Linkage == PrivateLinkage; }
|
|
|
|
bool hasLocalLinkage() const {
|
2009-05-23 16:06:57 +02:00
|
|
|
return Linkage == InternalLinkage || Linkage == PrivateLinkage;
|
2009-01-15 21:18:42 +01:00
|
|
|
}
|
Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr. These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global. In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time. This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function. If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body. The
code generators on the other hand map weak and weak_odr linkage
to the same thing.
llvm-svn: 66339
2009-03-07 16:45:40 +01:00
|
|
|
bool hasDLLImportLinkage() const { return Linkage == DLLImportLinkage; }
|
|
|
|
bool hasDLLExportLinkage() const { return Linkage == DLLExportLinkage; }
|
2009-03-11 09:08:06 +01:00
|
|
|
bool hasExternalWeakLinkage() const { return Linkage == ExternalWeakLinkage; }
|
Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr. These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global. In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time. This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function. If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body. The
code generators on the other hand map weak and weak_odr linkage
to the same thing.
llvm-svn: 66339
2009-03-07 16:45:40 +01:00
|
|
|
bool hasGhostLinkage() const { return Linkage == GhostLinkage; }
|
2009-03-11 21:14:15 +01:00
|
|
|
bool hasCommonLinkage() const { return Linkage == CommonLinkage; }
|
Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr. These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global. In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time. This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function. If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body. The
code generators on the other hand map weak and weak_odr linkage
to the same thing.
llvm-svn: 66339
2009-03-07 16:45:40 +01:00
|
|
|
|
2003-04-16 22:28:45 +02:00
|
|
|
void setLinkage(LinkageTypes LT) { Linkage = LT; }
|
|
|
|
LinkageTypes getLinkage() const { return Linkage; }
|
2001-11-26 19:46:40 +01:00
|
|
|
|
2008-09-29 13:25:42 +02:00
|
|
|
/// mayBeOverridden - Whether the definition of this global may be replaced
|
Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr. These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global. In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time. This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function. If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body. The
code generators on the other hand map weak and weak_odr linkage
to the same thing.
llvm-svn: 66339
2009-03-07 16:45:40 +01:00
|
|
|
/// by something non-equivalent at link time. For example, if a function has
|
|
|
|
/// weak linkage then the code defining it may be replaced by different code.
|
2008-09-29 13:25:42 +02:00
|
|
|
bool mayBeOverridden() const {
|
Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr. These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global. In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time. This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function. If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body. The
code generators on the other hand map weak and weak_odr linkage
to the same thing.
llvm-svn: 66339
2009-03-07 16:45:40 +01:00
|
|
|
return (Linkage == WeakAnyLinkage ||
|
|
|
|
Linkage == LinkOnceAnyLinkage ||
|
2009-03-11 21:14:15 +01:00
|
|
|
Linkage == CommonLinkage ||
|
2009-03-11 09:08:06 +01:00
|
|
|
Linkage == ExternalWeakLinkage);
|
Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr. These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global. In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time. This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function. If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body. The
code generators on the other hand map weak and weak_odr linkage
to the same thing.
llvm-svn: 66339
2009-03-07 16:45:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/// isWeakForLinker - Whether the definition of this global may be replaced at
|
2009-04-13 07:44:34 +02:00
|
|
|
/// link time.
|
Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr. These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global. In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time. This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function. If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body. The
code generators on the other hand map weak and weak_odr linkage
to the same thing.
llvm-svn: 66339
2009-03-07 16:45:40 +01:00
|
|
|
bool isWeakForLinker() const {
|
2009-04-13 07:44:34 +02:00
|
|
|
return (Linkage == AvailableExternallyLinkage ||
|
|
|
|
Linkage == WeakAnyLinkage ||
|
Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr. These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global. In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time. This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function. If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body. The
code generators on the other hand map weak and weak_odr linkage
to the same thing.
llvm-svn: 66339
2009-03-07 16:45:40 +01:00
|
|
|
Linkage == WeakODRLinkage ||
|
|
|
|
Linkage == LinkOnceAnyLinkage ||
|
|
|
|
Linkage == LinkOnceODRLinkage ||
|
2009-03-11 21:14:15 +01:00
|
|
|
Linkage == CommonLinkage ||
|
2009-03-11 09:08:06 +01:00
|
|
|
Linkage == ExternalWeakLinkage);
|
2008-07-06 01:48:30 +02:00
|
|
|
}
|
|
|
|
|
2008-05-26 21:58:59 +02:00
|
|
|
/// copyAttributesFrom - copy all additional attributes (those not needed to
|
|
|
|
/// create a GlobalValue) from the GlobalValue Src to this one.
|
|
|
|
virtual void copyAttributesFrom(const GlobalValue *Src);
|
|
|
|
|
2007-07-05 19:07:56 +02:00
|
|
|
/// hasNotBeenReadFromBitcode - If a module provider is being used to lazily
|
2004-11-16 00:20:19 +01:00
|
|
|
/// stream in functions from disk, this method can be used to check to see if
|
|
|
|
/// the function has been read in yet or not. Unless you are working on the
|
|
|
|
/// JIT or something else that streams stuff in lazily, you don't need to
|
|
|
|
/// worry about this.
|
2007-07-05 19:07:56 +02:00
|
|
|
bool hasNotBeenReadFromBitcode() const { return Linkage == GhostLinkage; }
|
2004-11-16 00:20:19 +01:00
|
|
|
|
|
|
|
/// Override from Constant class. No GlobalValue's are null values so this
|
|
|
|
/// always returns false.
|
2004-07-18 01:28:28 +02:00
|
|
|
virtual bool isNullValue() const { return false; }
|
|
|
|
|
|
|
|
/// Override from Constant class.
|
2009-06-20 02:24:58 +02:00
|
|
|
virtual void destroyConstant();
|
2004-07-18 01:28:28 +02:00
|
|
|
|
2007-01-30 21:08:39 +01:00
|
|
|
/// isDeclaration - Return true if the primary definition of this global
|
|
|
|
/// value is outside of the current translation unit...
|
|
|
|
virtual bool isDeclaration() const = 0;
|
2002-10-10 01:11:33 +02:00
|
|
|
|
2008-08-29 09:30:15 +02:00
|
|
|
/// removeFromParent - This method unlinks 'this' from the containing module,
|
|
|
|
/// but does not delete it.
|
|
|
|
virtual void removeFromParent() = 0;
|
|
|
|
|
|
|
|
/// eraseFromParent - This method unlinks 'this' from the containing module
|
|
|
|
/// and deletes it.
|
|
|
|
virtual void eraseFromParent() = 0;
|
|
|
|
|
2002-10-10 01:11:33 +02:00
|
|
|
/// getParent - Get the module that this global value is contained inside
|
|
|
|
/// of...
|
2001-10-03 21:28:15 +02:00
|
|
|
inline Module *getParent() { return Parent; }
|
|
|
|
inline const Module *getParent() const { return Parent; }
|
|
|
|
|
2004-07-12 03:17:52 +02:00
|
|
|
/// removeDeadConstantUsers - If there are any dead constant users dangling
|
|
|
|
/// off of this global value, remove them. This method is useful for clients
|
|
|
|
/// that want to check to see if a global is unused, but don't want to deal
|
|
|
|
/// with potentially dead constants hanging off of the globals.
|
2009-03-09 06:50:45 +01:00
|
|
|
void removeDeadConstantUsers() const;
|
2004-07-12 03:17:52 +02:00
|
|
|
|
2001-10-03 16:53:21 +02:00
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2005-10-25 19:59:28 +02:00
|
|
|
static inline bool classof(const GlobalValue *) { return true; }
|
2001-10-03 16:53:21 +02:00
|
|
|
static inline bool classof(const Value *V) {
|
2007-04-13 20:12:09 +02:00
|
|
|
return V->getValueID() == Value::FunctionVal ||
|
2007-04-25 16:27:10 +02:00
|
|
|
V->getValueID() == Value::GlobalVariableVal ||
|
|
|
|
V->getValueID() == Value::GlobalAliasVal;
|
2001-10-03 16:53:21 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-10-03 16:53:21 +02:00
|
|
|
#endif
|