@@ -224,17 +224,23 @@ void Optimizer::optimizeAll()
224224 checkInst (orig);
225225 if (use_info.escaped ) {
226226 REMARK ([&]() {
227+ std::string str;
228+ llvm::raw_string_ostream rso (str);
229+ orig->print (rso);
227230 return OptimizationRemarkMissed (DEBUG_TYPE, " Escaped" , orig)
228- << " GC allocation escaped " << ore::NV (" GC Allocation" , orig );
231+ << " GC allocation escaped " << ore::NV (" GC Allocation" , StringRef (str) );
229232 });
230233 if (use_info.hastypeof )
231234 optimizeTag (orig);
232235 continue ;
233236 }
234237 if (use_info.haserror || use_info.returned ) {
235238 REMARK ([&]() {
239+ std::string str;
240+ llvm::raw_string_ostream rso (str);
241+ orig->print (rso);
236242 return OptimizationRemarkMissed (DEBUG_TYPE, " Escaped" , orig)
237- << " GC allocation has error or was returned " << ore::NV (" GC Allocation" , orig );
243+ << " GC allocation has error or was returned " << ore::NV (" GC Allocation" , StringRef (str) );
238244 });
239245 if (use_info.hastypeof )
240246 optimizeTag (orig);
@@ -243,8 +249,11 @@ void Optimizer::optimizeAll()
243249 if (!use_info.addrescaped && !use_info.hasload && (!use_info.haspreserve ||
244250 !use_info.refstore )) {
245251 REMARK ([&]() {
252+ std::string str;
253+ llvm::raw_string_ostream rso (str);
254+ orig->print (rso);
246255 return OptimizationRemark (DEBUG_TYPE, " Dead Allocation" , orig)
247- << " GC allocation removed " << ore::NV (" GC Allocation" , orig );
256+ << " GC allocation removed " << ore::NV (" GC Allocation" , StringRef (str) );
248257 });
249258 // No one took the address, no one reads anything and there's no meaningful
250259 // preserve of fields (either no preserve/ccall or no object reference fields)
@@ -270,17 +279,23 @@ void Optimizer::optimizeAll()
270279 }
271280 if (has_refaggr) {
272281 REMARK ([&]() {
282+ std::string str;
283+ llvm::raw_string_ostream rso (str);
284+ orig->print (rso);
273285 return OptimizationRemarkMissed (DEBUG_TYPE, " Escaped" , orig)
274- << " GC allocation has unusual object reference, unable to move to stack " << ore::NV (" GC Allocation" , orig );
286+ << " GC allocation has unusual object reference, unable to move to stack " << ore::NV (" GC Allocation" , StringRef (str) );
275287 });
276288 if (use_info.hastypeof )
277289 optimizeTag (orig);
278290 continue ;
279291 }
280292 if (!use_info.hasunknownmem && !use_info.addrescaped ) {
281293 REMARK ([&](){
294+ std::string str;
295+ llvm::raw_string_ostream rso (str);
296+ orig->print (rso);
282297 return OptimizationRemark (DEBUG_TYPE, " Stack Split Allocation" , orig)
283- << " GC allocation split on stack " << ore::NV (" GC Allocation" , orig );
298+ << " GC allocation split on stack " << ore::NV (" GC Allocation" , StringRef (str) );
284299 });
285300 // No one actually care about the memory layout of this object, split it.
286301 splitOnStack (orig);
@@ -292,16 +307,22 @@ void Optimizer::optimizeAll()
292307 // This later causes the GC rooting pass, to miss-characterize the float as a pointer to a GC value
293308 if (has_unboxed && has_ref) {
294309 REMARK ([&]() {
310+ std::string str;
311+ llvm::raw_string_ostream rso (str);
312+ orig->print (rso);
295313 return OptimizationRemarkMissed (DEBUG_TYPE, " Escaped" , orig)
296- << " GC allocation could not be split since it contains both boxed and unboxed values, unable to move to stack " << ore::NV (" GC Allocation" , orig );
314+ << " GC allocation could not be split since it contains both boxed and unboxed values, unable to move to stack " << ore::NV (" GC Allocation" , StringRef (str) );
297315 });
298316 if (use_info.hastypeof )
299317 optimizeTag (orig);
300318 continue ;
301319 }
302320 REMARK ([&](){
321+ std::string str;
322+ llvm::raw_string_ostream rso (str);
323+ orig->print (rso);
303324 return OptimizationRemark (DEBUG_TYPE, " Stack Move Allocation" , orig)
304- << " GC allocation moved to stack " << ore::NV (" GC Allocation" , orig );
325+ << " GC allocation moved to stack " << ore::NV (" GC Allocation" , StringRef (str) );
305326 });
306327 // The object has no fields with mix reference access
307328 moveToStack (orig, sz, has_ref, use_info.allockind );
@@ -380,7 +401,10 @@ void Optimizer::checkInst(CallInst *I)
380401 std::string suse_info;
381402 llvm::raw_string_ostream osuse_info (suse_info);
382403 use_info.dump (osuse_info);
383- return OptimizationRemarkAnalysis (DEBUG_TYPE, " EscapeAnalysis" , I) << " escape analysis for " << ore::NV (" GC Allocation" , I) << " \n " << ore::NV (" UseInfo" , osuse_info.str ());
404+ std::string str;
405+ llvm::raw_string_ostream rso (str);
406+ I->print (rso);
407+ return OptimizationRemarkAnalysis (DEBUG_TYPE, " EscapeAnalysis" , I) << " escape analysis for " << ore::NV (" GC Allocation" , StringRef (str)) << " \n " << ore::NV (" UseInfo" , osuse_info.str ());
384408 });
385409}
386410
@@ -905,8 +929,11 @@ void Optimizer::optimizeTag(CallInst *orig_inst)
905929 if (pass.typeof_func == callee) {
906930 ++RemovedTypeofs;
907931 REMARK ([&](){
932+ std::string str;
933+ llvm::raw_string_ostream rso (str);
934+ orig_inst->print (rso);
908935 return OptimizationRemark (DEBUG_TYPE, " typeof" , call)
909- << " removed typeof call for GC allocation " << ore::NV (" Alloc" , orig_inst );
936+ << " removed typeof call for GC allocation " << ore::NV (" Alloc" , StringRef (str) );
910937 });
911938 call->replaceAllUsesWith (tag);
912939 // Push to the removed instructions to trigger `finalize` to
0 commit comments