Fix large functions debug info by default.

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)
This commit is contained in:
Maksim Panchenko 2016-05-31 19:29:34 -07:00
parent 4460da0d81
commit 6da0d95326
1 changed files with 10 additions and 3 deletions

View File

@ -125,9 +125,11 @@ UpdateDebugSections("update-debug-sections",
static cl::opt<bool> static cl::opt<bool>
FixDebugInfoLargeFunctions("fix-debuginfo-large-functions", FixDebugInfoLargeFunctions("fix-debuginfo-large-functions",
cl::init(true),
cl::desc("do another pass if we encounter large " cl::desc("do another pass if we encounter large "
"functions, to correct their debug info."), "functions, to correct their debug info."),
cl::Optional); cl::Optional,
cl::ReallyHidden);
static cl::opt<bool> static cl::opt<bool>
AlignBlocks("align-blocks", AlignBlocks("align-blocks",
@ -1306,6 +1308,7 @@ void RewriteInstance::emitFunctions() {
if (!Function.isSimple()) if (!Function.isSimple())
continue; continue;
auto TooLarge = false;
auto SMII = EFMM->SectionMapInfo.find(Function.getCodeSectionName()); auto SMII = EFMM->SectionMapInfo.find(Function.getCodeSectionName());
if (SMII != EFMM->SectionMapInfo.end()) { if (SMII != EFMM->SectionMapInfo.end()) {
DEBUG(dbgs() << "BOLT: mapping 0x" DEBUG(dbgs() << "BOLT: mapping 0x"
@ -1317,6 +1320,10 @@ void RewriteInstance::emitFunctions() {
Function.getAddress()); Function.getAddress());
Function.setImageAddress(SMII->second.AllocAddress); Function.setImageAddress(SMII->second.AllocAddress);
Function.setImageSize(SMII->second.Size); Function.setImageSize(SMII->second.Size);
if (Function.getImageSize() > Function.getMaxSize()) {
TooLarge = true;
FailedAddresses.emplace_back(Function.getAddress());
}
} else { } else {
errs() << "BOLT: cannot remap function " << Function.getName() << "\n"; errs() << "BOLT: cannot remap function " << Function.getName() << "\n";
FailedAddresses.emplace_back(Function.getAddress()); FailedAddresses.emplace_back(Function.getAddress());
@ -1340,10 +1347,10 @@ void RewriteInstance::emitFunctions() {
NextAvailableAddress); NextAvailableAddress);
Function.cold().setAddress(NextAvailableAddress); Function.cold().setAddress(NextAvailableAddress);
Function.cold().setImageAddress(SMII->second.AllocAddress); 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)); Function.cold().setFileOffset(getFileOffsetFor(NextAvailableAddress));
NextAvailableAddress += SMII->second.Size; NextAvailableAddress += Function.cold().getImageSize();
} else { } else {
errs() << "BOLT: cannot remap function " << Function.getName() << "\n"; errs() << "BOLT: cannot remap function " << Function.getName() << "\n";
FailedAddresses.emplace_back(Function.getAddress()); FailedAddresses.emplace_back(Function.getAddress());