[PATCH] D151643: [InstCombine] Add tests for propegating `nocapture` flag to callsites; NFC

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 29 00:14:07 PDT 2023


goldstein.w.n created this revision.
goldstein.w.n added reviewers: nikic, StephenFan.
Herald added a project: All.
goldstein.w.n requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151643

Files:
  llvm/test/Transforms/InstCombine/nocapture-attribute.ll


Index: llvm/test/Transforms/InstCombine/nocapture-attribute.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/InstCombine/nocapture-attribute.ll
@@ -0,0 +1,57 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
+; RUN: opt < %s -passes=instcombine -S | FileCheck %s
+
+declare void @ptrs_maybe_capture(ptr, ptr, ptr)
+declare void @ptr_maybe_capture(ptr)
+
+define void @all_maybe_capture(ptr %a0, ptr %a1, ptr %a2) {
+; CHECK-LABEL: define void @all_maybe_capture
+; CHECK-SAME: (ptr [[A0:%.*]], ptr [[A1:%.*]], ptr [[A2:%.*]]) {
+; CHECK-NEXT:    tail call void @ptrs_maybe_capture(ptr [[A0]], ptr [[A1]], ptr [[A2]])
+; CHECK-NEXT:    ret void
+;
+  tail call void @ptrs_maybe_capture(ptr %a0, ptr %a1, ptr %a2)
+  ret void
+}
+
+define void @a0_nocapture_a1_a2_maybe_capture(ptr nocapture %a0, ptr %a1, ptr %a2) {
+; CHECK-LABEL: define void @a0_nocapture_a1_a2_maybe_capture
+; CHECK-SAME: (ptr nocapture [[A0:%.*]], ptr [[A1:%.*]], ptr [[A2:%.*]]) {
+; CHECK-NEXT:    tail call void @ptrs_maybe_capture(ptr [[A0]], ptr [[A1]], ptr [[A2]])
+; CHECK-NEXT:    ret void
+;
+  tail call void @ptrs_maybe_capture(ptr %a0, ptr %a1, ptr %a2)
+  ret void
+}
+
+define void @a2_nocapture2x_a1_maybe_capture(ptr %a0, ptr %a1, ptr nocapture %a2) {
+; CHECK-LABEL: define void @a2_nocapture2x_a1_maybe_capture
+; CHECK-SAME: (ptr [[A0:%.*]], ptr [[A1:%.*]], ptr nocapture [[A2:%.*]]) {
+; CHECK-NEXT:    tail call void @ptrs_maybe_capture(ptr [[A2]], ptr [[A1]], ptr [[A2]])
+; CHECK-NEXT:    ret void
+;
+  tail call void @ptrs_maybe_capture(ptr %a2, ptr %a1, ptr %a2)
+  ret void
+}
+
+define void @a0_a1_a2_nocapture(ptr nocapture %a0, ptr nocapture %a1, ptr nocapture %a2) {
+; CHECK-LABEL: define void @a0_a1_a2_nocapture
+; CHECK-SAME: (ptr nocapture [[A0:%.*]], ptr nocapture [[A1:%.*]], ptr nocapture [[A2:%.*]]) {
+; CHECK-NEXT:    tail call void @ptrs_maybe_capture(ptr [[A0]], ptr [[A1]], ptr [[A2]])
+; CHECK-NEXT:    ret void
+;
+  tail call void @ptrs_maybe_capture(ptr %a0, ptr %a1, ptr %a2)
+  ret void
+}
+
+define void @a0_nocapture_todo(ptr nocapture %a0) {
+; CHECK-LABEL: define void @a0_nocapture_todo
+; CHECK-SAME: (ptr nocapture [[A0:%.*]]) {
+; CHECK-NEXT:    [[A0_OFF1:%.*]] = getelementptr inbounds i32, ptr [[A0]], i64 1
+; CHECK-NEXT:    tail call void @ptr_maybe_capture(ptr nonnull [[A0_OFF1]])
+; CHECK-NEXT:    ret void
+;
+  %a0_off1 = getelementptr inbounds i32, ptr %a0, i64 1
+  tail call void @ptr_maybe_capture(ptr %a0_off1)
+  ret void
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151643.526399.patch
Type: text/x-patch
Size: 2581 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230529/e3ef0ab0/attachment.bin>


More information about the llvm-commits mailing list