Coverage Report

Created: 2018-09-25 17:16

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/clang-build/lib/IR/AttributesCompatFunc.inc
Line
Count
Source (jump to first uncovered line)
1
#ifdef GET_ATTR_ENUM
2
#undef GET_ATTR_ENUM
3
Alignment,
4
AllocSize,
5
AlwaysInline,
6
ArgMemOnly,
7
Builtin,
8
ByVal,
9
Cold,
10
Convergent,
11
Dereferenceable,
12
DereferenceableOrNull,
13
InAlloca,
14
InReg,
15
InaccessibleMemOnly,
16
InaccessibleMemOrArgMemOnly,
17
InlineHint,
18
JumpTable,
19
MinSize,
20
Naked,
21
Nest,
22
NoAlias,
23
NoBuiltin,
24
NoCapture,
25
NoCfCheck,
26
NoDuplicate,
27
NoImplicitFloat,
28
NoInline,
29
NoRecurse,
30
NoRedZone,
31
NoReturn,
32
NoUnwind,
33
NonLazyBind,
34
NonNull,
35
OptForFuzzing,
36
OptimizeForSize,
37
OptimizeNone,
38
ReadNone,
39
ReadOnly,
40
Returned,
41
ReturnsTwice,
42
SExt,
43
SafeStack,
44
SanitizeAddress,
45
SanitizeHWAddress,
46
SanitizeMemory,
47
SanitizeThread,
48
ShadowCallStack,
49
Speculatable,
50
SpeculativeLoadHardening,
51
StackAlignment,
52
StackProtect,
53
StackProtectReq,
54
StackProtectStrong,
55
StrictFP,
56
StructRet,
57
SwiftError,
58
SwiftSelf,
59
UWTable,
60
WriteOnly,
61
ZExt,
62
#endif
63
#ifdef GET_ATTR_KIND_FROM_NAME
64
#undef GET_ATTR_KIND_FROM_NAME
65
0
static Attribute::AttrKind getAttrKindFromName(StringRef AttrName) {
66
0
  return StringSwitch<Attribute::AttrKind>(AttrName)
67
0
    .Case("align", Attribute::Alignment)
68
0
    .Case("allocsize", Attribute::AllocSize)
69
0
    .Case("alwaysinline", Attribute::AlwaysInline)
70
0
    .Case("argmemonly", Attribute::ArgMemOnly)
71
0
    .Case("builtin", Attribute::Builtin)
72
0
    .Case("byval", Attribute::ByVal)
73
0
    .Case("cold", Attribute::Cold)
74
0
    .Case("convergent", Attribute::Convergent)
75
0
    .Case("dereferenceable", Attribute::Dereferenceable)
76
0
    .Case("dereferenceable_or_null", Attribute::DereferenceableOrNull)
77
0
    .Case("inalloca", Attribute::InAlloca)
78
0
    .Case("inreg", Attribute::InReg)
79
0
    .Case("inaccessiblememonly", Attribute::InaccessibleMemOnly)
80
0
    .Case("inaccessiblemem_or_argmemonly", Attribute::InaccessibleMemOrArgMemOnly)
81
0
    .Case("inlinehint", Attribute::InlineHint)
82
0
    .Case("jumptable", Attribute::JumpTable)
83
0
    .Case("minsize", Attribute::MinSize)
84
0
    .Case("naked", Attribute::Naked)
85
0
    .Case("nest", Attribute::Nest)
86
0
    .Case("noalias", Attribute::NoAlias)
87
0
    .Case("nobuiltin", Attribute::NoBuiltin)
88
0
    .Case("nocapture", Attribute::NoCapture)
89
0
    .Case("nocf_check", Attribute::NoCfCheck)
90
0
    .Case("noduplicate", Attribute::NoDuplicate)
91
0
    .Case("noimplicitfloat", Attribute::NoImplicitFloat)
92
0
    .Case("noinline", Attribute::NoInline)
93
0
    .Case("norecurse", Attribute::NoRecurse)
94
0
    .Case("noredzone", Attribute::NoRedZone)
95
0
    .Case("noreturn", Attribute::NoReturn)
96
0
    .Case("nounwind", Attribute::NoUnwind)
97
0
    .Case("nonlazybind", Attribute::NonLazyBind)
98
0
    .Case("nonnull", Attribute::NonNull)
99
0
    .Case("optforfuzzing", Attribute::OptForFuzzing)
100
0
    .Case("optsize", Attribute::OptimizeForSize)
101
0
    .Case("optnone", Attribute::OptimizeNone)
102
0
    .Case("readnone", Attribute::ReadNone)
103
0
    .Case("readonly", Attribute::ReadOnly)
104
0
    .Case("returned", Attribute::Returned)
105
0
    .Case("returns_twice", Attribute::ReturnsTwice)
106
0
    .Case("signext", Attribute::SExt)
107
0
    .Case("safestack", Attribute::SafeStack)
108
0
    .Case("sanitize_address", Attribute::SanitizeAddress)
109
0
    .Case("sanitize_hwaddress", Attribute::SanitizeHWAddress)
110
0
    .Case("sanitize_memory", Attribute::SanitizeMemory)
111
0
    .Case("sanitize_thread", Attribute::SanitizeThread)
112
0
    .Case("shadowcallstack", Attribute::ShadowCallStack)
113
0
    .Case("speculatable", Attribute::Speculatable)
114
0
    .Case("speculative_load_hardening", Attribute::SpeculativeLoadHardening)
115
0
    .Case("alignstack", Attribute::StackAlignment)
116
0
    .Case("ssp", Attribute::StackProtect)
117
0
    .Case("sspreq", Attribute::StackProtectReq)
118
0
    .Case("sspstrong", Attribute::StackProtectStrong)
119
0
    .Case("strictfp", Attribute::StrictFP)
120
0
    .Case("sret", Attribute::StructRet)
121
0
    .Case("swifterror", Attribute::SwiftError)
122
0
    .Case("swiftself", Attribute::SwiftSelf)
123
0
    .Case("uwtable", Attribute::UWTable)
124
0
    .Case("writeonly", Attribute::WriteOnly)
125
0
    .Case("zeroext", Attribute::ZExt)
126
0
    .Default(Attribute::None);
127
0
}
128
129
#endif
130
#ifdef GET_ATTR_COMPAT_FUNC
131
#undef GET_ATTR_COMPAT_FUNC
132
struct EnumAttr {
133
  static bool isSet(const Function &Fn,
134
2.06M
                    Attribute::AttrKind Kind) {
135
2.06M
    return Fn.hasFnAttribute(Kind);
136
2.06M
  }
137
138
  static void set(Function &Fn,
139
4
                  Attribute::AttrKind Kind, bool Val) {
140
4
    if (Val)
141
4
      Fn.addFnAttr(Kind);
142
0
    else
143
0
      Fn.removeFnAttr(Kind);
144
4
  }
145
};
146
147
struct StrBoolAttr {
148
  static bool isSet(const Function &Fn,
149
4.14M
                    StringRef Kind) {
150
4.14M
    auto A = Fn.getFnAttribute(Kind);
151
4.14M
    return A.getValueAsString().equals("true");
152
4.14M
  }
153
154
  static void set(Function &Fn,
155
10
                  StringRef Kind, bool Val) {
156
10
    Fn.addFnAttr(Kind, Val ? 
"true"2
:
"false"8
);
157
10
  }
158
};
159
160
// EnumAttr classes
161
struct AlignmentAttr : EnumAttr {
162
0
  static enum Attribute::AttrKind getKind() {
163
0
    return llvm::Attribute::Alignment;
164
0
  }
165
};
166
struct AllocSizeAttr : EnumAttr {
167
0
  static enum Attribute::AttrKind getKind() {
168
0
    return llvm::Attribute::AllocSize;
169
0
  }
170
};
171
struct AlwaysInlineAttr : EnumAttr {
172
0
  static enum Attribute::AttrKind getKind() {
173
0
    return llvm::Attribute::AlwaysInline;
174
0
  }
175
};
176
struct ArgMemOnlyAttr : EnumAttr {
177
0
  static enum Attribute::AttrKind getKind() {
178
0
    return llvm::Attribute::ArgMemOnly;
179
0
  }
180
};
181
struct BuiltinAttr : EnumAttr {
182
0
  static enum Attribute::AttrKind getKind() {
183
0
    return llvm::Attribute::Builtin;
184
0
  }
185
};
186
struct ByValAttr : EnumAttr {
187
0
  static enum Attribute::AttrKind getKind() {
188
0
    return llvm::Attribute::ByVal;
189
0
  }
190
};
191
struct ColdAttr : EnumAttr {
192
0
  static enum Attribute::AttrKind getKind() {
193
0
    return llvm::Attribute::Cold;
194
0
  }
195
};
196
struct ConvergentAttr : EnumAttr {
197
0
  static enum Attribute::AttrKind getKind() {
198
0
    return llvm::Attribute::Convergent;
199
0
  }
200
};
201
struct DereferenceableAttr : EnumAttr {
202
0
  static enum Attribute::AttrKind getKind() {
203
0
    return llvm::Attribute::Dereferenceable;
204
0
  }
205
};
206
struct DereferenceableOrNullAttr : EnumAttr {
207
0
  static enum Attribute::AttrKind getKind() {
208
0
    return llvm::Attribute::DereferenceableOrNull;
209
0
  }
210
};
211
struct InAllocaAttr : EnumAttr {
212
0
  static enum Attribute::AttrKind getKind() {
213
0
    return llvm::Attribute::InAlloca;
214
0
  }
215
};
216
struct InRegAttr : EnumAttr {
217
0
  static enum Attribute::AttrKind getKind() {
218
0
    return llvm::Attribute::InReg;
219
0
  }
220
};
221
struct InaccessibleMemOnlyAttr : EnumAttr {
222
0
  static enum Attribute::AttrKind getKind() {
223
0
    return llvm::Attribute::InaccessibleMemOnly;
224
0
  }
225
};
226
struct InaccessibleMemOrArgMemOnlyAttr : EnumAttr {
227
0
  static enum Attribute::AttrKind getKind() {
228
0
    return llvm::Attribute::InaccessibleMemOrArgMemOnly;
229
0
  }
230
};
231
struct InlineHintAttr : EnumAttr {
232
0
  static enum Attribute::AttrKind getKind() {
233
0
    return llvm::Attribute::InlineHint;
234
0
  }
235
};
236
struct JumpTableAttr : EnumAttr {
237
0
  static enum Attribute::AttrKind getKind() {
238
0
    return llvm::Attribute::JumpTable;
239
0
  }
240
};
241
struct MinSizeAttr : EnumAttr {
242
0
  static enum Attribute::AttrKind getKind() {
243
0
    return llvm::Attribute::MinSize;
244
0
  }
245
};
246
struct NakedAttr : EnumAttr {
247
0
  static enum Attribute::AttrKind getKind() {
248
0
    return llvm::Attribute::Naked;
249
0
  }
250
};
251
struct NestAttr : EnumAttr {
252
0
  static enum Attribute::AttrKind getKind() {
253
0
    return llvm::Attribute::Nest;
254
0
  }
255
};
256
struct NoAliasAttr : EnumAttr {
257
0
  static enum Attribute::AttrKind getKind() {
258
0
    return llvm::Attribute::NoAlias;
259
0
  }
260
};
261
struct NoBuiltinAttr : EnumAttr {
262
0
  static enum Attribute::AttrKind getKind() {
263
0
    return llvm::Attribute::NoBuiltin;
264
0
  }
265
};
266
struct NoCaptureAttr : EnumAttr {
267
0
  static enum Attribute::AttrKind getKind() {
268
0
    return llvm::Attribute::NoCapture;
269
0
  }
270
};
271
struct NoCfCheckAttr : EnumAttr {
272
0
  static enum Attribute::AttrKind getKind() {
273
0
    return llvm::Attribute::NoCfCheck;
274
0
  }
275
};
276
struct NoDuplicateAttr : EnumAttr {
277
0
  static enum Attribute::AttrKind getKind() {
278
0
    return llvm::Attribute::NoDuplicate;
279
0
  }
280
};
281
struct NoImplicitFloatAttr : EnumAttr {
282
1.03M
  static enum Attribute::AttrKind getKind() {
283
1.03M
    return llvm::Attribute::NoImplicitFloat;
284
1.03M
  }
285
};
286
struct NoInlineAttr : EnumAttr {
287
0
  static enum Attribute::AttrKind getKind() {
288
0
    return llvm::Attribute::NoInline;
289
0
  }
290
};
291
struct NoRecurseAttr : EnumAttr {
292
0
  static enum Attribute::AttrKind getKind() {
293
0
    return llvm::Attribute::NoRecurse;
294
0
  }
295
};
296
struct NoRedZoneAttr : EnumAttr {
297
0
  static enum Attribute::AttrKind getKind() {
298
0
    return llvm::Attribute::NoRedZone;
299
0
  }
300
};
301
struct NoReturnAttr : EnumAttr {
302
0
  static enum Attribute::AttrKind getKind() {
303
0
    return llvm::Attribute::NoReturn;
304
0
  }
305
};
306
struct NoUnwindAttr : EnumAttr {
307
0
  static enum Attribute::AttrKind getKind() {
308
0
    return llvm::Attribute::NoUnwind;
309
0
  }
310
};
311
struct NonLazyBindAttr : EnumAttr {
312
0
  static enum Attribute::AttrKind getKind() {
313
0
    return llvm::Attribute::NonLazyBind;
314
0
  }
315
};
316
struct NonNullAttr : EnumAttr {
317
0
  static enum Attribute::AttrKind getKind() {
318
0
    return llvm::Attribute::NonNull;
319
0
  }
320
};
321
struct OptForFuzzingAttr : EnumAttr {
322
0
  static enum Attribute::AttrKind getKind() {
323
0
    return llvm::Attribute::OptForFuzzing;
324
0
  }
325
};
326
struct OptimizeForSizeAttr : EnumAttr {
327
0
  static enum Attribute::AttrKind getKind() {
328
0
    return llvm::Attribute::OptimizeForSize;
329
0
  }
330
};
331
struct OptimizeNoneAttr : EnumAttr {
332
0
  static enum Attribute::AttrKind getKind() {
333
0
    return llvm::Attribute::OptimizeNone;
334
0
  }
335
};
336
struct ReadNoneAttr : EnumAttr {
337
0
  static enum Attribute::AttrKind getKind() {
338
0
    return llvm::Attribute::ReadNone;
339
0
  }
340
};
341
struct ReadOnlyAttr : EnumAttr {
342
0
  static enum Attribute::AttrKind getKind() {
343
0
    return llvm::Attribute::ReadOnly;
344
0
  }
345
};
346
struct ReturnedAttr : EnumAttr {
347
0
  static enum Attribute::AttrKind getKind() {
348
0
    return llvm::Attribute::Returned;
349
0
  }
350
};
351
struct ReturnsTwiceAttr : EnumAttr {
352
0
  static enum Attribute::AttrKind getKind() {
353
0
    return llvm::Attribute::ReturnsTwice;
354
0
  }
355
};
356
struct SExtAttr : EnumAttr {
357
0
  static enum Attribute::AttrKind getKind() {
358
0
    return llvm::Attribute::SExt;
359
0
  }
360
};
361
struct SafeStackAttr : EnumAttr {
362
3.17M
  static enum Attribute::AttrKind getKind() {
363
3.17M
    return llvm::Attribute::SafeStack;
364
3.17M
  }
365
};
366
struct SanitizeAddressAttr : EnumAttr {
367
3.17M
  static enum Attribute::AttrKind getKind() {
368
3.17M
    return llvm::Attribute::SanitizeAddress;
369
3.17M
  }
370
};
371
struct SanitizeHWAddressAttr : EnumAttr {
372
3.17M
  static enum Attribute::AttrKind getKind() {
373
3.17M
    return llvm::Attribute::SanitizeHWAddress;
374
3.17M
  }
375
};
376
struct SanitizeMemoryAttr : EnumAttr {
377
3.17M
  static enum Attribute::AttrKind getKind() {
378
3.17M
    return llvm::Attribute::SanitizeMemory;
379
3.17M
  }
380
};
381
struct SanitizeThreadAttr : EnumAttr {
382
3.17M
  static enum Attribute::AttrKind getKind() {
383
3.17M
    return llvm::Attribute::SanitizeThread;
384
3.17M
  }
385
};
386
struct ShadowCallStackAttr : EnumAttr {
387
3.17M
  static enum Attribute::AttrKind getKind() {
388
3.17M
    return llvm::Attribute::ShadowCallStack;
389
3.17M
  }
390
};
391
struct SpeculatableAttr : EnumAttr {
392
0
  static enum Attribute::AttrKind getKind() {
393
0
    return llvm::Attribute::Speculatable;
394
0
  }
395
};
396
struct SpeculativeLoadHardeningAttr : EnumAttr {
397
1.03M
  static enum Attribute::AttrKind getKind() {
398
1.03M
    return llvm::Attribute::SpeculativeLoadHardening;
399
1.03M
  }
400
};
401
struct StackAlignmentAttr : EnumAttr {
402
0
  static enum Attribute::AttrKind getKind() {
403
0
    return llvm::Attribute::StackAlignment;
404
0
  }
405
};
406
struct StackProtectAttr : EnumAttr {
407
0
  static enum Attribute::AttrKind getKind() {
408
0
    return llvm::Attribute::StackProtect;
409
0
  }
410
};
411
struct StackProtectReqAttr : EnumAttr {
412
0
  static enum Attribute::AttrKind getKind() {
413
0
    return llvm::Attribute::StackProtectReq;
414
0
  }
415
};
416
struct StackProtectStrongAttr : EnumAttr {
417
0
  static enum Attribute::AttrKind getKind() {
418
0
    return llvm::Attribute::StackProtectStrong;
419
0
  }
420
};
421
struct StrictFPAttr : EnumAttr {
422
0
  static enum Attribute::AttrKind getKind() {
423
0
    return llvm::Attribute::StrictFP;
424
0
  }
425
};
426
struct StructRetAttr : EnumAttr {
427
0
  static enum Attribute::AttrKind getKind() {
428
0
    return llvm::Attribute::StructRet;
429
0
  }
430
};
431
struct SwiftErrorAttr : EnumAttr {
432
0
  static enum Attribute::AttrKind getKind() {
433
0
    return llvm::Attribute::SwiftError;
434
0
  }
435
};
436
struct SwiftSelfAttr : EnumAttr {
437
0
  static enum Attribute::AttrKind getKind() {
438
0
    return llvm::Attribute::SwiftSelf;
439
0
  }
440
};
441
struct UWTableAttr : EnumAttr {
442
0
  static enum Attribute::AttrKind getKind() {
443
0
    return llvm::Attribute::UWTable;
444
0
  }
445
};
446
struct WriteOnlyAttr : EnumAttr {
447
0
  static enum Attribute::AttrKind getKind() {
448
0
    return llvm::Attribute::WriteOnly;
449
0
  }
450
};
451
struct ZExtAttr : EnumAttr {
452
0
  static enum Attribute::AttrKind getKind() {
453
0
    return llvm::Attribute::ZExt;
454
0
  }
455
};
456
457
// StrBoolAttr classes
458
struct LessPreciseFPMADAttr : StrBoolAttr {
459
517k
  static StringRef getKind() {
460
517k
    return "less-precise-fpmad";
461
517k
  }
462
};
463
struct NoInfsFPMathAttr : StrBoolAttr {
464
517k
  static StringRef getKind() {
465
517k
    return "no-infs-fp-math";
466
517k
  }
467
};
468
struct NoJumpTablesAttr : StrBoolAttr {
469
1.03M
  static StringRef getKind() {
470
1.03M
    return "no-jump-tables";
471
1.03M
  }
472
};
473
struct NoNansFPMathAttr : StrBoolAttr {
474
517k
  static StringRef getKind() {
475
517k
    return "no-nans-fp-math";
476
517k
  }
477
};
478
struct ProfileSampleAccurateAttr : StrBoolAttr {
479
1.03M
  static StringRef getKind() {
480
1.03M
    return "profile-sample-accurate";
481
1.03M
  }
482
};
483
struct UnsafeFPMathAttr : StrBoolAttr {
484
517k
  static StringRef getKind() {
485
517k
    return "unsafe-fp-math";
486
517k
  }
487
};
488
489
static inline bool hasCompatibleFnAttrs(const Function &Caller,
490
1.58M
                                        const Function &Callee) {
491
1.58M
  bool Ret = true;
492
1.58M
493
1.58M
  Ret &= isEqual<SanitizeAddressAttr>(Caller, Callee);
494
1.58M
  Ret &= isEqual<SanitizeThreadAttr>(Caller, Callee);
495
1.58M
  Ret &= isEqual<SanitizeMemoryAttr>(Caller, Callee);
496
1.58M
  Ret &= isEqual<SanitizeHWAddressAttr>(Caller, Callee);
497
1.58M
  Ret &= isEqual<SafeStackAttr>(Caller, Callee);
498
1.58M
  Ret &= isEqual<ShadowCallStackAttr>(Caller, Callee);
499
1.58M
500
1.58M
  return Ret;
501
1.58M
}
502
503
static inline void mergeFnAttrs(Function &Caller,
504
517k
                                const Function &Callee) {
505
517k
  setOR<NoImplicitFloatAttr>(Caller, Callee);
506
517k
  setOR<NoJumpTablesAttr>(Caller, Callee);
507
517k
  setOR<ProfileSampleAccurateAttr>(Caller, Callee);
508
517k
  setOR<SpeculativeLoadHardeningAttr>(Caller, Callee);
509
517k
  adjustCallerSSPLevel(Caller, Callee);
510
517k
  adjustCallerStackProbes(Caller, Callee);
511
517k
  adjustCallerStackProbeSize(Caller, Callee);
512
517k
  adjustMinLegalVectorWidth(Caller, Callee);
513
517k
  adjustNullPointerValidAttr(Caller, Callee);
514
517k
  setAND<LessPreciseFPMADAttr>(Caller, Callee);
515
517k
  setAND<NoInfsFPMathAttr>(Caller, Callee);
516
517k
  setAND<NoNansFPMathAttr>(Caller, Callee);
517
517k
  setAND<UnsafeFPMathAttr>(Caller, Callee);
518
517k
}
519
520
#endif