[flang-commits] [flang] [llvm] [flang-rt] - Lightweight runtime assignment function (AssignSimple) for intrinsic-type assignments (PR #213704)
Tom Eccles via flang-commits
flang-commits at lists.llvm.org
Tue Aug 4 04:03:18 PDT 2026
================
@@ -851,6 +852,218 @@ void RTDEF(AssignExplicitLengthCharacter)(Descriptor &to,
ExplicitLengthCharacterLHS);
}
+void RTDEF(AssignSimple)(Descriptor &to, const Descriptor &from,
+ const char *sourceFile, int sourceLine) {
+ Terminator terminator{sourceFile, sourceLine};
+ // AssignSimple: fast path for intrinsic type assignments (integer, real,
+ // complex, logical). The compiler routes here only when:
+ // - LHS element type is trivial (isa_trivial), not derived/polymorphic
+ // - LHS and RHS ranks match (no scalar-to-array broadcasting)
+ // - LHS is not volatile (volatile needs memory ordering semantics)
+
+ if (to.rank() != from.rank()) {
+ terminator.Crash("AssignSimple: rank mismatch (to.rank=%d, from.rank=%d)",
+ to.rank(), from.rank());
+ }
+ if (to.ElementBytes() != from.ElementBytes()) {
----------------
tblah wrote:
Should this also check that the type codes match as well? e.g. not copying integer into real?
I presume this should/could be guaranteed by the frontend, but the same goes for ElementBytes() - my question is more about what the contract for this runtime function is.
If the goal is to minimise basic blocks, these checks could be moved to assertions and we could rely on the frontend to call the right function. This would be a departure from how the runtime handles other cases though so I wonder what other reviewers think.
https://github.com/llvm/llvm-project/pull/213704
More information about the flang-commits
mailing list