[llvm-commits] [poolalloc] r132423 - in /poolalloc/trunk: include/assistDS/TypeChecks.h lib/AssistDS/TypeChecks.cpp
Arushi Aggarwal
aggarwa4 at illinois.edu
Wed Jun 1 14:29:59 PDT 2011
Author: aggarwa4
Date: Wed Jun 1 16:29:58 2011
New Revision: 132423
URL: http://llvm.org/viewvc/llvm-project?rev=132423&view=rev
Log:
1. Rename a few functions.
2. Recognize byval functions earlier.
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=132423&r1=132422&r2=132423&view=diff
==============================================================================
--- poolalloc/trunk/include/assistDS/TypeChecks.h (original)
+++ poolalloc/trunk/include/assistDS/TypeChecks.h Wed Jun 1 16:29:58 2011
@@ -61,8 +61,8 @@
bool visitInvokeInst(Module &M, InvokeInst &CI);
bool visitCallSite(Module &M, CallSite CS);
bool visitIndirectCallSite(Module &M, CallSite CS);
- bool visitInternalFunction(Module &M, Function &F);
- bool visitExternalFunction(Module &M, Function &F);
+ bool visitInternalByValFunction(Module &M, Function &F);
+ bool visitExternalByValFunction(Module &M, Function &F);
bool visitByValFunction(Module &M, Function &F);
bool visitMain(Module &M, Function &F);
bool visitVarArgFunction(Module &M, Function &F);
Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=132423&r1=132422&r2=132423&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Wed Jun 1 16:29:58 2011
@@ -107,9 +107,20 @@
continue;
std::string name = F.getName();
-
if (strncmp(name.c_str(), "tc.", 3) == 0) continue;
+ // check for byval arguments
+ bool hasByValArg = false;
+ for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I) {
+ if (I->hasByValAttr()) {
+ hasByValArg = true;
+ break;
+ }
+ }
+ if(hasByValArg) {
+ ByValFunctions.push_back(&F);
+ }
+
// Iterate and find all varargs functions
if(F.isVarArg()) {
VAArgFunctions.push_back(&F);
@@ -134,13 +145,11 @@
}
}
- std::vector<Function *> toProcess;
for (Module::iterator MI = M.begin(), ME = M.end(); MI != ME; ++MI) {
Function &F = *MI;
if(F.isDeclaration())
continue;
// record all the original functions in the program
- toProcess.push_back(&F);
// Loop over all of the instructions in the function,
// adding their return type as well as the types of their operands.
@@ -169,9 +178,9 @@
}
}
- while(!toProcess.empty()) {
- Function *F = toProcess.back();
- toProcess.pop_back();
+ while(!ByValFunctions.empty()) {
+ Function *F = ByValFunctions.back();
+ ByValFunctions.pop_back();
modified |= visitByValFunction(M, *F);
}
@@ -580,24 +589,6 @@
bool TypeChecks::visitByValFunction(Module &M, Function &F) {
- // check for byval arguments
- bool hasByValArg = false;
- for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I) {
- if (I->hasByValAttr()) {
- if(EnableTypeSafeOpt) {
- if(!TS->isTypeSafe(cast<Value>(&I), &F)) {
- hasByValArg = true;
- break;
- }
- } else {
- hasByValArg = true;
- break;
- }
- }
- }
- if(!hasByValArg)
- return false;
-
// For internal functions
// Replace with a cloned function with extra arguments
// That takes as argument the original pointers without a byval parameter too
@@ -610,7 +601,7 @@
// To assume that the metadata for the byval arguments is TOP
if(F.hasInternalLinkage()) {
- visitInternalFunction(M, F);
+ visitInternalByValFunction(M, F);
} else {
// create internal clone
Function *F_clone = CloneFunction(&F);
@@ -618,13 +609,13 @@
F.setLinkage(GlobalValue::InternalLinkage);
F.getParent()->getFunctionList().push_back(F_clone);
F.replaceAllUsesWith(F_clone);
- visitInternalFunction(M, *F_clone);
- visitExternalFunction(M, F);
+ visitInternalByValFunction(M, *F_clone);
+ visitExternalByValFunction(M, F);
}
return true;
}
-bool TypeChecks::visitInternalFunction(Module &M, Function &F) {
+bool TypeChecks::visitInternalByValFunction(Module &M, Function &F) {
// Create a list of the argument types in the new function.
std::vector<const Type*>TP;
@@ -777,7 +768,7 @@
return true;
}
-bool TypeChecks::visitExternalFunction(Module &M, Function &F) {
+bool TypeChecks::visitExternalByValFunction(Module &M, Function &F) {
// A list of the byval arguments that we are setting metadata for
typedef SmallVector<Value *, 4> RegisteredArgTy;
More information about the llvm-commits
mailing list