From 307a7c48f15b087663b60d600d23afffb9e211e6 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 15 Sep 2009 16:14:44 +0000 Subject: Teach ValueTracking how to look through GlobalAliases. GlobalAliases are not folded in the constant folder because the constant folder doesn't simplify ConstantExpr operands. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81864 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ValueTracking.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/Analysis/ValueTracking.cpp') diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index 1782edee7b..9494a2f4c5 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -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(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. -- cgit v1.2.3-18-g5258