@@ -418,9 +418,6 @@ PreservedAnalyses CompileTimePropertiesPass::run(Module &M,
418
418
419
419
void CompileTimePropertiesPass::parseAlignmentAndApply (
420
420
Module &M, IntrinsicInst *IntrInst) {
421
- LLVMContext &Ctx = M.getContext ();
422
- unsigned MDKindID = Ctx.getMDKindID (SPIRV_DECOR_MD_KIND);
423
-
424
421
// Get the global variable with the annotation string.
425
422
const GlobalVariable *AnnotStrArgGV = nullptr ;
426
423
const Value *IntrAnnotStringArg = IntrInst->getArgOperand (1 );
@@ -435,54 +432,48 @@ void CompileTimePropertiesPass::parseAlignmentAndApply(
435
432
return ;
436
433
437
434
// parse properties string to decoration-value pairs
438
- auto properties = parseSYCLPropertiesString (M, IntrInst);
435
+ auto Properties = parseSYCLPropertiesString (M, IntrInst);
439
436
440
- SmallVector<Value *, 8 > userList ;
441
- SmallVector<Instruction *, 4 > instList ;
437
+ SmallVector<Value *, 8 > UserList ;
438
+ SmallVector<Instruction *, 4 > InstList ;
442
439
// check if used by a load or store instructions
443
- for (auto val : IntrInst->users ()) {
440
+ for (auto Val : IntrInst->users ()) {
444
441
// if castInst, push successors
445
- if (auto cast = dyn_cast<CastInst>(val )) {
446
- for (auto successor : cast ->users ())
447
- userList .push_back (successor );
442
+ if (auto CInst = dyn_cast<CastInst>(Val )) {
443
+ for (auto Successor : CInst ->users ())
444
+ UserList .push_back (Successor );
448
445
} else {
449
- userList .push_back (val );
446
+ UserList .push_back (Val );
450
447
}
451
448
}
452
449
453
- for (auto &value : userList ) {
454
- if (isa<LoadInst>(value ) || isa<StoreInst>(value ))
455
- instList .push_back (cast<Instruction>(value ));
450
+ for (auto &Value : UserList ) {
451
+ if (isa<LoadInst>(Value ) || isa<StoreInst>(Value ))
452
+ InstList .push_back (cast<Instruction>(Value ));
456
453
}
457
454
458
- for (auto property : properties) {
459
- // get decorcode code
460
- auto DecorIt = SpirvDecorMap.find (*property.first );
461
- if (DecorIt == SpirvDecorMap.end ())
462
- continue ;
463
-
464
- uint32_t DecorCode = DecorIt->second .Code ;
465
- auto DecorStr = property.first ->str ();
466
- auto DecorValue = property.second ;
467
- uint32_t attr_val;
455
+ for (auto &Property : Properties) {
456
+ auto DecorStr = Property.first ->str ();
457
+ auto DecorValue = Property.second ;
458
+ uint32_t AttrVal;
468
459
469
460
if (DecorStr == " sycl-alignment" ) {
470
461
assert (DecorValue && " sycl-alignment attribute is missing" );
471
462
472
- bool DecorValueIntConvFailed = DecorValue->getAsInteger (0 , attr_val );
463
+ bool DecorValueIntConvFailed = DecorValue->getAsInteger (0 , AttrVal );
473
464
474
465
std::ignore = DecorValueIntConvFailed;
475
466
assert (!DecorValueIntConvFailed &&
476
467
" sycl-alignment attribute is not an integer" );
477
- assert (llvm::isPowerOf2_64 (attr_val ) &&
468
+ assert (llvm::isPowerOf2_64 (AttrVal ) &&
478
469
" sycl-alignment attribute is not a power of 2" );
479
470
480
471
// apply alignment attributes to load/store
481
- for (auto inst : instList ) {
482
- if (auto loadinst = dyn_cast<LoadInst>(inst ))
483
- loadinst ->setAlignment (Align (attr_val ));
484
- else if (auto storeinst = dyn_cast<StoreInst>(inst ))
485
- storeinst ->setAlignment (Align (attr_val ));
472
+ for (auto Inst : InstList ) {
473
+ if (auto LInst = dyn_cast<LoadInst>(Inst ))
474
+ LInst ->setAlignment (Align (AttrVal ));
475
+ else if (auto SInst = dyn_cast<StoreInst>(Inst ))
476
+ SInst ->setAlignment (Align (AttrVal ));
486
477
}
487
478
}
488
479
}
@@ -517,9 +508,9 @@ bool CompileTimePropertiesPass::transformSYCLPropertiesAnnotation(
517
508
518
509
// Read the annotation values and create the new annotation string.
519
510
std::string NewAnnotString = " " ;
520
- auto properties = parseSYCLPropertiesString (M, IntrInst);
521
- for (auto property : properties ) {
522
- auto DecorIt = SpirvDecorMap.find (*property .first );
511
+ auto Properties = parseSYCLPropertiesString (M, IntrInst);
512
+ for (auto &Property : Properties ) {
513
+ auto DecorIt = SpirvDecorMap.find (*Property .first );
523
514
if (DecorIt == SpirvDecorMap.end ())
524
515
continue ;
525
516
uint32_t DecorCode = DecorIt->second .Code ;
@@ -529,8 +520,8 @@ bool CompileTimePropertiesPass::transformSYCLPropertiesAnnotation(
529
520
// string values are handled correctly. Note that " around values are
530
521
// always valid, even if the decoration parameters are not strings.
531
522
NewAnnotString += " {" + std::to_string (DecorCode);
532
- if (property .second )
533
- NewAnnotString += " :\" " + property .second ->str () + " \" " ;
523
+ if (Property .second )
524
+ NewAnnotString += " :\" " + Property .second ->str () + " \" " ;
534
525
NewAnnotString += " }" ;
535
526
}
536
527
@@ -568,7 +559,7 @@ bool CompileTimePropertiesPass::transformSYCLPropertiesAnnotation(
568
559
// The values are not in the annotation string, so we can remove the original
569
560
// annotation value.
570
561
PointerType *Arg4PtrTy =
571
- dyn_cast <PointerType>(IntrInst->getArgOperand (4 )->getType ());
562
+ cast <PointerType>(IntrInst->getArgOperand (4 )->getType ());
572
563
IntrInst->setArgOperand (4 , ConstantPointerNull::get (Arg4PtrTy));
573
564
return true ;
574
565
}
0 commit comments