diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2013-02-05 19:04:36 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2013-02-05 19:04:36 +0000 |
commit | a5a9ec5755974fdcd01e76a74f701f494c03817a (patch) | |
tree | 5512b875502064b1836925dcebdbaad3051fe239 /llvm/test | |
parent | 3be40b56c5409d02339b64992893af367b1fb112 (diff) | |
download | bcm5719-llvm-a5a9ec5755974fdcd01e76a74f701f494c03817a.tar.gz bcm5719-llvm-a5a9ec5755974fdcd01e76a74f701f494c03817a.zip |
ConstantFolding: Fix a crash when encoutering a truncating inttoptr.
This was introduced in r173293.
llvm-svn: 174424
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/Transforms/InstSimplify/ptr_diff.ll | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/ptr_diff.ll b/llvm/test/Transforms/InstSimplify/ptr_diff.ll index 86516280696..8b4aa796013 100644 --- a/llvm/test/Transforms/InstSimplify/ptr_diff.ll +++ b/llvm/test/Transforms/InstSimplify/ptr_diff.ll @@ -57,3 +57,22 @@ define <4 x i32> @ptrdiff4(<4 x i8*> %arg) nounwind { %sub = sub <4 x i32> %p1, %p2 ret <4 x i32> %sub } + +%struct.ham = type { i32, [2 x [2 x i32]] } + +@global = internal global %struct.ham zeroinitializer, align 4 + +define i32 @ptrdiff5() nounwind { +bb: + %tmp = getelementptr inbounds %struct.ham* @global, i32 0, i32 1 + %tmp1 = getelementptr inbounds [2 x [2 x i32]]* %tmp, i32 0, i32 0 + %tmp2 = bitcast [2 x i32]* %tmp1 to i32* + %tmp3 = ptrtoint i32* %tmp2 to i32 + %tmp4 = getelementptr inbounds %struct.ham* @global, i32 0, i32 1 + %tmp5 = getelementptr inbounds [2 x [2 x i32]]* %tmp4, i32 0, i32 0 + %tmp6 = ptrtoint [2 x i32]* %tmp5 to i32 + %tmp7 = sub i32 %tmp3, %tmp6 + ret i32 %tmp7 +; CHECK: @ptrdiff5 +; CHECK: ret i32 0 +} |