[PATCH] D152412: [clang/test/CodeGen] Add test coverage for VarBypassDetector handling init statements and condition variables in switch clauses

Vitaly Buka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 9 11:28:42 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGb03abbb537e5: [clang/test/CodeGen] Add test coverage for VarBypassDetector handling init… (authored by dwang, committed by vitalybuka).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152412/new/

https://reviews.llvm.org/D152412

Files:
  clang/test/CodeGen/lifetime3.cpp


Index: clang/test/CodeGen/lifetime3.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGen/lifetime3.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -S -emit-llvm -o - -O2 -disable-llvm-passes %s      | FileCheck %s --implicit-check-not="call void @llvm.lifetime" --check-prefixes=CHECK,O2
+// RUN: %clang_cc1 -S -emit-llvm -o - -O2 -disable-lifetime-markers %s | FileCheck %s --implicit-check-not="call void @llvm.lifetime" --check-prefixes=CHECK
+// RUN: %clang_cc1 -S -emit-llvm -o - -O0 %s                           | FileCheck %s --implicit-check-not="call void @llvm.lifetime" --check-prefixes=CHECK 
+
+extern int bar(char *A, int n);
+
+// CHECK-LABEL: @no_switch_bypass
+extern "C" void no_switch_bypass(int n) {
+  // O2: call void @llvm.lifetime.start.p0(i64 4,
+  switch (n += 1; int b=n) {
+  case 1: {
+    // O2: call void @llvm.lifetime.start.p0(i64 1,
+    // O2: call void @llvm.lifetime.end.p0(i64 1,
+    char x;
+    bar(&x, 1);
+    break;
+  }
+  case 2:
+    n = n;
+    // O2: call void @llvm.lifetime.start.p0(i64 5,
+    // O2: call void @llvm.lifetime.end.p0(i64 5,
+    char y[5];
+    bar(y, 5);
+    break;
+  }
+  // O2: call void @llvm.lifetime.end.p0(i64 4,
+}
+
+// CHECK-LABEL: @switch_bypass
+extern "C" void switch_bypass(int n) {
+  // O2: call void @llvm.lifetime.start.p0(i64 4,
+  // O2: call void @llvm.lifetime.end.p0(i64 4,
+  switch (n += 1; int b=n) {
+  case 1:
+    n = n;
+    char x;
+    bar(&x, 1);
+    break;
+  case 2:
+    bar(&x, 1);
+    break;
+  }
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152412.530030.patch
Type: text/x-patch
Size: 1559 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230609/57a46847/attachment-0001.bin>


More information about the cfe-commits mailing list