[tests] Stablize tests for possible change in deref semantics
authorPhilip Reames <listmail@philipreames.com>
Wed, 14 Jul 2021 20:35:18 +0000 (13:35 -0700)
committerPhilip Reames <listmail@philipreames.com>
Wed, 14 Jul 2021 20:37:50 +0000 (13:37 -0700)
This is conceptually part of e75a2dfe.  This file contains both tests whose results don't change (with the right attributes added), and tests which fundementally regress with the current proposal.  Doing the update took some care, thus the seperate change.

Here's the e75a2dfe context repeated:

There's a potential change in dereferenceability attribute semantics in the nearish future.  See llvm-dev thread "RFC: Decomposing deref(N) into deref(N) + nofree" and D99100 for context.

This change simply adds appropriate attributes to tests to keep transform logic exercised under both old and new/proposed semantics.  Note that for many of these cases, O3 would infer exactly these attributes on the test IR.

This change handles the idiomatic pattern of a dereferenceable object being passed to a call which can not free that memory.  There's a couple other tests which need more one-off attention, they'll be handled in another change.

llvm/test/Analysis/BasicAA/dereferenceable.ll

index 438114d..c50a7d3 100644 (file)
@@ -4,7 +4,7 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 
 @G = global i32 0, align 4
 
-define i64 @global_and_deref_arg_1(i64* dereferenceable(8) %arg) {
+define i64 @global_and_deref_arg_1(i64* dereferenceable(8) %arg) nofree nosync {
 ; CHECK:     Function: global_and_deref_arg_1: 2 pointers, 0 call sites
 ; CHECK-NEXT:  NoAlias:        i32* @G, i64* %arg
 bb:
@@ -14,7 +14,7 @@ bb:
   ret i64 %tmp
 }
 
-define i32 @global_and_deref_arg_2(i32* dereferenceable(8) %arg) {
+define i32 @global_and_deref_arg_2(i32* dereferenceable(8) %arg) nofree nosync {
 ; CHECK:     Function: global_and_deref_arg_2: 2 pointers, 0 call sites
 ; CHECK-NEXT:  NoAlias:        i32* %arg, i32* @G
 bb:
@@ -24,7 +24,7 @@ bb:
   ret i32 %tmp
 }
 
-define i32 @byval_and_deref_arg_1(i32* byval(i32) %obj, i64* dereferenceable(8) %arg) {
+define i32 @byval_and_deref_arg_1(i32* byval(i32) %obj, i64* dereferenceable(8) %arg) nofree nosync {
 ; CHECK:     Function: byval_and_deref_arg_1: 2 pointers, 0 call sites
 ; CHECK-NEXT:  NoAlias:        i32* %obj, i64* %arg
 bb:
@@ -34,7 +34,7 @@ bb:
   ret i32 %tmp
 }
 
-define i32 @byval_and_deref_arg_2(i32* byval(i32) %obj, i32* dereferenceable(8) %arg) {
+define i32 @byval_and_deref_arg_2(i32* byval(i32) %obj, i32* dereferenceable(8) %arg) nofree nosync {
 ; CHECK:     Function: byval_and_deref_arg_2: 2 pointers, 0 call sites
 ; CHECK-NEXT:  NoAlias:        i32* %arg, i32* %obj
 bb:
@@ -77,7 +77,7 @@ bb:
 
 ; Baseline tests, same as above but with 2 instead of 8 dereferenceable bytes.
 
-define i64 @global_and_deref_arg_non_deref_1(i64* dereferenceable(2) %arg) {
+define i64 @global_and_deref_arg_non_deref_1(i64* dereferenceable(2) %arg) nofree nosync {
 ; CHECK:     Function: global_and_deref_arg_non_deref_1: 2 pointers, 0 call sites
 ; CHECK-NEXT:  NoAlias:        i32* @G, i64* %arg
 bb:
@@ -87,7 +87,7 @@ bb:
   ret i64 %tmp
 }
 
-define i32 @global_and_deref_arg_non_deref_2(i32* dereferenceable(2) %arg) {
+define i32 @global_and_deref_arg_non_deref_2(i32* dereferenceable(2) %arg) nofree nosync {
 ; CHECK:     Function: global_and_deref_arg_non_deref_2: 2 pointers, 0 call sites
 ; Different result than above (see @global_and_deref_arg_2).
 ; CHECK-NEXT:  MayAlias:       i32* %arg, i32* @G
@@ -98,7 +98,7 @@ bb:
   ret i32 %tmp
 }
 
-define i32 @byval_and_deref_arg_non_deref_1(i32* byval(i32) %obj, i64* dereferenceable(2) %arg) {
+define i32 @byval_and_deref_arg_non_deref_1(i32* byval(i32) %obj, i64* dereferenceable(2) %arg) nofree nosync {
 ; CHECK:     Function: byval_and_deref_arg_non_deref_1: 2 pointers, 0 call sites
 ; CHECK-NEXT:  NoAlias:        i32* %obj, i64* %arg
 bb:
@@ -108,7 +108,7 @@ bb:
   ret i32 %tmp
 }
 
-define i32 @byval_and_deref_arg_non_deref_2(i32* byval(i32) %obj, i32* dereferenceable(2) %arg) {
+define i32 @byval_and_deref_arg_non_deref_2(i32* byval(i32) %obj, i32* dereferenceable(2) %arg) nofree nosync {
 ; CHECK:     Function: byval_and_deref_arg_non_deref_2: 2 pointers, 0 call sites
 ; CHECK-NEXT:  NoAlias:        i32* %arg, i32* %obj
 bb: