[llvm-branch-commits] [clang] [KeyInstr][Clang] Switch stmt atom (PR #134643)

Jeremy Morse via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu May 22 16:06:18 PDT 2025


================
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -gkey-instructions -x c++ -std=c++17 %s -debug-info-kind=line-tables-only -emit-llvm -o - \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank --check-prefixes=CHECK,CHECK-CXX
+
+// RUN: %clang_cc1 -gkey-instructions -x c %s -debug-info-kind=line-tables-only -emit-llvm -o - \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
+
+int g;
+void a(int A, int B) {
+// CHECK: entry:
+// The load gets associated with the branch rather than the store.
+// FIXME: Is that the best thing to do?
----------------
jmorse wrote:

Interesting -- I wonder what happens when various bits get optimised away:
 * The switch probably can't be constant-propagated or otherwise affected without also messing with the load?
 * The store could be DSE'd quite easily

I feel the least desirable outcome is one where the switch disappears and the load gets is_stmt, thus leading to the load and store being steps, on the same line. And that seems unlikely to occur given that if the switch can be optimised, then the load has already been optimised.

A long way of saying, this is probably alright.

https://github.com/llvm/llvm-project/pull/134643


More information about the llvm-branch-commits mailing list