[Mlir-commits] [mlir] [MLIR][Presburger] Fix bug in PresburgerSpace::convertVarKind (PR #67267)

Bharathi Ramana Joshi llvmlistbot at llvm.org
Sun Sep 24 23:41:13 PDT 2023


================
@@ -161,6 +161,26 @@ void PresburgerSpace::convertVarKind(VarKind srcKind, unsigned srcPos,
   assert(dstPos <= getNumVarKind(dstKind) &&
          "invalid position for destination variables");
 
+  // Move identifiers if `usingIds` and variables moved are not locals.
+  unsigned srcOffset = getVarKindOffset(srcKind) + srcPos;
+  unsigned dstOffset = getVarKindOffset(dstKind) + dstPos;
+  if (isUsingIds() && srcKind != VarKind::Local && dstKind != VarKind::Local) {
+    identifiers.insert(identifiers.begin() + dstOffset, num, Identifier());
+    // srcOffset is invalid after the insert.
----------------
iambrj wrote:

Minor nit: I suggest phrasing the comment as something like "Increment srcOffset after inserting num variables before it".

https://github.com/llvm/llvm-project/pull/67267


More information about the Mlir-commits mailing list