Skip to content

Conversation

@makslevental
Copy link
Contributor

@makslevental makslevental commented Apr 10, 2025

This PR fixes Wdangling-assignment-gsl in circt-bmc, circt-lec, and arcilator.

@makslevental makslevental force-pushed the makslevental/bump-llvm branch 2 times, most recently from 3acf2eb to f6b9046 Compare April 10, 2025 03:54
@makslevental makslevental marked this pull request as ready for review April 10, 2025 04:12
@makslevental makslevental force-pushed the makslevental/bump-llvm branch from f6b9046 to 5678a83 Compare April 10, 2025 04:13
engineOptions.transformer = mlir::makeOptimizingTransformer(
/*optLevel=*/3, /*sizeLevel=*/0,
/*targetMachine=*/nullptr);
static std::function<llvm::Error(llvm::Module *)> transformer =
Copy link
Contributor Author

@makslevental makslevental Apr 10, 2025

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.

Copy link
Contributor

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 🤔

Copy link
Contributor Author

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

Copy link
Member

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?

Copy link
Contributor Author

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.

@mikeurbach
Copy link
Contributor

@makslevental I had started an LLVM update here: #8404. Should I get that one in before your SMT-focused changes?

@makslevental
Copy link
Contributor Author

@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 function_ref.

@mikeurbach
Copy link
Contributor

Ok, I merged mine. Sorry for the delay and apparent merge conflicts. Hopefully simple to rebase and just deal with the function_ref thing.

@makslevental makslevental force-pushed the makslevental/bump-llvm branch from 5678a83 to 7177f88 Compare April 10, 2025 18:56
@makslevental makslevental changed the title [LLVM] bump to 747d4a95 [tools] fix Wdangling-assignment-gsl Apr 10, 2025
@makslevental
Copy link
Contributor Author

Okay I rebased and renamed this PR to just be about Wdangling-assignment-gsl.

engineOptions.transformer = mlir::makeOptimizingTransformer(
/*optLevel=*/3, /*sizeLevel=*/0,
/*targetMachine=*/nullptr);
static std::function<llvm::Error(llvm::Module *)> transformer =
Copy link
Member

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?

mlir::ExecutionEngineOptions engineOptions;
engineOptions.transformer = mlir::makeOptimizingTransformer(
/*optLevel*/ 3, /*sizeLevel=*/0, /*targetMachine=*/nullptr);
static std::function<llvm::Error(llvm::Module *)> transformer =
Copy link
Member

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)?

@makslevental makslevental force-pushed the makslevental/bump-llvm branch from 7177f88 to 5983e60 Compare April 14, 2025 17:36
@makslevental makslevental requested a review from maerhart April 14, 2025 17:44
mlir::ExecutionEngineOptions engineOptions;
engineOptions.transformer = mlir::makeOptimizingTransformer(
/*optLevel*/ 3, /*sizeLevel=*/0, /*targetMachine=*/nullptr);
std::function<llvm::Error(llvm::Module *)> transformer =
Copy link
Member

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)

@makslevental makslevental force-pushed the makslevental/bump-llvm branch from 5983e60 to 4e939ac Compare April 14, 2025 18:23
Copy link
Member

@maerhart maerhart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@makslevental makslevental merged commit 39b4aa7 into llvm:main Apr 14, 2025
5 checks passed
@makslevental makslevental deleted the makslevental/bump-llvm branch April 14, 2025 18:45
RonxBulld pushed a commit to RonxBulld/hs-circt that referenced this pull request Apr 15, 2025
KelvinChung2000 pushed a commit to KelvinChung2000/circt that referenced this pull request Apr 22, 2025
TaoBi22 pushed a commit to TaoBi22/circt that referenced this pull request Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants