[clang] [Clang] Add "extend lifetime" flags and release note (PR #110000)
David Blaikie via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 3 10:17:24 PDT 2024
================
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -emit-llvm -O2 -fextend-lifetimes -o - | FileCheck --check-prefixes=CHECK-ALL,CHECK-O2 %s
+// RUN: %clang_cc1 %s -emit-llvm -O0 -fextend-lifetimes -o - | FileCheck --check-prefixes=CHECK-ALL,CHECK-O0 %s
+
+// Checks that we emit the function attribute has_fake_uses when
+// -fextend-lifetimes is on and optimizations are enabled, and that it does not
+// when optimizations are disabled.
+
+// CHECK-ALL: define {{.*}}void @foo
+// CHECK-O2: attributes #0 = {{{.*}}has_fake_uses
----------------
dwblaikie wrote:
Interesting model - I haven't reviewed the other patches in this direction, but I'm a bit surprised this is the only IR effect from the frontend.
I take it this attribute is added, which then causes some middle end pass to add the fake uses themselves?
That seems a bit quirky in terms of creating an attribute to communicate that - I guess other directions have already been considered/found unsuitable? (a couple of others that come to mind include: having the frontend create the fake uses (limits reusability for other front ends) or having the frontend choose to insert the fake use pass or not (and then the pass is unconditional/doesn't look for an attribute) - I /think/ a combination of these might be how the sanitizers work? (frontend chooses to include certain passes but might also have to do some different IRGen too))
https://github.com/llvm/llvm-project/pull/110000
More information about the cfe-commits
mailing list