Skip to content

Commit 7d5212b

Browse files
clementvalsmallp-o-p
authored andcommitted
Revert "[flang][runtime][NFC] Allow different memmove function in assign" (llvm#114581)
Reverts llvm#114301
1 parent 4266e62 commit 7d5212b

File tree

2 files changed

+19
-32
lines changed

2 files changed

+19
-32
lines changed

flang/include/flang/Runtime/assign.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,11 @@
2424
#define FORTRAN_RUNTIME_ASSIGN_H_
2525

2626
#include "flang/Runtime/entry-names.h"
27-
#include "flang/Runtime/freestanding-tools.h"
2827

2928
namespace Fortran::runtime {
3029
class Descriptor;
31-
class Terminator;
32-
33-
enum AssignFlags {
34-
NoAssignFlags = 0,
35-
MaybeReallocate = 1 << 0,
36-
NeedFinalization = 1 << 1,
37-
CanBeDefinedAssignment = 1 << 2,
38-
ComponentCanBeDefinedAssignment = 1 << 3,
39-
ExplicitLengthCharacterLHS = 1 << 4,
40-
PolymorphicLHS = 1 << 5,
41-
DeallocateLHS = 1 << 6
42-
};
43-
44-
using MemmoveFct = void *(*)(void *, const void *, std::size_t);
45-
46-
static RT_API_ATTRS void *MemmoveWrapper(
47-
void *dest, const void *src, std::size_t count) {
48-
return Fortran::runtime::memmove(dest, src, count);
49-
}
50-
51-
RT_API_ATTRS void Assign(Descriptor &to, const Descriptor &from,
52-
Terminator &terminator, int flags, MemmoveFct memmoveFct = &MemmoveWrapper);
5330

5431
extern "C" {
55-
5632
// API for lowering assignment
5733
void RTDECL(Assign)(Descriptor &to, const Descriptor &from,
5834
const char *sourceFile = nullptr, int sourceLine = 0);

flang/runtime/assign.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@
1717

1818
namespace Fortran::runtime {
1919

20+
enum AssignFlags {
21+
NoAssignFlags = 0,
22+
MaybeReallocate = 1 << 0,
23+
NeedFinalization = 1 << 1,
24+
CanBeDefinedAssignment = 1 << 2,
25+
ComponentCanBeDefinedAssignment = 1 << 3,
26+
ExplicitLengthCharacterLHS = 1 << 4,
27+
PolymorphicLHS = 1 << 5,
28+
DeallocateLHS = 1 << 6
29+
};
30+
2031
// Predicate: is the left-hand side of an assignment an allocated allocatable
2132
// that must be deallocated?
2233
static inline RT_API_ATTRS bool MustDeallocateLHS(
@@ -239,8 +250,8 @@ static RT_API_ATTRS void BlankPadCharacterAssignment(Descriptor &to,
239250
// of elements, but their shape need not to conform (the assignment is done in
240251
// element sequence order). This facilitates some internal usages, like when
241252
// dealing with array constructors.
242-
RT_API_ATTRS void Assign(Descriptor &to, const Descriptor &from,
243-
Terminator &terminator, int flags, MemmoveFct memmoveFct) {
253+
RT_API_ATTRS static void Assign(
254+
Descriptor &to, const Descriptor &from, Terminator &terminator, int flags) {
244255
bool mustDeallocateLHS{(flags & DeallocateLHS) ||
245256
MustDeallocateLHS(to, from, terminator, flags)};
246257
DescriptorAddendum *toAddendum{to.Addendum()};
@@ -412,14 +423,14 @@ RT_API_ATTRS void Assign(Descriptor &to, const Descriptor &from,
412423
Assign(toCompDesc, fromCompDesc, terminator, nestedFlags);
413424
} else { // Component has intrinsic type; simply copy raw bytes
414425
std::size_t componentByteSize{comp.SizeInBytes(to)};
415-
memmoveFct(to.Element<char>(toAt) + comp.offset(),
426+
Fortran::runtime::memmove(to.Element<char>(toAt) + comp.offset(),
416427
from.Element<const char>(fromAt) + comp.offset(),
417428
componentByteSize);
418429
}
419430
break;
420431
case typeInfo::Component::Genre::Pointer: {
421432
std::size_t componentByteSize{comp.SizeInBytes(to)};
422-
memmoveFct(to.Element<char>(toAt) + comp.offset(),
433+
Fortran::runtime::memmove(to.Element<char>(toAt) + comp.offset(),
423434
from.Element<const char>(fromAt) + comp.offset(),
424435
componentByteSize);
425436
} break;
@@ -465,14 +476,14 @@ RT_API_ATTRS void Assign(Descriptor &to, const Descriptor &from,
465476
const auto &procPtr{
466477
*procPtrDesc.ZeroBasedIndexedElement<typeInfo::ProcPtrComponent>(
467478
k)};
468-
memmoveFct(to.Element<char>(toAt) + procPtr.offset,
479+
Fortran::runtime::memmove(to.Element<char>(toAt) + procPtr.offset,
469480
from.Element<const char>(fromAt) + procPtr.offset,
470481
sizeof(typeInfo::ProcedurePointer));
471482
}
472483
}
473484
} else { // intrinsic type, intrinsic assignment
474485
if (isSimpleMemmove()) {
475-
memmoveFct(to.raw().base_addr, from.raw().base_addr,
486+
Fortran::runtime::memmove(to.raw().base_addr, from.raw().base_addr,
476487
toElements * toElementBytes);
477488
} else if (toElementBytes > fromElementBytes) { // blank padding
478489
switch (to.type().raw()) {
@@ -496,8 +507,8 @@ RT_API_ATTRS void Assign(Descriptor &to, const Descriptor &from,
496507
} else { // elemental copies, possibly with character truncation
497508
for (std::size_t n{toElements}; n-- > 0;
498509
to.IncrementSubscripts(toAt), from.IncrementSubscripts(fromAt)) {
499-
memmoveFct(to.Element<char>(toAt), from.Element<const char>(fromAt),
500-
toElementBytes);
510+
Fortran::runtime::memmove(to.Element<char>(toAt),
511+
from.Element<const char>(fromAt), toElementBytes);
501512
}
502513
}
503514
}

0 commit comments

Comments
 (0)