[PATCH] D145643: [clang][driver] Add option to manually control -disable-free in cc1
Chenbing.Zheng via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 8 19:32:52 PST 2023
Chenbing.Zheng created this revision.
Chenbing.Zheng added reviewers: aaron.ballman, lebedev.ri, benshi001.
Chenbing.Zheng added a project: clang.
Herald added subscribers: StephenFan, Anastasia.
Herald added a project: All.
Chenbing.Zheng requested review of this revision.
Herald added subscribers: cfe-commits, jacquesguan, MaskRay.
I get a memory leak in clang's CompilerInstance::ExecuteAction,
and remove -disable-free in cc1 works according to
https://github.com/RadeonOpenCompute/ROCm-OpenCL-Driver/issues/13
So, I want to add option to manually control -disable-free in cc1.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D145643
Files:
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/clang_f_opts.c
Index: clang/test/Driver/clang_f_opts.c
===================================================================
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -616,3 +616,8 @@
// CHECK-INT-OBJEMITTER-NOT: unsupported option '-fintegrated-objemitter' for target
// RUN: %clang -### -fno-integrated-objemitter -target x86_64 %s 2>&1 | FileCheck -check-prefix=CHECK-NOINT-OBJEMITTER %s
// CHECK-NOINT-OBJEMITTER: unsupported option '-fno-integrated-objemitter' for target
+
+// RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-FREE %s
+// RUN: %clang -### -S -fno-disable-free %s 2>&1 | FileCheck -check-prefix=CHECK-NO-DISABLE-FREE %s
+// CHECK-DISABLE-FREE: "-disable-free"
+// CHECK-NO-DISABLE-FREE-NOT: "-disable-free"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4981,7 +4981,7 @@
// We normally speed up the clang process a bit by skipping destructors at
// exit, but when we're generating diagnostics we can rely on some of the
// cleanup.
- if (!C.isForDiagnostics())
+ if (!Args.hasArg(options::OPT_fno_disable_free) && !C.isForDiagnostics())
CmdArgs.push_back("-disable-free");
CmdArgs.push_back("-clear-ast-before-backend");
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1564,6 +1564,8 @@
HelpText<"Discard value names in LLVM IR">, Flags<[NoXarchOption]>;
def fno_discard_value_names : Flag<["-"], "fno-discard-value-names">, Group<f_clang_Group>,
HelpText<"Do not discard value names in LLVM IR">, Flags<[NoXarchOption]>;
+def fno_disable_free : Flag<["-"], "fno-disable-free">, Group<f_clang_Group>,
+ HelpText<"cancel disable-free in cc1">, Flags<[NoXarchOption]>;
defm dollars_in_identifiers : BoolFOption<"dollars-in-identifiers",
LangOpts<"DollarIdents">, Default<!strconcat("!", asm_preprocessor.KeyPath)>,
PosFlag<SetTrue, [], "Allow">, NegFlag<SetFalse, [], "Disallow">,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145643.503600.patch
Type: text/x-patch
Size: 2184 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230309/dd4b7635/attachment.bin>
More information about the cfe-commits
mailing list