[llvm-commits] [llvm] r172143 - in /llvm/trunk: lib/IR/Instructions.cpp test/Transforms/MergeFunc/2013-01-10-MergeFuncAssert.ll
Evan Cheng
evan.cheng at apple.com
Thu Jan 10 15:22:54 PST 2013
Author: evancheng
Date: Thu Jan 10 17:22:53 2013
New Revision: 172143
URL: http://llvm.org/viewvc/llvm-project?rev=172143&view=rev
Log:
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.
Added:
llvm/trunk/test/Transforms/MergeFunc/2013-01-10-MergeFuncAssert.ll
Modified:
llvm/trunk/lib/IR/Instructions.cpp
Modified: llvm/trunk/lib/IR/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Instructions.cpp?rev=172143&r1=172142&r2=172143&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Instructions.cpp (original)
+++ llvm/trunk/lib/IR/Instructions.cpp Thu Jan 10 17:22:53 2013
@@ -2624,6 +2624,11 @@
// 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;
Added: llvm/trunk/test/Transforms/MergeFunc/2013-01-10-MergeFuncAssert.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MergeFunc/2013-01-10-MergeFuncAssert.ll?rev=172143&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/MergeFunc/2013-01-10-MergeFuncAssert.ll (added)
+++ llvm/trunk/test/Transforms/MergeFunc/2013-01-10-MergeFuncAssert.ll Thu Jan 10 17:22:53 2013
@@ -0,0 +1,36 @@
+; RUN: opt -mergefunc -disable-output < %s
+; This used to trigger a ConstantExpr::getBitCast assertion.
+
+define void @t1() unnamed_addr uwtable ssp align 2 {
+entry:
+ switch i32 undef, label %sw.bb12 [
+ i32 127, label %sw.bb
+ i32 126, label %sw.bb4
+ ]
+
+sw.bb: ; preds = %entry
+ unreachable
+
+sw.bb4: ; preds = %entry
+ unreachable
+
+sw.bb12: ; preds = %entry
+ ret void
+}
+
+define void @t2() unnamed_addr uwtable ssp align 2 {
+entry:
+ switch i32 undef, label %sw.bb8 [
+ i32 4, label %sw.bb
+ i32 3, label %sw.bb4
+ ]
+
+sw.bb: ; preds = %entry
+ unreachable
+
+sw.bb4: ; preds = %entry
+ ret void
+
+sw.bb8: ; preds = %entry
+ unreachable
+}
More information about the llvm-commits
mailing list