[llvm] 4b5224a - Disable PGO instrumentation on naked function (#75224)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 12 21:53:56 PST 2023
Author: serge-sans-paille
Date: 2023-12-13T05:53:52Z
New Revision: 4b5224a27e3639b0efcec39bec48f66bd39a2751
URL: https://github.com/llvm/llvm-project/commit/4b5224a27e3639b0efcec39bec48f66bd39a2751
DIFF: https://github.com/llvm/llvm-project/commit/4b5224a27e3639b0efcec39bec48f66bd39a2751.diff
LOG: Disable PGO instrumentation on naked function (#75224)
We only allow for assembly code in naked function, and PGO
instrumentation (esp. temporal instrumentation that introduces a
function call) can wreak havoc in this.
Fix #74573
Added:
Modified:
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/test/Transforms/PGOProfile/timestamp.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
index 4a5a0b25bebbaf..57ff1648788f9a 100644
--- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
+++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
@@ -1783,6 +1783,8 @@ static bool skipPGOUse(const Function &F) {
static bool skipPGOGen(const Function &F) {
if (skipPGOUse(F))
return true;
+ if (F.hasFnAttribute(llvm::Attribute::Naked))
+ return true;
if (F.hasFnAttribute(llvm::Attribute::NoProfile))
return true;
if (F.hasFnAttribute(llvm::Attribute::SkipProfile))
diff --git a/llvm/test/Transforms/PGOProfile/timestamp.ll b/llvm/test/Transforms/PGOProfile/timestamp.ll
index 8d6095a031a66b..d5d1233070f7fa 100644
--- a/llvm/test/Transforms/PGOProfile/timestamp.ll
+++ b/llvm/test/Transforms/PGOProfile/timestamp.ll
@@ -3,10 +3,21 @@
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
+; CHECK-LABEL: define void @foo(
define void @foo() {
entry:
; CHECK: call void @llvm.instrprof.timestamp({{.*}})
ret void
}
-; CHECK: declare void @llvm.instrprof.timestamp(
+; CHECK-LABEL: define void @bar(
+define void @bar() #0 {
+entry:
+ ; CHECK-NOT: call void @llvm.instrprof.timestamp({{.*}})
+ call void asm sideeffect "retq;", "~{dirflag},~{fpsr},~{flags}"()
+ unreachable
+}
+
+; CHECK-LABEL: declare void @llvm.instrprof.timestamp(
+
+attributes #0 = { naked }
More information about the llvm-commits
mailing list