flang the compiler proves your program cannot hang 0.7.41 GitHub Try in the browserTry it Русский

The proof cache

This page answers the question: how not to prove the same thing on every run. flang check and flang emit prove the postconditions anew each time. The cache keeps the kernel's answers on disk and returns them until something the answer depends on changes. The cache is off by default.

How to turn it on

FLANG_PROOF_CACHE=on flang check --proof discount.flang
Value of FLANG_PROOF_CACHEWhat happens
unset, empty, off, 0no cache
on, 1the directory .flang-cache/proofs/ in the project root — the nearest directory upward with .flangrc or .git
anything elsea path to the cache directory

You can delete the directory at any time. It does not go into git.

How to see that the cache works

FLANG_PROOF_CACHE_STATS=1 adds counter lines. Two runs in a row on the file docs/examples/proofs/discount.flang:

FLANG_PROOF_CACHE=on FLANG_PROOF_CACHE_STATS=1 flang check --proof discount.flang
кеш доказательств: взято записей 0, попаданий 0, новых 10, потеряно 0, отвергнуто сегментов 0
FLANG_PROOF_CACHE=on FLANG_PROOF_CACHE_STATS=1 flang check --proof discount.flang
кеш доказательств: взято записей 10, попаданий 4, новых 0, потеряно 0, отвергнуто сегментов 0

The first run computed the answers and wrote ten entries. The second read them from disk and took a ready answer four times. «Сегмент» in the output is one cache file.

When an answer is computed anew

A cache entry fits only if everything the answer depends on matches:

Editing a function the postcondition does not depend on leaves its entry alone. After editing one function of a large file only what is connected with it is recomputed.

Why the cache will not let a false proof through

The cache neither adds trust nor takes it away: it holds answers of the same kernel. What you are trusting when you see «доказано» is on a separate page.

Variables

VariableWhat it does
FLANG_PROOF_CACHEturns the cache on and sets the directory
FLANG_PROOF_CACHE_STATS=1counter lines on stderr
FLANG_PROOF_CACHE_AUDIT=1the answer for a part of the program is compared with the answer for the whole program
FLANG_MEMO_AUDIT=1every hit is recomputed and compared with the entry
FLANG_PROOF_CACHE_KEYa signing key file instead of ~/.config/flang/proof-cache.key
FLANG_PROOF_CACHE_RECHECK=0do not run the independent check of the record after a run with hits

Where it is

.flang-cache/proofs/<fingerprint of the flang program>/<fingerprint of the file path>/<number>.seg

A directory of its own for every version of flang and every input file. Two simultaneous runs on one file do not disturb each other: the file is written under a temporary name and renamed.