[llvm-commits] CVS: llvm/lib/Transforms/ExprTypeConvert.cpp

Chris Lattner clattner at apple.com
Mon Dec 18 08:56:30 PST 2006


On Dec 18, 2006, at 12:16 AM, Reid Spencer wrote:

>
> Convert the last use of two-argument ConstantExpr::getCast into  
> another
> form so we can remove that method from ConstantExpr.
> ---
> Diffs of the changes:  (+3 -1)
>
>  ExprTypeConvert.cpp |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletion(-)
>
>
> Index: llvm/lib/Transforms/ExprTypeConvert.cpp
> diff -u llvm/lib/Transforms/ExprTypeConvert.cpp:1.115 llvm/lib/ 
> Transforms/ExprTypeConvert.cpp:1.116
> --- llvm/lib/Transforms/ExprTypeConvert.cpp:1.115	Wed Dec  6  
> 19:30:31 2006
> +++ llvm/lib/Transforms/ExprTypeConvert.cpp	Mon Dec 18 02:16:27 2006
> @@ -210,7 +210,9 @@
>      Constant *CPV = cast<Constant>(V);
>      // Constants are converted by constant folding the cast that  
> is required.
>      // We assume here that all casts are implemented for constant  
> prop.
> -    Value *Result = ConstantExpr::getCast(CPV, Ty);
> +    Instruction::CastOps opcode = CastInst::getCastOpcode(CPV,
> +        CPV->getType()->isSigned(), Ty, Ty->isSigned());
> +    Value *Result = ConstantExpr::getCast(opcode, CPV, Ty);
>      // Add the instruction to the expression map
>      //VMC.ExprMap[V] = Result;
>      return Result;

How is this safe?  Do you know that signedness can be trusted here?

-Chris



More information about the llvm-commits mailing list