Commit bbe27aee authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

Fixed an issue with String - Print lowering



The string literal SSA var need to be overridden in the tracking map to ensure the subsequent print is referring to an *in-scope* var.

e.g., multiple scoped regions referring to the same string literal for printing.

Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent 587eb3a5
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -69,7 +69,14 @@ LogicalResult CreateStringLiteralOpLowering::matchAndRewrite(
      StringRef(slOpText.str().c_str(), slOpText.str().length() + 1),
      parentModule);

  variables.insert({slVarName.str(), new_global_str});
  // The string literal var must be **overriden** by closest scope.
  // This will prevent dangling references b/w different scopes leading to
  // dominance checking failed.
  // Notes: the above getOrCreateGlobalString will just get a *reference*
  // to the globally-allocated string.
  // i.e., each scope must use its own reference (potentially to the same
  // string). Otherwise, we'll have dominance check failure.
  variables.insert_or_assign(slVarName.str(), new_global_str);

  rewriter.eraseOp(op);