diff options
author | Arthur Eubanks <aeubanks@google.com> | 2024-02-16 12:33:45 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-16 11:33:45 -0800 |
commit | 6841395953e64002c836a724e5429358554385a3 (patch) | |
tree | f421bf2d541739879ebe880de68913e2aaa4f4e0 | |
parent | 5ff8b30327245eb32a034f4e364a18cf32b0d8a4 (diff) | |
download | llvm-6841395953e64002c836a724e5429358554385a3.zip llvm-6841395953e64002c836a724e5429358554385a3.tar.gz llvm-6841395953e64002c836a724e5429358554385a3.tar.bz2 |
[PGOForceFunctionAttrs] Don't mark alwaysinline function optnone (#81930)
optnone requires noinline, which is incompatible with alwaysinline.
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/PGOForceFunctionAttrs.cpp | 5 | ||||
-rw-r--r-- | llvm/test/Instrumentation/PGOForceFunctionAttrs/basic.ll | 11 |
2 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/PGOForceFunctionAttrs.cpp b/llvm/lib/Transforms/Instrumentation/PGOForceFunctionAttrs.cpp index c0ebdd7..d93b5e5 100644 --- a/llvm/lib/Transforms/Instrumentation/PGOForceFunctionAttrs.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOForceFunctionAttrs.cpp @@ -40,7 +40,6 @@ PreservedAnalyses PGOForceFunctionAttrsPass::run(Module &M, for (Function &F : M) { if (!shouldRunOnFunction(F, PSI, FAM)) continue; - MadeChange = true; switch (ColdType) { case PGOOptions::ColdFuncOpt::Default: llvm_unreachable("bailed out for default above"); @@ -52,10 +51,14 @@ PreservedAnalyses PGOForceFunctionAttrsPass::run(Module &M, F.addFnAttr(Attribute::MinSize); break; case PGOOptions::ColdFuncOpt::OptNone: + // alwaysinline is incompatible with optnone. + if (F.hasFnAttribute(Attribute::AlwaysInline)) + continue; F.addFnAttr(Attribute::OptimizeNone); F.addFnAttr(Attribute::NoInline); break; } + MadeChange = true; } return MadeChange ? PreservedAnalyses::none() : PreservedAnalyses::all(); } diff --git a/llvm/test/Instrumentation/PGOForceFunctionAttrs/basic.ll b/llvm/test/Instrumentation/PGOForceFunctionAttrs/basic.ll index 29ebc03..1da0471 100644 --- a/llvm/test/Instrumentation/PGOForceFunctionAttrs/basic.ll +++ b/llvm/test/Instrumentation/PGOForceFunctionAttrs/basic.ll @@ -21,6 +21,12 @@ ; CHECK: Function Attrs: noinline optnone{{$}} ; CHECK-NEXT: define void @cold_optnone() +; NONE: Function Attrs: alwaysinline{{$}} +; OPTSIZE: Function Attrs: alwaysinline optsize{{$}} +; MINSIZE: Function Attrs: alwaysinline minsize{{$}} +; OPTNONE: Function Attrs: alwaysinline{{$}} +; CHECK-NEXT: define void @cold_alwaysinline() + ; NONE: Function Attrs: cold{{$}} ; OPTSIZE: Function Attrs: cold optsize{{$}} ; MINSIZE: Function Attrs: cold minsize{{$}} @@ -53,6 +59,11 @@ define void @cold_optnone() noinline optnone !prof !27 { ret void } +define void @cold_alwaysinline() alwaysinline !prof !27 { + store i32 1, ptr @s, align 4 + ret void +} + define void @cold_attr() cold { store i32 1, ptr @s, align 4 ret void |