MemoryDependenceAnalysis.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- llvm/Analysis/MemoryDependenceAnalysis.h - Memory Deps ---*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file defines the MemoryDependenceAnalysis analysis pass.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_ANALYSIS_MEMORYDEPENDENCEANALYSIS_H
  18. #define LLVM_ANALYSIS_MEMORYDEPENDENCEANALYSIS_H
  19. #include "llvm/ADT/DenseMap.h"
  20. #include "llvm/ADT/Optional.h"
  21. #include "llvm/ADT/PointerEmbeddedInt.h"
  22. #include "llvm/ADT/PointerIntPair.h"
  23. #include "llvm/ADT/PointerSumType.h"
  24. #include "llvm/ADT/SmallPtrSet.h"
  25. #include "llvm/Analysis/MemoryLocation.h"
  26. #include "llvm/IR/PassManager.h"
  27. #include "llvm/IR/PredIteratorCache.h"
  28. #include "llvm/IR/ValueHandle.h"
  29. #include "llvm/Pass.h"
  30. namespace llvm {
  31. class AAResults;
  32. class AssumptionCache;
  33. class BatchAAResults;
  34. class DominatorTree;
  35. class PHITransAddr;
  36. class PhiValues;
  37. /// A memory dependence query can return one of three different answers.
  38. class MemDepResult {
  39. enum DepType {
  40. /// Clients of MemDep never see this.
  41. ///
  42. /// Entries with this marker occur in a LocalDeps map or NonLocalDeps map
  43. /// when the instruction they previously referenced was removed from
  44. /// MemDep. In either case, the entry may include an instruction pointer.
  45. /// If so, the pointer is an instruction in the block where scanning can
  46. /// start from, saving some work.
  47. ///
  48. /// In a default-constructed MemDepResult object, the type will be Invalid
  49. /// and the instruction pointer will be null.
  50. Invalid = 0,
  51. /// This is a dependence on the specified instruction which clobbers the
  52. /// desired value. The pointer member of the MemDepResult pair holds the
  53. /// instruction that clobbers the memory. For example, this occurs when we
  54. /// see a may-aliased store to the memory location we care about.
  55. ///
  56. /// There are several cases that may be interesting here:
  57. /// 1. Loads are clobbered by may-alias stores.
  58. /// 2. Loads are considered clobbered by partially-aliased loads. The
  59. /// client may choose to analyze deeper into these cases.
  60. Clobber,
  61. /// This is a dependence on the specified instruction which defines or
  62. /// produces the desired memory location. The pointer member of the
  63. /// MemDepResult pair holds the instruction that defines the memory.
  64. ///
  65. /// Cases of interest:
  66. /// 1. This could be a load or store for dependence queries on
  67. /// load/store. The value loaded or stored is the produced value.
  68. /// Note that the pointer operand may be different than that of the
  69. /// queried pointer due to must aliases and phi translation. Note
  70. /// that the def may not be the same type as the query, the pointers
  71. /// may just be must aliases.
  72. /// 2. For loads and stores, this could be an allocation instruction. In
  73. /// this case, the load is loading an undef value or a store is the
  74. /// first store to (that part of) the allocation.
  75. /// 3. Dependence queries on calls return Def only when they are readonly
  76. /// calls or memory use intrinsics with identical callees and no
  77. /// intervening clobbers. No validation is done that the operands to
  78. /// the calls are the same.
  79. Def,
  80. /// This marker indicates that the query has no known dependency in the
  81. /// specified block.
  82. ///
  83. /// More detailed state info is encoded in the upper part of the pair (i.e.
  84. /// the Instruction*)
  85. Other
  86. };
  87. /// If DepType is "Other", the upper part of the sum type is an encoding of
  88. /// the following more detailed type information.
  89. enum OtherType {
  90. /// This marker indicates that the query has no dependency in the specified
  91. /// block.
  92. ///
  93. /// To find out more, the client should query other predecessor blocks.
  94. NonLocal = 1,
  95. /// This marker indicates that the query has no dependency in the specified
  96. /// function.
  97. NonFuncLocal,
  98. /// This marker indicates that the query dependency is unknown.
  99. Unknown
  100. };
  101. using ValueTy = PointerSumType<
  102. DepType, PointerSumTypeMember<Invalid, Instruction *>,
  103. PointerSumTypeMember<Clobber, Instruction *>,
  104. PointerSumTypeMember<Def, Instruction *>,
  105. PointerSumTypeMember<Other, PointerEmbeddedInt<OtherType, 3>>>;
  106. ValueTy Value;
  107. explicit MemDepResult(ValueTy V) : Value(V) {}
  108. public:
  109. MemDepResult() = default;
  110. /// get methods: These are static ctor methods for creating various
  111. /// MemDepResult kinds.
  112. static MemDepResult getDef(Instruction *Inst) {
  113. assert(Inst && "Def requires inst");
  114. return MemDepResult(ValueTy::create<Def>(Inst));
  115. }
  116. static MemDepResult getClobber(Instruction *Inst) {
  117. assert(Inst && "Clobber requires inst");
  118. return MemDepResult(ValueTy::create<Clobber>(Inst));
  119. }
  120. static MemDepResult getNonLocal() {
  121. return MemDepResult(ValueTy::create<Other>(NonLocal));
  122. }
  123. static MemDepResult getNonFuncLocal() {
  124. return MemDepResult(ValueTy::create<Other>(NonFuncLocal));
  125. }
  126. static MemDepResult getUnknown() {
  127. return MemDepResult(ValueTy::create<Other>(Unknown));
  128. }
  129. /// Tests if this MemDepResult represents a query that is an instruction
  130. /// clobber dependency.
  131. bool isClobber() const { return Value.is<Clobber>(); }
  132. /// Tests if this MemDepResult represents a query that is an instruction
  133. /// definition dependency.
  134. bool isDef() const { return Value.is<Def>(); }
  135. /// Tests if this MemDepResult represents a query that is transparent to the
  136. /// start of the block, but where a non-local hasn't been done.
  137. bool isNonLocal() const {
  138. return Value.is<Other>() && Value.cast<Other>() == NonLocal;
  139. }
  140. /// Tests if this MemDepResult represents a query that is transparent to the
  141. /// start of the function.
  142. bool isNonFuncLocal() const {
  143. return Value.is<Other>() && Value.cast<Other>() == NonFuncLocal;
  144. }
  145. /// Tests if this MemDepResult represents a query which cannot and/or will
  146. /// not be computed.
  147. bool isUnknown() const {
  148. return Value.is<Other>() && Value.cast<Other>() == Unknown;
  149. }
  150. /// If this is a normal dependency, returns the instruction that is depended
  151. /// on. Otherwise, returns null.
  152. Instruction *getInst() const {
  153. switch (Value.getTag()) {
  154. case Invalid:
  155. return Value.cast<Invalid>();
  156. case Clobber:
  157. return Value.cast<Clobber>();
  158. case Def:
  159. return Value.cast<Def>();
  160. case Other:
  161. return nullptr;
  162. }
  163. llvm_unreachable("Unknown discriminant!");
  164. }
  165. bool operator==(const MemDepResult &M) const { return Value == M.Value; }
  166. bool operator!=(const MemDepResult &M) const { return Value != M.Value; }
  167. bool operator<(const MemDepResult &M) const { return Value < M.Value; }
  168. bool operator>(const MemDepResult &M) const { return Value > M.Value; }
  169. private:
  170. friend class MemoryDependenceResults;
  171. /// Tests if this is a MemDepResult in its dirty/invalid. state.
  172. bool isDirty() const { return Value.is<Invalid>(); }
  173. static MemDepResult getDirty(Instruction *Inst) {
  174. return MemDepResult(ValueTy::create<Invalid>(Inst));
  175. }
  176. };
  177. /// This is an entry in the NonLocalDepInfo cache.
  178. ///
  179. /// For each BasicBlock (the BB entry) it keeps a MemDepResult.
  180. class NonLocalDepEntry {
  181. BasicBlock *BB;
  182. MemDepResult Result;
  183. public:
  184. NonLocalDepEntry(BasicBlock *bb, MemDepResult result)
  185. : BB(bb), Result(result) {}
  186. // This is used for searches.
  187. NonLocalDepEntry(BasicBlock *bb) : BB(bb) {}
  188. // BB is the sort key, it can't be changed.
  189. BasicBlock *getBB() const { return BB; }
  190. void setResult(const MemDepResult &R) { Result = R; }
  191. const MemDepResult &getResult() const { return Result; }
  192. bool operator<(const NonLocalDepEntry &RHS) const { return BB < RHS.BB; }
  193. };
  194. /// This is a result from a NonLocal dependence query.
  195. ///
  196. /// For each BasicBlock (the BB entry) it keeps a MemDepResult and the
  197. /// (potentially phi translated) address that was live in the block.
  198. class NonLocalDepResult {
  199. NonLocalDepEntry Entry;
  200. Value *Address;
  201. public:
  202. NonLocalDepResult(BasicBlock *bb, MemDepResult result, Value *address)
  203. : Entry(bb, result), Address(address) {}
  204. // BB is the sort key, it can't be changed.
  205. BasicBlock *getBB() const { return Entry.getBB(); }
  206. void setResult(const MemDepResult &R, Value *Addr) {
  207. Entry.setResult(R);
  208. Address = Addr;
  209. }
  210. const MemDepResult &getResult() const { return Entry.getResult(); }
  211. /// Returns the address of this pointer in this block.
  212. ///
  213. /// This can be different than the address queried for the non-local result
  214. /// because of phi translation. This returns null if the address was not
  215. /// available in a block (i.e. because phi translation failed) or if this is
  216. /// a cached result and that address was deleted.
  217. ///
  218. /// The address is always null for a non-local 'call' dependence.
  219. Value *getAddress() const { return Address; }
  220. };
  221. /// Provides a lazy, caching interface for making common memory aliasing
  222. /// information queries, backed by LLVM's alias analysis passes.
  223. ///
  224. /// The dependency information returned is somewhat unusual, but is pragmatic.
  225. /// If queried about a store or call that might modify memory, the analysis
  226. /// will return the instruction[s] that may either load from that memory or
  227. /// store to it. If queried with a load or call that can never modify memory,
  228. /// the analysis will return calls and stores that might modify the pointer,
  229. /// but generally does not return loads unless a) they are volatile, or
  230. /// b) they load from *must-aliased* pointers. Returning a dependence on
  231. /// must-alias'd pointers instead of all pointers interacts well with the
  232. /// internal caching mechanism.
  233. class MemoryDependenceResults {
  234. // A map from instructions to their dependency.
  235. using LocalDepMapType = DenseMap<Instruction *, MemDepResult>;
  236. LocalDepMapType LocalDeps;
  237. public:
  238. using NonLocalDepInfo = std::vector<NonLocalDepEntry>;
  239. private:
  240. /// A pair<Value*, bool> where the bool is true if the dependence is a read
  241. /// only dependence, false if read/write.
  242. using ValueIsLoadPair = PointerIntPair<const Value *, 1, bool>;
  243. /// This pair is used when caching information for a block.
  244. ///
  245. /// If the pointer is null, the cache value is not a full query that starts
  246. /// at the specified block. If non-null, the bool indicates whether or not
  247. /// the contents of the block was skipped.
  248. using BBSkipFirstBlockPair = PointerIntPair<BasicBlock *, 1, bool>;
  249. /// This record is the information kept for each (value, is load) pair.
  250. struct NonLocalPointerInfo {
  251. /// The pair of the block and the skip-first-block flag.
  252. BBSkipFirstBlockPair Pair;
  253. /// The results of the query for each relevant block.
  254. NonLocalDepInfo NonLocalDeps;
  255. /// The maximum size of the dereferences of the pointer.
  256. ///
  257. /// May be UnknownSize if the sizes are unknown.
  258. LocationSize Size = LocationSize::afterPointer();
  259. /// The AA tags associated with dereferences of the pointer.
  260. ///
  261. /// The members may be null if there are no tags or conflicting tags.
  262. AAMDNodes AATags;
  263. NonLocalPointerInfo() = default;
  264. };
  265. /// Cache storing single nonlocal def for the instruction.
  266. /// It is set when nonlocal def would be found in function returning only
  267. /// local dependencies.
  268. DenseMap<AssertingVH<const Value>, NonLocalDepResult> NonLocalDefsCache;
  269. using ReverseNonLocalDefsCacheTy =
  270. DenseMap<Instruction *, SmallPtrSet<const Value*, 4>>;
  271. ReverseNonLocalDefsCacheTy ReverseNonLocalDefsCache;
  272. /// This map stores the cached results of doing a pointer lookup at the
  273. /// bottom of a block.
  274. ///
  275. /// The key of this map is the pointer+isload bit, the value is a list of
  276. /// <bb->result> mappings.
  277. using CachedNonLocalPointerInfo =
  278. DenseMap<ValueIsLoadPair, NonLocalPointerInfo>;
  279. CachedNonLocalPointerInfo NonLocalPointerDeps;
  280. // A map from instructions to their non-local pointer dependencies.
  281. using ReverseNonLocalPtrDepTy =
  282. DenseMap<Instruction *, SmallPtrSet<ValueIsLoadPair, 4>>;
  283. ReverseNonLocalPtrDepTy ReverseNonLocalPtrDeps;
  284. /// This is the instruction we keep for each cached access that we have for
  285. /// an instruction.
  286. ///
  287. /// The pointer is an owning pointer and the bool indicates whether we have
  288. /// any dirty bits in the set.
  289. using PerInstNLInfo = std::pair<NonLocalDepInfo, bool>;
  290. // A map from instructions to their non-local dependencies.
  291. using NonLocalDepMapType = DenseMap<Instruction *, PerInstNLInfo>;
  292. NonLocalDepMapType NonLocalDepsMap;
  293. // A reverse mapping from dependencies to the dependees. This is
  294. // used when removing instructions to keep the cache coherent.
  295. using ReverseDepMapType =
  296. DenseMap<Instruction *, SmallPtrSet<Instruction *, 4>>;
  297. ReverseDepMapType ReverseLocalDeps;
  298. // A reverse mapping from dependencies to the non-local dependees.
  299. ReverseDepMapType ReverseNonLocalDeps;
  300. /// Current AA implementation, just a cache.
  301. AAResults &AA;
  302. AssumptionCache &AC;
  303. const TargetLibraryInfo &TLI;
  304. DominatorTree &DT;
  305. PhiValues &PV;
  306. PredIteratorCache PredCache;
  307. unsigned DefaultBlockScanLimit;
  308. /// Offsets to dependant clobber loads.
  309. using ClobberOffsetsMapType = DenseMap<LoadInst *, int32_t>;
  310. ClobberOffsetsMapType ClobberOffsets;
  311. public:
  312. MemoryDependenceResults(AAResults &AA, AssumptionCache &AC,
  313. const TargetLibraryInfo &TLI, DominatorTree &DT,
  314. PhiValues &PV, unsigned DefaultBlockScanLimit)
  315. : AA(AA), AC(AC), TLI(TLI), DT(DT), PV(PV),
  316. DefaultBlockScanLimit(DefaultBlockScanLimit) {}
  317. /// Handle invalidation in the new PM.
  318. bool invalidate(Function &F, const PreservedAnalyses &PA,
  319. FunctionAnalysisManager::Invalidator &Inv);
  320. /// Some methods limit the number of instructions they will examine.
  321. /// The return value of this method is the default limit that will be
  322. /// used if no limit is explicitly passed in.
  323. unsigned getDefaultBlockScanLimit() const;
  324. /// Returns the instruction on which a memory operation depends.
  325. ///
  326. /// See the class comment for more details. It is illegal to call this on
  327. /// non-memory instructions.
  328. MemDepResult getDependency(Instruction *QueryInst);
  329. /// Perform a full dependency query for the specified call, returning the set
  330. /// of blocks that the value is potentially live across.
  331. ///
  332. /// The returned set of results will include a "NonLocal" result for all
  333. /// blocks where the value is live across.
  334. ///
  335. /// This method assumes the instruction returns a "NonLocal" dependency
  336. /// within its own block.
  337. ///
  338. /// This returns a reference to an internal data structure that may be
  339. /// invalidated on the next non-local query or when an instruction is
  340. /// removed. Clients must copy this data if they want it around longer than
  341. /// that.
  342. const NonLocalDepInfo &getNonLocalCallDependency(CallBase *QueryCall);
  343. /// Perform a full dependency query for an access to the QueryInst's
  344. /// specified memory location, returning the set of instructions that either
  345. /// define or clobber the value.
  346. ///
  347. /// Warning: For a volatile query instruction, the dependencies will be
  348. /// accurate, and thus usable for reordering, but it is never legal to
  349. /// remove the query instruction.
  350. ///
  351. /// This method assumes the pointer has a "NonLocal" dependency within
  352. /// QueryInst's parent basic block.
  353. void getNonLocalPointerDependency(Instruction *QueryInst,
  354. SmallVectorImpl<NonLocalDepResult> &Result);
  355. /// Removes an instruction from the dependence analysis, updating the
  356. /// dependence of instructions that previously depended on it.
  357. void removeInstruction(Instruction *InstToRemove);
  358. /// Invalidates cached information about the specified pointer, because it
  359. /// may be too conservative in memdep.
  360. ///
  361. /// This is an optional call that can be used when the client detects an
  362. /// equivalence between the pointer and some other value and replaces the
  363. /// other value with ptr. This can make Ptr available in more places that
  364. /// cached info does not necessarily keep.
  365. void invalidateCachedPointerInfo(Value *Ptr);
  366. /// Clears the PredIteratorCache info.
  367. ///
  368. /// This needs to be done when the CFG changes, e.g., due to splitting
  369. /// critical edges.
  370. void invalidateCachedPredecessors();
  371. /// Returns the instruction on which a memory location depends.
  372. ///
  373. /// If isLoad is true, this routine ignores may-aliases with read-only
  374. /// operations. If isLoad is false, this routine ignores may-aliases
  375. /// with reads from read-only locations. If possible, pass the query
  376. /// instruction as well; this function may take advantage of the metadata
  377. /// annotated to the query instruction to refine the result. \p Limit
  378. /// can be used to set the maximum number of instructions that will be
  379. /// examined to find the pointer dependency. On return, it will be set to
  380. /// the number of instructions left to examine. If a null pointer is passed
  381. /// in, the limit will default to the value of -memdep-block-scan-limit.
  382. ///
  383. /// Note that this is an uncached query, and thus may be inefficient.
  384. MemDepResult getPointerDependencyFrom(const MemoryLocation &Loc, bool isLoad,
  385. BasicBlock::iterator ScanIt,
  386. BasicBlock *BB,
  387. Instruction *QueryInst = nullptr,
  388. unsigned *Limit = nullptr);
  389. MemDepResult getPointerDependencyFrom(const MemoryLocation &Loc, bool isLoad,
  390. BasicBlock::iterator ScanIt,
  391. BasicBlock *BB,
  392. Instruction *QueryInst,
  393. unsigned *Limit,
  394. BatchAAResults &BatchAA);
  395. MemDepResult
  396. getSimplePointerDependencyFrom(const MemoryLocation &MemLoc, bool isLoad,
  397. BasicBlock::iterator ScanIt, BasicBlock *BB,
  398. Instruction *QueryInst, unsigned *Limit,
  399. BatchAAResults &BatchAA);
  400. /// This analysis looks for other loads and stores with invariant.group
  401. /// metadata and the same pointer operand. Returns Unknown if it does not
  402. /// find anything, and Def if it can be assumed that 2 instructions load or
  403. /// store the same value and NonLocal which indicate that non-local Def was
  404. /// found, which can be retrieved by calling getNonLocalPointerDependency
  405. /// with the same queried instruction.
  406. MemDepResult getInvariantGroupPointerDependency(LoadInst *LI, BasicBlock *BB);
  407. /// Release memory in caches.
  408. void releaseMemory();
  409. /// Return the clobber offset to dependent instruction.
  410. Optional<int32_t> getClobberOffset(LoadInst *DepInst) const {
  411. const auto Off = ClobberOffsets.find(DepInst);
  412. if (Off != ClobberOffsets.end())
  413. return Off->getSecond();
  414. return None;
  415. }
  416. private:
  417. MemDepResult getCallDependencyFrom(CallBase *Call, bool isReadOnlyCall,
  418. BasicBlock::iterator ScanIt,
  419. BasicBlock *BB);
  420. bool getNonLocalPointerDepFromBB(Instruction *QueryInst,
  421. const PHITransAddr &Pointer,
  422. const MemoryLocation &Loc, bool isLoad,
  423. BasicBlock *BB,
  424. SmallVectorImpl<NonLocalDepResult> &Result,
  425. DenseMap<BasicBlock *, Value *> &Visited,
  426. bool SkipFirstBlock = false,
  427. bool IsIncomplete = false);
  428. MemDepResult getNonLocalInfoForBlock(Instruction *QueryInst,
  429. const MemoryLocation &Loc, bool isLoad,
  430. BasicBlock *BB, NonLocalDepInfo *Cache,
  431. unsigned NumSortedEntries,
  432. BatchAAResults &BatchAA);
  433. void removeCachedNonLocalPointerDependencies(ValueIsLoadPair P);
  434. void verifyRemoved(Instruction *Inst) const;
  435. };
  436. /// An analysis that produces \c MemoryDependenceResults for a function.
  437. ///
  438. /// This is essentially a no-op because the results are computed entirely
  439. /// lazily.
  440. class MemoryDependenceAnalysis
  441. : public AnalysisInfoMixin<MemoryDependenceAnalysis> {
  442. friend AnalysisInfoMixin<MemoryDependenceAnalysis>;
  443. static AnalysisKey Key;
  444. unsigned DefaultBlockScanLimit;
  445. public:
  446. using Result = MemoryDependenceResults;
  447. MemoryDependenceAnalysis();
  448. MemoryDependenceAnalysis(unsigned DefaultBlockScanLimit) : DefaultBlockScanLimit(DefaultBlockScanLimit) { }
  449. MemoryDependenceResults run(Function &F, FunctionAnalysisManager &AM);
  450. };
  451. /// A wrapper analysis pass for the legacy pass manager that exposes a \c
  452. /// MemoryDepnedenceResults instance.
  453. class MemoryDependenceWrapperPass : public FunctionPass {
  454. Optional<MemoryDependenceResults> MemDep;
  455. public:
  456. static char ID;
  457. MemoryDependenceWrapperPass();
  458. ~MemoryDependenceWrapperPass() override;
  459. /// Pass Implementation stuff. This doesn't do any analysis eagerly.
  460. bool runOnFunction(Function &) override;
  461. /// Clean up memory in between runs
  462. void releaseMemory() override;
  463. /// Does not modify anything. It uses Value Numbering and Alias Analysis.
  464. void getAnalysisUsage(AnalysisUsage &AU) const override;
  465. MemoryDependenceResults &getMemDep() { return *MemDep; }
  466. };
  467. } // end namespace llvm
  468. #endif // LLVM_ANALYSIS_MEMORYDEPENDENCEANALYSIS_H
  469. #ifdef __GNUC__
  470. #pragma GCC diagnostic pop
  471. #endif