Skip to content

Use F.hasOptSize() instead of checking optsize directly #147348

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions llvm/lib/CodeGen/MachineFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ void MachineFunction::init() {
Alignment = STI->getTargetLowering()->getMinFunctionAlignment();

// FIXME: Shouldn't use pref alignment if explicit alignment is set on F.
// FIXME: Use Function::hasOptSize().
if (!F.hasFnAttribute(Attribute::OptimizeForSize))
if (!F.hasOptSize())
Alignment = std::max(Alignment,
STI->getTargetLowering()->getPrefFunctionAlignment());

Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4261,8 +4261,7 @@ std::optional<unsigned> ARMBaseInstrInfo::getOperandLatencyImpl(
// instructions).
if (Latency > 0 && Subtarget.isThumb2()) {
const MachineFunction *MF = DefMI.getParent()->getParent();
// FIXME: Use Function::hasOptSize().
if (MF->getFunction().hasFnAttribute(Attribute::OptimizeForSize))
if (MF->getFunction().hasOptSize())
--Latency;
}
return Latency;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/Hexagon/HexagonCopyToCombine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ bool HexagonCopyToCombine::runOnMachineFunction(MachineFunction &MF) {
TII = ST->getInstrInfo();

const Function &F = MF.getFunction();
bool OptForSize = F.hasFnAttribute(Attribute::OptimizeForSize);
bool OptForSize = F.hasOptSize();

// Combine aggressively (for code size)
ShouldCombineAggressively =
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/Hexagon/HexagonMask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ bool HexagonMask::runOnMachineFunction(MachineFunction &MF) {
HII = HST.getInstrInfo();
const Function &F = MF.getFunction();

if (!F.hasFnAttribute(Attribute::OptimizeForSize))
if (!F.hasOptSize())
return false;
// Mask instruction is available only from v66
if (!HST.hasV66Ops())
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ static bool PGOMemOPSizeOptImpl(Function &F, BlockFrequencyInfo &BFI,
if (DisableMemOPOPT)
return false;

if (F.hasFnAttribute(Attribute::OptimizeForSize))
if (F.hasOptSize())
return false;
MemOPSizeOpt MemOPSizeOpt(F, BFI, ORE, DT, TLI);
MemOPSizeOpt.perform();
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Utils/LibCallsShrinkWrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ bool LibCallsShrinkWrap::perform(CallInst *CI) {

static bool runImpl(Function &F, const TargetLibraryInfo &TLI,
DominatorTree *DT) {
if (F.hasFnAttribute(Attribute::OptimizeForSize))
if (F.hasOptSize())
return false;
DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy);
LibCallsShrinkWrap CCDCE(TLI, DTU);
Expand Down
Loading