[llvm] r187635 - Teach InstructionSimplify about pointer address spaces

Eli Friedman eli.friedman at gmail.com
Fri Aug 2 16:54:17 PDT 2013


On Thu, Aug 1, 2013 at 5:10 PM, Matt Arsenault
<Matthew.Arsenault at amd.com> wrote:
> Author: arsenm
> Date: Thu Aug  1 19:10:44 2013
> New Revision: 187635
>
> URL: http://llvm.org/viewvc/llvm-project?rev=187635&view=rev
> Log:
> Teach InstructionSimplify about pointer address spaces
>
> Modified:
>     llvm/trunk/lib/Analysis/InstructionSimplify.cpp

Testcase?

> Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=187635&r1=187634&r2=187635&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
> +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Thu Aug  1 19:10:44 2013
> @@ -676,7 +676,8 @@ static Constant *stripAndComputeConstant
>    if (!TD)
>      return ConstantInt::get(IntegerType::get(V->getContext(), 64), 0);
>
> -  unsigned IntPtrWidth = TD->getPointerSizeInBits();
> +  unsigned AS = V->getType()->getPointerAddressSpace();
> +  unsigned IntPtrWidth = TD->getPointerSizeInBits(AS);
>    APInt Offset = APInt::getNullValue(IntPtrWidth);
>
>    // Even though we don't look through PHI nodes, we could be called on an
> @@ -689,7 +690,11 @@ static Constant *stripAndComputeConstant
>          break;
>        V = GEP->getPointerOperand();
>      } else if (Operator::getOpcode(V) == Instruction::BitCast) {
> -      V = cast<Operator>(V)->getOperand(0);
> +      Value *Op0 = cast<Operator>(V)->getOperand(0);
> +      assert(TD->getPointerTypeSizeInBits(V->getType()) ==
> +             TD->getPointerTypeSizeInBits(Op0->getType()) &&
> +             "Bitcasting between pointers from different size address spaces");
> +      V = Op0;


The verifier already checks this, no?

-Eli



More information about the llvm-commits mailing list