Skip to content

Commit 819f020

Browse files
authored
Use F.hasOptSize() instead of checking optsize directly (#147348)
1 parent a496a98 commit 819f020

File tree

9 files changed

+24
-10
lines changed

9 files changed

+24
-10
lines changed

llvm/lib/CodeGen/MachineFunction.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,7 @@ void MachineFunction::init() {
211211
ConstantPool = new (Allocator) MachineConstantPool(getDataLayout());
212212
Alignment = STI->getTargetLowering()->getMinFunctionAlignment();
213213

214-
// FIXME: Use Function::hasOptSize().
215-
if (!F.getAlign() && !F.hasFnAttribute(Attribute::OptimizeForSize))
214+
if (!F.getAlign() && !F.hasOptSize())
216215
Alignment = std::max(Alignment,
217216
STI->getTargetLowering()->getPrefFunctionAlignment());
218217

llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4261,8 +4261,7 @@ std::optional<unsigned> ARMBaseInstrInfo::getOperandLatencyImpl(
42614261
// instructions).
42624262
if (Latency > 0 && Subtarget.isThumb2()) {
42634263
const MachineFunction *MF = DefMI.getParent()->getParent();
4264-
// FIXME: Use Function::hasOptSize().
4265-
if (MF->getFunction().hasFnAttribute(Attribute::OptimizeForSize))
4264+
if (MF->getFunction().hasOptSize())
42664265
--Latency;
42674266
}
42684267
return Latency;

llvm/lib/Target/Hexagon/HexagonCopyToCombine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ bool HexagonCopyToCombine::runOnMachineFunction(MachineFunction &MF) {
457457
TII = ST->getInstrInfo();
458458

459459
const Function &F = MF.getFunction();
460-
bool OptForSize = F.hasFnAttribute(Attribute::OptimizeForSize);
460+
bool OptForSize = F.hasOptSize();
461461

462462
// Combine aggressively (for code size)
463463
ShouldCombineAggressively =

llvm/lib/Target/Hexagon/HexagonMask.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ bool HexagonMask::runOnMachineFunction(MachineFunction &MF) {
7676
HII = HST.getInstrInfo();
7777
const Function &F = MF.getFunction();
7878

79-
if (!F.hasFnAttribute(Attribute::OptimizeForSize))
79+
if (!F.hasOptSize())
8080
return false;
8181
// Mask instruction is available only from v66
8282
if (!HST.hasV66Ops())

llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ static bool PGOMemOPSizeOptImpl(Function &F, BlockFrequencyInfo &BFI,
456456
if (DisableMemOPOPT)
457457
return false;
458458

459-
if (F.hasFnAttribute(Attribute::OptimizeForSize))
459+
if (F.hasOptSize())
460460
return false;
461461
MemOPSizeOpt MemOPSizeOpt(F, BFI, ORE, DT, TLI);
462462
MemOPSizeOpt.perform();

llvm/lib/Transforms/Utils/LibCallsShrinkWrap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ bool LibCallsShrinkWrap::perform(CallInst *CI) {
498498

499499
static bool runImpl(Function &F, const TargetLibraryInfo &TLI,
500500
DominatorTree *DT) {
501-
if (F.hasFnAttribute(Attribute::OptimizeForSize))
501+
if (F.hasOptSize())
502502
return false;
503503
DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy);
504504
LibCallsShrinkWrap CCDCE(TLI, DTU);

llvm/test/CodeGen/AArch64/preferred-function-alignment.ll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,10 @@ define void @test_optsize() optsize {
4040

4141
; CHECK-LABEL: test_optsize
4242
; CHECK-NEXT: .p2align 2
43+
44+
define void @test_minsize() minsize {
45+
ret void
46+
}
47+
48+
; CHECK-LABEL: test_minsize
49+
; CHECK-NEXT: .p2align 2

llvm/test/CodeGen/ARM/preferred-function-alignment.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,11 @@ define void @test() {
2222
define void @test_optsize() optsize {
2323
ret void
2424
}
25+
26+
; CHECK-LABEL: test_minsize
27+
; ALIGN-CS-16: .p2align 1
28+
; ALIGN-CS-32: .p2align 2
29+
30+
define void @test_minsize() minsize {
31+
ret void
32+
}

llvm/test/CodeGen/Hexagon/hvx-reuse-fi-base.ll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ b0:
183183
%v11 = call <64 x i32> @llvm.hexagon.V6.vaddubh.128B(<32 x i32> %v10, <32 x i32> undef)
184184
%v12 = call <64 x i32> @llvm.hexagon.V6.vrmpyubi.128B(<64 x i32> %v11, i32 2147483647, i32 1)
185185
store <64 x i32> %v12, ptr @g0, align 128
186-
call void (ptr, ...) @f1(ptr @g3) #2
186+
call void (ptr, ...) @f1(ptr @g3) #3
187187
%v13 = call <32 x i32> @llvm.hexagon.V6.lvsplatw.128B(i32 2)
188188
%v14 = call <64 x i32> @llvm.hexagon.V6.vaddubh.128B(<32 x i32> undef, <32 x i32> %v13)
189189
%v15 = call <64 x i32> @llvm.hexagon.V6.vrmpyubi.128B(<64 x i32> %v14, i32 -2147483648, i32 1)
@@ -193,7 +193,7 @@ b0:
193193
%v17 = call <64 x i32> @llvm.hexagon.V6.vaddubh.128B(<32 x i32> undef, <32 x i32> %v16)
194194
%v18 = call <64 x i32> @llvm.hexagon.V6.vrmpyubi.128B(<64 x i32> %v17, i32 0, i32 1)
195195
store <64 x i32> %v18, ptr @g0, align 128
196-
call void @f0() #2
196+
call void @f0() #3
197197
%v19 = call <32 x i32> @llvm.hexagon.V6.lvsplatw.128B(i32 1)
198198
%v20 = call <32 x i32> @llvm.hexagon.V6.lvsplatw.128B(i32 2)
199199
%v21 = call <64 x i32> @llvm.hexagon.V6.vaddubh.128B(<32 x i32> %v19, <32 x i32> %v20)
@@ -205,3 +205,4 @@ b0:
205205
attributes #0 = { nounwind "use-soft-float"="false" "target-cpu"="hexagonv66" "target-features"="+hvxv66,+hvx-length128b" }
206206
attributes #1 = { nounwind readnone }
207207
attributes #2 = { nounwind optsize }
208+
attributes #3 = { nounwind minsize }

0 commit comments

Comments
 (0)