File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ void FixRISCVCallsPass::runOnFunction(BinaryFunction &BF) {
34
34
TargetSym = MIB->getPCRelLoSymbol (AInst);
35
35
if (TargetSym) {
36
36
auto BI = II;
37
- bool found = false ;
37
+ bool foundSymbol = false ;
38
38
while (BI != BB.begin ()){
39
39
auto *Label = MIB->getInstLabel (*BI);
40
40
if (Label && Label == TargetSym) {
@@ -48,6 +48,16 @@ void FixRISCVCallsPass::runOnFunction(BinaryFunction &BF) {
48
48
MIB->copyAnnotations (*BI, SavedInst);
49
49
BB.eraseInstruction (BI);
50
50
II = BB.insertInstruction (--II, std::move (SavedInst));
51
+
52
+ // Verify that the label of the current instruction matches
53
+ // the getPCRelLoSymbol of the next instruction
54
+ auto NextII = std::next (II);
55
+ if (NextII != BB.end ()) {
56
+ auto *CurrentLabel = MIB->getInstLabel (*II);
57
+ auto *NextTargetSym = MIB->getPCRelLoSymbol (*NextII);
58
+ assert (CurrentLabel && NextTargetSym && CurrentLabel == NextTargetSym &&
59
+ " Label and target symbol mismatch after instruction reordering" );
60
+ }
51
61
II++;
52
62
}
53
63
}
You can’t perform that action at this time.
0 commit comments