mirror of
https://github.com/revanced/smali.git
synced 2025-05-02 15:44:30 +02:00
Fix register propagation when overriding a register type from a predecessor
This commit is contained in:
parent
398630dde5
commit
37d14becd1
@ -189,12 +189,19 @@ public class AnalyzedInstruction implements Comparable<AnalyzedInstruction> {
|
|||||||
* register is a destination register for this instruction, or if the pre-instruction register type didn't change
|
* register is a destination register for this instruction, or if the pre-instruction register type didn't change
|
||||||
* after merging in the given register type
|
* after merging in the given register type
|
||||||
*/
|
*/
|
||||||
protected boolean mergeRegister(int registerNumber, RegisterType registerType, BitSet verifiedInstructions) {
|
protected boolean mergeRegister(int registerNumber, RegisterType registerType, BitSet verifiedInstructions,
|
||||||
|
boolean override) {
|
||||||
assert registerNumber >= 0 && registerNumber < postRegisterMap.length;
|
assert registerNumber >= 0 && registerNumber < postRegisterMap.length;
|
||||||
assert registerType != null;
|
assert registerType != null;
|
||||||
|
|
||||||
RegisterType oldRegisterType = preRegisterMap[registerNumber];
|
RegisterType oldRegisterType = preRegisterMap[registerNumber];
|
||||||
RegisterType mergedRegisterType = oldRegisterType.merge(registerType);
|
|
||||||
|
RegisterType mergedRegisterType;
|
||||||
|
if (override) {
|
||||||
|
mergedRegisterType = getMergedPreRegisterTypeFromPredecessors(registerNumber);
|
||||||
|
} else {
|
||||||
|
mergedRegisterType = oldRegisterType.merge(registerType);
|
||||||
|
}
|
||||||
|
|
||||||
if (mergedRegisterType.equals(oldRegisterType)) {
|
if (mergedRegisterType.equals(oldRegisterType)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -336,8 +336,7 @@ public class MethodAnalyzer {
|
|||||||
registerType);
|
registerType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void propagateChanges(@Nonnull BitSet changedInstructions, int registerNumber,
|
private void propagateChanges(@Nonnull BitSet changedInstructions, int registerNumber, boolean override) {
|
||||||
@Nonnull RegisterType registerType) {
|
|
||||||
//Using a for loop inside the while loop optimizes for the common case of the successors of an instruction
|
//Using a for loop inside the while loop optimizes for the common case of the successors of an instruction
|
||||||
//occurring after the instruction. Any successors that occur prior to the instruction will be picked up on
|
//occurring after the instruction. Any successors that occur prior to the instruction will be picked up on
|
||||||
//the next iteration of the while loop.
|
//the next iteration of the while loop.
|
||||||
@ -350,7 +349,7 @@ public class MethodAnalyzer {
|
|||||||
changedInstructions.clear(instructionIndex);
|
changedInstructions.clear(instructionIndex);
|
||||||
|
|
||||||
propagateRegisterToSuccessors(analyzedInstructions.valueAt(instructionIndex), registerNumber,
|
propagateRegisterToSuccessors(analyzedInstructions.valueAt(instructionIndex), registerNumber,
|
||||||
changedInstructions);
|
changedInstructions, override);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -366,7 +365,7 @@ public class MethodAnalyzer {
|
|||||||
}
|
}
|
||||||
changedInstructions.set(analyzedInstruction.instructionIndex);
|
changedInstructions.set(analyzedInstruction.instructionIndex);
|
||||||
|
|
||||||
propagateChanges(changedInstructions, registerNumber, registerType);
|
propagateChanges(changedInstructions, registerNumber, true);
|
||||||
|
|
||||||
if (registerType.category == RegisterType.LONG_LO) {
|
if (registerType.category == RegisterType.LONG_LO) {
|
||||||
checkWidePair(registerNumber, analyzedInstruction);
|
checkWidePair(registerNumber, analyzedInstruction);
|
||||||
@ -388,9 +387,9 @@ public class MethodAnalyzer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
propagateRegisterToSuccessors(analyzedInstruction, registerNumber, changedInstructions);
|
propagateRegisterToSuccessors(analyzedInstruction, registerNumber, changedInstructions, false);
|
||||||
|
|
||||||
propagateChanges(changedInstructions, registerNumber, registerType);
|
propagateChanges(changedInstructions, registerNumber, false);
|
||||||
|
|
||||||
if (registerType.category == RegisterType.LONG_LO) {
|
if (registerType.category == RegisterType.LONG_LO) {
|
||||||
checkWidePair(registerNumber, analyzedInstruction);
|
checkWidePair(registerNumber, analyzedInstruction);
|
||||||
@ -402,10 +401,10 @@ public class MethodAnalyzer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void propagateRegisterToSuccessors(@Nonnull AnalyzedInstruction instruction, int registerNumber,
|
private void propagateRegisterToSuccessors(@Nonnull AnalyzedInstruction instruction, int registerNumber,
|
||||||
@Nonnull BitSet changedInstructions) {
|
@Nonnull BitSet changedInstructions, boolean override) {
|
||||||
RegisterType postRegisterType = instruction.getPostInstructionRegisterType(registerNumber);
|
RegisterType postRegisterType = instruction.getPostInstructionRegisterType(registerNumber);
|
||||||
for (AnalyzedInstruction successor: instruction.successors) {
|
for (AnalyzedInstruction successor: instruction.successors) {
|
||||||
if (successor.mergeRegister(registerNumber, postRegisterType, analyzedState)) {
|
if (successor.mergeRegister(registerNumber, postRegisterType, analyzedState, override)) {
|
||||||
changedInstructions.set(successor.instructionIndex);
|
changedInstructions.set(successor.instructionIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user