Skip to content

Commit

Permalink
[EVM] Tmp: fix memcpy and other small issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelKopyl committed Oct 21, 2024
1 parent 481deb7 commit be3b27f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
16 changes: 8 additions & 8 deletions llvm/lib/Target/EVM/EVMOptimizedCodeTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ void EVMOptimizedCodeTransform::createStackLayout(Stack TargetStack) {
std::string VarNameDeep = SlotVariableName(DeepSlot);
std::string VarNameTop = SlotVariableName(CurrentStack.back());
std::string Msg =
(Twine("Cannot swap ") +
(VarNameDeep.empty() ? ("Slot " + stackSlotToString(DeepSlot))
: (Twine("Variable ") + VarNameDeep)) +
(Twine("cannot swap ") +
(VarNameDeep.empty() ? ("slot " + stackSlotToString(DeepSlot))
: (Twine("variable ") + VarNameDeep)) +
" with " +
(VarNameTop.empty()
? ("Slot " + stackSlotToString(CurrentStack.back()))
: (Twine("Variable ") + VarNameTop)) +
? ("slot " + stackSlotToString(CurrentStack.back()))
: (Twine("variable ") + VarNameTop)) +
": too deep in the stack by " + std::to_string(Deficit) +
" slots in " + stackToString(CurrentStack))
.str();
Expand All @@ -194,9 +194,9 @@ void EVMOptimizedCodeTransform::createStackLayout(Stack TargetStack) {
return;
} else if (!canBeFreelyGenerated(Slot)) {
std::string VarName = SlotVariableName(Slot);
Twine Msg =
((VarName.empty() ? "Slot " + stackSlotToString(Slot)
: Twine("Variable ") + VarName) +
std::string Msg =
((VarName.empty() ? "slot " + stackSlotToString(Slot)
: Twine("variable ") + VarName) +
" is " + std::to_string(*Depth - 15) +
" too deep in the stack " + stackToString(CurrentStack))
.str();
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/EVM/EVMStackLayoutGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ Stack StackLayoutGenerator::propagateStackThroughOperation(
if (auto const *VarSlot = std::get_if<VariableSlot>(&StackSlot))
assert(!EVMUtils::contains(Assignment->Variables, *VarSlot));

// Since stack+Operation.output can be easily shuffled to _exitLayout, the
// Since stack+Operation.output can be easily shuffled to ExitLayout, the
// desired layout before the operation is stack+Operation.input;
IdealStack += Operation.Input;

Expand Down
7 changes: 6 additions & 1 deletion llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,13 @@ Instruction *InstCombinerImpl::SimplifyAnyMemTransfer(AnyMemTransferInst *MI) {
assert(Size && "0-sized memory transferring should be removed already.");

// EraVM local begin
uint64_t SizeLimit = 8;
// For EVM we do not need to expand memcpy at all, as the possible memcpy
// operations are 1 to 1 mapped to corresponding instructions.
Triple TT(MI->getFunction()->getParent()->getTargetTriple());
if (TT.isEVM())
return nullptr;

uint64_t SizeLimit = 8;
if (TT.isEraVM())
SizeLimit = 32;

Expand Down

0 comments on commit be3b27f

Please sign in to comment.