Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiler which can run its components in parallel mode

Do we have today a compiler infrastructure, which can run its components in parallel mode to increase compilation speed in common? For example when code generator starts emit the code for target platform, possibly, compiler infrastructure can do lexical & syntactical analysis for next source file at the same time. Does we have any related research in this topic?

UPD0: This is a relative answer.

like image 359
pmor Avatar asked Mar 10 '26 23:03

pmor


1 Answers

LLVM doesn't perform multithreaded compilation, but it theoretically could because each compiler pass can only mutate a certain 'scope' of the IR. From the docs:

Depending on how your pass works, you should inherit from the ModulePass , CallGraphSCCPass, FunctionPass , or LoopPass, or RegionPass, or BasicBlockPass classes, which gives the system more information about what your pass does, and how it can be combined with other passes. One of the main features of the LLVM Pass Framework is that it schedules passes to run in an efficient way based on the constraints that your pass meets (which are indicated by which class they derive from).

In practice, fine-grained parallelism in compiler passes probably isn't worth the overhead of synchronization (and the inevitable bugs when a pass touches more than it claims to) given that individual source files in large programs can be compiled in parallel. The different pass classes are primarily useful for documentation. They can also help in scheduling passes in a cache-friendly way; for example, when running a bunch of FunctionPasses on all the translation unit's functions, it's faster to run each pass on one function (keeping it in cache) before moving to the next function.

like image 162
Jeffrey Bosboom Avatar answered Mar 15 '26 00:03

Jeffrey Bosboom



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!