mirror of https://github.com/llvm/circt.git
Disable MLIR multithreading while parsing input, this speeds up the
parser (which doesn't a lot of IR generation) by about 18%!
This commit is contained in:
parent
90daf8bbcf
commit
7a80afaad6
|
@ -7,10 +7,10 @@
|
|||
#include "cirt/FIRParser.h"
|
||||
#include "FIRLexer.h"
|
||||
#include "cirt/Dialect/FIRRTL/Ops.h"
|
||||
#include "mlir/IR/Verifier.h"
|
||||
#include "mlir/IR/Diagnostics.h"
|
||||
#include "mlir/IR/Module.h"
|
||||
#include "mlir/IR/StandardTypes.h"
|
||||
#include "mlir/IR/Verifier.h"
|
||||
#include "mlir/Translation.h"
|
||||
#include "llvm/ADT/ScopedHashTable.h"
|
||||
#include "llvm/Support/SourceMgr.h"
|
||||
|
|
|
@ -79,6 +79,10 @@ int main(int argc, char **argv) {
|
|||
auto processBuffer = [&](std::unique_ptr<llvm::MemoryBuffer> ownedBuffer,
|
||||
raw_ostream &os) {
|
||||
MLIRContext context;
|
||||
|
||||
// Nothing here is threaded. Disable synchronization overhead.
|
||||
context.disableMultithreading();
|
||||
|
||||
llvm::SourceMgr sourceMgr;
|
||||
sourceMgr.AddNewSourceBuffer(std::move(ownedBuffer), llvm::SMLoc());
|
||||
|
||||
|
|
|
@ -70,6 +70,9 @@ processBuffer(std::unique_ptr<llvm::MemoryBuffer> ownedBuffer,
|
|||
sourceMgr.AddNewSourceBuffer(std::move(ownedBuffer), llvm::SMLoc());
|
||||
SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context);
|
||||
|
||||
// Nothing in the parser is threaded. Disable synchronization overhead.
|
||||
context.disableMultithreading();
|
||||
|
||||
OwningModuleRef module;
|
||||
if (inputFormat == InputFIRFile) {
|
||||
FIRParserOptions options;
|
||||
|
@ -82,6 +85,9 @@ processBuffer(std::unique_ptr<llvm::MemoryBuffer> ownedBuffer,
|
|||
if (!module)
|
||||
return failure();
|
||||
|
||||
// Allow optimizations to run multithreaded.
|
||||
context.disableMultithreading(false);
|
||||
|
||||
// If enabled, run the optimizer.
|
||||
if (!disableOptimization) {
|
||||
// Apply any pass manager command line options.
|
||||
|
|
Loading…
Reference in New Issue