[clang] [BPF] make __BPF_FEATURE_MAY_GOTO available for cpuv1 (PR #108071)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 10 11:45:04 PDT 2024
https://github.com/eddyz87 created https://github.com/llvm/llvm-project/pull/108071
For some reason `__BPF_FEATURE_MAY_GOTO` is available for CPUs v{2,3,4} but is not available for CPU v1. This limitation is arbitrary:
- the instruction is never produced by LLVM backend;
- on Linux Kernel side this instruction is available in kernels that also support CPUv4.
Hence, it is more consistent to either always allow `__BPF_FEATURE_MAY_GOTO` or only allow it for CPUv4.
>From 170f6a604b041bb33c5089dd84fd26de7bd2292e Mon Sep 17 00:00:00 2001
From: Eduard Zingerman <eddyz87 at gmail.com>
Date: Tue, 10 Sep 2024 11:11:58 -0700
Subject: [PATCH] [BPF] make __BPF_FEATURE_MAY_GOTO available for cpuv1
For some reason __BPF_FEATURE_MAY_GOTO is available for CPUs v{2,3,4}
but is not available for CPU v1. This limitation is arbitrary:
- the instruction is never produced by LLVM backend;
- on Linux Kernel side this instruction is available in kernels that
also support CPUv4.
Hence, it is more consistent to either always allow
__BPF_FEATURE_MAY_GOTO or only allow it for CPUv4.
---
clang/lib/Basic/Targets/BPF.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/Basic/Targets/BPF.cpp b/clang/lib/Basic/Targets/BPF.cpp
index a94ceee5a6a5e7..931f407ecb0d7e 100644
--- a/clang/lib/Basic/Targets/BPF.cpp
+++ b/clang/lib/Basic/Targets/BPF.cpp
@@ -37,6 +37,7 @@ void BPFTargetInfo::getTargetDefines(const LangOptions &Opts,
}
Builder.defineMacro("__BPF_FEATURE_ADDR_SPACE_CAST");
+ Builder.defineMacro("__BPF_FEATURE_MAY_GOTO");
if (CPU.empty())
CPU = "v3";
@@ -48,7 +49,6 @@ void BPFTargetInfo::getTargetDefines(const LangOptions &Opts,
std::string CpuVerNumStr = CPU.substr(1);
Builder.defineMacro("__BPF_CPU_VERSION__", CpuVerNumStr);
- Builder.defineMacro("__BPF_FEATURE_MAY_GOTO");
int CpuVerNum = std::stoi(CpuVerNumStr);
if (CpuVerNum >= 2)
More information about the cfe-commits
mailing list