[llvm-commits] [llvm] r162888 - /llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp

David Blaikie dblaikie at gmail.com
Wed Aug 29 23:16:36 PDT 2012


On Wed, Aug 29, 2012 at 6:32 PM, Bill Wendling <isanbard at gmail.com> wrote:
> Author: void
> Date: Wed Aug 29 20:32:31 2012
> New Revision: 162888
>
> URL: http://llvm.org/viewvc/llvm-project?rev=162888&view=rev
> Log:
> Pass by pointer and not std::string.

Any particular reason for a c-style string rather than a StringRef or
Twine? Looks like it's just being passed through to replace_extension
which takes a Twine so you could expose that same flexibility.

(Ramble: not sure how I feel about something like replace_extension
taking a Twine instead of a StringRef - it unconditionally evaluates
the Twine anyway so it's not winning the "possibly avoid creating this
string" benefit that (so far as I understand it) is the big win of
Twine. On the other hand it'd be annoying for clients of this API not
to be able to write simple string concatenation expressions, or pass
other Twines through. (& having Twines be implicitly convertible to
StringRefs is of course fraught with danger (works only for the life
of a full expression since the Twine would have to store the thing the
StringRef refers to) - or even implicitly convertible to std::string
or similar isn't ideal (inefficient if you use a Twine multiple times
in the body of a function - causing multiple repeated conversions)...
meh, not sure what the right answer is)

>
> Modified:
>     llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp
>
> Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=162888&r1=162887&r2=162888&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original)
> +++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Wed Aug 29 20:32:31 2012
> @@ -91,7 +91,7 @@
>      void insertCounterWriteout(ArrayRef<std::pair<GlobalVariable*, MDNode*> >);
>      void insertIndirectCounterIncrement();
>
> -    std::string mangleName(DICompileUnit CU, std::string NewStem);
> +    std::string mangleName(DICompileUnit CU, const char *NewStem);
>
>      bool EmitNotes;
>      bool EmitData;
> @@ -328,7 +328,7 @@
>    };
>  }
>
> -std::string GCOVProfiler::mangleName(DICompileUnit CU, std::string NewStem) {
> +std::string GCOVProfiler::mangleName(DICompileUnit CU, const char *NewStem) {
>    if (NamedMDNode *GCov = M->getNamedMetadata("llvm.gcov")) {
>      for (int i = 0, e = GCov->getNumOperands(); i != e; ++i) {
>        MDNode *N = GCov->getOperand(i);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list