summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2013-01-10 23:22:53 +0000
committerEvan Cheng <evan.cheng@apple.com>2013-01-10 23:22:53 +0000
commit098d7b76b0105f413df9e748a42a35fdc09733c0 (patch)
treee658bd3ee3aef04a36ba56895003b619c79eaa0a /llvm/lib/IR
parent2e64aeda89bf9a901870718a7c3b59effbf7f068 (diff)
downloadbcm5719-llvm-098d7b76b0105f413df9e748a42a35fdc09733c0.tar.gz
bcm5719-llvm-098d7b76b0105f413df9e748a42a35fdc09733c0.zip
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. llvm-svn: 172143
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/Instructions.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index f2e9813bc63..26398ce8515 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/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;
OpenPOWER on IntegriCloud