Skip to content

[BPF] rename 'arena' to 'address_space' #85161

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

Merged
merged 2 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/lib/Basic/Targets/BPF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void BPFTargetInfo::getTargetDefines(const LangOptions &Opts,
return;
}

Builder.defineMacro("__BPF_FEATURE_ARENA_CAST");
Builder.defineMacro("__BPF_FEATURE_ADDR_SPACE_CAST");

if (CPU.empty() || CPU == "generic" || CPU == "v1") {
Builder.defineMacro("__BPF_CPU_VERSION__", "1");
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Preprocessor/bpf-predefined-macros.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int r;
#ifdef __BPF_FEATURE_ST
int s;
#endif
#ifdef __BPF_FEATURE_ARENA_CAST
#ifdef __BPF_FEATURE_ADDR_SPACE_CAST
int t;
#endif

Expand Down
10 changes: 5 additions & 5 deletions llvm/lib/Target/BPF/BPFCheckAndAdjustIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// - remove llvm.bpf.getelementptr.and.load builtins.
// - remove llvm.bpf.getelementptr.and.store builtins.
// - for loads and stores with base addresses from non-zero address space
// cast base address to zero address space (support for BPF arenas).
// cast base address to zero address space (support for BPF address spaces).
//
//===----------------------------------------------------------------------===//

Expand Down Expand Up @@ -482,15 +482,15 @@ static void aspaceWrapOperand(DenseMap<Value *, Value *> &Cache, Instruction *I,
}
}

// Support for BPF arenas:
// Support for BPF address spaces:
// - for each function in the module M, update pointer operand of
// each memory access instruction (load/store/cmpxchg/atomicrmw)
// by casting it from non-zero address space to zero address space, e.g:
//
// (load (ptr addrspace (N) %p) ...)
// -> (load (addrspacecast ptr addrspace (N) %p to ptr))
//
// - assign section with name .arena.N for globals defined in
// - assign section with name .addr_space.N for globals defined in
// non-zero address space N
bool BPFCheckAndAdjustIR::insertASpaceCasts(Module &M) {
bool Changed = false;
Expand All @@ -517,13 +517,13 @@ bool BPFCheckAndAdjustIR::insertASpaceCasts(Module &M) {
Changed |= !CastsCache.empty();
}
// Merge all globals within same address space into single
// .arena.<addr space no> section
// .addr_space.<addr space no> section
for (GlobalVariable &G : M.globals()) {
if (G.getAddressSpace() == 0 || G.hasSection())
continue;
SmallString<16> SecName;
raw_svector_ostream OS(SecName);
OS << ".arena." << G.getAddressSpace();
OS << ".addr_space." << G.getAddressSpace();
G.setSection(SecName);
// Prevent having separate section for constants
G.setConstant(false);
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/BPF/addr-space-globals.ll
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

; Verify that a,b,c reside in the same section

; CHECK: .section .arena.272,"aw",@progbits
; CHECK: .section .addr_space.272,"aw",@progbits
; CHECK-NOT: .section
; CHECK: .globl a
; CHECK: .ascii "\001\002"
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/BPF/addr-space-globals2.ll
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

; Verify that a,b reside in separate sections

; CHECK: .section .arena.1,"aw",@progbits
; CHECK: .section .addr_space.1,"aw",@progbits
; CHECK-NOT: .section
; CHECK: .globl a
; CHECK: .ascii "\001\002"

; CHECK: .section .arena.2,"aw",@progbits
; CHECK: .section .addr_space.2,"aw",@progbits
; CHECK-NOT: .section
; CHECK: .globl b
; CHECK: .ascii "\003\004"