|
| 1 | +; RUN: llc -march=bpfel -mcpu=v3 -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s |
| 2 | +; RUN: llc -march=bpfeb -mcpu=v3 -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s |
| 3 | +; |
| 4 | +; Source: |
| 5 | +; #include <stdatomic.h> |
| 6 | +; struct gstruct_t { |
| 7 | +; _Atomic int a; |
| 8 | +; } gstruct; |
| 9 | +; extern _Atomic int ext; |
| 10 | +; _Atomic int gbl; |
| 11 | +; _Atomic int *pgbl; |
| 12 | +; volatile _Atomic int vvar; |
| 13 | +; _Atomic int foo(_Atomic int a1, _Atomic int *p1) { |
| 14 | +; (void)__c11_atomic_fetch_add(&gstruct.a, 1, memory_order_relaxed); |
| 15 | +; (void)__c11_atomic_fetch_add(&ext, 1, memory_order_relaxed); |
| 16 | +; (void)__c11_atomic_fetch_add(&gbl, 1, memory_order_relaxed); |
| 17 | +; (void)__c11_atomic_fetch_add(pgbl, 1, memory_order_relaxed); |
| 18 | +; (void)__c11_atomic_fetch_add(&vvar, 1, memory_order_relaxed); |
| 19 | +; (void)__c11_atomic_fetch_add(p1, 1, memory_order_relaxed); |
| 20 | +; |
| 21 | +; return a1; |
| 22 | +; } |
| 23 | + |
| 24 | +target triple = "bpf" |
| 25 | + |
| 26 | +%struct.gstruct_t = type { i32 } |
| 27 | + |
| 28 | +@gstruct = dso_local global %struct.gstruct_t zeroinitializer, align 4, !dbg !0 |
| 29 | +@ext = external dso_local global i32, align 4, !dbg !26 |
| 30 | +@gbl = dso_local global i32 0, align 4, !dbg !16 |
| 31 | +@pgbl = dso_local local_unnamed_addr global ptr null, align 8, !dbg !20 |
| 32 | +@vvar = dso_local global i32 0, align 4, !dbg !23 |
| 33 | + |
| 34 | +; Function Attrs: mustprogress nofree norecurse nounwind willreturn |
| 35 | +define dso_local i32 @foo(i32 returned %a1, ptr nocapture noundef %p1) local_unnamed_addr #0 !dbg !37 { |
| 36 | +entry: |
| 37 | + #dbg_value(i32 %a1, !41, !DIExpression(), !43) |
| 38 | + #dbg_value(ptr %p1, !42, !DIExpression(), !43) |
| 39 | + %0 = atomicrmw add ptr @gstruct, i32 1 monotonic, align 4, !dbg !44 |
| 40 | + %1 = atomicrmw add ptr @ext, i32 1 monotonic, align 4, !dbg !45 |
| 41 | + %2 = atomicrmw add ptr @gbl, i32 1 monotonic, align 4, !dbg !46 |
| 42 | + %3 = load ptr, ptr @pgbl, align 8, !dbg !47, !tbaa !48 |
| 43 | + %4 = atomicrmw add ptr %3, i32 1 monotonic, align 4, !dbg !52 |
| 44 | + %5 = atomicrmw volatile add ptr @vvar, i32 1 monotonic, align 4, !dbg !53 |
| 45 | + %6 = atomicrmw add ptr %p1, i32 1 monotonic, align 4, !dbg !54 |
| 46 | + ret i32 %a1, !dbg !55 |
| 47 | +} |
| 48 | + |
| 49 | +; CHECK: .long 1 # BTF_KIND_INT(id = 1) |
| 50 | +; CHECK-NEXT: .long 16777216 # 0x1000000 |
| 51 | +; CHECK-NEXT: .long 4 |
| 52 | +; CHECK-NEXT: .long 16777248 # 0x1000020 |
| 53 | +; CHECK-NEXT: .long 0 # BTF_KIND_PTR(id = 2) |
| 54 | +; CHECK-NEXT: .long 33554432 # 0x2000000 |
| 55 | +; CHECK-NEXT: .long 1 |
| 56 | +; CHECK-NEXT: .long 0 # BTF_KIND_FUNC_PROTO(id = 3) |
| 57 | +; CHECK-NEXT: .long 218103810 # 0xd000002 |
| 58 | +; CHECK-NEXT: .long 1 |
| 59 | +; CHECK-NEXT: .long 5 |
| 60 | +; CHECK-NEXT: .long 1 |
| 61 | +; CHECK-NEXT: .long 8 |
| 62 | +; CHECK-NEXT: .long 2 |
| 63 | +; CHECK-NEXT: .long 11 # BTF_KIND_FUNC(id = 4) |
| 64 | +; CHECK-NEXT: .long 201326593 # 0xc000001 |
| 65 | +; CHECK-NEXT: .long 3 |
| 66 | +; CHECK-NEXT: .long 66 # BTF_KIND_STRUCT(id = 5) |
| 67 | +; CHECK-NEXT: .long 67108865 # 0x4000001 |
| 68 | +; CHECK-NEXT: .long 4 |
| 69 | +; CHECK-NEXT: .long 76 |
| 70 | +; CHECK-NEXT: .long 1 |
| 71 | +; CHECK-NEXT: .long 0 # 0x0 |
| 72 | +; CHECK-NEXT: .long 78 # BTF_KIND_VAR(id = 6) |
| 73 | +; CHECK-NEXT: .long 234881024 # 0xe000000 |
| 74 | +; CHECK-NEXT: .long 5 |
| 75 | +; CHECK-NEXT: .long 1 |
| 76 | +; CHECK-NEXT: .long 86 # BTF_KIND_VAR(id = 7) |
| 77 | +; CHECK-NEXT: .long 234881024 # 0xe000000 |
| 78 | +; CHECK-NEXT: .long 1 |
| 79 | +; CHECK-NEXT: .long 2 |
| 80 | +; CHECK-NEXT: .long 90 # BTF_KIND_VAR(id = 8) |
| 81 | +; CHECK-NEXT: .long 234881024 # 0xe000000 |
| 82 | +; CHECK-NEXT: .long 1 |
| 83 | +; CHECK-NEXT: .long 1 |
| 84 | +; CHECK-NEXT: .long 94 # BTF_KIND_VAR(id = 9) |
| 85 | +; CHECK-NEXT: .long 234881024 # 0xe000000 |
| 86 | +; CHECK-NEXT: .long 2 |
| 87 | +; CHECK-NEXT: .long 1 |
| 88 | +; CHECK-NEXT: .long 0 # BTF_KIND_VOLATILE(id = 10) |
| 89 | +; CHECK-NEXT: .long 150994944 # 0x9000000 |
| 90 | +; CHECK-NEXT: .long 1 |
| 91 | +; CHECK-NEXT: .long 99 # BTF_KIND_VAR(id = 11) |
| 92 | +; CHECK-NEXT: .long 234881024 # 0xe000000 |
| 93 | +; CHECK-NEXT: .long 10 |
| 94 | +; CHECK-NEXT: .long 1 |
| 95 | +; CHECK-NEXT: .long 104 # BTF_KIND_DATASEC(id = 12) |
| 96 | +; CHECK-NEXT: .long 251658244 # 0xf000004 |
| 97 | +; CHECK-NEXT: .long 0 |
| 98 | +; CHECK-NEXT: .long 6 |
| 99 | +; CHECK-NEXT: .long gstruct |
| 100 | +; CHECK-NEXT: .long 4 |
| 101 | +; CHECK-NEXT: .long 8 |
| 102 | +; CHECK-NEXT: .long gbl |
| 103 | +; CHECK-NEXT: .long 4 |
| 104 | +; CHECK-NEXT: .long 9 |
| 105 | +; CHECK-NEXT: .long pgbl |
| 106 | +; CHECK-NEXT: .long 8 |
| 107 | +; CHECK-NEXT: .long 11 |
| 108 | +; CHECK-NEXT: .long vvar |
| 109 | +; CHECK-NEXT: .long 4 |
| 110 | + |
| 111 | + |
| 112 | +; CHECK: .byte 0 # string offset=0 |
| 113 | +; CHECK: .ascii "int" # string offset=1 |
| 114 | +; CHECK: .ascii "a1" # string offset=5 |
| 115 | +; CHECK: .ascii "p1" # string offset=8 |
| 116 | +; CHECK: .ascii "foo" # string offset=11 |
| 117 | +; CHECK: .ascii "gstruct_t" # string offset=66 |
| 118 | +; CHECK: .byte 97 # string offset=76 |
| 119 | +; CHECK: .ascii "gstruct" # string offset=78 |
| 120 | +; CHECK: .ascii "ext" # string offset=86 |
| 121 | +; CHECK: .ascii "gbl" # string offset=90 |
| 122 | +; CHECK: .ascii "pgbl" # string offset=94 |
| 123 | +; CHECK: .ascii "vvar" # string offset=99 |
| 124 | + |
| 125 | +attributes #0 = { mustprogress nofree norecurse nounwind willreturn "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="v3" } |
| 126 | + |
| 127 | +!llvm.dbg.cu = !{!2} |
| 128 | +!llvm.module.flags = !{!31, !32, !33, !34, !35} |
| 129 | +!llvm.ident = !{!36} |
| 130 | + |
| 131 | +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) |
| 132 | +!1 = distinct !DIGlobalVariable(name: "gstruct", scope: !2, file: !3, line: 4, type: !28, isLocal: false, isDefinition: true) |
| 133 | +!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang version 20.0.0git ([email protected]:yonghong-song/llvm-project.git a7bdb883df5731338d84603c60210d93c86f0870)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !15, splitDebugInlining: false, nameTableKind: None) |
| 134 | +!3 = !DIFile(filename: "atomics.c", directory: "/tmp/home/yhs/tests/result/atomics", checksumkind: CSK_MD5, checksum: "cabe3f3bfcfa90a93ff6d959be6e563a") |
| 135 | +!4 = !{!5} |
| 136 | +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "memory_order", file: !6, line: 68, baseType: !7, size: 32, elements: !8) |
| 137 | +!6 = !DIFile(filename: "work/yhs/llvm-project/llvm/build/install/lib/clang/20/include/stdatomic.h", directory: "/home/yhs", checksumkind: CSK_MD5, checksum: "f17199a988fe91afffaf0f943ef87096") |
| 138 | +!7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) |
| 139 | +!8 = !{!9, !10, !11, !12, !13, !14} |
| 140 | +!9 = !DIEnumerator(name: "memory_order_relaxed", value: 0) |
| 141 | +!10 = !DIEnumerator(name: "memory_order_consume", value: 1) |
| 142 | +!11 = !DIEnumerator(name: "memory_order_acquire", value: 2) |
| 143 | +!12 = !DIEnumerator(name: "memory_order_release", value: 3) |
| 144 | +!13 = !DIEnumerator(name: "memory_order_acq_rel", value: 4) |
| 145 | +!14 = !DIEnumerator(name: "memory_order_seq_cst", value: 5) |
| 146 | +!15 = !{!0, !16, !20, !23, !26} |
| 147 | +!16 = !DIGlobalVariableExpression(var: !17, expr: !DIExpression()) |
| 148 | +!17 = distinct !DIGlobalVariable(name: "gbl", scope: !2, file: !3, line: 6, type: !18, isLocal: false, isDefinition: true) |
| 149 | +!18 = !DIDerivedType(tag: DW_TAG_atomic_type, baseType: !19) |
| 150 | +!19 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) |
| 151 | +!20 = !DIGlobalVariableExpression(var: !21, expr: !DIExpression()) |
| 152 | +!21 = distinct !DIGlobalVariable(name: "pgbl", scope: !2, file: !3, line: 7, type: !22, isLocal: false, isDefinition: true) |
| 153 | +!22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !18, size: 64) |
| 154 | +!23 = !DIGlobalVariableExpression(var: !24, expr: !DIExpression()) |
| 155 | +!24 = distinct !DIGlobalVariable(name: "vvar", scope: !2, file: !3, line: 8, type: !25, isLocal: false, isDefinition: true) |
| 156 | +!25 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !18) |
| 157 | +!26 = !DIGlobalVariableExpression(var: !27, expr: !DIExpression()) |
| 158 | +!27 = distinct !DIGlobalVariable(name: "ext", scope: !2, file: !3, line: 5, type: !18, isLocal: false, isDefinition: false) |
| 159 | +!28 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "gstruct_t", file: !3, line: 2, size: 32, elements: !29) |
| 160 | +!29 = !{!30} |
| 161 | +!30 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !28, file: !3, line: 3, baseType: !18, size: 32) |
| 162 | +!31 = !{i32 7, !"Dwarf Version", i32 5} |
| 163 | +!32 = !{i32 2, !"Debug Info Version", i32 3} |
| 164 | +!33 = !{i32 1, !"wchar_size", i32 4} |
| 165 | +!34 = !{i32 7, !"frame-pointer", i32 2} |
| 166 | +!35 = !{i32 7, !"debug-info-assignment-tracking", i1 true} |
| 167 | +!36 = !{! "clang version 20.0.0git ([email protected]:yonghong-song/llvm-project.git a7bdb883df5731338d84603c60210d93c86f0870)"} |
| 168 | +!37 = distinct !DISubprogram(name: "foo", scope: !3, file: !3, line: 9, type: !38, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !40) |
| 169 | +!38 = !DISubroutineType(types: !39) |
| 170 | +!39 = !{!18, !18, !22} |
| 171 | +!40 = !{!41, !42} |
| 172 | +!41 = !DILocalVariable(name: "a1", arg: 1, scope: !37, file: !3, line: 9, type: !18) |
| 173 | +!42 = !DILocalVariable(name: "p1", arg: 2, scope: !37, file: !3, line: 9, type: !22) |
| 174 | +!43 = !DILocation(line: 0, scope: !37) |
| 175 | +!44 = !DILocation(line: 10, column: 9, scope: !37) |
| 176 | +!45 = !DILocation(line: 11, column: 9, scope: !37) |
| 177 | +!46 = !DILocation(line: 12, column: 9, scope: !37) |
| 178 | +!47 = !DILocation(line: 13, column: 32, scope: !37) |
| 179 | +!48 = !{!49, !49, i64 0} |
| 180 | +!49 = !{!"any pointer", !50, i64 0} |
| 181 | +!50 = !{!"omnipotent char", !51, i64 0} |
| 182 | +!51 = !{!"Simple C/C++ TBAA"} |
| 183 | +!52 = !DILocation(line: 13, column: 9, scope: !37) |
| 184 | +!53 = !DILocation(line: 14, column: 9, scope: !37) |
| 185 | +!54 = !DILocation(line: 15, column: 9, scope: !37) |
| 186 | +!55 = !DILocation(line: 17, column: 3, scope: !37) |
0 commit comments