mirror of
https://github.com/intel/llvm.git
synced 2026-01-14 11:57:39 +08:00
Fix CFG building issue.
Summary: Fixed getBasicBlockContainingOffset() to return correct basic block. (cherry picked from FBD2532514)
This commit is contained in:
@@ -31,6 +31,22 @@ namespace llvm {
|
||||
|
||||
namespace flo {
|
||||
|
||||
BinaryBasicBlock *
|
||||
BinaryFunction::getBasicBlockContainingOffset(uint64_t Offset) {
|
||||
if (Offset > Size)
|
||||
return nullptr;
|
||||
|
||||
if (BasicBlocks.empty())
|
||||
return nullptr;
|
||||
|
||||
auto I = std::upper_bound(BasicBlocks.begin(),
|
||||
BasicBlocks.end(),
|
||||
BinaryBasicBlock(Offset));
|
||||
assert(I != BasicBlocks.begin() && "first basic block not at offset 0");
|
||||
|
||||
return &(*--I);
|
||||
}
|
||||
|
||||
void BinaryFunction::print(raw_ostream &OS, bool PrintInstructions) const {
|
||||
StringRef SectionName;
|
||||
Section.getName(SectionName);
|
||||
|
||||
@@ -263,22 +263,7 @@ public:
|
||||
|
||||
/// Return basic block that originally contained offset \p Offset
|
||||
/// from the function start.
|
||||
BinaryBasicBlock *getBasicBlockContainingOffset(uint64_t Offset) {
|
||||
if (Offset > Size)
|
||||
return nullptr;
|
||||
|
||||
if (BasicBlocks.empty())
|
||||
return nullptr;
|
||||
|
||||
auto I = std::lower_bound(BasicBlocks.begin(),
|
||||
BasicBlocks.end(),
|
||||
BinaryBasicBlock(Offset));
|
||||
|
||||
if (I == BasicBlocks.end())
|
||||
return &BasicBlocks.back();
|
||||
|
||||
return &(*I);
|
||||
}
|
||||
BinaryBasicBlock *getBasicBlockContainingOffset(uint64_t Offset);
|
||||
|
||||
/// Dump function information to debug output. If \p PrintInstructions
|
||||
/// is true - include instruction disassembly.
|
||||
|
||||
Reference in New Issue
Block a user