xref: /llvm-project/llvm/test/CodeGen/BPF/xadd.ll (revision c5037db4acd95790a0ca5061c8fa79c5c291607e)
1; RUN: not llc -mtriple=bpfel -mcpu=v1 < %s 2>&1 | FileCheck %s
2; RUN: not llc -mtriple=bpfeb -mcpu=v1 < %s 2>&1 | FileCheck %s
3
4; This file is generated with the source command and source
5; $ clang -target bpf -O2 -g -S -emit-llvm t.c
6; $ cat t.c
7; int test(int *ptr) {
8;    int r;
9;    __sync_fetch_and_add(ptr, 4);
10;    r = __sync_fetch_and_add(ptr, 6);
11;    return r;
12; }
13
14; ModuleID = 't.c'
15source_filename = "t.c"
16target datalayout = "e-m:e-p:64:64-i64:64-n32:64-S128"
17target triple = "bpf"
18
19; Function Attrs: nounwind
20define dso_local i32 @test(ptr nocapture %ptr) local_unnamed_addr #0 !dbg !7 {
21entry:
22  call void @llvm.dbg.value(metadata ptr %ptr, metadata !13, metadata !DIExpression()), !dbg !15
23  %0 = atomicrmw add ptr %ptr, i32 4 seq_cst, !dbg !16
24  %1 = atomicrmw add ptr %ptr, i32 6 seq_cst, !dbg !17
25; CHECK: in function test i32 (ptr): Invalid usage of the XADD return value
26  call void @llvm.dbg.value(metadata i32 %1, metadata !14, metadata !DIExpression()), !dbg !18
27  ret i32 %1, !dbg !19
28}
29
30; Function Attrs: nounwind readnone speculatable
31declare void @llvm.dbg.value(metadata, metadata, metadata) #1
32
33attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
34attributes #1 = { nounwind readnone speculatable }
35
36!llvm.dbg.cu = !{!0}
37!llvm.module.flags = !{!3, !4, !5}
38!llvm.ident = !{!6}
39
40!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 8.0.0 (trunk 342605) (llvm/trunk 342612)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
41!1 = !DIFile(filename: "t.c", directory: "/home/yhs/work/tests/llvm/sync/test1")
42!2 = !{}
43!3 = !{i32 2, !"Dwarf Version", i32 4}
44!4 = !{i32 2, !"Debug Info Version", i32 3}
45!5 = !{i32 1, !"wchar_size", i32 4}
46!6 = !{!"clang version 8.0.0 (trunk 342605) (llvm/trunk 342612)"}
47!7 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
48!8 = !DISubroutineType(types: !9)
49!9 = !{!10, !11}
50!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
51!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)
52!12 = !{!13, !14}
53!13 = !DILocalVariable(name: "ptr", arg: 1, scope: !7, file: !1, line: 1, type: !11)
54!14 = !DILocalVariable(name: "r", scope: !7, file: !1, line: 2, type: !10)
55!15 = !DILocation(line: 1, column: 15, scope: !7)
56!16 = !DILocation(line: 3, column: 4, scope: !7)
57!17 = !DILocation(line: 4, column: 8, scope: !7)
58!18 = !DILocation(line: 2, column: 8, scope: !7)
59!19 = !DILocation(line: 5, column: 4, scope: !7)
60