Coverage Report

Created: 2018-09-23 16:00

/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
24.1k
LLVM_ATTRIBUTE_UNUSED static Optional<Reloc::Model> getRelocModel() {
61
24.1k
  if (RelocModel.getNumOccurrences()) {
62
1.81k
    Reloc::Model R = RelocModel;
63
1.81k
    return R;
64
1.81k
  }
65
22.3k
  return None;
66
22.3k
}
opt.cpp:getRelocModel()
Line
Count
Source
60
3.49k
LLVM_ATTRIBUTE_UNUSED static Optional<Reloc::Model> getRelocModel() {
61
3.49k
  if (RelocModel.getNumOccurrences()) {
62
6
    Reloc::Model R = RelocModel;
63
6
    return R;
64
6
  }
65
3.48k
  return None;
66
3.48k
}
llc.cpp:getRelocModel()
Line
Count
Source
60
20.6k
LLVM_ATTRIBUTE_UNUSED static Optional<Reloc::Model> getRelocModel() {
61
20.6k
  if (RelocModel.getNumOccurrences()) {
62
1.80k
    Reloc::Model R = RelocModel;
63
1.80k
    return R;
64
1.80k
  }
65
18.8k
  return None;
66
18.8k
}
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
24.1k
LLVM_ATTRIBUTE_UNUSED static Optional<CodeModel::Model> getCodeModel() {
84
24.1k
  if (CMModel.getNumOccurrences()) {
85
192
    CodeModel::Model M = CMModel;
86
192
    return M;
87
192
  }
88
23.9k
  return None;
89
23.9k
}
opt.cpp:getCodeModel()
Line
Count
Source
83
3.49k
LLVM_ATTRIBUTE_UNUSED static Optional<CodeModel::Model> getCodeModel() {
84
3.49k
  if (CMModel.getNumOccurrences()) {
85
0
    CodeModel::Model M = CMModel;
86
0
    return M;
87
0
  }
88
3.49k
  return None;
89
3.49k
}
llc.cpp:getCodeModel()
Line
Count
Source
83
20.6k
LLVM_ATTRIBUTE_UNUSED static Optional<CodeModel::Model> getCodeModel() {
84
20.6k
  if (CMModel.getNumOccurrences()) {
85
192
    CodeModel::Model M = CMModel;
86
192
    return M;
87
192
  }
88
20.5k
  return None;
89
20.5k
}
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
29.9k
static TargetOptions InitTargetOptionsFromCodeGenFlags() {
272
29.9k
  TargetOptions Options;
273
29.9k
  Options.AllowFPOpFusion = FuseFPOps;
274
29.9k
  Options.UnsafeFPMath = EnableUnsafeFPMath;
275
29.9k
  Options.NoInfsFPMath = EnableNoInfsFPMath;
276
29.9k
  Options.NoNaNsFPMath = EnableNoNaNsFPMath;
277
29.9k
  Options.NoSignedZerosFPMath = EnableNoSignedZerosFPMath;
278
29.9k
  Options.NoTrappingFPMath = EnableNoTrappingFPMath;
279
29.9k
  Options.FPDenormalMode = DenormalMode;
280
29.9k
  Options.HonorSignDependentRoundingFPMathOption =
281
29.9k
      EnableHonorSignDependentRoundingFPMath;
282
29.9k
  if (FloatABIForCalls != FloatABI::Default)
283
107
    Options.FloatABIType = FloatABIForCalls;
284
29.9k
  Options.NoZerosInBSS = DontPlaceZerosInBSS;
285
29.9k
  Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
286
29.9k
  Options.StackAlignmentOverride = OverrideStackAlignment;
287
29.9k
  Options.StackSymbolOrdering = StackSymbolOrdering;
288
29.9k
  Options.UseInitArray = !UseCtors;
289
29.9k
  Options.RelaxELFRelocations = RelaxELFRelocations;
290
29.9k
  Options.DataSections = DataSections;
291
29.9k
  Options.FunctionSections = FunctionSections;
292
29.9k
  Options.UniqueSectionNames = UniqueSectionNames;
293
29.9k
  Options.EmulatedTLS = EmulatedTLS;
294
29.9k
  Options.ExplicitEmulatedTLS = EmulatedTLS.getNumOccurrences() > 0;
295
29.9k
  Options.ExceptionModel = ExceptionModel;
296
29.9k
  Options.EmitStackSizeSection = EnableStackSizeSection;
297
29.9k
  Options.EmitAddrsig = EnableAddrsig;
298
29.9k
299
29.9k
  Options.MCOptions = InitMCTargetOptionsFromFlags();
300
29.9k
301
29.9k
  Options.ThreadModel = TMModel;
302
29.9k
  Options.EABIVersion = EABIVersion;
303
29.9k
  Options.DebuggerTuning = DebuggerTuningOpt;
304
29.9k
305
29.9k
  return Options;
306
29.9k
}
opt.cpp:InitTargetOptionsFromCodeGenFlags()
Line
Count
Source
271
9.24k
static TargetOptions InitTargetOptionsFromCodeGenFlags() {
272
9.24k
  TargetOptions Options;
273
9.24k
  Options.AllowFPOpFusion = FuseFPOps;
274
9.24k
  Options.UnsafeFPMath = EnableUnsafeFPMath;
275
9.24k
  Options.NoInfsFPMath = EnableNoInfsFPMath;
276
9.24k
  Options.NoNaNsFPMath = EnableNoNaNsFPMath;
277
9.24k
  Options.NoSignedZerosFPMath = EnableNoSignedZerosFPMath;
278
9.24k
  Options.NoTrappingFPMath = EnableNoTrappingFPMath;
279
9.24k
  Options.FPDenormalMode = DenormalMode;
280
9.24k
  Options.HonorSignDependentRoundingFPMathOption =
281
9.24k
      EnableHonorSignDependentRoundingFPMath;
282
9.24k
  if (FloatABIForCalls != FloatABI::Default)
283
0
    Options.FloatABIType = FloatABIForCalls;
284
9.24k
  Options.NoZerosInBSS = DontPlaceZerosInBSS;
285
9.24k
  Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
286
9.24k
  Options.StackAlignmentOverride = OverrideStackAlignment;
287
9.24k
  Options.StackSymbolOrdering = StackSymbolOrdering;
288
9.24k
  Options.UseInitArray = !UseCtors;
289
9.24k
  Options.RelaxELFRelocations = RelaxELFRelocations;
290
9.24k
  Options.DataSections = DataSections;
291
9.24k
  Options.FunctionSections = FunctionSections;
292
9.24k
  Options.UniqueSectionNames = UniqueSectionNames;
293
9.24k
  Options.EmulatedTLS = EmulatedTLS;
294
9.24k
  Options.ExplicitEmulatedTLS = EmulatedTLS.getNumOccurrences() > 0;
295
9.24k
  Options.ExceptionModel = ExceptionModel;
296
9.24k
  Options.EmitStackSizeSection = EnableStackSizeSection;
297
9.24k
  Options.EmitAddrsig = EnableAddrsig;
298
9.24k
299
9.24k
  Options.MCOptions = InitMCTargetOptionsFromFlags();
300
9.24k
301
9.24k
  Options.ThreadModel = TMModel;
302
9.24k
  Options.EABIVersion = EABIVersion;
303
9.24k
  Options.DebuggerTuning = DebuggerTuningOpt;
304
9.24k
305
9.24k
  return Options;
306
9.24k
}
llc.cpp:InitTargetOptionsFromCodeGenFlags()
Line
Count
Source
271
20.6k
static TargetOptions InitTargetOptionsFromCodeGenFlags() {
272
20.6k
  TargetOptions Options;
273
20.6k
  Options.AllowFPOpFusion = FuseFPOps;
274
20.6k
  Options.UnsafeFPMath = EnableUnsafeFPMath;
275
20.6k
  Options.NoInfsFPMath = EnableNoInfsFPMath;
276
20.6k
  Options.NoNaNsFPMath = EnableNoNaNsFPMath;
277
20.6k
  Options.NoSignedZerosFPMath = EnableNoSignedZerosFPMath;
278
20.6k
  Options.NoTrappingFPMath = EnableNoTrappingFPMath;
279
20.6k
  Options.FPDenormalMode = DenormalMode;
280
20.6k
  Options.HonorSignDependentRoundingFPMathOption =
281
20.6k
      EnableHonorSignDependentRoundingFPMath;
282
20.6k
  if (FloatABIForCalls != FloatABI::Default)
283
107
    Options.FloatABIType = FloatABIForCalls;
284
20.6k
  Options.NoZerosInBSS = DontPlaceZerosInBSS;
285
20.6k
  Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
286
20.6k
  Options.StackAlignmentOverride = OverrideStackAlignment;
287
20.6k
  Options.StackSymbolOrdering = StackSymbolOrdering;
288
20.6k
  Options.UseInitArray = !UseCtors;
289
20.6k
  Options.RelaxELFRelocations = RelaxELFRelocations;
290
20.6k
  Options.DataSections = DataSections;
291
20.6k
  Options.FunctionSections = FunctionSections;
292
20.6k
  Options.UniqueSectionNames = UniqueSectionNames;
293
20.6k
  Options.EmulatedTLS = EmulatedTLS;
294
20.6k
  Options.ExplicitEmulatedTLS = EmulatedTLS.getNumOccurrences() > 0;
295
20.6k
  Options.ExceptionModel = ExceptionModel;
296
20.6k
  Options.EmitStackSizeSection = EnableStackSizeSection;
297
20.6k
  Options.EmitAddrsig = EnableAddrsig;
298
20.6k
299
20.6k
  Options.MCOptions = InitMCTargetOptionsFromFlags();
300
20.6k
301
20.6k
  Options.ThreadModel = TMModel;
302
20.6k
  Options.EABIVersion = EABIVersion;
303
20.6k
  Options.DebuggerTuning = DebuggerTuningOpt;
304
20.6k
305
20.6k
  return Options;
306
20.6k
}
307
308
24.1k
LLVM_ATTRIBUTE_UNUSED static std::string getCPUStr() {
309
24.1k
  // If user asked for the 'native' CPU, autodetect here. If autodection fails,
310
24.1k
  // this will set the CPU to an empty string which tells the target to
311
24.1k
  // pick a basic default.
312
24.1k
  if (MCPU == "native")
313
0
    return sys::getHostCPUName();
314
24.1k
315
24.1k
  return MCPU;
316
24.1k
}
opt.cpp:getCPUStr()
Line
Count
Source
308
3.49k
LLVM_ATTRIBUTE_UNUSED static std::string getCPUStr() {
309
3.49k
  // If user asked for the 'native' CPU, autodetect here. If autodection fails,
310
3.49k
  // this will set the CPU to an empty string which tells the target to
311
3.49k
  // pick a basic default.
312
3.49k
  if (MCPU == "native")
313
0
    return sys::getHostCPUName();
314
3.49k
315
3.49k
  return MCPU;
316
3.49k
}
llc.cpp:getCPUStr()
Line
Count
Source
308
20.6k
LLVM_ATTRIBUTE_UNUSED static std::string getCPUStr() {
309
20.6k
  // If user asked for the 'native' CPU, autodetect here. If autodection fails,
310
20.6k
  // this will set the CPU to an empty string which tells the target to
311
20.6k
  // pick a basic default.
312
20.6k
  if (MCPU == "native")
313
0
    return sys::getHostCPUName();
314
20.6k
315
20.6k
  return MCPU;
316
20.6k
}
317
318
24.1k
LLVM_ATTRIBUTE_UNUSED static std::string getFeaturesStr() {
319
24.1k
  SubtargetFeatures Features;
320
24.1k
321
24.1k
  // If user asked for the 'native' CPU, we need to autodetect features.
322
24.1k
  // This is necessary for x86 where the CPU might not support all the
323
24.1k
  // features the autodetected CPU name lists in the target. For example,
324
24.1k
  // not all Sandybridge processors support AVX.
325
24.1k
  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
24.1k
332
32.3k
  for (unsigned i = 0; i != MAttrs.size(); 
++i8.11k
)
333
8.11k
    Features.AddFeature(MAttrs[i]);
334
24.1k
335
24.1k
  return Features.getString();
336
24.1k
}
opt.cpp:getFeaturesStr()
Line
Count
Source
318
3.49k
LLVM_ATTRIBUTE_UNUSED static std::string getFeaturesStr() {
319
3.49k
  SubtargetFeatures Features;
320
3.49k
321
3.49k
  // If user asked for the 'native' CPU, we need to autodetect features.
322
3.49k
  // This is necessary for x86 where the CPU might not support all the
323
3.49k
  // features the autodetected CPU name lists in the target. For example,
324
3.49k
  // not all Sandybridge processors support AVX.
325
3.49k
  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.49k
332
3.93k
  for (unsigned i = 0; i != MAttrs.size(); 
++i437
)
333
437
    Features.AddFeature(MAttrs[i]);
334
3.49k
335
3.49k
  return Features.getString();
336
3.49k
}
llc.cpp:getFeaturesStr()
Line
Count
Source
318
20.6k
LLVM_ATTRIBUTE_UNUSED static std::string getFeaturesStr() {
319
20.6k
  SubtargetFeatures Features;
320
20.6k
321
20.6k
  // If user asked for the 'native' CPU, we need to autodetect features.
322
20.6k
  // This is necessary for x86 where the CPU might not support all the
323
20.6k
  // features the autodetected CPU name lists in the target. For example,
324
20.6k
  // not all Sandybridge processors support AVX.
325
20.6k
  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
20.6k
332
28.3k
  for (unsigned i = 0; i != MAttrs.size(); 
++i7.67k
)
333
7.67k
    Features.AddFeature(MAttrs[i]);
334
20.6k
335
20.6k
  return Features.getString();
336
20.6k
}
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
29.9k
setFunctionAttributes(StringRef CPU, StringRef Features, Module &M) {
362
304k
  for (auto &F : M) {
363
304k
    auto &Ctx = F.getContext();
364
304k
    AttributeList Attrs = F.getAttributes();
365
304k
    AttrBuilder NewAttrs;
366
304k
367
304k
    if (!CPU.empty())
368
88.9k
      NewAttrs.addAttribute("target-cpu", CPU);
369
304k
    if (!Features.empty())
370
128k
      NewAttrs.addAttribute("target-features", Features);
371
304k
    if (DisableFPElim.getNumOccurrences() > 0)
372
2.03k
      NewAttrs.addAttribute("no-frame-pointer-elim",
373
2.03k
                            DisableFPElim ? 
"true"2.01k
:
"false"21
);
374
304k
    if (DisableTailCalls.getNumOccurrences() > 0)
375
34
      NewAttrs.addAttribute("disable-tail-calls",
376
34
                            toStringRef(DisableTailCalls));
377
304k
    if (StackRealign)
378
84
      NewAttrs.addAttribute("stackrealign");
379
304k
380
304k
    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
304k
391
304k
    // Let NewAttrs override Attrs.
392
304k
    F.setAttributes(
393
304k
        Attrs.addAttributes(Ctx, AttributeList::FunctionIndex, NewAttrs));
394
304k
  }
395
29.9k
}
opt.cpp:setFunctionAttributes(llvm::StringRef, llvm::StringRef, llvm::Module&)
Line
Count
Source
361
9.24k
setFunctionAttributes(StringRef CPU, StringRef Features, Module &M) {
362
66.5k
  for (auto &F : M) {
363
66.5k
    auto &Ctx = F.getContext();
364
66.5k
    AttributeList Attrs = F.getAttributes();
365
66.5k
    AttrBuilder NewAttrs;
366
66.5k
367
66.5k
    if (!CPU.empty())
368
5.18k
      NewAttrs.addAttribute("target-cpu", CPU);
369
66.5k
    if (!Features.empty())
370
5.96k
      NewAttrs.addAttribute("target-features", Features);
371
66.5k
    if (DisableFPElim.getNumOccurrences() > 0)
372
0
      NewAttrs.addAttribute("no-frame-pointer-elim",
373
0
                            DisableFPElim ? "true" : "false");
374
66.5k
    if (DisableTailCalls.getNumOccurrences() > 0)
375
0
      NewAttrs.addAttribute("disable-tail-calls",
376
0
                            toStringRef(DisableTailCalls));
377
66.5k
    if (StackRealign)
378
0
      NewAttrs.addAttribute("stackrealign");
379
66.5k
380
66.5k
    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
66.5k
391
66.5k
    // Let NewAttrs override Attrs.
392
66.5k
    F.setAttributes(
393
66.5k
        Attrs.addAttributes(Ctx, AttributeList::FunctionIndex, NewAttrs));
394
66.5k
  }
395
9.24k
}
llc.cpp:setFunctionAttributes(llvm::StringRef, llvm::StringRef, llvm::Module&)
Line
Count
Source
361
20.6k
setFunctionAttributes(StringRef CPU, StringRef Features, Module &M) {
362
238k
  for (auto &F : M) {
363
238k
    auto &Ctx = F.getContext();
364
238k
    AttributeList Attrs = F.getAttributes();
365
238k
    AttrBuilder NewAttrs;
366
238k
367
238k
    if (!CPU.empty())
368
83.7k
      NewAttrs.addAttribute("target-cpu", CPU);
369
238k
    if (!Features.empty())
370
122k
      NewAttrs.addAttribute("target-features", Features);
371
238k
    if (DisableFPElim.getNumOccurrences() > 0)
372
2.03k
      NewAttrs.addAttribute("no-frame-pointer-elim",
373
2.03k
                            DisableFPElim ? 
"true"2.01k
:
"false"21
);
374
238k
    if (DisableTailCalls.getNumOccurrences() > 0)
375
34
      NewAttrs.addAttribute("disable-tail-calls",
376
34
                            toStringRef(DisableTailCalls));
377
238k
    if (StackRealign)
378
84
      NewAttrs.addAttribute("stackrealign");
379
238k
380
238k
    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
238k
391
238k
    // Let NewAttrs override Attrs.
392
238k
    F.setAttributes(
393
238k
        Attrs.addAttributes(Ctx, AttributeList::FunctionIndex, NewAttrs));
394
238k
  }
395
20.6k
}