Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit 6c8e20a

Browse files
committed
[SOL] Allow selectively disable compiler builtins for BPF target (#4)
* [BPF] Add method to check whether a triple is a BPF architecture * [BPF] Make rust allocation builtins unavailable for BPF target - the calls to rust alloc/dealloc routines need to be preserved and not replaced by compiler generated builtin inlined code
1 parent cfaaae2 commit 6c8e20a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

llvm/include/llvm/ADT/Triple.h

+5
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,11 @@ class Triple {
738738
: PointerWidth == 64;
739739
}
740740

741+
/// Tests whether the target is BPF (little and big endian).
742+
bool isBPF() const {
743+
return getArch() == Triple::bpfel || getArch() == Triple::bpfeb;
744+
}
745+
741746
/// Tests whether the target is MIPS 32-bit (little and big endian).
742747
bool isMIPS32() const {
743748
return getArch() == Triple::mips || getArch() == Triple::mipsel;

llvm/lib/Analysis/TargetLibraryInfo.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,12 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
628628
TLI.setUnavailable(LibFunc_vec_free);
629629
}
630630

631+
if (T.isBPF()) {
632+
TLI.setUnavailable(LibFunc_rust_alloc);
633+
TLI.setUnavailable(LibFunc_rust_dealloc);
634+
TLI.setUnavailable(LibFunc_rust_realloc);
635+
}
636+
631637
TLI.addVectorizableFunctionsFromVecLib(ClVectorLibrary);
632638
}
633639

0 commit comments

Comments
 (0)