[llvm-commits] [poolalloc] r128872 - /poolalloc/trunk/lib/AssistDS/ArgSimplify.cpp
Arushi Aggarwal
aggarwa4 at illinois.edu
Mon Apr 4 18:36:02 PDT 2011
Author: aggarwa4
Date: Mon Apr 4 20:36:02 2011
New Revision: 128872
URL: http://llvm.org/viewvc/llvm-project?rev=128872&view=rev
Log:
Handle cases where the Type to cast from is an integer.
Modified:
poolalloc/trunk/lib/AssistDS/ArgSimplify.cpp
Modified: poolalloc/trunk/lib/AssistDS/ArgSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/ArgSimplify.cpp?rev=128872&r1=128871&r2=128872&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/ArgSimplify.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/ArgSimplify.cpp Mon Apr 4 20:36:02 2011
@@ -93,14 +93,16 @@
Value *CastedVal;
BasicBlock* entryBB = BasicBlock::
Create (M->getContext(), "entry", NewF);
-
- if(type->isIntegerTy()){
- CastedVal = new PtrToIntInst(fargs.at(arg_count),
+
+ const Type *FromTy = fargs.at(arg_count)->getType();
+ if(FromTy->isPointerTy()) {
+ CastedVal = CastInst::CreatePointerCast(fargs.at(arg_count),
type, "castd", entryBB);
} else {
- CastedVal = new BitCastInst(fargs.at(arg_count),
- type, "castd", entryBB);
+ CastedVal = CastInst::CreateIntegerCast(fargs.at(arg_count),
+ type, false, "casted", entryBB);
}
+
SmallVector<Value*, 8> Args;
for(Function::arg_iterator ai = NewF->arg_begin(),
ae= NewF->arg_end(); ai != ae; ++ai) {
@@ -109,14 +111,14 @@
else
Args.push_back(ai);
}
-
+
CallInst * CallI = CallInst::Create(F,Args.begin(),
Args.end(),"", entryBB);
if(CallI->getType()->isVoidTy())
ReturnInst::Create(M->getContext(), entryBB);
else
ReturnInst::Create(M->getContext(), CallI, entryBB);
-
+
CI->setCalledFunction(NewF);
numTransformable++;
}
@@ -131,14 +133,14 @@
}
}
}
-
+
class ArgSimplify : public ModulePass {
public:
static char ID;
ArgSimplify() : ModulePass(&ID) {}
bool runOnModule(Module& M) {
-
+
for (Module::iterator I = M.begin(); I != M.end(); ++I)
if (!I->isDeclaration() && !I->mayBeOverridden()) {
if(I->getNameStr() == "main")
@@ -162,7 +164,7 @@
}
}
}
-
+
return true;
}
More information about the llvm-commits
mailing list