-
Notifications
You must be signed in to change notification settings - Fork 389
[tools] fix Wdangling-assignment-gsl
#8407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
3acf2eb to
f6b9046
Compare
f6b9046 to
5678a83
Compare
tools/arcilator/arcilator.cpp
Outdated
| engineOptions.transformer = mlir::makeOptimizingTransformer( | ||
| /*optLevel=*/3, /*sizeLevel=*/0, | ||
| /*targetMachine=*/nullptr); | ||
| static std::function<llvm::Error(llvm::Module *)> transformer = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise
warning: object backing the pointer engineOptions.transformer will be destroyed
at the end of the full-expression [-Wdangling-assignment-gsl]
because engineOptions.transformer is a function_ref.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is using a global variable the approved way of doing this upstream? I suspect a auto transformer = ...; engineOptions.transformer = transformer; might suffice 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's locally allocated/scope - it'll die at the end of the body while the executionEngine is returned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it looks like an auto transformer = ... would have the same lifetime as the execution engine. Where is the engine returned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh um whoops - I skimmed the file too quickly (the return is success). Lemme change.
|
@makslevental I had started an LLVM update here: #8404. Should I get that one in before your SMT-focused changes? |
ah sorry didn't notice that one. yea this one needs to precede the SMT integration. looks like the only diff between mine and yours is this thing with |
|
Ok, I merged mine. Sorry for the delay and apparent merge conflicts. Hopefully simple to rebase and just deal with the function_ref thing. |
5678a83 to
7177f88
Compare
Wdangling-assignment-gsl
|
Okay I rebased and renamed this PR to just be about |
tools/arcilator/arcilator.cpp
Outdated
| engineOptions.transformer = mlir::makeOptimizingTransformer( | ||
| /*optLevel=*/3, /*sizeLevel=*/0, | ||
| /*targetMachine=*/nullptr); | ||
| static std::function<llvm::Error(llvm::Module *)> transformer = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it looks like an auto transformer = ... would have the same lifetime as the execution engine. Where is the engine returned?
tools/circt-lec/circt-lec.cpp
Outdated
| mlir::ExecutionEngineOptions engineOptions; | ||
| engineOptions.transformer = mlir::makeOptimizingTransformer( | ||
| /*optLevel*/ 3, /*sizeLevel=*/0, /*targetMachine=*/nullptr); | ||
| static std::function<llvm::Error(llvm::Module *)> transformer = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't a std::function<llvm::Error(llvm::Module *)> transformer; declaration above where the engine variable is declared (i.e. outside this local scope) be enough (instead of using static here)?
7177f88 to
5983e60
Compare
tools/circt-bmc/circt-bmc.cpp
Outdated
| mlir::ExecutionEngineOptions engineOptions; | ||
| engineOptions.transformer = mlir::makeOptimizingTransformer( | ||
| /*optLevel*/ 3, /*sizeLevel=*/0, /*targetMachine=*/nullptr); | ||
| std::function<llvm::Error(llvm::Module *)> transformer = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you have to declare the variable outside this nested scope, because otherwise it'd be deallocated at the engine->invokePacked call, right? (also in circt-lec.cpp)
5983e60 to
4e939ac
Compare
maerhart
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This PR fixes
Wdangling-assignment-gslincirct-bmc,circt-lec, andarcilator.