[clang] [llvm] BPF address space insn (PR #84410)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 8 11:15:46 PST 2024
================
@@ -0,0 +1,52 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
+; RUN: opt --bpf-check-and-opt-ir -S -mtriple=bpf-pc-linux < %s | FileCheck %s
+
+; Generated from the following C code:
+;
+; extern int __uptr *magic1();
+; extern int __uptr *magic2();
+;
+; void test(long i) {
+; int __uptr *a;
+;
+; if (i > 42)
+; a = magic1();
+; else
+; a = magic2();
+; a[5] = 7;
+; }
+;
+; Using the following command:
+;
+; clang --target=bpf -O2 -S -emit-llvm -o t.ll t.c
+
+; Function Attrs: nounwind
----------------
eddyz87 wrote:
Retested this, the attrs are like in the test:
```c
$ cat test.c
#define __uptr __attribute__((address_space(1)))
extern int __uptr *magic1();
extern int __uptr *magic2();
void test(long i) {
int __uptr *a;
if (i > 42)
a = magic1();
else
a = magic2();
a[5] = 7;
}
$ clang --target=bpf -O2 -S -emit-llvm -o - test.c | head -n10
; ModuleID = 'test.c'
source_filename = "test.c"
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
target triple = "bpf"
; Function Attrs: nounwind
define dso_local void @test(i64 noundef %i) local_unnamed_addr #0 {
entry:
%cmp = icmp sgt i64 %i, 42
br i1 %cmp, label %if.then, label %if.else
```
https://github.com/llvm/llvm-project/pull/84410
More information about the cfe-commits
mailing list