From 582e4f278b95d50a45c6f56e33da5e78c19afc17 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Thu, 10 Jan 2013 23:22:53 +0000 Subject: CastInst::castIsValid should return true if the dest type is the same as Value's current type. The casting is trivial even for aggregate type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172143 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/Instructions.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/IR') diff --git a/lib/IR/Instructions.cpp b/lib/IR/Instructions.cpp index f2e9813bc6..26398ce851 100644 --- a/lib/IR/Instructions.cpp +++ b/lib/IR/Instructions.cpp @@ -2624,6 +2624,11 @@ CastInst::castIsValid(Instruction::CastOps op, Value *S, Type *DstTy) { // Check for type sanity on the arguments Type *SrcTy = S->getType(); + + // If this is a cast to the same type then it's trivially true. + if (SrcTy == DstTy) + return true; + if (!SrcTy->isFirstClassType() || !DstTy->isFirstClassType() || SrcTy->isAggregateType() || DstTy->isAggregateType()) return false; -- cgit v1.2.3-18-g5258