Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not lost original AST after optimisations #119

Open
Tracked by #106
PalumboN opened this issue Mar 7, 2024 · 0 comments
Open
Tracked by #106

Do not lost original AST after optimisations #119

PalumboN opened this issue Mar 7, 2024 · 0 comments

Comments

@PalumboN
Copy link
Contributor

PalumboN commented Mar 7, 2024

Druid can, for instruction, track the expression in the interpreter from it was created:

image

But if some optimization replaces this instruction with another equivalent, the source is lost.
For example, here the subtraction 1 was changed by an addition -1:

image

This is happening because some instructions are being instantiated without origin and originAST:
image

This happens mostly inside the optimizations. They replace instructions with origin with new ones without.

We should keep the origin of an instruction when it is replace:by: a new one (without origin).


To focus on this refactor, I searched the senders of #operands:result: (used to instantiate instructions) and filtered some methods. Maybe help:

DRCogitCanonicaliser>>#visitSubstract:
DRCogitCanonicaliser>>#visitPop: 
DRCogitCanonicaliser>>#visitAddition:
DRCogitCodeGenerator>>#visitLoad: 
DRCogitSendMarshall class>>#send:
DRCogitSimpleStackGenerator>>#visitClosureCreation:
DRCommutativeOperation>>#reversed 
DRGetConditionCode>>#reversed
DRIRGenerator>>#instantiate:operands: 
DRInstruction class>>#result:
DRLinearScanRegisterAllocator>>#assignRegisterToResultInInstruction:
DRLinearScanRegisterAllocator>>#assignRegistersToOperandsInInstruction:
DRLocalVariableInstructionScheluder>>#storeReusedResultOf:
DRPhiSimplication>>#applyTo: 
DRPrimitiveIRGenerator>>#spillStack
DRSCCP>>#tryReplaceInstructionByFoldedValue:
DRSCCPConstantFoldingTest>>#testConstantFoldingOf:betweenOp:andOp:
DRSCCPConstantFoldingTest>>#nonReducibleOperation
DRSCCPWithStaging>>#latticeForLoad: 
DRStager>>#stageInstruction:
DRStrongCopyForInlining>>#asCopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant