Coverage Report

Created: 2018-11-16 02:38

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/CodeGen/CommandFlags.inc
Line
Count
Source (jump to first uncovered line)
1
//===-- CommandFlags.h - Command Line Flags Interface -----------*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file contains codegen-specific flags that are shared between different
11
// command line tools. The tools "llc" and "opt" both use this file to prevent
12
// flag duplication.
13
//
14
//===----------------------------------------------------------------------===//
15
16
#include "llvm/ADT/StringExtras.h"
17
#include "llvm/IR/Instructions.h"
18
#include "llvm/IR/Intrinsics.h"
19
#include "llvm/IR/Module.h"
20
#include "llvm/MC/MCTargetOptionsCommandFlags.inc"
21
#include "llvm/MC/SubtargetFeature.h"
22
#include "llvm/Support/CodeGen.h"
23
#include "llvm/Support/CommandLine.h"
24
#include "llvm/Support/Host.h"
25
#include "llvm/Target/TargetMachine.h"
26
#include "llvm/Target/TargetOptions.h"
27
#include <string>
28
using namespace llvm;
29
30
static cl::opt<std::string>
31
    MArch("march",
32
          cl::desc("Architecture to generate code for (see --version)"));
33
34
static cl::opt<std::string>
35
    MCPU("mcpu",
36
         cl::desc("Target a specific cpu type (-mcpu=help for details)"),
37
         cl::value_desc("cpu-name"), cl::init(""));
38
39
static cl::list<std::string>
40
    MAttrs("mattr", cl::CommaSeparated,
41
           cl::desc("Target specific attributes (-mattr=help for details)"),
42
           cl::value_desc("a1,+a2,-a3,..."));
43
44
static cl::opt<Reloc::Model> RelocModel(
45
    "relocation-model", cl::desc("Choose relocation model"),
46
    cl::values(
47
        clEnumValN(Reloc::Static, "static", "Non-relocatable code"),
48
        clEnumValN(Reloc::PIC_, "pic",
49
                   "Fully relocatable, position independent code"),
50
        clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
51
                   "Relocatable external references, non-relocatable code"),
52
        clEnumValN(Reloc::ROPI, "ropi",
53
                   "Code and read-only data relocatable, accessed PC-relative"),
54
        clEnumValN(
55
            Reloc::RWPI, "rwpi",
56
            "Read-write data relocatable, accessed relative to static base"),
57
        clEnumValN(Reloc::ROPI_RWPI, "ropi-rwpi",
58
                   "Combination of ropi and rwpi")));
59
60
25.2k
LLVM_ATTRIBUTE_UNUSED static Optional<Reloc::Model> getRelocModel() {
61
25.2k
  if (RelocModel.getNumOccurrences()) {
62
1.81k
    Reloc::Model R = RelocModel;
63
1.81k
    return R;
64
1.81k
  }
65
23.4k
  return None;
66
23.4k
}
opt.cpp:getRelocModel()
Line
Count
Source
60
3.71k
LLVM_ATTRIBUTE_UNUSED static Optional<Reloc::Model> getRelocModel() {
61
3.71k
  if (RelocModel.getNumOccurrences()) {
62
6
    Reloc::Model R = RelocModel;
63
6
    return R;
64
6
  }
65
3.71k
  return None;
66
3.71k
}
llc.cpp:getRelocModel()
Line
Count
Source
60
21.5k
LLVM_ATTRIBUTE_UNUSED static Optional<Reloc::Model> getRelocModel() {
61
21.5k
  if (RelocModel.getNumOccurrences()) {
62
1.81k
    Reloc::Model R = RelocModel;
63
1.81k
    return R;
64
1.81k
  }
65
19.7k
  return None;
66
19.7k
}
67
68
static cl::opt<ThreadModel::Model> TMModel(
69
    "thread-model", cl::desc("Choose threading model"),
70
    cl::init(ThreadModel::POSIX),
71
    cl::values(clEnumValN(ThreadModel::POSIX, "posix", "POSIX thread model"),
72
               clEnumValN(ThreadModel::Single, "single",
73
                          "Single thread model")));
74
75
static cl::opt<llvm::CodeModel::Model> CMModel(
76
    "code-model", cl::desc("Choose code model"),
77
    cl::values(clEnumValN(CodeModel::Tiny, "tiny", "Tiny code model"),
78
               clEnumValN(CodeModel::Small, "small", "Small code model"),
79
               clEnumValN(CodeModel::Kernel, "kernel", "Kernel code model"),
80
               clEnumValN(CodeModel::Medium, "medium", "Medium code model"),
81
               clEnumValN(CodeModel::Large, "large", "Large code model")));
82
83
25.2k
LLVM_ATTRIBUTE_UNUSED static Optional<CodeModel::Model> getCodeModel() {
84
25.2k
  if (CMModel.getNumOccurrences()) {
85
193
    CodeModel::Model M = CMModel;
86
193
    return M;
87
193
  }
88
25.0k
  return None;
89
25.0k
}
opt.cpp:getCodeModel()
Line
Count
Source
83
3.71k
LLVM_ATTRIBUTE_UNUSED static Optional<CodeModel::Model> getCodeModel() {
84
3.71k
  if (CMModel.getNumOccurrences()) {
85
0
    CodeModel::Model M = CMModel;
86
0
    return M;
87
0
  }
88
3.71k
  return None;
89
3.71k
}
llc.cpp:getCodeModel()
Line
Count
Source
83
21.5k
LLVM_ATTRIBUTE_UNUSED static Optional<CodeModel::Model> getCodeModel() {
84
21.5k
  if (CMModel.getNumOccurrences()) {
85
193
    CodeModel::Model M = CMModel;
86
193
    return M;
87
193
  }
88
21.3k
  return None;
89
21.3k
}
90
91
static cl::opt<llvm::ExceptionHandling> ExceptionModel(
92
    "exception-model", cl::desc("exception model"),
93
    cl::init(ExceptionHandling::None),
94
    cl::values(
95
        clEnumValN(ExceptionHandling::None, "default",
96
                   "default exception handling model"),
97
        clEnumValN(ExceptionHandling::DwarfCFI, "dwarf",
98
                   "DWARF-like CFI based exception handling"),
99
        clEnumValN(ExceptionHandling::SjLj, "sjlj", "SjLj exception handling"),
100
        clEnumValN(ExceptionHandling::ARM, "arm", "ARM EHABI exceptions"),
101
        clEnumValN(ExceptionHandling::WinEH, "wineh",
102
                   "Windows exception model"),
103
        clEnumValN(ExceptionHandling::Wasm, "wasm",
104
                   "WebAssembly exception handling")));
105
106
static cl::opt<TargetMachine::CodeGenFileType> FileType(
107
    "filetype", cl::init(TargetMachine::CGFT_AssemblyFile),
108
    cl::desc(
109
        "Choose a file type (not all types are supported by all targets):"),
110
    cl::values(clEnumValN(TargetMachine::CGFT_AssemblyFile, "asm",
111
                          "Emit an assembly ('.s') file"),
112
               clEnumValN(TargetMachine::CGFT_ObjectFile, "obj",
113
                          "Emit a native object ('.o') file"),
114
               clEnumValN(TargetMachine::CGFT_Null, "null",
115
                          "Emit nothing, for performance testing")));
116
117
static cl::opt<bool>
118
    DisableFPElim("disable-fp-elim",
119
                  cl::desc("Disable frame pointer elimination optimization"),
120
                  cl::init(false));
121
122
static cl::opt<bool> EnableUnsafeFPMath(
123
    "enable-unsafe-fp-math",
124
    cl::desc("Enable optimizations that may decrease FP precision"),
125
    cl::init(false));
126
127
static cl::opt<bool> EnableNoInfsFPMath(
128
    "enable-no-infs-fp-math",
129
    cl::desc("Enable FP math optimizations that assume no +-Infs"),
130
    cl::init(false));
131
132
static cl::opt<bool> EnableNoNaNsFPMath(
133
    "enable-no-nans-fp-math",
134
    cl::desc("Enable FP math optimizations that assume no NaNs"),
135
    cl::init(false));
136
137
static cl::opt<bool> EnableNoSignedZerosFPMath(
138
    "enable-no-signed-zeros-fp-math",
139
    cl::desc("Enable FP math optimizations that assume "
140
             "the sign of 0 is insignificant"),
141
    cl::init(false));
142
143
static cl::opt<bool>
144
    EnableNoTrappingFPMath("enable-no-trapping-fp-math",
145
                           cl::desc("Enable setting the FP exceptions build "
146
                                    "attribute not to use exceptions"),
147
                           cl::init(false));
148
149
static cl::opt<llvm::FPDenormal::DenormalMode> DenormalMode(
150
    "denormal-fp-math",
151
    cl::desc("Select which denormal numbers the code is permitted to require"),
152
    cl::init(FPDenormal::IEEE),
153
    cl::values(clEnumValN(FPDenormal::IEEE, "ieee",
154
                          "IEEE 754 denormal numbers"),
155
               clEnumValN(FPDenormal::PreserveSign, "preserve-sign",
156
                          "the sign of a  flushed-to-zero number is preserved "
157
                          "in the sign of 0"),
158
               clEnumValN(FPDenormal::PositiveZero, "positive-zero",
159
                          "denormals are flushed to positive zero")));
160
161
static cl::opt<bool> EnableHonorSignDependentRoundingFPMath(
162
    "enable-sign-dependent-rounding-fp-math", cl::Hidden,
163
    cl::desc("Force codegen to assume rounding mode can change dynamically"),
164
    cl::init(false));
165
166
static cl::opt<llvm::FloatABI::ABIType> FloatABIForCalls(
167
    "float-abi", cl::desc("Choose float ABI type"), cl::init(FloatABI::Default),
168
    cl::values(clEnumValN(FloatABI::Default, "default",
169
                          "Target default float ABI type"),
170
               clEnumValN(FloatABI::Soft, "soft",
171
                          "Soft float ABI (implied by -soft-float)"),
172
               clEnumValN(FloatABI::Hard, "hard",
173
                          "Hard float ABI (uses FP registers)")));
174
175
static cl::opt<llvm::FPOpFusion::FPOpFusionMode> FuseFPOps(
176
    "fp-contract", cl::desc("Enable aggressive formation of fused FP ops"),
177
    cl::init(FPOpFusion::Standard),
178
    cl::values(
179
        clEnumValN(FPOpFusion::Fast, "fast", "Fuse FP ops whenever profitable"),
180
        clEnumValN(FPOpFusion::Standard, "on", "Only fuse 'blessed' FP ops."),
181
        clEnumValN(FPOpFusion::Strict, "off",
182
                   "Only fuse FP ops when the result won't be affected.")));
183
184
static cl::opt<bool> DontPlaceZerosInBSS(
185
    "nozero-initialized-in-bss",
186
    cl::desc("Don't place zero-initialized symbols into bss section"),
187
    cl::init(false));
188
189
static cl::opt<bool> EnableGuaranteedTailCallOpt(
190
    "tailcallopt",
191
    cl::desc(
192
        "Turn fastcc calls into tail calls by (potentially) changing ABI."),
193
    cl::init(false));
194
195
static cl::opt<bool> DisableTailCalls("disable-tail-calls",
196
                                      cl::desc("Never emit tail calls"),
197
                                      cl::init(false));
198
199
static cl::opt<bool> StackSymbolOrdering("stack-symbol-ordering",
200
                                         cl::desc("Order local stack symbols."),
201
                                         cl::init(true));
202
203
static cl::opt<unsigned>
204
    OverrideStackAlignment("stack-alignment",
205
                           cl::desc("Override default stack alignment"),
206
                           cl::init(0));
207
208
static cl::opt<bool>
209
    StackRealign("stackrealign",
210
                 cl::desc("Force align the stack to the minimum alignment"),
211
                 cl::init(false));
212
213
static cl::opt<std::string> TrapFuncName(
214
    "trap-func", cl::Hidden,
215
    cl::desc("Emit a call to trap function rather than a trap instruction"),
216
    cl::init(""));
217
218
static cl::opt<bool> UseCtors("use-ctors",
219
                              cl::desc("Use .ctors instead of .init_array."),
220
                              cl::init(false));
221
222
static cl::opt<bool> RelaxELFRelocations(
223
    "relax-elf-relocations",
224
    cl::desc("Emit GOTPCRELX/REX_GOTPCRELX instead of GOTPCREL on x86-64 ELF"),
225
    cl::init(false));
226
227
static cl::opt<bool> DataSections("data-sections",
228
                                  cl::desc("Emit data into separate sections"),
229
                                  cl::init(false));
230
231
static cl::opt<bool>
232
    FunctionSections("function-sections",
233
                     cl::desc("Emit functions into separate sections"),
234
                     cl::init(false));
235
236
static cl::opt<bool> EmulatedTLS("emulated-tls",
237
                                 cl::desc("Use emulated TLS model"),
238
                                 cl::init(false));
239
240
static cl::opt<bool>
241
    UniqueSectionNames("unique-section-names",
242
                       cl::desc("Give unique names to every section"),
243
                       cl::init(true));
244
245
static cl::opt<llvm::EABI>
246
    EABIVersion("meabi", cl::desc("Set EABI type (default depends on triple):"),
247
                cl::init(EABI::Default),
248
                cl::values(clEnumValN(EABI::Default, "default",
249
                                      "Triple default EABI version"),
250
                           clEnumValN(EABI::EABI4, "4", "EABI version 4"),
251
                           clEnumValN(EABI::EABI5, "5", "EABI version 5"),
252
                           clEnumValN(EABI::GNU, "gnu", "EABI GNU")));
253
254
static cl::opt<DebuggerKind> DebuggerTuningOpt(
255
    "debugger-tune", cl::desc("Tune debug info for a particular debugger"),
256
    cl::init(DebuggerKind::Default),
257
    cl::values(clEnumValN(DebuggerKind::GDB, "gdb", "gdb"),
258
               clEnumValN(DebuggerKind::LLDB, "lldb", "lldb"),
259
               clEnumValN(DebuggerKind::SCE, "sce", "SCE targets (e.g. PS4)")));
260
261
static cl::opt<bool> EnableStackSizeSection(
262
    "stack-size-section",
263
    cl::desc("Emit a section containing stack size metadata"), cl::init(false));
264
265
static cl::opt<bool>
266
    EnableAddrsig("addrsig", cl::desc("Emit an address-significance table"),
267
                  cl::init(false));
268
269
// Common utility function tightly tied to the options listed here. Initializes
270
// a TargetOptions object with CodeGen flags and returns it.
271
31.0k
static TargetOptions InitTargetOptionsFromCodeGenFlags() {
272
31.0k
  TargetOptions Options;
273
31.0k
  Options.AllowFPOpFusion = FuseFPOps;
274
31.0k
  Options.UnsafeFPMath = EnableUnsafeFPMath;
275
31.0k
  Options.NoInfsFPMath = EnableNoInfsFPMath;
276
31.0k
  Options.NoNaNsFPMath = EnableNoNaNsFPMath;
277
31.0k
  Options.NoSignedZerosFPMath = EnableNoSignedZerosFPMath;
278
31.0k
  Options.NoTrappingFPMath = EnableNoTrappingFPMath;
279
31.0k
  Options.FPDenormalMode = DenormalMode;
280
31.0k
  Options.HonorSignDependentRoundingFPMathOption =
281
31.0k
      EnableHonorSignDependentRoundingFPMath;
282
31.0k
  if (FloatABIForCalls != FloatABI::Default)
283
109
    Options.FloatABIType = FloatABIForCalls;
284
31.0k
  Options.NoZerosInBSS = DontPlaceZerosInBSS;
285
31.0k
  Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
286
31.0k
  Options.StackAlignmentOverride = OverrideStackAlignment;
287
31.0k
  Options.StackSymbolOrdering = StackSymbolOrdering;
288
31.0k
  Options.UseInitArray = !UseCtors;
289
31.0k
  Options.RelaxELFRelocations = RelaxELFRelocations;
290
31.0k
  Options.DataSections = DataSections;
291
31.0k
  Options.FunctionSections = FunctionSections;
292
31.0k
  Options.UniqueSectionNames = UniqueSectionNames;
293
31.0k
  Options.EmulatedTLS = EmulatedTLS;
294
31.0k
  Options.ExplicitEmulatedTLS = EmulatedTLS.getNumOccurrences() > 0;
295
31.0k
  Options.ExceptionModel = ExceptionModel;
296
31.0k
  Options.EmitStackSizeSection = EnableStackSizeSection;
297
31.0k
  Options.EmitAddrsig = EnableAddrsig;
298
31.0k
299
31.0k
  Options.MCOptions = InitMCTargetOptionsFromFlags();
300
31.0k
301
31.0k
  Options.ThreadModel = TMModel;
302
31.0k
  Options.EABIVersion = EABIVersion;
303
31.0k
  Options.DebuggerTuning = DebuggerTuningOpt;
304
31.0k
305
31.0k
  return Options;
306
31.0k
}
opt.cpp:InitTargetOptionsFromCodeGenFlags()
Line
Count
Source
271
9.57k
static TargetOptions InitTargetOptionsFromCodeGenFlags() {
272
9.57k
  TargetOptions Options;
273
9.57k
  Options.AllowFPOpFusion = FuseFPOps;
274
9.57k
  Options.UnsafeFPMath = EnableUnsafeFPMath;
275
9.57k
  Options.NoInfsFPMath = EnableNoInfsFPMath;
276
9.57k
  Options.NoNaNsFPMath = EnableNoNaNsFPMath;
277
9.57k
  Options.NoSignedZerosFPMath = EnableNoSignedZerosFPMath;
278
9.57k
  Options.NoTrappingFPMath = EnableNoTrappingFPMath;
279
9.57k
  Options.FPDenormalMode = DenormalMode;
280
9.57k
  Options.HonorSignDependentRoundingFPMathOption =
281
9.57k
      EnableHonorSignDependentRoundingFPMath;
282
9.57k
  if (FloatABIForCalls != FloatABI::Default)
283
0
    Options.FloatABIType = FloatABIForCalls;
284
9.57k
  Options.NoZerosInBSS = DontPlaceZerosInBSS;
285
9.57k
  Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
286
9.57k
  Options.StackAlignmentOverride = OverrideStackAlignment;
287
9.57k
  Options.StackSymbolOrdering = StackSymbolOrdering;
288
9.57k
  Options.UseInitArray = !UseCtors;
289
9.57k
  Options.RelaxELFRelocations = RelaxELFRelocations;
290
9.57k
  Options.DataSections = DataSections;
291
9.57k
  Options.FunctionSections = FunctionSections;
292
9.57k
  Options.UniqueSectionNames = UniqueSectionNames;
293
9.57k
  Options.EmulatedTLS = EmulatedTLS;
294
9.57k
  Options.ExplicitEmulatedTLS = EmulatedTLS.getNumOccurrences() > 0;
295
9.57k
  Options.ExceptionModel = ExceptionModel;
296
9.57k
  Options.EmitStackSizeSection = EnableStackSizeSection;
297
9.57k
  Options.EmitAddrsig = EnableAddrsig;
298
9.57k
299
9.57k
  Options.MCOptions = InitMCTargetOptionsFromFlags();
300
9.57k
301
9.57k
  Options.ThreadModel = TMModel;
302
9.57k
  Options.EABIVersion = EABIVersion;
303
9.57k
  Options.DebuggerTuning = DebuggerTuningOpt;
304
9.57k
305
9.57k
  return Options;
306
9.57k
}
llc.cpp:InitTargetOptionsFromCodeGenFlags()
Line
Count
Source
271
21.5k
static TargetOptions InitTargetOptionsFromCodeGenFlags() {
272
21.5k
  TargetOptions Options;
273
21.5k
  Options.AllowFPOpFusion = FuseFPOps;
274
21.5k
  Options.UnsafeFPMath = EnableUnsafeFPMath;
275
21.5k
  Options.NoInfsFPMath = EnableNoInfsFPMath;
276
21.5k
  Options.NoNaNsFPMath = EnableNoNaNsFPMath;
277
21.5k
  Options.NoSignedZerosFPMath = EnableNoSignedZerosFPMath;
278
21.5k
  Options.NoTrappingFPMath = EnableNoTrappingFPMath;
279
21.5k
  Options.FPDenormalMode = DenormalMode;
280
21.5k
  Options.HonorSignDependentRoundingFPMathOption =
281
21.5k
      EnableHonorSignDependentRoundingFPMath;
282
21.5k
  if (FloatABIForCalls != FloatABI::Default)
283
109
    Options.FloatABIType = FloatABIForCalls;
284
21.5k
  Options.NoZerosInBSS = DontPlaceZerosInBSS;
285
21.5k
  Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
286
21.5k
  Options.StackAlignmentOverride = OverrideStackAlignment;
287
21.5k
  Options.StackSymbolOrdering = StackSymbolOrdering;
288
21.5k
  Options.UseInitArray = !UseCtors;
289
21.5k
  Options.RelaxELFRelocations = RelaxELFRelocations;
290
21.5k
  Options.DataSections = DataSections;
291
21.5k
  Options.FunctionSections = FunctionSections;
292
21.5k
  Options.UniqueSectionNames = UniqueSectionNames;
293
21.5k
  Options.EmulatedTLS = EmulatedTLS;
294
21.5k
  Options.ExplicitEmulatedTLS = EmulatedTLS.getNumOccurrences() > 0;
295
21.5k
  Options.ExceptionModel = ExceptionModel;
296
21.5k
  Options.EmitStackSizeSection = EnableStackSizeSection;
297
21.5k
  Options.EmitAddrsig = EnableAddrsig;
298
21.5k
299
21.5k
  Options.MCOptions = InitMCTargetOptionsFromFlags();
300
21.5k
301
21.5k
  Options.ThreadModel = TMModel;
302
21.5k
  Options.EABIVersion = EABIVersion;
303
21.5k
  Options.DebuggerTuning = DebuggerTuningOpt;
304
21.5k
305
21.5k
  return Options;
306
21.5k
}
307
308
25.2k
LLVM_ATTRIBUTE_UNUSED static std::string getCPUStr() {
309
25.2k
  // If user asked for the 'native' CPU, autodetect here. If autodection fails,
310
25.2k
  // this will set the CPU to an empty string which tells the target to
311
25.2k
  // pick a basic default.
312
25.2k
  if (MCPU == "native")
313
0
    return sys::getHostCPUName();
314
25.2k
315
25.2k
  return MCPU;
316
25.2k
}
opt.cpp:getCPUStr()
Line
Count
Source
308
3.72k
LLVM_ATTRIBUTE_UNUSED static std::string getCPUStr() {
309
3.72k
  // If user asked for the 'native' CPU, autodetect here. If autodection fails,
310
3.72k
  // this will set the CPU to an empty string which tells the target to
311
3.72k
  // pick a basic default.
312
3.72k
  if (MCPU == "native")
313
0
    return sys::getHostCPUName();
314
3.72k
315
3.72k
  return MCPU;
316
3.72k
}
llc.cpp:getCPUStr()
Line
Count
Source
308
21.5k
LLVM_ATTRIBUTE_UNUSED static std::string getCPUStr() {
309
21.5k
  // If user asked for the 'native' CPU, autodetect here. If autodection fails,
310
21.5k
  // this will set the CPU to an empty string which tells the target to
311
21.5k
  // pick a basic default.
312
21.5k
  if (MCPU == "native")
313
0
    return sys::getHostCPUName();
314
21.5k
315
21.5k
  return MCPU;
316
21.5k
}
317
318
25.2k
LLVM_ATTRIBUTE_UNUSED static std::string getFeaturesStr() {
319
25.2k
  SubtargetFeatures Features;
320
25.2k
321
25.2k
  // If user asked for the 'native' CPU, we need to autodetect features.
322
25.2k
  // This is necessary for x86 where the CPU might not support all the
323
25.2k
  // features the autodetected CPU name lists in the target. For example,
324
25.2k
  // not all Sandybridge processors support AVX.
325
25.2k
  if (MCPU == "native") {
326
0
    StringMap<bool> HostFeatures;
327
0
    if (sys::getHostCPUFeatures(HostFeatures))
328
0
      for (auto &F : HostFeatures)
329
0
        Features.AddFeature(F.first(), F.second);
330
0
  }
331
25.2k
332
34.0k
  for (unsigned i = 0; i != MAttrs.size(); 
++i8.82k
)
333
8.82k
    Features.AddFeature(MAttrs[i]);
334
25.2k
335
25.2k
  return Features.getString();
336
25.2k
}
opt.cpp:getFeaturesStr()
Line
Count
Source
318
3.72k
LLVM_ATTRIBUTE_UNUSED static std::string getFeaturesStr() {
319
3.72k
  SubtargetFeatures Features;
320
3.72k
321
3.72k
  // If user asked for the 'native' CPU, we need to autodetect features.
322
3.72k
  // This is necessary for x86 where the CPU might not support all the
323
3.72k
  // features the autodetected CPU name lists in the target. For example,
324
3.72k
  // not all Sandybridge processors support AVX.
325
3.72k
  if (MCPU == "native") {
326
0
    StringMap<bool> HostFeatures;
327
0
    if (sys::getHostCPUFeatures(HostFeatures))
328
0
      for (auto &F : HostFeatures)
329
0
        Features.AddFeature(F.first(), F.second);
330
0
  }
331
3.72k
332
4.30k
  for (unsigned i = 0; i != MAttrs.size(); 
++i578
)
333
578
    Features.AddFeature(MAttrs[i]);
334
3.72k
335
3.72k
  return Features.getString();
336
3.72k
}
llc.cpp:getFeaturesStr()
Line
Count
Source
318
21.5k
LLVM_ATTRIBUTE_UNUSED static std::string getFeaturesStr() {
319
21.5k
  SubtargetFeatures Features;
320
21.5k
321
21.5k
  // If user asked for the 'native' CPU, we need to autodetect features.
322
21.5k
  // This is necessary for x86 where the CPU might not support all the
323
21.5k
  // features the autodetected CPU name lists in the target. For example,
324
21.5k
  // not all Sandybridge processors support AVX.
325
21.5k
  if (MCPU == "native") {
326
0
    StringMap<bool> HostFeatures;
327
0
    if (sys::getHostCPUFeatures(HostFeatures))
328
0
      for (auto &F : HostFeatures)
329
0
        Features.AddFeature(F.first(), F.second);
330
0
  }
331
21.5k
332
29.7k
  for (unsigned i = 0; i != MAttrs.size(); 
++i8.24k
)
333
8.24k
    Features.AddFeature(MAttrs[i]);
334
21.5k
335
21.5k
  return Features.getString();
336
21.5k
}
337
338
0
LLVM_ATTRIBUTE_UNUSED static std::vector<std::string> getFeatureList() {
339
0
  SubtargetFeatures Features;
340
0
341
0
  // If user asked for the 'native' CPU, we need to autodetect features.
342
0
  // This is necessary for x86 where the CPU might not support all the
343
0
  // features the autodetected CPU name lists in the target. For example,
344
0
  // not all Sandybridge processors support AVX.
345
0
  if (MCPU == "native") {
346
0
    StringMap<bool> HostFeatures;
347
0
    if (sys::getHostCPUFeatures(HostFeatures))
348
0
      for (auto &F : HostFeatures)
349
0
        Features.AddFeature(F.first(), F.second);
350
0
  }
351
0
352
0
  for (unsigned i = 0; i != MAttrs.size(); ++i)
353
0
    Features.AddFeature(MAttrs[i]);
354
0
355
0
  return Features.getFeatures();
356
0
}
Unexecuted instantiation: opt.cpp:getFeatureList()
Unexecuted instantiation: llc.cpp:getFeatureList()
357
358
/// Set function attributes of functions in Module M based on CPU,
359
/// Features, and command line flags.
360
LLVM_ATTRIBUTE_UNUSED static void
361
31.0k
setFunctionAttributes(StringRef CPU, StringRef Features, Module &M) {
362
323k
  for (auto &F : M) {
363
323k
    auto &Ctx = F.getContext();
364
323k
    AttributeList Attrs = F.getAttributes();
365
323k
    AttrBuilder NewAttrs;
366
323k
367
323k
    if (!CPU.empty())
368
92.4k
      NewAttrs.addAttribute("target-cpu", CPU);
369
323k
    if (!Features.empty())
370
142k
      NewAttrs.addAttribute("target-features", Features);
371
323k
    if (DisableFPElim.getNumOccurrences() > 0)
372
2.05k
      NewAttrs.addAttribute("no-frame-pointer-elim",
373
2.05k
                            DisableFPElim ? 
"true"2.03k
:
"false"21
);
374
323k
    if (DisableTailCalls.getNumOccurrences() > 0)
375
36
      NewAttrs.addAttribute("disable-tail-calls",
376
36
                            toStringRef(DisableTailCalls));
377
323k
    if (StackRealign)
378
84
      NewAttrs.addAttribute("stackrealign");
379
323k
380
323k
    if (TrapFuncName.getNumOccurrences() > 0)
381
12
      for (auto &B : F)
382
7
        for (auto &I : B)
383
14
          if (auto *Call = dyn_cast<CallInst>(&I))
384
7
            if (const auto *F = Call->getCalledFunction())
385
7
              if (F->getIntrinsicID() == Intrinsic::debugtrap ||
386
7
                  
F->getIntrinsicID() == Intrinsic::trap5
)
387
7
                Call->addAttribute(
388
7
                    llvm::AttributeList::FunctionIndex,
389
7
                    Attribute::get(Ctx, "trap-func-name", TrapFuncName));
390
323k
391
323k
    // Let NewAttrs override Attrs.
392
323k
    F.setAttributes(
393
323k
        Attrs.addAttributes(Ctx, AttributeList::FunctionIndex, NewAttrs));
394
323k
  }
395
31.0k
}
opt.cpp:setFunctionAttributes(llvm::StringRef, llvm::StringRef, llvm::Module&)
Line
Count
Source
361
9.57k
setFunctionAttributes(StringRef CPU, StringRef Features, Module &M) {
362
71.1k
  for (auto &F : M) {
363
71.1k
    auto &Ctx = F.getContext();
364
71.1k
    AttributeList Attrs = F.getAttributes();
365
71.1k
    AttrBuilder NewAttrs;
366
71.1k
367
71.1k
    if (!CPU.empty())
368
5.79k
      NewAttrs.addAttribute("target-cpu", CPU);
369
71.1k
    if (!Features.empty())
370
8.65k
      NewAttrs.addAttribute("target-features", Features);
371
71.1k
    if (DisableFPElim.getNumOccurrences() > 0)
372
0
      NewAttrs.addAttribute("no-frame-pointer-elim",
373
0
                            DisableFPElim ? "true" : "false");
374
71.1k
    if (DisableTailCalls.getNumOccurrences() > 0)
375
0
      NewAttrs.addAttribute("disable-tail-calls",
376
0
                            toStringRef(DisableTailCalls));
377
71.1k
    if (StackRealign)
378
0
      NewAttrs.addAttribute("stackrealign");
379
71.1k
380
71.1k
    if (TrapFuncName.getNumOccurrences() > 0)
381
0
      for (auto &B : F)
382
0
        for (auto &I : B)
383
0
          if (auto *Call = dyn_cast<CallInst>(&I))
384
0
            if (const auto *F = Call->getCalledFunction())
385
0
              if (F->getIntrinsicID() == Intrinsic::debugtrap ||
386
0
                  F->getIntrinsicID() == Intrinsic::trap)
387
0
                Call->addAttribute(
388
0
                    llvm::AttributeList::FunctionIndex,
389
0
                    Attribute::get(Ctx, "trap-func-name", TrapFuncName));
390
71.1k
391
71.1k
    // Let NewAttrs override Attrs.
392
71.1k
    F.setAttributes(
393
71.1k
        Attrs.addAttributes(Ctx, AttributeList::FunctionIndex, NewAttrs));
394
71.1k
  }
395
9.57k
}
llc.cpp:setFunctionAttributes(llvm::StringRef, llvm::StringRef, llvm::Module&)
Line
Count
Source
361
21.4k
setFunctionAttributes(StringRef CPU, StringRef Features, Module &M) {
362
252k
  for (auto &F : M) {
363
252k
    auto &Ctx = F.getContext();
364
252k
    AttributeList Attrs = F.getAttributes();
365
252k
    AttrBuilder NewAttrs;
366
252k
367
252k
    if (!CPU.empty())
368
86.6k
      NewAttrs.addAttribute("target-cpu", CPU);
369
252k
    if (!Features.empty())
370
133k
      NewAttrs.addAttribute("target-features", Features);
371
252k
    if (DisableFPElim.getNumOccurrences() > 0)
372
2.05k
      NewAttrs.addAttribute("no-frame-pointer-elim",
373
2.05k
                            DisableFPElim ? 
"true"2.03k
:
"false"21
);
374
252k
    if (DisableTailCalls.getNumOccurrences() > 0)
375
36
      NewAttrs.addAttribute("disable-tail-calls",
376
36
                            toStringRef(DisableTailCalls));
377
252k
    if (StackRealign)
378
84
      NewAttrs.addAttribute("stackrealign");
379
252k
380
252k
    if (TrapFuncName.getNumOccurrences() > 0)
381
12
      for (auto &B : F)
382
7
        for (auto &I : B)
383
14
          if (auto *Call = dyn_cast<CallInst>(&I))
384
7
            if (const auto *F = Call->getCalledFunction())
385
7
              if (F->getIntrinsicID() == Intrinsic::debugtrap ||
386
7
                  
F->getIntrinsicID() == Intrinsic::trap5
)
387
7
                Call->addAttribute(
388
7
                    llvm::AttributeList::FunctionIndex,
389
7
                    Attribute::get(Ctx, "trap-func-name", TrapFuncName));
390
252k
391
252k
    // Let NewAttrs override Attrs.
392
252k
    F.setAttributes(
393
252k
        Attrs.addAttributes(Ctx, AttributeList::FunctionIndex, NewAttrs));
394
252k
  }
395
21.4k
}