@@ -68,6 +68,7 @@ class remove_asmt
68
68
void gcc_asm_function_call (
69
69
const irep_idt &function_base_name,
70
70
const code_asm_gcct &code,
71
+ std::size_t n_args,
71
72
goto_programt &dest);
72
73
73
74
void msc_asm_function_call (
@@ -83,10 +84,12 @@ class remove_asmt
83
84
// / \param function_base_name: Name of the function to call
84
85
// / \param code: gcc-style inline assembly statement to translate to function
85
86
// / call
87
+ // / \param n_args: Number of arguments required by \p function_base_name
86
88
// / \param dest: Goto program to append the function call to
87
89
void remove_asmt::gcc_asm_function_call (
88
90
const irep_idt &function_base_name,
89
91
const code_asm_gcct &code,
92
+ std::size_t n_args,
90
93
goto_programt &dest)
91
94
{
92
95
irep_idt function_identifier = function_base_name;
@@ -115,6 +118,16 @@ void remove_asmt::gcc_asm_function_call(
115
118
}
116
119
}
117
120
121
+ // An inline asm statement may consist of multiple commands, not all of which
122
+ // use all of the inputs/outputs of the inline asm statement.
123
+ DATA_INVARIANT_WITH_DIAGNOSTICS (
124
+ arguments.size () >= n_args,
125
+ " insufficient number of arguments for calling " +
126
+ id2string (function_identifier),
127
+ " required arguments: " + std::to_string (n_args),
128
+ code.pretty ());
129
+ arguments.resize (n_args);
130
+
118
131
code_typet fkt_type{
119
132
code_typet::parameterst{
120
133
arguments.size (), code_typet::parametert{void_pointer}},
@@ -139,9 +152,12 @@ void remove_asmt::gcc_asm_function_call(
139
152
}
140
153
else
141
154
{
142
- DATA_INVARIANT (
155
+ DATA_INVARIANT_WITH_DIAGNOSTICS (
143
156
symbol_table.lookup_ref (function_identifier).type == fkt_type,
144
- " function types should match" );
157
+ " types of function " + id2string (function_identifier) + " should match" ,
158
+ code.pretty (),
159
+ symbol_table.lookup_ref (function_identifier).type .pretty (),
160
+ fkt_type.pretty ());
145
161
}
146
162
}
147
163
@@ -299,12 +315,12 @@ void remove_asmt::process_instruction_gcc(
299
315
300
316
if (command == " fstcw" || command == " fnstcw" || command == " fldcw" ) // x86
301
317
{
302
- gcc_asm_function_call (" __asm_" + id2string (command), code, tmp_dest);
318
+ gcc_asm_function_call (" __asm_" + id2string (command), code, 1 , tmp_dest);
303
319
}
304
320
else if (
305
321
command == " mfence" || command == " lfence" || command == " sfence" ) // x86
306
322
{
307
- gcc_asm_function_call (" __asm_" + id2string (command), code, tmp_dest);
323
+ gcc_asm_function_call (" __asm_" + id2string (command), code, 0 , tmp_dest);
308
324
}
309
325
else if (command == ID_sync) // Power
310
326
{
0 commit comments