Coverage Report

Created: 2018-07-12 09:57

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