-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Remove llvm::shouldOptForSize() from Utils.h #112630
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |||||||
| #include "llvm/CodeGen/MachineInstr.h" | ||||||||
| #include "llvm/CodeGenTypes/LowLevelType.h" | ||||||||
| #include "llvm/IR/Function.h" | ||||||||
| #include "llvm/Transforms/Utils/SizeOpts.h" | ||||||||
| #include <bitset> | ||||||||
| #include <cstddef> | ||||||||
| #include <cstdint> | ||||||||
|
|
@@ -635,8 +636,12 @@ class GIMatchTableExecutor { | |||||||
|
|
||||||||
| bool shouldOptForSize(const MachineFunction *MF) const { | ||||||||
| const auto &F = MF->getFunction(); | ||||||||
| return F.hasOptSize() || F.hasMinSize() || | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lost the hasMinSize check?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned above (but got lost in the changes), llvm-project/llvm/include/llvm/IR/Function.h Lines 707 to 709 in 927af63
|
||||||||
| (PSI && BFI && CurMBB && llvm::shouldOptForSize(*CurMBB, PSI, BFI)); | ||||||||
| if (F.hasOptSize()) | ||||||||
| return true; | ||||||||
| if (CurMBB) | ||||||||
| if (auto *BB = CurMBB->getBasicBlock()) | ||||||||
| return llvm::shouldOptimizeForSize(BB, PSI, BFI); | ||||||||
| return false; | ||||||||
| } | ||||||||
|
|
||||||||
| public: | ||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.
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.
I don't think this is from your change, but it's a bit confusing how
shouldOptForSizediffers fromllvm::shouldOptimizeForSize. I guess this is specifically used for GISel, and as long as the current processing block is optimized for size, we consider this function optimized for size? But don't we derive this check for a block by checking its parent function? Basically, my understanding is that even ifshouldOptimizeForSizefor a function is false,shouldOptimizeForSizefor a block that belongs to the function may be true. Here, it doesn't seem like that's the case.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.
Yes, I would like to remove this too, but this caused some build errors because of generated code. In fact, some implementors don't even check PGO.
llvm-project/llvm/include/llvm/CodeGen/FastISel.h
Lines 520 to 523 in 66bbbf2
Since I'm less familiar with ISel, I thought I'd leave this alone for now.
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 appears that ISel generally prioritizes optimization for size. Since the
shouldOptForSizederives its result from the current processing block, the outcome may not be consistent depending on which blocks are being processed, which is counterintuitive.Upon examining another usage of DAGISel below, I believe this API is actually asking whether the current function should be optimized for size based on the current processing block or DAG.
llvm-project/llvm/include/llvm/CodeGen/SelectionDAGISel.h
Lines 396 to 398 in 66bbbf2
So, we should keep this way on this context.