Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
9339c414
Commit
9339c414
authored
7 years ago
by
Kostyantyn Vorobyov
Browse files
Options
Downloads
Patches
Plain Diff
Aligning small blocks during temporal analysis
parent
0f4734e9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/e-acsl/prepare_ast.ml
+55
-0
55 additions, 0 deletions
src/plugins/e-acsl/prepare_ast.ml
with
55 additions
and
0 deletions
src/plugins/e-acsl/prepare_ast.ml
+
55
−
0
View file @
9339c414
...
@@ -22,9 +22,64 @@
...
@@ -22,9 +22,64 @@
open
Cil_types
open
Cil_types
exception
Alignment_error
of
string
let
align_error
s
=
raise
(
Alignment_error
s
)
(* Returns true if the list of attributes [attrs] contains an [align]
* attribute of [algn] or greater. Returns false otherwise.
* Throws an exception if
* - [attrs] contains several [align] attributes specifying different
* alignment
* - [attrs] has a single align attribute with a value which is less than [algn] *)
let
sufficiently_aligned
attrs
algn
=
let
alignment
=
List
.
fold_left
(
fun
acc
attr
->
match
attr
with
|
Attr
(
"align"
,
[
AInt
i
])
->
let
alignment
=
Integer
.
to_int
i
in
if
acc
<>
0
&&
acc
<>
alignment
then
(* Multiple align attributes with different values *)
align_error
"Multiple alignment attributes"
else
if
alignment
<
algn
then
(* If there is an alignment attribute it should be greater
* or equal to [algn] *)
align_error
"Insufficient alignment"
else
alignment
|
Attr
(
"align"
,
_
)
->
(* Align attribute with an argument other than a single number,
should not happen really *)
assert
false
|
_
->
acc
)
0
attrs
in
if
alignment
>
0
then
true
else
false
(* Given the type and the list of attributes of [varinfo] ([fieldinfo]) return
* true if that [varinfo] ([fieldinfo]) requires to be aligned at the boundary
* of [algn] (i.e., less than [algn] bytes and has no alignment attribute *)
let
require_alignment
typ
attrs
algn
=
if
(
Cil
.
bitsSizeOf
typ
)
<
algn
*
8
&&
not
(
sufficiently_aligned
attrs
algn
)
then
true
else
false
class
prepare_visitor
prj
=
object
(
_
)
class
prepare_visitor
prj
=
object
(
_
)
inherit
Visitor
.
frama_c_copy
prj
inherit
Visitor
.
frama_c_copy
prj
(* Add align attributes to local variables (required by temporal analysis) *)
method
!
vblock
_
=
if
(
Temporal
.
is_enabled
()
)
then
Cil
.
DoChildrenPost
(
fun
blk
->
List
.
iter
(
fun
vi
->
if
require_alignment
vi
.
vtype
vi
.
vattr
4
;
then
begin
vi
.
vattr
<-
Attr
(
"aligned"
,
[
AInt
(
Integer
.
four
)])
::
vi
.
vattr
end
)
blk
.
blocals
;
blk
)
else
Cil
.
DoChildren
(* Move variable declared in the body of a switch statement to the outer
scope *)
method
!
vstmt_aux
_
=
method
!
vstmt_aux
_
=
Cil
.
DoChildrenPost
(
fun
stmt
->
Cil
.
DoChildrenPost
(
fun
stmt
->
match
stmt
.
skind
with
match
stmt
.
skind
with
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment