mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
MarkForSerialization now ignores duplicated uses
Remove the logic for detecting Instructions with duplicated uses introduced by control-flow restructuring (the use is duplicated, but the instruction is not). By dropping this detection, we'll end up not marking for serialization some Instructions. Hence, when emitting C code, such Instructions will just be emitted as inline expressions, without declaring a dedicated local variable to hold their value. This is somehow suboptimal w.r.t the fact that the expression will be emitted many times, one for each duplicated use. However, this is not semantically incorrect, just verbose. On the other hand, the logic for detecting Instructions with duplicated uses has always been subtly broken, because it only looked at the number of duplicates for a given basic block introduced by control-flow restructuring. This information is not enough to detect Instructions with duplicated uses. Proper detection should actually be based on GHAST.
This commit is contained in:
@@ -39,16 +39,9 @@ bool MarkForSerializationPass::runOnFunction(llvm::Function &F) {
|
||||
if (not F.getName().equals(TargetFunction.c_str()))
|
||||
return false;
|
||||
|
||||
// Compute the number of duplicates for each BasicBlock.
|
||||
const auto &RestructurePass = getAnalysis<RestructureCFG>();
|
||||
using MarkAnalysis::DuplicationMap;
|
||||
const DuplicationMap &NDuplicates = RestructurePass.getNDuplicates();
|
||||
|
||||
// Mark instructions for serialization, and write the results in ToSerialize
|
||||
ToSerialize = {};
|
||||
MarkAnalysis::Analysis</* IgnoreDuplicatedUses */ false> Mark(F,
|
||||
NDuplicates,
|
||||
ToSerialize);
|
||||
MarkAnalysis::Analysis Mark(F, ToSerialize);
|
||||
Mark.initialize();
|
||||
Mark.run();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user