Coverage Report

Created: 2017-08-18 19:41

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/polly/include/polly/ScopDetectionDiagnostic.h
Line
Count
Source (jump to first uncovered line)
1
//=== ScopDetectionDiagnostic.h -- Diagnostic for ScopDetection -*- 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
// Small set of diagnostic helper classes to encapsulate any errors occurred
11
// during the detection of Scops.
12
//
13
// The ScopDetection defines a set of error classes (via Statistic variables)
14
// that groups a number of individual errors into a group, e.g. non-affinity
15
// related errors.
16
// On error we generate an object that carries enough additional information
17
// to diagnose the error and generate a helpful error message.
18
//
19
//===----------------------------------------------------------------------===//
20
#ifndef POLLY_SCOP_DETECTION_DIAGNOSTIC_H
21
#define POLLY_SCOP_DETECTION_DIAGNOSTIC_H
22
23
#include "llvm/ADT/SmallVector.h"
24
#include "llvm/ADT/Statistic.h"
25
#include "llvm/ADT/Twine.h"
26
#include "llvm/Analysis/AliasSetTracker.h"
27
#include "llvm/Analysis/LoopInfo.h"
28
#include "llvm/Analysis/OptimizationDiagnosticInfo.h"
29
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
30
#include "llvm/IR/BasicBlock.h"
31
#include "llvm/IR/Value.h"
32
#include "llvm/Support/Casting.h"
33
#include <memory>
34
#include <string>
35
36
using namespace llvm;
37
38
namespace llvm {
39
class SCEV;
40
class BasicBlock;
41
class Value;
42
class Region;
43
} // namespace llvm
44
45
namespace polly {
46
47
/// Type to hold region delimiters (entry & exit block).
48
using BBPair = std::pair<BasicBlock *, BasicBlock *>;
49
50
/// Return the region delimiters (entry & exit block) of @p R.
51
BBPair getBBPairForRegion(const Region *R);
52
53
/// Set the begin and end source location for the region limited by @p P.
54
void getDebugLocations(const BBPair &P, DebugLoc &Begin, DebugLoc &End);
55
56
class RejectLog;
57
/// Emit optimization remarks about the rejected regions to the user.
58
///
59
/// This emits the content of the reject log as optimization remarks.
60
/// Remember to at least track failures (-polly-detect-track-failures).
61
/// @param P The region delimiters (entry & exit) we emit remarks for.
62
/// @param Log The error log containing all messages being emitted as remark.
63
void emitRejectionRemarks(const BBPair &P, const RejectLog &Log,
64
                          OptimizationRemarkEmitter &ORE);
65
66
// Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
67
enum class RejectReasonKind {
68
  // CFG Category
69
  CFG,
70
  InvalidTerminator,
71
  IrreducibleRegion,
72
  UnreachableInExit,
73
  LastCFG,
74
75
  // Non-Affinity
76
  AffFunc,
77
  UndefCond,
78
  InvalidCond,
79
  UndefOperand,
80
  NonAffBranch,
81
  NoBasePtr,
82
  UndefBasePtr,
83
  VariantBasePtr,
84
  NonAffineAccess,
85
  DifferentElementSize,
86
  LastAffFunc,
87
88
  LoopBound,
89
  LoopHasNoExit,
90
  LoopOnlySomeLatches,
91
92
  FuncCall,
93
  NonSimpleMemoryAccess,
94
95
  Alias,
96
97
  // Other
98
  Other,
99
  IntToPtr,
100
  Alloca,
101
  UnknownInst,
102
  Entry,
103
  Unprofitable,
104
  LastOther
105
};
106
107
//===----------------------------------------------------------------------===//
108
/// Base class of all reject reasons found during Scop detection.
109
///
110
/// Subclasses of RejectReason should provide means to capture enough
111
/// diagnostic information to help clients figure out what and where something
112
/// went wrong in the Scop detection.
113
class RejectReason {
114
  //===--------------------------------------------------------------------===//
115
private:
116
  const RejectReasonKind Kind;
117
118
protected:
119
  static const DebugLoc Unknown;
120
121
public:
122
0
  RejectReasonKind getKind() const { return Kind; }
123
124
  RejectReason(RejectReasonKind K);
125
126
584
  virtual ~RejectReason() {}
127
128
  /// Generate the remark name to identify this remark.
129
  ///
130
  /// @return A short string that identifies the error.
131
  virtual std::string getRemarkName() const = 0;
132
133
  /// Get the Basic Block containing this remark.
134
  ///
135
  /// @return The Basic Block containing this remark.
136
  virtual const Value *getRemarkBB() const = 0;
137
138
  /// Generate a reasonable diagnostic message describing this error.
139
  ///
140
  /// @return A debug message representing this error.
141
  virtual std::string getMessage() const = 0;
142
143
  /// Generate a message for the end-user describing this error.
144
  ///
145
  /// The message provided has to be suitable for the end-user. So it should
146
  /// not reference any LLVM internal data structures or terminology.
147
  /// Ideally, the message helps the end-user to increase the size of the
148
  /// regions amenable to Polly.
149
  ///
150
  /// @return A short message representing this error.
151
183
  virtual std::string getEndUserMessage() const { return "Unspecified error."; }
152
153
  /// Get the source location of this error.
154
  ///
155
  /// @return The debug location for this error.
156
  virtual const llvm::DebugLoc &getDebugLoc() const;
157
};
158
159
typedef std::shared_ptr<RejectReason> RejectReasonPtr;
160
161
/// Stores all errors that occurred during the detection.
162
class RejectLog {
163
  Region *R;
164
  llvm::SmallVector<RejectReasonPtr, 1> ErrorReports;
165
166
public:
167
4.80k
  explicit RejectLog(Region *R) : R(R) {}
168
169
  typedef llvm::SmallVector<RejectReasonPtr, 1>::const_iterator iterator;
170
171
423
  iterator begin() const { return ErrorReports.begin(); }
172
423
  iterator end() const { return ErrorReports.end(); }
173
10.5k
  size_t size() const { return ErrorReports.size(); }
174
175
  /// Returns true, if we store at least one error.
176
  ///
177
  /// @return true, if we store at least one error.
178
9.12k
  bool hasErrors() const { return size() > 0; }
179
180
  void print(raw_ostream &OS, int level = 0) const;
181
182
0
  const Region *region() const { return R; }
183
584
  void report(RejectReasonPtr Reject) { ErrorReports.push_back(Reject); }
184
};
185
186
//===----------------------------------------------------------------------===//
187
/// Base class for CFG related reject reasons.
188
///
189
/// Scop candidates that violate structural restrictions can be grouped under
190
/// this reject reason class.
191
class ReportCFG : public RejectReason {
192
  //===--------------------------------------------------------------------===//
193
public:
194
  ReportCFG(const RejectReasonKind K);
195
196
  /// @name LLVM-RTTI interface
197
  //@{
198
  static bool classof(const RejectReason *RR);
199
  //@}
200
};
201
202
//===----------------------------------------------------------------------===//
203
/// Captures bad terminator within a Scop candidate.
204
class ReportInvalidTerminator : public ReportCFG {
205
  BasicBlock *BB;
206
207
public:
208
  ReportInvalidTerminator(BasicBlock *BB)
209
0
      : ReportCFG(RejectReasonKind::InvalidTerminator), BB(BB) {}
210
211
  /// @name LLVM-RTTI interface
212
  //@{
213
  static bool classof(const RejectReason *RR);
214
  //@}
215
216
  /// @name RejectReason interface
217
  //@{
218
  virtual std::string getRemarkName() const override;
219
  virtual const Value *getRemarkBB() const override;
220
  virtual std::string getMessage() const override;
221
  virtual const DebugLoc &getDebugLoc() const override;
222
  //@}
223
};
224
225
//===----------------------------------------------------------------------===//
226
/// Captures irreducible regions in CFG.
227
class ReportIrreducibleRegion : public ReportCFG {
228
  Region *R;
229
  DebugLoc DbgLoc;
230
231
public:
232
  ReportIrreducibleRegion(Region *R, DebugLoc DbgLoc)
233
3
      : ReportCFG(RejectReasonKind::IrreducibleRegion), R(R), DbgLoc(DbgLoc) {}
234
235
  /// @name LLVM-RTTI interface
236
  //@{
237
  static bool classof(const RejectReason *RR);
238
  //@}
239
240
  /// @name RejectReason interface
241
  //@{
242
  virtual std::string getRemarkName() const override;
243
  virtual const Value *getRemarkBB() const override;
244
  virtual std::string getMessage() const override;
245
  virtual std::string getEndUserMessage() const override;
246
  virtual const DebugLoc &getDebugLoc() const override;
247
  //@}
248
};
249
250
//===----------------------------------------------------------------------===//
251
/// Captures regions with an unreachable in the exit block.
252
class ReportUnreachableInExit : public ReportCFG {
253
  BasicBlock *BB;
254
  DebugLoc DbgLoc;
255
256
public:
257
  ReportUnreachableInExit(BasicBlock *BB, DebugLoc DbgLoc)
258
23
      : ReportCFG(RejectReasonKind::UnreachableInExit), BB(BB), DbgLoc(DbgLoc) {
259
23
  }
260
261
  /// @name LLVM-RTTI interface
262
  //@{
263
  static bool classof(const RejectReason *RR);
264
  //@}
265
266
  /// @name RejectReason interface
267
  //@{
268
  virtual std::string getRemarkName() const override;
269
  virtual const Value *getRemarkBB() const override;
270
  virtual std::string getMessage() const override;
271
  virtual std::string getEndUserMessage() const override;
272
  virtual const DebugLoc &getDebugLoc() const override;
273
  //@}
274
};
275
276
//===----------------------------------------------------------------------===//
277
/// Base class for non-affine reject reasons.
278
///
279
/// Scop candidates that violate restrictions to affinity are reported under
280
/// this class.
281
class ReportAffFunc : public RejectReason {
282
  //===--------------------------------------------------------------------===//
283
284
protected:
285
  // The instruction that caused non-affinity to occur.
286
  const Instruction *Inst;
287
288
public:
289
  ReportAffFunc(const RejectReasonKind K, const Instruction *Inst);
290
291
  /// @name LLVM-RTTI interface
292
  //@{
293
  static bool classof(const RejectReason *RR);
294
  //@}
295
296
  /// @name RejectReason interface
297
  //@{
298
221
  virtual const DebugLoc &getDebugLoc() const override {
299
221
    return Inst->getDebugLoc();
300
221
  }
301
  //@}
302
};
303
304
//===----------------------------------------------------------------------===//
305
/// Captures a condition that is based on an 'undef' value.
306
class ReportUndefCond : public ReportAffFunc {
307
  //===--------------------------------------------------------------------===//
308
309
  // The BasicBlock we found the broken condition in.
310
  BasicBlock *BB;
311
312
public:
313
  ReportUndefCond(const Instruction *Inst, BasicBlock *BB)
314
158
      : ReportAffFunc(RejectReasonKind::UndefCond, Inst), BB(BB) {}
315
316
  /// @name LLVM-RTTI interface
317
  //@{
318
  static bool classof(const RejectReason *RR);
319
  //@}
320
321
  /// @name RejectReason interface
322
  //@{
323
  virtual std::string getRemarkName() const override;
324
  virtual const Value *getRemarkBB() const override;
325
  virtual std::string getMessage() const override;
326
  //@}
327
};
328
329
//===----------------------------------------------------------------------===//
330
/// Captures an invalid condition
331
///
332
/// Conditions have to be either constants or icmp instructions.
333
class ReportInvalidCond : public ReportAffFunc {
334
  //===--------------------------------------------------------------------===//
335
336
  // The BasicBlock we found the broken condition in.
337
  BasicBlock *BB;
338
339
public:
340
  ReportInvalidCond(const Instruction *Inst, BasicBlock *BB)
341
0
      : ReportAffFunc(RejectReasonKind::InvalidCond, Inst), BB(BB) {}
342
343
  /// @name LLVM-RTTI interface
344
  //@{
345
  static bool classof(const RejectReason *RR);
346
  //@}
347
348
  /// @name RejectReason interface
349
  //@{
350
  virtual std::string getRemarkName() const override;
351
  virtual const Value *getRemarkBB() const override;
352
  virtual std::string getMessage() const override;
353
  //@}
354
};
355
356
//===----------------------------------------------------------------------===//
357
/// Captures an undefined operand.
358
class ReportUndefOperand : public ReportAffFunc {
359
  //===--------------------------------------------------------------------===//
360
361
  // The BasicBlock we found the undefined operand in.
362
  BasicBlock *BB;
363
364
public:
365
  ReportUndefOperand(BasicBlock *BB, const Instruction *Inst)
366
5
      : ReportAffFunc(RejectReasonKind::UndefOperand, Inst), BB(BB) {}
367
368
  /// @name LLVM-RTTI interface
369
  //@{
370
  static bool classof(const RejectReason *RR);
371
  //@}
372
373
  /// @name RejectReason interface
374
  //@{
375
  virtual std::string getRemarkName() const override;
376
  virtual const Value *getRemarkBB() const override;
377
  virtual std::string getMessage() const override;
378
  //@}
379
};
380
381
//===----------------------------------------------------------------------===//
382
/// Captures a non-affine branch.
383
class ReportNonAffBranch : public ReportAffFunc {
384
  //===--------------------------------------------------------------------===//
385
386
  // The BasicBlock we found the non-affine branch in.
387
  BasicBlock *BB;
388
389
  /// LHS & RHS of the failed condition.
390
  //@{
391
  const SCEV *LHS;
392
  const SCEV *RHS;
393
  //@}
394
395
public:
396
  ReportNonAffBranch(BasicBlock *BB, const SCEV *LHS, const SCEV *RHS,
397
                     const Instruction *Inst)
398
      : ReportAffFunc(RejectReasonKind::NonAffBranch, Inst), BB(BB), LHS(LHS),
399
5
        RHS(RHS) {}
400
401
0
  const SCEV *lhs() { return LHS; }
402
0
  const SCEV *rhs() { return RHS; }
403
404
  /// @name LLVM-RTTI interface
405
  //@{
406
  static bool classof(const RejectReason *RR);
407
  //@}
408
409
  /// @name RejectReason interface
410
  //@{
411
  virtual std::string getRemarkName() const override;
412
  virtual const Value *getRemarkBB() const override;
413
  virtual std::string getMessage() const override;
414
  //@}
415
};
416
417
//===----------------------------------------------------------------------===//
418
/// Captures a missing base pointer.
419
class ReportNoBasePtr : public ReportAffFunc {
420
  //===--------------------------------------------------------------------===//
421
public:
422
  ReportNoBasePtr(const Instruction *Inst)
423
0
      : ReportAffFunc(RejectReasonKind::NoBasePtr, Inst) {}
424
425
  /// @name LLVM-RTTI interface
426
  //@{
427
  static bool classof(const RejectReason *RR);
428
  //@}
429
430
  /// @name RejectReason interface
431
  //@{
432
  virtual std::string getRemarkName() const override;
433
  virtual const Value *getRemarkBB() const override;
434
  virtual std::string getMessage() const override;
435
  //@}
436
};
437
438
//===----------------------------------------------------------------------===//
439
/// Captures an undefined base pointer.
440
class ReportUndefBasePtr : public ReportAffFunc {
441
  //===--------------------------------------------------------------------===//
442
public:
443
  ReportUndefBasePtr(const Instruction *Inst)
444
5
      : ReportAffFunc(RejectReasonKind::UndefBasePtr, Inst) {}
445
446
  /// @name LLVM-RTTI interface
447
  //@{
448
  static bool classof(const RejectReason *RR);
449
  //@}
450
451
  /// @name RejectReason interface
452
  //@{
453
  virtual std::string getRemarkName() const override;
454
  virtual const Value *getRemarkBB() const override;
455
  virtual std::string getMessage() const override;
456
  //@}
457
};
458
459
//===----------------------------------------------------------------------===//
460
/// Captures a base pointer that is not invariant in the region.
461
class ReportVariantBasePtr : public ReportAffFunc {
462
  //===--------------------------------------------------------------------===//
463
464
  // The variant base pointer.
465
  Value *BaseValue;
466
467
public:
468
  ReportVariantBasePtr(Value *BaseValue, const Instruction *Inst)
469
      : ReportAffFunc(RejectReasonKind::VariantBasePtr, Inst),
470
10
        BaseValue(BaseValue) {}
471
472
  /// @name LLVM-RTTI interface
473
  //@{
474
  static bool classof(const RejectReason *RR);
475
  //@}
476
477
  /// @name RejectReason interface
478
  //@{
479
  virtual std::string getRemarkName() const override;
480
  virtual const Value *getRemarkBB() const override;
481
  virtual std::string getMessage() const override;
482
  virtual std::string getEndUserMessage() const override;
483
  //@}
484
};
485
486
//===----------------------------------------------------------------------===//
487
/// Captures a non-affine access function.
488
class ReportNonAffineAccess : public ReportAffFunc {
489
  //===--------------------------------------------------------------------===//
490
491
  // The non-affine access function.
492
  const SCEV *AccessFunction;
493
494
  // The base pointer of the memory access.
495
  const Value *BaseValue;
496
497
public:
498
  ReportNonAffineAccess(const SCEV *AccessFunction, const Instruction *Inst,
499
                        const Value *V)
500
      : ReportAffFunc(RejectReasonKind::NonAffineAccess, Inst),
501
58
        AccessFunction(AccessFunction), BaseValue(V) {}
502
503
0
  const SCEV *get() { return AccessFunction; }
504
505
  /// @name LLVM-RTTI interface
506
  //@{
507
  static bool classof(const RejectReason *RR);
508
  //@}
509
510
  /// @name RejectReason interface
511
  //@{
512
  virtual std::string getRemarkName() const override;
513
  virtual const Value *getRemarkBB() const override;
514
  virtual std::string getMessage() const override;
515
  virtual std::string getEndUserMessage() const override;
516
  //@}
517
};
518
519
//===----------------------------------------------------------------------===//
520
/// Report array accesses with differing element size.
521
class ReportDifferentArrayElementSize : public ReportAffFunc {
522
  //===--------------------------------------------------------------------===//
523
524
  // The base pointer of the memory access.
525
  const Value *BaseValue;
526
527
public:
528
  ReportDifferentArrayElementSize(const Instruction *Inst, const Value *V)
529
      : ReportAffFunc(RejectReasonKind::DifferentElementSize, Inst),
530
0
        BaseValue(V) {}
531
532
  /// @name LLVM-RTTI interface
533
  //@{
534
  static bool classof(const RejectReason *RR);
535
  //@}
536
537
  /// @name RejectReason interface
538
  //@{
539
  virtual std::string getRemarkName() const override;
540
  virtual const Value *getRemarkBB() const override;
541
  virtual std::string getMessage() const override;
542
  virtual std::string getEndUserMessage() const override;
543
  //@}
544
};
545
546
//===----------------------------------------------------------------------===//
547
/// Captures errors with non affine loop bounds.
548
class ReportLoopBound : public RejectReason {
549
  //===--------------------------------------------------------------------===//
550
551
  // The offending loop.
552
  Loop *L;
553
554
  // The non-affine loop bound.
555
  const SCEV *LoopCount;
556
557
  // A copy of the offending loop's debug location.
558
  const DebugLoc Loc;
559
560
public:
561
  ReportLoopBound(Loop *L, const SCEV *LoopCount);
562
563
0
  const SCEV *loopCount() { return LoopCount; }
564
565
  /// @name LLVM-RTTI interface
566
  //@{
567
  static bool classof(const RejectReason *RR);
568
  //@}
569
570
  /// @name RejectReason interface
571
  //@{
572
  virtual std::string getRemarkName() const override;
573
  virtual const Value *getRemarkBB() const override;
574
  virtual std::string getMessage() const override;
575
  virtual const DebugLoc &getDebugLoc() const override;
576
  virtual std::string getEndUserMessage() const override;
577
  //@}
578
};
579
580
//===----------------------------------------------------------------------===//
581
/// Captures errors when loop has no exit.
582
class ReportLoopHasNoExit : public RejectReason {
583
  //===--------------------------------------------------------------------===//
584
585
  /// The loop that has no exit.
586
  Loop *L;
587
588
  const DebugLoc Loc;
589
590
public:
591
  ReportLoopHasNoExit(Loop *L)
592
      : RejectReason(RejectReasonKind::LoopHasNoExit), L(L),
593
0
        Loc(L->getStartLoc()) {}
594
595
  /// @name LLVM-RTTI interface
596
  //@{
597
  static bool classof(const RejectReason *RR);
598
  //@}
599
600
  /// @name RejectReason interface
601
  //@{
602
  virtual std::string getRemarkName() const override;
603
  virtual const Value *getRemarkBB() const override;
604
  virtual std::string getMessage() const override;
605
  virtual const DebugLoc &getDebugLoc() const override;
606
  virtual std::string getEndUserMessage() const override;
607
  //@}
608
};
609
610
//===----------------------------------------------------------------------===//
611
/// Captures errors when not all loop latches are part of the scop.
612
class ReportLoopOnlySomeLatches : public RejectReason {
613
  //===--------------------------------------------------------------------===//
614
615
  /// The loop for which not all loop latches are part of the scop.
616
  Loop *L;
617
618
  const DebugLoc Loc;
619
620
public:
621
  ReportLoopOnlySomeLatches(Loop *L)
622
      : RejectReason(RejectReasonKind::LoopOnlySomeLatches), L(L),
623
5
        Loc(L->getStartLoc()) {}
624
625
  /// @name LLVM-RTTI interface
626
  //@{
627
  static bool classof(const RejectReason *RR);
628
  //@}
629
630
  /// @name RejectReason interface
631
  //@{
632
  virtual std::string getRemarkName() const override;
633
  virtual const Value *getRemarkBB() const override;
634
  virtual std::string getMessage() const override;
635
  virtual const DebugLoc &getDebugLoc() const override;
636
  virtual std::string getEndUserMessage() const override;
637
  //@}
638
};
639
640
//===----------------------------------------------------------------------===//
641
/// Captures errors with non-side-effect-known function calls.
642
class ReportFuncCall : public RejectReason {
643
  //===--------------------------------------------------------------------===//
644
645
  // The offending call instruction.
646
  Instruction *Inst;
647
648
public:
649
  ReportFuncCall(Instruction *Inst);
650
651
  /// @name LLVM-RTTI interface
652
  //@{
653
  static bool classof(const RejectReason *RR);
654
  //@}
655
656
  /// @name RejectReason interface
657
  //@{
658
  virtual std::string getRemarkName() const override;
659
  virtual const Value *getRemarkBB() const override;
660
  virtual std::string getMessage() const override;
661
  virtual const DebugLoc &getDebugLoc() const override;
662
  virtual std::string getEndUserMessage() const override;
663
  //@}
664
};
665
666
//===----------------------------------------------------------------------===//
667
/// Captures errors with aliasing.
668
class ReportAlias : public RejectReason {
669
  //===--------------------------------------------------------------------===//
670
public:
671
  typedef std::vector<const llvm::Value *> PointerSnapshotTy;
672
673
private:
674
  /// Format an invalid alias set.
675
  ///
676
  //  @param Prefix A prefix string to put before the list of aliasing pointers.
677
  //  @param Suffix A suffix string to put after the list of aliasing pointers.
678
  std::string formatInvalidAlias(std::string Prefix = "",
679
                                 std::string Suffix = "") const;
680
681
  Instruction *Inst;
682
683
  // A snapshot of the llvm values that took part in the aliasing error.
684
  mutable PointerSnapshotTy Pointers;
685
686
public:
687
  ReportAlias(Instruction *Inst, AliasSet &AS);
688
689
0
  const PointerSnapshotTy &getPointers() const { return Pointers; }
690
691
  /// @name LLVM-RTTI interface
692
  //@{
693
  static bool classof(const RejectReason *RR);
694
  //@}
695
696
  /// @name RejectReason interface
697
  //@{
698
  virtual std::string getRemarkName() const override;
699
  virtual const Value *getRemarkBB() const override;
700
  virtual std::string getMessage() const override;
701
  virtual const DebugLoc &getDebugLoc() const override;
702
  virtual std::string getEndUserMessage() const override;
703
  //@}
704
};
705
706
//===----------------------------------------------------------------------===//
707
/// Base class for otherwise ungrouped reject reasons.
708
class ReportOther : public RejectReason {
709
  //===--------------------------------------------------------------------===//
710
public:
711
  ReportOther(const RejectReasonKind K);
712
713
  /// @name LLVM-RTTI interface
714
  //@{
715
  static bool classof(const RejectReason *RR);
716
  //@}
717
718
  /// @name RejectReason interface
719
  //@{
720
  virtual std::string getRemarkName() const override;
721
  virtual std::string getMessage() const override;
722
  //@}
723
};
724
725
//===----------------------------------------------------------------------===//
726
/// Captures errors with bad IntToPtr instructions.
727
class ReportIntToPtr : public ReportOther {
728
  //===--------------------------------------------------------------------===//
729
730
  // The offending base value.
731
  Instruction *BaseValue;
732
733
public:
734
  ReportIntToPtr(Instruction *BaseValue);
735
736
  /// @name LLVM-RTTI interface
737
  //@{
738
  static bool classof(const RejectReason *RR);
739
  //@}
740
741
  /// @name RejectReason interface
742
  //@{
743
  virtual std::string getRemarkName() const override;
744
  virtual const Value *getRemarkBB() const override;
745
  virtual std::string getMessage() const override;
746
  virtual const DebugLoc &getDebugLoc() const override;
747
  //@}
748
};
749
750
//===----------------------------------------------------------------------===//
751
/// Captures errors with alloca instructions.
752
class ReportAlloca : public ReportOther {
753
  //===--------------------------------------------------------------------===//
754
  Instruction *Inst;
755
756
public:
757
  ReportAlloca(Instruction *Inst);
758
759
  /// @name LLVM-RTTI interface
760
  //@{
761
  static bool classof(const RejectReason *RR);
762
  //@}
763
764
  /// @name RejectReason interface
765
  //@{
766
  virtual std::string getRemarkName() const override;
767
  virtual const Value *getRemarkBB() const override;
768
  virtual std::string getMessage() const override;
769
  virtual const DebugLoc &getDebugLoc() const override;
770
  //@}
771
};
772
773
//===----------------------------------------------------------------------===//
774
/// Captures errors with unknown instructions.
775
class ReportUnknownInst : public ReportOther {
776
  //===--------------------------------------------------------------------===//
777
  Instruction *Inst;
778
779
public:
780
  ReportUnknownInst(Instruction *Inst);
781
782
  /// @name LLVM-RTTI interface
783
  //@{
784
  static bool classof(const RejectReason *RR);
785
  //@}
786
787
  /// @name RejectReason interface
788
  //@{
789
  virtual std::string getRemarkName() const override;
790
  virtual const Value *getRemarkBB() const override;
791
  virtual std::string getMessage() const override;
792
  virtual const DebugLoc &getDebugLoc() const override;
793
  //@}
794
};
795
796
//===----------------------------------------------------------------------===//
797
/// Captures errors with regions containing the function entry block.
798
class ReportEntry : public ReportOther {
799
  //===--------------------------------------------------------------------===//
800
  BasicBlock *BB;
801
802
public:
803
  ReportEntry(BasicBlock *BB);
804
805
  /// @name LLVM-RTTI interface
806
  //@{
807
  static bool classof(const RejectReason *RR);
808
  //@}
809
810
  /// @name RejectReason interface
811
  //@{
812
  virtual std::string getRemarkName() const override;
813
  virtual const Value *getRemarkBB() const override;
814
  virtual std::string getMessage() const override;
815
  virtual std::string getEndUserMessage() const override;
816
  virtual const DebugLoc &getDebugLoc() const override;
817
  //@}
818
};
819
820
//===----------------------------------------------------------------------===//
821
/// Report regions that seem not profitable to be optimized.
822
class ReportUnprofitable : public ReportOther {
823
  //===--------------------------------------------------------------------===//
824
  Region *R;
825
826
public:
827
  ReportUnprofitable(Region *R);
828
829
  /// @name LLVM-RTTI interface
830
  //@{
831
  static bool classof(const RejectReason *RR);
832
  //@}
833
834
  /// @name RejectReason interface
835
  //@{
836
  virtual std::string getRemarkName() const override;
837
  virtual const Value *getRemarkBB() const override;
838
  virtual std::string getMessage() const override;
839
  virtual std::string getEndUserMessage() const override;
840
  virtual const DebugLoc &getDebugLoc() const override;
841
  //@}
842
};
843
844
//===----------------------------------------------------------------------===//
845
/// Captures errors with non-simple memory accesses.
846
class ReportNonSimpleMemoryAccess : public ReportOther {
847
  //===--------------------------------------------------------------------===//
848
849
  // The offending call instruction.
850
  Instruction *Inst;
851
852
public:
853
  ReportNonSimpleMemoryAccess(Instruction *Inst);
854
855
  /// @name LLVM-RTTI interface
856
  //@{
857
  static bool classof(const RejectReason *RR);
858
  //@}
859
860
  /// @name RejectReason interface
861
  //@{
862
  virtual std::string getRemarkName() const override;
863
  virtual const Value *getRemarkBB() const override;
864
  virtual std::string getMessage() const override;
865
  virtual const DebugLoc &getDebugLoc() const override;
866
  virtual std::string getEndUserMessage() const override;
867
  //@}
868
};
869
870
} // namespace polly
871
872
#endif // POLLY_SCOP_DETECTION_DIAGNOSTIC_H