-
Notifications
You must be signed in to change notification settings - Fork 31
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
Function to estimate stack size #1116
Conversation
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.
This is very nice! I just have some nits, so approving as well.
|
||
// Derived from lines containing substrings like 'paddb [sp], #224;' | ||
// There is one vector of ints per function. | ||
SmallVector<SmallVector<int>> bumps; |
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.
Nit, but you could use uint32_t
as bumps would always be positive right? Same for a couple of other int
variables in this function.
llvm::errs() << "Failed to get stack size from assembly file\n"; | ||
return failure(); | ||
} | ||
auto upperBounds = std::move(maybeUpperBounds.value()); |
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.
auto upperBounds = std::move(maybeUpperBounds.value()); | |
llvm::DenseMap<std::pair<int, int>, int> upperBounds = std::move(maybeUpperBounds.value()); |
<< ") is not found in the assembly file. "; | ||
return failure(); | ||
} | ||
auto stackSize = coreOp.getStackSize(); |
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.
auto stackSize = coreOp.getStackSize(); | |
int32_t stackSize = coreOp.getStackSize(); |
mlir::FailureOr<llvm::DenseMap<std::pair<int, int>, int>> ubs = | ||
detail::getUpperBoundStackSizes(asmStr); | ||
EXPECT_TRUE(succeeded(ubs)); | ||
// auto upperBounds = maybeUpperBounds.value(); |
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.
// auto upperBounds = maybeUpperBounds.value(); |
mlir::FailureOr<llvm::DenseMap<std::pair<int, int>, int>> ubs = | ||
detail::getUpperBoundStackSizes(asmStr); | ||
EXPECT_TRUE(succeeded(ubs)); | ||
// auto upperBounds = maybeUpperBounds.value(); |
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.
// auto upperBounds = maybeUpperBounds.value(); |
mlir::FailureOr<llvm::DenseMap<std::pair<int, int>, int>> maybeUpperBounds = | ||
detail::getUpperBoundStackSizes(asmStr); | ||
EXPECT_TRUE(succeeded(maybeUpperBounds)); | ||
auto upperBounds = maybeUpperBounds.value(); |
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.
auto upperBounds = maybeUpperBounds.value(); | |
llvm::DenseMap<std::pair<int, int>, int> upperBounds = maybeUpperBounds.value(); |
Closing in favor of #1121 |
This will replace #1116 -- instead of string matching the assembly file, it uses llvm's `llvm-readelf` after adding `--stack-size-section` to the llc call. Please read the paper trail of PRs I've left here for more information.
This is a simpler version of #1104
In this PR, the stack size is not set based on the assembly analysis, this PR just adds a check that the assigned stack is sufficient.
I have checked this locally by changing the stack size here and it works fine.
This should help avoid the bad situations like Xilinx/llvm-aie#342
Next steps (I'd like to do these in a separate PR):