Commit 8bae57b9 authored by Alastair Robertson's avatar Alastair Robertson

Update codegen tests

parent ac436bba
......@@ -23,26 +23,6 @@ IRBuilderBPF::IRBuilderBPF(LLVMContext &context,
GlobalValue::ExternalLinkage,
"llvm.bpf.pseudo",
&module_);
FunctionType *memcpy_func_type = FunctionType::get(
getVoidTy(),
{getInt8PtrTy(), getInt8PtrTy(), getInt64Ty(), getInt32Ty(), getInt1Ty()},
false);
Function::Create(
memcpy_func_type,
GlobalValue::ExternalLinkage,
"llvm.memcpy.p0i8.p0i8.i64",
&module_);
FunctionType *memset_func_type = FunctionType::get(
getVoidTy(),
{getInt8PtrTy(), getInt8Ty(), getInt64Ty(), getInt32Ty(), getInt1Ty()},
false);
Function::Create(
memset_func_type,
GlobalValue::ExternalLinkage,
"llvm.memset.p0i8.i64",
&module_);
}
AllocaInst *IRBuilderBPF::CreateAllocaBPF(llvm::Type *ty, const std::string &name)
......
# BPFtrace Tests
Tests can be run with the `bpftrace_test` executable.
The code generation tests are based on the output of the latest stable version of LLVM, so may give errors if run with an older LLVM. They can be excluded by running:
`bpftrace_test --gtest_filter=-codegen*`
......@@ -113,7 +113,7 @@ entry:
store i8 104, i8* %str.repack3, align 1
%str.repack4 = getelementptr inbounds [64 x i8], [64 x i8]* %str, i64 0, i64 4
%2 = bitcast i64* %"@x_key" to i8*
call void @llvm.memset.p0i8.i64(i8* %str.repack4, i8 0, i64 60, i32 1, i1 false)
call void @llvm.memset.p0i8.i64(i8* nonnull %str.repack4, i8 0, i64 60, i32 1, i1 false)
call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %2)
store i64 0, i64* %"@x_key", align 8
%pseudo = tail call i64 @llvm.bpf.pseudo(i64 1, i64 1)
......@@ -191,11 +191,11 @@ entry:
store i8 97, i8* %1, align 1
%str.sroa.3.0..sroa_idx = getelementptr inbounds [128 x i8], [128 x i8]* %"@x_key", i64 0, i64 1
%str1.sroa.0.0..sroa_idx = getelementptr inbounds [128 x i8], [128 x i8]* %"@x_key", i64 0, i64 64
call void @llvm.memset.p0i8.i64(i8* %str.sroa.3.0..sroa_idx, i8 0, i64 63, i32 1, i1 false)
call void @llvm.memset.p0i8.i64(i8* nonnull %str.sroa.3.0..sroa_idx, i8 0, i64 63, i32 1, i1 false)
store i8 98, i8* %str1.sroa.0.0..sroa_idx, align 1
%str1.sroa.3.0..sroa_idx = getelementptr inbounds [128 x i8], [128 x i8]* %"@x_key", i64 0, i64 65
%2 = bitcast i64* %"@x_val" to i8*
call void @llvm.memset.p0i8.i64(i8* %str1.sroa.3.0..sroa_idx, i8 0, i64 63, i32 1, i1 false)
call void @llvm.memset.p0i8.i64(i8* nonnull %str1.sroa.3.0..sroa_idx, i8 0, i64 63, i32 1, i1 false)
call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %2)
store i64 44, i64* %"@x_val", align 8
%pseudo = tail call i64 @llvm.bpf.pseudo(i64 1, i64 1)
......@@ -471,9 +471,6 @@ TEST(codegen, builtin_comm)
R"EXPECTED(; Function Attrs: nounwind
declare i64 @llvm.bpf.pseudo(i64, i64) #0
; Function Attrs: argmemonly nounwind
declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i32, i1) #1
; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
......@@ -495,6 +492,9 @@ entry:
ret i64 0
}
; Function Attrs: argmemonly nounwind
declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i32, i1) #1
; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
......@@ -773,9 +773,6 @@ TEST(codegen, call_str)
R"EXPECTED(; Function Attrs: nounwind
declare i64 @llvm.bpf.pseudo(i64, i64) #0
; Function Attrs: argmemonly nounwind
declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i32, i1) #1
; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
......@@ -804,6 +801,9 @@ entry:
ret i64 0
}
; Function Attrs: argmemonly nounwind
declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i32, i1) #1
; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
......@@ -945,12 +945,6 @@ TEST(codegen, string_propagation)
R"EXPECTED(; Function Attrs: nounwind
declare i64 @llvm.bpf.pseudo(i64, i64) #0
; Function Attrs: argmemonly nounwind
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1) #1
; Function Attrs: argmemonly nounwind
declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i32, i1) #1
; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
......@@ -972,7 +966,7 @@ entry:
store i8 102, i8* %str.repack7, align 1
%str.repack8 = getelementptr inbounds [64 x i8], [64 x i8]* %str, i64 0, i64 4
%2 = bitcast i64* %"@x_key" to i8*
call void @llvm.memset.p0i8.i64(i8* %str.repack8, i8 0, i64 60, i32 1, i1 false)
call void @llvm.memset.p0i8.i64(i8* nonnull %str.repack8, i8 0, i64 60, i32 1, i1 false)
call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %2)
store i64 0, i64* %"@x_key", align 8
%pseudo = tail call i64 @llvm.bpf.pseudo(i64 1, i64 1)
......@@ -1012,6 +1006,12 @@ lookup_merge: ; preds = %lookup_failure, %lo
; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
; Function Attrs: argmemonly nounwind
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1) #1
; Function Attrs: argmemonly nounwind
declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i32, i1) #1
attributes #0 = { nounwind }
attributes #1 = { argmemonly nounwind }
)EXPECTED");
......@@ -1068,9 +1068,6 @@ TEST(codegen, variable)
R"EXPECTED(; Function Attrs: nounwind
declare i64 @llvm.bpf.pseudo(i64, i64) #0
; Function Attrs: argmemonly nounwind
declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i32, i1) #1
; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
......@@ -1098,6 +1095,9 @@ entry:
ret i64 0
}
; Function Attrs: argmemonly nounwind
declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i32, i1) #1
; Function Attrs: argmemonly nounwind
declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment