Coverage Report

Created: 2018-07-19 03:59

/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
23.4k
LLVM_ATTRIBUTE_UNUSED static Optional<Reloc::Model> getRelocModel() {
61
23.4k
  if (RelocModel.getNumOccurrences()) {
62
1.78k
    Reloc::Model R = RelocModel;
63
1.78k
    return R;
64
1.78k
  }
65
21.6k
  return None;
66
21.6k
}
opt.cpp:getRelocModel()
Line
Count
Source
60
3.38k
LLVM_ATTRIBUTE_UNUSED static Optional<Reloc::Model> getRelocModel() {
61
3.38k
  if (RelocModel.getNumOccurrences()) {
62
6
    Reloc::Model R = RelocModel;
63
6
    return R;
64
6
  }
65
3.38k
  return None;
66
3.38k
}
llc.cpp:getRelocModel()
Line
Count
Source
60
20.0k
LLVM_ATTRIBUTE_UNUSED static Optional<Reloc::Model> getRelocModel() {
61
20.0k
  if (RelocModel.getNumOccurrences()) {
62
1.77k
    Reloc::Model R = RelocModel;
63
1.77k
    return R;
64
1.77k
  }
65
18.3k
  return None;
66
18.3k
}
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::Small, "small", "Small code model"),
78
               clEnumValN(CodeModel::Kernel, "kernel", "Kernel code model"),
79
               clEnumValN(CodeModel::Medium, "medium", "Medium code model"),
80
               clEnumValN(CodeModel::Large, "large", "Large code model")));
81
82
23.4k
LLVM_ATTRIBUTE_UNUSED static Optional<CodeModel::Model> getCodeModel() {
83
23.4k
  if (CMModel.getNumOccurrences()) {
84
154
    CodeModel::Model M = CMModel;
85
154
    return M;
86
154
  }
87
23.3k
  return None;
88
23.3k
}
opt.cpp:getCodeModel()
Line
Count
Source
82
3.38k
LLVM_ATTRIBUTE_UNUSED static Optional<CodeModel::Model> getCodeModel() {
83
3.38k
  if (CMModel.getNumOccurrences()) {
84
0
    CodeModel::Model M = CMModel;
85
0
    return M;
86
0
  }
87
3.38k
  return None;
88
3.38k
}
llc.cpp:getCodeModel()
Line
Count
Source
82
20.0k
LLVM_ATTRIBUTE_UNUSED static Optional<CodeModel::Model> getCodeModel() {
83
20.0k
  if (CMModel.getNumOccurrences()) {
84
154
    CodeModel::Model M = CMModel;
85
154
    return M;
86
154
  }
87
19.9k
  return None;
88
19.9k
}
89
90
static cl::opt<llvm::ExceptionHandling> ExceptionModel(
91
    "exception-model", cl::desc("exception model"),
92
    cl::init(ExceptionHandling::None),
93
    cl::values(
94
        clEnumValN(ExceptionHandling::None, "default",
95
                   "default exception handling model"),
96
        clEnumValN(ExceptionHandling::DwarfCFI, "dwarf",
97
                   "DWARF-like CFI based exception handling"),
98
        clEnumValN(ExceptionHandling::SjLj, "sjlj", "SjLj exception handling"),
99
        clEnumValN(ExceptionHandling::ARM, "arm", "ARM EHABI exceptions"),
100
        clEnumValN(ExceptionHandling::WinEH, "wineh",
101
                   "Windows exception model"),
102
        clEnumValN(ExceptionHandling::Wasm, "wasm",
103
                   "WebAssembly exception handling")));
104
105
static cl::opt<TargetMachine::CodeGenFileType> FileType(
106
    "filetype", cl::init(TargetMachine::CGFT_AssemblyFile),
107
    cl::desc(
108
        "Choose a file type (not all types are supported by all targets):"),
109
    cl::values(clEnumValN(TargetMachine::CGFT_AssemblyFile, "asm",
110
                          "Emit an assembly ('.s') file"),
111
               clEnumValN(TargetMachine::CGFT_ObjectFile, "obj",
112
                          "Emit a native object ('.o') file"),
113
               clEnumValN(TargetMachine::CGFT_Null, "null",
114
                          "Emit nothing, for performance testing")));
115
116
static cl::opt<bool>
117
    DisableFPElim("disable-fp-elim",
118
                  cl::desc("Disable frame pointer elimination optimization"),
119
                  cl::init(false));
120
121
static cl::opt<bool> EnableUnsafeFPMath(
122
    "enable-unsafe-fp-math",
123
    cl::desc("Enable optimizations that may decrease FP precision"),
124
    cl::init(false));
125
126
static cl::opt<bool> EnableNoInfsFPMath(
127
    "enable-no-infs-fp-math",
128
    cl::desc("Enable FP math optimizations that assume no +-Infs"),
129
    cl::init(false));
130
131
static cl::opt<bool> EnableNoNaNsFPMath(
132
    "enable-no-nans-fp-math",
133
    cl::desc("Enable FP math optimizations that assume no NaNs"),
134
    cl::init(false));
135
136
static cl::opt<bool> EnableNoSignedZerosFPMath(
137
    "enable-no-signed-zeros-fp-math",
138
    cl::desc("Enable FP math optimizations that assume "
139
             "the sign of 0 is insignificant"),
140
    cl::init(false));
141
142
static cl::opt<bool>
143
    EnableNoTrappingFPMath("enable-no-trapping-fp-math",
144
                           cl::desc("Enable setting the FP exceptions build "
145
                                    "attribute not to use exceptions"),
146
                           cl::init(false));
147
148
static cl::opt<llvm::FPDenormal::DenormalMode> DenormalMode(
149
    "denormal-fp-math",
150
    cl::desc("Select which denormal numbers the code is permitted to require"),
151
    cl::init(FPDenormal::IEEE),
152
    cl::values(clEnumValN(FPDenormal::IEEE, "ieee",
153
                          "IEEE 754 denormal numbers"),
154
               clEnumValN(FPDenormal::PreserveSign, "preserve-sign",
155
                          "the sign of a  flushed-to-zero number is preserved "
156
                          "in the sign of 0"),
157
               clEnumValN(FPDenormal::PositiveZero, "positive-zero",
158
                          "denormals are flushed to positive zero")));
159
160
static cl::opt<bool> EnableHonorSignDependentRoundingFPMath(
161
    "enable-sign-dependent-rounding-fp-math", cl::Hidden,
162
    cl::desc("Force codegen to assume rounding mode can change dynamically"),
163
    cl::init(false));
164
165
static cl::opt<llvm::FloatABI::ABIType> FloatABIForCalls(
166
    "float-abi", cl::desc("Choose float ABI type"), cl::init(FloatABI::Default),
167
    cl::values(clEnumValN(FloatABI::Default, "default",
168
                          "Target default float ABI type"),
169
               clEnumValN(FloatABI::Soft, "soft",
170
                          "Soft float ABI (implied by -soft-float)"),
171
               clEnumValN(FloatABI::Hard, "hard",
172
                          "Hard float ABI (uses FP registers)")));
173
174
static cl::opt<llvm::FPOpFusion::FPOpFusionMode> FuseFPOps(
175
    "fp-contract", cl::desc("Enable aggressive formation of fused FP ops"),
176
    cl::init(FPOpFusion::Standard),
177
    cl::values(
178
        clEnumValN(FPOpFusion::Fast, "fast", "Fuse FP ops whenever profitable"),
179
        clEnumValN(FPOpFusion::Standard, "on", "Only fuse 'blessed' FP ops."),
180
        clEnumValN(FPOpFusion::Strict, "off",
181
                   "Only fuse FP ops when the result won't be affected.")));
182
183
static cl::opt<bool> DontPlaceZerosInBSS(
184
    "nozero-initialized-in-bss",
185
    cl::desc("Don't place zero-initialized symbols into bss section"),
186
    cl::init(false));
187
188
static cl::opt<bool> EnableGuaranteedTailCallOpt(
189
    "tailcallopt",
190
    cl::desc(
191
        "Turn fastcc calls into tail calls by (potentially) changing ABI."),
192
    cl::init(false));
193
194
static cl::opt<bool> DisableTailCalls("disable-tail-calls",
195
                                      cl::desc("Never emit tail calls"),
196
                                      cl::init(false));
197
198
static cl::opt<bool> StackSymbolOrdering("stack-symbol-ordering",
199
                                         cl::desc("Order local stack symbols."),
200
                                         cl::init(true));
201
202
static cl::opt<unsigned>
203
    OverrideStackAlignment("stack-alignment",
204
                           cl::desc("Override default stack alignment"),
205
                           cl::init(0));
206
207
static cl::opt<bool>
208
    StackRealign("stackrealign",
209
                 cl::desc("Force align the stack to the minimum alignment"),
210
                 cl::init(false));
211
212
static cl::opt<std::string> TrapFuncName(
213
    "trap-func", cl::Hidden,
214
    cl::desc("Emit a call to trap function rather than a trap instruction"),
215
    cl::init(""));
216
217
static cl::opt<bool> UseCtors("use-ctors",
218
                              cl::desc("Use .ctors instead of .init_array."),
219
                              cl::init(false));
220
221
static cl::opt<bool> RelaxELFRelocations(
222
    "relax-elf-relocations",
223
    cl::desc("Emit GOTPCRELX/REX_GOTPCRELX instead of GOTPCREL on x86-64 ELF"),
224
    cl::init(false));
225
226
static cl::opt<bool> DataSections("data-sections",
227
                                  cl::desc("Emit data into separate sections"),
228
                                  cl::init(false));
229
230
static cl::opt<bool>
231
    FunctionSections("function-sections",
232
                     cl::desc("Emit functions into separate sections"),
233
                     cl::init(false));
234
235
static cl::opt<bool> EmulatedTLS("emulated-tls",
236
                                 cl::desc("Use emulated TLS model"),
237
                                 cl::init(false));
238
239
static cl::opt<bool>
240
    UniqueSectionNames("unique-section-names",
241
                       cl::desc("Give unique names to every section"),
242
                       cl::init(true));
243
244
static cl::opt<llvm::EABI>
245
    EABIVersion("meabi", cl::desc("Set EABI type (default depends on triple):"),
246
                cl::init(EABI::Default),
247
                cl::values(clEnumValN(EABI::Default, "default",
248
                                      "Triple default EABI version"),
249
                           clEnumValN(EABI::EABI4, "4", "EABI version 4"),
250
                           clEnumValN(EABI::EABI5, "5", "EABI version 5"),
251
                           clEnumValN(EABI::GNU, "gnu", "EABI GNU")));
252
253
static cl::opt<DebuggerKind> DebuggerTuningOpt(
254
    "debugger-tune", cl::desc("Tune debug info for a particular debugger"),
255
    cl::init(DebuggerKind::Default),
256
    cl::values(clEnumValN(DebuggerKind::GDB, "gdb", "gdb"),
257
               clEnumValN(DebuggerKind::LLDB, "lldb", "lldb"),
258
               clEnumValN(DebuggerKind::SCE, "sce", "SCE targets (e.g. PS4)")));
259
260
static cl::opt<bool> EnableStackSizeSection(
261
    "stack-size-section",
262
    cl::desc("Emit a section containing stack size metadata"), cl::init(false));
263
264
static cl::opt<bool>
265
    EnableAddrsig("addrsig", cl::desc("Emit an address-significance table"),
266
                  cl::init(false));
267
268
// Common utility function tightly tied to the options listed here. Initializes
269
// a TargetOptions object with CodeGen flags and returns it.
270
29.0k
static TargetOptions InitTargetOptionsFromCodeGenFlags() {
271
29.0k
  TargetOptions Options;
272
29.0k
  Options.AllowFPOpFusion = FuseFPOps;
273
29.0k
  Options.UnsafeFPMath = EnableUnsafeFPMath;
274
29.0k
  Options.NoInfsFPMath = EnableNoInfsFPMath;
275
29.0k
  Options.NoNaNsFPMath = EnableNoNaNsFPMath;
276
29.0k
  Options.NoSignedZerosFPMath = EnableNoSignedZerosFPMath;
277
29.0k
  Options.NoTrappingFPMath = EnableNoTrappingFPMath;
278
29.0k
  Options.FPDenormalMode = DenormalMode;
279
29.0k
  Options.HonorSignDependentRoundingFPMathOption =
280
29.0k
      EnableHonorSignDependentRoundingFPMath;
281
29.0k
  if (FloatABIForCalls != FloatABI::Default)
282
104
    Options.FloatABIType = FloatABIForCalls;
283
29.0k
  Options.NoZerosInBSS = DontPlaceZerosInBSS;
284
29.0k
  Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
285
29.0k
  Options.StackAlignmentOverride = OverrideStackAlignment;
286
29.0k
  Options.StackSymbolOrdering = StackSymbolOrdering;
287
29.0k
  Options.UseInitArray = !UseCtors;
288
29.0k
  Options.RelaxELFRelocations = RelaxELFRelocations;
289
29.0k
  Options.DataSections = DataSections;
290
29.0k
  Options.FunctionSections = FunctionSections;
291
29.0k
  Options.UniqueSectionNames = UniqueSectionNames;
292
29.0k
  Options.EmulatedTLS = EmulatedTLS;
293
29.0k
  Options.ExplicitEmulatedTLS = EmulatedTLS.getNumOccurrences() > 0;
294
29.0k
  Options.ExceptionModel = ExceptionModel;
295
29.0k
  Options.EmitStackSizeSection = EnableStackSizeSection;
296
29.0k
  Options.EmitAddrsig = EnableAddrsig;
297
29.0k
298
29.0k
  Options.MCOptions = InitMCTargetOptionsFromFlags();
299
29.0k
300
29.0k
  Options.ThreadModel = TMModel;
301
29.0k
  Options.EABIVersion = EABIVersion;
302
29.0k
  Options.DebuggerTuning = DebuggerTuningOpt;
303
29.0k
304
29.0k
  return Options;
305
29.0k
}
opt.cpp:InitTargetOptionsFromCodeGenFlags()
Line
Count
Source
270
9.00k
static TargetOptions InitTargetOptionsFromCodeGenFlags() {
271
9.00k
  TargetOptions Options;
272
9.00k
  Options.AllowFPOpFusion = FuseFPOps;
273
9.00k
  Options.UnsafeFPMath = EnableUnsafeFPMath;
274
9.00k
  Options.NoInfsFPMath = EnableNoInfsFPMath;
275
9.00k
  Options.NoNaNsFPMath = EnableNoNaNsFPMath;
276
9.00k
  Options.NoSignedZerosFPMath = EnableNoSignedZerosFPMath;
277
9.00k
  Options.NoTrappingFPMath = EnableNoTrappingFPMath;
278
9.00k
  Options.FPDenormalMode = DenormalMode;
279
9.00k
  Options.HonorSignDependentRoundingFPMathOption =
280
9.00k
      EnableHonorSignDependentRoundingFPMath;
281
9.00k
  if (FloatABIForCalls != FloatABI::Default)
282
0
    Options.FloatABIType = FloatABIForCalls;
283
9.00k
  Options.NoZerosInBSS = DontPlaceZerosInBSS;
284
9.00k
  Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
285
9.00k
  Options.StackAlignmentOverride = OverrideStackAlignment;
286
9.00k
  Options.StackSymbolOrdering = StackSymbolOrdering;
287
9.00k
  Options.UseInitArray = !UseCtors;
288
9.00k
  Options.RelaxELFRelocations = RelaxELFRelocations;
289
9.00k
  Options.DataSections = DataSections;
290
9.00k
  Options.FunctionSections = FunctionSections;
291
9.00k
  Options.UniqueSectionNames = UniqueSectionNames;
292
9.00k
  Options.EmulatedTLS = EmulatedTLS;
293
9.00k
  Options.ExplicitEmulatedTLS = EmulatedTLS.getNumOccurrences() > 0;
294
9.00k
  Options.ExceptionModel = ExceptionModel;
295
9.00k
  Options.EmitStackSizeSection = EnableStackSizeSection;
296
9.00k
  Options.EmitAddrsig = EnableAddrsig;
297
9.00k
298
9.00k
  Options.MCOptions = InitMCTargetOptionsFromFlags();
299
9.00k
300
9.00k
  Options.ThreadModel = TMModel;
301
9.00k
  Options.EABIVersion = EABIVersion;
302
9.00k
  Options.DebuggerTuning = DebuggerTuningOpt;
303
9.00k
304
9.00k
  return Options;
305
9.00k
}
llc.cpp:InitTargetOptionsFromCodeGenFlags()
Line
Count
Source
270
20.0k
static TargetOptions InitTargetOptionsFromCodeGenFlags() {
271
20.0k
  TargetOptions Options;
272
20.0k
  Options.AllowFPOpFusion = FuseFPOps;
273
20.0k
  Options.UnsafeFPMath = EnableUnsafeFPMath;
274
20.0k
  Options.NoInfsFPMath = EnableNoInfsFPMath;
275
20.0k
  Options.NoNaNsFPMath = EnableNoNaNsFPMath;
276
20.0k
  Options.NoSignedZerosFPMath = EnableNoSignedZerosFPMath;
277
20.0k
  Options.NoTrappingFPMath = EnableNoTrappingFPMath;
278
20.0k
  Options.FPDenormalMode = DenormalMode;
279
20.0k
  Options.HonorSignDependentRoundingFPMathOption =
280
20.0k
      EnableHonorSignDependentRoundingFPMath;
281
20.0k
  if (FloatABIForCalls != FloatABI::Default)
282
104
    Options.FloatABIType = FloatABIForCalls;
283
20.0k
  Options.NoZerosInBSS = DontPlaceZerosInBSS;
284
20.0k
  Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
285
20.0k
  Options.StackAlignmentOverride = OverrideStackAlignment;
286
20.0k
  Options.StackSymbolOrdering = StackSymbolOrdering;
287
20.0k
  Options.UseInitArray = !UseCtors;
288
20.0k
  Options.RelaxELFRelocations = RelaxELFRelocations;
289
20.0k
  Options.DataSections = DataSections;
290
20.0k
  Options.FunctionSections = FunctionSections;
291
20.0k
  Options.UniqueSectionNames = UniqueSectionNames;
292
20.0k
  Options.EmulatedTLS = EmulatedTLS;
293
20.0k
  Options.ExplicitEmulatedTLS = EmulatedTLS.getNumOccurrences() > 0;
294
20.0k
  Options.ExceptionModel = ExceptionModel;
295
20.0k
  Options.EmitStackSizeSection = EnableStackSizeSection;
296
20.0k
  Options.EmitAddrsig = EnableAddrsig;
297
20.0k
298
20.0k
  Options.MCOptions = InitMCTargetOptionsFromFlags();
299
20.0k
300
20.0k
  Options.ThreadModel = TMModel;
301
20.0k
  Options.EABIVersion = EABIVersion;
302
20.0k
  Options.DebuggerTuning = DebuggerTuningOpt;
303
20.0k
304
20.0k
  return Options;
305
20.0k
}
306
307
23.4k
LLVM_ATTRIBUTE_UNUSED static std::string getCPUStr() {
308
23.4k
  // If user asked for the 'native' CPU, autodetect here. If autodection fails,
309
23.4k
  // this will set the CPU to an empty string which tells the target to
310
23.4k
  // pick a basic default.
311
23.4k
  if (MCPU == "native")
312
0
    return sys::getHostCPUName();
313
23.4k
314
23.4k
  return MCPU;
315
23.4k
}
opt.cpp:getCPUStr()
Line
Count
Source
307
3.39k
LLVM_ATTRIBUTE_UNUSED static std::string getCPUStr() {
308
3.39k
  // If user asked for the 'native' CPU, autodetect here. If autodection fails,
309
3.39k
  // this will set the CPU to an empty string which tells the target to
310
3.39k
  // pick a basic default.
311
3.39k
  if (MCPU == "native")
312
0
    return sys::getHostCPUName();
313
3.39k
314
3.39k
  return MCPU;
315
3.39k
}
llc.cpp:getCPUStr()
Line
Count
Source
307
20.0k
LLVM_ATTRIBUTE_UNUSED static std::string getCPUStr() {
308
20.0k
  // If user asked for the 'native' CPU, autodetect here. If autodection fails,
309
20.0k
  // this will set the CPU to an empty string which tells the target to
310
20.0k
  // pick a basic default.
311
20.0k
  if (MCPU == "native")
312
0
    return sys::getHostCPUName();
313
20.0k
314
20.0k
  return MCPU;
315
20.0k
}
316
317
23.4k
LLVM_ATTRIBUTE_UNUSED static std::string getFeaturesStr() {
318
23.4k
  SubtargetFeatures Features;
319
23.4k
320
23.4k
  // If user asked for the 'native' CPU, we need to autodetect features.
321
23.4k
  // This is necessary for x86 where the CPU might not support all the
322
23.4k
  // features the autodetected CPU name lists in the target. For example,
323
23.4k
  // not all Sandybridge processors support AVX.
324
23.4k
  if (MCPU == "native") {
325
0
    StringMap<bool> HostFeatures;
326
0
    if (sys::getHostCPUFeatures(HostFeatures))
327
0
      for (auto &F : HostFeatures)
328
0
        Features.AddFeature(F.first(), F.second);
329
0
  }
330
23.4k
331
31.3k
  for (unsigned i = 0; i != MAttrs.size(); 
++i7.85k
)
332
7.85k
    Features.AddFeature(MAttrs[i]);
333
23.4k
334
23.4k
  return Features.getString();
335
23.4k
}
opt.cpp:getFeaturesStr()
Line
Count
Source
317
3.39k
LLVM_ATTRIBUTE_UNUSED static std::string getFeaturesStr() {
318
3.39k
  SubtargetFeatures Features;
319
3.39k
320
3.39k
  // If user asked for the 'native' CPU, we need to autodetect features.
321
3.39k
  // This is necessary for x86 where the CPU might not support all the
322
3.39k
  // features the autodetected CPU name lists in the target. For example,
323
3.39k
  // not all Sandybridge processors support AVX.
324
3.39k
  if (MCPU == "native") {
325
0
    StringMap<bool> HostFeatures;
326
0
    if (sys::getHostCPUFeatures(HostFeatures))
327
0
      for (auto &F : HostFeatures)
328
0
        Features.AddFeature(F.first(), F.second);
329
0
  }
330
3.39k
331
3.82k
  for (unsigned i = 0; i != MAttrs.size(); 
++i432
)
332
432
    Features.AddFeature(MAttrs[i]);
333
3.39k
334
3.39k
  return Features.getString();
335
3.39k
}
llc.cpp:getFeaturesStr()
Line
Count
Source
317
20.0k
LLVM_ATTRIBUTE_UNUSED static std::string getFeaturesStr() {
318
20.0k
  SubtargetFeatures Features;
319
20.0k
320
20.0k
  // If user asked for the 'native' CPU, we need to autodetect features.
321
20.0k
  // This is necessary for x86 where the CPU might not support all the
322
20.0k
  // features the autodetected CPU name lists in the target. For example,
323
20.0k
  // not all Sandybridge processors support AVX.
324
20.0k
  if (MCPU == "native") {
325
0
    StringMap<bool> HostFeatures;
326
0
    if (sys::getHostCPUFeatures(HostFeatures))
327
0
      for (auto &F : HostFeatures)
328
0
        Features.AddFeature(F.first(), F.second);
329
0
  }
330
20.0k
331
27.5k
  for (unsigned i = 0; i != MAttrs.size(); 
++i7.42k
)
332
7.42k
    Features.AddFeature(MAttrs[i]);
333
20.0k
334
20.0k
  return Features.getString();
335
20.0k
}
336
337
0
LLVM_ATTRIBUTE_UNUSED static std::vector<std::string> getFeatureList() {
338
0
  SubtargetFeatures Features;
339
0
340
0
  // If user asked for the 'native' CPU, we need to autodetect features.
341
0
  // This is necessary for x86 where the CPU might not support all the
342
0
  // features the autodetected CPU name lists in the target. For example,
343
0
  // not all Sandybridge processors support AVX.
344
0
  if (MCPU == "native") {
345
0
    StringMap<bool> HostFeatures;
346
0
    if (sys::getHostCPUFeatures(HostFeatures))
347
0
      for (auto &F : HostFeatures)
348
0
        Features.AddFeature(F.first(), F.second);
349
0
  }
350
0
351
0
  for (unsigned i = 0; i != MAttrs.size(); ++i)
352
0
    Features.AddFeature(MAttrs[i]);
353
0
354
0
  return Features.getFeatures();
355
0
}
Unexecuted instantiation: opt.cpp:getFeatureList()
Unexecuted instantiation: llc.cpp:getFeatureList()
356
357
/// Set function attributes of functions in Module M based on CPU,
358
/// Features, and command line flags.
359
LLVM_ATTRIBUTE_UNUSED static void
360
29.0k
setFunctionAttributes(StringRef CPU, StringRef Features, Module &M) {
361
293k
  for (auto &F : M) {
362
293k
    auto &Ctx = F.getContext();
363
293k
    AttributeList Attrs = F.getAttributes();
364
293k
    AttrBuilder NewAttrs;
365
293k
366
293k
    if (!CPU.empty())
367
85.9k
      NewAttrs.addAttribute("target-cpu", CPU);
368
293k
    if (!Features.empty())
369
125k
      NewAttrs.addAttribute("target-features", Features);
370
293k
    if (DisableFPElim.getNumOccurrences() > 0)
371
1.94k
      NewAttrs.addAttribute("no-frame-pointer-elim",
372
1.94k
                            DisableFPElim ? 
"true"1.92k
:
"false"21
);
373
293k
    if (DisableTailCalls.getNumOccurrences() > 0)
374
34
      NewAttrs.addAttribute("disable-tail-calls",
375
34
                            toStringRef(DisableTailCalls));
376
293k
    if (StackRealign)
377
84
      NewAttrs.addAttribute("stackrealign");
378
293k
379
293k
    if (TrapFuncName.getNumOccurrences() > 0)
380
12
      for (auto &B : F)
381
7
        for (auto &I : B)
382
14
          if (auto *Call = dyn_cast<CallInst>(&I))
383
7
            if (const auto *F = Call->getCalledFunction())
384
7
              if (F->getIntrinsicID() == Intrinsic::debugtrap ||
385
7
                  
F->getIntrinsicID() == Intrinsic::trap5
)
386
7
                Call->addAttribute(
387
7
                    llvm::AttributeList::FunctionIndex,
388
7
                    Attribute::get(Ctx, "trap-func-name", TrapFuncName));
389
293k
390
293k
    // Let NewAttrs override Attrs.
391
293k
    F.setAttributes(
392
293k
        Attrs.addAttributes(Ctx, AttributeList::FunctionIndex, NewAttrs));
393
293k
  }
394
29.0k
}
opt.cpp:setFunctionAttributes(llvm::StringRef, llvm::StringRef, llvm::Module&)
Line
Count
Source
360
9.00k
setFunctionAttributes(StringRef CPU, StringRef Features, Module &M) {
361
64.0k
  for (auto &F : M) {
362
64.0k
    auto &Ctx = F.getContext();
363
64.0k
    AttributeList Attrs = F.getAttributes();
364
64.0k
    AttrBuilder NewAttrs;
365
64.0k
366
64.0k
    if (!CPU.empty())
367
4.96k
      NewAttrs.addAttribute("target-cpu", CPU);
368
64.0k
    if (!Features.empty())
369
5.94k
      NewAttrs.addAttribute("target-features", Features);
370
64.0k
    if (DisableFPElim.getNumOccurrences() > 0)
371
0
      NewAttrs.addAttribute("no-frame-pointer-elim",
372
0
                            DisableFPElim ? "true" : "false");
373
64.0k
    if (DisableTailCalls.getNumOccurrences() > 0)
374
0
      NewAttrs.addAttribute("disable-tail-calls",
375
0
                            toStringRef(DisableTailCalls));
376
64.0k
    if (StackRealign)
377
0
      NewAttrs.addAttribute("stackrealign");
378
64.0k
379
64.0k
    if (TrapFuncName.getNumOccurrences() > 0)
380
0
      for (auto &B : F)
381
0
        for (auto &I : B)
382
0
          if (auto *Call = dyn_cast<CallInst>(&I))
383
0
            if (const auto *F = Call->getCalledFunction())
384
0
              if (F->getIntrinsicID() == Intrinsic::debugtrap ||
385
0
                  F->getIntrinsicID() == Intrinsic::trap)
386
0
                Call->addAttribute(
387
0
                    llvm::AttributeList::FunctionIndex,
388
0
                    Attribute::get(Ctx, "trap-func-name", TrapFuncName));
389
64.0k
390
64.0k
    // Let NewAttrs override Attrs.
391
64.0k
    F.setAttributes(
392
64.0k
        Attrs.addAttributes(Ctx, AttributeList::FunctionIndex, NewAttrs));
393
64.0k
  }
394
9.00k
}
llc.cpp:setFunctionAttributes(llvm::StringRef, llvm::StringRef, llvm::Module&)
Line
Count
Source
360
20.0k
setFunctionAttributes(StringRef CPU, StringRef Features, Module &M) {
361
229k
  for (auto &F : M) {
362
229k
    auto &Ctx = F.getContext();
363
229k
    AttributeList Attrs = F.getAttributes();
364
229k
    AttrBuilder NewAttrs;
365
229k
366
229k
    if (!CPU.empty())
367
81.0k
      NewAttrs.addAttribute("target-cpu", CPU);
368
229k
    if (!Features.empty())
369
119k
      NewAttrs.addAttribute("target-features", Features);
370
229k
    if (DisableFPElim.getNumOccurrences() > 0)
371
1.94k
      NewAttrs.addAttribute("no-frame-pointer-elim",
372
1.94k
                            DisableFPElim ? 
"true"1.92k
:
"false"21
);
373
229k
    if (DisableTailCalls.getNumOccurrences() > 0)
374
34
      NewAttrs.addAttribute("disable-tail-calls",
375
34
                            toStringRef(DisableTailCalls));
376
229k
    if (StackRealign)
377
84
      NewAttrs.addAttribute("stackrealign");
378
229k
379
229k
    if (TrapFuncName.getNumOccurrences() > 0)
380
12
      for (auto &B : F)
381
7
        for (auto &I : B)
382
14
          if (auto *Call = dyn_cast<CallInst>(&I))
383
7
            if (const auto *F = Call->getCalledFunction())
384
7
              if (F->getIntrinsicID() == Intrinsic::debugtrap ||
385
7
                  
F->getIntrinsicID() == Intrinsic::trap5
)
386
7
                Call->addAttribute(
387
7
                    llvm::AttributeList::FunctionIndex,
388
7
                    Attribute::get(Ctx, "trap-func-name", TrapFuncName));
389
229k
390
229k
    // Let NewAttrs override Attrs.
391
229k
    F.setAttributes(
392
229k
        Attrs.addAttributes(Ctx, AttributeList::FunctionIndex, NewAttrs));
393
229k
  }
394
20.0k
}