@@ -62,6 +62,7 @@ class remove_asmt
62
62
void gcc_asm_function_call (
63
63
const irep_idt &function_base_name,
64
64
const code_asm_gcct &code,
65
+ std::size_t n_args,
65
66
goto_programt &dest);
66
67
67
68
void msc_asm_function_call (
@@ -77,10 +78,12 @@ class remove_asmt
77
78
// / \param function_base_name: Name of the function to call
78
79
// / \param code: gcc-style inline assembly statement to translate to function
79
80
// / call
81
+ // / \param n_args: Number of arguments required by \p function_base_name
80
82
// / \param dest: Goto program to append the function call to
81
83
void remove_asmt::gcc_asm_function_call (
82
84
const irep_idt &function_base_name,
83
85
const code_asm_gcct &code,
86
+ std::size_t n_args,
84
87
goto_programt &dest)
85
88
{
86
89
irep_idt function_identifier = function_base_name;
@@ -109,6 +112,16 @@ void remove_asmt::gcc_asm_function_call(
109
112
}
110
113
}
111
114
115
+ // An inline asm statement may consist of multiple commands, not all of which
116
+ // use all of the inputs/outputs of the inline asm statement.
117
+ DATA_INVARIANT_WITH_DIAGNOSTICS (
118
+ arguments.size () >= n_args,
119
+ " insufficient number of arguments for calling " +
120
+ id2string (function_identifier),
121
+ " required arguments: " + std::to_string (n_args),
122
+ code.pretty ());
123
+ arguments.resize (n_args);
124
+
112
125
code_typet fkt_type{
113
126
code_typet::parameterst{
114
127
arguments.size (), code_typet::parametert{void_pointer}},
@@ -133,9 +146,12 @@ void remove_asmt::gcc_asm_function_call(
133
146
}
134
147
else
135
148
{
136
- DATA_INVARIANT (
149
+ DATA_INVARIANT_WITH_DIAGNOSTICS (
137
150
symbol_table.lookup_ref (function_identifier).type == fkt_type,
138
- " function types should match" );
151
+ " types of function " + id2string (function_identifier) + " should match" ,
152
+ code.pretty (),
153
+ symbol_table.lookup_ref (function_identifier).type .pretty (),
154
+ fkt_type.pretty ());
139
155
}
140
156
}
141
157
@@ -293,12 +309,12 @@ void remove_asmt::process_instruction_gcc(
293
309
294
310
if (command == " fstcw" || command == " fnstcw" || command == " fldcw" ) // x86
295
311
{
296
- gcc_asm_function_call (" __asm_" + id2string (command), code, tmp_dest);
312
+ gcc_asm_function_call (" __asm_" + id2string (command), code, 1 , tmp_dest);
297
313
}
298
314
else if (
299
315
command == " mfence" || command == " lfence" || command == " sfence" ) // x86
300
316
{
301
- gcc_asm_function_call (" __asm_" + id2string (command), code, tmp_dest);
317
+ gcc_asm_function_call (" __asm_" + id2string (command), code, 0 , tmp_dest);
302
318
}
303
319
else if (command == ID_sync) // Power
304
320
{
0 commit comments