ScopDetectionDiagnostic.h 24 KB

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