From ac08785edaac826afe11a4e596a46fc693848848 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 31 Jan 2013 23:49:33 +0000 Subject: An alloca can be equal to an argument. It can't *alias* an alloca, but it could be equal, since there's nothing preventing a caller from correctly predicting the stack location of an alloca. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174119 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/InstSimplify/compare.ll | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/Transforms/InstSimplify') diff --git a/test/Transforms/InstSimplify/compare.ll b/test/Transforms/InstSimplify/compare.ll index 56627b99a4..a6d7a64b91 100644 --- a/test/Transforms/InstSimplify/compare.ll +++ b/test/Transforms/InstSimplify/compare.ll @@ -647,3 +647,16 @@ unreachableblock: %Y = icmp eq i32* %X, null ret i1 %Y } + +; It's not valid to fold a comparison of an argument with an alloca, even though +; that's tempting. An argument can't *alias* an alloca, however the aliasing rule +; relies on restrictions against guessing an object's address and dereferencing. +; There are no restrictions against guessing an object's address and comparing. + +define i1 @alloca_argument_compare(i64* %arg) { + %alloc = alloca i64 + %cmp = icmp eq i64* %arg, %alloc + ret i1 %cmp + ; CHECK: alloca_argument_compare + ; CHECK: ret i1 %cmp +} -- cgit v1.2.3-70-g09d2