diff options
author | Mikael Holmen <mikael.holmen@ericsson.com> | 2017-10-03 06:03:49 +0000 |
---|---|---|
committer | Mikael Holmen <mikael.holmen@ericsson.com> | 2017-10-03 06:03:49 +0000 |
commit | 42c9fd02c2e5f782133f6f340344b150b53c927f (patch) | |
tree | cc021c7be9ce1942a348855dd52711c2035aa1ca /test/Analysis | |
parent | 42d7f5ca74d809ccda29b4cc22163252a40c4dc0 (diff) |
[Lint] Avoid failed assertion by fetching the proper pointer type
Summary:
When checking if a constant expression is a noop cast we fetched the
IntPtrType by doing DL->getIntPtrType(V->getType())). However, there can
be cases where V doesn't return a pointer, and then getIntPtrType()
triggers an assertion.
Now we pass DataLayout to isNoopCast so the method itself can determine
what the IntPtrType is.
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: wdng, llvm-commits
Differential Revision: https://reviews.llvm.org/D37894
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314763 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis')
-rw-r--r-- | test/Analysis/Lint/noop-cast-expr-no-pointer.ll | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/Analysis/Lint/noop-cast-expr-no-pointer.ll b/test/Analysis/Lint/noop-cast-expr-no-pointer.ll new file mode 100644 index 00000000000..b9258711428 --- /dev/null +++ b/test/Analysis/Lint/noop-cast-expr-no-pointer.ll @@ -0,0 +1,23 @@ +; RUN: opt -lint < %s + +; lint shouldn't crash on any of the below functions + +@g_1 = external global [3 x i32] +@g_2 = external global [2 x i32] + +define void @test1() { +entry: + tail call void @f1(i16 zext (i1 icmp eq (i32* getelementptr inbounds ([2 x i32], [2 x i32]* @g_2, i64 0, i64 0), i32* getelementptr inbounds ([3 x i32], [3 x i32]* @g_1, i64 0, i64 1)) to i16)) + ret void +} + +declare void @f1(i16) + +define void @test2() { + tail call void inttoptr (i64 sext (i32 ptrtoint (void ()* @f2 to i32) to i64) to void ()*)() + + ret void +} + +declare void @f2() + |