Skip to content

Commit e28ee5e

Browse files
committed
filter comments out in emit
1 parent 69544b6 commit e28ee5e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

backend/amd64/emit.ml

+7-2
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,20 @@ let to_x86_constant_with_width (c : ND.Directive.Constant_with_width.t) :
6767

6868
let to_x86_directive (dir : ND.Directive.t) : X86_ast.asm_line list =
6969
let comment_lines comment =
70-
Option.to_list (Option.map (fun s -> X86_ast.Comment s) comment)
70+
(* CR sspies: This check is usually done in the printing function of the new
71+
directives. Since we are skipping those at the moment (by emitting via
72+
the X86 DSL), we do the same check here in the conversion. *)
73+
if !Clflags.keep_asm_file && !Flambda_backend_flags.dasm_comments
74+
then Option.to_list (Option.map (fun s -> X86_ast.Comment s) comment)
75+
else []
7176
in
7277
match dir with
7378
| Align { bytes } ->
7479
[X86_ast.Align (false, bytes)]
7580
(* The data field is currently ignored by both assembler backends. The bytes
7681
field is only converted to the final value when printing. *)
7782
| Bytes { str; comment } -> comment_lines comment @ [X86_ast.Bytes str]
78-
| Comment s -> [X86_ast.Comment s]
83+
| Comment s -> comment_lines (Some s)
7984
| Const { constant; comment } ->
8085
comment_lines comment @ [to_x86_constant_with_width constant]
8186
| Direct_assignment (s, c) ->

0 commit comments

Comments
 (0)