[clang] [compiler-rt] Revert "[Coverage] Fix region termination for GNU statement expressions" (PR #132095)

Justin Cady via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 19 13:47:52 PDT 2025


https://github.com/justincady created https://github.com/llvm/llvm-project/pull/132095

Reverts llvm/llvm-project#130976

Breaks clang-cmake-x86_64-avx512-linux bot.

>From 2f37c9ec685b8ba82fdc3bd8387ce59b3f8a77dc Mon Sep 17 00:00:00 2001
From: Justin Cady <justin at jcady.com>
Date: Wed, 19 Mar 2025 16:45:26 -0400
Subject: [PATCH] =?UTF-8?q?Revert=20"[Coverage]=20Fix=20region=20terminati?=
 =?UTF-8?q?on=20for=20GNU=20statement=20expressions=20(#130=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit 0827e3aae6eb69c2a6fa842ffa780881feb45b5d.
---
 clang/lib/CodeGen/CoverageMappingGen.cpp      |  8 -------
 .../CoverageMapping/terminate-statements.cpp  |  7 -------
 .../Linux/coverage-statement-expression.cpp   | 21 -------------------
 3 files changed, 36 deletions(-)
 delete mode 100644 compiler-rt/test/profile/Linux/coverage-statement-expression.cpp

diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 73811d15979d5..f09157771d2b5 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1505,14 +1505,6 @@ struct CounterCoverageMappingBuilder
     handleFileExit(getEnd(S));
   }
 
-  void VisitStmtExpr(const StmtExpr *E) {
-    Visit(E->getSubStmt());
-    // Any region termination (such as a noreturn CallExpr) within the statement
-    // expression has been handled by visiting the sub-statement. The visitor
-    // cannot be at a terminate statement leaving the statement expression.
-    HasTerminateStmt = false;
-  }
-
   void VisitDecl(const Decl *D) {
     Stmt *Body = D->getBody();
 
diff --git a/clang/test/CoverageMapping/terminate-statements.cpp b/clang/test/CoverageMapping/terminate-statements.cpp
index 3f8e43f0fbcb6..0067185fee8e6 100644
--- a/clang/test/CoverageMapping/terminate-statements.cpp
+++ b/clang/test/CoverageMapping/terminate-statements.cpp
@@ -346,12 +346,6 @@ int elsecondnoret(void) {
   return 0;
 }
 
-// CHECK-LABEL: _Z18statementexprnoretb
-int statementexprnoret(bool crash) {
-  int rc = ({ if (crash) abort(); 0; }); // CHECK: File 0, 351:35 -> 352:12 = (#0 - #1)
-  return rc;                             // CHECK-NOT: Gap
-}
-
 int main() {
   foo(0);
   foo(1);
@@ -374,6 +368,5 @@ int main() {
   ornoret();
   abstractcondnoret();
   elsecondnoret();
-  statementexprnoret(false);
   return 0;
 }
diff --git a/compiler-rt/test/profile/Linux/coverage-statement-expression.cpp b/compiler-rt/test/profile/Linux/coverage-statement-expression.cpp
deleted file mode 100644
index 7c76555e3300b..0000000000000
--- a/compiler-rt/test/profile/Linux/coverage-statement-expression.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-// RUN: %clangxx_profgen -std=gnu++17 -fuse-ld=lld -fcoverage-mapping -o %t %s
-// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
-// RUN: llvm-profdata merge -o %t.profdata %t.profraw
-// RUN: llvm-cov show %t -instr-profile=%t.profdata 2>&1 | FileCheck %s
-
-#include <stdio.h>
-
-// clang-format off
-__attribute__ ((__noreturn__))
-void foo(void) { while (1); }                   // CHECK:  [[@LINE]]| 0|void foo(void)
-_Noreturn void bar(void) { while (1); }         // CHECK:  [[@LINE]]| 0|_Noreturn void bar(void)
-                                                // CHECK:  [[@LINE]]|  |
-int main(int argc, char **argv) {               // CHECK:  [[@LINE]]| 1|int main(
-  int rc = ({ if (argc > 3) foo(); 0; });       // CHECK:  [[@LINE]]| 1|  int rc =
-  printf("coverage after foo is present\n");    // CHECK:  [[@LINE]]| 1|  printf(
-                                                // CHECK:  [[@LINE]]|  |
-  int rc2 = ({ if (argc > 3) bar(); 0; });      // CHECK:  [[@LINE]]| 1|  int rc2 =
-  printf("coverage after bar is present\n");    // CHECK:  [[@LINE]]| 1|  printf(
-  return rc + rc2;                              // CHECK:  [[@LINE]]| 1|  return rc
-}                                               // CHECK:  [[@LINE]]| 1|}
-// clang-format on



More information about the llvm-commits mailing list