[clang] [Clang] Add fake use emission to Clang with -fextend-lifetimes (PR #110102)

Jeremy Morse via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 19 07:29:25 PST 2024


================
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 %s -O2 -emit-llvm -fextend-lifetimes -o - | FileCheck %s
+// Make sure we don't generate fake.use for non-scalar variables.
+// Make sure we don't generate fake.use for volatile variables
+// and parameters even when they are scalar.
+
+struct A {
+  unsigned long t;
+  char c[1024];
+  unsigned char r[32];
+};
+
+
+int foo(volatile int param)
+{
+  struct A s;
+  volatile int vloc;
+  struct A v[128];
+  char c[33];
+  return 0;
+}
+
+// CHECK-NOT:  fake.use
----------------
jmorse wrote:

This wants a positive check condition, so that we're actually testing clang produced an LLVM-IR output. (Better to have fake.use in an implicit-check-not?)

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


More information about the cfe-commits mailing list