-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[BPF] make __BPF_FEATURE_MAY_GOTO available for cpuv1 #108071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BPF] make __BPF_FEATURE_MAY_GOTO available for cpuv1 #108071
Conversation
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.
As a cleanup, Yonghong suggested moving Wdyt? |
@llvm/pr-subscribers-clang Author: None (eddyz87) ChangesFor some reason
Hence, it is more consistent to either always allow Full diff: https://github.com/llvm/llvm-project/pull/108071.diff 1 Files Affected:
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)
|
why force users to specify -mcpu=v4 ? |
<commit message would be squashed and is not relevant>
Ok, then this is exactly what this pull request does (allows may_goto for v1). |
@4ast, ping |
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:Hence, it is more consistent to either always allow
__BPF_FEATURE_MAY_GOTO
or only allow it for CPUv4.