Skip to main content

Questions tagged [static-analysis]

For questions about approaches for determining properties of a program from the code without evaluating it

5 votes
1 answer
167 views

How is Go's DSE implemented?

Apparently, Go can implement a dead store analysis in the compiler without a CFG. I stumbled upon this example: ...
feldentm's user avatar
  • 1,969
8 votes
1 answer
378 views

How can I account for expressions when building control-flow graphs?

How do statically typed programming languages build CFGs for programs containing expression-level control flow (e.g. ternary expressions, match expressions) which require transformation or extra ...
WZoG's user avatar
  • 83
5 votes
1 answer
1k views

How is "Ignore next line" implemented in linters?

Most every linter has an option to "ignore" some parts of the code: /* @eslint-ignore-next-line semi */ // @phpstan-ignore // @ts-ignore # noqa: E731 etc. ...
mousetail's user avatar
  • 8,531
0 votes
1 answer
196 views

How to minimize total size of static data?

I am implementing a WASM backend and I hope to optimize the size. I have collected a series of static data. After erasing the type, it can be simply considered as ...
Aster's user avatar
  • 3,238
10 votes
1 answer
1k views

What are the tradeoffs between using sea of nodes, CFG of basic blocks, and egraphs for compiler optimizations?

I've heard of "sea of nodes" intermediate representations mostly in the context of just-in-time compilation (JVM, V8, Graal) whereas intermediate representations such as LLVM IR are used in ...
Troy Sargent's user avatar
12 votes
4 answers
1k views

How can type systems be a useful formal framework for modeling things other than type-checking?

Quoting one of Alexis King's answers: Many programming language researchers would call many things “type systems” that programmers probably don’t think of as type systems. Many forms of static ...
kaya3's user avatar
  • 20k
11 votes
3 answers
316 views

How can a language statically ensure a required index exists in a list?

Suppose a language has a conventional list data structure that contains some dynamic number of values indexed sequentially. Some operations to access a value from the list require that a certain index ...
Michael Homer's user avatar
  • 13.1k
4 votes
2 answers
189 views

How to estimate which parts of a program will be slow?

Many modern compilers are sophisticated enough to determine that some functions or expressions can be computed lazily, memoised, or parallelised. For example, pure functions can be computed at any ...
kaya3's user avatar
  • 20k
7 votes
3 answers
525 views

How to verify function purity in an imperative language?

A pure function in an imperative language means one with no observable side-effects, which when called multiple times with identical arguments will always return identical results, and which doesn't ...
kaya3's user avatar
  • 20k
5 votes
2 answers
290 views

How can I implement a control flow graph?

A Control-Flow-Graph is: In computer science, a control-flow graph (CFG) is a representation, using graph notation, of all paths that might be traversed through a program during its execution. The ...
FireTheLost's user avatar
  • 1,613
3 votes
3 answers
176 views

Why do some languages not have an 'unreachable' function?

Several languages have a function or macro to indicate that a certain point in control flow cannot be reached, even though the compiler cannot statically prove it, such as ...
Bbrk24's user avatar
  • 9,127