[llvm] r188725 - Introduce non-const overloads for GlobalAlias::{get, resolve}AliasedGlobal.
Peter Collingbourne
peter at pcc.me.uk
Mon Aug 19 16:13:33 PDT 2013
Author: pcc
Date: Mon Aug 19 18:13:33 2013
New Revision: 188725
URL: http://llvm.org/viewvc/llvm-project?rev=188725&view=rev
Log:
Introduce non-const overloads for GlobalAlias::{get,resolve}AliasedGlobal.
Modified:
llvm/trunk/include/llvm/IR/GlobalAlias.h
llvm/trunk/lib/IR/Globals.cpp
Modified: llvm/trunk/include/llvm/IR/GlobalAlias.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/GlobalAlias.h?rev=188725&r1=188724&r2=188725&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/GlobalAlias.h (original)
+++ llvm/trunk/include/llvm/IR/GlobalAlias.h Mon Aug 19 18:13:33 2013
@@ -66,14 +66,20 @@ public:
}
/// getAliasedGlobal() - Aliasee can be either global or bitcast of
/// global. This method retrives the global for both aliasee flavours.
- const GlobalValue *getAliasedGlobal() const;
+ GlobalValue *getAliasedGlobal();
+ const GlobalValue *getAliasedGlobal() const {
+ return const_cast<GlobalAlias *>(this)->getAliasedGlobal();
+ }
/// resolveAliasedGlobal() - This method tries to ultimately resolve the alias
/// by going through the aliasing chain and trying to find the very last
/// global. Returns NULL if a cycle was found. If stopOnWeak is false, then
/// the whole chain aliasing chain is traversed, otherwise - only strong
/// aliases.
- const GlobalValue *resolveAliasedGlobal(bool stopOnWeak = true) const;
+ GlobalValue *resolveAliasedGlobal(bool stopOnWeak = true);
+ const GlobalValue *resolveAliasedGlobal(bool stopOnWeak = true) const {
+ return const_cast<GlobalAlias *>(this)->resolveAliasedGlobal(stopOnWeak);
+ }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const Value *V) {
Modified: llvm/trunk/lib/IR/Globals.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Globals.cpp?rev=188725&r1=188724&r2=188725&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Globals.cpp (original)
+++ llvm/trunk/lib/IR/Globals.cpp Mon Aug 19 18:13:33 2013
@@ -229,14 +229,14 @@ void GlobalAlias::setAliasee(Constant *A
setOperand(0, Aliasee);
}
-const GlobalValue *GlobalAlias::getAliasedGlobal() const {
- const Constant *C = getAliasee();
+GlobalValue *GlobalAlias::getAliasedGlobal() {
+ Constant *C = getAliasee();
if (C == 0) return 0;
- if (const GlobalValue *GV = dyn_cast<GlobalValue>(C))
+ if (GlobalValue *GV = dyn_cast<GlobalValue>(C))
return GV;
- const ConstantExpr *CE = cast<ConstantExpr>(C);
+ ConstantExpr *CE = cast<ConstantExpr>(C);
assert((CE->getOpcode() == Instruction::BitCast ||
CE->getOpcode() == Instruction::GetElementPtr) &&
"Unsupported aliasee");
@@ -244,18 +244,18 @@ const GlobalValue *GlobalAlias::getAlias
return cast<GlobalValue>(CE->getOperand(0));
}
-const GlobalValue *GlobalAlias::resolveAliasedGlobal(bool stopOnWeak) const {
- SmallPtrSet<const GlobalValue*, 3> Visited;
+GlobalValue *GlobalAlias::resolveAliasedGlobal(bool stopOnWeak) {
+ SmallPtrSet<GlobalValue*, 3> Visited;
// Check if we need to stop early.
if (stopOnWeak && mayBeOverridden())
return this;
- const GlobalValue *GV = getAliasedGlobal();
+ GlobalValue *GV = getAliasedGlobal();
Visited.insert(GV);
// Iterate over aliasing chain, stopping on weak alias if necessary.
- while (const GlobalAlias *GA = dyn_cast<GlobalAlias>(GV)) {
+ while (GlobalAlias *GA = dyn_cast<GlobalAlias>(GV)) {
if (stopOnWeak && GA->mayBeOverridden())
break;
More information about the llvm-commits
mailing list