Anonymous definitions in foreach blocks triggered a 'def already exists'

llvm-svn: 210526
This commit is contained in:
Artyom Skrobov 2014-06-10 12:41:14 +00:00
parent 8d5e97704b
commit 99252b5c50
2 changed files with 32 additions and 3 deletions

View File

@ -360,8 +360,13 @@ bool TGParser::ProcessForeachDefs(Record *CurRec, SMLoc Loc, IterSet &IterVals){
}
if (Records.getDef(IterRec->getNameInitAsString())) {
Error(Loc, "def already exists: " + IterRec->getNameInitAsString());
return true;
// If this record is anonymous, it's no problem, just generate a new name
if (IterRec->isAnonymous())
IterRec->setName(GetNewAnonymousName());
else {
Error(Loc, "def already exists: " + IterRec->getNameInitAsString());
return true;
}
}
Records.addDef(IterRec);

View File

@ -51,8 +51,10 @@ foreach i = [0, 1, 2, 3, 4, 5, 6, 7] in
// CHECK: string Name = "R7";
// CHECK: int Index = 7;
foreach i = {0-3,9-7} in
foreach i = {0-3,9-7} in {
def S#i : Register<"Q"#i, i>;
def : Register<"T"#i, i>;
}
// CHECK: def S0
// CHECK: def S1
@ -61,3 +63,25 @@ foreach i = {0-3,9-7} in
// CHECK: def S7
// CHECK: def S8
// CHECK: def S9
// CHECK: def
// CHECK: string Name = "T0";
// CHECK: def
// CHECK: string Name = "T1";
// CHECK: def
// CHECK: string Name = "T2";
// CHECK: def
// CHECK: string Name = "T3";
// CHECK: def
// CHECK: string Name = "T9";
// CHECK: def
// CHECK: string Name = "T8";
// CHECK: def
// CHECK: string Name = "T7";