[FunctionAttrs] Add test for argmemonly function that already has attr (NFC)
authorNikita Popov <npopov@redhat.com>
Thu, 29 Sep 2022 11:55:36 +0000 (13:55 +0200)
committerNikita Popov <npopov@redhat.com>
Thu, 29 Sep 2022 11:56:31 +0000 (13:56 +0200)
Test for the issue reported in https://reviews.llvm.org/D134527#3821010.

llvm/test/Transforms/FunctionAttrs/argmemonly.ll

index 204c609..1954f70 100644 (file)
@@ -25,6 +25,18 @@ entry:
   ret i32 %l
 }
 
+define i32 @test_only_read_arg_already_has_argmemonly(i32* %ptr) argmemonly {
+; CHECK: Function Attrs: argmemonly mustprogress nofree norecurse nosync nounwind readonly willreturn
+; CHECK-LABEL: @test_only_read_arg_already_has_argmemonly(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[L:%.*]] = load i32, i32* [[PTR:%.*]], align 4
+; CHECK-NEXT:    ret i32 [[L]]
+;
+entry:
+  %l = load i32, i32* %ptr
+  ret i32 %l
+}
+
 define i32 @test_read_global() {
 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind readonly willreturn
 ; CHECK-LABEL: @test_read_global(