@@ -317,17 +317,12 @@ void GenXVisaRegAlloc::extraCoalescing()
317
317
/* **********************************************************************
318
318
* allocReg : allocate a register for a LiveRange
319
319
*/
320
- void GenXVisaRegAlloc::allocReg (LiveRange *LR)
321
- {
320
+ void GenXVisaRegAlloc::allocReg (LiveRange *LR) {
322
321
if (LR->value_empty ())
323
322
return ;
324
323
if (LR->getCategory () >= RegCategory::NUMREALCATEGORIES)
325
324
return ; // don't allocate register to EM or RM value
326
- LLVM_DEBUG (
327
- dbgs () << " Allocating " ;
328
- LR->print (dbgs ());
329
- dbgs () << " \n "
330
- );
325
+ LLVM_DEBUG (dbgs () << " Allocating " ; LR->print (dbgs ()); dbgs () << " \n " );
331
326
SimpleValue V = *LR->value_begin ();
332
327
Type *Ty = V.getType ();
333
328
if (auto GV = dyn_cast<GlobalVariable>(V.getValue ()))
@@ -336,28 +331,29 @@ void GenXVisaRegAlloc::allocReg(LiveRange *LR)
336
331
assert (!Ty->isVoidTy ());
337
332
if (LR->Category == RegCategory::PREDICATE) {
338
333
VectorType *VT = dyn_cast<VectorType>(Ty);
339
- assert ((!VT || genx::exactLog2 (VT->getNumElements ()) >= 0 ) && " invalid predicate width" );
334
+ assert ((!VT || genx::exactLog2 (VT->getNumElements ()) >= 0 ) &&
335
+ " invalid predicate width" );
340
336
(void )VT;
341
337
}
342
338
// Allocate the register, also setting the alignment.
339
+ Reg *NewReg =
340
+ createReg (LR->Category , Ty, DONTCARESIGNED, LR->getLogAlignment ());
343
341
// Assign to the values. If any value is an input arg, ensure the register
344
342
// gets its type, to avoid needing an alias for an input arg.
345
- for (auto &F : LR->Funcs ) {
346
- Reg *NewReg =
347
- createReg (LR->Category , Ty, DONTCARESIGNED, LR->getLogAlignment ());
348
- if (RegMap.count (F) > 0 ) {
349
- for (LiveRange::value_iterator vi = LR->value_begin (),
350
- ve = LR->value_end ();
351
- vi != ve; ++vi) {
352
- LLVM_DEBUG (dbgs () << " Allocating reg " << NewReg->Num << " to "
343
+ for (LiveRange::value_iterator vi = LR->value_begin (), ve = LR->value_end ();
344
+ vi != ve; ++vi) {
345
+ for (auto &F : LR->Funcs ) {
346
+ if (FGA->getGroup (F) == FG) {
347
+ assert (RegMap.count (F) > 0 );
348
+ LLVM_DEBUG (dbgs () << " Allocating reg " << NewReg->Num << " for "
353
349
<< *(vi->getValue ()) << " in func " << F->getName ()
354
- << " \n " ; );
350
+ << " \n " );
355
351
assert (RegMap.at (F).find (*vi) == RegMap.at (F).end ());
356
352
RegMap.at (F)[*vi] = NewReg;
357
- if (isa<Argument>(vi->getValue ()))
358
- NewReg->Ty = vi->getType ();
359
353
}
360
354
}
355
+ if (isa<Argument>(vi->getValue ()))
356
+ NewReg->Ty = vi->getType ();
361
357
}
362
358
}
363
359
0 commit comments