AsmWriterEmitter will generate a getRegisterName function with an alternate register name index as its second argument if the target makes use of them. The enum of these values is generated in RegisterInfoEmitter. The getRegisterName generator would assume the namespace could always be found by reading index 1 of the list of AltNameIndices, but this will fail if this list is sorted such that the NoRegAltName is at index 1. Because this list is sorted by record name (in CodeGenTarget::ReadRegAltNameIndices), you only run in to problems if your MyTargetRegisterInfo.td defines a single RegAltNameIndex that sorts lexically before NoRegAltName.
i.e. if a target has something like def AnAltNameIndex : RegAltNameIndex and defines RegAltNameIndices for some registers then without this patch, AsmWriterEmitter will generate references to ::AnAltNameIndex and ::NoRegAltName.
Adding Jakob Oleson (TableGen code owner) and Jim Grosbach (original author of the RegAltName code) as reviewers. This patch is relevant to D14994, but the two patches are independent.
Patch by Alex Bradbury