[llvm-commits] [poolalloc] r132029 - in /poolalloc/trunk: include/assistDS/TypeChecks.h lib/AssistDS/TypeChecks.cpp
Arushi Aggarwal
aggarwa4 at illinois.edu
Tue May 24 19:16:55 PDT 2011
Author: aggarwa4
Date: Tue May 24 21:16:55 2011
New Revision: 132029
URL: http://llvm.org/viewvc/llvm-project?rev=132029&view=rev
Log:
Clone var_arg functions if they do not have internal
linkage.
Modified:
poolalloc/trunk/include/assistDS/TypeChecks.h
poolalloc/trunk/lib/AssistDS/TypeChecks.cpp
Modified: poolalloc/trunk/include/assistDS/TypeChecks.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/TypeChecks.h?rev=132029&r1=132028&r2=132029&view=diff
==============================================================================
--- poolalloc/trunk/include/assistDS/TypeChecks.h (original)
+++ poolalloc/trunk/include/assistDS/TypeChecks.h Tue May 24 21:16:55 2011
@@ -60,6 +60,7 @@
bool visitByValFunction(Module &M, Function &F);
bool visitMain(Module &M, Function &F);
bool visitVarArgFunction(Module &M, Function &F);
+ bool visitInternalVarArgFunction(Module &M, Function &F);
bool visitLoadInst(Module &M, LoadInst &LI);
bool visitStoreInst(Module &M, StoreInst &SI);
bool visitAllocaInst(Module &M, AllocaInst &AI);
Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=132029&r1=132028&r2=132029&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Tue May 24 21:16:55 2011
@@ -147,10 +147,23 @@
TypeChecks::visitVarArgFunction(Module &M, Function &F) {
if(!F.isVarArg())
return false;
- if(!F.hasInternalLinkage())
- return false;
- // FIXME:handle external functions
+ if(F.hasInternalLinkage()) {
+ visitInternalVarArgFunction(M, F);
+ } else {
+ // create internal clone
+ Function *F_clone = CloneFunction(&F);
+ F_clone->setName(F.getNameStr() + "internal");
+ F.setLinkage(GlobalValue::InternalLinkage);
+ F.getParent()->getFunctionList().push_back(F_clone);
+ F.replaceAllUsesWith(F_clone);
+ visitInternalVarArgFunction(M, *F_clone);
+ }
+ return true;
+}
+
+bool
+TypeChecks::visitInternalVarArgFunction(Module &M, Function &F) {
// Modify the function to add a call to get the num of arguments
VAArgInst *VASize = NULL;
VAArgInst *VAMetaData = NULL;
@@ -178,11 +191,6 @@
assert(VASize && "Varargs function without a call to VAStart???");
// FIXME:handle external functions
- // For every va_arg instruction,
- // In a transformed function, we pass in the type metadata before the actual argument
- // Read metadata from va_list
- // And then add a compare in the runtime
-
// Modify function to add checks on every var_arg call to ensure that we
// are not accessing more arguments than we passed in.
@@ -303,6 +311,7 @@
F_clone->setName(F.getNameStr() + "internal");
F.setLinkage(GlobalValue::InternalLinkage);
F.getParent()->getFunctionList().push_back(F_clone);
+ F.replaceAllUsesWith(F_clone);
visitInternalFunction(M, *F_clone);
visitExternalFunction(M, F);
}
More information about the llvm-commits
mailing list