@@ -437,19 +437,22 @@ ModuleImport::processAliasScopeMetadata(const llvm::MDNode *node) {
437437 return idx >= node->getNumOperands () ||
438438 isa<llvm::MDString>(node->getOperand (idx));
439439 };
440+
441+ auto getIdAttr = [&](const llvm::MDNode *node) -> Attribute {
442+ if (verifySelfRef (node))
443+ return DistinctAttr::create (builder.getUnitAttr ());
444+
445+ auto name = cast<llvm::MDString>(node->getOperand (0 ));
446+ return builder.getStringAttr (name->getString ());
447+ };
448+
440449 // Helper that creates an alias scope domain attribute.
441450 auto createAliasScopeDomainOp = [&](const llvm::MDNode *aliasDomain) {
442451 StringAttr description = nullptr ;
443452 if (aliasDomain->getNumOperands () >= 2 )
444453 if (auto *operand = dyn_cast<llvm::MDString>(aliasDomain->getOperand (1 )))
445454 description = builder.getStringAttr (operand->getString ());
446- Attribute idAttr;
447- if (verifySelfRef (aliasDomain)) {
448- idAttr = DistinctAttr::create (builder.getUnitAttr ());
449- } else {
450- auto name = cast<llvm::MDString>(aliasDomain->getOperand (0 ));
451- idAttr = builder.getStringAttr (name->getString ());
452- }
455+ Attribute idAttr = getIdAttr (aliasDomain);
453456 return builder.getAttr <AliasScopeDomainAttr>(idAttr, description);
454457 };
455458
@@ -485,14 +488,7 @@ ModuleImport::processAliasScopeMetadata(const llvm::MDNode *node) {
485488 StringAttr description = nullptr ;
486489 if (!aliasScope.getName ().empty ())
487490 description = builder.getStringAttr (aliasScope.getName ());
488- Attribute idAttr;
489- if (verifySelfRef (scope)) {
490- idAttr = DistinctAttr::create (builder.getUnitAttr ());
491- } else {
492- auto name = cast<llvm::MDString>(scope->getOperand (0 ));
493- idAttr = builder.getStringAttr (name->getString ());
494- }
495-
491+ Attribute idAttr = getIdAttr (scope);
496492 auto aliasScopeOp = builder.getAttr <AliasScopeAttr>(
497493 idAttr, cast<AliasScopeDomainAttr>(it->second ), description);
498494
0 commit comments