diff --git a/include/llvm/Transforms/Instrumentation.h b/include/llvm/Transforms/Instrumentation.h index bedd6f18f33..6f594d76906 100644 --- a/include/llvm/Transforms/Instrumentation.h +++ b/include/llvm/Transforms/Instrumentation.h @@ -63,10 +63,6 @@ struct GCOVOptions { // gcc's gcov-io.h char Version[4]; - // Emit a "cfg checksum" that follows the "line number checksum" of a - // function. This affects both .gcno and .gcda files. - bool UseCfgChecksum; - // Add the 'noredzone' attribute to added runtime library calls. bool NoRedZone; diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 0df316e5cdf..cad1071df42 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -49,9 +49,9 @@ using namespace llvm; #define DEBUG_TYPE "insert-gcov-profiling" -static cl::opt -DefaultGCOVVersion("default-gcov-version", cl::init("402*"), cl::Hidden, - cl::ValueRequired); +static cl::opt DefaultGCOVVersion("default-gcov-version", + cl::init("407*"), cl::Hidden, + cl::ValueRequired); static cl::opt DefaultExitBlockBeforeBody("gcov-exit-block-before-body", cl::init(false), cl::Hidden); @@ -59,7 +59,6 @@ GCOVOptions GCOVOptions::getDefault() { GCOVOptions Options; Options.EmitNotes = true; Options.EmitData = true; - Options.UseCfgChecksum = false; Options.NoRedZone = false; Options.ExitBlockBeforeBody = DefaultExitBlockBeforeBody; @@ -747,9 +746,10 @@ void GCOVProfiler::emitProfileNotes() { ++It; EntryBlock.splitBasicBlock(It); - Funcs.push_back(std::make_unique(SP, &F, &out, FunctionIdent++, - Options.UseCfgChecksum, - Options.ExitBlockBeforeBody)); + bool UseCfgChecksum = strncmp(Options.Version, "407", 3) >= 0; + Funcs.push_back(std::make_unique( + SP, &F, &out, FunctionIdent++, UseCfgChecksum, + Options.ExitBlockBeforeBody)); GCOVFunction &Func = *Funcs.back(); // Add the function line number to the lines of the entry block @@ -945,16 +945,14 @@ FunctionCallee GCOVProfiler::getEmitFunctionFunc(const TargetLibraryInfo *TLI) { Type *Args[] = { Type::getInt32Ty(*Ctx), // uint32_t ident Type::getInt32Ty(*Ctx), // uint32_t func_checksum - Type::getInt8Ty(*Ctx), // uint8_t use_extra_checksum Type::getInt32Ty(*Ctx), // uint32_t cfg_checksum }; FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), Args, false); AttributeList AL; if (auto AK = TLI->getExtAttrForI32Param(false)) { AL = AL.addParamAttribute(*Ctx, 0, AK); + AL = AL.addParamAttribute(*Ctx, 1, AK); AL = AL.addParamAttribute(*Ctx, 2, AK); - AL = AL.addParamAttribute(*Ctx, 3, AK); - AL = AL.addParamAttribute(*Ctx, 4, AK); } return M->getOrInsertFunction("llvm_gcda_emit_function", FTy); } @@ -1014,9 +1012,8 @@ Function *GCOVProfiler::insertCounterWriteout( // walk to write out everything. StructType *StartFileCallArgsTy = StructType::create( {Builder.getInt8PtrTy(), Builder.getInt8PtrTy(), Builder.getInt32Ty()}); - StructType *EmitFunctionCallArgsTy = - StructType::create({Builder.getInt32Ty(), Builder.getInt32Ty(), - Builder.getInt8Ty(), Builder.getInt32Ty()}); + StructType *EmitFunctionCallArgsTy = StructType::create( + {Builder.getInt32Ty(), Builder.getInt32Ty(), Builder.getInt32Ty()}); StructType *EmitArcsCallArgsTy = StructType::create( {Builder.getInt32Ty(), Builder.getInt64Ty()->getPointerTo()}); StructType *FileInfoTy = @@ -1051,7 +1048,6 @@ Function *GCOVProfiler::insertCounterWriteout( EmitFunctionCallArgsTy, {Builder.getInt32(j), Builder.getInt32(FuncChecksum), - Builder.getInt8(Options.UseCfgChecksum), Builder.getInt32(CfgChecksum)})); GlobalVariable *GV = CountersBySP[j].first; @@ -1179,17 +1175,13 @@ Function *GCOVProfiler::insertCounterWriteout( Builder.CreateStructGEP(EmitFunctionCallArgsTy, EmitFunctionCallArgsPtr, 1)), Builder.CreateLoad(EmitFunctionCallArgsTy->getElementType(2), - Builder.CreateStructGEP(EmitFunctionCallArgsTy, - EmitFunctionCallArgsPtr, 2)), - Builder.CreateLoad(EmitFunctionCallArgsTy->getElementType(3), Builder.CreateStructGEP(EmitFunctionCallArgsTy, EmitFunctionCallArgsPtr, - 3))}); + 2))}); if (auto AK = TLI->getExtAttrForI32Param(false)) { EmitFunctionCall->addParamAttr(0, AK); EmitFunctionCall->addParamAttr(1, AK); EmitFunctionCall->addParamAttr(2, AK); - EmitFunctionCall->addParamAttr(3, AK); } auto *EmitArcsCallArgsPtr = Builder.CreateInBoundsGEP(EmitArcsCallArgsTy, EmitArcsCallArgsArray, JV); diff --git a/test/Transforms/GCOVProfiling/function-numbering.ll b/test/Transforms/GCOVProfiling/function-numbering.ll index dfaacc8d772..973b29f590c 100644 --- a/test/Transforms/GCOVProfiling/function-numbering.ll +++ b/test/Transforms/GCOVProfiling/function-numbering.ll @@ -52,13 +52,10 @@ target triple = "x86_64-apple-macosx10.10.0" ; GCDA-NEXT: %[[EMIT_FUN_ARG_1_PTR:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[EMIT_FUN_ARGS]], i32 0, i32 1 ; GCDA-NEXT: %[[EMIT_FUN_ARG_1:.*]] = load i32, i32* %[[EMIT_FUN_ARG_1_PTR]] ; GCDA-NEXT: %[[EMIT_FUN_ARG_2_PTR:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[EMIT_FUN_ARGS]], i32 0, i32 2 -; GCDA-NEXT: %[[EMIT_FUN_ARG_2:.*]] = load i8, i8* %[[EMIT_FUN_ARG_2_PTR]] -; GCDA-NEXT: %[[EMIT_FUN_ARG_3_PTR:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[EMIT_FUN_ARGS]], i32 0, i32 3 -; GCDA-NEXT: %[[EMIT_FUN_ARG_3:.*]] = load i32, i32* %[[EMIT_FUN_ARG_3_PTR]] +; GCDA-NEXT: %[[EMIT_FUN_ARG_2:.*]] = load i32, i32* %[[EMIT_FUN_ARG_2_PTR]] ; GCDA-NEXT: call void @llvm_gcda_emit_function(i32 %[[EMIT_FUN_ARG_0]], ; GCDA-SAME: i32 %[[EMIT_FUN_ARG_1]], -; GCDA-SAME: i8 %[[EMIT_FUN_ARG_2]], -; GCDA-SAME: i32 %[[EMIT_FUN_ARG_3]]) +; GCDA-SAME: i32 %[[EMIT_FUN_ARG_2]]) ; GCDA-NEXT: %[[EMIT_ARCS_ARGS:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[EMIT_ARCS_ARGS_ARRAY]], i32 %[[JV]] ; GCDA-NEXT: %[[EMIT_ARCS_ARG_0_PTR:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[EMIT_ARCS_ARGS]], i32 0, i32 0 ; GCDA-NEXT: %[[EMIT_ARCS_ARG_0:.*]] = load i32, i32* %[[EMIT_ARCS_ARG_0_PTR]] diff --git a/test/Transforms/GCOVProfiling/version.ll b/test/Transforms/GCOVProfiling/version.ll index c72b64260ff..c1358039b1f 100644 --- a/test/Transforms/GCOVProfiling/version.ll +++ b/test/Transforms/GCOVProfiling/version.ll @@ -2,19 +2,19 @@ ; RUN: echo '!9 = !{!"%/t/version.ll", !0}' > %t/1 ; RUN: cat %s %t/1 > %t/2 ; RUN: opt -insert-gcov-profiling -disable-output < %t/2 -; RUN: head -c8 %t/version.gcno | grep '^oncg.204' +; RUN: head -c8 %t/version.gcno | grep '^oncg.704' ; RUN: rm %t/version.gcno ; RUN: not --crash opt -insert-gcov-profiling -default-gcov-version=asdfasdf -disable-output < %t/2 -; RUN: opt -insert-gcov-profiling -default-gcov-version=407* -disable-output < %t/2 -; RUN: head -c8 %t/version.gcno | grep '^oncg.704' +; RUN: opt -insert-gcov-profiling -default-gcov-version='402*' -disable-output < %t/2 +; RUN: head -c8 %t/version.gcno | grep '^oncg.204' ; RUN: rm %t/version.gcno ; RUN: opt -passes=insert-gcov-profiling -disable-output < %t/2 -; RUN: head -c8 %t/version.gcno | grep '^oncg.204' +; RUN: head -c8 %t/version.gcno | grep '^oncg.704' ; RUN: rm %t/version.gcno ; RUN: not --crash opt -passes=insert-gcov-profiling -default-gcov-version=asdfasdf -disable-output < %t/2 -; RUN: opt -passes=insert-gcov-profiling -default-gcov-version=407* -disable-output < %t/2 -; RUN: head -c8 %t/version.gcno | grep '^oncg.704' +; RUN: opt -passes=insert-gcov-profiling -default-gcov-version='402*' -disable-output < %t/2 +; RUN: head -c8 %t/version.gcno | grep '^oncg.204' ; RUN: rm %t/version.gcno define void @test() !dbg !5 {