[llvm] r267908 - [PGO] Fix incorrect Twine usage in emitting optimization remarks.

Rong Xu via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 28 10:49:56 PDT 2016


Author: xur
Date: Thu Apr 28 12:49:56 2016
New Revision: 267908

URL: http://llvm.org/viewvc/llvm-project?rev=267908&view=rev
Log:
[PGO] Fix incorrect Twine usage in emitting optimization remarks.

Should not store Twine objects to local variables. This is fixed the test
failures with r267815 in VS2015 X64 build.

Modified:
    llvm/trunk/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp

Modified: llvm/trunk/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp?rev=267908&r1=267907&r2=267908&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp Thu Apr 28 12:49:56 2016
@@ -327,12 +327,11 @@ ICallPromotionFunc::getPromotionCandidat
       StringRef TargetFuncName = Symtab->getFuncName(Target);
       const char *Reason = StatusToString(Status);
       DEBUG(dbgs() << " Not promote: " << Reason << "\n");
-      Twine Msg =
+      emitOptimizationRemarkMissed(
+          F.getContext(), "PGOIndirectCallPromotion", F, Inst->getDebugLoc(),
           Twine("Cannot promote indirect call to ") +
-          (TargetFuncName.empty() ? Twine(Target) : Twine(TargetFuncName)) +
-          Twine(" with count of ") + Twine(Count) + ": " + Reason;
-      emitOptimizationRemarkMissed(F.getContext(), "PGOIndirectCallPromotion",
-                                   F, Inst->getDebugLoc(), Msg);
+              (TargetFuncName.empty() ? Twine(Target) : Twine(TargetFuncName)) +
+              Twine(" with count of ") + Twine(Count) + ": " + Reason);
       break;
     }
     Ret.push_back(PromotionCandidate(TargetFunction, Count));
@@ -603,10 +602,10 @@ void ICallPromotionFunc::promote(Instruc
   DEBUG(dbgs() << "\n== Basic Blocks After ==\n");
   DEBUG(dbgs() << *BB << *DirectCallBB << *IndirectCallBB << *MergeBB << "\n");
 
-  Twine Msg = Twine("Promote indirect call to ") + DirectCallee->getName() +
-              " with count " + Twine(Count) + " out of " + Twine(TotalCount);
-  emitOptimizationRemark(F.getContext(), "PGOIndirectCallPromotion", F,
-                         Inst->getDebugLoc(), Msg);
+  emitOptimizationRemark(
+      F.getContext(), "PGOIndirectCallPromotion", F, Inst->getDebugLoc(),
+      Twine("Promote indirect call to ") + DirectCallee->getName() +
+          " with count " + Twine(Count) + " out of " + Twine(TotalCount));
 }
 
 // Promote indirect-call to conditional direct-call for one callsite.




More information about the llvm-commits mailing list