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
de5e6d81
Commit
de5e6d81
authored
Oct 15, 2018
by
Mateusz Lenik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cast integers to the correct type
Apply Brendan's patch
parent
c86d02b0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
src/ast/codegen_llvm.cpp
src/ast/codegen_llvm.cpp
+11
-0
No files found.
src/ast/codegen_llvm.cpp
View file @
de5e6d81
...
...
@@ -160,6 +160,7 @@ void CodegenLLVM::visit(Call &call)
AllocaInst
*
newval
=
b_
.
CreateAllocaBPF
(
map
.
type
,
map
.
ident
+
"_val"
);
call
.
vargs
->
front
()
->
accept
(
*
this
);
expr_
=
b_
.
CreateIntCast
(
expr_
,
b_
.
getInt64Ty
(),
false
);
// promote int to 64-bit
b_
.
CreateStore
(
b_
.
CreateAdd
(
expr_
,
oldval
),
newval
);
b_
.
CreateMapUpdateElem
(
map
,
key
,
newval
);
...
...
@@ -179,6 +180,7 @@ void CodegenLLVM::visit(Call &call)
// elements will always store on the first occurrance. Revent this later when printing.
Function
*
parent
=
b_
.
GetInsertBlock
()
->
getParent
();
call
.
vargs
->
front
()
->
accept
(
*
this
);
expr_
=
b_
.
CreateIntCast
(
expr_
,
b_
.
getInt64Ty
(),
false
);
// promote int to 64-bit
Value
*
inverted
=
b_
.
CreateSub
(
b_
.
getInt64
(
0xffffffff
),
expr_
);
BasicBlock
*
lt
=
BasicBlock
::
Create
(
module_
->
getContext
(),
"min.lt"
,
parent
);
BasicBlock
*
ge
=
BasicBlock
::
Create
(
module_
->
getContext
(),
"min.ge"
,
parent
);
...
...
@@ -203,6 +205,7 @@ void CodegenLLVM::visit(Call &call)
Function
*
parent
=
b_
.
GetInsertBlock
()
->
getParent
();
call
.
vargs
->
front
()
->
accept
(
*
this
);
expr_
=
b_
.
CreateIntCast
(
expr_
,
b_
.
getInt64Ty
(),
false
);
// promote int to 64-bit
BasicBlock
*
lt
=
BasicBlock
::
Create
(
module_
->
getContext
(),
"min.lt"
,
parent
);
BasicBlock
*
ge
=
BasicBlock
::
Create
(
module_
->
getContext
(),
"min.ge"
,
parent
);
b_
.
CreateCondBr
(
b_
.
CreateICmpSGE
(
expr_
,
oldval
),
ge
,
lt
);
...
...
@@ -235,6 +238,7 @@ void CodegenLLVM::visit(Call &call)
Value
*
total_old
=
b_
.
CreateMapLookupElem
(
map
,
total_key
);
AllocaInst
*
total_new
=
b_
.
CreateAllocaBPF
(
map
.
type
,
map
.
ident
+
"_val"
);
call
.
vargs
->
front
()
->
accept
(
*
this
);
expr_
=
b_
.
CreateIntCast
(
expr_
,
b_
.
getInt64Ty
(),
false
);
// promote int to 64-bit
b_
.
CreateStore
(
b_
.
CreateAdd
(
expr_
,
total_old
),
total_new
);
b_
.
CreateMapUpdateElem
(
map
,
total_key
,
total_new
);
b_
.
CreateLifetimeEnd
(
total_key
);
...
...
@@ -246,6 +250,7 @@ void CodegenLLVM::visit(Call &call)
{
Map
&
map
=
*
call
.
map
;
call
.
vargs
->
front
()
->
accept
(
*
this
);
expr_
=
b_
.
CreateIntCast
(
expr_
,
b_
.
getInt64Ty
(),
false
);
// promote int to 64-bit
Function
*
log2_func
=
module_
->
getFunction
(
"log2"
);
Value
*
log2
=
b_
.
CreateCall
(
log2_func
,
expr_
,
"log2"
);
AllocaInst
*
key
=
getHistMapKey
(
map
,
log2
);
...
...
@@ -281,6 +286,12 @@ void CodegenLLVM::visit(Call &call)
step_arg
.
accept
(
*
this
);
step
=
expr_
;
// promote int to 64-bit
value
=
b_
.
CreateIntCast
(
value
,
b_
.
getInt64Ty
(),
false
);
min
=
b_
.
CreateIntCast
(
min
,
b_
.
getInt64Ty
(),
false
);
max
=
b_
.
CreateIntCast
(
max
,
b_
.
getInt64Ty
(),
false
);
step
=
b_
.
CreateIntCast
(
step
,
b_
.
getInt64Ty
(),
false
);
Value
*
linear
=
b_
.
CreateCall
(
linear_func
,
{
value
,
min
,
max
,
step
}
,
"linear"
);
AllocaInst
*
key
=
getHistMapKey
(
map
,
linear
);
...
...
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