[clang] b03abbb - [clang/test/CodeGen] Add test coverage for VarBypassDetector handling init statements and condition variables in switch clauses
Vitaly Buka via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 9 11:28:30 PDT 2023
Author: Wang
Date: 2023-06-09T11:28:14-07:00
New Revision: b03abbb537e5403ab32f97e2ffcebafe4a92720d
URL: https://github.com/llvm/llvm-project/commit/b03abbb537e5403ab32f97e2ffcebafe4a92720d
DIFF: https://github.com/llvm/llvm-project/commit/b03abbb537e5403ab32f97e2ffcebafe4a92720d.diff
LOG: [clang/test/CodeGen] Add test coverage for VarBypassDetector handling init statements and condition variables in switch clauses
[VarBypassDetector.cpp](https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/VarBypassDetector.cpp) lacks test coverage for handling init statements and condition variables in switch clauses, as is shown in:
https://lab.llvm.org/coverage/coverage-reports/coverage/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/CodeGen/VarBypassDetector.cpp.html#L70
This patch adds test coverage for uncovered lines.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D152412
Added:
clang/test/CodeGen/lifetime3.cpp
Modified:
Removed:
################################################################################
diff --git a/clang/test/CodeGen/lifetime3.cpp b/clang/test/CodeGen/lifetime3.cpp
new file mode 100644
index 0000000000000..37ed5f1938111
--- /dev/null
+++ b/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;
+ }
+}
More information about the cfe-commits
mailing list