mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
BPF: make __builtin_btf_type_id() return 64bit int
Linux kernel recently added support for kernel modules https://lore.kernel.org/bpf/20201110011932.3201430-5-andrii@kernel.org/ In such cases, a type id in the kernel needs to be presented as (btf id for modules, btf type id for this module). Change __builtin_btf_type_id() to return 64bit value so libbpf can do the above encoding. Differential Revision: https://reviews.llvm.org/D91489
This commit is contained in:
parent
0bc59c8f71
commit
4b2b975a37
@ -24,7 +24,7 @@ let TargetPrefix = "bpf" in { // All intrinsics start with "llvm.bpf."
|
|||||||
Intrinsic<[llvm_i32_ty], [llvm_anyptr_ty, llvm_i64_ty],
|
Intrinsic<[llvm_i32_ty], [llvm_anyptr_ty, llvm_i64_ty],
|
||||||
[IntrNoMem, ImmArg<ArgIndex<1>>]>;
|
[IntrNoMem, ImmArg<ArgIndex<1>>]>;
|
||||||
def int_bpf_btf_type_id : GCCBuiltin<"__builtin_bpf_btf_type_id">,
|
def int_bpf_btf_type_id : GCCBuiltin<"__builtin_bpf_btf_type_id">,
|
||||||
Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i64_ty],
|
Intrinsic<[llvm_i64_ty], [llvm_i32_ty, llvm_i64_ty],
|
||||||
[IntrNoMem]>;
|
[IntrNoMem]>;
|
||||||
def int_bpf_preserve_type_info : GCCBuiltin<"__builtin_bpf_preserve_type_info">,
|
def int_bpf_preserve_type_info : GCCBuiltin<"__builtin_bpf_preserve_type_info">,
|
||||||
Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i64_ty],
|
Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i64_ty],
|
||||||
|
@ -90,7 +90,7 @@ static bool BPFPreserveDITypeImpl(Function &F) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BasicBlock *BB = Call->getParent();
|
BasicBlock *BB = Call->getParent();
|
||||||
IntegerType *VarType = Type::getInt32Ty(BB->getContext());
|
IntegerType *VarType = Type::getInt64Ty(BB->getContext());
|
||||||
std::string GVName = BaseName + std::to_string(Count) + "$" +
|
std::string GVName = BaseName + std::to_string(Count) + "$" +
|
||||||
std::to_string(Reloc);
|
std::to_string(Reloc);
|
||||||
GlobalVariable *GV = new GlobalVariable(
|
GlobalVariable *GV = new GlobalVariable(
|
||||||
@ -99,8 +99,8 @@ static bool BPFPreserveDITypeImpl(Function &F) {
|
|||||||
GV->setMetadata(LLVMContext::MD_preserve_access_index, MD);
|
GV->setMetadata(LLVMContext::MD_preserve_access_index, MD);
|
||||||
|
|
||||||
// Load the global variable which represents the type info.
|
// Load the global variable which represents the type info.
|
||||||
auto *LDInst = new LoadInst(Type::getInt32Ty(BB->getContext()), GV, "",
|
auto *LDInst =
|
||||||
Call);
|
new LoadInst(Type::getInt64Ty(BB->getContext()), GV, "", Call);
|
||||||
Instruction *PassThroughInst =
|
Instruction *PassThroughInst =
|
||||||
BPFCoreSharedInfo::insertPassThrough(M, BB, LDInst, Call);
|
BPFCoreSharedInfo::insertPassThrough(M, BB, LDInst, Call);
|
||||||
Call->replaceAllUsesWith(PassThroughInst);
|
Call->replaceAllUsesWith(PassThroughInst);
|
||||||
|
@ -1224,7 +1224,9 @@ bool BTFDebug::InstLower(const MachineInstr *MI, MCInst &OutMI) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Reloc == BPFCoreSharedInfo::ENUM_VALUE_EXISTENCE ||
|
if (Reloc == BPFCoreSharedInfo::ENUM_VALUE_EXISTENCE ||
|
||||||
Reloc == BPFCoreSharedInfo::ENUM_VALUE)
|
Reloc == BPFCoreSharedInfo::ENUM_VALUE ||
|
||||||
|
Reloc == BPFCoreSharedInfo::BTF_TYPE_ID_LOCAL ||
|
||||||
|
Reloc == BPFCoreSharedInfo::BTF_TYPE_ID_REMOTE)
|
||||||
OutMI.setOpcode(BPF::LD_imm64);
|
OutMI.setOpcode(BPF::LD_imm64);
|
||||||
else
|
else
|
||||||
OutMI.setOpcode(BPF::MOV_ri);
|
OutMI.setOpcode(BPF::MOV_ri);
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
; RUN: opt -O2 %s | llvm-dis > %t1
|
; RUN: opt -O2 -mtriple=bpf-pc-linux %s | llvm-dis > %t1
|
||||||
; RUN: llc -filetype=asm -o - %t1 | FileCheck -check-prefixes=CHECK %s
|
; RUN: llc -filetype=asm -o - %t1 | FileCheck -check-prefixes=CHECK %s
|
||||||
; RUN: llc -mattr=+alu32 -filetype=asm -o - %t1 | FileCheck -check-prefixes=CHECK %s
|
; RUN: llc -mattr=+alu32 -filetype=asm -o - %t1 | FileCheck -check-prefixes=CHECK %s
|
||||||
;
|
;
|
||||||
; Source code:
|
; Source code:
|
||||||
; static int (*bpf_log)(unsigned tid, void *data, int data_size) = (void *)999;
|
; static int (*bpf_log)(unsigned long tid, void *data, int data_size) = (void *)999;
|
||||||
; struct {
|
; struct {
|
||||||
; char f1[100];
|
; char f1[100];
|
||||||
; typeof(3) f2;
|
; typeof(3) f2;
|
||||||
@ -20,43 +20,45 @@
|
|||||||
; Compilation flag:
|
; Compilation flag:
|
||||||
; clang -target bpf -O2 -g -S -emit-llvm -Xclang -disable-llvm-passes test.c
|
; clang -target bpf -O2 -g -S -emit-llvm -Xclang -disable-llvm-passes test.c
|
||||||
|
|
||||||
target triple = "bpf"
|
|
||||||
|
|
||||||
@tmp__abc = dso_local global { <{ i8, i8, [98 x i8] }>, i32 } { <{ i8, i8, [98 x i8] }> <{ i8 1, i8 3, [98 x i8] zeroinitializer }>, i32 0 }, align 4, !dbg !0
|
@tmp__abc = dso_local global { <{ i8, i8, [98 x i8] }>, i32 } { <{ i8, i8, [98 x i8] }> <{ i8 1, i8 3, [98 x i8] zeroinitializer }>, i32 0 }, align 4, !dbg !0
|
||||||
|
@bpf_log = internal global i32 (i64, i8*, i32)* inttoptr (i64 999 to i32 (i64, i8*, i32)*), align 8, !dbg !17
|
||||||
|
|
||||||
; Function Attrs: nounwind
|
; Function Attrs: nounwind
|
||||||
define dso_local void @prog1() local_unnamed_addr #0 !dbg !28 {
|
define dso_local void @prog1() #0 !dbg !28 {
|
||||||
entry:
|
entry:
|
||||||
%0 = tail call i32 @llvm.bpf.btf.type.id(i32 0, i64 0), !dbg !31, !llvm.preserve.access.index !7
|
%0 = load i32 (i64, i8*, i32)*, i32 (i64, i8*, i32)** @bpf_log, align 8, !dbg !31, !tbaa !32
|
||||||
%call = tail call i32 inttoptr (i64 999 to i32 (i32, i8*, i32)*)(i32 %0, i8* getelementptr inbounds ({ <{ i8, i8, [98 x i8] }>, i32 }, { <{ i8, i8, [98 x i8] }>, i32 }* @tmp__abc, i64 0, i32 0, i32 0), i32 104) #2, !dbg !32
|
%1 = call i64 @llvm.bpf.btf.type.id(i32 0, i64 0), !dbg !36, !llvm.preserve.access.index !7
|
||||||
ret void, !dbg !33
|
%call = call i32 %0(i64 %1, i8* getelementptr inbounds ({ <{ i8, i8, [98 x i8] }>, i32 }, { <{ i8, i8, [98 x i8] }>, i32 }* @tmp__abc, i32 0, i32 0, i32 0), i32 104), !dbg !31
|
||||||
}
|
|
||||||
|
|
||||||
; Function Attrs: nounwind readnone
|
|
||||||
declare i32 @llvm.bpf.btf.type.id(i32, i64) #1
|
|
||||||
|
|
||||||
; Function Attrs: nounwind
|
|
||||||
define dso_local void @prog2() local_unnamed_addr #0 !dbg !34 {
|
|
||||||
entry:
|
|
||||||
%0 = tail call i32 @llvm.bpf.btf.type.id(i32 1, i64 0), !dbg !35, !llvm.preserve.access.index !6
|
|
||||||
%call = tail call i32 inttoptr (i64 999 to i32 (i32, i8*, i32)*)(i32 %0, i8* getelementptr inbounds ({ <{ i8, i8, [98 x i8] }>, i32 }, { <{ i8, i8, [98 x i8] }>, i32 }* @tmp__abc, i64 0, i32 0, i32 0), i32 104) #2, !dbg !36
|
|
||||||
ret void, !dbg !37
|
ret void, !dbg !37
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; Function Attrs: nounwind readnone
|
||||||
|
declare i64 @llvm.bpf.btf.type.id(i32, i64) #1
|
||||||
|
|
||||||
; Function Attrs: nounwind
|
; Function Attrs: nounwind
|
||||||
define dso_local void @prog3() local_unnamed_addr #0 !dbg !38 {
|
define dso_local void @prog2() #0 !dbg !38 {
|
||||||
entry:
|
entry:
|
||||||
%0 = tail call i32 @llvm.bpf.btf.type.id(i32 2, i64 1), !dbg !39, !llvm.preserve.access.index !11
|
%0 = load i32 (i64, i8*, i32)*, i32 (i64, i8*, i32)** @bpf_log, align 8, !dbg !39, !tbaa !32
|
||||||
%call = tail call i32 inttoptr (i64 999 to i32 (i32, i8*, i32)*)(i32 %0, i8* getelementptr inbounds ({ <{ i8, i8, [98 x i8] }>, i32 }, { <{ i8, i8, [98 x i8] }>, i32 }* @tmp__abc, i64 0, i32 0, i32 0), i32 104) #2, !dbg !40
|
%1 = call i64 @llvm.bpf.btf.type.id(i32 1, i64 0), !dbg !40, !llvm.preserve.access.index !6
|
||||||
|
%call = call i32 %0(i64 %1, i8* getelementptr inbounds ({ <{ i8, i8, [98 x i8] }>, i32 }, { <{ i8, i8, [98 x i8] }>, i32 }* @tmp__abc, i32 0, i32 0, i32 0), i32 104), !dbg !39
|
||||||
ret void, !dbg !41
|
ret void, !dbg !41
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; Function Attrs: nounwind
|
||||||
|
define dso_local void @prog3() #0 !dbg !42 {
|
||||||
|
entry:
|
||||||
|
%0 = load i32 (i64, i8*, i32)*, i32 (i64, i8*, i32)** @bpf_log, align 8, !dbg !43, !tbaa !32
|
||||||
|
%1 = call i64 @llvm.bpf.btf.type.id(i32 2, i64 1), !dbg !44, !llvm.preserve.access.index !11
|
||||||
|
%call = call i32 %0(i64 %1, i8* getelementptr inbounds ({ <{ i8, i8, [98 x i8] }>, i32 }, { <{ i8, i8, [98 x i8] }>, i32 }* @tmp__abc, i32 0, i32 0, i32 0), i32 104), !dbg !43
|
||||||
|
ret void, !dbg !45
|
||||||
|
}
|
||||||
|
|
||||||
; CHECK-LABEL: prog1
|
; CHECK-LABEL: prog1
|
||||||
; CHECK: r1 = 3
|
; CHECK: r1 = 3 ll
|
||||||
; CHECK-LABEL: prog2
|
; CHECK-LABEL: prog2
|
||||||
; CHECK: r1 = 10
|
; CHECK: r1 = 10 ll
|
||||||
; CHECK-LABEL: prog3
|
; CHECK-LABEL: prog3
|
||||||
; CHECK: r1 = 4
|
; CHECK: r1 = 4 ll
|
||||||
|
|
||||||
; CHECK: .long 0 # BTF_KIND_STRUCT(id = 3)
|
; CHECK: .long 0 # BTF_KIND_STRUCT(id = 3)
|
||||||
; CHECK-NEXT: .long 67108866 # 0x4000002
|
; CHECK-NEXT: .long 67108866 # 0x4000002
|
||||||
@ -94,9 +96,8 @@ entry:
|
|||||||
; CHECK-NEXT: .long 48
|
; CHECK-NEXT: .long 48
|
||||||
; CHECK-NEXT: .long 7
|
; CHECK-NEXT: .long 7
|
||||||
|
|
||||||
attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
attributes #0 = { nounwind "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
||||||
attributes #1 = { nounwind readnone }
|
attributes #1 = { nounwind readnone }
|
||||||
attributes #2 = { nounwind }
|
|
||||||
|
|
||||||
!llvm.dbg.cu = !{!2}
|
!llvm.dbg.cu = !{!2}
|
||||||
!llvm.module.flags = !{!24, !25, !26}
|
!llvm.module.flags = !{!24, !25, !26}
|
||||||
@ -104,7 +105,7 @@ attributes #2 = { nounwind }
|
|||||||
|
|
||||||
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
|
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
|
||||||
!1 = distinct !DIGlobalVariable(name: "tmp__abc", scope: !2, file: !3, line: 5, type: !7, isLocal: false, isDefinition: true)
|
!1 = distinct !DIGlobalVariable(name: "tmp__abc", scope: !2, file: !3, line: 5, type: !7, isLocal: false, isDefinition: true)
|
||||||
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 12.0.0 (https://github.com/llvm/llvm-project.git f39aae11dca3f8f8c2c755a871726ed2fa82fd57)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !5, globals: !16, splitDebugInlining: false, nameTableKind: None)
|
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 12.0.0 (https://github.com/llvm/llvm-project.git 630c2da0e967e27e2a4c678dfc6e452a74141880)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !5, globals: !16, splitDebugInlining: false, nameTableKind: None)
|
||||||
!3 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/core")
|
!3 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/core")
|
||||||
!4 = !{}
|
!4 = !{}
|
||||||
!5 = !{!6, !11}
|
!5 = !{!6, !11}
|
||||||
@ -124,23 +125,27 @@ attributes #2 = { nounwind }
|
|||||||
!19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !20, size: 64)
|
!19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !20, size: 64)
|
||||||
!20 = !DISubroutineType(types: !21)
|
!20 = !DISubroutineType(types: !21)
|
||||||
!21 = !{!15, !22, !23, !15}
|
!21 = !{!15, !22, !23, !15}
|
||||||
!22 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
|
!22 = !DIBasicType(name: "long unsigned int", size: 64, encoding: DW_ATE_unsigned)
|
||||||
!23 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
|
!23 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
|
||||||
!24 = !{i32 7, !"Dwarf Version", i32 4}
|
!24 = !{i32 7, !"Dwarf Version", i32 4}
|
||||||
!25 = !{i32 2, !"Debug Info Version", i32 3}
|
!25 = !{i32 2, !"Debug Info Version", i32 3}
|
||||||
!26 = !{i32 1, !"wchar_size", i32 4}
|
!26 = !{i32 1, !"wchar_size", i32 4}
|
||||||
!27 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project.git f39aae11dca3f8f8c2c755a871726ed2fa82fd57)"}
|
!27 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project.git 630c2da0e967e27e2a4c678dfc6e452a74141880)"}
|
||||||
!28 = distinct !DISubprogram(name: "prog1", scope: !3, file: !3, line: 6, type: !29, scopeLine: 6, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4)
|
!28 = distinct !DISubprogram(name: "prog1", scope: !3, file: !3, line: 6, type: !29, scopeLine: 6, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4)
|
||||||
!29 = !DISubroutineType(types: !30)
|
!29 = !DISubroutineType(types: !30)
|
||||||
!30 = !{null}
|
!30 = !{null}
|
||||||
!31 = !DILocation(line: 7, column: 11, scope: !28)
|
!31 = !DILocation(line: 7, column: 3, scope: !28)
|
||||||
!32 = !DILocation(line: 7, column: 3, scope: !28)
|
!32 = !{!33, !33, i64 0}
|
||||||
!33 = !DILocation(line: 8, column: 1, scope: !28)
|
!33 = !{!"any pointer", !34, i64 0}
|
||||||
!34 = distinct !DISubprogram(name: "prog2", scope: !3, file: !3, line: 9, type: !29, scopeLine: 9, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4)
|
!34 = !{!"omnipotent char", !35, i64 0}
|
||||||
!35 = !DILocation(line: 10, column: 11, scope: !34)
|
!35 = !{!"Simple C/C++ TBAA"}
|
||||||
!36 = !DILocation(line: 10, column: 3, scope: !34)
|
!36 = !DILocation(line: 7, column: 11, scope: !28)
|
||||||
!37 = !DILocation(line: 11, column: 1, scope: !34)
|
!37 = !DILocation(line: 8, column: 1, scope: !28)
|
||||||
!38 = distinct !DISubprogram(name: "prog3", scope: !3, file: !3, line: 12, type: !29, scopeLine: 12, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4)
|
!38 = distinct !DISubprogram(name: "prog2", scope: !3, file: !3, line: 9, type: !29, scopeLine: 9, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4)
|
||||||
!39 = !DILocation(line: 13, column: 11, scope: !38)
|
!39 = !DILocation(line: 10, column: 3, scope: !38)
|
||||||
!40 = !DILocation(line: 13, column: 3, scope: !38)
|
!40 = !DILocation(line: 10, column: 11, scope: !38)
|
||||||
!41 = !DILocation(line: 14, column: 1, scope: !38)
|
!41 = !DILocation(line: 11, column: 1, scope: !38)
|
||||||
|
!42 = distinct !DISubprogram(name: "prog3", scope: !3, file: !3, line: 12, type: !29, scopeLine: 12, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4)
|
||||||
|
!43 = !DILocation(line: 13, column: 3, scope: !42)
|
||||||
|
!44 = !DILocation(line: 13, column: 11, scope: !42)
|
||||||
|
!45 = !DILocation(line: 14, column: 1, scope: !42)
|
||||||
|
@ -18,15 +18,16 @@ entry:
|
|||||||
%arg.addr = alloca %struct.s1*, align 8
|
%arg.addr = alloca %struct.s1*, align 8
|
||||||
store %struct.s1* %arg, %struct.s1** %arg.addr, align 8, !tbaa !18
|
store %struct.s1* %arg, %struct.s1** %arg.addr, align 8, !tbaa !18
|
||||||
call void @llvm.dbg.declare(metadata %struct.s1** %arg.addr, metadata !17, metadata !DIExpression()), !dbg !22
|
call void @llvm.dbg.declare(metadata %struct.s1** %arg.addr, metadata !17, metadata !DIExpression()), !dbg !22
|
||||||
%0 = call i32 @llvm.bpf.btf.type.id(i32 0, i64 0), !dbg !23, !llvm.preserve.access.index !12
|
%0 = call i64 @llvm.bpf.btf.type.id(i32 0, i64 0), !dbg !23, !llvm.preserve.access.index !12
|
||||||
ret i32 %0, !dbg !24
|
%conv = trunc i64 %0 to i32, !dbg !23
|
||||||
|
ret i32 %conv, !dbg !24
|
||||||
}
|
}
|
||||||
|
|
||||||
; Function Attrs: nounwind readnone speculatable willreturn
|
; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
|
||||||
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
|
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
|
||||||
|
|
||||||
; Function Attrs: nounwind readnone
|
; Function Attrs: nounwind readnone
|
||||||
declare i32 @llvm.bpf.btf.type.id(i32, i64) #2
|
declare i64 @llvm.bpf.btf.type.id(i32, i64) #2
|
||||||
|
|
||||||
; Function Attrs: nounwind
|
; Function Attrs: nounwind
|
||||||
define dso_local i32 @bar(%struct.s1* %arg) #0 !dbg !25 {
|
define dso_local i32 @bar(%struct.s1* %arg) #0 !dbg !25 {
|
||||||
@ -34,8 +35,9 @@ entry:
|
|||||||
%arg.addr = alloca %struct.s1*, align 8
|
%arg.addr = alloca %struct.s1*, align 8
|
||||||
store %struct.s1* %arg, %struct.s1** %arg.addr, align 8, !tbaa !18
|
store %struct.s1* %arg, %struct.s1** %arg.addr, align 8, !tbaa !18
|
||||||
call void @llvm.dbg.declare(metadata %struct.s1** %arg.addr, metadata !27, metadata !DIExpression()), !dbg !28
|
call void @llvm.dbg.declare(metadata %struct.s1** %arg.addr, metadata !27, metadata !DIExpression()), !dbg !28
|
||||||
%0 = call i32 @llvm.bpf.btf.type.id(i32 1, i64 0), !dbg !29, !llvm.preserve.access.index !12
|
%0 = call i64 @llvm.bpf.btf.type.id(i32 1, i64 0), !dbg !29, !llvm.preserve.access.index !12
|
||||||
ret i32 %0, !dbg !30
|
%conv = trunc i64 %0 to i32, !dbg !29
|
||||||
|
ret i32 %conv, !dbg !30
|
||||||
}
|
}
|
||||||
|
|
||||||
; CHECK: .long 1 # BTF_KIND_STRUCT(id = 2)
|
; CHECK: .long 1 # BTF_KIND_STRUCT(id = 2)
|
||||||
@ -57,20 +59,20 @@ entry:
|
|||||||
; CHECK-NEXT: .long 6
|
; CHECK-NEXT: .long 6
|
||||||
|
|
||||||
attributes #0 = { nounwind "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
attributes #0 = { nounwind "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
||||||
attributes #1 = { nounwind readnone speculatable willreturn }
|
attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
|
||||||
attributes #2 = { nounwind readnone }
|
attributes #2 = { nounwind readnone }
|
||||||
|
|
||||||
!llvm.dbg.cu = !{!0}
|
!llvm.dbg.cu = !{!0}
|
||||||
!llvm.module.flags = !{!3, !4, !5}
|
!llvm.module.flags = !{!3, !4, !5}
|
||||||
!llvm.ident = !{!6}
|
!llvm.ident = !{!6}
|
||||||
|
|
||||||
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0 (https://github.com/llvm/llvm-project.git 80a3f7beebd8caab358ff063526ae2d26467c029)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
|
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0 (https://github.com/llvm/llvm-project.git c1c153c3c70641a23c4a9540a897ff2d4eb4c5b2)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
|
||||||
!1 = !DIFile(filename: "test.c", directory: "/home/yhs/work/tests/dup")
|
!1 = !DIFile(filename: "test.c", directory: "/home/yhs/work/tests/dup")
|
||||||
!2 = !{}
|
!2 = !{}
|
||||||
!3 = !{i32 7, !"Dwarf Version", i32 4}
|
!3 = !{i32 7, !"Dwarf Version", i32 4}
|
||||||
!4 = !{i32 2, !"Debug Info Version", i32 3}
|
!4 = !{i32 2, !"Debug Info Version", i32 3}
|
||||||
!5 = !{i32 1, !"wchar_size", i32 4}
|
!5 = !{i32 1, !"wchar_size", i32 4}
|
||||||
!6 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project.git 80a3f7beebd8caab358ff063526ae2d26467c029)"}
|
!6 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project.git c1c153c3c70641a23c4a9540a897ff2d4eb4c5b2)"}
|
||||||
!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !16)
|
!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !16)
|
||||||
!8 = !DISubroutineType(types: !9)
|
!8 = !DISubroutineType(types: !9)
|
||||||
!9 = !{!10, !11}
|
!9 = !{!10, !11}
|
||||||
|
@ -12,14 +12,16 @@ target triple = "bpf"
|
|||||||
; Function Attrs: noinline nounwind optnone
|
; Function Attrs: noinline nounwind optnone
|
||||||
define dso_local i32 @foo() #0 !dbg !9 {
|
define dso_local i32 @foo() #0 !dbg !9 {
|
||||||
entry:
|
entry:
|
||||||
%0 = call i32 @llvm.bpf.btf.type.id(i32 0, i64 0), !dbg !12, !llvm.preserve.access.index !4
|
%0 = call i64 @llvm.bpf.btf.type.id(i32 0, i64 0), !dbg !11, !llvm.preserve.access.index !4
|
||||||
%1 = call i32 @llvm.bpf.preserve.type.info(i32 1, i64 0), !dbg !13, !llvm.preserve.access.index !14
|
%1 = call i32 @llvm.bpf.preserve.type.info(i32 1, i64 0), !dbg !12, !llvm.preserve.access.index !13
|
||||||
%add = add i32 %0, %1, !dbg !17
|
%conv = zext i32 %1 to i64, !dbg !12
|
||||||
ret i32 %add, !dbg !18
|
%add = add i64 %0, %conv, !dbg !16
|
||||||
|
%conv1 = trunc i64 %add to i32, !dbg !11
|
||||||
|
ret i32 %conv1, !dbg !17
|
||||||
}
|
}
|
||||||
|
|
||||||
; Function Attrs: nounwind readnone
|
; Function Attrs: nounwind readnone
|
||||||
declare i32 @llvm.bpf.btf.type.id(i32, i64) #1
|
declare i64 @llvm.bpf.btf.type.id(i32, i64) #1
|
||||||
|
|
||||||
; Function Attrs: nounwind readnone
|
; Function Attrs: nounwind readnone
|
||||||
declare i32 @llvm.bpf.preserve.type.info(i32, i64) #1
|
declare i32 @llvm.bpf.preserve.type.info(i32, i64) #1
|
||||||
@ -40,13 +42,12 @@ attributes #1 = { nounwind readnone }
|
|||||||
!6 = !{i32 2, !"Debug Info Version", i32 3}
|
!6 = !{i32 2, !"Debug Info Version", i32 3}
|
||||||
!7 = !{i32 1, !"wchar_size", i32 4}
|
!7 = !{i32 1, !"wchar_size", i32 4}
|
||||||
!8 = !{!"clang version 12.0.0"}
|
!8 = !{!"clang version 12.0.0"}
|
||||||
!9 = distinct !DISubprogram(name: "foo", scope: !10, file: !10, line: 2, type: !11, scopeLine: 2, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
|
!9 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !10, scopeLine: 2, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
|
||||||
!10 = !DIFile(filename: "C:/src/tmp/a.c", directory: "")
|
!10 = !DISubroutineType(types: !3)
|
||||||
!11 = !DISubroutineType(types: !3)
|
!11 = !DILocation(line: 2, column: 20, scope: !9)
|
||||||
!12 = !DILocation(line: 2, column: 21, scope: !9)
|
!12 = !DILocation(line: 2, column: 50, scope: !9)
|
||||||
!13 = !DILocation(line: 2, column: 51, scope: !9)
|
!13 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "ss", file: !1, line: 1, size: 32, elements: !14)
|
||||||
!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "ss", file: !10, line: 1, size: 32, elements: !15)
|
!14 = !{!15}
|
||||||
!15 = !{!16}
|
!15 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !13, file: !1, line: 1, baseType: !4, size: 32)
|
||||||
!16 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !14, file: !10, line: 1, baseType: !4, size: 32)
|
!16 = !DILocation(line: 2, column: 48, scope: !9)
|
||||||
!17 = !DILocation(line: 2, column: 49, scope: !9)
|
!17 = !DILocation(line: 2, column: 13, scope: !9)
|
||||||
!18 = !DILocation(line: 2, column: 14, scope: !9)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user