Teach ValueTracking how to look through GlobalAliases. GlobalAliases are

not folded in the constant folder because the constant folder doesn't
simplify ConstantExpr operands.

llvm-svn: 81864
This commit is contained in:
Dan Gohman 2009-09-15 16:14:44 +00:00
parent ccdb00720e
commit 78b99e3761

View File

@ -16,6 +16,7 @@
#include "llvm/Constants.h"
#include "llvm/Instructions.h"
#include "llvm/GlobalVariable.h"
#include "llvm/GlobalAlias.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/LLVMContext.h"
#include "llvm/Operator.h"
@ -105,6 +106,17 @@ void llvm::ComputeMaskedBits(Value *V, const APInt &Mask,
KnownOne.clear();
return;
}
// A weak GlobalAlias is totally unknown. A non-weak GlobalAlias has
// the bits of its aliasee.
if (GlobalAlias *GA = dyn_cast<GlobalAlias>(V)) {
if (GA->mayBeOverridden()) {
KnownZero.clear(); KnownOne.clear();
} else {
ComputeMaskedBits(GA->getAliasee(), Mask, KnownZero, KnownOne,
TD, Depth+1);
}
return;
}
KnownZero.clear(); KnownOne.clear(); // Start out not knowing anything.