Files
swift-mirror/lib/SIL/Verifier/VerifierPrivate.h
Andrew Trick 8e3fb44f2d Rewrite LoadBorrowImmutabilityChecker using AccessPath.
The verification will now be as complete as it can be within the
capability of our SIL utilities. It is much more aggressive with
respect to boxes, references, and pointers. It's more efficient in
that it only considers "overlapping" uses.

It is also now wholly consistent with the utilities that it uses, so
can be reenabled.

We could probably go even further and remove the switch statement
entirely, relying on AccessPath to recognize any operations that
propagate addresses, boxes, or pointers. But I didn't want to
potentially weaken enforcement without more careful consideration.
2020-10-21 15:02:08 -07:00

51 lines
1.4 KiB
C++

//===--- VerifierPrivate.h ------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_SIL_VERIFIER_VERIFIERPRIVATE_H
#define SWIFT_SIL_VERIFIER_VERIFIERPRIVATE_H
#include "swift/Basic/MultiMapCache.h"
#include "swift/SIL/MemAccessUtils.h"
#include "swift/SIL/SILValue.h"
namespace swift {
class BeginAccessInst;
class LoadBorrowInst;
class SILValue;
class Operand;
namespace silverifier {
class LoadBorrowImmutabilityAnalysis {
SmallMultiMapCache<AccessPath, Operand *> cache;
DeadEndBlocks &deadEndBlocks;
public:
LoadBorrowImmutabilityAnalysis(DeadEndBlocks &deadEndBlocks,
const SILFunction *f);
/// Returns true if exhaustively lbi is guaranteed to never be invalidated by
/// local writes.
bool isImmutable(LoadBorrowInst *lbi);
private:
bool isImmutableInScope(LoadBorrowInst *lbi,
ArrayRef<Operand *> endBorrowUses,
AccessPath accessPath);
};
} // namespace silverifier
} // namespace swift
#endif