diff options
| author | Mircea Trofin <mtrofin@google.com> | 2018-12-13 19:40:59 +0000 |
|---|---|---|
| committer | Mircea Trofin <mtrofin@google.com> | 2018-12-13 19:40:59 +0000 |
| commit | 41c729e78ec61f47c9b44978a58b23120347d18f (patch) | |
| tree | 747ea86232f6cfed8117fc71dcb89a589d9cf627 /llvm/lib | |
| parent | 4888c4aba5a1eaca0f0b9f4ec2ab7008c2fc103b (diff) | |
| download | bcm5719-llvm-41c729e78ec61f47c9b44978a58b23120347d18f.tar.gz bcm5719-llvm-41c729e78ec61f47c9b44978a58b23120347d18f.zip | |
[llvm] Address base discriminator overflow in X86DiscriminateMemOps
Summary:
Macros are expanded on a single line. In case of large expansions,
with sufficiently many instructions with memory operands (and when
-fdebug-info-for-profiling is requested), we may be unable to generate
new base discriminator values - new values overflow (base
discriminators may not be larger than 2^12).
This CL warns instead of asserting in such a case. A subsequent CL
will add APIs to check for overflow before creating new debug info.
See https://bugs.llvm.org/show_bug.cgi?id=39890
Reviewers: davidxl, wmi, gbedwell
Reviewed By: davidxl
Subscribers: aprantl, llvm-commits
Differential Revision: https://reviews.llvm.org/D55643
llvm-svn: 349075
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/X86/X86DiscriminateMemOps.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/Target/X86/X86DiscriminateMemOps.cpp b/llvm/lib/Target/X86/X86DiscriminateMemOps.cpp index 4ab32ab53e5..5653babedf8 100644 --- a/llvm/lib/Target/X86/X86DiscriminateMemOps.cpp +++ b/llvm/lib/Target/X86/X86DiscriminateMemOps.cpp @@ -24,6 +24,8 @@ #include "llvm/Transforms/IPO/SampleProfile.h" using namespace llvm; +#define DEBUG_TYPE "x86-discriminate-memops" + namespace { using Location = std::pair<StringRef, unsigned>; @@ -114,9 +116,18 @@ bool X86DiscriminateMemOps::runOnMachineFunction(MachineFunction &MF) { Changed = true; const std::pair<DenseSet<unsigned>::iterator, bool> MustInsert = Set.insert(DI->getBaseDiscriminator()); - (void)MustInsert; // silence warning. - assert(MustInsert.second && - "New discriminator shouldn't be present in set"); + // FIXME (mtrofin): check if the to-be inserted base discriminator can + // be added. This requires a new API on DILocation. + // The assumption is that this scenario is infrequent/OK not to support. + // If evidence points otherwise, we can explore synthesize unique DIs by + // adding fake line numbers. + if (!MustInsert.second) { + LLVM_DEBUG(dbgs() + << "Unable to create a unique discriminator in " + << DI->getFilename() << " Line: " << DI->getLine() + << " Column: " << DI->getColumn() + << ". This is likely due to a large macro expansion.\n"); + } } // Bump the reference DI to avoid cramming discriminators on line 0. |

