[cfe-commits] r149973 - /cfe/trunk/lib/CodeGen/BackendUtil.cpp

David Blaikie dblaikie at gmail.com
Tue Feb 7 10:22:22 PST 2012


On Tue, Feb 7, 2012 at 1:05 AM, Bill Wendling <isanbard at gmail.com> wrote:
> Author: void
> Date: Tue Feb  7 03:05:34 2012
> New Revision: 149973
>
> URL: http://llvm.org/viewvc/llvm-project?rev=149973&view=rev
> Log:
> Reserve a moderate amount of space for the back-end arguments.
>
> Modified:
>    cfe/trunk/lib/CodeGen/BackendUtil.cpp
>
> Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=149973&r1=149972&r2=149973&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
> +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue Feb  7 03:05:34 2012
> @@ -247,6 +247,7 @@
>   }
>
>   std::vector<const char *> BackendArgs;
> +  BackendArgs.reserve(16);

Would a SmallVector be a better fit, then? (see attached patches - I
also went down a small rabbit hole when I discovered that
ParseCommandLineOptions couldn't be passed a buffer of const char*s -
by fixing the const down in LLVM's command line support I was able to
enable this & remove a few const_casts from clang's various drivers
too. (another thing to do down there might be to change CommandLine's
internal buffering to SmallVector rather than std::vector (see newArgv
in CommandLine.cpp:479 - though I only discovered this when I realized
I couldn't change line 486 to use data() because vector::data()
doesn't exist in C++98))

>   BackendArgs.push_back("clang"); // Fake program name.
>   if (!CodeGenOpts.DebugPass.empty()) {
>     BackendArgs.push_back("-debug-pass");
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cl_const.diff
Type: text/x-patch
Size: 2462 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120207/60dc4a2d/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cl_const_clang.diff
Type: text/x-patch
Size: 2735 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120207/60dc4a2d/attachment-0001.bin>


More information about the cfe-commits mailing list