[llvm] r183630 - tblgen: always lookup values from the original vector as it could be grown under our feet.

David Blaikie dblaikie at gmail.com
Mon Jun 10 13:08:49 PDT 2013


On Sun, Jun 9, 2013 at 8:20 AM, Benjamin Kramer
<benny.kra at googlemail.com> wrote:
> Author: d0k
> Date: Sun Jun  9 10:20:23 2013
> New Revision: 183630
>
> URL: http://llvm.org/viewvc/llvm-project?rev=183630&view=rev
> Log:
> tblgen: always lookup values from the original vector as it could be grown under our feet.
>
> PR16281.
>
> Modified:
>     llvm/trunk/utils/TableGen/CodeGenSchedule.cpp
>
> Modified: llvm/trunk/utils/TableGen/CodeGenSchedule.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenSchedule.cpp?rev=183630&r1=183629&r2=183630&view=diff
> ==============================================================================
> --- llvm/trunk/utils/TableGen/CodeGenSchedule.cpp (original)
> +++ llvm/trunk/utils/TableGen/CodeGenSchedule.cpp Sun Jun  9 10:20:23 2013
> @@ -890,9 +890,9 @@ void CodeGenSchedModels::inferFromItinCl
>
>  /// Infer classes from per-processor InstReadWrite definitions.
>  void CodeGenSchedModels::inferFromInstRWs(unsigned SCIdx) {
> -  const RecVec &RWDefs = SchedClasses[SCIdx].InstRWs;
> -  for (RecIter RWI = RWDefs.begin(), RWE = RWDefs.end(); RWI != RWE; ++RWI) {
> -    const RecVec *InstDefs = Sets.expand(*RWI);
> +  for (unsigned I = 0, E = SchedClasses[SCIdx].InstRWs.size(); I != E; ++I) {
> +    Record *Rec = SchedClasses[SCIdx].InstRWs[I];

Does this deserve a comment? Would it be at all worth putting in an
assert to demonstrate that the size only ever increases (retrieve the
size before the loop, assert that it's <= the size at the start of the
loop, etc) so we can't accidentally skip the loop termination
condition?

> +    const RecVec *InstDefs = Sets.expand(Rec);
>      RecIter II = InstDefs->begin(), IE = InstDefs->end();
>      for (; II != IE; ++II) {
>        if (InstrClassMap[*II] == SCIdx)
> @@ -903,10 +903,10 @@ void CodeGenSchedModels::inferFromInstRW
>      if (II == IE)
>        continue;
>      IdxVec Writes, Reads;
> -    findRWs((*RWI)->getValueAsListOfDefs("OperandReadWrites"), Writes, Reads);
> -    unsigned PIdx = getProcModel((*RWI)->getValueAsDef("SchedModel")).Index;
> +    findRWs(Rec->getValueAsListOfDefs("OperandReadWrites"), Writes, Reads);
> +    unsigned PIdx = getProcModel(Rec->getValueAsDef("SchedModel")).Index;
>      IdxVec ProcIndices(1, PIdx);
> -    inferFromRW(Writes, Reads, SCIdx, ProcIndices);
> +    inferFromRW(Writes, Reads, SCIdx, ProcIndices); // May mutate SchedClasses.
>    }
>  }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list