Skip to content

Commit

Permalink
fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Tietz committed Feb 7, 2024
1 parent da74c6c commit d54ca43
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/cfg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ and cfgStmt (s: stmt) (next:stmt option) (break:stmt option) (cont:stmt option)
cfgBlock blk (Some s) next (Some s) nodeList rlabels
(* Since all loops have terminating condition true, we don't put
any direct successor to stmt following the loop *)
| Asm _ -> addOptionSucc next (* the extra edges are added inside goblint's cfg *)
| Asm (_, _, _, _, _, labels, _) -> addOptionSucc next (* the extra edges are added inside goblint's cfg *)

(*------------------------------------------------------------*)

Expand Down
12 changes: 11 additions & 1 deletion src/check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,17 @@ and checkStmt (s: stmt) =
cases;

| Instr il -> List.iter checkInstr il
| Asm _ -> () (* Not yet implemented *)
| Asm (_, _, _, _, _, labels, l) ->
currentLoc := l;
List.iter (fun dest ->
List.iter (fun label ->
let name = match label with
| Label (name, _, true) -> name
| _ -> failwith "unreachable"
in
gotoTargets := (name, !dest) :: !gotoTargets
) !dest.labels;
) labels;
)
() (* argument of withContext *)

Expand Down
6 changes: 5 additions & 1 deletion src/cil.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6550,7 +6550,11 @@ and succpred_stmt s fallthrough rlabels =
| hd :: tl -> link s hd ;
succpred_block b fallthrough rlabels
end
| Asm _ -> trylink s fallthrough
| Asm (_, _, _, _, _, labels, _) ->
List.iter (fun label ->
link s !label
) labels;
trylink s fallthrough


let caseRangeFold (l: label list) =
Expand Down
9 changes: 8 additions & 1 deletion src/rmUnused.ml
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,14 @@ class markUsedLabels (labelMap: (string, unit) H.t) = object
(* Mark it as used *)
H.replace labelMap ln ();
DoChildren

| Asm (_, _, _, _, _, labels, _) ->
List.iter (fun dest ->
let (ln, _, _), _ = labelsToKeep !dest.labels in
if ln = "" then
E.s (E.bug "rmUnused: destination of statement does not have labels");
H.replace labelMap ln ();
) labels;
DoChildren
| _ -> DoChildren

method! vexpr e = match e with
Expand Down
2 changes: 1 addition & 1 deletion test/small1/asm_goto3.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "testharness.h"

void code() {
int main(void) {
start:
asm goto ("nop" : : : : start, exit);
exit:
Expand Down

0 comments on commit d54ca43

Please sign in to comment.