21#include <mlir/Dialect/SCF/IR/SCF.h>
22#include <mlir/Interfaces/CallInterfaces.h>
24#include <llvm/ADT/DenseMap.h>
25#include <llvm/ADT/DenseSet.h>
26#include <llvm/ADT/SetVector.h>
27#include <llvm/ADT/SmallVector.h>
64 return llvm::hash_combine(
73 static_cast<uint8_t
>(lhs) |
static_cast<uint8_t
>(rhs)
85 return static_cast<uint8_t
>(influence) != 0;
91 return (
static_cast<uint8_t
>(influence) &
static_cast<uint8_t
>(flag)) != 0;
104template <
typename T,
typename... Args>
105inline ForbiddenPreconditionInfluenceInfo
135 return llvm::hash_combine(
166 llvm::SmallVector<IncludedContractFailure>
failures;
168 explicit operator bool()
const {
return !
failures.empty(); }
190 return llvm::hash_combine(
225 mlir::CallableOpInterface callableOp, llvm::ArrayRef<InfluenceInfo> argInfluences,
226 unsigned resultNumber
249 class AnalysisFrame {
254 llvm::ArrayRef<InfluenceInfo> argInfluenceInfos,
274 InfluenceInfo analyzeAncestorControl(mlir::Operation *ancestor, mlir::Operation *nestedOp);
277 InfluenceInfo analyzeBlockArgument(mlir::BlockArgument blockArg);
280 InfluenceInfo analyzeCallResult(mlir::CallOpInterface call, mlir::OpResult callRes);
283 InfluenceInfo analyzeIfResult(mlir::scf::IfOp ifOp, mlir::OpResult ifRes);
286 InfluenceInfo analyzeForResult(mlir::scf::ForOp forOp, mlir::OpResult forRes);
291 analyzeExecuteRegionResult(mlir::scf::ExecuteRegionOp execOp, mlir::OpResult execRes);
294 InfluenceInfo analyzeWhileResult(mlir::scf::WhileOp whileOp, mlir::OpResult whileRes);
297 llvm::DenseMap<mlir::Value, InfluenceInfo> valueCache;
298 llvm::DenseMap<mlir::Operation *, InfluenceInfo> controlAncestorCache;
299 llvm::DenseSet<mlir::Value> activeValues;
308 mlir::ModuleOp module;
309 llvm::DenseMap<CallableSummaryKey, InfluenceInfo, CallableSummaryKeyInfo> callableSummaryCache;
310 llvm::DenseSet<CallableSummaryKey, CallableSummaryKeyInfo> activeSummaries;
312 IncludedContractSummaryKey, IncludedContractSummary, IncludedContractSummaryKeyInfo>
313 includedContractSummaryCache;
314 llvm::DenseSet<IncludedContractSummaryKey, IncludedContractSummaryKeyInfo>
315 activeIncludedSummaries;
316 llvm::DenseMap<ContractOp, AnalysisFrame> cachedFrames;
347 mlir::ModuleOp module, mlir::CallableOpInterface callableOp,
348 llvm::ArrayRef<ForbiddenPreconditionInfluenceInfo> argInfluences,
unsigned resultNumber
351 callableOp, argInfluences, resultNumber
358 mlir::ModuleOp module, mlir::CallableOpInterface callableOp,
359 llvm::ArrayRef<ForbiddenPreconditionInfluenceInfo> argInfluences,
unsigned resultNumber
362 module, callableOp, argInfluences, resultNumber
371 llvm::ArrayRef<ForbiddenPreconditionInfluenceInfo> argInfluences
374 calleeContract, argInfluences
Interprocedural verifier-local analysis for forbidden precondition influence.
InfluenceInfo analyzeCallableResult(mlir::CallableOpInterface callableOp, llvm::ArrayRef< InfluenceInfo > argInfluences, unsigned resultNumber)
Summarize the forbidden influence of one callable result under the given argument influences.
IncludedContractSummary analyzeIncludedContract(verif::ContractOp calleeContract, llvm::ArrayRef< InfluenceInfo > argInfluences, const InfluenceInfo &inheritedControlInfluence=InfluenceInfo::None())
Check whether an included contract becomes invalid under caller-provided operand influences,...
IncludedContractSummary analyzeIncludedOp(verif::ContractOp contract, verif::IncludeOp includeOp)
Check whether an include op becomes invalid under its caller's operand bindings and enclosing SCF con...
InfluenceInfo analyzePreconditionOp(verif::ContractOp contract, verif::PreconditionOpInterface preCondOp)
Classify the forbidden influence reaching a precondition op, including both the condition operand and...
InfluenceInfo analyzeContractValue(verif::ContractOp contract, mlir::Value value)
Classify the forbidden influence reaching a value inside a contract body.
ForbiddenInfluenceAnalyzer(mlir::ModuleOp owningModule)
Create a verifier-local analyzer for one LLZK module.
Common interface for constant parameter-like symbol operations that can be defined within a TemplateO...
ForbiddenPreconditionInfluence Influence
ForbiddenPreconditionInfluenceInfo InfluenceInfo
ForbiddenPreconditionInfluence analyzeForbiddenPreconditionCallableResult(mlir::ModuleOp module, mlir::CallableOpInterface callableOp, llvm::ArrayRef< ForbiddenPreconditionInfluenceInfo > argInfluences, unsigned resultNumber)
Analyze whether a callable result depends on forbidden precondition sources under a caller-provided a...
ForbiddenPreconditionInfluenceInfo analyzeForbiddenPreconditionCallableResultInfo(mlir::ModuleOp module, mlir::CallableOpInterface callableOp, llvm::ArrayRef< ForbiddenPreconditionInfluenceInfo > argInfluences, unsigned resultNumber)
Analyze whether a callable result depends on forbidden precondition sources under a caller-provided a...
detail::IncludedContractSummary analyzeForbiddenIncludedContractSummary(mlir::ModuleOp module, verif::ContractOp calleeContract, llvm::ArrayRef< ForbiddenPreconditionInfluenceInfo > argInfluences)
Analyze whether including a contract with caller-provided operand influence summaries would trigger a...
ForbiddenPreconditionInfluenceInfo mergeInfluenceInfo(ForbiddenPreconditionInfluenceInfo lhs, const ForbiddenPreconditionInfluenceInfo &rhs)
Merge two forbidden-influence summaries, preserving the first known source location for each forbidde...
detail::IncludedContractSummary analyzeForbiddenIncludedOpSummary(mlir::ModuleOp module, verif::ContractOp contract, verif::IncludeOp includeOp)
Analyze whether a specific include op triggers forbidden preconditions in the callee,...
ForbiddenPreconditionInfluenceInfo analyzeForbiddenPreconditionInfluenceInfo(mlir::ModuleOp module, verif::ContractOp contract, mlir::Value value)
Analyze whether a contract value depends on forbidden precondition sources and recover representative...
ForbiddenPreconditionInfluence operator|(ForbiddenPreconditionInfluence lhs, ForbiddenPreconditionInfluence rhs)
ForbiddenPreconditionInfluence
Sources of information that are not allowed in contract preconditions.
bool hasInfluence(ForbiddenPreconditionInfluence influence, ForbiddenPreconditionInfluence flag)
Return true when influence contains the requested flag.
ForbiddenPreconditionInfluenceInfo analyzeForbiddenPreconditionOpInfluenceInfo(mlir::ModuleOp module, verif::ContractOp contract, verif::PreconditionOpInterface preCondOp)
Analyze whether a precondition op depends on forbidden sources, including both its condition operand ...
ForbiddenPreconditionInfluence analyzeForbiddenPreconditionInfluence(mlir::ModuleOp module, verif::ContractOp contract, mlir::Value value)
Analyze whether a contract value depends on forbidden precondition sources.
llvm::hash_code hash_value(const ForbiddenPreconditionInfluenceInfo &info)
ForbiddenPreconditionInfluence & operator|=(ForbiddenPreconditionInfluence &lhs, ForbiddenPreconditionInfluence rhs)
bool any(ForbiddenPreconditionInfluence influence)
Return true when the influence set contains at least one classification.
Summary of forbidden precondition influence along with representative source locations for each forbi...
static ForbiddenPreconditionInfluenceInfo StructMember()
ForbiddenPreconditionInfluence influence
llvm::SmallSetVector< mlir::Location, 2 > structMemberLocs
bool operator==(const ForbiddenPreconditionInfluenceInfo &other) const
static ForbiddenPreconditionInfluenceInfo None()
static ForbiddenPreconditionInfluenceInfo FunctionReturn()
static unsigned getHashValue(const CallableSummaryKey &key)
static bool isEqual(const CallableSummaryKey &lhs, const CallableSummaryKey &rhs)
Cache key for one interprocedural callable-result summary query.
bool operator==(const CallableSummaryKey &other) const
llvm::SmallVector< InfluenceInfo > argInfluences
mlir::Operation * callable
One included precondition that becomes illegal under a specific caller binding.
InfluenceInfo influenceInfo
std::optional< mlir::Location > preconditionLoc
static bool isEqual(const IncludedContractSummaryKey &lhs, const IncludedContractSummaryKey &rhs)
static unsigned getHashValue(const IncludedContractSummaryKey &key)
Cache key for one interprocedural included-contract summary query.
llvm::SmallVector< InfluenceInfo > argInfluences
InfluenceInfo inheritedControlInfluence
mlir::Operation * contract
bool operator==(const IncludedContractSummaryKey &other) const
Summary of all included-contract precondition failures under a specific caller binding.
llvm::SmallVector< IncludedContractFailure > failures