[llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Globals.cpp Verifier.cpp
Anton Korobeynikov
asl at math.spbu.ru
Sun Apr 29 11:03:21 PDT 2007
Changes in directory llvm/lib/VMCore:
AsmWriter.cpp updated: 1.277 -> 1.278
Globals.cpp updated: 1.21 -> 1.22
Verifier.cpp updated: 1.208 -> 1.209
---
Log message:
Implement review feedback
---
Diffs of the changes: (+30 -9)
AsmWriter.cpp | 3 +--
Globals.cpp | 33 +++++++++++++++++++++++++++------
Verifier.cpp | 3 ++-
3 files changed, 30 insertions(+), 9 deletions(-)
Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.277 llvm/lib/VMCore/AsmWriter.cpp:1.278
--- llvm/lib/VMCore/AsmWriter.cpp:1.277 Sat Apr 28 08:44:59 2007
+++ llvm/lib/VMCore/AsmWriter.cpp Sun Apr 29 13:02:48 2007
@@ -926,8 +926,7 @@
assert(0 && "Invalid alias linkage");
}
- const Constant *Aliasee = dyn_cast_or_null<Constant>(GA->getAliasee());
- assert(Aliasee && "Aliasee cannot be null");
+ const Constant *Aliasee = GA->getAliasee();
if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(Aliasee)) {
printType(GV->getType());
Index: llvm/lib/VMCore/Globals.cpp
diff -u llvm/lib/VMCore/Globals.cpp:1.21 llvm/lib/VMCore/Globals.cpp:1.22
--- llvm/lib/VMCore/Globals.cpp:1.21 Sat Apr 28 08:44:59 2007
+++ llvm/lib/VMCore/Globals.cpp Sun Apr 29 13:02:48 2007
@@ -12,6 +12,7 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/Constants.h"
#include "llvm/GlobalVariable.h"
#include "llvm/GlobalAlias.h"
#include "llvm/DerivedTypes.h"
@@ -193,16 +194,36 @@
}
bool GlobalAlias::isDeclaration() const {
- const GlobalValue* AV = dyn_cast_or_null<const GlobalValue>(getAliasee());
- return (AV && AV->isDeclaration());
+ const GlobalValue* AV = getAliasedGlobal();
+ if (AV)
+ return AV->isDeclaration();
+ else
+ return false;
}
void GlobalAlias::setAliasee(Constant *Aliasee)
{
- if (Aliasee) {
- assert(Aliasee->getType() == getType() &&
+ if (Aliasee)
+ assert(Aliasee->getType() == getType() &&
"Alias and aliasee types should match!");
- setOperand(0, Aliasee);
- }
+
+ setOperand(0, Aliasee);
+}
+
+const GlobalValue *GlobalAlias::getAliasedGlobal() const {
+ const Constant *C = getAliasee();
+ if (C) {
+ if (const GlobalValue *GV = dyn_cast<GlobalValue>(C))
+ return GV;
+ else {
+ const ConstantExpr *CE = 0;
+ if ((CE = dyn_cast<ConstantExpr>(Aliasee)) &&
+ (CE->getOpcode() == Instruction::BitCast))
+ return cast<GlobalValue>(CE->getOperand(0));
+ else
+ assert(0 && "Unsupported aliasee");
+ }
+ } else
+ return 0;
}
Index: llvm/lib/VMCore/Verifier.cpp
diff -u llvm/lib/VMCore/Verifier.cpp:1.208 llvm/lib/VMCore/Verifier.cpp:1.209
--- llvm/lib/VMCore/Verifier.cpp:1.208 Sat Apr 28 09:35:41 2007
+++ llvm/lib/VMCore/Verifier.cpp Sun Apr 29 13:02:48 2007
@@ -321,7 +321,8 @@
if (!isa<GlobalValue>(GA.getAliasee())) {
const ConstantExpr *CE = dyn_cast<ConstantExpr>(GA.getAliasee());
- Assert1(CE && CE->getOpcode() == Instruction::BitCast,
+ Assert1(CE && CE->getOpcode() == Instruction::BitCast &&
+ isa<GlobalValue>(CE->getOperand(0)),
"Aliasee should be either GlobalValue or bitcast of GlobalValue",
&GA);
}
More information about the llvm-commits
mailing list