llvm.org GIT mirror llvm / 52b4edf
In GCC 4.7, function names are now forbidden from .gcda files. Support this by passing a null pointer to the function name in to GCDAProfiling, and add another switch onto GCOVProfiling. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176173 91177308-0d34-0410-b5e6-96231b3b80d8 Nick Lewycky 7 years ago
3 changed file(s) with 24 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
3333 ModulePass *createGCOVProfilerPass(bool EmitNotes = true, bool EmitData = true,
3434 bool Use402Format = false,
3535 bool UseExtraChecksum = false,
36 bool NoRedZone = false);
36 bool NoRedZone = false,
37 bool NoFunctionNamesInData = false);
3738
3839 // Insert AddressSanitizer (address sanity checking) instrumentation
3940 FunctionPass *createAddressSanitizerFunctionPass(
4444 static char ID;
4545 GCOVProfiler()
4646 : ModulePass(ID), EmitNotes(true), EmitData(true), Use402Format(false),
47 UseExtraChecksum(false), NoRedZone(false) {
47 UseExtraChecksum(false), NoRedZone(false),
48 NoFunctionNamesInData(false) {
4849 initializeGCOVProfilerPass(*PassRegistry::getPassRegistry());
4950 }
50 GCOVProfiler(bool EmitNotes, bool EmitData, bool use402Format,
51 bool useExtraChecksum, bool NoRedZone_)
51 GCOVProfiler(bool EmitNotes, bool EmitData, bool Use402Format,
52 bool UseExtraChecksum, bool NoRedZone,
53 bool NoFunctionNamesInData)
5254 : ModulePass(ID), EmitNotes(EmitNotes), EmitData(EmitData),
53 Use402Format(use402Format), UseExtraChecksum(useExtraChecksum),
54 NoRedZone(NoRedZone_) {
55 Use402Format(Use402Format), UseExtraChecksum(UseExtraChecksum),
56 NoRedZone(NoRedZone), NoFunctionNamesInData(NoFunctionNamesInData) {
5557 assert((EmitNotes || EmitData) && "GCOVProfiler asked to do nothing?");
5658 initializeGCOVProfilerPass(*PassRegistry::getPassRegistry());
5759 }
99101 bool Use402Format;
100102 bool UseExtraChecksum;
101103 bool NoRedZone;
104 bool NoFunctionNamesInData;
102105
103106 Module *M;
104107 LLVMContext *Ctx;
112115 ModulePass *llvm::createGCOVProfilerPass(bool EmitNotes, bool EmitData,
113116 bool Use402Format,
114117 bool UseExtraChecksum,
115 bool NoRedZone) {
118 bool NoRedZone,
119 bool NoFunctionNamesInData) {
116120 return new GCOVProfiler(EmitNotes, EmitData, Use402Format, UseExtraChecksum,
117 NoRedZone);
121 NoRedZone, NoFunctionNamesInData);
118122 }
119123
120124 namespace {
663667 intptr_t ident = reinterpret_cast(I->second);
664668 Builder.CreateCall2(EmitFunction,
665669 Builder.getInt32(ident),
666 Builder.CreateGlobalStringPtr(SP.getName()));
670 NoFunctionNamesInData ?
671 Constant::getNullValue(Builder.getInt8PtrTy()) :
672 Builder.CreateGlobalStringPtr(SP.getName()));
667673
668674 GlobalVariable *GV = I->first;
669675 unsigned Arcs =
161161
162162 void llvm_gcda_emit_function(uint32_t ident, const char *function_name) {
163163 #ifdef DEBUG_GCDAPROFILING
164 printf("llvmgcda: function id=%x\n", ident);
164 printf("llvmgcda: function id=%x name=%s\n", ident,
165 function_name ? function_name : "NULL");
165166 #endif
166167 if (!output_file) return;
167168
168169 /* function tag */
169170 fwrite("\0\0\0\1", 4, 1, output_file);
170 write_int32(3 + 1 + length_of_string(function_name));
171 uint32_t len = 3;
172 if (function_name)
173 len += 1 + length_of_string(function_name);
174 write_int32(len);
171175 write_int32(ident);
172176 write_int32(0);
173177 write_int32(0);
174 write_string(function_name);
178 if (function_name)
179 write_string(function_name);
175180 }
176181
177182 void llvm_gcda_emit_arcs(uint32_t num_counters, uint64_t *counters) {