Skip to content

Commit 822f74a

Browse files
authored
[Clang] Cleanup docs and comments relating to -fextend-variable-liveness (#124767)
This patch contains a number of changes relating to the above flag; primarily it updates comment references to the old flag names, "-fextend-lifetimes" and "-fextend-this-ptr" to refer to the new names, "-fextend-variable-liveness[={all,this}]". These changes are all NFC. This patch also removes the explicit -fextend-this-ptr-liveness flag alias, and shortens the help-text for the main flag; these are both changes that were meant to be applied in the initial PR (#110000), but due to some user-error on my part they were not included in the merged commit.
1 parent cfdd937 commit 822f74a

File tree

14 files changed

+22
-31
lines changed

14 files changed

+22
-31
lines changed

clang/docs/ReleaseNotes.rst

+9-9
Original file line numberDiff line numberDiff line change
@@ -524,15 +524,15 @@ New Compiler Flags
524524
Clang to generate code that tries to preserve the liveness of source variables
525525
through optimizations, meaning that variables will typically be visible in a
526526
debugger more often. The flag has two levels: ``-fextend-variable-liveness``,
527-
or ``-fextend-variable-liveness=all``, extendes the liveness of all user
528-
variables and the ``this`` pointer. Alternatively ``-fextend-this-ptr``, or
529-
``-fextend-variable-liveness=this``, has the same behaviour but applies only
530-
to the ``this`` variable in C++ class member functions, meaning its effect is
531-
a strict subset of ``-fextend-variable-liveness``. Note that this flag
532-
modifies the results of optimizations that Clang performs, which will result
533-
in reduced performance in generated code; however, this feature will not
534-
extend the liveness of some variables in cases where doing so would likely
535-
have a severe impact on generated code performance.
527+
or ``-fextend-variable-liveness=all``, extends the liveness of all user
528+
variables and the ``this`` pointer. Alternatively
529+
``-fextend-variable-liveness=this`` has the same behaviour but applies only to
530+
the ``this`` variable in C++ class member functions, meaning its effect is a
531+
strict subset of ``-fextend-variable-liveness``. Note that this flag modifies
532+
the results of optimizations that Clang performs, which will result in reduced
533+
performance in generated code; however, this feature will not extend the
534+
liveness of some variables in cases where doing so would likely have a severe
535+
impact on generated code performance.
536536

537537
- The ``-Warray-compare`` warning has been added to warn about array comparison
538538
on versions older than C++20.

clang/include/clang/Driver/Options.td

+1-9
Original file line numberDiff line numberDiff line change
@@ -4352,19 +4352,11 @@ def stack_usage_file : Separate<["-"], "stack-usage-file">,
43524352
def fextend_variable_liveness_EQ : Joined<["-"], "fextend-variable-liveness=">,
43534353
Group<f_Group>, Visibility<[ClangOption, CC1Option]>,
43544354
HelpText<"Extend the liveness of user variables through optimizations to "
4355-
"prevent stale or optimized-out variable values when debugging. Can "
4356-
"be applied to all user variables, or just to the C++ 'this' ptr. "
4357-
"May choose not to extend the liveness of some variables, such as "
4358-
"non-scalars larger than 4 unsigned ints, or variables in any "
4359-
"inlined functions.">,
4355+
"prevent stale or optimized-out variable values when debugging."
43604356
Values<"all,this,none">,
43614357
NormalizedValues<["All", "This", "None"]>,
43624358
NormalizedValuesScope<"CodeGenOptions::ExtendVariableLivenessKind">,
43634359
MarshallingInfoEnum<CodeGenOpts<"ExtendVariableLiveness">, "None">;
4364-
def fextend_this_ptr_liveness : Flag<["-"], "fextend-this-ptr-liveness">,
4365-
Visibility<[ClangOption, CC1Option]>,
4366-
Alias<fextend_variable_liveness_EQ>, AliasArgs<["this"]>,
4367-
HelpText<"Alias for -fextend-variable-liveness=this.">;
43684360
def fextend_variable_liveness : Flag<["-"], "fextend-variable-liveness">,
43694361
Visibility<[ClangOption, CC1Option]>,
43704362
Alias<fextend_variable_liveness_EQ>, AliasArgs<["all"]>,

clang/lib/CodeGen/CGDecl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ void CodeGenFunction::EmitAndRegisterVariableArrayDimensions(
14231423
}
14241424

14251425
/// Return the maximum size of an aggregate for which we generate a fake use
1426-
/// intrinsic when -fextend-lifetimes is in effect.
1426+
/// intrinsic when -fextend-variable-liveness is in effect.
14271427
static uint64_t maxFakeUseAggregateSize(const ASTContext &C) {
14281428
return 4 * C.getTypeSize(C.UnsignedIntTy);
14291429
}

clang/lib/CodeGen/CodeGenFunction.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -724,8 +724,8 @@ class CodeGenFunction : public CodeGenTypeCache {
724724
};
725725

726726
// We are using objects of this 'cleanup' class to emit fake.use calls
727-
// for -fextend-lifetimes and -fextend-this-ptr. They are placed at the end of
728-
// a variable's scope analogous to lifetime markers.
727+
// for -fextend-variable-liveness. They are placed at the end of a variable's
728+
// scope analogous to lifetime markers.
729729
class FakeUse final : public EHScopeStack::Cleanup {
730730
Address Addr;
731731

clang/test/CodeGen/fake-use-sanitizer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -fextend-variable-liveness -fsanitize=null -fsanitize-trap=null -o - | FileCheck --check-prefixes=CHECK,NULL --implicit-check-not=ubsantrap %s
22
// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -fextend-variable-liveness -o - | FileCheck %s
33

4-
// With -fextend-lifetimes, the compiler previously generated a fake.use of any
4+
// With -fextend-variable-liveness, the compiler previously generated a fake.use of any
55
// reference variable at the end of the scope in which its alloca exists. This
66
// caused two issues, where we would get fake uses for uninitialized variables
77
// if that variable was declared after an early-return, and UBSan's null checks

clang/test/CodeGen/fake-use-this.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 %s -emit-llvm -fextend-this-ptr-liveness -o - | FileCheck %s --implicit-check-not=fake.use
1+
// RUN: %clang_cc1 %s -emit-llvm -fextend-variable-liveness=this -o - | FileCheck %s --implicit-check-not=fake.use
22
// Check that we generate a fake_use call with the 'this' pointer as argument,
33
// and no other fake uses.
44
// The call should appear after the call to bar().

clang/test/Driver/extend-variable-liveness.c

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// RUN: %clang -### -c %s 2>&1 | FileCheck %s --check-prefixes=CHECK,DEFAULT
55
// RUN: %clang -fextend-variable-liveness=none -### -c %s 2>&1 | FileCheck %s --check-prefixes=CHECK,NONE
66
// RUN: %clang -fextend-variable-liveness=this -### -c %s 2>&1 | FileCheck %s --check-prefixes=CHECK,THIS
7-
// RUN: %clang -fextend-this-ptr-liveness -### -c %s 2>&1 | FileCheck %s --check-prefixes=CHECK,THIS
87
// RUN: %clang -fextend-variable-liveness=all -### -c %s 2>&1 | FileCheck %s --check-prefixes=CHECK,ALL
98
// RUN: %clang -fextend-variable-liveness -### -c %s 2>&1 | FileCheck %s --check-prefixes=CHECK,ALL
109

llvm/test/CodeGen/MIR/X86/fake-use-tailcall.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# in the return block itself into the predecessor blocks. This test enures that we do so.
99
#
1010
# Generated from the following source with
11-
# clang -fextend-lifetimes -S -emit-llvm -O2 -mllvm -stop-before=codegenprepare -o test.mir test.c
11+
# clang -fextend-variable-liveness -S -emit-llvm -O2 -mllvm -stop-before=codegenprepare -o test.mir test.c
1212
#
1313
# extern int f0();
1414
# extern int f1();

llvm/test/CodeGen/X86/fake-use-simple-tail-call.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -O2 -o - \
22
; RUN: | FileCheck %s --implicit-check-not=TAILCALL
3-
; Generated with: clang -emit-llvm -O2 -S -fextend-lifetimes test.cpp -o -
3+
; Generated with: clang -emit-llvm -O2 -S -fextend-variable-liveness test.cpp -o -
44
; =========== test.cpp ===============
55
; extern int bar(int);
66
; int foo1(int i)

llvm/test/CodeGen/X86/fake-use-zero-length.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
; and structs. Check also that they are not propagated.
55
;
66
; Generated from the following source with
7-
; clang -fextend-lifetimes -S -emit-llvm -O2 -mllvm -stop-after=safe-stack -o test.mir test.cpp
7+
; clang -fextend-variable-liveness -S -emit-llvm -O2 -mllvm -stop-after=safe-stack -o test.mir test.cpp
88
;
99
; int main ()
1010
; { int array[0]; }

llvm/test/DebugInfo/AArch64/fake-use-global-isel.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
; RUN: not %python %p/../Inputs/check-fake-use.py %t
1313

1414
; Generated with:
15-
; clang -O2 -g -S -emit-llvm -fextend-this-ptr fake-use.c
15+
; clang -O2 -g -S -emit-llvm -fextend-variable-liveness=this fake-use.c
1616
;
1717
; int glob[10];
1818
; extern void bar();

llvm/test/DebugInfo/X86/fake-use.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
; RUN: not %python %p/../Inputs/check-fake-use.py %t
1010

1111
; Generated with:
12-
; clang -O2 -g -S -emit-llvm -fextend-this-ptr fake-use.c
12+
; clang -O2 -g -S -emit-llvm -fextend-variable-liveness=this fake-use.c
1313
;
1414
; int glob[10];
1515
; extern void bar();

llvm/test/Transforms/CodeGenPrepare/X86/fake-use-split-ret.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
;
33
; Ensure return instruction splitting ignores fake uses.
44
;
5-
; IR Generated with clang -O2 -S -emit-llvm -fextend-lifetimes test.cpp
5+
; IR Generated with clang -O2 -S -emit-llvm -fextend-variable-liveness test.cpp
66
;
77
;// test.cpp
88
;extern int bar(int);

llvm/test/Transforms/GVN/fake-use-constprop.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
; with respect to keeping the variable live up until the fake.use.
88
; This test checks that we don't generate any fake.uses with constant 0.
99
;
10-
; Reduced from the following test case, generated with clang -O2 -S -emit-llvm -fextend-lifetimes test.c
10+
; Reduced from the following test case, generated with clang -O2 -S -emit-llvm -fextend-variable-liveness test.c
1111
;
1212
; extern void func1();
1313
; extern int bar();

0 commit comments

Comments
 (0)