Skip to content

Commit be83f5c

Browse files
authored
[BOLT][NFC] Simplify analyzeIndirectBranch (#91662)
Simplify mutually exclusive sanity checks in analyzeIndirectBranch, where an UNKNOWN IndirectBranchType is to be returned. Reduces confusion and code duplication when adding a new IndirectBranchType (to be added in #91667). Test Plan: NFC
1 parent ccde823 commit be83f5c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

bolt/lib/Target/X86/X86MCPlusBuilder.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,13 +2115,15 @@ class X86MCPlusBuilder : public MCPlusBuilder {
21152115
return IndirectBranchType::POSSIBLE_FIXED_BRANCH;
21162116
}
21172117

2118-
if (Type == IndirectBranchType::POSSIBLE_PIC_JUMP_TABLE &&
2119-
(MO->ScaleImm != 1 || MO->BaseRegNum != RIPRegister))
2120-
return IndirectBranchType::UNKNOWN;
2121-
2122-
if (Type != IndirectBranchType::POSSIBLE_PIC_JUMP_TABLE &&
2123-
MO->ScaleImm != PtrSize)
2124-
return IndirectBranchType::UNKNOWN;
2118+
switch (Type) {
2119+
case IndirectBranchType::POSSIBLE_PIC_JUMP_TABLE:
2120+
if (MO->ScaleImm != 1 || MO->BaseRegNum != RIPRegister)
2121+
return IndirectBranchType::UNKNOWN;
2122+
break;
2123+
default:
2124+
if (MO->ScaleImm != PtrSize)
2125+
return IndirectBranchType::UNKNOWN;
2126+
}
21252127

21262128
MemLocInstrOut = MemLocInstr;
21272129

0 commit comments

Comments
 (0)