[llvm] fff2092 - [Mem2Reg] Add additional noundef variations to nonnull tests (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 20 06:39:33 PST 2023


Author: Nikita Popov
Date: 2023-01-20T15:39:25+01:00
New Revision: fff2092d54286858a7ba0e4a23fa7e1dd62f86fb

URL: https://github.com/llvm/llvm-project/commit/fff2092d54286858a7ba0e4a23fa7e1dd62f86fb
DIFF: https://github.com/llvm/llvm-project/commit/fff2092d54286858a7ba0e4a23fa7e1dd62f86fb.diff

LOG: [Mem2Reg] Add additional noundef variations to nonnull tests (NFC)

Added: 
    

Modified: 
    llvm/test/Transforms/Mem2Reg/preserve-nonnull-load-metadata.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/Mem2Reg/preserve-nonnull-load-metadata.ll b/llvm/test/Transforms/Mem2Reg/preserve-nonnull-load-metadata.ll
index 1e12526bf178d..f974b9044a5a9 100644
--- a/llvm/test/Transforms/Mem2Reg/preserve-nonnull-load-metadata.ll
+++ b/llvm/test/Transforms/Mem2Reg/preserve-nonnull-load-metadata.ll
@@ -5,8 +5,24 @@
 ; from allocas that get optimized out.
 
 ; Check the case where the alloca in question has a single store.
-define ptr @single_store(ptr %arg) {
-; CHECK-LABEL: @single_store(
+define ptr @single_store_noundef(ptr %arg) {
+; CHECK-LABEL: @single_store_noundef(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[ARG_LOAD:%.*]] = load ptr, ptr [[ARG:%.*]], align 8
+; CHECK-NEXT:    [[TMP0:%.*]] = icmp ne ptr [[ARG_LOAD]], null
+; CHECK-NEXT:    call void @llvm.assume(i1 [[TMP0]])
+; CHECK-NEXT:    ret ptr [[ARG_LOAD]]
+;
+entry:
+  %buf = alloca ptr
+  %arg.load = load ptr, ptr %arg, align 8
+  store ptr %arg.load, ptr %buf, align 8
+  %buf.load = load ptr, ptr %buf, !nonnull !0, !noundef !0
+  ret ptr %buf.load
+}
+
+define ptr @single_store_missing_noundef(ptr %arg) {
+; CHECK-LABEL: @single_store_missing_noundef(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[ARG_LOAD:%.*]] = load ptr, ptr [[ARG:%.*]], align 8
 ; CHECK-NEXT:    [[TMP0:%.*]] = icmp ne ptr [[ARG_LOAD]], null
@@ -23,8 +39,25 @@ entry:
 
 ; Check the case where the alloca in question has more than one
 ; store but still within one basic block.
-define ptr @single_block(ptr %arg) {
-; CHECK-LABEL: @single_block(
+define ptr @single_block_noundef(ptr %arg) {
+; CHECK-LABEL: @single_block_noundef(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[ARG_LOAD:%.*]] = load ptr, ptr [[ARG:%.*]], align 8
+; CHECK-NEXT:    [[TMP0:%.*]] = icmp ne ptr [[ARG_LOAD]], null
+; CHECK-NEXT:    call void @llvm.assume(i1 [[TMP0]])
+; CHECK-NEXT:    ret ptr [[ARG_LOAD]]
+;
+entry:
+  %buf = alloca ptr
+  %arg.load = load ptr, ptr %arg, align 8
+  store ptr null, ptr %buf, align 8
+  store ptr %arg.load, ptr %buf, align 8
+  %buf.load = load ptr, ptr %buf, !nonnull !0, !noundef !0
+  ret ptr %buf.load
+}
+
+define ptr @single_block_missing_noundef(ptr %arg) {
+; CHECK-LABEL: @single_block_missing_noundef(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[ARG_LOAD:%.*]] = load ptr, ptr [[ARG:%.*]], align 8
 ; CHECK-NEXT:    [[TMP0:%.*]] = icmp ne ptr [[ARG_LOAD]], null
@@ -42,8 +75,29 @@ entry:
 
 ; Check the case where the alloca in question has more than one
 ; store and also reads ands writes in multiple blocks.
-define ptr @multi_block(ptr %arg) {
-; CHECK-LABEL: @multi_block(
+define ptr @multi_block_noundef(ptr %arg) {
+; CHECK-LABEL: @multi_block_noundef(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[ARG_LOAD:%.*]] = load ptr, ptr [[ARG:%.*]], align 8
+; CHECK-NEXT:    br label [[NEXT:%.*]]
+; CHECK:       next:
+; CHECK-NEXT:    [[TMP0:%.*]] = icmp ne ptr [[ARG_LOAD]], null
+; CHECK-NEXT:    call void @llvm.assume(i1 [[TMP0]])
+; CHECK-NEXT:    ret ptr [[ARG_LOAD]]
+;
+entry:
+  %buf = alloca ptr
+  %arg.load = load ptr, ptr %arg, align 8
+  store ptr null, ptr %buf, align 8
+  br label %next
+next:
+  store ptr %arg.load, ptr %buf, align 8
+  %buf.load = load ptr, ptr %buf, !nonnull !0, !noundef !0
+  ret ptr %buf.load
+}
+
+define ptr @multi_block_missing_noundef(ptr %arg) {
+; CHECK-LABEL: @multi_block_missing_noundef(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[ARG_LOAD:%.*]] = load ptr, ptr [[ARG:%.*]], align 8
 ; CHECK-NEXT:    br label [[NEXT:%.*]]
@@ -101,7 +155,7 @@ define ptr @no_store_single_load() {
 ;
 entry:
   %buf = alloca ptr
-  %buf.load = load ptr, ptr %buf, !nonnull !0
+  %buf.load = load ptr, ptr %buf, !nonnull !0, !noundef !0
   ret ptr %buf.load
 }
 
@@ -123,11 +177,11 @@ entry:
   br i1 %c, label %if, label %else
 
 if:
-  %buf.load = load ptr, ptr %buf, !nonnull !0
+  %buf.load = load ptr, ptr %buf, !nonnull !0, !noundef !0
   ret ptr %buf.load
 
   else:
-  %buf.load2 = load ptr, ptr %buf, !nonnull !0
+  %buf.load2 = load ptr, ptr %buf, !nonnull !0, !noundef !0
   ret ptr %buf.load2
 }
 


        


More information about the llvm-commits mailing list