81 lines · plain
1; RUN: opt -O2 %s | llvm-dis > %t12; RUN: llc -mcpu=v3 -filetype=asm -o - %t1 | FileCheck %s3; Source code:4; struct lock_t {5; int counter;6; } __attribute__((preserve_access_index));7;8; #define __arena __attribute__((address_space(1)))9; int test(struct lock_t __arena *lock, unsigned val)10; {11; return __sync_val_compare_and_swap((&lock->counter), val, 1);12; }13; Compilation flag:14; clang -target bpf -O2 -g -S -emit-llvm -Xclang -disable-llvm-passes arena_bitcast.c15 16target triple = "bpf"17 18%struct.lock_t = type { i32 }19 20; Function Attrs: nounwind21define dso_local i32 @test(ptr addrspace(1) noundef %lock, i32 noundef %val) #0 !dbg !7 {22entry:23 %lock.addr = alloca ptr addrspace(1), align 824 %val.addr = alloca i32, align 425 store ptr addrspace(1) %lock, ptr %lock.addr, align 8, !tbaa !1926 #dbg_declare(ptr %lock.addr, !17, !DIExpression(), !24)27 store i32 %val, ptr %val.addr, align 4, !tbaa !2528 #dbg_declare(ptr %val.addr, !18, !DIExpression(), !27)29 %0 = load ptr addrspace(1), ptr %lock.addr, align 8, !dbg !28, !tbaa !1930 %1 = call ptr addrspace(1) @llvm.preserve.struct.access.index.p1.p1(ptr addrspace(1) elementtype(%struct.lock_t) %0, i32 0, i32 0), !dbg !29, !llvm.preserve.access.index !1231 %2 = load i32, ptr %val.addr, align 4, !dbg !30, !tbaa !2532 %3 = cmpxchg ptr addrspace(1) %1, i32 %2, i32 1 seq_cst seq_cst, align 4, !dbg !3133 %4 = extractvalue { i32, i1 } %3, 0, !dbg !3134 ret i32 %4, !dbg !3235}36; CHECK: r1 = addr_space_cast(r1, 0, 1)37 38; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)39declare ptr addrspace(1) @llvm.preserve.struct.access.index.p1.p1(ptr addrspace(1), i32 immarg, i32 immarg) #140 41attributes #0 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }42attributes #1 = { nocallback nofree nosync nounwind willreturn memory(none) }43 44!llvm.dbg.cu = !{!0}45!llvm.module.flags = !{!2, !3, !4, !5}46!llvm.ident = !{!6}47 48!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 21.0.0git (https://github.com/llvm/llvm-project.git 7d4d8509cbec7eecd8aaf2510015b54bc5c173e1)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)49!1 = !DIFile(filename: "arena_bitcast.c", directory: "/root/home/yhs/tests/arena/simple", checksumkind: CSK_MD5, checksum: "51cb51c1fc09d3033dbd9aee9044dc9b")50!2 = !{i32 7, !"Dwarf Version", i32 5}51!3 = !{i32 2, !"Debug Info Version", i32 3}52!4 = !{i32 1, !"wchar_size", i32 4}53!5 = !{i32 7, !"frame-pointer", i32 2}54!6 = !{!"clang version 21.0.0git (https://github.com/llvm/llvm-project.git 7d4d8509cbec7eecd8aaf2510015b54bc5c173e1)"}55!7 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 6, type: !8, scopeLine: 7, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !16)56!8 = !DISubroutineType(types: !9)57!9 = !{!10, !11, !15}58!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)59!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)60!12 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "lock_t", file: !1, line: 1, size: 32, elements: !13)61!13 = !{!14}62!14 = !DIDerivedType(tag: DW_TAG_member, name: "counter", scope: !12, file: !1, line: 2, baseType: !10, size: 32)63!15 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)64!16 = !{!17, !18}65!17 = !DILocalVariable(name: "lock", arg: 1, scope: !7, file: !1, line: 6, type: !11)66!18 = !DILocalVariable(name: "val", arg: 2, scope: !7, file: !1, line: 6, type: !15)67!19 = !{!20, !20, i64 0}68!20 = !{!"p1 _ZTS6lock_t", !21, i64 0}69!21 = !{!"any pointer", !22, i64 0}70!22 = !{!"omnipotent char", !23, i64 0}71!23 = !{!"Simple C/C++ TBAA"}72!24 = !DILocation(line: 6, column: 33, scope: !7)73!25 = !{!26, !26, i64 0}74!26 = !{!"int", !22, i64 0}75!27 = !DILocation(line: 6, column: 48, scope: !7)76!28 = !DILocation(line: 8, column: 40, scope: !7)77!29 = !DILocation(line: 8, column: 46, scope: !7)78!30 = !DILocation(line: 8, column: 56, scope: !7)79!31 = !DILocation(line: 8, column: 10, scope: !7)80!32 = !DILocation(line: 8, column: 3, scope: !7)81