[llvm-commits] [Patch] GCDA Files for Coverage
Nick Lewycky
nlewycky at google.com
Thu Jul 28 13:37:56 PDT 2011
On 28 July 2011 01:46, Bill Wendling <wendling at apple.com> wrote:
> Hi,
>
> Attached is a patch that I'm concerned may cause breakage for some people.
> Darwin needs the "402" version of GCOV. I made this change for the .gcno
> file, but I failed to make it for the .gcda file. Unfortunately, it's a bit
> more involved than one would think. I will need to change the
> llvm_gcda_start_file() function in runtime/libprofile/GCDAProfiling.c, since
> that library gets called when running the program. But if I change the
> function's arguments, it would break current files that were built were
> built the olde waye.
>
> So, is this a problem? If so, then would it be okay to create a new
> function (llvm_gcda_start_file_402format or something) and use that?
>
I'm fine with requiring libprofile_rt to be version-locked with the
llvm+clang that generated it. Everybody statically links it, right? We only
build the .so version for utils/profile.pl to lli -load it.
NIck
>
> Comments?
>
> -bw
>
> Index: runtime/libprofile/GCDAProfiling.c
> ===================================================================
> --- runtime/libprofile/GCDAProfiling.c (revision 136325)
> +++ runtime/libprofile/GCDAProfiling.c (working copy)
> @@ -107,14 +107,17 @@
> * profiling enabled will emit to a different file. Only one file may be
> * started at a time.
> */
> -void llvm_gcda_start_file(const char *orig_filename) {
> +void llvm_gcda_start_file(const char *orig_filename, int use_402_format) {
> char *filename;
> filename = mangle_filename(orig_filename);
> recursive_mkdir(filename);
> output_file = fopen(filename, "wb");
>
> /* gcda file, version 404*, stamp LLVM. */
> - fwrite("adcg*404MVLL", 12, 1, output_file);
> + if (!use_402_format)
> + fwrite("adcg*404MVLL", 12, 1, output_file);
> + else
> + fwrite("adcg*204MVLL", 12, 1, output_file);
>
> #ifdef DEBUG_GCDAPROFILING
> printf("llvmgcda: [%s]\n", orig_filename);
> Index: lib/Transforms/Instrumentation/GCOVProfiling.cpp
> ===================================================================
> --- lib/Transforms/Instrumentation/GCOVProfiling.cpp (revision 136325)
> +++ lib/Transforms/Instrumentation/GCOVProfiling.cpp (working copy)
> @@ -571,8 +571,11 @@
> }
>
> Constant *GCOVProfiler::getStartFileFunc() {
> + Type *Args[] = {
> + Type::getInt8PtrTy(*Ctx), Type::getInt32Ty(*Ctx)
> + };
> FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx),
> - Type::getInt8PtrTy(*Ctx),
> false);
> + Args, false);
> return M->getOrInsertFunction("llvm_gcda_start_file", FTy);
> }
>
> @@ -645,8 +648,10 @@
> CUE = DIF.compile_unit_end(); CUI != CUE; ++CUI) {
> DICompileUnit compile_unit(*CUI);
> std::string FilenameGcda = mangleName(compile_unit, "gcda");
> - Builder.CreateCall(StartFile,
> - Builder.CreateGlobalStringPtr(FilenameGcda));
> + Builder.CreateCall2(StartFile,
> + Builder.CreateGlobalStringPtr(FilenameGcda),
> + ConstantInt::get(Type::getInt32Ty(*Ctx),
> Use402Format));
> +
> for (SmallVector<std::pair<GlobalVariable *, MDNode *>, 8>::iterator
> I = CountersBySP.begin(), E = CountersBySP.end();
> I != E; ++I) {
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110728/1f149ac6/attachment.html>
More information about the llvm-commits
mailing list