[llvm] [BPF] add cast_{user,kern} instructions (PR #79902)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 29 13:29:29 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 460ff58f62456a1f3ccf61ec9cf9d10781bd41bb f235b4021c58e12cae44cad1e2f1e468ea4be17d -- llvm/lib/Target/BPF/BPFCheckAndAdjustIR.cpp llvm/lib/Target/BPF/BPFISelLowering.cpp llvm/lib/Target/BPF/BPFISelLowering.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Target/BPF/BPFCheckAndAdjustIR.cpp b/llvm/lib/Target/BPF/BPFCheckAndAdjustIR.cpp
index d350d4f816..9acad98837 100644
--- a/llvm/lib/Target/BPF/BPFCheckAndAdjustIR.cpp
+++ b/llvm/lib/Target/BPF/BPFCheckAndAdjustIR.cpp
@@ -418,9 +418,7 @@ bool BPFCheckAndAdjustIR::removeGEPBuiltins(Module &M) {
 }
 
 static Instruction *aspaceWrapValue(DenseMap<Value *, Instruction *> &Cache,
-                                    Function *F,
-                                    Value *ToWrap,
-                                    unsigned Code) {
+                                    Function *F, Value *ToWrap, unsigned Code) {
   auto It = Cache.find(ToWrap);
   if (It != Cache.end())
     return It->getSecond();
@@ -444,8 +442,9 @@ static Instruction *aspaceWrapValue(DenseMap<Value *, Instruction *> &Cache,
     IB.SetInsertPoint(F->getEntryBlock().getFirstInsertionPt());
   Type *PtrTy = ToWrap->getType();
   Function *ASpaceFn =
-    Intrinsic::getDeclaration(M, Intrinsic::bpf_addr_space, {PtrTy, PtrTy});
-  auto *Call = IB.CreateCall(ASpaceFn, {ToWrap, IB.getInt32(Code)}, ToWrap->getName());
+      Intrinsic::getDeclaration(M, Intrinsic::bpf_addr_space, {PtrTy, PtrTy});
+  auto *Call =
+      IB.CreateCall(ASpaceFn, {ToWrap, IB.getInt32(Code)}, ToWrap->getName());
   Cache[ToWrap] = Call;
   return Call;
 }
@@ -483,13 +482,13 @@ bool BPFCheckAndAdjustIR::insertASpaceBuiltins(Module &M) {
     for (BasicBlock &BB : F) {
       for (Instruction &I : BB) {
         if (auto *LD = dyn_cast<LoadInst>(&I)) {
-          aspaceWrapOperand(ToKernelCache,
-                            LD, LD->getPointerOperandIndex(), ASPACE_TO_KERNEL);
+          aspaceWrapOperand(ToKernelCache, LD, LD->getPointerOperandIndex(),
+                            ASPACE_TO_KERNEL);
           continue;
         }
         if (auto *ST = dyn_cast<StoreInst>(&I)) {
-          aspaceWrapOperand(ToKernelCache,
-                            ST, ST->getPointerOperandIndex(), ASPACE_TO_KERNEL);
+          aspaceWrapOperand(ToKernelCache, ST, ST->getPointerOperandIndex(),
+                            ASPACE_TO_KERNEL);
           Value *VO = ST->getValueOperand();
           PointerType *VOTy = dyn_cast<PointerType>(VO->getType());
           if (VOTy && VOTy->getAddressSpace() != 0)
diff --git a/llvm/lib/Target/BPF/BPFISelLowering.cpp b/llvm/lib/Target/BPF/BPFISelLowering.cpp
index 40a0fa7d54..4bbc7ee172 100644
--- a/llvm/lib/Target/BPF/BPFISelLowering.cpp
+++ b/llvm/lib/Target/BPF/BPFISelLowering.cpp
@@ -644,7 +644,7 @@ SDValue BPFTargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op,
 }
 
 void BPFTargetLowering::CollectTargetIntrinsicOperands(
-  const CallInst &I, SmallVectorImpl<SDValue> &Ops, SelectionDAG &DAG) const {
+    const CallInst &I, SmallVectorImpl<SDValue> &Ops, SelectionDAG &DAG) const {
   Function *Func = I.getCalledFunction();
   if (!Func)
     return;
@@ -663,7 +663,8 @@ SDValue BPFTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
     SDValue Ptr = Op.getOperand(1);
     SDValue Code = Op.getOperand(2);
     SDValue ASpace = Op.getOperand(3);
-    return DAG.getNode(BPFISD::ADDR_SPACE, DL, Op.getValueType(), Ptr, Code, ASpace);
+    return DAG.getNode(BPFISD::ADDR_SPACE, DL, Op.getValueType(), Ptr, Code,
+                       ASpace);
   }
   return SDValue();
 }
diff --git a/llvm/lib/Target/BPF/BPFISelLowering.h b/llvm/lib/Target/BPF/BPFISelLowering.h
index f84d8a4e39..72ac142ed9 100644
--- a/llvm/lib/Target/BPF/BPFISelLowering.h
+++ b/llvm/lib/Target/BPF/BPFISelLowering.h
@@ -66,8 +66,9 @@ public:
                          EVT VT) const override;
 
   MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override;
-  void CollectTargetIntrinsicOperands(
-    const CallInst &I, SmallVectorImpl<SDValue> &Ops, SelectionDAG &DAG) const override;
+  void CollectTargetIntrinsicOperands(const CallInst &I,
+                                      SmallVectorImpl<SDValue> &Ops,
+                                      SelectionDAG &DAG) const override;
 
 private:
   // Control Instruction Selection Features

``````````

</details>


https://github.com/llvm/llvm-project/pull/79902


More information about the llvm-commits mailing list