Fix use-after-free. Thanks ASAN for giving me a detailed report :-).
authorDaniel Jasper <djasper@google.com>
Thu, 29 Oct 2015 12:49:37 +0000 (12:49 +0000)
committerDaniel Jasper <djasper@google.com>
Thu, 29 Oct 2015 12:49:37 +0000 (12:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251623 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/SampleProfile.cpp

index 47250cccc4d4d5d58e1c7f1dca9373bef1c08c6e..51e95a5887a27e292aad45fb246ab19c6ddb515f 100644 (file)
@@ -380,9 +380,9 @@ bool SampleProfileLoader::computeBlockWeights(Function &F) {
   if (SampleProfileCoverage) {
     unsigned Coverage = CoverageTracker.computeCoverage(Samples);
     if (Coverage < SampleProfileCoverage) {
-      const char *Filename = getDISubprogram(&F)->getFilename().str().c_str();
+      StringRef Filename = getDISubprogram(&F)->getFilename();
       F.getContext().diagnose(DiagnosticInfoSampleProfile(
-          Filename, getFunctionLoc(F),
+          Filename.str().c_str(), getFunctionLoc(F),
           Twine(CoverageTracker.getNumUsedSamples(Samples)) + " of " +
               Twine(Samples->getBodySamples().size()) +
               " available profile records (" + Twine(Coverage) +