summaryrefslogtreecommitdiffstats
path: root/dynamic-layers/clang-layer
diff options
context:
space:
mode:
authorAnuj Mittal <anuj.mittal@intel.com>2021-10-21 23:40:23 +0800
committerAnuj Mittal <anuj.mittal@intel.com>2021-10-21 23:42:39 +0800
commit3b386a9dc80eb61055b74d93f2da582ce2c652c7 (patch)
tree1a522e8924fec699408907dd0a96c72ac50d41b4 /dynamic-layers/clang-layer
parent272e0889026e6479fd366d4447e7345e4dd52d11 (diff)
downloadmeta-intel-3b386a9dc80eb61055b74d93f2da582ce2c652c7.tar.gz
llvm-project-source/10.0.1: backport fixes from LLVM 11
Include a fix and two supporting patches from LLVM 11 to fix problems with double registration while both clang-cpp and llvm lib are linked (like in case of opencl-clang). | CommandLine Error: Option 'mc-relax-all' registered more than once! | LLVM ERROR: inconsistency in registered CommandLine options Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Diffstat (limited to 'dynamic-layers/clang-layer')
-rw-r--r--dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm10-Enable-the-call-site-info-only-for-g-optimizations.patch550
-rw-r--r--dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm10-Replace-MCTargetOptionsCommandFlags.inc-and-CommandF.patch2243
-rw-r--r--dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm10-basic-block-sections-support.patch237
-rw-r--r--dynamic-layers/clang-layer/recipes-devtools/clang/llvm-project-source.bbappend3
4 files changed, 3033 insertions, 0 deletions
diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm10-Enable-the-call-site-info-only-for-g-optimizations.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm10-Enable-the-call-site-info-only-for-g-optimizations.patch
new file mode 100644
index 00000000..2e3872dc
--- /dev/null
+++ b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm10-Enable-the-call-site-info-only-for-g-optimizations.patch
@@ -0,0 +1,550 @@
1From 447cb2e1b2f0d8bdcfd8a0b39f47d28de50b5d82 Mon Sep 17 00:00:00 2001
2From: Djordje Todorovic <djordje.todorovic@syrmia.com>
3Date: Mon, 9 Mar 2020 11:02:35 +0100
4Subject: [PATCH] Enable the call site info only for -g + optimizations
5
6Emit call site info only in the case of '-g' + 'O>0' level.
7
8Differential Revision: https://reviews.llvm.org/D75175
9
10Upstream-Status: Backport [https://github.com/llvm/llvm-project/commit/c15c68abdc6f1afece637bdedba808676191a8e6]
11Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
12---
13 clang/include/clang/Basic/CodeGenOptions.def | 2 ++
14 clang/lib/CodeGen/BackendUtil.cpp | 1 +
15 clang/lib/Frontend/CompilerInvocation.cpp | 4 +++-
16 llvm/include/llvm/CodeGen/CommandFlags.inc | 7 +++++++
17 llvm/include/llvm/Target/TargetOptions.h | 7 ++++++-
18 llvm/lib/CodeGen/MIRParser/MIRParser.cpp | 4 ++--
19 llvm/lib/CodeGen/MachineFunction.cpp | 2 +-
20 llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp | 2 +-
21 llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | 2 +-
22 llvm/lib/Target/ARM/ARMISelLowering.cpp | 2 +-
23 llvm/lib/Target/X86/X86ISelLowering.cpp | 2 +-
24 llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir | 2 +-
25 llvm/test/CodeGen/X86/call-site-info-output.ll | 4 ++--
26 llvm/test/DebugInfo/AArch64/call-site-info-output.ll | 2 +-
27 llvm/test/DebugInfo/ARM/call-site-info-output.ll | 2 +-
28 .../MIR/AArch64/dbgcall-site-interpret-movzxi.mir | 2 +-
29 .../DebugInfo/MIR/AArch64/dbgcall-site-interpretation.mir | 2 +-
30 llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir | 2 +-
31 .../test/DebugInfo/MIR/AArch64/implicit-def-dead-scope.mir | 2 +-
32 .../test/DebugInfo/MIR/ARM/dbgcall-site-interpretation.mir | 2 +-
33 .../DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir | 2 +-
34 llvm/test/DebugInfo/MIR/ARM/if-coverter-call-site-info.mir | 2 +-
35 .../MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir | 2 +-
36 .../MIR/Hexagon/live-debug-values-bundled-entry-values.mir | 2 +-
37 llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir | 2 +-
38 llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir | 2 +-
39 llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir | 2 +-
40 .../test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir | 2 +-
41 .../test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir | 2 +-
42 .../DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir | 2 +-
43 llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir | 2 +-
44 .../DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir | 2 +-
45 llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir | 2 +-
46 llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir | 4 ++--
47 .../DebugInfo/MIR/X86/entry-value-of-modified-param.mir | 2 +-
48 llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir | 2 +-
49 .../DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir | 2 +-
50 .../test/DebugInfo/MIR/X86/unreachable-block-call-site.mir | 2 +-
51 llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll | 2 +-
52 llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll | 2 +-
53 .../tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll | 2 +-
54 41 files changed, 58 insertions(+), 41 deletions(-)
55
56diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def
57index 1ecae98b13b1..6a6a9465273f 100644
58--- a/clang/include/clang/Basic/CodeGenOptions.def
59+++ b/clang/include/clang/Basic/CodeGenOptions.def
60@@ -64,6 +64,8 @@ CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
61 ///< pass manager.
62 CODEGENOPT(DisableRedZone , 1, 0) ///< Set when -mno-red-zone is enabled.
63 CODEGENOPT(EnableDebugEntryValues, 1, 0) ///< Emit call site parameter dbg info
64+CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
65+ ///< '-g' + 'O>0' level.
66 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
67 ///< is specified.
68 CODEGENOPT(DisableTailCalls , 1, 0) ///< Do not emit tail calls.
69diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
70index db8fd4166d7a..db09f9b641fe 100644
71--- a/clang/lib/CodeGen/BackendUtil.cpp
72+++ b/clang/lib/CodeGen/BackendUtil.cpp
73@@ -482,6 +482,7 @@ static void initTargetOptions(llvm::TargetOptions &Options,
74 Options.EmitAddrsig = CodeGenOpts.Addrsig;
75 Options.EnableDebugEntryValues = CodeGenOpts.EnableDebugEntryValues;
76 Options.ForceDwarfFrameSection = CodeGenOpts.ForceDwarfFrameSection;
77+ Options.EmitCallSiteInfo = CodeGenOpts.EmitCallSiteInfo;
78
79 Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
80 Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll;
81diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
82index 18fa06bf3c6d..2e73dcbdebe4 100644
83--- a/clang/lib/Frontend/CompilerInvocation.cpp
84+++ b/clang/lib/Frontend/CompilerInvocation.cpp
85@@ -789,8 +789,10 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
86
87 llvm::Triple T(TargetOpts.Triple);
88 if (Opts.OptimizationLevel > 0 && Opts.hasReducedDebugInfo() &&
89- llvm::is_contained(DebugEntryValueArchs, T.getArch()))
90+ llvm::is_contained(DebugEntryValueArchs, T.getArch())) {
91 Opts.EnableDebugEntryValues = Args.hasArg(OPT_femit_debug_entry_values);
92+ Opts.EmitCallSiteInfo = true;
93+ }
94
95 Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
96 Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
97diff --git a/llvm/include/llvm/CodeGen/CommandFlags.inc b/llvm/include/llvm/CodeGen/CommandFlags.inc
98index 6475a5b19edb..36073fe9cc98 100644
99--- a/llvm/include/llvm/CodeGen/CommandFlags.inc
100+++ b/llvm/include/llvm/CodeGen/CommandFlags.inc
101@@ -286,6 +286,12 @@ static cl::opt<bool>
102 EnableAddrsig("addrsig", cl::desc("Emit an address-significance table"),
103 cl::init(false));
104
105+static cl::opt<bool> EmitCallSiteInfo(
106+ "emit-call-site-info",
107+ cl::desc(
108+ "Emit call site debug information, if debug information is enabled."),
109+ cl::init(false));
110+
111 static cl::opt<bool>
112 EnableDebugEntryValues("debug-entry-values",
113 cl::desc("Emit debug info about parameter's entry values"),
114@@ -349,6 +355,7 @@ static TargetOptions InitTargetOptionsFromCodeGenFlags() {
115 Options.ExceptionModel = ExceptionModel;
116 Options.EmitStackSizeSection = EnableStackSizeSection;
117 Options.EmitAddrsig = EnableAddrsig;
118+ Options.EmitCallSiteInfo = EmitCallSiteInfo;
119 Options.EnableDebugEntryValues = EnableDebugEntryValues;
120 Options.ForceDwarfFrameSection = ForceDwarfFrameSection;
121
122diff --git a/llvm/include/llvm/Target/TargetOptions.h b/llvm/include/llvm/Target/TargetOptions.h
123index d27c7b0178f0..9378e290bed1 100644
124--- a/llvm/include/llvm/Target/TargetOptions.h
125+++ b/llvm/include/llvm/Target/TargetOptions.h
126@@ -134,7 +134,8 @@ namespace llvm {
127 EmulatedTLS(false), ExplicitEmulatedTLS(false), EnableIPRA(false),
128 EmitStackSizeSection(false), EnableMachineOutliner(false),
129 SupportsDefaultOutlining(false), EmitAddrsig(false),
130- EnableDebugEntryValues(false), ForceDwarfFrameSection(false) {}
131+ EmitCallSiteInfo(false), EnableDebugEntryValues(false),
132+ ForceDwarfFrameSection(false) {}
133
134 /// PrintMachineCode - This flag is enabled when the -print-machineinstrs
135 /// option is specified on the command line, and should enable debugging
136@@ -281,6 +282,10 @@ namespace llvm {
137 /// to selectively generate basic block sections.
138 std::shared_ptr<MemoryBuffer> BBSectionsFuncListBuf;
139
140+ /// The flag enables call site info production. It is used only for debug
141+ /// info, and it is restricted only to optimized code. This can be used for
142+ /// something else, so that should be controlled in the frontend.
143+ unsigned EmitCallSiteInfo : 1;
144 /// Emit debug info about parameter's entry values.
145 unsigned EnableDebugEntryValues : 1;
146
147diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
148index 10157c746b46..f955bdc6186a 100644
149--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
150+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
151@@ -381,11 +381,11 @@ bool MIRParserImpl::initializeCallSiteInfo(
152 CSInfo.emplace_back(Reg, ArgRegPair.ArgNo);
153 }
154
155- if (TM.Options.EnableDebugEntryValues)
156+ if (TM.Options.EmitCallSiteInfo)
157 MF.addCallArgsForwardingRegs(&*CallI, std::move(CSInfo));
158 }
159
160- if (YamlMF.CallSitesInfo.size() && !TM.Options.EnableDebugEntryValues)
161+ if (YamlMF.CallSitesInfo.size() && !TM.Options.EmitCallSiteInfo)
162 return error(Twine("Call site info provided but not used"));
163 return false;
164 }
165diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
166index 4612690644fe..c3795b7ed314 100644
167--- a/llvm/lib/CodeGen/MachineFunction.cpp
168+++ b/llvm/lib/CodeGen/MachineFunction.cpp
169@@ -855,7 +855,7 @@ MachineFunction::CallSiteInfoMap::iterator
170 MachineFunction::getCallSiteInfo(const MachineInstr *MI) {
171 assert(MI->isCall() && "Call site info refers only to call instructions!");
172
173- if (!Target.Options.EnableDebugEntryValues)
174+ if (!Target.Options.EmitCallSiteInfo)
175 return CallSitesInfo.end();
176 return CallSitesInfo.find(MI);
177 }
178diff --git a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
179index 0e4d783e3505..52099f24aca5 100644
180--- a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
181+++ b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
182@@ -863,7 +863,7 @@ EmitSchedule(MachineBasicBlock::iterator &InsertPos) {
183 MI = &*std::next(Before);
184 }
185
186- if (MI->isCall() && DAG->getTarget().Options.EnableDebugEntryValues)
187+ if (MI->isCall() && DAG->getTarget().Options.EmitCallSiteInfo)
188 MF.addCallArgsForwardingRegs(MI, DAG->getSDCallSiteInfo(Node));
189
190 return MI;
191diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
192index 23f05eaad944..63ff3031a5e8 100644
193--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
194+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
195@@ -4132,7 +4132,7 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI,
196 RegsToPass.emplace_back(VA.getLocReg(), Arg);
197 RegsUsed.insert(VA.getLocReg());
198 const TargetOptions &Options = DAG.getTarget().Options;
199- if (Options.EnableDebugEntryValues)
200+ if (Options.EmitCallSiteInfo)
201 CSInfo.emplace_back(VA.getLocReg(), i);
202 }
203 } else {
204diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
205index 9f504b1eaa42..5589ba34a2ac 100644
206--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
207+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
208@@ -2222,7 +2222,7 @@ ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
209 isThisReturn = true;
210 }
211 const TargetOptions &Options = DAG.getTarget().Options;
212- if (Options.EnableDebugEntryValues)
213+ if (Options.EmitCallSiteInfo)
214 CSInfo.emplace_back(VA.getLocReg(), i);
215 RegsToPass.push_back(std::make_pair(VA.getLocReg(), Arg));
216 } else if (isByVal) {
217diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
218index d5de94aeb8a2..4808bdf6ddc2 100644
219--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
220+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
221@@ -4030,7 +4030,7 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
222 } else if (VA.isRegLoc()) {
223 RegsToPass.push_back(std::make_pair(VA.getLocReg(), Arg));
224 const TargetOptions &Options = DAG.getTarget().Options;
225- if (Options.EnableDebugEntryValues)
226+ if (Options.EmitCallSiteInfo)
227 CSInfo.emplace_back(VA.getLocReg(), I);
228 if (isVarArg && IsWin64) {
229 // Win64 ABI requires argument XMM reg to be copied to the corresponding
230diff --git a/llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir b/llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
231index 5ffa0293a2e1..fec542223fc9 100644
232--- a/llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
233+++ b/llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
234@@ -1,4 +1,4 @@
235-# RUN: llc -debug-entry-values -run-pass=none -verify-machineinstrs -o - %s | FileCheck %s
236+# RUN: llc -emit-call-site-info -debug-entry-values -run-pass=none -verify-machineinstrs -o - %s | FileCheck %s
237
238 # Verify that it is possible to read and write MIR where a callSites entry
239 # points to a call residing in a bundle. The offset should point to the call
240diff --git a/llvm/test/CodeGen/X86/call-site-info-output.ll b/llvm/test/CodeGen/X86/call-site-info-output.ll
241index 4b1e236aadfe..a0438f0c2b98 100644
242--- a/llvm/test/CodeGen/X86/call-site-info-output.ll
243+++ b/llvm/test/CodeGen/X86/call-site-info-output.ll
244@@ -1,6 +1,6 @@
245 ; Test call site info MIR printer and parser.Parser assertions and machine
246 ; verifier will check the rest;
247-; RUN: llc -debug-entry-values %s -stop-before=finalize-isel -o %t.mir
248+; RUN: llc -emit-call-site-info -debug-entry-values %s -stop-before=finalize-isel -o %t.mir
249 ; RUN: cat %t.mir | FileCheck %s
250 ; CHECK: name: fn2
251 ; CHECK: callSites:
252@@ -10,7 +10,7 @@
253 ; CHECK-NEXT: arg: 0, reg: '$edi'
254 ; CHECK-NEXT: arg: 1, reg: '$esi'
255 ; CHECK-NEXT: arg: 2, reg: '$edx'
256-; RUN: llc -debug-entry-values %t.mir -run-pass=finalize-isel -o -| FileCheck %s --check-prefix=PARSER
257+; RUN: llc -emit-call-site-info -debug-entry-values %t.mir -run-pass=finalize-isel -o -| FileCheck %s --check-prefix=PARSER
258 ; Verify that we are able to parse output mir and that we are getting the same result.
259 ; PARSER: name: fn2
260 ; PARSER: callSites:
261diff --git a/llvm/test/DebugInfo/AArch64/call-site-info-output.ll b/llvm/test/DebugInfo/AArch64/call-site-info-output.ll
262index d52d6962f3c4..17d9f7f18762 100644
263--- a/llvm/test/DebugInfo/AArch64/call-site-info-output.ll
264+++ b/llvm/test/DebugInfo/AArch64/call-site-info-output.ll
265@@ -1,4 +1,4 @@
266-; RUN: llc -mtriple aarch64-linux-gnu -debug-entry-values %s -o - -stop-before=finalize-isel | FileCheck %s
267+; RUN: llc -emit-call-site-info -mtriple aarch64-linux-gnu -debug-entry-values %s -o - -stop-before=finalize-isel | FileCheck %s
268 ; Verify that Selection DAG knows how to recognize simple function parameter forwarding registers.
269 ; Produced from:
270 ; extern int fn1(int,int,int);
271diff --git a/llvm/test/DebugInfo/ARM/call-site-info-output.ll b/llvm/test/DebugInfo/ARM/call-site-info-output.ll
272index 9255a7d57dde..ed726dfe753f 100644
273--- a/llvm/test/DebugInfo/ARM/call-site-info-output.ll
274+++ b/llvm/test/DebugInfo/ARM/call-site-info-output.ll
275@@ -1,4 +1,4 @@
276-; RUN: llc -mtriple arm-linux-gnu -debug-entry-values %s -o - -stop-before=finalize-isel | FileCheck %s
277+; RUN: llc -emit-call-site-info -mtriple arm-linux-gnu -debug-entry-values %s -o - -stop-before=finalize-isel | FileCheck %s
278 ; Verify that Selection DAG knows how to recognize simple function parameter forwarding registers.
279 ; Produced from:
280 ; extern int fn1(int,int,int);
281diff --git a/llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpret-movzxi.mir b/llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpret-movzxi.mir
282index dc7561ca6400..057779a90721 100644
283--- a/llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpret-movzxi.mir
284+++ b/llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpret-movzxi.mir
285@@ -1,4 +1,4 @@
286-# RUN: llc -mtriple aarch64-linux-gnu -debug-entry-values -start-after=machineverifier -filetype=obj %s -o -| llvm-dwarfdump -| FileCheck %s
287+# RUN: llc -emit-call-site-info -mtriple aarch64-linux-gnu -debug-entry-values -start-after=machineverifier -filetype=obj %s -o -| llvm-dwarfdump -| FileCheck %s
288 #
289 # Based on the following C reproducer:
290 #
291diff --git a/llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpretation.mir b/llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpretation.mir
292index 0371ccef603e..d925bc395878 100644
293--- a/llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpretation.mir
294+++ b/llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpretation.mir
295@@ -1,4 +1,4 @@
296-# RUN: llc -mtriple aarch64-linux-gnu -debug-entry-values -start-after=machineverifier -filetype=obj %s -o -| llvm-dwarfdump -| FileCheck %s
297+# RUN: llc -emit-call-site-info -mtriple aarch64-linux-gnu -debug-entry-values -start-after=machineverifier -filetype=obj %s -o -| llvm-dwarfdump -| FileCheck %s
298 # Following code is used for producing this test case. Note that
299 # some of argument loading instruction are modified in order to
300 # cover certain cases.
301diff --git a/llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir b/llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
302index 916a14022ba5..4a87dad3b9b5 100644
303--- a/llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
304+++ b/llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
305@@ -1,4 +1,4 @@
306-# RUN: llc -debug-entry-values -start-after=livedebugvalues -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s
307+# RUN: llc -emit-call-site-info -debug-entry-values -start-after=livedebugvalues -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s
308
309 # Based on the following C reproducer:
310 #
311diff --git a/llvm/test/DebugInfo/MIR/AArch64/implicit-def-dead-scope.mir b/llvm/test/DebugInfo/MIR/AArch64/implicit-def-dead-scope.mir
312index fbf9b3454689..d85f2d25391d 100644
313--- a/llvm/test/DebugInfo/MIR/AArch64/implicit-def-dead-scope.mir
314+++ b/llvm/test/DebugInfo/MIR/AArch64/implicit-def-dead-scope.mir
315@@ -1,4 +1,4 @@
316-# RUN: llc -start-after=livedebugvalues -filetype=obj -o - %s \
317+# RUN: llc -emit-call-site-info -start-after=livedebugvalues -filetype=obj -o - %s \
318 # RUN: | llvm-dwarfdump -v - | FileCheck %s
319
320 # This tests for a crash in DwarfDebug's singular DBG_VALUE range promotion when
321diff --git a/llvm/test/DebugInfo/MIR/ARM/dbgcall-site-interpretation.mir b/llvm/test/DebugInfo/MIR/ARM/dbgcall-site-interpretation.mir
322index ce8dc97f0e72..0ae4e6ec485c 100644
323--- a/llvm/test/DebugInfo/MIR/ARM/dbgcall-site-interpretation.mir
324+++ b/llvm/test/DebugInfo/MIR/ARM/dbgcall-site-interpretation.mir
325@@ -1,4 +1,4 @@
326-# RUN: llc -mtriple=arm-linux-gnueabi -debug-entry-values -filetype=obj -start-after=machineverifier %s -o -| llvm-dwarfdump -| FileCheck %s
327+# RUN: llc -emit-call-site-info -mtriple=arm-linux-gnueabi -debug-entry-values -filetype=obj -start-after=machineverifier %s -o -| llvm-dwarfdump -| FileCheck %s
328 # Following code is used for producing this test case. Note that
329 # some of argument loading instruction are modified in order to
330 # cover certain cases.
331diff --git a/llvm/test/DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir b/llvm/test/DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir
332index 9001c8ba8eea..5b84d9e9627f 100644
333--- a/llvm/test/DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir
334+++ b/llvm/test/DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir
335@@ -1,4 +1,4 @@
336-# RUN: llc -debug-entry-values -run-pass=livedebugvalues -o - %s | FileCheck %s
337+# RUN: llc -emit-call-site-info -debug-entry-values -run-pass=livedebugvalues -o - %s | FileCheck %s
338
339 # Based on the following C reproducer:
340 #
341diff --git a/llvm/test/DebugInfo/MIR/ARM/if-coverter-call-site-info.mir b/llvm/test/DebugInfo/MIR/ARM/if-coverter-call-site-info.mir
342index aa7b54c1e5bb..11e9c4c90836 100644
343--- a/llvm/test/DebugInfo/MIR/ARM/if-coverter-call-site-info.mir
344+++ b/llvm/test/DebugInfo/MIR/ARM/if-coverter-call-site-info.mir
345@@ -1,4 +1,4 @@
346-# RUN: llc -mtriple=arm-linux-gnu -debug-entry-values -run-pass if-converter %s -o -| FileCheck %s
347+# RUN: llc -emit-call-site-info -mtriple=arm-linux-gnu -debug-entry-values -run-pass if-converter %s -o -| FileCheck %s
348
349 # Vefify that the call site info will be updated after the optimization.
350 # This test case would previously trigger an assertion when
351diff --git a/llvm/test/DebugInfo/MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir b/llvm/test/DebugInfo/MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir
352index 8ae628af2c09..3ae23d4189bf 100644
353--- a/llvm/test/DebugInfo/MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir
354+++ b/llvm/test/DebugInfo/MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir
355@@ -1,4 +1,4 @@
356-# RUN: llc -mtriple hexagon -debug-entry-values -start-after=machineverifier -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s
357+# RUN: llc -mtriple hexagon -emit-call-site-info -debug-entry-values -start-after=machineverifier -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s
358
359 # Based on the following C reproducer:
360 #
361diff --git a/llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir b/llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
362index ff0a539dd15d..8bb0b3202acd 100644
363--- a/llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
364+++ b/llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
365@@ -1,4 +1,4 @@
366-# RUN: llc -debug-entry-values -run-pass=livedebugvalues -o - %s | FileCheck %s
367+# RUN: llc -emit-call-site-info -debug-entry-values -run-pass=livedebugvalues -o - %s | FileCheck %s
368
369 # Verify that the entry values for the input parameters are inserted after the
370 # bundles which contains the registers' clobbering instructions (the calls to
371diff --git a/llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir b/llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir
372index 8a4e8b5632c2..3cf41467f7f9 100644
373--- a/llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir
374+++ b/llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir
375@@ -1,4 +1,4 @@
376-# RUN: llc -debug-entry-values -start-after=livedebugvalues -o - %s | FileCheck %s
377+# RUN: llc -emit-call-site-info -debug-entry-values -start-after=livedebugvalues -o - %s | FileCheck %s
378
379 # This test would previously trigger an assertion when trying to describe the
380 # call site value for callee()'s float parameter.
381diff --git a/llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir b/llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir
382index e6fe5d2de878..4e5a07321d42 100644
383--- a/llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir
384+++ b/llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir
385@@ -1,4 +1,4 @@
386-# RUN: llc -debug-entry-values -start-before=livedebugvalues -mtriple=x86_64-apple-darwin -o %t %s -filetype=obj
387+# RUN: llc -emit-call-site-info -debug-entry-values -start-before=livedebugvalues -mtriple=x86_64-apple-darwin -o %t %s -filetype=obj
388 # RUN: llvm-dwarfdump %t | FileCheck %s
389 #
390 # int global;
391diff --git a/llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir b/llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir
392index c32a1155d038..edeef2c7aed4 100644
393--- a/llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir
394+++ b/llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir
395@@ -1,6 +1,6 @@
396 # Check that llvm can describe a call site parameter which resides in a spill slot.
397 #
398-# RUN: llc -debug-entry-values -start-after=machineverifier -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s
399+# RUN: llc -emit-call-site-info -debug-entry-values -start-after=machineverifier -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s
400 #
401 # Command:
402 # $ ~/src/builds/llvm-project-master-RA/bin/clang -g -Xclang -femit-debug-entry-values -O2 -c -o spill.o spill.cc -mllvm -stop-before=machineverifier -o spill.mir
403diff --git a/llvm/test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir b/llvm/test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir
404index a2d51a203512..01a2b887a60b 100644
405--- a/llvm/test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir
406+++ b/llvm/test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir
407@@ -1,4 +1,4 @@
408-# RUN: llc -debug-entry-values -start-after=livedebugvalues -filetype=obj %s -o -| llvm-dwarfdump -| FileCheck %s
409+# RUN: llc -emit-call-site-info -debug-entry-values -start-after=livedebugvalues -filetype=obj %s -o -| llvm-dwarfdump -| FileCheck %s
410
411 # Based on the following reproducer:
412 #
413diff --git a/llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir b/llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
414index f9e9459f1abd..104bc0146798 100644
415--- a/llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
416+++ b/llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
417@@ -1,4 +1,4 @@
418-# RUN: llc -debug-entry-values -start-after=machineverifier -filetype=obj %s -o -| llvm-dwarfdump -| FileCheck %s
419+# RUN: llc -emit-call-site-info -debug-entry-values -start-after=machineverifier -filetype=obj %s -o -| llvm-dwarfdump -| FileCheck %s
420 #
421 # CHECK: DW_TAG_GNU_call_site
422 # CHECK-NEXT: DW_AT_abstract_origin {{.*}} "foo"
423diff --git a/llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir b/llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
424index 1bb70f6d4530..4d88fa9aab74 100644
425--- a/llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
426+++ b/llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
427@@ -1,4 +1,4 @@
428-# RUN: llc -debug-entry-values -start-after=machineverifier -filetype=obj %s -o -| llvm-dwarfdump -| FileCheck %s
429+# RUN: llc -emit-call-site-info -debug-entry-values -start-after=machineverifier -filetype=obj %s -o -| llvm-dwarfdump -| FileCheck %s
430 # CHECK: DW_TAG_GNU_call_site
431 # CHECK-NEXT: DW_AT_abstract_origin {{.*}} "foo")
432 # CHECK-NEXT: DW_AT_low_pc {{.*}}
433diff --git a/llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir b/llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
434index 235787573f51..81af598ba194 100644
435--- a/llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
436+++ b/llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
437@@ -1,4 +1,4 @@
438-# RUN: llc -debug-entry-values -start-before=livedebugvalues -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s
439+# RUN: llc -emit-call-site-info -debug-entry-values -start-before=livedebugvalues -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s
440
441 # Based on the following C++ code:
442 # struct A { A(A &) {} };
443diff --git a/llvm/test/DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir b/llvm/test/DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir
444index db0934c595c3..46adedd1be44 100644
445--- a/llvm/test/DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir
446+++ b/llvm/test/DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir
447@@ -1,4 +1,4 @@
448-# RUN: llc -O1 -debug-entry-values -start-after=livedebugvalues -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s
449+# RUN: llc -O1 -emit-call-site-info -debug-entry-values -start-after=livedebugvalues -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s
450
451 # Based on the following C reproducer:
452 #
453diff --git a/llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir b/llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
454index 5d203029936e..1d7b64f169d1 100644
455--- a/llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
456+++ b/llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
457@@ -1,4 +1,4 @@
458-# RUN: llc -debug-entry-values -run-pass=livedebugvalues -march=x86-64 -o - %s | FileCheck %s
459+# RUN: llc -emit-call-site-info -debug-entry-values -run-pass=livedebugvalues -march=x86-64 -o - %s | FileCheck %s
460 #
461 #extern void fn2(int);
462 #
463diff --git a/llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir b/llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
464index e79be66cd4e3..c39bc4db50be 100644
465--- a/llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
466+++ b/llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
467@@ -2,8 +2,8 @@
468 # When the debugger tuning is set to gdb, use GNU opcodes.
469 # For lldb, use the standard DWARF5 opcodes.
470
471-# RUN: llc -debug-entry-values -debugger-tune=gdb -filetype=obj -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-GNU
472-# RUN: llc -debug-entry-values -debugger-tune=lldb -filetype=obj -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-DWARF5
473+# RUN: llc -emit-call-site-info -debug-entry-values -debugger-tune=gdb -filetype=obj -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-GNU
474+# RUN: llc -emit-call-site-info -debug-entry-values -debugger-tune=lldb -filetype=obj -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-DWARF5
475 #
476 # extern void foo(int *a, int b, int c, int d, int e, int f);
477 # extern int getVal();
478diff --git a/llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir b/llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
479index 8d121c3a30b9..c7f15aaaa562 100644
480--- a/llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
481+++ b/llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
482@@ -1,4 +1,4 @@
483-# RUN: llc -debug-entry-values -run-pass=livedebugvalues -march=x86-64 -o - %s | FileCheck %s
484+# RUN: llc -emit-call-site-info -debug-entry-values -run-pass=livedebugvalues -march=x86-64 -o - %s | FileCheck %s
485 #
486 #extern void fn1 (int, int, int);
487 #
488diff --git a/llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir b/llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir
489index 2396daada876..aa8fdd7afd47 100644
490--- a/llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir
491+++ b/llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir
492@@ -1,4 +1,4 @@
493-# RUN: llc -debug-entry-values -run-pass=livedebugvalues -march=x86-64 -o - %s | FileCheck %s
494+# RUN: llc -emit-call-site-info -debug-entry-values -run-pass=livedebugvalues -march=x86-64 -o - %s | FileCheck %s
495 #
496 # The test case was artificially adjusted, in order to make proper diamond basic
497 # block structure relevant to the debug entry values propagation.
498diff --git a/llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir b/llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir
499index 86b1cddaa462..c5af863954bf 100644
500--- a/llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir
501+++ b/llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir
502@@ -1,4 +1,4 @@
503-# RUN: llc -debug-entry-values -run-pass=livedebugvalues -march=x86-64 -o - %s | FileCheck %s
504+# RUN: llc -emit-call-site-info -debug-entry-values -run-pass=livedebugvalues -march=x86-64 -o - %s | FileCheck %s
505 #
506 #extern void fn1 (int, int, int);
507 #__attribute__((noinline))
508diff --git a/llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir b/llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
509index d282d796f6d7..ea9c12b5a192 100644
510--- a/llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
511+++ b/llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
512@@ -1,4 +1,4 @@
513-# RUN: llc -mtriple=x86_64-pc-linux -debug-entry-values -run-pass=unreachable-mbb-elimination -o - %s | FileCheck %s
514+# RUN: llc -mtriple=x86_64-pc-linux -emit-call-site-info -debug-entry-values -run-pass=unreachable-mbb-elimination -o - %s | FileCheck %s
515
516 # Verify that the call site information for the call residing in the eliminated
517 # block is removed. This test case would previously trigger an assertion when
518diff --git a/llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll b/llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll
519index b698f1cdbfe8..b8cd9574cc63 100644
520--- a/llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll
521+++ b/llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll
522@@ -1,4 +1,4 @@
523-; RUN: llc -O1 -debug-entry-values -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s
524+; RUN: llc -O1 -emit-call-site-info -debug-entry-values -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s
525
526 ; Verify that the 64-bit call site immediates are not truncated.
527 ;
528diff --git a/llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll b/llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll
529index 9fe67f82a2b4..5d37774f55d6 100644
530--- a/llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll
531+++ b/llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll
532@@ -1,4 +1,4 @@
533-; RUN: llc -O3 -debug-entry-values -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s
534+; RUN: llc -O3 -emit-call-site-info -debug-entry-values -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s
535
536 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
537 target triple = "x86_64-unknown-linux-gnu"
538diff --git a/llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll b/llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll
539index c304e9d768a5..d126757398ff 100644
540--- a/llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll
541+++ b/llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll
542@@ -1,4 +1,4 @@
543-; RUN: llc -debug-entry-values %s -o - -filetype=obj \
544+; RUN: llc -emit-call-site-info -debug-entry-values %s -o - -filetype=obj \
545 ; RUN: | llvm-dwarfdump -statistics - | FileCheck %s
546 ;
547 ; The LLVM IR file was generated on this source code by using
548--
5492.33.1
550
diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm10-Replace-MCTargetOptionsCommandFlags.inc-and-CommandF.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm10-Replace-MCTargetOptionsCommandFlags.inc-and-CommandF.patch
new file mode 100644
index 00000000..6b2db931
--- /dev/null
+++ b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm10-Replace-MCTargetOptionsCommandFlags.inc-and-CommandF.patch
@@ -0,0 +1,2243 @@
1From fd7146658e3b4ce045dfb332c2edf216f76c1e1f Mon Sep 17 00:00:00 2001
2From: serge-sans-paille <sguelton@redhat.com>
3Date: Wed, 4 Mar 2020 00:47:43 +0100
4Subject: [PATCH] Replace MCTargetOptionsCommandFlags.inc and CommandFlags.inc
5 by runtime registration
6
7MCTargetOptionsCommandFlags.inc and CommandFlags.inc are headers which contain
8cl::opt with static storage.
9These headers are meant to be incuded by tools to make it easier to parametrize
10codegen/mc.
11
12However, these headers are also included in at least two libraries: lldCommon
13and handle-llvm. As a result, when creating DYLIB, clang-cpp holds a reference
14to the options, and lldCommon holds another reference. Linking the two in a
15single executable, as zig does[0], results in a double registration.
16
17This patch explores an other approach: the .inc files are moved to regular
18files, and the registration happens on-demand through static declaration of
19options in the constructor of a static object.
20
21[0] https://bugzilla.redhat.com/show_bug.cgi?id=1756977#c5
22
23Differential Revision: https://reviews.llvm.org/D75579
24
25Upstream-Status: Backport
26Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
27---
28 .../clang-fuzzer/handle-llvm/handle_llvm.cpp | 32 +-
29 lld/Common/TargetOptionsCommandFlags.cpp | 25 +-
30 llvm/include/llvm/CodeGen/CommandFlags.h | 149 +++++
31 .../llvm/MC/MCTargetOptionsCommandFlags.h | 54 ++
32 .../llvm/MC/MCTargetOptionsCommandFlags.inc | 65 --
33 llvm/include/llvm/module.modulemap | 3 -
34 llvm/lib/CodeGen/CMakeLists.txt | 1 +
35 llvm/lib/CodeGen/CommandFlags.cpp | 588 ++++++++++++++++++
36 llvm/lib/MC/CMakeLists.txt | 1 +
37 llvm/lib/MC/MCTargetOptionsCommandFlags.cpp | 105 ++++
38 llvm/tools/dsymutil/DwarfStreamer.cpp | 7 +-
39 llvm/tools/gold/gold-plugin.cpp | 16 +-
40 llvm/tools/llc/CMakeLists.txt | 1 +
41 llvm/tools/llc/llc.cpp | 43 +-
42 llvm/tools/lli/CMakeLists.txt | 1 +
43 llvm/tools/lli/lli.cpp | 41 +-
44 llvm/tools/llvm-dwp/llvm-dwp.cpp | 6 +-
45 .../llvm-isel-fuzzer/llvm-isel-fuzzer.cpp | 17 +-
46 llvm/tools/llvm-lto/CMakeLists.txt | 5 +-
47 llvm/tools/llvm-lto/llvm-lto.cpp | 28 +-
48 llvm/tools/llvm-lto2/CMakeLists.txt | 1 +
49 llvm/tools/llvm-lto2/llvm-lto2.cpp | 20 +-
50 .../llvm-mc-assemble-fuzzer/CMakeLists.txt | 1 +
51 .../llvm-mc-assemble-fuzzer.cpp | 12 +-
52 llvm/tools/llvm-mc/CMakeLists.txt | 1 +
53 llvm/tools/llvm-mc/llvm-mc.cpp | 6 +-
54 llvm/tools/llvm-mca/llvm-mca.cpp | 8 +-
55 .../tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp | 16 +-
56 llvm/tools/lto/CMakeLists.txt | 4 +-
57 llvm/tools/lto/lto.cpp | 35 +-
58 llvm/tools/opt/opt.cpp | 23 +-
59 .../DebugInfo/DWARF/DwarfGenerator.cpp | 6 +-
60 32 files changed, 1088 insertions(+), 233 deletions(-)
61 create mode 100644 llvm/include/llvm/CodeGen/CommandFlags.h
62 create mode 100644 llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
63 delete mode 100644 llvm/include/llvm/MC/MCTargetOptionsCommandFlags.inc
64 create mode 100644 llvm/lib/CodeGen/CommandFlags.cpp
65 create mode 100644 llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
66
67diff --git a/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp b/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
68index d8ab14594185..aefb761cd70c 100644
69--- a/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
70+++ b/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
71@@ -19,7 +19,7 @@
72 #include "llvm/ADT/Triple.h"
73 #include "llvm/Analysis/TargetLibraryInfo.h"
74 #include "llvm/Analysis/TargetTransformInfo.h"
75-#include "llvm/CodeGen/CommandFlags.inc"
76+#include "llvm/CodeGen/CommandFlags.h"
77 #include "llvm/CodeGen/MachineModuleInfo.h"
78 #include "llvm/CodeGen/TargetPassConfig.h"
79 #include "llvm/ExecutionEngine/JITEventListener.h"
80@@ -29,9 +29,9 @@
81 #include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
82 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
83 #include "llvm/IR/IRPrintingPasses.h"
84+#include "llvm/IR/LLVMContext.h"
85 #include "llvm/IR/LegacyPassManager.h"
86 #include "llvm/IR/LegacyPassNameParser.h"
87-#include "llvm/IR/LLVMContext.h"
88 #include "llvm/IR/Module.h"
89 #include "llvm/IR/Verifier.h"
90 #include "llvm/IRReader/IRReader.h"
91@@ -42,12 +42,14 @@
92 #include "llvm/Support/TargetRegistry.h"
93 #include "llvm/Support/TargetSelect.h"
94 #include "llvm/Target/TargetMachine.h"
95-#include "llvm/Transforms/IPO/PassManagerBuilder.h"
96 #include "llvm/Transforms/IPO.h"
97+#include "llvm/Transforms/IPO/PassManagerBuilder.h"
98 #include "llvm/Transforms/Vectorize.h"
99
100 using namespace llvm;
101
102+static codegen::RegisterCodeGenFlags CGF;
103+
104 // Define a type for the functions that are compiled and executed
105 typedef void (*LLVMFunc)(int*, int*, int*, int);
106
107@@ -100,15 +102,17 @@ static std::string OptLLVM(const std::string &IR, CodeGenOpt::Level OLvl) {
108 ErrorAndExit("Could not parse IR");
109
110 Triple ModuleTriple(M->getTargetTriple());
111- const TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
112+ const TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
113 std::string E;
114- const Target *TheTarget = TargetRegistry::lookupTarget(MArch, ModuleTriple, E);
115- TargetMachine *Machine =
116- TheTarget->createTargetMachine(M->getTargetTriple(), getCPUStr(),
117- getFeaturesStr(), Options, getRelocModel(),
118- getCodeModel(), OLvl);
119+ const Target *TheTarget =
120+ TargetRegistry::lookupTarget(codegen::getMArch(), ModuleTriple, E);
121+ TargetMachine *Machine = TheTarget->createTargetMachine(
122+ M->getTargetTriple(), codegen::getCPUStr(), codegen::getFeaturesStr(),
123+ Options, codegen::getExplicitRelocModel(),
124+ codegen::getExplicitCodeModel(), OLvl);
125 std::unique_ptr<TargetMachine> TM(Machine);
126- setFunctionAttributes(getCPUStr(), getFeaturesStr(), *M);
127+ codegen::setFunctionAttributes(codegen::getCPUStr(),
128+ codegen::getFeaturesStr(), *M);
129
130 legacy::PassManager Passes;
131
132@@ -154,14 +158,14 @@ static void CreateAndRunJITFunc(const std::string &IR, CodeGenOpt::Level OLvl) {
133
134 std::string ErrorMsg;
135 EngineBuilder builder(std::move(M));
136- builder.setMArch(MArch);
137- builder.setMCPU(getCPUStr());
138- builder.setMAttrs(getFeatureList());
139+ builder.setMArch(codegen::getMArch());
140+ builder.setMCPU(codegen::getCPUStr());
141+ builder.setMAttrs(codegen::getFeatureList());
142 builder.setErrorStr(&ErrorMsg);
143 builder.setEngineKind(EngineKind::JIT);
144 builder.setMCJITMemoryManager(std::make_unique<SectionMemoryManager>());
145 builder.setOptLevel(OLvl);
146- builder.setTargetOptions(InitTargetOptionsFromCodeGenFlags());
147+ builder.setTargetOptions(codegen::InitTargetOptionsFromCodeGenFlags());
148
149 std::unique_ptr<ExecutionEngine> EE(builder.create());
150 if (!EE)
151diff --git a/lld/Common/TargetOptionsCommandFlags.cpp b/lld/Common/TargetOptionsCommandFlags.cpp
152index 0137feb63f37..9b166a3e130a 100644
153--- a/lld/Common/TargetOptionsCommandFlags.cpp
154+++ b/lld/Common/TargetOptionsCommandFlags.cpp
155@@ -5,35 +5,26 @@
156 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
157 //
158 //===----------------------------------------------------------------------===//
159-//
160-// This file exists as a place for global variables defined in LLVM's
161-// CodeGen/CommandFlags.inc. By putting the resulting object file in
162-// an archive and linking with it, the definitions will automatically be
163-// included when needed and skipped when already present.
164-//
165-//===----------------------------------------------------------------------===//
166
167 #include "lld/Common/TargetOptionsCommandFlags.h"
168
169-#include "llvm/CodeGen/CommandFlags.inc"
170+#include "llvm/CodeGen/CommandFlags.h"
171 #include "llvm/Target/TargetOptions.h"
172
173-// Define an externally visible version of
174-// initTargetOptionsFromCodeGenFlags, so that its functionality can be
175-// used without having to include llvm/CodeGen/CommandFlags.inc, which
176-// would lead to multiple definitions of the command line flags.
177+static llvm::codegen::RegisterCodeGenFlags CGF;
178+
179 llvm::TargetOptions lld::initTargetOptionsFromCodeGenFlags() {
180- return ::InitTargetOptionsFromCodeGenFlags();
181+ return llvm::codegen::InitTargetOptionsFromCodeGenFlags();
182 }
183
184 llvm::Optional<llvm::Reloc::Model> lld::getRelocModelFromCMModel() {
185- return getRelocModel();
186+ return llvm::codegen::getExplicitRelocModel();
187 }
188
189 llvm::Optional<llvm::CodeModel::Model> lld::getCodeModelFromCMModel() {
190- return getCodeModel();
191+ return llvm::codegen::getExplicitCodeModel();
192 }
193
194-std::string lld::getCPUStr() { return ::getCPUStr(); }
195+std::string lld::getCPUStr() { return llvm::codegen::getCPUStr(); }
196
197-std::vector<std::string> lld::getMAttrs() { return ::MAttrs; }
198+std::vector<std::string> lld::getMAttrs() { return llvm::codegen::getMAttrs(); }
199diff --git a/llvm/include/llvm/CodeGen/CommandFlags.h b/llvm/include/llvm/CodeGen/CommandFlags.h
200new file mode 100644
201index 000000000000..cdec26879f73
202--- /dev/null
203+++ b/llvm/include/llvm/CodeGen/CommandFlags.h
204@@ -0,0 +1,149 @@
205+//===-- CommandFlags.h - Command Line Flags Interface -----------*- C++ -*-===//
206+//
207+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
208+// See https://llvm.org/LICENSE.txt for license information.
209+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
210+//
211+//===----------------------------------------------------------------------===//
212+//
213+// This file contains codegen-specific flags that are shared between different
214+// command line tools. The tools "llc" and "opt" both use this file to prevent
215+// flag duplication.
216+//
217+//===----------------------------------------------------------------------===//
218+
219+#include "llvm/ADT/StringExtras.h"
220+#include "llvm/IR/Instructions.h"
221+#include "llvm/IR/Intrinsics.h"
222+#include "llvm/IR/Module.h"
223+#include "llvm/MC/MCTargetOptionsCommandFlags.h"
224+#include "llvm/MC/SubtargetFeature.h"
225+#include "llvm/Support/CodeGen.h"
226+#include "llvm/Support/CommandLine.h"
227+#include "llvm/Support/Host.h"
228+#include "llvm/Target/TargetMachine.h"
229+#include "llvm/Target/TargetOptions.h"
230+#include <string>
231+
232+namespace llvm {
233+
234+namespace codegen {
235+
236+std::string getMArch();
237+
238+std::string getMCPU();
239+
240+std::vector<std::string> getMAttrs();
241+
242+Reloc::Model getRelocModel();
243+Optional<Reloc::Model> getExplicitRelocModel();
244+
245+ThreadModel::Model getThreadModel();
246+
247+CodeModel::Model getCodeModel();
248+Optional<CodeModel::Model> getExplicitCodeModel();
249+
250+llvm::ExceptionHandling getExceptionModel();
251+
252+CodeGenFileType getFileType();
253+Optional<CodeGenFileType> getExplicitFileType();
254+
255+CodeGenFileType getFileType();
256+
257+llvm::FramePointer::FP getFramePointerUsage();
258+
259+bool getEnableUnsafeFPMath();
260+
261+bool getEnableNoInfsFPMath();
262+
263+bool getEnableNoNaNsFPMath();
264+
265+bool getEnableNoSignedZerosFPMath();
266+
267+bool getEnableNoTrappingFPMath();
268+
269+llvm::FPDenormal::DenormalMode getDenormalFPMath();
270+
271+bool getEnableHonorSignDependentRoundingFPMath();
272+
273+llvm::FloatABI::ABIType getFloatABIForCalls();
274+
275+llvm::FPOpFusion::FPOpFusionMode getFuseFPOps();
276+
277+bool getDontPlaceZerosInBSS();
278+
279+bool getEnableGuaranteedTailCallOpt();
280+
281+bool getDisableTailCalls();
282+
283+bool getStackSymbolOrdering();
284+
285+unsigned getOverrideStackAlignment();
286+
287+bool getStackRealign();
288+
289+std::string getTrapFuncName();
290+
291+bool getUseCtors();
292+
293+bool getRelaxELFRelocations();
294+
295+bool getDataSections();
296+Optional<bool> getExplicitDataSections();
297+
298+bool getFunctionSections();
299+Optional<bool> getExplicitFunctionSections();
300+
301+std::string getBBSections();
302+
303+unsigned getTLSSize();
304+
305+bool getEmulatedTLS();
306+
307+bool getUniqueSectionNames();
308+
309+bool getUniqueBBSectionNames();
310+
311+llvm::EABI getEABIVersion();
312+
313+llvm::DebuggerKind getDebuggerTuningOpt();
314+
315+bool getEnableStackSizeSection();
316+
317+bool getEnableAddrsig();
318+
319+bool getEmitCallSiteInfo();
320+
321+bool getEnableDebugEntryValues();
322+
323+bool getForceDwarfFrameSection();
324+
325+/// Create this object with static storage to register codegen-related command
326+/// line options.
327+struct RegisterCodeGenFlags {
328+ RegisterCodeGenFlags();
329+};
330+
331+llvm::BasicBlockSection getBBSectionsMode(llvm::TargetOptions &Options);
332+
333+// Common utility function tightly tied to the options listed here. Initializes
334+// a TargetOptions object with CodeGen flags and returns it.
335+TargetOptions InitTargetOptionsFromCodeGenFlags();
336+
337+std::string getCPUStr();
338+
339+std::string getFeaturesStr();
340+
341+std::vector<std::string> getFeatureList();
342+
343+void renderBoolStringAttr(AttrBuilder &B, StringRef Name, bool Val);
344+
345+/// Set function attributes of function \p F based on CPU, Features, and command
346+/// line flags.
347+void setFunctionAttributes(StringRef CPU, StringRef Features, Function &F);
348+
349+/// Set function attributes of functions in Module M based on CPU,
350+/// Features, and command line flags.
351+void setFunctionAttributes(StringRef CPU, StringRef Features, Module &M);
352+} // namespace codegen
353+} // namespace llvm
354diff --git a/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h b/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
355new file mode 100644
356index 000000000000..7a5edf78fdcc
357--- /dev/null
358+++ b/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
359@@ -0,0 +1,54 @@
360+//===-- MCTargetOptionsCommandFlags.h --------------------------*- C++ -*-===//
361+//
362+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
363+// See https://llvm.org/LICENSE.txt for license information.
364+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
365+//
366+//===----------------------------------------------------------------------===//
367+//
368+// This file contains machine code-specific flags that are shared between
369+// different command line tools.
370+//
371+//===----------------------------------------------------------------------===//
372+
373+#ifndef LLVM_MC_MCTARGETOPTIONSCOMMANDFLAGS_H
374+#define LLVM_MC_MCTARGETOPTIONSCOMMANDFLAGS_H
375+
376+#include "llvm/ADT/Optional.h"
377+#include "llvm/MC/MCTargetOptions.h"
378+#include "llvm/Support/CommandLine.h"
379+
380+namespace llvm {
381+
382+namespace mc {
383+
384+bool getRelaxAll();
385+Optional<bool> getExplicitRelaxAll();
386+
387+bool getIncrementalLinkerCompatible();
388+
389+int getDwarfVersion();
390+
391+bool getShowMCInst();
392+
393+bool getFatalWarnings();
394+
395+bool getNoWarn();
396+
397+bool getNoDeprecatedWarn();
398+
399+std::string getABIName();
400+
401+/// Create this object with static storage to register mc-related command
402+/// line options.
403+struct RegisterMCTargetOptionsFlags {
404+ RegisterMCTargetOptionsFlags();
405+};
406+
407+MCTargetOptions InitMCTargetOptionsFromFlags();
408+
409+} // namespace mc
410+
411+} // namespace llvm
412+
413+#endif
414diff --git a/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.inc b/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.inc
415deleted file mode 100644
416index 93e21b626eac..000000000000
417--- a/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.inc
418+++ /dev/null
419@@ -1,65 +0,0 @@
420-//===-- MCTargetOptionsCommandFlags.h --------------------------*- C++ -*-===//
421-//
422-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
423-// See https://llvm.org/LICENSE.txt for license information.
424-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
425-//
426-//===----------------------------------------------------------------------===//
427-//
428-// This file contains machine code-specific flags that are shared between
429-// different command line tools.
430-//
431-//===----------------------------------------------------------------------===//
432-
433-#ifndef LLVM_MC_MCTARGETOPTIONSCOMMANDFLAGS_H
434-#define LLVM_MC_MCTARGETOPTIONSCOMMANDFLAGS_H
435-
436-#include "llvm/MC/MCTargetOptions.h"
437-#include "llvm/Support/CommandLine.h"
438-using namespace llvm;
439-
440-static cl::opt<bool> RelaxAll("mc-relax-all",
441- cl::desc("When used with filetype=obj, "
442- "relax all fixups in the emitted object file"));
443-
444-static cl::opt<bool> IncrementalLinkerCompatible(
445- "incremental-linker-compatible",
446- cl::desc(
447- "When used with filetype=obj, "
448- "emit an object file which can be used with an incremental linker"));
449-
450-static cl::opt<int> DwarfVersion("dwarf-version", cl::desc("Dwarf version"),
451- cl::init(0));
452-
453-static cl::opt<bool> ShowMCInst("asm-show-inst",
454- cl::desc("Emit internal instruction representation to "
455- "assembly file"));
456-
457-static cl::opt<bool> FatalWarnings("fatal-warnings",
458- cl::desc("Treat warnings as errors"));
459-
460-static cl::opt<bool> NoWarn("no-warn", cl::desc("Suppress all warnings"));
461-static cl::alias NoWarnW("W", cl::desc("Alias for --no-warn"), cl::aliasopt(NoWarn));
462-
463-static cl::opt<bool> NoDeprecatedWarn("no-deprecated-warn",
464- cl::desc("Suppress all deprecated warnings"));
465-
466-static cl::opt<std::string>
467-ABIName("target-abi", cl::Hidden,
468- cl::desc("The name of the ABI to be targeted from the backend."),
469- cl::init(""));
470-
471-static MCTargetOptions InitMCTargetOptionsFromFlags() {
472- MCTargetOptions Options;
473- Options.MCRelaxAll = RelaxAll;
474- Options.MCIncrementalLinkerCompatible = IncrementalLinkerCompatible;
475- Options.DwarfVersion = DwarfVersion;
476- Options.ShowMCInst = ShowMCInst;
477- Options.ABIName = ABIName;
478- Options.MCFatalWarnings = FatalWarnings;
479- Options.MCNoWarn = NoWarn;
480- Options.MCNoDeprecatedWarn = NoDeprecatedWarn;
481- return Options;
482-}
483-
484-#endif
485diff --git a/llvm/include/llvm/module.modulemap b/llvm/include/llvm/module.modulemap
486index d281682ae003..d176b3dfd4be 100644
487--- a/llvm/include/llvm/module.modulemap
488+++ b/llvm/include/llvm/module.modulemap
489@@ -29,7 +29,6 @@ module LLVM_Backend {
490 exclude header "CodeGen/LinkAllCodegenComponents.h"
491
492 // These are intended for (repeated) textual inclusion.
493- textual header "CodeGen/CommandFlags.inc"
494 textual header "CodeGen/DIEValue.def"
495 }
496 }
497@@ -308,8 +307,6 @@ module LLVM_MC {
498
499 umbrella "MC"
500 module * { export * }
501-
502- textual header "MC/MCTargetOptionsCommandFlags.inc"
503 }
504
505 // Used by llvm-tblgen
506diff --git a/llvm/lib/CodeGen/CMakeLists.txt b/llvm/lib/CodeGen/CMakeLists.txt
507index a3916b7c6242..c6be91247017 100644
508--- a/llvm/lib/CodeGen/CMakeLists.txt
509+++ b/llvm/lib/CodeGen/CMakeLists.txt
510@@ -14,6 +14,7 @@ add_llvm_component_library(LLVMCodeGen
511 CFIInstrInserter.cpp
512 CodeGen.cpp
513 CodeGenPrepare.cpp
514+ CommandFlags.cpp
515 CriticalAntiDepBreaker.cpp
516 DeadMachineInstructionElim.cpp
517 DetectDeadLanes.cpp
518diff --git a/llvm/lib/CodeGen/CommandFlags.cpp b/llvm/lib/CodeGen/CommandFlags.cpp
519new file mode 100644
520index 000000000000..7acb84df582f
521--- /dev/null
522+++ b/llvm/lib/CodeGen/CommandFlags.cpp
523@@ -0,0 +1,588 @@
524+//===-- CommandFlags.cpp - Command Line Flags Interface ---------*- C++ -*-===//
525+//
526+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
527+// See https://llvm.org/LICENSE.txt for license information.
528+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
529+//
530+//===----------------------------------------------------------------------===//
531+//
532+// This file contains codegen-specific flags that are shared between different
533+// command line tools. The tools "llc" and "opt" both use this file to prevent
534+// flag duplication.
535+//
536+//===----------------------------------------------------------------------===//
537+
538+#include "llvm/CodeGen/CommandFlags.h"
539+
540+using namespace llvm;
541+
542+#define CGOPT(TY, NAME) \
543+ static cl::opt<TY> *NAME##View; \
544+ TY codegen::get##NAME() { \
545+ assert(NAME##View && "RegisterCodeGenFlags not created."); \
546+ return *NAME##View; \
547+ }
548+
549+#define CGLIST(TY, NAME) \
550+ static cl::list<TY> *NAME##View; \
551+ std::vector<TY> codegen::get##NAME() { \
552+ assert(NAME##View && "RegisterCodeGenFlags not created."); \
553+ return *NAME##View; \
554+ }
555+
556+#define CGOPT_EXP(TY, NAME) \
557+ CGOPT(TY, NAME) \
558+ Optional<TY> codegen::getExplicit##NAME() { \
559+ if (NAME##View->getNumOccurrences()) { \
560+ TY res = *NAME##View; \
561+ return res; \
562+ } \
563+ return None; \
564+ }
565+
566+CGOPT(std::string, MArch)
567+CGOPT(std::string, MCPU)
568+CGLIST(std::string, MAttrs)
569+CGOPT_EXP(Reloc::Model, RelocModel)
570+CGOPT(ThreadModel::Model, ThreadModel)
571+CGOPT_EXP(CodeModel::Model, CodeModel)
572+CGOPT(ExceptionHandling, ExceptionModel)
573+CGOPT_EXP(CodeGenFileType, FileType)
574+CGOPT(FramePointer::FP, FramePointerUsage)
575+CGOPT(bool, EnableUnsafeFPMath)
576+CGOPT(bool, EnableNoInfsFPMath)
577+CGOPT(bool, EnableNoNaNsFPMath)
578+CGOPT(bool, EnableNoSignedZerosFPMath)
579+CGOPT(bool, EnableNoTrappingFPMath)
580+CGOPT(FPDenormal::DenormalMode, DenormalFPMath)
581+CGOPT(bool, EnableHonorSignDependentRoundingFPMath)
582+CGOPT(FloatABI::ABIType, FloatABIForCalls)
583+CGOPT(FPOpFusion::FPOpFusionMode, FuseFPOps)
584+CGOPT(bool, DontPlaceZerosInBSS)
585+CGOPT(bool, EnableGuaranteedTailCallOpt)
586+CGOPT(bool, DisableTailCalls)
587+CGOPT(bool, StackSymbolOrdering)
588+CGOPT(unsigned, OverrideStackAlignment)
589+CGOPT(bool, StackRealign)
590+CGOPT(std::string, TrapFuncName)
591+CGOPT(bool, UseCtors)
592+CGOPT(bool, RelaxELFRelocations)
593+CGOPT_EXP(bool, DataSections)
594+CGOPT_EXP(bool, FunctionSections)
595+CGOPT(std::string, BBSections)
596+CGOPT(unsigned, TLSSize)
597+CGOPT(bool, EmulatedTLS)
598+CGOPT(bool, UniqueSectionNames)
599+CGOPT(bool, UniqueBBSectionNames)
600+CGOPT(EABI, EABIVersion)
601+CGOPT(DebuggerKind, DebuggerTuningOpt)
602+CGOPT(bool, EnableStackSizeSection)
603+CGOPT(bool, EnableAddrsig)
604+CGOPT(bool, EmitCallSiteInfo)
605+CGOPT(bool, EnableDebugEntryValues)
606+CGOPT(bool, ForceDwarfFrameSection)
607+
608+codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() {
609+#define CGBINDOPT(NAME) \
610+ do { \
611+ NAME##View = std::addressof(NAME); \
612+ } while (0)
613+
614+ static cl::opt<std::string> MArch(
615+ "march", cl::desc("Architecture to generate code for (see --version)"));
616+ CGBINDOPT(MArch);
617+
618+ static cl::opt<std::string> MCPU(
619+ "mcpu", cl::desc("Target a specific cpu type (-mcpu=help for details)"),
620+ cl::value_desc("cpu-name"), cl::init(""));
621+ CGBINDOPT(MCPU);
622+
623+ static cl::list<std::string> MAttrs(
624+ "mattr", cl::CommaSeparated,
625+ cl::desc("Target specific attributes (-mattr=help for details)"),
626+ cl::value_desc("a1,+a2,-a3,..."));
627+ CGBINDOPT(MAttrs);
628+
629+ static cl::opt<Reloc::Model> RelocModel(
630+ "relocation-model", cl::desc("Choose relocation model"),
631+ cl::values(
632+ clEnumValN(Reloc::Static, "static", "Non-relocatable code"),
633+ clEnumValN(Reloc::PIC_, "pic",
634+ "Fully relocatable, position independent code"),
635+ clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
636+ "Relocatable external references, non-relocatable code"),
637+ clEnumValN(
638+ Reloc::ROPI, "ropi",
639+ "Code and read-only data relocatable, accessed PC-relative"),
640+ clEnumValN(
641+ Reloc::RWPI, "rwpi",
642+ "Read-write data relocatable, accessed relative to static base"),
643+ clEnumValN(Reloc::ROPI_RWPI, "ropi-rwpi",
644+ "Combination of ropi and rwpi")));
645+ CGBINDOPT(RelocModel);
646+
647+ static cl::opt<ThreadModel::Model> ThreadModel(
648+ "thread-model", cl::desc("Choose threading model"),
649+ cl::init(ThreadModel::POSIX),
650+ cl::values(
651+ clEnumValN(ThreadModel::POSIX, "posix", "POSIX thread model"),
652+ clEnumValN(ThreadModel::Single, "single", "Single thread model")));
653+ CGBINDOPT(ThreadModel);
654+
655+ static cl::opt<CodeModel::Model> CodeModel(
656+ "code-model", cl::desc("Choose code model"),
657+ cl::values(clEnumValN(CodeModel::Tiny, "tiny", "Tiny code model"),
658+ clEnumValN(CodeModel::Small, "small", "Small code model"),
659+ clEnumValN(CodeModel::Kernel, "kernel", "Kernel code model"),
660+ clEnumValN(CodeModel::Medium, "medium", "Medium code model"),
661+ clEnumValN(CodeModel::Large, "large", "Large code model")));
662+ CGBINDOPT(CodeModel);
663+
664+ static cl::opt<ExceptionHandling> ExceptionModel(
665+ "exception-model", cl::desc("exception model"),
666+ cl::init(ExceptionHandling::None),
667+ cl::values(
668+ clEnumValN(ExceptionHandling::None, "default",
669+ "default exception handling model"),
670+ clEnumValN(ExceptionHandling::DwarfCFI, "dwarf",
671+ "DWARF-like CFI based exception handling"),
672+ clEnumValN(ExceptionHandling::SjLj, "sjlj",
673+ "SjLj exception handling"),
674+ clEnumValN(ExceptionHandling::ARM, "arm", "ARM EHABI exceptions"),
675+ clEnumValN(ExceptionHandling::WinEH, "wineh",
676+ "Windows exception model"),
677+ clEnumValN(ExceptionHandling::Wasm, "wasm",
678+ "WebAssembly exception handling")));
679+ CGBINDOPT(ExceptionModel);
680+
681+ static cl::opt<CodeGenFileType> FileType(
682+ "filetype", cl::init(CGFT_AssemblyFile),
683+ cl::desc(
684+ "Choose a file type (not all types are supported by all targets):"),
685+ cl::values(
686+ clEnumValN(CGFT_AssemblyFile, "asm", "Emit an assembly ('.s') file"),
687+ clEnumValN(CGFT_ObjectFile, "obj",
688+ "Emit a native object ('.o') file"),
689+ clEnumValN(CGFT_Null, "null",
690+ "Emit nothing, for performance testing")));
691+ CGBINDOPT(FileType);
692+
693+ static cl::opt<FramePointer::FP> FramePointerUsage(
694+ "frame-pointer",
695+ cl::desc("Specify frame pointer elimination optimization"),
696+ cl::init(FramePointer::None),
697+ cl::values(
698+ clEnumValN(FramePointer::All, "all",
699+ "Disable frame pointer elimination"),
700+ clEnumValN(FramePointer::NonLeaf, "non-leaf",
701+ "Disable frame pointer elimination for non-leaf frame"),
702+ clEnumValN(FramePointer::None, "none",
703+ "Enable frame pointer elimination")));
704+ CGBINDOPT(FramePointerUsage);
705+
706+ static cl::opt<bool> EnableUnsafeFPMath(
707+ "enable-unsafe-fp-math",
708+ cl::desc("Enable optimizations that may decrease FP precision"),
709+ cl::init(false));
710+ CGBINDOPT(EnableUnsafeFPMath);
711+
712+ static cl::opt<bool> EnableNoInfsFPMath(
713+ "enable-no-infs-fp-math",
714+ cl::desc("Enable FP math optimizations that assume no +-Infs"),
715+ cl::init(false));
716+ CGBINDOPT(EnableNoInfsFPMath);
717+
718+ static cl::opt<bool> EnableNoNaNsFPMath(
719+ "enable-no-nans-fp-math",
720+ cl::desc("Enable FP math optimizations that assume no NaNs"),
721+ cl::init(false));
722+ CGBINDOPT(EnableNoNaNsFPMath);
723+
724+ static cl::opt<bool> EnableNoSignedZerosFPMath(
725+ "enable-no-signed-zeros-fp-math",
726+ cl::desc("Enable FP math optimizations that assume "
727+ "the sign of 0 is insignificant"),
728+ cl::init(false));
729+ CGBINDOPT(EnableNoSignedZerosFPMath);
730+
731+ static cl::opt<bool> EnableNoTrappingFPMath(
732+ "enable-no-trapping-fp-math",
733+ cl::desc("Enable setting the FP exceptions build "
734+ "attribute not to use exceptions"),
735+ cl::init(false));
736+ CGBINDOPT(EnableNoTrappingFPMath);
737+
738+ static cl::opt<FPDenormal::DenormalMode> DenormalFPMath(
739+ "denormal-fp-math",
740+ cl::desc(
741+ "Select which denormal numbers the code is permitted to require"),
742+ cl::init(FPDenormal::IEEE),
743+ cl::values(
744+ clEnumValN(FPDenormal::IEEE, "ieee", "IEEE 754 denormal numbers"),
745+ clEnumValN(FPDenormal::PreserveSign, "preserve-sign",
746+ "the sign of a flushed-to-zero number is preserved "
747+ "in the sign of 0"),
748+ clEnumValN(FPDenormal::PositiveZero, "positive-zero",
749+ "denormals are flushed to positive zero")));
750+ CGBINDOPT(DenormalFPMath);
751+
752+ static cl::opt<bool> EnableHonorSignDependentRoundingFPMath(
753+ "enable-sign-dependent-rounding-fp-math", cl::Hidden,
754+ cl::desc("Force codegen to assume rounding mode can change dynamically"),
755+ cl::init(false));
756+ CGBINDOPT(EnableHonorSignDependentRoundingFPMath);
757+
758+ static cl::opt<FloatABI::ABIType> FloatABIForCalls(
759+ "float-abi", cl::desc("Choose float ABI type"),
760+ cl::init(FloatABI::Default),
761+ cl::values(clEnumValN(FloatABI::Default, "default",
762+ "Target default float ABI type"),
763+ clEnumValN(FloatABI::Soft, "soft",
764+ "Soft float ABI (implied by -soft-float)"),
765+ clEnumValN(FloatABI::Hard, "hard",
766+ "Hard float ABI (uses FP registers)")));
767+ CGBINDOPT(FloatABIForCalls);
768+
769+ static cl::opt<FPOpFusion::FPOpFusionMode> FuseFPOps(
770+ "fp-contract", cl::desc("Enable aggressive formation of fused FP ops"),
771+ cl::init(FPOpFusion::Standard),
772+ cl::values(
773+ clEnumValN(FPOpFusion::Fast, "fast",
774+ "Fuse FP ops whenever profitable"),
775+ clEnumValN(FPOpFusion::Standard, "on", "Only fuse 'blessed' FP ops."),
776+ clEnumValN(FPOpFusion::Strict, "off",
777+ "Only fuse FP ops when the result won't be affected.")));
778+ CGBINDOPT(FuseFPOps);
779+
780+ static cl::opt<bool> DontPlaceZerosInBSS(
781+ "nozero-initialized-in-bss",
782+ cl::desc("Don't place zero-initialized symbols into bss section"),
783+ cl::init(false));
784+ CGBINDOPT(DontPlaceZerosInBSS);
785+
786+ static cl::opt<bool> EnableGuaranteedTailCallOpt(
787+ "tailcallopt",
788+ cl::desc(
789+ "Turn fastcc calls into tail calls by (potentially) changing ABI."),
790+ cl::init(false));
791+ CGBINDOPT(EnableGuaranteedTailCallOpt);
792+
793+ static cl::opt<bool> DisableTailCalls(
794+ "disable-tail-calls", cl::desc("Never emit tail calls"), cl::init(false));
795+ CGBINDOPT(DisableTailCalls);
796+
797+ static cl::opt<bool> StackSymbolOrdering(
798+ "stack-symbol-ordering", cl::desc("Order local stack symbols."),
799+ cl::init(true));
800+ CGBINDOPT(StackSymbolOrdering);
801+
802+ static cl::opt<unsigned> OverrideStackAlignment(
803+ "stack-alignment", cl::desc("Override default stack alignment"),
804+ cl::init(0));
805+ CGBINDOPT(OverrideStackAlignment);
806+
807+ static cl::opt<bool> StackRealign(
808+ "stackrealign",
809+ cl::desc("Force align the stack to the minimum alignment"),
810+ cl::init(false));
811+ CGBINDOPT(StackRealign);
812+
813+ static cl::opt<std::string> TrapFuncName(
814+ "trap-func", cl::Hidden,
815+ cl::desc("Emit a call to trap function rather than a trap instruction"),
816+ cl::init(""));
817+ CGBINDOPT(TrapFuncName);
818+
819+ static cl::opt<bool> UseCtors("use-ctors",
820+ cl::desc("Use .ctors instead of .init_array."),
821+ cl::init(false));
822+ CGBINDOPT(UseCtors);
823+
824+ static cl::opt<bool> RelaxELFRelocations(
825+ "relax-elf-relocations",
826+ cl::desc(
827+ "Emit GOTPCRELX/REX_GOTPCRELX instead of GOTPCREL on x86-64 ELF"),
828+ cl::init(false));
829+ CGBINDOPT(RelaxELFRelocations);
830+
831+ static cl::opt<bool> DataSections(
832+ "data-sections", cl::desc("Emit data into separate sections"),
833+ cl::init(false));
834+ CGBINDOPT(DataSections);
835+
836+ static cl::opt<bool> FunctionSections(
837+ "function-sections", cl::desc("Emit functions into separate sections"),
838+ cl::init(false));
839+ CGBINDOPT(FunctionSections);
840+
841+ static cl::opt<std::string> BBSections(
842+ "basicblock-sections",
843+ cl::desc("Emit basic blocks into separate sections"),
844+ cl::value_desc("all | <function list (file)> | labels | none"),
845+ cl::init("none"));
846+ CGBINDOPT(BBSections);
847+
848+ static cl::opt<unsigned> TLSSize(
849+ "tls-size", cl::desc("Bit size of immediate TLS offsets"), cl::init(0));
850+ CGBINDOPT(TLSSize);
851+
852+ static cl::opt<bool> EmulatedTLS(
853+ "emulated-tls", cl::desc("Use emulated TLS model"), cl::init(false));
854+ CGBINDOPT(EmulatedTLS);
855+
856+ static cl::opt<bool> UniqueSectionNames(
857+ "unique-section-names", cl::desc("Give unique names to every section"),
858+ cl::init(true));
859+ CGBINDOPT(UniqueSectionNames);
860+
861+ static cl::opt<bool> UniqueBBSectionNames(
862+ "unique-bb-section-names",
863+ cl::desc("Give unique names to every basic block section"),
864+ cl::init(false));
865+ CGBINDOPT(UniqueBBSectionNames);
866+
867+ static cl::opt<EABI> EABIVersion(
868+ "meabi", cl::desc("Set EABI type (default depends on triple):"),
869+ cl::init(EABI::Default),
870+ cl::values(
871+ clEnumValN(EABI::Default, "default", "Triple default EABI version"),
872+ clEnumValN(EABI::EABI4, "4", "EABI version 4"),
873+ clEnumValN(EABI::EABI5, "5", "EABI version 5"),
874+ clEnumValN(EABI::GNU, "gnu", "EABI GNU")));
875+ CGBINDOPT(EABIVersion);
876+
877+ static cl::opt<DebuggerKind> DebuggerTuningOpt(
878+ "debugger-tune", cl::desc("Tune debug info for a particular debugger"),
879+ cl::init(DebuggerKind::Default),
880+ cl::values(
881+ clEnumValN(DebuggerKind::GDB, "gdb", "gdb"),
882+ clEnumValN(DebuggerKind::LLDB, "lldb", "lldb"),
883+ clEnumValN(DebuggerKind::SCE, "sce", "SCE targets (e.g. PS4)")));
884+ CGBINDOPT(DebuggerTuningOpt);
885+
886+ static cl::opt<bool> EnableStackSizeSection(
887+ "stack-size-section",
888+ cl::desc("Emit a section containing stack size metadata"),
889+ cl::init(false));
890+ CGBINDOPT(EnableStackSizeSection);
891+
892+ static cl::opt<bool> EnableAddrsig(
893+ "addrsig", cl::desc("Emit an address-significance table"),
894+ cl::init(false));
895+ CGBINDOPT(EnableAddrsig);
896+
897+ static cl::opt<bool> EmitCallSiteInfo(
898+ "emit-call-site-info",
899+ cl::desc(
900+ "Emit call site debug information, if debug information is enabled."),
901+ cl::init(false));
902+ CGBINDOPT(EmitCallSiteInfo);
903+
904+ static cl::opt<bool> EnableDebugEntryValues(
905+ "debug-entry-values",
906+ cl::desc("Emit debug info about parameter's entry values"),
907+ cl::init(false));
908+ CGBINDOPT(EnableDebugEntryValues);
909+
910+ static cl::opt<bool> ForceDwarfFrameSection(
911+ "force-dwarf-frame-section",
912+ cl::desc("Always emit a debug frame section."), cl::init(false));
913+ CGBINDOPT(ForceDwarfFrameSection);
914+
915+#undef CGBINDOPT
916+
917+ mc::RegisterMCTargetOptionsFlags();
918+}
919+
920+llvm::BasicBlockSection
921+codegen::getBBSectionsMode(llvm::TargetOptions &Options) {
922+ if (getBBSections() == "all")
923+ return BasicBlockSection::All;
924+ else if (getBBSections() == "labels")
925+ return BasicBlockSection::Labels;
926+ else if (getBBSections() == "none")
927+ return BasicBlockSection::None;
928+ else {
929+ ErrorOr<std::unique_ptr<MemoryBuffer>> MBOrErr =
930+ MemoryBuffer::getFile(getBBSections());
931+ if (!MBOrErr) {
932+ errs() << "Error loading basic block sections function list file: "
933+ << MBOrErr.getError().message() << "\n";
934+ } else {
935+ Options.BBSectionsFuncListBuf = std::move(*MBOrErr);
936+ }
937+ return BasicBlockSection::List;
938+ }
939+}
940+
941+// Common utility function tightly tied to the options listed here. Initializes
942+// a TargetOptions object with CodeGen flags and returns it.
943+TargetOptions codegen::InitTargetOptionsFromCodeGenFlags() {
944+ TargetOptions Options;
945+ Options.AllowFPOpFusion = getFuseFPOps();
946+ Options.UnsafeFPMath = getEnableUnsafeFPMath();
947+ Options.NoInfsFPMath = getEnableNoInfsFPMath();
948+ Options.NoNaNsFPMath = getEnableNoNaNsFPMath();
949+ Options.NoSignedZerosFPMath = getEnableNoSignedZerosFPMath();
950+ Options.NoTrappingFPMath = getEnableNoTrappingFPMath();
951+ Options.FPDenormalMode = getDenormalFPMath();
952+ Options.HonorSignDependentRoundingFPMathOption =
953+ getEnableHonorSignDependentRoundingFPMath();
954+ if (getFloatABIForCalls() != FloatABI::Default)
955+ Options.FloatABIType = getFloatABIForCalls();
956+ Options.NoZerosInBSS = getDontPlaceZerosInBSS();
957+ Options.GuaranteedTailCallOpt = getEnableGuaranteedTailCallOpt();
958+ Options.StackAlignmentOverride = getOverrideStackAlignment();
959+ Options.StackSymbolOrdering = getStackSymbolOrdering();
960+ Options.UseInitArray = !getUseCtors();
961+ Options.RelaxELFRelocations = getRelaxELFRelocations();
962+ Options.DataSections = getDataSections();
963+ Options.FunctionSections = getFunctionSections();
964+ Options.BBSections = getBBSectionsMode(Options);
965+ Options.UniqueSectionNames = getUniqueSectionNames();
966+ Options.UniqueBBSectionNames = getUniqueBBSectionNames();
967+ Options.TLSSize = getTLSSize();
968+ Options.EmulatedTLS = getEmulatedTLS();
969+ Options.ExplicitEmulatedTLS = EmulatedTLSView->getNumOccurrences() > 0;
970+ Options.ExceptionModel = getExceptionModel();
971+ Options.EmitStackSizeSection = getEnableStackSizeSection();
972+ Options.EmitAddrsig = getEnableAddrsig();
973+ Options.EmitCallSiteInfo = getEmitCallSiteInfo();
974+ Options.EnableDebugEntryValues = getEnableDebugEntryValues();
975+ Options.ForceDwarfFrameSection = getForceDwarfFrameSection();
976+
977+ Options.MCOptions = mc::InitMCTargetOptionsFromFlags();
978+
979+ Options.ThreadModel = getThreadModel();
980+ Options.EABIVersion = getEABIVersion();
981+ Options.DebuggerTuning = getDebuggerTuningOpt();
982+
983+ return Options;
984+}
985+
986+std::string codegen::getCPUStr() {
987+ // If user asked for the 'native' CPU, autodetect here. If autodection fails,
988+ // this will set the CPU to an empty string which tells the target to
989+ // pick a basic default.
990+ if (getMCPU() == "native")
991+ return std::string(sys::getHostCPUName());
992+
993+ return getMCPU();
994+}
995+
996+std::string codegen::getFeaturesStr() {
997+ SubtargetFeatures Features;
998+
999+ // If user asked for the 'native' CPU, we need to autodetect features.
1000+ // This is necessary for x86 where the CPU might not support all the
1001+ // features the autodetected CPU name lists in the target. For example,
1002+ // not all Sandybridge processors support AVX.
1003+ if (getMCPU() == "native") {
1004+ StringMap<bool> HostFeatures;
1005+ if (sys::getHostCPUFeatures(HostFeatures))
1006+ for (auto &F : HostFeatures)
1007+ Features.AddFeature(F.first(), F.second);
1008+ }
1009+
1010+ for (auto const &MAttr : getMAttrs())
1011+ Features.AddFeature(MAttr);
1012+
1013+ return Features.getString();
1014+}
1015+
1016+std::vector<std::string> codegen::getFeatureList() {
1017+ SubtargetFeatures Features;
1018+
1019+ // If user asked for the 'native' CPU, we need to autodetect features.
1020+ // This is necessary for x86 where the CPU might not support all the
1021+ // features the autodetected CPU name lists in the target. For example,
1022+ // not all Sandybridge processors support AVX.
1023+ if (getMCPU() == "native") {
1024+ StringMap<bool> HostFeatures;
1025+ if (sys::getHostCPUFeatures(HostFeatures))
1026+ for (auto &F : HostFeatures)
1027+ Features.AddFeature(F.first(), F.second);
1028+ }
1029+
1030+ for (auto const &MAttr : getMAttrs())
1031+ Features.AddFeature(MAttr);
1032+
1033+ return Features.getFeatures();
1034+}
1035+
1036+void codegen::renderBoolStringAttr(AttrBuilder &B, StringRef Name, bool Val) {
1037+ B.addAttribute(Name, Val ? "true" : "false");
1038+}
1039+
1040+#define HANDLE_BOOL_ATTR(CL, AttrName) \
1041+ do { \
1042+ if (CL->getNumOccurrences() > 0 && !F.hasFnAttribute(AttrName)) \
1043+ renderBoolStringAttr(NewAttrs, AttrName, *CL); \
1044+ } while (0)
1045+
1046+/// Set function attributes of function \p F based on CPU, Features, and command
1047+/// line flags.
1048+void codegen::setFunctionAttributes(StringRef CPU, StringRef Features,
1049+ Function &F) {
1050+ auto &Ctx = F.getContext();
1051+ AttributeList Attrs = F.getAttributes();
1052+ AttrBuilder NewAttrs;
1053+
1054+ if (!CPU.empty() && !F.hasFnAttribute("target-cpu"))
1055+ NewAttrs.addAttribute("target-cpu", CPU);
1056+ if (!Features.empty()) {
1057+ // Append the command line features to any that are already on the function.
1058+ StringRef OldFeatures =
1059+ F.getFnAttribute("target-features").getValueAsString();
1060+ if (OldFeatures.empty())
1061+ NewAttrs.addAttribute("target-features", Features);
1062+ else {
1063+ SmallString<256> Appended(OldFeatures);
1064+ Appended.push_back(',');
1065+ Appended.append(Features);
1066+ NewAttrs.addAttribute("target-features", Appended);
1067+ }
1068+ }
1069+ if (FramePointerUsageView->getNumOccurrences() > 0 &&
1070+ !F.hasFnAttribute("frame-pointer")) {
1071+ if (getFramePointerUsage() == FramePointer::All)
1072+ NewAttrs.addAttribute("frame-pointer", "all");
1073+ else if (getFramePointerUsage() == FramePointer::NonLeaf)
1074+ NewAttrs.addAttribute("frame-pointer", "non-leaf");
1075+ else if (getFramePointerUsage() == FramePointer::None)
1076+ NewAttrs.addAttribute("frame-pointer", "none");
1077+ }
1078+ if (DisableTailCallsView->getNumOccurrences() > 0)
1079+ NewAttrs.addAttribute("disable-tail-calls",
1080+ toStringRef(getDisableTailCalls()));
1081+ if (getStackRealign())
1082+ NewAttrs.addAttribute("stackrealign");
1083+
1084+ HANDLE_BOOL_ATTR(EnableUnsafeFPMathView, "unsafe-fp-math");
1085+ HANDLE_BOOL_ATTR(EnableNoInfsFPMathView, "no-infs-fp-math");
1086+ HANDLE_BOOL_ATTR(EnableNoNaNsFPMathView, "no-nans-fp-math");
1087+ HANDLE_BOOL_ATTR(EnableNoSignedZerosFPMathView, "no-signed-zeros-fp-math");
1088+
1089+ if (TrapFuncNameView->getNumOccurrences() > 0)
1090+ for (auto &B : F)
1091+ for (auto &I : B)
1092+ if (auto *Call = dyn_cast<CallInst>(&I))
1093+ if (const auto *F = Call->getCalledFunction())
1094+ if (F->getIntrinsicID() == Intrinsic::debugtrap ||
1095+ F->getIntrinsicID() == Intrinsic::trap)
1096+ Call->addAttribute(
1097+ AttributeList::FunctionIndex,
1098+ Attribute::get(Ctx, "trap-func-name", getTrapFuncName()));
1099+
1100+ // Let NewAttrs override Attrs.
1101+ F.setAttributes(
1102+ Attrs.addAttributes(Ctx, AttributeList::FunctionIndex, NewAttrs));
1103+}
1104+
1105+/// Set function attributes of functions in Module M based on CPU,
1106+/// Features, and command line flags.
1107+void codegen::setFunctionAttributes(StringRef CPU, StringRef Features,
1108+ Module &M) {
1109+ for (Function &F : M)
1110+ setFunctionAttributes(CPU, Features, F);
1111+}
1112diff --git a/llvm/lib/MC/CMakeLists.txt b/llvm/lib/MC/CMakeLists.txt
1113index de2e47d8d9b2..ab809daf5273 100644
1114--- a/llvm/lib/MC/CMakeLists.txt
1115+++ b/llvm/lib/MC/CMakeLists.txt
1116@@ -44,6 +44,7 @@ add_llvm_component_library(LLVMMC
1117 MCSymbol.cpp
1118 MCSymbolELF.cpp
1119 MCTargetOptions.cpp
1120+ MCTargetOptionsCommandFlags.cpp
1121 MCValue.cpp
1122 MCWasmObjectTargetWriter.cpp
1123 MCWasmStreamer.cpp
1124diff --git a/llvm/lib/MC/MCTargetOptionsCommandFlags.cpp b/llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
1125new file mode 100644
1126index 000000000000..3ca34061241a
1127--- /dev/null
1128+++ b/llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
1129@@ -0,0 +1,105 @@
1130+//===-- MCTargetOptionsCommandFlags.cpp --------------------------*- C++
1131+//-*-===//
1132+//
1133+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
1134+// See https://llvm.org/LICENSE.txt for license information.
1135+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
1136+//
1137+//===----------------------------------------------------------------------===//
1138+//
1139+// This file contains machine code-specific flags that are shared between
1140+// different command line tools.
1141+//
1142+//===----------------------------------------------------------------------===//
1143+
1144+#include "llvm/MC/MCTargetOptionsCommandFlags.h"
1145+
1146+using namespace llvm;
1147+
1148+#define MCOPT(TY, NAME) \
1149+ static cl::opt<TY> *NAME##View; \
1150+ TY llvm::mc::get##NAME() { \
1151+ assert(NAME##View && "RegisterMCTargetOptionsFlags not created."); \
1152+ return *NAME##View; \
1153+ }
1154+
1155+#define MCOPT_EXP(TY, NAME) \
1156+ MCOPT(TY, NAME) \
1157+ Optional<TY> llvm::mc::getExplicit##NAME() { \
1158+ if (NAME##View->getNumOccurrences()) { \
1159+ TY res = *NAME##View; \
1160+ return res; \
1161+ } \
1162+ return None; \
1163+ }
1164+
1165+MCOPT_EXP(bool, RelaxAll)
1166+MCOPT(bool, IncrementalLinkerCompatible)
1167+MCOPT(int, DwarfVersion)
1168+MCOPT(bool, ShowMCInst)
1169+MCOPT(bool, FatalWarnings)
1170+MCOPT(bool, NoWarn)
1171+MCOPT(bool, NoDeprecatedWarn)
1172+MCOPT(std::string, ABIName)
1173+
1174+llvm::mc::RegisterMCTargetOptionsFlags::RegisterMCTargetOptionsFlags() {
1175+#define MCBINDOPT(NAME) \
1176+ do { \
1177+ NAME##View = std::addressof(NAME); \
1178+ } while (0)
1179+
1180+ static cl::opt<bool> RelaxAll(
1181+ "mc-relax-all", cl::desc("When used with filetype=obj, relax all fixups "
1182+ "in the emitted object file"));
1183+ MCBINDOPT(RelaxAll);
1184+
1185+ static cl::opt<bool> IncrementalLinkerCompatible(
1186+ "incremental-linker-compatible",
1187+ cl::desc(
1188+ "When used with filetype=obj, "
1189+ "emit an object file which can be used with an incremental linker"));
1190+ MCBINDOPT(IncrementalLinkerCompatible);
1191+
1192+ static cl::opt<int> DwarfVersion("dwarf-version", cl::desc("Dwarf version"),
1193+ cl::init(0));
1194+ MCBINDOPT(DwarfVersion);
1195+
1196+ static cl::opt<bool> ShowMCInst(
1197+ "asm-show-inst",
1198+ cl::desc("Emit internal instruction representation to assembly file"));
1199+ MCBINDOPT(ShowMCInst);
1200+
1201+ static cl::opt<bool> FatalWarnings("fatal-warnings",
1202+ cl::desc("Treat warnings as errors"));
1203+ MCBINDOPT(FatalWarnings);
1204+
1205+ static cl::opt<bool> NoWarn("no-warn", cl::desc("Suppress all warnings"));
1206+ static cl::alias NoWarnW("W", cl::desc("Alias for --no-warn"),
1207+ cl::aliasopt(NoWarn));
1208+ MCBINDOPT(NoWarn);
1209+
1210+ static cl::opt<bool> NoDeprecatedWarn(
1211+ "no-deprecated-warn", cl::desc("Suppress all deprecated warnings"));
1212+ MCBINDOPT(NoDeprecatedWarn);
1213+
1214+ static cl::opt<std::string> ABIName(
1215+ "target-abi", cl::Hidden,
1216+ cl::desc("The name of the ABI to be targeted from the backend."),
1217+ cl::init(""));
1218+ MCBINDOPT(ABIName);
1219+
1220+#undef MCBINDOPT
1221+}
1222+
1223+MCTargetOptions llvm::mc::InitMCTargetOptionsFromFlags() {
1224+ MCTargetOptions Options;
1225+ Options.MCRelaxAll = getRelaxAll();
1226+ Options.MCIncrementalLinkerCompatible = getIncrementalLinkerCompatible();
1227+ Options.DwarfVersion = getDwarfVersion();
1228+ Options.ShowMCInst = getShowMCInst();
1229+ Options.ABIName = getABIName();
1230+ Options.MCFatalWarnings = getFatalWarnings();
1231+ Options.MCNoWarn = getNoWarn();
1232+ Options.MCNoDeprecatedWarn = getNoDeprecatedWarn();
1233+ return Options;
1234+}
1235diff --git a/llvm/tools/dsymutil/DwarfStreamer.cpp b/llvm/tools/dsymutil/DwarfStreamer.cpp
1236index 3e132c29eada..eb068effbc71 100644
1237--- a/llvm/tools/dsymutil/DwarfStreamer.cpp
1238+++ b/llvm/tools/dsymutil/DwarfStreamer.cpp
1239@@ -13,13 +13,16 @@
1240 #include "llvm/DWARFLinker/DWARFLinkerCompileUnit.h"
1241 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
1242 #include "llvm/MC/MCTargetOptions.h"
1243-#include "llvm/MC/MCTargetOptionsCommandFlags.inc"
1244+#include "llvm/MC/MCTargetOptionsCommandFlags.h"
1245 #include "llvm/Support/LEB128.h"
1246 #include "llvm/Support/TargetRegistry.h"
1247 #include "llvm/Target/TargetMachine.h"
1248 #include "llvm/Target/TargetOptions.h"
1249
1250 namespace llvm {
1251+
1252+static mc::RegisterMCTargetOptionsFlags MOF;
1253+
1254 namespace dsymutil {
1255
1256 /// Retrieve the section named \a SecName in \a Obj.
1257@@ -61,7 +64,7 @@ bool DwarfStreamer::init(Triple TheTriple) {
1258 if (!MRI)
1259 return error(Twine("no register info for target ") + TripleName, Context);
1260
1261- MCTargetOptions MCOptions = InitMCTargetOptionsFromFlags();
1262+ MCTargetOptions MCOptions = mc::InitMCTargetOptionsFromFlags();
1263 MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
1264 if (!MAI)
1265 return error("no asm info for target " + TripleName, Context);
1266diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp
1267index 406079dad307..95e72b861197 100644
1268--- a/llvm/tools/gold/gold-plugin.cpp
1269+++ b/llvm/tools/gold/gold-plugin.cpp
1270@@ -14,7 +14,7 @@
1271 #include "llvm/ADT/Statistic.h"
1272 #include "llvm/Bitcode/BitcodeReader.h"
1273 #include "llvm/Bitcode/BitcodeWriter.h"
1274-#include "llvm/CodeGen/CommandFlags.inc"
1275+#include "llvm/CodeGen/CommandFlags.h"
1276 #include "llvm/Config/config.h" // plugin-api.h requires HAVE_STDINT_H
1277 #include "llvm/IR/Constants.h"
1278 #include "llvm/IR/DiagnosticPrinter.h"
1279@@ -50,6 +50,8 @@
1280 using namespace llvm;
1281 using namespace lto;
1282
1283+static codegen::RegisterCodeGenFlags CodeGenFlags;
1284+
1285 // FIXME: Remove when binutils 2.31 (containing gold 1.16) is the minimum
1286 // required version.
1287 typedef enum ld_plugin_status (*ld_plugin_get_wrap_symbols)(
1288@@ -842,21 +844,21 @@ static std::unique_ptr<LTO> createLTO(IndexWriteCallback OnIndexWrite,
1289 ThinBackend Backend;
1290
1291 Conf.CPU = options::mcpu;
1292- Conf.Options = InitTargetOptionsFromCodeGenFlags();
1293+ Conf.Options = codegen::InitTargetOptionsFromCodeGenFlags();
1294
1295 // Disable the new X86 relax relocations since gold might not support them.
1296 // FIXME: Check the gold version or add a new option to enable them.
1297 Conf.Options.RelaxELFRelocations = false;
1298
1299 // Toggle function/data sections.
1300- if (FunctionSections.getNumOccurrences() == 0)
1301+ if (!codegen::getExplicitFunctionSections())
1302 Conf.Options.FunctionSections = SplitSections;
1303- if (DataSections.getNumOccurrences() == 0)
1304+ if (!codegen::getExplicitDataSections())
1305 Conf.Options.DataSections = SplitSections;
1306
1307- Conf.MAttrs = MAttrs;
1308- Conf.RelocModel = RelocationModel;
1309- Conf.CodeModel = getCodeModel();
1310+ Conf.MAttrs = codegen::getMAttrs();
1311+ Conf.RelocModel = codegen::getExplicitRelocModel();
1312+ Conf.CodeModel = codegen::getExplicitCodeModel();
1313 Conf.CGOptLevel = getCGOptLevel();
1314 Conf.DisableVerify = options::DisableVerify;
1315 Conf.OptLevel = options::OptLevel;
1316diff --git a/llvm/tools/llc/CMakeLists.txt b/llvm/tools/llc/CMakeLists.txt
1317index 880deefa539c..479bc6b55b27 100644
1318--- a/llvm/tools/llc/CMakeLists.txt
1319+++ b/llvm/tools/llc/CMakeLists.txt
1320@@ -26,4 +26,5 @@ add_llvm_tool(llc
1321 intrinsics_gen
1322 SUPPORT_PLUGINS
1323 )
1324+
1325 export_executable_symbols(llc)
1326diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp
1327index b35f8e853c30..4c41ed292fdc 100644
1328--- a/llvm/tools/llc/llc.cpp
1329+++ b/llvm/tools/llc/llc.cpp
1330@@ -15,7 +15,7 @@
1331 #include "llvm/ADT/STLExtras.h"
1332 #include "llvm/ADT/Triple.h"
1333 #include "llvm/Analysis/TargetLibraryInfo.h"
1334-#include "llvm/CodeGen/CommandFlags.inc"
1335+#include "llvm/CodeGen/CommandFlags.h"
1336 #include "llvm/CodeGen/LinkAllAsmWriterComponents.h"
1337 #include "llvm/CodeGen/LinkAllCodegenComponents.h"
1338 #include "llvm/CodeGen/MIRParser/MIRParser.h"
1339@@ -55,6 +55,8 @@
1340 #include <memory>
1341 using namespace llvm;
1342
1343+static codegen::RegisterCodeGenFlags CGF;
1344+
1345 // General options for llc. Other pass-specific options are specified
1346 // within the corresponding llc passes, and target-specific options
1347 // and back-end code generation options are specified with the target machine.
1348@@ -202,7 +204,7 @@ static std::unique_ptr<ToolOutputFile> GetOutputStream(const char *TargetName,
1349 else
1350 OutputFilename = IFN;
1351
1352- switch (FileType) {
1353+ switch (codegen::getFileType()) {
1354 case CGFT_AssemblyFile:
1355 if (TargetName[0] == 'c') {
1356 if (TargetName[1] == 0)
1357@@ -229,7 +231,7 @@ static std::unique_ptr<ToolOutputFile> GetOutputStream(const char *TargetName,
1358
1359 // Decide if we need "binary" output.
1360 bool Binary = false;
1361- switch (FileType) {
1362+ switch (codegen::getFileType()) {
1363 case CGFT_AssemblyFile:
1364 break;
1365 case CGFT_ObjectFile:
1366@@ -395,14 +397,16 @@ static int compileModule(char **argv, LLVMContext &Context) {
1367 std::unique_ptr<Module> M;
1368 std::unique_ptr<MIRParser> MIR;
1369 Triple TheTriple;
1370- std::string CPUStr = getCPUStr(), FeaturesStr = getFeaturesStr();
1371+ std::string CPUStr = codegen::getCPUStr(),
1372+ FeaturesStr = codegen::getFeaturesStr();
1373
1374 // Set attributes on functions as loaded from MIR from command line arguments.
1375 auto setMIRFunctionAttributes = [&CPUStr, &FeaturesStr](Function &F) {
1376- setFunctionAttributes(CPUStr, FeaturesStr, F);
1377+ codegen::setFunctionAttributes(CPUStr, FeaturesStr, F);
1378 };
1379
1380- bool SkipModule = MCPU == "help" ||
1381+ auto MAttrs = codegen::getMAttrs();
1382+ bool SkipModule = codegen::getMCPU() == "help" ||
1383 (!MAttrs.empty() && MAttrs.front() == "help");
1384
1385 // If user just wants to list available options, skip module loading
1386@@ -433,8 +437,8 @@ static int compileModule(char **argv, LLVMContext &Context) {
1387
1388 // Get the target specific parser.
1389 std::string Error;
1390- const Target *TheTarget = TargetRegistry::lookupTarget(MArch, TheTriple,
1391- Error);
1392+ const Target *TheTarget =
1393+ TargetRegistry::lookupTarget(codegen::getMArch(), TheTriple, Error);
1394 if (!TheTarget) {
1395 WithColor::error(errs(), argv[0]) << Error;
1396 return 1;
1397@@ -452,7 +456,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
1398 case '3': OLvl = CodeGenOpt::Aggressive; break;
1399 }
1400
1401- TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
1402+ TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
1403 Options.DisableIntegratedAS = NoIntegratedAssembler;
1404 Options.MCOptions.ShowMCEncoding = ShowMCEncoding;
1405 Options.MCOptions.MCUseDwarfDirectory = EnableDwarfDirectory;
1406@@ -462,8 +466,8 @@ static int compileModule(char **argv, LLVMContext &Context) {
1407 Options.MCOptions.SplitDwarfFile = SplitDwarfFile;
1408
1409 std::unique_ptr<TargetMachine> Target(TheTarget->createTargetMachine(
1410- TheTriple.getTriple(), CPUStr, FeaturesStr, Options, getRelocModel(),
1411- getCodeModel(), OLvl));
1412+ TheTriple.getTriple(), CPUStr, FeaturesStr, Options, codegen::getExplicitRelocModel(),
1413+ codegen::getExplicitCodeModel(), OLvl));
1414
1415 assert(Target && "Could not allocate target machine!");
1416
1417@@ -474,8 +478,8 @@ static int compileModule(char **argv, LLVMContext &Context) {
1418 return 0;
1419
1420 assert(M && "Should have exited if we didn't have a module!");
1421- if (FloatABIForCalls != FloatABI::Default)
1422- Options.FloatABIType = FloatABIForCalls;
1423+ if (codegen::getFloatABIForCalls() != FloatABI::Default)
1424+ Options.FloatABIType = codegen::getFloatABIForCalls();
1425
1426 // Figure out where we are going to send the output.
1427 std::unique_ptr<ToolOutputFile> Out =
1428@@ -522,10 +526,9 @@ static int compileModule(char **argv, LLVMContext &Context) {
1429
1430 // Override function attributes based on CPUStr, FeaturesStr, and command line
1431 // flags.
1432- setFunctionAttributes(CPUStr, FeaturesStr, *M);
1433+ codegen::setFunctionAttributes(CPUStr, FeaturesStr, *M);
1434
1435- if (RelaxAll.getNumOccurrences() > 0 &&
1436- FileType != CGFT_ObjectFile)
1437+ if (mc::getExplicitRelaxAll() && codegen::getFileType() != CGFT_ObjectFile)
1438 WithColor::warning(errs(), argv[0])
1439 << ": warning: ignoring -mc-relax-all because filetype != obj";
1440
1441@@ -536,7 +539,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
1442 // so we can memcmp the contents in CompileTwice mode
1443 SmallVector<char, 0> Buffer;
1444 std::unique_ptr<raw_svector_ostream> BOS;
1445- if ((FileType != CGFT_AssemblyFile &&
1446+ if ((codegen::getFileType() != CGFT_AssemblyFile &&
1447 !Out->os().supportsSeeking()) ||
1448 CompileTwice) {
1449 BOS = std::make_unique<raw_svector_ostream>(Buffer);
1450@@ -575,9 +578,9 @@ static int compileModule(char **argv, LLVMContext &Context) {
1451 TPC.setInitialized();
1452 PM.add(createPrintMIRPass(*OS));
1453 PM.add(createFreeMachineFunctionPass());
1454- } else if (Target->addPassesToEmitFile(PM, *OS,
1455- DwoOut ? &DwoOut->os() : nullptr,
1456- FileType, NoVerify, MMIWP)) {
1457+ } else if (Target->addPassesToEmitFile(
1458+ PM, *OS, DwoOut ? &DwoOut->os() : nullptr,
1459+ codegen::getFileType(), NoVerify, MMIWP)) {
1460 WithColor::warning(errs(), argv[0])
1461 << "target does not support generation of this"
1462 << " file type!\n";
1463diff --git a/llvm/tools/lli/CMakeLists.txt b/llvm/tools/lli/CMakeLists.txt
1464index db163ad131e8..bc6ef213b8fd 100644
1465--- a/llvm/tools/lli/CMakeLists.txt
1466+++ b/llvm/tools/lli/CMakeLists.txt
1467@@ -53,4 +53,5 @@ add_llvm_tool(lli
1468 DEPENDS
1469 intrinsics_gen
1470 )
1471+
1472 export_executable_symbols(lli)
1473diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
1474index 0efd0df2c12b..b6a4e3f2833c 100644
1475--- a/llvm/tools/lli/lli.cpp
1476+++ b/llvm/tools/lli/lli.cpp
1477@@ -16,7 +16,7 @@
1478 #include "llvm/ADT/StringExtras.h"
1479 #include "llvm/ADT/Triple.h"
1480 #include "llvm/Bitcode/BitcodeReader.h"
1481-#include "llvm/CodeGen/CommandFlags.inc"
1482+#include "llvm/CodeGen/CommandFlags.h"
1483 #include "llvm/CodeGen/LinkAllCodegenComponents.h"
1484 #include "llvm/Config/llvm-config.h"
1485 #include "llvm/ExecutionEngine/GenericValue.h"
1486@@ -67,6 +67,8 @@
1487
1488 using namespace llvm;
1489
1490+static codegen::RegisterCodeGenFlags CGF;
1491+
1492 #define DEBUG_TYPE "lli"
1493
1494 namespace {
1495@@ -410,13 +412,13 @@ int main(int argc, char **argv, char * const *envp) {
1496
1497 std::string ErrorMsg;
1498 EngineBuilder builder(std::move(Owner));
1499- builder.setMArch(MArch);
1500- builder.setMCPU(getCPUStr());
1501- builder.setMAttrs(getFeatureList());
1502- if (RelocModel.getNumOccurrences())
1503- builder.setRelocationModel(RelocModel);
1504- if (CMModel.getNumOccurrences())
1505- builder.setCodeModel(CMModel);
1506+ builder.setMArch(codegen::getMArch());
1507+ builder.setMCPU(codegen::getCPUStr());
1508+ builder.setMAttrs(codegen::getFeatureList());
1509+ if (auto RM = codegen::getExplicitRelocModel())
1510+ builder.setRelocationModel(RM.getValue());
1511+ if (auto CM = codegen::getExplicitCodeModel())
1512+ builder.setCodeModel(CM.getValue());
1513 builder.setErrorStr(&ErrorMsg);
1514 builder.setEngineKind(ForceInterpreter
1515 ? EngineKind::Interpreter
1516@@ -448,9 +450,9 @@ int main(int argc, char **argv, char * const *envp) {
1517
1518 builder.setOptLevel(getOptLevel());
1519
1520- TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
1521- if (FloatABIForCalls != FloatABI::Default)
1522- Options.FloatABIType = FloatABIForCalls;
1523+ TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
1524+ if (codegen::getFloatABIForCalls() != FloatABI::Default)
1525+ Options.FloatABIType = codegen::getFloatABIForCalls();
1526
1527 builder.setTargetOptions(Options);
1528
1529@@ -762,18 +764,15 @@ int runOrcLazyJIT(const char *ProgName) {
1530 TT.empty() ? ExitOnErr(orc::JITTargetMachineBuilder::detectHost())
1531 : orc::JITTargetMachineBuilder(Triple(TT)));
1532
1533- if (!MArch.empty())
1534- Builder.getJITTargetMachineBuilder()->getTargetTriple().setArchName(MArch);
1535+ if (!codegen::getMArch().empty())
1536+ Builder.getJITTargetMachineBuilder()->getTargetTriple().setArchName(
1537+ codegen::getMArch());
1538
1539 Builder.getJITTargetMachineBuilder()
1540- ->setCPU(getCPUStr())
1541- .addFeatures(getFeatureList())
1542- .setRelocationModel(RelocModel.getNumOccurrences()
1543- ? Optional<Reloc::Model>(RelocModel)
1544- : None)
1545- .setCodeModel(CMModel.getNumOccurrences()
1546- ? Optional<CodeModel::Model>(CMModel)
1547- : None);
1548+ ->setCPU(codegen::getCPUStr())
1549+ .addFeatures(codegen::getFeatureList())
1550+ .setRelocationModel(codegen::getExplicitRelocModel())
1551+ .setCodeModel(codegen::getExplicitCodeModel());
1552
1553 Builder.setLazyCompileFailureAddr(
1554 pointerToJITTargetAddress(exitOnLazyCallThroughFailure));
1555diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp
1556index 23513ef8fb4e..8cfd433d5da3 100644
1557--- a/llvm/tools/llvm-dwp/llvm-dwp.cpp
1558+++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp
1559@@ -27,7 +27,7 @@
1560 #include "llvm/MC/MCObjectWriter.h"
1561 #include "llvm/MC/MCRegisterInfo.h"
1562 #include "llvm/MC/MCStreamer.h"
1563-#include "llvm/MC/MCTargetOptionsCommandFlags.inc"
1564+#include "llvm/MC/MCTargetOptionsCommandFlags.h"
1565 #include "llvm/Object/Decompressor.h"
1566 #include "llvm/Object/ObjectFile.h"
1567 #include "llvm/Support/DataExtractor.h"
1568@@ -46,6 +46,8 @@
1569 using namespace llvm;
1570 using namespace llvm::object;
1571
1572+static mc::RegisterMCTargetOptionsFlags MCTargetOptionsFlags;
1573+
1574 cl::OptionCategory DwpCategory("Specific Options");
1575 static cl::list<std::string> InputFiles(cl::Positional, cl::ZeroOrMore,
1576 cl::desc("<input files>"),
1577@@ -676,7 +678,7 @@ int main(int argc, char **argv) {
1578 if (!MRI)
1579 return error(Twine("no register info for target ") + TripleName, Context);
1580
1581- MCTargetOptions MCOptions = InitMCTargetOptionsFromFlags();
1582+ MCTargetOptions MCOptions = llvm::mc::InitMCTargetOptionsFromFlags();
1583 std::unique_ptr<MCAsmInfo> MAI(
1584 TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
1585 if (!MAI)
1586diff --git a/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp b/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
1587index b71ed4a70566..627e9ab4c03f 100644
1588--- a/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
1589+++ b/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
1590@@ -14,7 +14,7 @@
1591 #include "llvm/Analysis/TargetLibraryInfo.h"
1592 #include "llvm/Bitcode/BitcodeReader.h"
1593 #include "llvm/Bitcode/BitcodeWriter.h"
1594-#include "llvm/CodeGen/CommandFlags.inc"
1595+#include "llvm/CodeGen/CommandFlags.h"
1596 #include "llvm/FuzzMutate/FuzzerCLI.h"
1597 #include "llvm/FuzzMutate/IRMutator.h"
1598 #include "llvm/FuzzMutate/Operations.h"
1599@@ -35,6 +35,8 @@
1600
1601 using namespace llvm;
1602
1603+static codegen::RegisterCodeGenFlags CGF;
1604+
1605 static cl::opt<char>
1606 OptLevel("O",
1607 cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] "
1608@@ -133,14 +135,15 @@ extern "C" LLVM_ATTRIBUTE_USED int LLVMFuzzerInitialize(int *argc,
1609 // Get the target specific parser.
1610 std::string Error;
1611 const Target *TheTarget =
1612- TargetRegistry::lookupTarget(MArch, TheTriple, Error);
1613+ TargetRegistry::lookupTarget(codegen::getMArch(), TheTriple, Error);
1614 if (!TheTarget) {
1615 errs() << argv[0] << ": " << Error;
1616 return 1;
1617 }
1618
1619 // Set up the pipeline like llc does.
1620- std::string CPUStr = getCPUStr(), FeaturesStr = getFeaturesStr();
1621+ std::string CPUStr = codegen::getCPUStr(),
1622+ FeaturesStr = codegen::getFeaturesStr();
1623
1624 CodeGenOpt::Level OLvl = CodeGenOpt::Default;
1625 switch (OptLevel) {
1626@@ -154,10 +157,10 @@ extern "C" LLVM_ATTRIBUTE_USED int LLVMFuzzerInitialize(int *argc,
1627 case '3': OLvl = CodeGenOpt::Aggressive; break;
1628 }
1629
1630- TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
1631- TM.reset(TheTarget->createTargetMachine(TheTriple.getTriple(), CPUStr,
1632- FeaturesStr, Options, getRelocModel(),
1633- getCodeModel(), OLvl));
1634+ TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
1635+ TM.reset(TheTarget->createTargetMachine(
1636+ TheTriple.getTriple(), CPUStr, FeaturesStr, Options,
1637+ codegen::getExplicitRelocModel(), codegen::getExplicitCodeModel(), OLvl));
1638 assert(TM && "Could not allocate target machine!");
1639
1640 // Make sure we print the summary and the current unit when LLVM errors out.
1641diff --git a/llvm/tools/llvm-lto/CMakeLists.txt b/llvm/tools/llvm-lto/CMakeLists.txt
1642index 69868fb870c0..5128e713eecf 100644
1643--- a/llvm/tools/llvm-lto/CMakeLists.txt
1644+++ b/llvm/tools/llvm-lto/CMakeLists.txt
1645@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
1646 AllTargetsInfos
1647 BitReader
1648 BitWriter
1649+ CodeGen
1650 Core
1651 IRReader
1652 LTO
1653@@ -17,7 +18,5 @@ set(LLVM_LINK_COMPONENTS
1654 add_llvm_tool(llvm-lto
1655 llvm-lto.cpp
1656
1657- DEPENDS
1658- intrinsics_gen
1659+ DEPENDS intrinsics_gen
1660 )
1661-
1662diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp
1663index b47e68e82850..7886426e8945 100644
1664--- a/llvm/tools/llvm-lto/llvm-lto.cpp
1665+++ b/llvm/tools/llvm-lto/llvm-lto.cpp
1666@@ -21,7 +21,7 @@
1667 #include "llvm/ADT/Twine.h"
1668 #include "llvm/Bitcode/BitcodeReader.h"
1669 #include "llvm/Bitcode/BitcodeWriter.h"
1670-#include "llvm/CodeGen/CommandFlags.inc"
1671+#include "llvm/CodeGen/CommandFlags.h"
1672 #include "llvm/IR/DiagnosticInfo.h"
1673 #include "llvm/IR/DiagnosticPrinter.h"
1674 #include "llvm/IR/LLVMContext.h"
1675@@ -62,6 +62,8 @@
1676
1677 using namespace llvm;
1678
1679+static codegen::RegisterCodeGenFlags CGF;
1680+
1681 static cl::opt<char>
1682 OptLevel("O", cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] "
1683 "(default = '-O2')"),
1684@@ -521,7 +523,7 @@ public:
1685 ThinLTOCodeGenerator ThinGenerator;
1686
1687 ThinLTOProcessing(const TargetOptions &Options) {
1688- ThinGenerator.setCodePICModel(getRelocModel());
1689+ ThinGenerator.setCodePICModel(codegen::getExplicitRelocModel());
1690 ThinGenerator.setTargetOptions(Options);
1691 ThinGenerator.setCacheDir(ThinLTOCacheDir);
1692 ThinGenerator.setCachePruningInterval(ThinLTOCachePruningInterval);
1693@@ -873,7 +875,7 @@ int main(int argc, char **argv) {
1694 InitializeAllAsmParsers();
1695
1696 // set up the TargetOptions for the machine
1697- TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
1698+ TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
1699
1700 if (ListSymbolsOnly) {
1701 listSymbols(Options);
1702@@ -929,7 +931,7 @@ int main(int argc, char **argv) {
1703 if (UseDiagnosticHandler)
1704 CodeGen.setDiagnosticHandler(handleDiagnostics, nullptr);
1705
1706- CodeGen.setCodePICModel(getRelocModel());
1707+ CodeGen.setCodePICModel(codegen::getExplicitRelocModel());
1708 CodeGen.setFreestanding(EnableFreestanding);
1709
1710 CodeGen.setDebugInfo(LTO_DEBUG_MODEL_DWARF);
1711@@ -980,22 +982,18 @@ int main(int argc, char **argv) {
1712 CodeGen.addMustPreserveSymbol(KeptDSOSyms[i]);
1713
1714 // Set cpu and attrs strings for the default target/subtarget.
1715- CodeGen.setCpu(MCPU.c_str());
1716+ CodeGen.setCpu(codegen::getMCPU().c_str());
1717
1718 CodeGen.setOptLevel(OptLevel - '0');
1719
1720- std::string attrs;
1721- for (unsigned i = 0; i < MAttrs.size(); ++i) {
1722- if (i > 0)
1723- attrs.append(",");
1724- attrs.append(MAttrs[i]);
1725- }
1726-
1727- if (!attrs.empty())
1728+ auto MAttrs = codegen::getMAttrs();
1729+ if (!MAttrs.empty()) {
1730+ std::string attrs = join(MAttrs, ",");
1731 CodeGen.setAttr(attrs);
1732+ }
1733
1734- if (FileType.getNumOccurrences())
1735- CodeGen.setFileType(FileType);
1736+ if (auto FT = codegen::getExplicitFileType())
1737+ CodeGen.setFileType(FT.getValue());
1738
1739 if (!OutputFilename.empty()) {
1740 if (!CodeGen.optimize(DisableVerify, DisableInline, DisableGVNLoadPRE,
1741diff --git a/llvm/tools/llvm-lto2/CMakeLists.txt b/llvm/tools/llvm-lto2/CMakeLists.txt
1742index fa2d8624fd94..4d3364175b04 100644
1743--- a/llvm/tools/llvm-lto2/CMakeLists.txt
1744+++ b/llvm/tools/llvm-lto2/CMakeLists.txt
1745@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
1746 AllTargetsDescs
1747 AllTargetsInfos
1748 BitReader
1749+ CodeGen
1750 Core
1751 Linker
1752 LTO
1753diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp
1754index 67a677dd45fb..142ba605aa2a 100644
1755--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
1756+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
1757@@ -16,7 +16,7 @@
1758 //===----------------------------------------------------------------------===//
1759
1760 #include "llvm/Bitcode/BitcodeReader.h"
1761-#include "llvm/CodeGen/CommandFlags.inc"
1762+#include "llvm/CodeGen/CommandFlags.h"
1763 #include "llvm/IR/DiagnosticPrinter.h"
1764 #include "llvm/LTO/Caching.h"
1765 #include "llvm/LTO/LTO.h"
1766@@ -29,6 +29,8 @@
1767 using namespace llvm;
1768 using namespace lto;
1769
1770+static codegen::RegisterCodeGenFlags CGF;
1771+
1772 static cl::opt<char>
1773 OptLevel("O", cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] "
1774 "(default = '-O2')"),
1775@@ -217,12 +219,12 @@ static int run(int argc, char **argv) {
1776 exit(1);
1777 };
1778
1779- Conf.CPU = MCPU;
1780- Conf.Options = InitTargetOptionsFromCodeGenFlags();
1781- Conf.MAttrs = MAttrs;
1782- if (auto RM = getRelocModel())
1783- Conf.RelocModel = *RM;
1784- Conf.CodeModel = getCodeModel();
1785+ Conf.CPU = codegen::getMCPU();
1786+ Conf.Options = codegen::InitTargetOptionsFromCodeGenFlags();
1787+ Conf.MAttrs = codegen::getMAttrs();
1788+ if (auto RM = codegen::getExplicitRelocModel())
1789+ Conf.RelocModel = RM.getValue();
1790+ Conf.CodeModel = codegen::getExplicitCodeModel();
1791
1792 Conf.DebugPassManager = DebugPassManager;
1793
1794@@ -264,8 +266,8 @@ static int run(int argc, char **argv) {
1795 return 1;
1796 }
1797
1798- if (FileType.getNumOccurrences())
1799- Conf.CGFileType = FileType;
1800+ if (auto FT = codegen::getExplicitFileType())
1801+ Conf.CGFileType = FT.getValue();
1802
1803 Conf.OverrideTriple = OverrideTriple;
1804 Conf.DefaultTriple = DefaultTriple;
1805diff --git a/llvm/tools/llvm-mc-assemble-fuzzer/CMakeLists.txt b/llvm/tools/llvm-mc-assemble-fuzzer/CMakeLists.txt
1806index fb6befd3c54a..6bbc502e2eee 100644
1807--- a/llvm/tools/llvm-mc-assemble-fuzzer/CMakeLists.txt
1808+++ b/llvm/tools/llvm-mc-assemble-fuzzer/CMakeLists.txt
1809@@ -7,6 +7,7 @@ set(LLVM_LINK_COMPONENTS
1810 MCParser
1811 Support
1812 )
1813+
1814 add_llvm_fuzzer(llvm-mc-assemble-fuzzer
1815 llvm-mc-assemble-fuzzer.cpp
1816 )
1817diff --git a/llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp b/llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
1818index 6c5961f7027c..29699c634bfa 100644
1819--- a/llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
1820+++ b/llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
1821@@ -9,7 +9,6 @@
1822 //===----------------------------------------------------------------------===//
1823
1824 #include "llvm-c/Target.h"
1825-#include "llvm/MC/SubtargetFeature.h"
1826 #include "llvm/MC/MCAsmBackend.h"
1827 #include "llvm/MC/MCAsmInfo.h"
1828 #include "llvm/MC/MCCodeEmitter.h"
1829@@ -24,15 +23,16 @@
1830 #include "llvm/MC/MCSectionMachO.h"
1831 #include "llvm/MC/MCStreamer.h"
1832 #include "llvm/MC/MCSubtargetInfo.h"
1833-#include "llvm/MC/MCTargetOptionsCommandFlags.inc"
1834-#include "llvm/Support/MemoryBuffer.h"
1835+#include "llvm/MC/MCTargetOptionsCommandFlags.h"
1836+#include "llvm/MC/SubtargetFeature.h"
1837 #include "llvm/Support/CommandLine.h"
1838 #include "llvm/Support/FileUtilities.h"
1839-#include "llvm/Support/raw_ostream.h"
1840+#include "llvm/Support/MemoryBuffer.h"
1841 #include "llvm/Support/SourceMgr.h"
1842-#include "llvm/Support/TargetSelect.h"
1843 #include "llvm/Support/TargetRegistry.h"
1844+#include "llvm/Support/TargetSelect.h"
1845 #include "llvm/Support/ToolOutputFile.h"
1846+#include "llvm/Support/raw_ostream.h"
1847
1848 using namespace llvm;
1849
1850@@ -161,7 +161,7 @@ int AssembleOneInput(const uint8_t *Data, size_t Size) {
1851 abort();
1852 }
1853
1854- MCTargetOptions MCOptions = InitMCTargetOptionsFromFlags();
1855+ MCTargetOptions MCOptions = mc::InitMCTargetOptionsFromFlags();
1856 std::unique_ptr<MCAsmInfo> MAI(
1857 TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
1858 if (!MAI) {
1859diff --git a/llvm/tools/llvm-mc/CMakeLists.txt b/llvm/tools/llvm-mc/CMakeLists.txt
1860index 15c6dda1b258..94add70b6943 100644
1861--- a/llvm/tools/llvm-mc/CMakeLists.txt
1862+++ b/llvm/tools/llvm-mc/CMakeLists.txt
1863@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
1864 AllTargetsDescs
1865 AllTargetsDisassemblers
1866 AllTargetsInfos
1867+ CodeGen
1868 MC
1869 MCParser
1870 Support
1871diff --git a/llvm/tools/llvm-mc/llvm-mc.cpp b/llvm/tools/llvm-mc/llvm-mc.cpp
1872index 6aa347d98be2..8c1b3cf2cab0 100644
1873--- a/llvm/tools/llvm-mc/llvm-mc.cpp
1874+++ b/llvm/tools/llvm-mc/llvm-mc.cpp
1875@@ -25,7 +25,7 @@
1876 #include "llvm/MC/MCRegisterInfo.h"
1877 #include "llvm/MC/MCStreamer.h"
1878 #include "llvm/MC/MCSubtargetInfo.h"
1879-#include "llvm/MC/MCTargetOptionsCommandFlags.inc"
1880+#include "llvm/MC/MCTargetOptionsCommandFlags.h"
1881 #include "llvm/Support/CommandLine.h"
1882 #include "llvm/Support/Compression.h"
1883 #include "llvm/Support/FileUtilities.h"
1884@@ -41,6 +41,8 @@
1885
1886 using namespace llvm;
1887
1888+static mc::RegisterMCTargetOptionsFlags MOF;
1889+
1890 static cl::opt<std::string>
1891 InputFilename(cl::Positional, cl::desc("<input file>"), cl::init("-"));
1892
1893@@ -317,7 +319,7 @@ int main(int argc, char **argv) {
1894 cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion);
1895
1896 cl::ParseCommandLineOptions(argc, argv, "llvm machine code playground\n");
1897- const MCTargetOptions MCOptions = InitMCTargetOptionsFromFlags();
1898+ const MCTargetOptions MCOptions = mc::InitMCTargetOptionsFromFlags();
1899 setDwarfDebugFlags(argc, argv);
1900
1901 setDwarfDebugProducer();
1902diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp
1903index fff5906bb59b..eca86768aa5c 100644
1904--- a/llvm/tools/llvm-mca/llvm-mca.cpp
1905+++ b/llvm/tools/llvm-mca/llvm-mca.cpp
1906@@ -39,7 +39,7 @@
1907 #include "llvm/MC/MCObjectFileInfo.h"
1908 #include "llvm/MC/MCRegisterInfo.h"
1909 #include "llvm/MC/MCSubtargetInfo.h"
1910-#include "llvm/MC/MCTargetOptionsCommandFlags.inc"
1911+#include "llvm/MC/MCTargetOptionsCommandFlags.h"
1912 #include "llvm/MCA/CodeEmitter.h"
1913 #include "llvm/MCA/Context.h"
1914 #include "llvm/MCA/InstrBuilder.h"
1915@@ -62,6 +62,8 @@
1916
1917 using namespace llvm;
1918
1919+static mc::RegisterMCTargetOptionsFlags MOF;
1920+
1921 static cl::OptionCategory ToolOptions("Tool Options");
1922 static cl::OptionCategory ViewOptions("View Options");
1923
1924@@ -353,7 +355,7 @@ int main(int argc, char **argv) {
1925 std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TripleName));
1926 assert(MRI && "Unable to create target register info!");
1927
1928- MCTargetOptions MCOptions = InitMCTargetOptionsFromFlags();
1929+ MCTargetOptions MCOptions = mc::InitMCTargetOptionsFromFlags();
1930 std::unique_ptr<MCAsmInfo> MAI(
1931 TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
1932 assert(MAI && "Unable to create target asm info!");
1933@@ -443,7 +445,7 @@ int main(int argc, char **argv) {
1934 TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx));
1935
1936 std::unique_ptr<MCAsmBackend> MAB(TheTarget->createMCAsmBackend(
1937- *STI, *MRI, InitMCTargetOptionsFromFlags()));
1938+ *STI, *MRI, mc::InitMCTargetOptionsFromFlags()));
1939
1940 for (const std::unique_ptr<mca::CodeRegion> &Region : Regions) {
1941 // Skip empty code regions.
1942diff --git a/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp b/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
1943index cd6c7d380cc6..e353e333f580 100644
1944--- a/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
1945+++ b/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
1946@@ -12,7 +12,7 @@
1947
1948 #include "llvm/Bitcode/BitcodeReader.h"
1949 #include "llvm/Bitcode/BitcodeWriter.h"
1950-#include "llvm/CodeGen/CommandFlags.inc"
1951+#include "llvm/CodeGen/CommandFlags.h"
1952 #include "llvm/FuzzMutate/FuzzerCLI.h"
1953 #include "llvm/FuzzMutate/IRMutator.h"
1954 #include "llvm/IR/Verifier.h"
1955@@ -24,6 +24,8 @@
1956
1957 using namespace llvm;
1958
1959+static codegen::RegisterCodeGenFlags CGF;
1960+
1961 static cl::opt<std::string>
1962 TargetTripleStr("mtriple", cl::desc("Override target triple for module"));
1963
1964@@ -124,7 +126,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
1965
1966 M->setTargetTriple(TM->getTargetTriple().normalize());
1967 M->setDataLayout(TM->createDataLayout());
1968- setFunctionAttributes(TM->getTargetCPU(), TM->getTargetFeatureString(), *M);
1969+ codegen::setFunctionAttributes(TM->getTargetCPU(),
1970+ TM->getTargetFeatureString(), *M);
1971
1972 // Create pass pipeline
1973 //
1974@@ -214,16 +217,17 @@ extern "C" LLVM_ATTRIBUTE_USED int LLVMFuzzerInitialize(
1975
1976 std::string Error;
1977 const Target *TheTarget =
1978- TargetRegistry::lookupTarget(MArch, TargetTriple, Error);
1979+ TargetRegistry::lookupTarget(codegen::getMArch(), TargetTriple, Error);
1980 if (!TheTarget) {
1981 errs() << *argv[0] << ": " << Error;
1982 exit(1);
1983 }
1984
1985- TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
1986+ TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
1987 TM.reset(TheTarget->createTargetMachine(
1988- TargetTriple.getTriple(), getCPUStr(), getFeaturesStr(),
1989- Options, getRelocModel(), getCodeModel(), CodeGenOpt::Default));
1990+ TargetTriple.getTriple(), codegen::getCPUStr(), codegen::getFeaturesStr(),
1991+ Options, codegen::getExplicitRelocModel(),
1992+ codegen::getExplicitCodeModel(), CodeGenOpt::Default));
1993 assert(TM && "Could not allocate target machine!");
1994
1995 // Check that pass pipeline is specified and correct
1996diff --git a/llvm/tools/lto/CMakeLists.txt b/llvm/tools/lto/CMakeLists.txt
1997index b86e4abd01a7..2963f97cad88 100644
1998--- a/llvm/tools/lto/CMakeLists.txt
1999+++ b/llvm/tools/lto/CMakeLists.txt
2000@@ -6,6 +6,7 @@ set(LLVM_LINK_COMPONENTS
2001 AllTargetsInfos
2002 BitReader
2003 Core
2004+ CodeGen
2005 LTO
2006 MC
2007 MCDisassembler
2008@@ -20,7 +21,8 @@ set(SOURCES
2009
2010 set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/lto.exports)
2011
2012-add_llvm_library(LTO SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES} DEPENDS intrinsics_gen)
2013+add_llvm_library(LTO SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES} DEPENDS
2014+ intrinsics_gen)
2015
2016 install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h
2017 DESTINATION include/llvm-c
2018diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp
2019index 9933af94de1e..6d207b76685f 100644
2020--- a/llvm/tools/lto/lto.cpp
2021+++ b/llvm/tools/lto/lto.cpp
2022@@ -15,7 +15,7 @@
2023 #include "llvm/ADT/STLExtras.h"
2024 #include "llvm/ADT/StringExtras.h"
2025 #include "llvm/Bitcode/BitcodeReader.h"
2026-#include "llvm/CodeGen/CommandFlags.inc"
2027+#include "llvm/CodeGen/CommandFlags.h"
2028 #include "llvm/IR/DiagnosticInfo.h"
2029 #include "llvm/IR/DiagnosticPrinter.h"
2030 #include "llvm/IR/LLVMContext.h"
2031@@ -28,6 +28,10 @@
2032 #include "llvm/Support/TargetSelect.h"
2033 #include "llvm/Support/raw_ostream.h"
2034
2035+using namespace llvm;
2036+
2037+static codegen::RegisterCodeGenFlags CGF;
2038+
2039 // extra command-line flags needed for LTOCodeGenerator
2040 static cl::opt<char>
2041 OptLevel("O",
2042@@ -154,14 +158,9 @@ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LTOModule, lto_module_t)
2043 // Convert the subtarget features into a string to pass to LTOCodeGenerator.
2044 static void lto_add_attrs(lto_code_gen_t cg) {
2045 LTOCodeGenerator *CG = unwrap(cg);
2046- if (MAttrs.size()) {
2047- std::string attrs;
2048- for (unsigned i = 0; i < MAttrs.size(); ++i) {
2049- if (i > 0)
2050- attrs.append(",");
2051- attrs.append(MAttrs[i]);
2052- }
2053-
2054+ auto MAttrs = codegen::getMAttrs();
2055+ if (!MAttrs.empty()) {
2056+ std::string attrs = join(MAttrs, ",");
2057 CG->setAttr(attrs);
2058 }
2059
2060@@ -219,7 +218,7 @@ lto_module_is_object_file_in_memory_for_target(const void* mem,
2061
2062 lto_module_t lto_module_create(const char* path) {
2063 lto_initialize();
2064- llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
2065+ llvm::TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
2066 ErrorOr<std::unique_ptr<LTOModule>> M =
2067 LTOModule::createFromFile(*LTOContext, StringRef(path), Options);
2068 if (!M)
2069@@ -229,7 +228,7 @@ lto_module_t lto_module_create(const char* path) {
2070
2071 lto_module_t lto_module_create_from_fd(int fd, const char *path, size_t size) {
2072 lto_initialize();
2073- llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
2074+ llvm::TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
2075 ErrorOr<std::unique_ptr<LTOModule>> M = LTOModule::createFromOpenFile(
2076 *LTOContext, fd, StringRef(path), size, Options);
2077 if (!M)
2078@@ -242,7 +241,7 @@ lto_module_t lto_module_create_from_fd_at_offset(int fd, const char *path,
2079 size_t map_size,
2080 off_t offset) {
2081 lto_initialize();
2082- llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
2083+ llvm::TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
2084 ErrorOr<std::unique_ptr<LTOModule>> M = LTOModule::createFromOpenFileSlice(
2085 *LTOContext, fd, StringRef(path), map_size, offset, Options);
2086 if (!M)
2087@@ -252,7 +251,7 @@ lto_module_t lto_module_create_from_fd_at_offset(int fd, const char *path,
2088
2089 lto_module_t lto_module_create_from_memory(const void* mem, size_t length) {
2090 lto_initialize();
2091- llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
2092+ llvm::TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
2093 ErrorOr<std::unique_ptr<LTOModule>> M =
2094 LTOModule::createFromBuffer(*LTOContext, mem, length, Options);
2095 if (!M)
2096@@ -264,7 +263,7 @@ lto_module_t lto_module_create_from_memory_with_path(const void* mem,
2097 size_t length,
2098 const char *path) {
2099 lto_initialize();
2100- llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
2101+ llvm::TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
2102 ErrorOr<std::unique_ptr<LTOModule>> M = LTOModule::createFromBuffer(
2103 *LTOContext, mem, length, Options, StringRef(path));
2104 if (!M)
2105@@ -275,7 +274,7 @@ lto_module_t lto_module_create_from_memory_with_path(const void* mem,
2106 lto_module_t lto_module_create_in_local_context(const void *mem, size_t length,
2107 const char *path) {
2108 lto_initialize();
2109- llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
2110+ llvm::TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
2111
2112 // Create a local context. Ownership will be transferred to LTOModule.
2113 std::unique_ptr<LLVMContext> Context = std::make_unique<LLVMContext>();
2114@@ -294,7 +293,7 @@ lto_module_t lto_module_create_in_codegen_context(const void *mem,
2115 const char *path,
2116 lto_code_gen_t cg) {
2117 lto_initialize();
2118- llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
2119+ llvm::TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
2120 ErrorOr<std::unique_ptr<LTOModule>> M = LTOModule::createFromBuffer(
2121 unwrap(cg)->getContext(), mem, length, Options, StringRef(path));
2122 return wrap(M->release());
2123@@ -336,7 +335,7 @@ void lto_codegen_set_diagnostic_handler(lto_code_gen_t cg,
2124 static lto_code_gen_t createCodeGen(bool InLocalContext) {
2125 lto_initialize();
2126
2127- TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
2128+ TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
2129
2130 LibLTOCodeGenerator *CodeGen =
2131 InLocalContext ? new LibLTOCodeGenerator(std::make_unique<LLVMContext>())
2132@@ -484,7 +483,7 @@ void lto_codegen_set_should_embed_uselists(lto_code_gen_t cg,
2133 thinlto_code_gen_t thinlto_create_codegen(void) {
2134 lto_initialize();
2135 ThinLTOCodeGenerator *CodeGen = new ThinLTOCodeGenerator();
2136- CodeGen->setTargetOptions(InitTargetOptionsFromCodeGenFlags());
2137+ CodeGen->setTargetOptions(codegen::InitTargetOptionsFromCodeGenFlags());
2138 CodeGen->setFreestanding(EnableFreestanding);
2139
2140 if (OptLevel.getNumOccurrences()) {
2141diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
2142index 75a6cdc3892b..8d619ef76b7a 100644
2143--- a/llvm/tools/opt/opt.cpp
2144+++ b/llvm/tools/opt/opt.cpp
2145@@ -22,7 +22,7 @@
2146 #include "llvm/Analysis/TargetLibraryInfo.h"
2147 #include "llvm/Analysis/TargetTransformInfo.h"
2148 #include "llvm/Bitcode/BitcodeWriterPass.h"
2149-#include "llvm/CodeGen/CommandFlags.inc"
2150+#include "llvm/CodeGen/CommandFlags.h"
2151 #include "llvm/CodeGen/TargetPassConfig.h"
2152 #include "llvm/Config/llvm-config.h"
2153 #include "llvm/IR/DataLayout.h"
2154@@ -61,6 +61,8 @@
2155 using namespace llvm;
2156 using namespace opt_tool;
2157
2158+static codegen::RegisterCodeGenFlags CFG;
2159+
2160 // The OptimizationList is automatically populated with registered Passes by the
2161 // PassNameParser.
2162 //
2163@@ -470,16 +472,17 @@ static TargetMachine* GetTargetMachine(Triple TheTriple, StringRef CPUStr,
2164 StringRef FeaturesStr,
2165 const TargetOptions &Options) {
2166 std::string Error;
2167- const Target *TheTarget = TargetRegistry::lookupTarget(MArch, TheTriple,
2168- Error);
2169+ const Target *TheTarget =
2170+ TargetRegistry::lookupTarget(codegen::getMArch(), TheTriple, Error);
2171 // Some modules don't specify a triple, and this is okay.
2172 if (!TheTarget) {
2173 return nullptr;
2174 }
2175
2176- return TheTarget->createTargetMachine(TheTriple.getTriple(), CPUStr,
2177- FeaturesStr, Options, getRelocModel(),
2178- getCodeModel(), GetCodeGenOptLevel());
2179+ return TheTarget->createTargetMachine(
2180+ TheTriple.getTriple(), codegen::getCPUStr(), codegen::getFeaturesStr(),
2181+ Options, codegen::getExplicitRelocModel(),
2182+ codegen::getExplicitCodeModel(), GetCodeGenOptLevel());
2183 }
2184
2185 #ifdef BUILD_EXAMPLES
2186@@ -659,11 +662,11 @@ int main(int argc, char **argv) {
2187 Triple ModuleTriple(M->getTargetTriple());
2188 std::string CPUStr, FeaturesStr;
2189 TargetMachine *Machine = nullptr;
2190- const TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
2191+ const TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
2192
2193 if (ModuleTriple.getArch()) {
2194- CPUStr = getCPUStr();
2195- FeaturesStr = getFeaturesStr();
2196+ CPUStr = codegen::getCPUStr();
2197+ FeaturesStr = codegen::getFeaturesStr();
2198 Machine = GetTargetMachine(ModuleTriple, CPUStr, FeaturesStr, Options);
2199 } else if (ModuleTriple.getArchName() != "unknown" &&
2200 ModuleTriple.getArchName() != "") {
2201@@ -676,7 +679,7 @@ int main(int argc, char **argv) {
2202
2203 // Override function attributes based on CPUStr, FeaturesStr, and command line
2204 // flags.
2205- setFunctionAttributes(CPUStr, FeaturesStr, *M);
2206+ codegen::setFunctionAttributes(CPUStr, FeaturesStr, *M);
2207
2208 // If the output is set to be emitted to standard out, and standard out is a
2209 // console, print out a warning message and refuse to do it. We don't
2210diff --git a/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp b/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
2211index 472d4dd6ad1e..32d1d3c91ff2 100644
2212--- a/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
2213+++ b/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
2214@@ -25,7 +25,7 @@
2215 #include "llvm/MC/MCRegisterInfo.h"
2216 #include "llvm/MC/MCStreamer.h"
2217 #include "llvm/MC/MCSubtargetInfo.h"
2218-#include "llvm/MC/MCTargetOptionsCommandFlags.inc"
2219+#include "llvm/MC/MCTargetOptionsCommandFlags.h"
2220 #include "llvm/PassAnalysisSupport.h"
2221 #include "llvm/Support/TargetRegistry.h"
2222 #include "llvm/Support/raw_ostream.h"
2223@@ -36,6 +36,8 @@
2224 using namespace llvm;
2225 using namespace dwarf;
2226
2227+mc::RegisterMCTargetOptionsFlags MOF;
2228+
2229 namespace {} // end anonymous namespace
2230
2231 //===----------------------------------------------------------------------===//
2232@@ -410,7 +412,7 @@ llvm::Error dwarfgen::Generator::init(Triple TheTriple, uint16_t V) {
2233 TripleName,
2234 inconvertibleErrorCode());
2235
2236- MCTargetOptions MCOptions = InitMCTargetOptionsFromFlags();
2237+ MCTargetOptions MCOptions = mc::InitMCTargetOptionsFromFlags();
2238 MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
2239 if (!MAI)
2240 return make_error<StringError>("no asm info for target " + TripleName,
2241--
22422.33.1
2243
diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm10-basic-block-sections-support.patch b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm10-basic-block-sections-support.patch
new file mode 100644
index 00000000..f90a79ae
--- /dev/null
+++ b/dynamic-layers/clang-layer/recipes-devtools/clang/files/llvm10-basic-block-sections-support.patch
@@ -0,0 +1,237 @@
1From d51fdb9f2986747a56c593fa057d531720b39deb Mon Sep 17 00:00:00 2001
2From: Sriraman Tallam <tmsriram@google.com>
3Date: Fri, 13 Mar 2020 15:58:57 -0700
4Subject: [PATCH] Basic Block Sections Support.
5
6This is the first in a series of patches to enable Basic Block Sections
7in LLVM.
8
9We introduce a new compiler option, -fbasicblock-sections=, which places every
10basic block in a unique ELF text section in the object file along with a
11symbol labeling the basic block. The linker can then order the basic block
12sections in any arbitrary sequence which when done correctly can encapsulate
13block layout, function layout and function splitting optimizations. However,
14there are a couple of challenges to be addressed for this to be feasible:
15
161) The compiler must not allow any implicit fall-through between any two
17 adjacent basic blocks as they could be reordered at link time to be
18 non-adjacent. In other words, the compiler must make a fall-through
19 between adjacent basic blocks explicit by retaining the direct jump
20 instruction that jumps to the next basic block. These branches can only
21 be removed later by the linker after the blocks have been reordered.
222) All inter-basic block branch targets would now need to be resolved by
23 the linker as they cannot be calculated during compile time. This is
24 done using static relocations which bloats the size of the object files.
25 Further, the compiler tries to use short branch instructions on some ISAs
26 for branch offsets that can be accommodated in one byte. This is not
27 possible with basic block sections as the offset is not determined at
28 compile time, and long branch instructions have to be used everywhere.
293) Each additional section bloats object file sizes by tens of bytes. The
30 number of basic blocks can be potentially very large compared to the
31 size of functions and can bloat object sizes significantly. Option
32 fbasicblock-sections= also takes a file path which can be used to
33 specify a subset of basic blocks that needs unique sections to keep
34 the bloats small.
354) Debug Info and CFI need special handling and will be presented as
36 separate patches.
37
38Basic Block Labels
39
40With -fbasicblock-sections=labels, or when a basic block is placed in a
41unique section, it is labelled with a symbol. This allows easy mapping of
42virtual addresses from PMU profiles back to the corresponding basic blocks.
43Since the number of basic blocks is large, the labeling bloats the symbol
44table sizes and the string table sizes significantly. While the binary size
45does increase, it does not affect performance as the symbol table is not
46loaded in memory during run-time. The string table size bloat is kept very
47minimal using a unary naming scheme that uses string suffix compression.
48The basic blocks for function foo are named "a.BB.foo", "aa.BB.foo", ...
49This turns out to be very good for string table sizes and the bloat in the
50string table size for a very large binary is ~8 %. The naming also allows
51using the --symbol-ordering-file option in LLD to arbitrarily reorder the
52sections.
53
54Differential Revision: https://reviews.llvm.org/D68063
55
56Upstream-Status: Backport [https://github.com/llvm/llvm-project/commit/4dfe92e46542be46d634a7ec24da2f2f889623d0]
57Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
58---
59 llvm/include/llvm/CodeGen/CommandFlags.inc | 34 ++++++++++++++++++++++
60 llvm/include/llvm/Target/TargetMachine.h | 14 +++++++++
61 llvm/include/llvm/Target/TargetOptions.h | 31 ++++++++++++++++++--
62 3 files changed, 76 insertions(+), 3 deletions(-)
63
64diff --git a/llvm/include/llvm/CodeGen/CommandFlags.inc b/llvm/include/llvm/CodeGen/CommandFlags.inc
65index 8739b644873d..6475a5b19edb 100644
66--- a/llvm/include/llvm/CodeGen/CommandFlags.inc
67+++ b/llvm/include/llvm/CodeGen/CommandFlags.inc
68@@ -238,6 +238,12 @@ static cl::opt<bool>
69 cl::desc("Emit functions into separate sections"),
70 cl::init(false));
71
72+static cl::opt<std::string>
73+ BBSections("basicblock-sections",
74+ cl::desc("Emit basic blocks into separate sections"),
75+ cl::value_desc("all | <function list (file)> | labels | none"),
76+ cl::init("none"));
77+
78 static cl::opt<unsigned> TLSSize("tls-size",
79 cl::desc("Bit size of immediate TLS offsets"),
80 cl::init(0));
81@@ -251,6 +257,11 @@ static cl::opt<bool>
82 cl::desc("Give unique names to every section"),
83 cl::init(true));
84
85+static cl::opt<bool> UniqueBBSectionNames(
86+ "unique-bb-section-names",
87+ cl::desc("Give unique names to every basic block section"),
88+ cl::init(false));
89+
90 static cl::opt<llvm::EABI>
91 EABIVersion("meabi", cl::desc("Set EABI type (default depends on triple):"),
92 cl::init(EABI::Default),
93@@ -285,6 +296,27 @@ static cl::opt<bool>
94 cl::desc("Always emit a debug frame section."),
95 cl::init(false));
96
97+static llvm::BasicBlockSection
98+getBBSectionsMode(llvm::TargetOptions &Options) {
99+ if (BBSections == "all")
100+ return BasicBlockSection::All;
101+ else if (BBSections == "labels")
102+ return BasicBlockSection::Labels;
103+ else if (BBSections == "none")
104+ return BasicBlockSection::None;
105+ else {
106+ ErrorOr<std::unique_ptr<MemoryBuffer>> MBOrErr =
107+ MemoryBuffer::getFile(BBSections);
108+ if (!MBOrErr) {
109+ errs() << "Error loading basic block sections function list file: "
110+ << MBOrErr.getError().message() << "\n";
111+ } else {
112+ Options.BBSectionsFuncListBuf = std::move(*MBOrErr);
113+ }
114+ return BasicBlockSection::List;
115+ }
116+}
117+
118 // Common utility function tightly tied to the options listed here. Initializes
119 // a TargetOptions object with CodeGen flags and returns it.
120 static TargetOptions InitTargetOptionsFromCodeGenFlags() {
121@@ -308,7 +340,9 @@ static TargetOptions InitTargetOptionsFromCodeGenFlags() {
122 Options.RelaxELFRelocations = RelaxELFRelocations;
123 Options.DataSections = DataSections;
124 Options.FunctionSections = FunctionSections;
125+ Options.BBSections = getBBSectionsMode(Options);
126 Options.UniqueSectionNames = UniqueSectionNames;
127+ Options.UniqueBBSectionNames = UniqueBBSectionNames;
128 Options.TLSSize = TLSSize;
129 Options.EmulatedTLS = EmulatedTLS;
130 Options.ExplicitEmulatedTLS = EmulatedTLS.getNumOccurrences() > 0;
131diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h
132index 176ae39b17a7..4a1f3377f31d 100644
133--- a/llvm/include/llvm/Target/TargetMachine.h
134+++ b/llvm/include/llvm/Target/TargetMachine.h
135@@ -242,6 +242,9 @@ public:
136
137 bool getUniqueSectionNames() const { return Options.UniqueSectionNames; }
138
139+ /// Return true if unique basic block section names must be generated.
140+ bool getUniqueBBSectionNames() const { return Options.UniqueBBSectionNames; }
141+
142 /// Return true if data objects should be emitted into their own section,
143 /// corresponds to -fdata-sections.
144 bool getDataSections() const {
145@@ -254,6 +257,17 @@ public:
146 return Options.FunctionSections;
147 }
148
149+ /// If basic blocks should be emitted into their own section,
150+ /// corresponding to -fbasicblock-sections.
151+ llvm::BasicBlockSection getBBSectionsType() const {
152+ return Options.BBSections;
153+ }
154+
155+ /// Get the list of functions and basic block ids that need unique sections.
156+ const MemoryBuffer *getBBSectionsFuncListBuf() const {
157+ return Options.BBSectionsFuncListBuf.get();
158+ }
159+
160 /// Get a \c TargetIRAnalysis appropriate for the target.
161 ///
162 /// This is used to construct the new pass manager's target IR analysis pass,
163diff --git a/llvm/include/llvm/Target/TargetOptions.h b/llvm/include/llvm/Target/TargetOptions.h
164index 84c6ee2a6387..d27c7b0178f0 100644
165--- a/llvm/include/llvm/Target/TargetOptions.h
166+++ b/llvm/include/llvm/Target/TargetOptions.h
167@@ -16,8 +16,11 @@
168
169 #include "llvm/MC/MCTargetOptions.h"
170
171+#include <memory>
172+
173 namespace llvm {
174 class MachineFunction;
175+ class MemoryBuffer;
176 class Module;
177
178 namespace FloatABI {
179@@ -63,6 +66,18 @@ namespace llvm {
180 };
181 }
182
183+ enum class BasicBlockSection {
184+ All, // Use Basic Block Sections for all basic blocks. A section
185+ // for every basic block can significantly bloat object file sizes.
186+ List, // Get list of functions & BBs from a file. Selectively enables
187+ // basic block sections for a subset of basic blocks which can be
188+ // used to control object size bloats from creating sections.
189+ Labels, // Do not use Basic Block Sections but label basic blocks. This
190+ // is useful when associating profile counts from virtual addresses
191+ // to basic blocks.
192+ None // Do not use Basic Block Sections.
193+ };
194+
195 enum class EABI {
196 Unknown,
197 Default, // Default means not specified
198@@ -114,9 +129,9 @@ namespace llvm {
199 EnableFastISel(false), EnableGlobalISel(false), UseInitArray(false),
200 DisableIntegratedAS(false), RelaxELFRelocations(false),
201 FunctionSections(false), DataSections(false),
202- UniqueSectionNames(true), TrapUnreachable(false),
203- NoTrapAfterNoreturn(false), TLSSize(0), EmulatedTLS(false),
204- ExplicitEmulatedTLS(false), EnableIPRA(false),
205+ UniqueSectionNames(true), UniqueBBSectionNames(false),
206+ TrapUnreachable(false), NoTrapAfterNoreturn(false), TLSSize(0),
207+ EmulatedTLS(false), ExplicitEmulatedTLS(false), EnableIPRA(false),
208 EmitStackSizeSection(false), EnableMachineOutliner(false),
209 SupportsDefaultOutlining(false), EmitAddrsig(false),
210 EnableDebugEntryValues(false), ForceDwarfFrameSection(false) {}
211@@ -224,6 +239,9 @@ namespace llvm {
212
213 unsigned UniqueSectionNames : 1;
214
215+ /// Use unique names for basic block sections.
216+ unsigned UniqueBBSectionNames : 1;
217+
218 /// Emit target-specific trap instruction for 'unreachable' IR instructions.
219 unsigned TrapUnreachable : 1;
220
221@@ -256,6 +274,13 @@ namespace llvm {
222 /// Emit address-significance table.
223 unsigned EmitAddrsig : 1;
224
225+ /// Emit basic blocks into separate sections.
226+ BasicBlockSection BBSections = BasicBlockSection::None;
227+
228+ /// Memory Buffer that contains information on sampled basic blocks and used
229+ /// to selectively generate basic block sections.
230+ std::shared_ptr<MemoryBuffer> BBSectionsFuncListBuf;
231+
232 /// Emit debug info about parameter's entry values.
233 unsigned EnableDebugEntryValues : 1;
234
235--
2362.33.1
237
diff --git a/dynamic-layers/clang-layer/recipes-devtools/clang/llvm-project-source.bbappend b/dynamic-layers/clang-layer/recipes-devtools/clang/llvm-project-source.bbappend
index 96011f1d..9701aca6 100644
--- a/dynamic-layers/clang-layer/recipes-devtools/clang/llvm-project-source.bbappend
+++ b/dynamic-layers/clang-layer/recipes-devtools/clang/llvm-project-source.bbappend
@@ -23,6 +23,9 @@ SRC_URI_LLVM10_PATCHES = " \
23 file://llvm10-0013-ispc-10_0_k_reg_mov_avx512_i8_i16.patch \ 23 file://llvm10-0013-ispc-10_0_k_reg_mov_avx512_i8_i16.patch \
24 file://llvm10-0014-ispc-10_0_packed_load_store_avx512skx.patch \ 24 file://llvm10-0014-ispc-10_0_packed_load_store_avx512skx.patch \
25 file://llvm10-0015-ispc-10_0_vXi1calling_avx512_i8_i16.patch \ 25 file://llvm10-0015-ispc-10_0_vXi1calling_avx512_i8_i16.patch \
26 file://llvm10-basic-block-sections-support.patch \
27 file://llvm10-Enable-the-call-site-info-only-for-g-optimizations.patch \
28 file://llvm10-Replace-MCTargetOptionsCommandFlags.inc-and-CommandF.patch \
26 " 29 "
27 30
28SRC_URI_LLVM12_PATCHES = " \ 31SRC_URI_LLVM12_PATCHES = " \