Skip to content

Commit

Permalink
Fix large functions debug info by default.
Browse files Browse the repository at this point in the history
Summary:
Turn on -fix-debuginfo-large-functions by default.

In the process of testing I've discovered that we output cold code
for functions that were too large to be emitted. Fixed that.

(cherry picked from FBD3372697)
  • Loading branch information
maksfb committed Jun 1, 2016
1 parent 4460da0 commit 6da0d95
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions bolt/RewriteInstance.cpp
Expand Up @@ -125,9 +125,11 @@ UpdateDebugSections("update-debug-sections",

static cl::opt<bool>
FixDebugInfoLargeFunctions("fix-debuginfo-large-functions",
cl::init(true),
cl::desc("do another pass if we encounter large "
"functions, to correct their debug info."),
cl::Optional);
cl::Optional,
cl::ReallyHidden);

static cl::opt<bool>
AlignBlocks("align-blocks",
Expand Down Expand Up @@ -1306,6 +1308,7 @@ void RewriteInstance::emitFunctions() {
if (!Function.isSimple())
continue;

auto TooLarge = false;
auto SMII = EFMM->SectionMapInfo.find(Function.getCodeSectionName());
if (SMII != EFMM->SectionMapInfo.end()) {
DEBUG(dbgs() << "BOLT: mapping 0x"
Expand All @@ -1317,6 +1320,10 @@ void RewriteInstance::emitFunctions() {
Function.getAddress());
Function.setImageAddress(SMII->second.AllocAddress);
Function.setImageSize(SMII->second.Size);
if (Function.getImageSize() > Function.getMaxSize()) {
TooLarge = true;
FailedAddresses.emplace_back(Function.getAddress());
}
} else {
errs() << "BOLT: cannot remap function " << Function.getName() << "\n";
FailedAddresses.emplace_back(Function.getAddress());
Expand All @@ -1340,10 +1347,10 @@ void RewriteInstance::emitFunctions() {
NextAvailableAddress);
Function.cold().setAddress(NextAvailableAddress);
Function.cold().setImageAddress(SMII->second.AllocAddress);
Function.cold().setImageSize(SMII->second.Size);
Function.cold().setImageSize(TooLarge ? 0 : SMII->second.Size);
Function.cold().setFileOffset(getFileOffsetFor(NextAvailableAddress));

NextAvailableAddress += SMII->second.Size;
NextAvailableAddress += Function.cold().getImageSize();
} else {
errs() << "BOLT: cannot remap function " << Function.getName() << "\n";
FailedAddresses.emplace_back(Function.getAddress());
Expand Down

0 comments on commit 6da0d95

Please sign in to comment.