Skip to content

Commit 58affdd

Browse files
alessandrodLucasSte
authored andcommitted
[SOL] disable llvm.bpf.load.* intrinsics on SBF (#24)
1 parent 665ba1f commit 58affdd

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

llvm/lib/Target/BPF/BPFISelLowering.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "llvm/CodeGen/ValueTypes.h"
2626
#include "llvm/IR/DiagnosticInfo.h"
2727
#include "llvm/IR/DiagnosticPrinter.h"
28+
#include "llvm/IR/IntrinsicsBPF.h"
2829
#include "llvm/Support/Debug.h"
2930
#include "llvm/Support/ErrorHandling.h"
3031
#include "llvm/Support/raw_ostream.h"
@@ -79,6 +80,8 @@ BPFTargetLowering::BPFTargetLowering(const TargetMachine &TM,
7980
setOperationAction(ISD::STACKSAVE, MVT::Other, Expand);
8081
setOperationAction(ISD::STACKRESTORE, MVT::Other, Expand);
8182

83+
setOperationAction(ISD::INTRINSIC_W_CHAIN, MVT::Other, Custom);
84+
8285
for (auto VT : {MVT::i8, MVT::i16, MVT::i32, MVT::i32, MVT::i64}) {
8386
if (Subtarget->isSolana()) {
8487
// Implement custom lowering for all atomic operations
@@ -368,10 +371,28 @@ SDValue BPFTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
368371
case ISD::ATOMIC_LOAD_UMIN:
369372
case ISD::ATOMIC_LOAD_XOR:
370373
return LowerATOMICRMW(Op, DAG);
374+
case ISD::INTRINSIC_W_CHAIN: {
375+
unsigned IntNo = cast<ConstantSDNode>(Op->getOperand(1))->getZExtValue();
376+
switch (IntNo) {
377+
case Intrinsic::bpf_load_byte:
378+
case Intrinsic::bpf_load_half:
379+
case Intrinsic::bpf_load_word:
380+
if (Subtarget->isSolana()) {
381+
report_fatal_error(
382+
"llvm.bpf.load.* intrinsics are not supported in SBF", false);
383+
}
384+
break;
385+
default:
386+
break;
387+
}
388+
389+
// continue the expansion as defined with tablegen
390+
return SDValue();
391+
}
371392
case ISD::DYNAMIC_STACKALLOC:
372393
report_fatal_error("Unsupported dynamic stack allocation");
373394
default:
374-
llvm_unreachable("unimplemented atomic operand");
395+
llvm_unreachable("unimplemented operation");
375396
}
376397
}
377398

llvm/test/CodeGen/BPF/intrinsics.ll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
; RUN: llc < %s -march=bpfel -show-mc-encoding | FileCheck --check-prefix=CHECK-EL %s
22
; RUN: llc < %s -march=bpfeb -show-mc-encoding | FileCheck --check-prefix=CHECK-EB %s
3+
; RUN: not --crash llc -march=sbf <%s 2>&1 | FileCheck --check-prefix=CHECK-SBF %s
4+
5+
; CHECK-SBF: LLVM ERROR: llvm.bpf.load.* intrinsics are not supported in SBF
36

47
; Function Attrs: nounwind uwtable
58
define i32 @ld_b(i64 %foo, ptr nocapture %bar, ptr %ctx, ptr %ctx2) #0 {

0 commit comments

Comments
 (0)