From b7a7566165fc2e878447cb23a76710ea6075f858 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Mon, 16 Feb 2015 09:37:35 +0000 Subject: [PATCH] IR: SrcTy == DstTy doesn't imply that a cast is valid Cast validity depends on the cast's kind, not just its types. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229366 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/Instructions.cpp | 4 ---- test/Assembler/invalid_cast4.ll | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 test/Assembler/invalid_cast4.ll diff --git a/lib/IR/Instructions.cpp b/lib/IR/Instructions.cpp index 8c4eeafdf84..7136923ecb4 100644 --- a/lib/IR/Instructions.cpp +++ b/lib/IR/Instructions.cpp @@ -2864,10 +2864,6 @@ 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; diff --git a/test/Assembler/invalid_cast4.ll b/test/Assembler/invalid_cast4.ll new file mode 100644 index 00000000000..7056f840035 --- /dev/null +++ b/test/Assembler/invalid_cast4.ll @@ -0,0 +1,4 @@ +; RUN: not llvm-as < %s 2>&1 | FileCheck %s + +; CHECK: invalid cast opcode for cast from 'i64' to 'i64' +global i64* inttoptr (i64 0 to i64) -- 2.34.1