Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bpftrace
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bpftrace
Commits
d5d5acd6
Commit
d5d5acd6
authored
Mar 07, 2018
by
Alastair Robertson
Committed by
GitHub
Mar 07, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #20 from brendangregg/issue18
fix for #18: initializing comm memory
parents
ac109604
6da28c1d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
0 deletions
+10
-0
src/ast/codegen_llvm.cpp
src/ast/codegen_llvm.cpp
+2
-0
tests/codegen.cpp
tests/codegen.cpp
+8
-0
No files found.
src/ast/codegen_llvm.cpp
View file @
d5d5acd6
...
...
@@ -69,6 +69,8 @@ void CodegenLLVM::visit(Builtin &builtin)
else
if
(
builtin
.
ident
==
"comm"
)
{
AllocaInst
*
buf
=
b_
.
CreateAllocaBPF
(
builtin
.
type
,
"comm"
);
// initializing memory needed for older kernels:
b_
.
CreateMemSet
(
buf
,
b_
.
getInt8
(
0
),
builtin
.
type
.
size
,
1
);
b_
.
CreateGetCurrentComm
(
buf
,
builtin
.
type
.
size
);
expr_
=
buf
;
}
...
...
tests/codegen.cpp
View file @
d5d5acd6
...
...
@@ -471,6 +471,9 @@ 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
...
...
@@ -480,6 +483,7 @@ entry:
%comm = alloca [64 x i8], align 1
%1 = getelementptr inbounds [64 x i8], [64 x i8]* %comm, i64 0, i64 0
call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %1)
call void @llvm.memset.p0i8.i64(i8* nonnull %1, i8 0, i64 64, i32 1, i1 false)
%get_comm = call i64 inttoptr (i64 16 to i64 (i8*, i64)*)([64 x i8]* nonnull %comm, i64 64)
%2 = bitcast i64* %"@x_key" to i8*
call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %2)
...
...
@@ -1064,6 +1068,9 @@ 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
...
...
@@ -1074,6 +1081,7 @@ entry:
%comm = alloca [64 x i8], align 1
%1 = getelementptr inbounds [64 x i8], [64 x i8]* %comm, i64 0, i64 0
call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %1)
call void @llvm.memset.p0i8.i64(i8* nonnull %1, i8 0, i64 64, i32 1, i1 false)
%get_comm = call i64 inttoptr (i64 16 to i64 (i8*, i64)*)([64 x i8]* nonnull %comm, i64 64)
%2 = bitcast i64* %"@x_key" to i8*
call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %2)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment