Added the #(internal functions) to output
authorAnand Shukla <ashukla@cs.uiuc.edu>
Sun, 1 Jun 2003 02:40:49 +0000 (02:40 +0000)
committerAnand Shukla <ashukla@cs.uiuc.edu>
Sun, 1 Jun 2003 02:40:49 +0000 (02:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6502 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Instrumentation/EmitFunctions.cpp

index c9b8748cca3c3f3024d15370283ff74e41a81b94..ed3b63e81fc8373df17e05643e0ac9017b2a9cef 100644 (file)
@@ -21,10 +21,12 @@ namespace {
 bool EmitFunctionTable::run(Module &M){
   std::vector<const Type*> vType;
   std::vector<Constant *> vConsts;
+  unsigned char counter = 0;
   for(Module::iterator MI = M.begin(), ME = M.end(); MI != ME; ++MI)
     if (!MI->isExternal()) {
       vType.push_back(MI->getType());
       vConsts.push_back(ConstantPointerRef::get(MI));
+      counter++;
     }
   
   StructType *sttype = StructType::get(vType);
@@ -34,5 +36,11 @@ bool EmitFunctionTable::run(Module &M){
                                           GlobalValue::ExternalLinkage, 
                                           cstruct, "llvmFunctionTable");
   M.getGlobalList().push_back(gb);
+
+  ConstantInt *cnst = ConstantInt::get(Type::IntTy, counter); 
+  GlobalVariable *fnCount = new GlobalVariable(Type::IntTy, true, 
+                                              GlobalValue::ExternalLinkage, 
+                                              cnst, "llvmFunctionCount");
+  M.getGlobalList().push_back(fnCount);
   return true;  // Always modifies program
 }