aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Tozer <stephen.tozer@sony.com>2025-04-25 12:18:26 +0100
committerStephen Tozer <stephen.tozer@sony.com>2025-04-25 12:55:10 +0100
commit2dc6e98169baeb1f73036da0ea50fd828d8323d0 (patch)
tree8dc02a5bab26f5ca9bc0c215b8da115127e02143
parentaccee2b5538eedae297201d1a2d66ddefd4c0cc1 (diff)
downloadllvm-2dc6e98169baeb1f73036da0ea50fd828d8323d0.zip
llvm-2dc6e98169baeb1f73036da0ea50fd828d8323d0.tar.gz
llvm-2dc6e98169baeb1f73036da0ea50fd828d8323d0.tar.bz2
Revert "[Clang] Enable -fextend-lifetimes at -Og (#118026)"
Reverted following several issues appearing related to fake uses, reported on the github PR. This reverts commit a9dff35ad251cd20376ab25b26d1e5394e18ff4c.
-rw-r--r--clang/docs/CommandGuide/clang.rst7
-rw-r--r--clang/docs/ReleaseNotes.rst4
-rw-r--r--clang/lib/Driver/ToolChains/Clang.cpp8
-rw-r--r--clang/test/Driver/extend-variable-liveness.c3
4 files changed, 4 insertions, 18 deletions
diff --git a/clang/docs/CommandGuide/clang.rst b/clang/docs/CommandGuide/clang.rst
index a1e738f..42aac7b 100644
--- a/clang/docs/CommandGuide/clang.rst
+++ b/clang/docs/CommandGuide/clang.rst
@@ -443,11 +443,8 @@ Code Generation Options
:option:`-Oz` Like :option:`-Os` (and thus :option:`-O2`), but reduces code
size further.
- :option:`-Og` Similar to :option:`-O1`, but with slightly reduced
- optimization and better variable visibility. The same optimizations are run
- as at :option:`-O1`, but the ``-fextend-variable-liveness`` flag is
- also set, which tries to prevent optimizations from reducing the liveness of
- user variables, improving their availability when debugging.
+ :option:`-Og` Like :option:`-O1`. In future versions, this option might
+ disable different optimizations in order to improve debuggability.
:option:`-O` Equivalent to :option:`-O1`.
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d1f24fb..8140f6c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -230,10 +230,6 @@ Modified Compiler Flags
- The ``-mexecute-only`` and ``-mpure-code`` flags are now accepted for AArch64 targets. (#GH125688)
-- The ``-Og`` optimization flag now sets ``-fextend-variable-liveness``,
- reducing performance slightly while reducing the number of optimized-out
- variables.
-
Removed Compiler Flags
-------------------------
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index f98cd38..762f8af 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7683,13 +7683,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (Args.hasArg(options::OPT_fretain_comments_from_system_headers))
CmdArgs.push_back("-fretain-comments-from-system-headers");
- if (Arg *A = Args.getLastArg(options::OPT_fextend_variable_liveness_EQ)) {
- A->render(Args, CmdArgs);
- } else if (Arg *A = Args.getLastArg(options::OPT_O_Group);
- A && A->containsValue("g")) {
- // Set -fextend-variable-liveness=all by default at -Og.
- CmdArgs.push_back("-fextend-variable-liveness=all");
- }
+ Args.AddLastArg(CmdArgs, options::OPT_fextend_variable_liveness_EQ);
// Forward -fcomment-block-commands to -cc1.
Args.AddAllArgs(CmdArgs, options::OPT_fcomment_block_commands);
diff --git a/clang/test/Driver/extend-variable-liveness.c b/clang/test/Driver/extend-variable-liveness.c
index 99a5409..bbfb2ec 100644
--- a/clang/test/Driver/extend-variable-liveness.c
+++ b/clang/test/Driver/extend-variable-liveness.c
@@ -1,8 +1,7 @@
// Tests that -fextend-variable-liveness and its aliases are correctly passed
-// by the driver, and are set by default at -Og.
+// by the driver.
// RUN: %clang -### -c %s 2>&1 | FileCheck %s --check-prefixes=CHECK,DEFAULT
-// RUN: %clang -### -Og -c %s 2>&1 | FileCheck %s --check-prefixes=CHECK,ALL
// RUN: %clang -fextend-variable-liveness=none -### -c %s 2>&1 | FileCheck %s --check-prefixes=CHECK,NONE
// RUN: %clang -fextend-variable-liveness=this -### -c %s 2>&1 | FileCheck %s --check-prefixes=CHECK,THIS
// RUN: %clang -fextend-variable-liveness=all -### -c %s 2>&1 | FileCheck %s --check-prefixes=CHECK,ALL