Open brendangregg opened 6 years ago
@ajor / @brendangregg : Would I be correct in postulating that the only way to do this is to reimplement soft-float functions in LLVM's IRBuilder?
The logic being that BPF doesn't support floats natively, so LLVM attempts to start calling its soft-float functions (e.g. "__divdf3(...)"). That doesn't work because BPF doesn't support the calling of arbitary external functions (i.e. those not in BCC's/Linux's "helpers.h"). For much the same reason, trying to define a C/C++ function and having BPF call into it won't work either. Thus, the only option is to implement the soft-float functions in LLVM's IRBuilder. I'm given to understand that this is why "createLog2Function()" and "createStrcmpFunction()" in "bpftrace/src/ast/codegen_llvm.cpp" create their functions in the aforementioned way.
BCC has the same issue if one tries to use floats in the compiled C BPF code, so they use Python (or similar) to work with floats once the BPF code has executed. BPFtrace has no such recourse.
Ticket to suggest adding floats (doubles).
Eg, this should work: