@@ -226,45 +226,45 @@ extern "C" {
226
226
extern void jl_cpuid (int32_t CPUInfo[4 ], int32_t InfoType);
227
227
}
228
228
229
- static void jl_gen_llvm_gv_array (llvm::Module *mod)
229
+ static void jl_gen_llvm_gv_array (llvm::Module *mod, SmallVector<GlobalVariable*, 8 > &globalvars )
230
230
{
231
- // emit the variable table into the code image (can only call this once)
232
- // used just before dumping bitcode
231
+ // emit the variable table into the code image. used just before dumping bitcode.
232
+ // afterwards, call eraseFromParent on everything in globalvars to reset code generator.
233
233
ArrayType *atype = ArrayType::get (T_psize,jl_sysimg_gvars.size ());
234
- new GlobalVariable (
234
+ globalvars. push_back ( new GlobalVariable (
235
235
*mod,
236
236
atype,
237
237
true ,
238
238
GlobalVariable::ExternalLinkage,
239
239
ConstantArray::get (atype, ArrayRef<Constant*>(jl_sysimg_gvars)),
240
- " jl_sysimg_gvars" );
241
- new GlobalVariable (
240
+ " jl_sysimg_gvars" )) ;
241
+ globalvars. push_back ( new GlobalVariable (
242
242
*mod,
243
243
T_size,
244
244
true ,
245
245
GlobalVariable::ExternalLinkage,
246
246
ConstantInt::get (T_size,globalUnique+1 ),
247
- " jl_globalUnique" );
247
+ " jl_globalUnique" )) ;
248
248
249
249
Constant *feature_string = ConstantDataArray::getString (jl_LLVMContext, jl_cpu_string);
250
- new GlobalVariable (*mod,
250
+ globalvars. push_back ( new GlobalVariable (*mod,
251
251
feature_string->getType (),
252
252
true ,
253
253
GlobalVariable::ExternalLinkage,
254
254
feature_string,
255
- " jl_sysimg_cpu_target" );
255
+ " jl_sysimg_cpu_target" )) ;
256
256
257
257
// For native also store the cpuid
258
258
if (strcmp (jl_cpu_string," native" ) == 0 ) {
259
259
uint32_t info[4 ];
260
260
261
261
jl_cpuid ((int32_t *)info, 1 );
262
- new GlobalVariable (*mod,
262
+ globalvars. push_back ( new GlobalVariable (*mod,
263
263
T_int64,
264
264
true ,
265
265
GlobalVariable::ExternalLinkage,
266
266
ConstantInt::get (T_int64,((uint64_t )info[2 ])|(((uint64_t )info[3 ])<<32 )),
267
- " jl_sysimg_cpu_cpuid" );
267
+ " jl_sysimg_cpu_cpuid" )) ;
268
268
}
269
269
}
270
270
0 commit comments