[all-commits] [llvm/llvm-project] 761b91: [BPF] treat compiler fence as codegen no-op (#196734)

Bidhan via All-commits all-commits at lists.llvm.org
Wed Jun 10 10:47:17 PDT 2026


  Branch: refs/heads/release/22.x
  Home:   https://github.com/llvm/llvm-project
  Commit: 761b9134dd9beda6f133fdc19a42b148834cb06b
      https://github.com/llvm/llvm-project/commit/761b9134dd9beda6f133fdc19a42b148834cb06b
  Author: Bidhan <bidhan619 at gmail.com>
  Date:   2026-06-10 (Wed, 10 Jun 2026)

  Changed paths:
    M llvm/lib/Target/BPF/BPFISelLowering.cpp
    M llvm/lib/Target/BPF/BPFISelLowering.h
    A llvm/test/CodeGen/BPF/fence-singlethread.ll

  Log Message:
  -----------
  [BPF] treat compiler fence as codegen no-op (#196734)

The BPF backend has no instruction-selection pattern for
`ISD::ATOMIC_FENCE`, so LLVM IR containing a fence instruction crashes
with `Cannot select: AtomicFence...`.

**Rust code snippet**

```
#[unsafe(no_mangle)]
pub fn entrypoint(_input: *mut u8) -> u64 {
    core::sync::atomic::compiler_fence(core::sync::atomic::Ordering::SeqCst);
    0
}
```

**LLVM IR**

```
; ModuleID = 'linked_module'
source_filename = "linked_module"
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
target triple = "bpfel"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn
define dso_local noundef i64 @entrypoint(ptr noundef readnone captures(none) %0) unnamed_addr #0 {
  fence syncscope("singlethread") seq_cst
  ret i64 0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn "target-cpu"="generic" }

!llvm.ident = !{!0}

!0 = !{!"rustc version 1.97.0-nightly (f53b654a8 2026-04-30)"}
```

**Error**

```
LLVM ERROR: Cannot select: 0x7fcf7701a1c0: ch = AtomicFence 0x7fcf75718df8, TargetConstant:i64<7>, TargetConstant:i64<0>
In function: entrypoint

Stack dump:
          0.    Running pass 'Function Pass Manager' on module 'linked_module'.
          1.    Running pass 'BPF DAG->DAG Pattern Instruction Selection' on function '@entrypoint'
```

-----

**Fix**

This patch lowers single-thread (compiler) fences to `ISD::MEMBARRIER`
(no-op) and produces an error for cross-thread (runtime) fences.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list