-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests for user function definition support
Includes parser, codegen and semantic analyzer tests.
- Loading branch information
1 parent
79c10df
commit 66635ae
Showing
4 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
; ModuleID = 'bpftrace' | ||
source_filename = "bpftrace" | ||
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128" | ||
target triple = "bpf-pc-linux" | ||
|
||
; Function Attrs: nounwind | ||
declare i64 @llvm.bpf.pseudo(i64 %0, i64 %1) #0 | ||
|
||
define internal i64 @add(i64 %0, i64 %1) { | ||
entry: | ||
%"$b" = alloca i64, align 8 | ||
%"$a" = alloca i64, align 8 | ||
%2 = bitcast i64* %"$a" to i8* | ||
call void @llvm.lifetime.start.p0i8(i64 -1, i8* %2) | ||
store i64 %0, i64* %"$a", align 8 | ||
%3 = bitcast i64* %"$b" to i8* | ||
call void @llvm.lifetime.start.p0i8(i64 -1, i8* %3) | ||
store i64 %1, i64* %"$b", align 8 | ||
%4 = load i64, i64* %"$a", align 8 | ||
%5 = load i64, i64* %"$b", align 8 | ||
%6 = add i64 %4, %5 | ||
ret i64 %6 | ||
} | ||
|
||
; Function Attrs: argmemonly nofree nosync nounwind willreturn | ||
declare void @llvm.lifetime.start.p0i8(i64 immarg %0, i8* nocapture %1) #1 | ||
|
||
attributes #0 = { nounwind } | ||
attributes #1 = { argmemonly nofree nosync nounwind willreturn } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include "common.h" | ||
|
||
namespace bpftrace { | ||
namespace test { | ||
namespace codegen { | ||
|
||
TEST(codegen, subprog_arguments) | ||
{ | ||
test("fn add($a : int64, $b : int64): int64 { return $a + $b; }", NAME); | ||
} | ||
|
||
} // namespace codegen | ||
} // namespace test | ||
} // namespace bpftrace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters