"detected in function "
<< *this << '\n';
}
- if (JT.Entries.empty()) {
- bool HasOneParent = (JT.Parents.size() == 1);
- for (unsigned I = 0; I < JT.EntriesAsAddress.size(); ++I) {
- uint64_t EntryAddress = JT.EntriesAsAddress[I];
- // builtin_unreachable does not belong to any function
- // Need to handle separately
- bool IsBuiltIn = false;
- for (BinaryFunction *Parent : JT.Parents) {
- if (EntryAddress == Parent->getAddress() + Parent->getSize()) {
- IsBuiltIn = true;
- // Specify second parameter as true to accept builtin_unreachable
- MCSymbol *Label = getOrCreateLocalLabel(EntryAddress, true);
- JT.Entries.push_back(Label);
- break;
- }
- }
- if (IsBuiltIn)
- continue;
- // Create local label for targets cannot be reached by other fragments
- // Otherwise, secondary entry point to target function
- BinaryFunction *TargetBF =
- BC.getBinaryFunctionContainingAddress(EntryAddress);
- if (TargetBF->getAddress() != EntryAddress) {
- MCSymbol *Label =
- (HasOneParent && TargetBF == this)
- ? getOrCreateLocalLabel(JT.EntriesAsAddress[I], true)
- : TargetBF->addEntryPointAtOffset(EntryAddress -
- TargetBF->getAddress());
- JT.Entries.push_back(Label);
- }
- }
- }
-
const uint64_t BDSize =
BC.getBinaryDataAtAddress(JT.getAddress())->getSize();
if (!BDSize) {
assert(BDSize >= JT.getSize() &&
"jump table cannot be larger than the containing object");
}
+ if (!JT.Entries.empty())
+ continue;
+
+ bool HasOneParent = (JT.Parents.size() == 1);
+ for (uint64_t EntryAddress : JT.EntriesAsAddress) {
+ // builtin_unreachable does not belong to any function
+ // Need to handle separately
+ bool IsBuiltinUnreachable =
+ llvm::any_of(JT.Parents, [&](const BinaryFunction *Parent) {
+ return EntryAddress == Parent->getAddress() + Parent->getSize();
+ });
+ if (IsBuiltinUnreachable) {
+ MCSymbol *Label = getOrCreateLocalLabel(EntryAddress, true);
+ JT.Entries.push_back(Label);
+ continue;
+ }
+ // Create local label for targets cannot be reached by other fragments
+ // Otherwise, secondary entry point to target function
+ BinaryFunction *TargetBF =
+ BC.getBinaryFunctionContainingAddress(EntryAddress);
+ if (uint64_t Offset = EntryAddress - TargetBF->getAddress()) {
+ MCSymbol *Label = (HasOneParent && TargetBF == this)
+ ? getOrCreateLocalLabel(EntryAddress, true)
+ : TargetBF->addEntryPointAtOffset(Offset);
+ JT.Entries.push_back(Label);
+ }
+ }
}
// Add TakenBranches from JumpTables.