Skip to content

Commit e677112

Browse files
committed
[profcheck] Exclude naked functions from profcheck
1 parent 9349a10 commit e677112

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

llvm/lib/Transforms/Utils/ProfileVerify.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ class ProfileInjector {
7070
// FIXME: currently this injects only for terminators. Select isn't yet
7171
// supported.
7272
bool ProfileInjector::inject() {
73+
// skip purely asm functions
74+
if (F.hasFnAttribute(Attribute::AttrKind::Naked))
75+
return false;
7376
// Get whatever branch probability info can be derived from the given IR -
7477
// whether it has or not metadata. The main intention for this pass is to
7578
// ensure that other passes don't drop or "forget" to update MD_prof. We do
@@ -176,6 +179,10 @@ PreservedAnalyses ProfileInjectorPass::run(Function &F,
176179

177180
PreservedAnalyses ProfileVerifierPass::run(Function &F,
178181
FunctionAnalysisManager &FAM) {
182+
// skip purely asm functions
183+
if (F.hasFnAttribute(Attribute::AttrKind::Naked))
184+
return PreservedAnalyses::all();
185+
179186
const auto EntryCount = F.getEntryCount(/*AllowSynthetic=*/true);
180187
if (!EntryCount) {
181188
auto *MD = F.getMetadata(LLVMContext::MD_prof);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
; RUN: opt -passes=prof-inject %s -S -o - | FileCheck %s
2+
; RUN: opt -passes=prof-verify %s --disable-output
3+
4+
5+
define void @bar(i1 %c) #0 {
6+
ret void
7+
}
8+
9+
attributes #0 = { naked }
10+
; CHECK-NOT: !prof

0 commit comments

Comments
 (0)