[llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp
Andrew Lenharth
alenhar2 at cs.uiuc.edu
Fri Apr 7 14:27:22 PDT 2006
Changes in directory llvm-poolalloc/lib/PoolAllocate:
PointerCompress.cpp updated: 1.68 -> 1.69
---
Log message:
some fixes and a crazy hack
---
Diffs of the changes: (+33 -4)
PointerCompress.cpp | 37 +++++++++++++++++++++++++++++++++----
1 files changed, 33 insertions(+), 4 deletions(-)
Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp
diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.68 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.69
--- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.68 Thu Feb 23 21:34:29 2006
+++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Fri Apr 7 16:27:10 2006
@@ -49,6 +49,10 @@
cl::opt<bool>
DisablePoolBaseASR("disable-ptrcomp-poolbase-aggregation",
cl::desc("Don't optimize pool base loads"));
+ cl::opt<bool>
+ ADLFix("adl-pc",
+ cl::desc("Enable Andrew's fixes/hacks"));
+
Statistic<> NumCompressed("pointercompress",
"Number of pools pointer compressed");
@@ -231,6 +235,13 @@
ComputeCompressedType(const Type *OrigTy, unsigned NodeOffset,
std::map<const DSNode*, CompressedPoolInfo> &Nodes) {
if (const PointerType *PTY = dyn_cast<PointerType>(OrigTy)) {
+ if (ADLFix) {
+ DSNode *PointeeNode = getNode()->getLink(NodeOffset).getNode();
+ if (PointeeNode == getNode())
+ return MEMUINTTYPE;
+ return OrigTy;
+ }
+
// Okay, we have a pointer. Check to see if the node pointed to is actually
// compressed!
//DSNode *PointeeNode = getNode()->getLink(NodeOffset).getNode();
@@ -927,7 +938,7 @@
// If this is one of the functions we know about, just materialize the
// compressed pointer as a real pointer, and pass it.
- if (Callee->getName() == "printf") {
+ if (Callee->getName() == "printf" || Callee->getName() == "sprintf") {
for (unsigned i = 1, e = CI.getNumOperands(); i != e; ++i)
if (isa<PointerType>(CI.getOperand(i)->getType()) &&
getPoolInfo(CI.getOperand(i)))
@@ -944,7 +955,20 @@
CI.setOperand(2, SrcPtr);
return;
}
- } else if (Callee->getName() == "llvm.memset") {
+ } else if (Callee->getName() == "fwrite") {
+ if (const CompressedPoolInfo *DestPI = getPoolInfo(CI.getOperand(1))) {
+ std::vector<Value*> Ops;
+ Ops.push_back(getTransformedValue(CI.getOperand(1)));
+ Value *BasePtr = DestPI->EmitPoolBaseLoad(CI);
+ Value *SrcPtr = new GetElementPtrInst(BasePtr, Ops,
+ CI.getOperand(1)->getName()+".pp", &CI);
+ SrcPtr = new CastInst(SrcPtr, CI.getOperand(1)->getType(), "", &CI);
+ CI.setOperand(1, SrcPtr);
+ return;
+ }
+ } else if (Callee->getName() == "llvm.memset" ||
+ Callee->getName() == "llvm.memset.i32" ||
+ Callee->getName() == "llvm.memset.i64") {
if (const CompressedPoolInfo *DestPI = getPoolInfo(CI.getOperand(1))) {
std::vector<Value*> Ops;
Ops.push_back(getTransformedValue(CI.getOperand(1)));
@@ -955,7 +979,9 @@
CI.setOperand(1, SrcPtr);
return;
}
- } else if (Callee->getName() == "llvm.memcpy") {
+ } else if (Callee->getName() == "llvm.memcpy" ||
+ Callee->getName() == "llvm.memcpy.i32" ||
+ Callee->getName() == "llvm.memcpy.i64") {
bool doret = false;
if (const CompressedPoolInfo *DestPI = getPoolInfo(CI.getOperand(1))) {
std::vector<Value*> Ops;
@@ -1022,7 +1048,10 @@
// Find the arguments we need to compress.
unsigned NumPoolArgs = FI ? FI->ArgNodes.size() : 0;
- for (unsigned i = 1, e = CI.getNumOperands(); i != e; ++i)
+ //only search non-vararg arguments
+ //FIXME: suspect hack to prevent crashing on user-defined vaarg functions
+ unsigned NumSearch = FI ? FI->F.arg_size() + 1: CI.getNumOperands();
+ for (unsigned i = 1, e = NumSearch; i != e; ++i)
if (isa<PointerType>(CI.getOperand(i)->getType()) && i > NumPoolArgs) {
Argument *FormalArg = next(FI->F.arg_begin(), i-1-NumPoolArgs);
More information about the llvm-commits
mailing list