[llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PoolAllocate.h
Changes in directory llvm-poolalloc/lib/PoolAllocate: PoolAllocate.h updated: 1.47 - 1.48 --- Log message: Extra book keeping for SAFECode --- Diffs of the changes: (+35 -4) PoolAllocate.h | 39 +++ 1 files changed, 35 insertions(+), 4 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/PoolAllocate.h diff -u llvm-poolalloc/lib/PoolAllocate/PoolAllocate.h:1.47 llvm-poolalloc/lib/PoolAllocate/PoolAllocate.h:1.48 --- llvm-poolalloc/lib/PoolAllocate/PoolAllocate.h:1.47 Wed May 18 14:56:28 2005 +++ llvm-poolalloc/lib/PoolAllocate/PoolAllocate.h Thu Dec 22 10:32:21 2005 @@ -16,17 +16,28 @@ #ifndef POOLALLOCATE_H #define POOLALLOCATE_H - +//#define SAFECODE 1 +//#define BOUNDS_CHECK 1 +//comment the above two for normal poolallocation #include llvm/Pass.h #include llvm/DerivedTypes.h #include llvm/Support/CallSite.h #include llvm/ADT/EquivalenceClasses.h #include llvm/ADT/VectorExtras.h #include llvm/ADT/hash_set + +#ifdef SAFECODE +//FIXME : make this use some configuration options +#include /home/vadve/dhurjati/llvm/projects/safecode.typesafe/include/ConvertUnsafeAllocas.h +#endif + + #include set namespace llvm { - +#ifdef SAFECODE + using namespace CUA; +#endif class DSNode; class DSGraph; class Type; @@ -73,6 +84,12 @@ /// function. std::mapconst DSNode*, Value* PoolDescriptors; +#ifdef SAFECODE +//This is a map from Old to New Value Map reverse of the one above +//Useful in SAFECode for check insertion +std::mapconst Value*, Value* ValueMap; +#endif + /// NewToOldValueMap - When and if a function needs to be cloned, this map /// contains a mapping from all of the values in the new function back to /// the values they correspond to in the old function. @@ -105,13 +122,23 @@ Module *CurModule; EquivClassGraphs *ECGraphs; - + std::mapFunction*, PA::FuncInfo FunctionInfo; std::mapFunction*, Function* CloneToOrigMap; public: +#ifdef SAFECODE + ConvertUnsafeAllocas *CUAPass; +#endif Function *PoolInit, *PoolDestroy, *PoolAlloc, *PoolRealloc, *PoolMemAlign; Function *PoolFree; +#ifdef SAFECODE + Function *PoolRegister; +#endif +#ifdef BOUNDS_CHECK + Function *PoolRegister; +#endif + static const Type *PoolDescPtrTy; PA::Heuristic *CurHeuristic; @@ -122,9 +149,13 @@ std::mapconst DSNode*, Value* GlobalNodes; public: +#ifdef SAFECODE + PoolAllocate(bool passAllArguments = true) +: PassAllArguments(passAllArguments) {} +#else PoolAllocate(bool passAllArguments = false) : PassAllArguments(passAllArguments) {} - +#endif bool runOnModule(Module M); virtual void getAnalysisUsage(AnalysisUsage AU) const; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm-poolalloc/runtime/SafePoolAllocator/
Changes in directory llvm-poolalloc/runtime/SafePoolAllocator: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm-poolalloc/runtime/SafePoolAllocator added to the repository --- Diffs of the changes: (+0 -0) 0 files changed ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp
Changes in directory llvm-poolalloc/lib/PoolAllocate: PoolAllocate.cpp updated: 1.120 - 1.121 --- Log message: Extra book keeping for SAFECode --- Diffs of the changes: (+58 -6) PoolAllocate.cpp | 64 +-- 1 files changed, 58 insertions(+), 6 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.120 llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.121 --- llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.120 Wed May 18 14:56:28 2005 +++ llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cppThu Dec 22 10:32:54 2005 @@ -34,6 +34,9 @@ #include llvm/Support/Timer.h using namespace llvm; using namespace PA; +#ifdef SAFECODE +using namespace CUA; +#endif const Type *PoolAllocate::PoolDescPtrTy = 0; @@ -73,13 +76,27 @@ } void PoolAllocate::getAnalysisUsage(AnalysisUsage AU) const { +#ifdef SAFECODE + AU.addRequiredConvertUnsafeAllocas(); +#endif AU.addRequiredEquivClassGraphs(); AU.addPreservedEquivClassGraphs(); +#ifdef SAFECODE + //Dinakar for preserving the pool information across passes + AU.setPreservesAll(); +#endif +#ifdef BOUNDS_CHECK + //Dinakar hack for preserving the pool information across passes + AU.setPreservesAll(); +#endif AU.addRequiredTargetData(); } bool PoolAllocate::runOnModule(Module M) { if (M.begin() == M.end()) return false; +#ifdef SAFECODE + CUAPass = getAnalysisConvertUnsafeAllocas(); +#endif CurModule = M; ECGraphs = getAnalysisEquivClassGraphs(); // folded inlined CBU graphs @@ -149,7 +166,11 @@ if (VoidPtrTy == 0) { // NOTE: If these are changed, make sure to update PoolOptimize.cpp as well! VoidPtrTy = PointerType::get(Type::SByteTy); +#ifdef SAFECODE +PoolDescType = ArrayType::get(VoidPtrTy, 50); +#else PoolDescType = ArrayType::get(VoidPtrTy, 16); +#endif PoolDescPtrTy = PointerType::get(PoolDescType); } @@ -180,7 +201,16 @@ // Get the poolfree function. PoolFree = CurModule-getOrInsertFunction(poolfree, Type::VoidTy, -PoolDescPtrTy, VoidPtrTy, 0); +PoolDescPtrTy, VoidPtrTy, 0); +#ifdef SAFECODE + //Get the poolregister function + PoolRegister = CurModule-getOrInsertFunction(poolregister, Type::VoidTy, + PoolDescPtrTy, Type::UIntTy, VoidPtrTy, 0); +#endif +#ifdef BOUNDS_CHECK + PoolRegister = CurModule-getOrInsertFunction(poolregister, Type::VoidTy, + PoolDescPtrTy, VoidPtrTy, Type::UIntTy, 0); +#endif } static void getCallsOf(Function *F, std::vectorCallInst* Calls) { @@ -270,7 +300,7 @@ for (hash_setconst DSNode*::iterator I = MarkedNodes.begin(), E = MarkedNodes.end(); I != E; ) { const DSNode *N = *I++; -if ((!N-isHeapNode() !PassAllArguments) || NodesFromGlobals.count(N)) +if ((!(1 || N-isHeapNode()) !PassAllArguments) || NodesFromGlobals.count(N)) MarkedNodes.erase(N); } } @@ -343,7 +373,11 @@ // Map the existing arguments of the old function to the corresponding // arguments of the new function, and copy over the names. +#ifdef SAFECODE + std::mapconst Value*, Value* ValueMap = FI.ValueMap; +#else std::mapconst Value*, Value* ValueMap; +#endif for (Function::arg_iterator I = F.arg_begin(); NI != New-arg_end(); ++I, ++NI) { ValueMap[I] = NI; @@ -387,7 +421,15 @@ for (hash_setconst DSNode*::iterator I = GlobalHeapNodes.begin(), E = GlobalHeapNodes.end(); I != E; ) { hash_setconst DSNode*::iterator Last = I++; -if (!(*Last)-isHeapNode()) +#ifndef SAFECODE +#ifndef BOUNDS_CHECK +//if (!(*Last)-isHeapNode()); +// GlobalHeapNodes.erase(Last); +#endif +#endif +const DSNode *tmp = *Last; +//std::cerr test \n; +if (!(tmp-isHeapNode() || tmp-isArray())) GlobalHeapNodes.erase(Last); } @@ -409,8 +451,11 @@ CurHeuristic-AssignToPools(NodesToPA, 0, GG, ResultPools); BasicBlock::iterator InsertPt = MainFunc-getEntryBlock().begin(); +#ifndef SAFECODE +#ifndef BOUNDS_CHECK while (isaAllocaInst(InsertPt)) ++InsertPt; - +#endif +#endif // Perform all global assignments as specified. for (unsigned i = 0, e = ResultPools.size(); i != e; ++i) { Heuristic::OnePool Pool = ResultPools[i]; @@ -490,8 +535,11 @@ std::setconst DSNode* UnallocatedNodes(NodesToPA.begin(), NodesToPA.end()); BasicBlock::iterator InsertPoint = F.front().begin(); +#ifndef SAFECODE +#ifndef BOUNDS_CHECK while (isaAllocaInst(InsertPoint)) ++InsertPoint; - +#endif +#endif // Is this main? If so, make the pool descriptors globals, not automatic // vars. bool IsMain = F.getName() == main F.hasExternalLinkage(); @@ -562,7 +610,11 @@ for (DSGraph::node_iterator I = G.node_begin(), E = G.node_end(); I != E;++I){
[llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp
Changes in directory llvm-poolalloc/lib/PoolAllocate: TransformFunctionBody.cpp updated: 1.47 - 1.48 --- Log message: Changes for SAFECode --- Diffs of the changes: (+75 -4) TransformFunctionBody.cpp | 79 +++--- 1 files changed, 75 insertions(+), 4 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp diff -u llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.47 llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.48 --- llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.47 Tue Dec 6 12:06:43 2005 +++ llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp Thu Dec 22 10:33:29 2005 @@ -60,6 +60,7 @@ void visitInstruction(Instruction I); void visitMallocInst(MallocInst MI); +void visitAllocaInst(AllocaInst MI); void visitCallocCall(CallSite CS); void visitReallocCall(CallSite CS); void visitMemAlignCall(CallSite CS); @@ -149,6 +150,7 @@ // Insert a call to poolalloc Value *PH = getPoolHandle(I); + Instruction *V = new CallInst(PAInfo.PoolAlloc, make_vector(PH, Size, 0), Name, I); @@ -187,6 +189,7 @@ void FuncTransform::visitMallocInst(MallocInst MI) { // Get the pool handle for the node that this contributes to... Value *PH = getPoolHandle(MI); + if (PH == 0 || isaConstantPointerNull(PH)) return; TargetData TD = PAInfo.getAnalysisTargetData(); @@ -196,8 +199,57 @@ if (MI.isArrayAllocation()) AllocSize = BinaryOperator::create(Instruction::Mul, AllocSize, MI.getOperand(0), sizetmp, MI); +#ifdef SAFECODE + const MallocInst *originalMalloc = MI; + if (FI.NewToOldValueMap.count(MI)) { +originalMalloc = castMallocInst(FI.NewToOldValueMap[MI]); + } + //Dinakar to test stack safety array safety + if (PAInfo.CUAPass-ArrayMallocs.find(originalMalloc) == + PAInfo.CUAPass-ArrayMallocs.end()) { +TransformAllocationInstr(MI, AllocSize); + } else { +AllocaInst *AI = new AllocaInst(MI.getType()-getElementType(), MI.getArraySize(), MI.getName(), MI.getNext()); +MI.replaceAllUsesWith(AI); +MI.getParent()-getInstList().erase(MI); +Value *Casted = AI; +Instruction *aiNext = AI-getNext(); +if (AI-getType() != PointerType::get(Type::SByteTy)) + Casted = new CastInst(AI, PointerType::get(Type::SByteTy), + AI-getName()+.casted,aiNext); + +Instruction *V = new CallInst(PAInfo.PoolRegister, + make_vector(PH, AllocSize, Casted, 0), , aiNext); +AddPoolUse(*V, PH, PoolUses); + } +#else + TransformAllocationInstr(MI, AllocSize); +#endif +} - TransformAllocationInstr(MI, AllocSize); +void FuncTransform::visitAllocaInst(AllocaInst MI) { +#ifdef BOUNDS_CHECK + // Get the pool handle for the node that this contributes to... + DSNode *Node = getDSNodeHFor(MI).getNode(); + if (Node-isArray()) { +Value *PH = getPoolHandle(MI); +if (PH == 0 || isaConstantPointerNull(PH)) return; +TargetData TD = PAInfo.getAnalysisTargetData(); +Value *AllocSize = + ConstantUInt::get(Type::UIntTy, TD.getTypeSize(MI.getAllocatedType())); + +if (MI.isArrayAllocation()) + AllocSize = BinaryOperator::create(Instruction::Mul, AllocSize, +MI.getOperand(0), sizetmp, MI); + +// TransformAllocationInstr(MI, AllocSize); +Instruction *Casted = new CastInst(MI, PointerType::get(Type::SByteTy), + MI.getName()+.casted, MI.getNext()); +Instruction *V = new CallInst(PAInfo.PoolRegister, + make_vector(PH, Casted, AllocSize, 0), , Casted-getNext()); +AddPoolUse(*V, PH, PoolUses); + } +#endif } @@ -536,10 +588,29 @@ if (DSNode *LocalNode = NodeMapping[ArgNodes[i]].getNode()) if (FI.PoolDescriptors.count(LocalNode)) ArgVal = FI.PoolDescriptors.find(LocalNode)-second; -#if 0 -if (isaConstant(ArgVal) castConstant(ArgVal)-isNullValue()) - std::cerr WARNING: NULL POOL ARGUMENTS ARE PASSED IN!\n; +if (isaConstant(ArgVal) castConstant(ArgVal)-isNullValue()) { +#ifdef BOUNDS_CHECK + if (ArgNodes[i]-isArray()) { #endif + if (1) { + //Dinakar we need pooldescriptors for allocas in the callee if it escapes + BasicBlock::iterator InsertPt = TheCall-getParent()-getParent()-front().begin(); + Type *VoidPtrTy = PointerType::get(Type::SByteTy); + ArgVal = new AllocaInst(ArrayType::get(VoidPtrTy, 16), 0, PD, InsertPt); + Value *ElSize = ConstantUInt::get(Type::UIntTy,0); + Value *Align = ConstantUInt::get(Type::UIntTy,0); + new CallInst(PAInfo.PoolInit, make_vector(ArgVal, ElSize, Align, 0),, TheCall); + //UGLY HACK this won't release some memory + if (!isaInvokeInst(TheCall)) + new
[llvm-commits] CVS: llvm-poolalloc/runtime/BoundsCheckAllocator/PoolAllocator.h
Changes in directory llvm-poolalloc/runtime/BoundsCheckAllocator: PoolAllocator.h added (r1.1) --- Log message: *** empty log message *** --- Diffs of the changes: (+235 -0) PoolAllocator.h | 235 1 files changed, 235 insertions(+) Index: llvm-poolalloc/runtime/BoundsCheckAllocator/PoolAllocator.h diff -c /dev/null llvm-poolalloc/runtime/BoundsCheckAllocator/PoolAllocator.h:1.1 *** /dev/null Thu Dec 22 10:40:54 2005 --- llvm-poolalloc/runtime/BoundsCheckAllocator/PoolAllocator.h Thu Dec 22 10:40:44 2005 *** *** 0 --- 1,235 + //===- PoolAllocator.h - Pool allocator runtime interface file --*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===--===// + // + // This file defines the interface which is implemented by the LLVM pool + // allocator runtime library. + // + // Note: this version uses splay data structure to note object sizes and + // uses it to do bounds checking like Jones-Kelley + // + //===--===// + + #ifndef POOLALLOCATOR_RUNTIME_H + #define POOLALLOCATOR_RUNTIME_H + + #include assert.h + #include splay.h + #include stdio.h + #include stdlib.h + + templatetypename PoolTraits + struct PoolSlab; + templatetypename PoolTraits + struct FreedNodeHeader; + + // NormalPoolTraits - This describes normal pool allocation pools, which can + // address the entire heap, and are made out of multiple chunks of memory. The + // object header is a full machine word, and pointers into the heap are native + // pointers. + struct NormalPoolTraits { + typedef unsigned long NodeHeaderType; + enum { + UseLargeArrayObjects = 1, + CanGrowPool = 1, + }; + + // Pointers are just pointers. + typedef FreedNodeHeaderNormalPoolTraits* FreeNodeHeaderPtrTy; + + static const char *getSuffix() { return ; } + + /// DerefFNHPtr - Given an index into the pool, return a pointer to the + /// FreeNodeHeader object. + static FreedNodeHeaderNormalPoolTraits* + IndexToFNHPtr(FreeNodeHeaderPtrTy P, void *PoolBase) { + return P; + } + + static FreeNodeHeaderPtrTy + FNHPtrToIndex(FreedNodeHeaderNormalPoolTraits* FNHP, void *PoolBase) { + return FNHP; + } + }; + + + // CompressedPoolTraits - This describes a statically pointer compressed pool, + // which is known to be = 2^32 bytes in size (even on a 64-bit machine), and is + // made out of a single contiguous block. The meta-data to represent the pool + // uses 32-bit indexes from the start of the pool instead of full pointers to + // decrease the minimum object size. + struct CompressedPoolTraits { + typedef unsigned NodeHeaderType; + + enum { + UseLargeArrayObjects = 0, + CanGrowPool = 0, + }; + + // Represent pointers with indexes from the pool base. + typedef unsigned FreeNodeHeaderPtrTy; + + static const char *getSuffix() { return _pc; } + + /// DerefFNHPtr - Given an index into the pool, return a pointer to the + /// FreeNodeHeader object. + static FreedNodeHeaderCompressedPoolTraits* + IndexToFNHPtr(FreeNodeHeaderPtrTy P, void *PoolBase) { + return (FreedNodeHeaderCompressedPoolTraits*)((char*)PoolBase + P); + } + + static FreeNodeHeaderPtrTy + FNHPtrToIndex(FreedNodeHeaderCompressedPoolTraits* FNHP, void *PoolBase) { + assert(FNHP PoolBase Can't handle null FHNP!); + return (char*)FNHP - (char*)PoolBase; + } + }; + + + // NodeHeader - Each block of memory is preceeded in the the pool by one of + // these headers. + templatetypename PoolTraits + struct NodeHeader { + typename PoolTraits::NodeHeaderType Size; + }; + + + // When objects are on the free list, we pretend they have this header. + templatetypename PoolTraits + struct FreedNodeHeader { + // NormalHeader - This is the normal node header that is on allocated or free + // blocks. + NodeHeaderPoolTraits Header; + + // Next - The next object in the free list. + typename PoolTraits::FreeNodeHeaderPtrTy Next; + + // Prev - The node that points to this node on the free list. This is null + // if it is the first node in one of the two free lists. + typename PoolTraits::FreeNodeHeaderPtrTy Prev; + }; + + + // Large Arrays are passed on to directly malloc, and are not necessarily page + // aligned. These arrays are marked by setting the object size preheader to ~1. + // LargeArrays are on their own list to allow for efficient deletion. + struct LargeArrayHeader { + LargeArrayHeader **Prev, *Next; + + // Size - This contains the size of the object. + unsigned long Size; + + // Marker: this is the ObjectSize marker which MUST BE THE LAST ELEMENT
[llvm-commits] CVS: llvm-poolalloc/runtime/BoundsCheckAllocator/
Changes in directory llvm-poolalloc/runtime/BoundsCheckAllocator: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm-poolalloc/runtime/BoundsCheckAllocator added to the repository --- Diffs of the changes: (+0 -0) 0 files changed ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm-poolalloc/runtime/BoundsCheckAllocator/splay.h
Changes in directory llvm-poolalloc/runtime/BoundsCheckAllocator: splay.h added (r1.1) --- Log message: *** empty log message *** --- Diffs of the changes: (+48 -0) splay.h | 48 1 files changed, 48 insertions(+) Index: llvm-poolalloc/runtime/BoundsCheckAllocator/splay.h diff -c /dev/null llvm-poolalloc/runtime/BoundsCheckAllocator/splay.h:1.1 *** /dev/null Thu Dec 22 10:46:56 2005 --- llvm-poolalloc/runtime/BoundsCheckAllocator/splay.h Thu Dec 22 10:46:46 2005 *** *** 0 --- 1,48 + // Note: This file is obtained from + // http://www.cs.utk.edu/~cs140/spring-2005/notes/Splay/ + // FIXME: This may not be the most efficient version of splay implementation + // This may be updated with a different splay implementation in near future + #ifndef _SPLAY_ + #define SPLAY + + typedef unsigned long Jval ; + + /* Node identities */ + + #define SPLAY_SENTINEL 0 + #define SPLAY_OTHER 1 + + typedef struct splay { + Jval key; + Jval val; + int is_sentinel; + struct splay *left; + struct splay *right; + struct splay *flink; + struct splay *blink; + struct splay *parent; + } Splay; + + extern C { + Splay *new_splay(); + void free_splay(Splay *); + Splay *splay_insert_ptr(Splay *tree, unsigned long key, Jval val); + Splay *splay_find_ptr(Splay *tree, unsigned long key); + Splay *splay_find_gte_ptr(Splay *tree, unsigned long key, int *found); + + Splay *splay_root(Splay *tree); + Splay *splay_first(Splay *tree); + Splay *splay_last(Splay *tree); + Splay *splay_next(Splay *node); + Splay *splay_prev(Splay *node); + Splay *splay_nil(Splay *tree); + + void splay_delete_node(Splay *node); + }; + + #define splay_traverse(ptr, list) \ + for (ptr = splay_first(list); ptr != splay_nil(list); ptr = splay_next(ptr)) + #define splay_rtraverse(ptr, list) \ + for (ptr = splay_last(list); ptr != splay_nil(list); ptr = splay_prev(ptr)) + + #endif ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm-poolalloc/runtime/BoundsCheckAllocator/splay.cpp
Changes in directory llvm-poolalloc/runtime/BoundsCheckAllocator: splay.cpp added (r1.1) --- Log message: *** empty log message *** --- Diffs of the changes: (+322 -0) splay.cpp | 322 ++ 1 files changed, 322 insertions(+) Index: llvm-poolalloc/runtime/BoundsCheckAllocator/splay.cpp diff -c /dev/null llvm-poolalloc/runtime/BoundsCheckAllocator/splay.cpp:1.1 *** /dev/null Thu Dec 22 10:47:32 2005 --- llvm-poolalloc/runtime/BoundsCheckAllocator/splay.cpp Thu Dec 22 10:47:21 2005 *** *** 0 --- 1,322 + // Note: This file is obtained from + // http://www.cs.utk.edu/~cs140/spring-2005/notes/Splay/ + // FIXME: This may not be the most efficient version of splay implementation + // This may be updated with a different splay implementation in near future + #include stdio.h + #include splay.h + #include stdlib.h + void rotate(Splay *node) + { + Splay *parent, *grandparent; + + if (node-parent-is_sentinel) return; + + parent = node-parent; + grandparent = parent-parent; + + if (parent-left == node) { + parent-left = node-right; + if (parent-left != NULL) parent-left-parent = parent; + node-right = parent; + } else if (parent-right == node) { + parent-right = node-left; + if (parent-right != NULL) parent-right-parent = parent; + node-left = parent; + } else { + fprintf(stderr, rotate: error: parent's children are not right\n); + exit(1); + } + + parent-parent = node; + node-parent = grandparent; + + if (grandparent-is_sentinel) { + grandparent-parent = node; + } else if (grandparent-left == parent) { + grandparent-left = node; + } else if (grandparent-right == parent) { + grandparent-right = node; + } else { + fprintf(stderr, rotate: error: grandparent's children are not right\n); + exit(1); + } + } + + void splay(Splay *node) + { + Splay *parent, *grandparent; + + if (node-is_sentinel) return; + + while(1) { + if (node-parent-is_sentinel) return; + + parent = node-parent; + grandparent = parent-parent; + + /* If the node's parent is the root of the tree, do one rotation */ + + if (grandparent-is_sentinel) { + rotate(node); + + /* If we have a zig-zig, then rotate my parent, then rotate me */ + + } else if ((parent-left == node grandparent-left == parent) || +(parent-right == node grandparent-right == parent)) { + rotate(parent); + rotate(node); + + /* If we have a zig-zag, then rotate me twice */ + + } else { + rotate(node); + rotate(node); + } + } + } + + Splay *new_splay() + { + Splay *tree; + + tree = (Splay *) malloc(sizeof(struct splay)); + tree-key = 0; + tree-val = 0; + tree-is_sentinel = 1; + tree-flink = tree; + tree-blink = tree; + tree-left = NULL; + tree-right = NULL; + tree-parent = NULL; + return tree; + } + + Splay *splay_root(Splay *tree) + { + return tree-parent; + } + + Splay *splay_first(Splay *tree) + { + return tree-flink; + } + + Splay *splay_last(Splay *tree) + { + return tree-blink; + } + + Splay *splay_next(Splay *node) + { + return node-flink; + } + + Splay *splay_prev(Splay *node) + { + return node-blink; + } + + Splay *splay_nil(Splay *tree) + { + return tree; + } + + void free_splay(Splay *tree) + { + Splay *ptr; + + while (1) { + ptr = splay_first(tree); + if (!ptr-is_sentinel) { + splay_delete_node(ptr); + } else { + free(ptr); + return; + } + } + } + + Splay *splay_find_nearest_ptr(Splay *tree, unsigned long key, int *cmpval) + { + Splay *s, *last; + int cmp; + + last = tree; + s = splay_root(tree); + cmp = 1; + + while(s != NULL) { + last = s; + if (key == s-key) { + *cmpval = 0; + return s; + } else if (key (s-key)) { + s = s-left; + cmp = -1; + } else { + if (key (s-val + s-key)) { + *cmpval = 0; + return s; + } + s = s-right; + cmp = 1; + } + } + + *cmpval = cmp; + return last; + } + + + Splay *splay_find_ptr(Splay *tree, unsigned long key) + { + int cmpval; + Splay *s; + + s = splay_find_nearest_ptr(tree, key, cmpval); + splay(s); + if (cmpval == 0) return s; else return NULL; + } + + + Splay *splay_insert(Splay *tree, Jval key, Jval val, Splay *parent, int cmpval) + { + Splay *s; + + s = (Splay *) malloc(sizeof(struct splay)); + s-is_sentinel = 0; + s-parent = parent; + s-left = NULL; + s-right = NULL; + s-key = key; + s-val = val; + +/* Set the parent's correct child pointer. The only + subtle case here is when the key is already in + the tree -- then we need to find a leaf node + to use as a parent */ + +/* When we're done
[llvm-commits] CVS: llvm-poolalloc/runtime/SafePoolAllocator/Makefile
Changes in directory llvm-poolalloc/runtime/SafePoolAllocator: Makefile added (r1.1) --- Log message: *** empty log message *** --- Diffs of the changes: (+9 -0) Makefile |9 + 1 files changed, 9 insertions(+) Index: llvm-poolalloc/runtime/SafePoolAllocator/Makefile diff -c /dev/null llvm-poolalloc/runtime/SafePoolAllocator/Makefile:1.1 *** /dev/null Thu Dec 22 10:49:41 2005 --- llvm-poolalloc/runtime/SafePoolAllocator/Makefile Thu Dec 22 10:49:31 2005 *** *** 0 --- 1,9 + LEVEL = ../.. + BYTECODE_LIBRARY=1 + SHARED_LIBRARY=1 + LIBRARYNAME=poolalloc_safe_rt + + include $(LEVEL)/Makefile.common + + # Always build optimized and debug versions + all:: $(LIBNAME_OBJO) $(LIBNAME_OBJG) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm-poolalloc/runtime/SafePoolAllocator/PoolAllocator.h
Changes in directory llvm-poolalloc/runtime/SafePoolAllocator: PoolAllocator.h added (r1.1) --- Log message: *** empty log message *** --- Diffs of the changes: (+79 -0) PoolAllocator.h | 79 1 files changed, 79 insertions(+) Index: llvm-poolalloc/runtime/SafePoolAllocator/PoolAllocator.h diff -c /dev/null llvm-poolalloc/runtime/SafePoolAllocator/PoolAllocator.h:1.1 *** /dev/null Thu Dec 22 10:50:05 2005 --- llvm-poolalloc/runtime/SafePoolAllocator/PoolAllocator.hThu Dec 22 10:49:55 2005 *** *** 0 --- 1,79 + //===- PoolAllocator.h - Pool allocator runtime interface file --*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===--===// + // + // This file defines the interface which is implemented by the LLVM pool + // allocator runtime library. + // + //===--===// + + #ifndef POOLALLOCATOR_RUNTIME_H + #define POOLALLOCATOR_RUNTIME_H + #include Support/hash_set + + #define AddrArrSize 2 + unsigned poolmemusage = 0; + unsigned PCheckPassed = 1; + typedef struct PoolTy { + // Ptr1, Ptr2 - Implementation specified data pointers. + void *Ptr1, *Ptr2; + + // NodeSize - Keep track of the object size tracked by this pool + unsigned short NodeSize; + + // FreeablePool - Set to false if the memory from this pool cannot be freed + // before destroy. + // + // unsigned short FreeablePool; + + // Use the hash_set only if the number of Slabs exceeds AddrArrSize + hash_setvoid* *Slabs; + + // The array containing the initial address of slabs (as long as there are + // fewer than a certain number of them) + unsigned SlabAddressArray[AddrArrSize]; + + // The number of slabs allocated. Large arrays are not counted + unsigned NumSlabs; + + // Large arrays. In SAFECode, these are currently not freed or reused. + // A better implementation could split them up into single slabs for reuse, + // upon being freed. + void *LargeArrays; + + void *prevPage[4]; + unsigned short lastUsed; + + short AllocadPool; + void *allocaptr; + + } PoolTy; + + extern C { + void exactcheck(int a, int b) { + if ((0 a) || (a = b)) { + fprintf(stderr, exact check failed\n); + exit(-1); + } + } + void poolinit(PoolTy *Pool, unsigned NodeSize); + void poolmakeunfreeable(PoolTy *Pool); + void pooldestroy(PoolTy *Pool); + void *poolalloc(PoolTy *Pool, unsigned NumBytes); + void poolregister(PoolTy *Pool, unsigned NumBytes, void *allocaptr); + void poolfree(PoolTy *Pool, void *Node); + void poolcheck(PoolTy *Pool, void *Node); + void poolcheckoptim(PoolTy *Pool, void *Node); + void poolstats() { + fprintf(stderr, pool mem usage %d\n,poolmemusage); + } + void poolcheckalign(PoolTy *Pool, void *Node, unsigned StartOffset, +unsigned EndOffset); + } + + #endif ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm-poolalloc/runtime/BoundsCheckAllocator/PoolAllocator.cpp
Changes in directory llvm-poolalloc/runtime/BoundsCheckAllocator: PoolAllocator.cpp added (r1.1) --- Log message: *** empty log message *** --- Diffs of the changes: (+1093 -0) PoolAllocator.cpp | 1093 ++ 1 files changed, 1093 insertions(+) Index: llvm-poolalloc/runtime/BoundsCheckAllocator/PoolAllocator.cpp diff -c /dev/null llvm-poolalloc/runtime/BoundsCheckAllocator/PoolAllocator.cpp:1.1 *** /dev/null Thu Dec 22 10:49:02 2005 --- llvm-poolalloc/runtime/BoundsCheckAllocator/PoolAllocator.cpp Thu Dec 22 10:48:52 2005 *** *** 0 --- 1,1093 + //===- PoolAllocator.cpp - Simple free-list based pool allocator --===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===--===// + // + // This file is one possible implementation of the LLVM pool allocator runtime + // library. + // + // FIXME: + // The pointer compression functions are not thread safe. + //===--===// + + #include PoolAllocator.h + #include poolalloc/MMAPSupport.h + #include stdlib.h + #include stdio.h + #include string.h + + typedef long intptr_t; + typedef unsigned long uintptr_t; + + // Performance tweaking macros. + #define INITIAL_SLAB_SIZE 4096 + #define LARGE_SLAB_SIZE 4096 + + #ifndef NDEBUG + // Configuration macros. Define up to one of these. + #define PRINT_NUM_POOLS // Print use dynamic # pools info + //#define PRINT_POOLDESTROY_STATS // When pools are destroyed, print stats + //#define PRINT_POOL_TRACE // Print a full trace + #define ENABLE_POOL_IDS// PID for access/pool traces + + + // ALWAYS_USE_MALLOC_FREE - Make poolalloc/free always call malloc/free. Note + // that if the poolfree optimization is in use that this will cause memory + // leaks! + //#define ALWAYS_USE_MALLOC_FREE + #endif + + //===--===// + // Pool Debugging stuff. + //===--===// + + #if defined(ALWAYS_USE_MALLOC_FREE) + #define DO_IF_FORCE_MALLOCFREE(x) x + #else + #define DO_IF_FORCE_MALLOCFREE(x) + #endif + + + #if !defined(PRINT_POOL_TRACE) + #define DO_IF_TRACE(X) + #else + #define ENABLE_POOL_IDS + #define DO_IF_TRACE(X) X + #define PRINT_POOLDESTROY_STATS + #endif + + #if defined(ENABLE_POOL_IDS) + struct PoolID { + void *PD; + unsigned ID; + }; + + struct PoolID *PoolIDs = 0; + static unsigned NumLivePools = 0; + static unsigned NumPoolIDsAllocated = 0; + static unsigned CurPoolID = 0; + + static unsigned addPoolNumber(void *PD) { + if (NumLivePools == NumPoolIDsAllocated) { + NumPoolIDsAllocated = (10+NumPoolIDsAllocated)*2; + PoolIDs = (PoolID*)realloc(PoolIDs, sizeof(PoolID)*NumPoolIDsAllocated); + } + + PoolIDs[NumLivePools].PD = PD; + PoolIDs[NumLivePools].ID = ++CurPoolID; + NumLivePools++; + return CurPoolID; + } + + static unsigned getPoolNumber(void *PD) { + if (PD == 0) return ~0; + for (unsigned i = 0; i != NumLivePools; ++i) + if (PoolIDs[i].PD == PD) + return PoolIDs[i].ID; + fprintf(stderr, INVALID/UNKNOWN POOL DESCRIPTOR: 0x%lX\n,(unsigned long)PD); + return 0; + } + + static unsigned removePoolNumber(void *PD) { + for (unsigned i = 0; i != NumLivePools; ++i) + if (PoolIDs[i].PD == PD) { + unsigned PN = PoolIDs[i].ID; + memmove(PoolIDs[i], PoolIDs[i+1], sizeof(PoolID)*(NumLivePools-i-1)); + --NumLivePools; + return PN; + } + fprintf(stderr, INVALID/UNKNOWN POOL DESCRIPTOR: 0x%lX\n,(unsigned long)PD); + return 0; + } + + static void PrintPoolStats(void *Pool); + templatetypename PoolTraits + static void PrintLivePoolInfo() { + for (unsigned i = 0; i != NumLivePools; ++i) { + fprintf(stderr, [%d] pool at exit , PoolIDs[i].ID); + PrintPoolStats((PoolTyPoolTraits*)PoolIDs[i].PD); + } + } + #endif + + #ifdef PRINT_POOLDESTROY_STATS + #define DO_IF_POOLDESTROY_STATS(X) X + #define PRINT_NUM_POOLS + + templatetypename PoolTraits + static void PrintPoolStats(PoolTyPoolTraits *Pool) { + fprintf(stderr, + (0x%X) BytesAlloc=%d NumObjs=%d +AvgObjSize=%d NextAllocSize=%d DeclaredSize=%d\n, + Pool, Pool-BytesAllocated, Pool-NumObjects, + Pool-NumObjects ? Pool-BytesAllocated/Pool-NumObjects : 0, + Pool-AllocSize, Pool-DeclaredSize); + } + + #else + #define DO_IF_POOLDESTROY_STATS(X) + #endif + + #ifdef PRINT_NUM_POOLS + static unsigned PoolCounter = 0; + static unsigned PoolsInited = 0; + + // MaxHeapSize - The maximum size of the heap ever. + static unsigned MaxHeapSize = 0; + + //
[llvm-commits] CVS: llvm-poolalloc/runtime/Makefile
Changes in directory llvm-poolalloc/runtime: Makefile updated: 1.8 - 1.9 --- Log message: added safecode runtime --- Diffs of the changes: (+1 -1) Makefile |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-poolalloc/runtime/Makefile diff -u llvm-poolalloc/runtime/Makefile:1.8 llvm-poolalloc/runtime/Makefile:1.9 --- llvm-poolalloc/runtime/Makefile:1.8 Wed May 18 14:56:29 2005 +++ llvm-poolalloc/runtime/Makefile Thu Dec 22 10:51:59 2005 @@ -6,6 +6,6 @@ # # List all of the subdirectories that we will compile. # -DIRS=PoolAllocator FreeListAllocator FL2Allocator +DIRS=SafePoolAllocator PoolAllocator FreeListAllocator FL2Allocator include $(LEVEL)/Makefile.common ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm-poolalloc/runtime/SafePoolAllocator/PageManager.cpp
Changes in directory llvm-poolalloc/runtime/SafePoolAllocator: PageManager.cpp added (r1.1) --- Log message: *** empty log message *** --- Diffs of the changes: (+128 -0) PageManager.cpp | 128 1 files changed, 128 insertions(+) Index: llvm-poolalloc/runtime/SafePoolAllocator/PageManager.cpp diff -c /dev/null llvm-poolalloc/runtime/SafePoolAllocator/PageManager.cpp:1.1 *** /dev/null Thu Dec 22 10:50:54 2005 --- llvm-poolalloc/runtime/SafePoolAllocator/PageManager.cppThu Dec 22 10:50:44 2005 *** *** 0 --- 1,128 + //===- PageManager.cpp - Implementation of the page allocator -===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===--===// + // + // This file implements the PageManager.h interface. + // + //===--===// + + #include PageManager.h + #ifndef _POSIX_MAPPED_FILES + #define _POSIX_MAPPED_FILES + #endif + #include unistd.h + #include poolalloc/Support/MallocAllocator.h + #include poolalloc/MMAPSupport.h + #include iostream + #include vector + #include cassert + // Define this if we want to use memalign instead of mmap to get pages. + // Empirically, this slows down the pool allocator a LOT. + #define USE_MEMALIGN 0 + extern C { + unsigned PageSize = 0; + } + extern unsigned poolmemusage; + void InitializePageManager() { + if (!PageSize) { + PageSize = 32 * sysconf(_SC_PAGESIZE) ; + } + } + + #if !USE_MEMALIGN + static void *GetPages(unsigned NumPages) { + #if defined(i386) || defined(__i386__) || defined(__x86__) + /* Linux and *BSD tend to have these flags named differently. */ + #if defined(MAP_ANON) !defined(MAP_ANONYMOUS) + # define MAP_ANONYMOUS MAP_ANON + #endif /* defined(MAP_ANON) !defined(MAP_ANONYMOUS) */ + #elif defined(sparc) || defined(__sparc__) || defined(__sparcv9) + /* nothing */ + #else + std::cerr This architecture is not supported by the pool allocator!\n; + abort(); + #endif + + #if defined(__linux__) + #define fd 0 + #else + #define fd -1 + #endif + void *Addr; + //MMAP DOESNOT WORK + // Addr = mmap(0, NumPages*PageSize, PROT_READ|PROT_WRITE, + // MAP_SHARED|MAP_ANONYMOUS, fd, 0); + // void *pa = malloc(NumPages * PageSize); + // assert(Addr != MAP_FAILED MMAP FAILED!); +if (posix_memalign(Addr, PageSize, NumPages*PageSize) != 0){ + assert(1 memalign failed \n); +} + poolmemusage += NumPages * PageSize; + memset(Addr, 0xcc, NumPages *PageSize); + return Addr; + } + #endif + + // Explicitly use the malloc allocator here, to avoid depending on the C++ + // runtime library. + typedef std::vectorvoid*, llvm::MallocAllocatorvoid* FreePagesListType; + + static FreePagesListType getFreePageList() { + static FreePagesListType *FreePages = 0; + + if (!FreePages) { + // Avoid using operator new! + FreePages = (FreePagesListType*)malloc(sizeof(FreePagesListType)); + // Use placement new now. + //new (FreePages) std::vectorvoid*, llvm::MallocAllocatorvoid* (); + } + return *FreePages; + } + + /// AllocatePage - This function returns a chunk of memory with size and + /// alignment specified by PageSize. + void *AllocatePage() { + + FreePagesListType FPL = getFreePageList(); + + if (!FPL.empty()) { + void *Result = FPL.back(); + FPL.pop_back(); + return Result; + } + + // Allocate several pages, and put the extras on the freelist... + unsigned NumToAllocate = 8; + char *Ptr = (char*)GetPages(NumToAllocate); + + for (unsigned i = 1; i != NumToAllocate; ++i) + FPL.push_back(Ptr+i*PageSize); + return Ptr; + } + + void *AllocateNPages(unsigned Num) { + if (Num = 1) return AllocatePage(); + return GetPages(Num); + } + + /// FreePage - This function returns the specified page to the pagemanager for + /// future allocation. + #define THRESHOLD 5 + void FreePage(void *Page) { + FreePagesListType FPL = getFreePageList(); + FPL.push_back(Page); + //munmap(Page, 1); + /* + if (FPL.size() THRESHOLD) { + //printf( pool allocator : reached a threshold \n); + //exit(-1); + munmap(Page, PageSize); + poolmemusage -= PageSize; + } + */ + } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/PowerPC/README.txt
Changes in directory llvm/lib/Target/PowerPC: README.txt updated: 1.40 - 1.41 --- Log message: move some random notes out of my email into someplace useful --- Diffs of the changes: (+32 -0) README.txt | 32 1 files changed, 32 insertions(+) Index: llvm/lib/Target/PowerPC/README.txt diff -u llvm/lib/Target/PowerPC/README.txt:1.40 llvm/lib/Target/PowerPC/README.txt:1.41 --- llvm/lib/Target/PowerPC/README.txt:1.40 Thu Dec 8 01:13:28 2005 +++ llvm/lib/Target/PowerPC/README.txt Thu Dec 22 11:19:28 2005 @@ -241,3 +241,35 @@ -- important for C++. +===-=== + +int test3(int a, int b) { return (a 0) ? a : 0; } + +should be branch free code. LLVM is turning it into 1 because of the RHS. + +===-=== + +For this testcase: +int f1(int a, int b) { return (a0xF)|(b0xF0); } + +We currently emit: +_f1: +rlwinm r2, r4, 0, 24, 27 +rlwimi r2, r3, 0, 28, 31 +or r3, r2, r2 +blr + +We could emit: +_f1: +rlwinm r4, r4, 0, 24, 27 +rlwimi r3, r4, 0, 0, 27 +blr + +===-=== + +No loads or stores of the constants should be needed: + +struct foo { double X, Y; }; +void xxx(struct foo F); +void bar() { struct foo R = { 1.0, 2.0 }; xxx(R); } + ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp
Changes in directory llvm-poolalloc/lib/PoolAllocate: TransformFunctionBody.cpp updated: 1.48 - 1.49 --- Log message: *** empty log message *** --- Diffs of the changes: (+2 -4) TransformFunctionBody.cpp |6 ++ 1 files changed, 2 insertions(+), 4 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp diff -u llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.48 llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.49 --- llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.48 Thu Dec 22 10:33:29 2005 +++ llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp Thu Dec 22 11:49:34 2005 @@ -592,16 +592,14 @@ #ifdef BOUNDS_CHECK if (ArgNodes[i]-isArray()) { #endif - if (1) { - //Dinakar we need pooldescriptors for allocas in the callee if it escapes + if (!isaInvokeInst(TheCall)) { + //Dinakar we need pooldescriptors for allocas in the callee if it escapes BasicBlock::iterator InsertPt = TheCall-getParent()-getParent()-front().begin(); Type *VoidPtrTy = PointerType::get(Type::SByteTy); ArgVal = new AllocaInst(ArrayType::get(VoidPtrTy, 16), 0, PD, InsertPt); Value *ElSize = ConstantUInt::get(Type::UIntTy,0); Value *Align = ConstantUInt::get(Type::UIntTy,0); new CallInst(PAInfo.PoolInit, make_vector(ArgVal, ElSize, Align, 0),, TheCall); - //UGLY HACK this won't release some memory - if (!isaInvokeInst(TheCall)) new CallInst(PAInfo.PoolDestroy, make_vector(ArgVal, 0), , TheCall-getNext()); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/tools/analyze/AnalysisWrappers.cpp
Changes in directory llvm/tools/analyze: AnalysisWrappers.cpp updated: 1.16 - 1.17 --- Log message: Fix test/Regression/Other/2002-01-31-CallGraph.ll after the recent callgraph rework. --- Diffs of the changes: (+17 -3) AnalysisWrappers.cpp | 20 +--- 1 files changed, 17 insertions(+), 3 deletions(-) Index: llvm/tools/analyze/AnalysisWrappers.cpp diff -u llvm/tools/analyze/AnalysisWrappers.cpp:1.16 llvm/tools/analyze/AnalysisWrappers.cpp:1.17 --- llvm/tools/analyze/AnalysisWrappers.cpp:1.16Thu Apr 21 18:59:21 2005 +++ llvm/tools/analyze/AnalysisWrappers.cpp Thu Dec 22 13:26:06 2005 @@ -20,6 +20,7 @@ #include llvm/Module.h #include llvm/Pass.h #include llvm/Support/CallSite.h +#include llvm/Analysis/CallGraph.h #include iostream using namespace llvm; @@ -55,13 +56,26 @@ return false; } -void print(std::ostream OS) const {} - virtual void getAnalysisUsage(AnalysisUsage AU) const { AU.setPreservesAll(); } }; RegisterAnalysisExternalFunctionsPassedConstants - P2(externalfnconstants, Print external fn callsites passed constants); + P1(externalfnconstants, Print external fn callsites passed constants); + + struct CallGraphPrinter : public ModulePass { +virtual void getAnalysisUsage(AnalysisUsage AU) const { + AU.setPreservesAll(); + AU.addRequiredCallGraph(); +} +virtual bool runOnModule(Module M) { return false; } + +void print(std::ostream OS, Module *M) const { + getAnalysisCallGraph().print(OS, M); +} + }; + + RegisterAnalysisCallGraphPrinter +P2(callgraph, Print a call graph); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/test/Regression/Verifier/2004-01-22-FloatNormalization.ll
Changes in directory llvm/test/Regression/Verifier: 2004-01-22-FloatNormalization.ll added (r1.1) --- Log message: Fix PR409: http://llvm.cs.uiuc.edu/PR409 : Implement the suggested check to ensure that out-of-range float constants don't get accepted by LLVM accidentally. Adjust the supporting test cases as well. --- Diffs of the changes: (+6 -0) 2004-01-22-FloatNormalization.ll |6 ++ 1 files changed, 6 insertions(+) Index: llvm/test/Regression/Verifier/2004-01-22-FloatNormalization.ll diff -c /dev/null llvm/test/Regression/Verifier/2004-01-22-FloatNormalization.ll:1.1 *** /dev/null Thu Dec 22 15:07:39 2005 --- llvm/test/Regression/Verifier/2004-01-22-FloatNormalization.ll Thu Dec 22 15:07:29 2005 *** *** 0 --- 1,6 + ; RUN: llvm-as %s -o /dev/null -f + ; XFAIL: * + + ; make sure that invalid 'float' values are caught. + + global float 0x1 ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp
Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.139 - 1.140 --- Log message: Fix PR409: http://llvm.cs.uiuc.edu/PR409 : Implement the suggested check to ensure that out-of-range float constants don't get accepted by LLVM accidentally. Adjust the supporting test cases as well. --- Diffs of the changes: (+3 -0) Constants.cpp |3 +++ 1 files changed, 3 insertions(+) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.139 llvm/lib/VMCore/Constants.cpp:1.140 --- llvm/lib/VMCore/Constants.cpp:1.139 Fri Oct 7 00:23:36 2005 +++ llvm/lib/VMCore/Constants.cpp Thu Dec 22 15:07:29 2005 @@ -482,6 +482,9 @@ // TODO: Figure out how to test if a double can be cast to a float! case Type::FloatTyID: +float FV = float(Val); +double DV = double(FV); +return IsNAN(Val) || Val == DV; case Type::DoubleTyID: return true; // This is the largest type... } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/test/Regression/Assembler/2004-12-06-ConstantFloatRange.ll 2004-01-22-FloatNormalization.ll
Changes in directory llvm/test/Regression/Assembler: 2004-12-06-ConstantFloatRange.ll updated: 1.2 - 1.3 2004-01-22-FloatNormalization.ll (r1.2) removed --- Log message: Fix PR409: http://llvm.cs.uiuc.edu/PR409 : Implement the suggested check to ensure that out-of-range float constants don't get accepted by LLVM accidentally. Adjust the supporting test cases as well. --- Diffs of the changes: (+0 -1) 2004-12-06-ConstantFloatRange.ll |1 - 1 files changed, 1 deletion(-) Index: llvm/test/Regression/Assembler/2004-12-06-ConstantFloatRange.ll diff -u llvm/test/Regression/Assembler/2004-12-06-ConstantFloatRange.ll:1.2 llvm/test/Regression/Assembler/2004-12-06-ConstantFloatRange.ll:1.3 --- llvm/test/Regression/Assembler/2004-12-06-ConstantFloatRange.ll:1.2 Tue Dec 7 20:25:32 2004 +++ llvm/test/Regression/Assembler/2004-12-06-ConstantFloatRange.ll Thu Dec 22 15:07:29 2005 @@ -1,5 +1,4 @@ ; RUN: llvm-as %s -o /dev/null 21 | grep constant invalid for type -; XFAIL: * ;; This is a testcase for PR409 ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
Changes in directory llvm/lib/Target/PowerPC: PPCAsmPrinter.cpp updated: 1.131 - 1.132 --- Log message: fix handling of weak linkage --- Diffs of the changes: (+2 -3) PPCAsmPrinter.cpp |5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.131 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.132 --- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.131 Mon Dec 19 17:40:42 2005 +++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Thu Dec 22 15:15:17 2005 @@ -495,9 +495,8 @@ switch (I-getLinkage()) { case GlobalValue::LinkOnceLinkage: case GlobalValue::WeakLinkage: -O .globl name '\n' - .weak_definition name '\n' - .private_extern name '\n'; +O \t.globl name '\n' + \t.weak_definition name '\n'; SwitchSection(.section __DATA,__datacoal_nt,coalesced, I); break; case GlobalValue::AppendingLinkage: ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/IA64/IA64ISelPattern.cpp
Changes in directory llvm/lib/Target/IA64: IA64ISelPattern.cpp updated: 1.70 - 1.71 --- Log message: remove dead code --- Diffs of the changes: (+0 -7) IA64ISelPattern.cpp |7 --- 1 files changed, 7 deletions(-) Index: llvm/lib/Target/IA64/IA64ISelPattern.cpp diff -u llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.70 llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.71 --- llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.70 Wed Dec 21 14:51:36 2005 +++ llvm/lib/Target/IA64/IA64ISelPattern.cppThu Dec 22 15:15:41 2005 @@ -2281,13 +2281,6 @@ return; } - case ISD::ImplicitDef: { -Select(N.getOperand(0)); -BuildMI(BB, IA64::IDEF, 0, -castRegisterSDNode(N.getOperand(1))-getReg()); -return; - } - case ISD::BRCOND: { MachineBasicBlock *Dest = castBasicBlockSDNode(N.getOperand(2))-getBasicBlock(); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp SelectionDAG.cpp
Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.241 - 1.242 SelectionDAG.cpp updated: 1.228 - 1.229 --- Log message: remove dead code --- Diffs of the changes: (+0 -7) LegalizeDAG.cpp |6 -- SelectionDAG.cpp |1 - 2 files changed, 7 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.241 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.242 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.241 Wed Dec 21 23:23:45 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Thu Dec 22 15:16:08 2005 @@ -589,12 +589,6 @@ AddLegalizedOperand(Op.getValue(0), Result); AddLegalizedOperand(Op.getValue(1), Result.getValue(1)); return Result.getValue(Op.ResNo); - case ISD::ImplicitDef: -Tmp1 = LegalizeOp(Node-getOperand(0)); -if (Tmp1 != Node-getOperand(0)) - Result = DAG.getNode(ISD::ImplicitDef, MVT::Other, - Tmp1, Node-getOperand(1)); -break; case ISD::UNDEF: { MVT::ValueType VT = Op.getValueType(); switch (TLI.getOperationAction(ISD::UNDEF, VT)) { Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.228 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.229 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.228Tue Dec 20 00:22:03 2005 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Dec 22 15:16:08 2005 @@ -1874,7 +1874,6 @@ case ISD::TargetConstantPool: return TargetConstantPool; case ISD::CopyToReg: return CopyToReg; case ISD::CopyFromReg: return CopyFromReg; - case ISD::ImplicitDef: return ImplicitDef; case ISD::UNDEF: return undef; // Unary operators ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAG.h SelectionDAGNodes.h
Changes in directory llvm/include/llvm/CodeGen: SelectionDAG.h updated: 1.81 - 1.82 SelectionDAGNodes.h updated: 1.82 - 1.83 --- Log message: remove a dead node --- Diffs of the changes: (+0 -10) SelectionDAG.h |4 SelectionDAGNodes.h |6 -- 2 files changed, 10 deletions(-) Index: llvm/include/llvm/CodeGen/SelectionDAG.h diff -u llvm/include/llvm/CodeGen/SelectionDAG.h:1.81 llvm/include/llvm/CodeGen/SelectionDAG.h:1.82 --- llvm/include/llvm/CodeGen/SelectionDAG.h:1.81 Thu Dec 22 01:02:51 2005 +++ llvm/include/llvm/CodeGen/SelectionDAG.hThu Dec 22 15:16:35 2005 @@ -184,10 +184,6 @@ return getNode(ISD::CopyFromReg, ResultTys, Ops); } - SDOperand getImplicitDef(SDOperand Chain, unsigned Reg, MVT::ValueType VT) { -return getNode(ISD::ImplicitDef, MVT::Other, Chain, getRegister(Reg, VT)); - } - /// getCall - Note that this destroys the vector of RetVals passed in. /// SDNode *getCall(std::vectorMVT::ValueType RetVals, SDOperand Chain, Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.82 llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.83 --- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.82 Fri Dec 16 16:45:28 2005 +++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h Thu Dec 22 15:16:35 2005 @@ -92,12 +92,6 @@ // SelectionDAG. The register is available from the RegSDNode object. CopyFromReg, -// ImplicitDef - This node indicates that the specified register is -// implicitly defined by some operation (e.g. its a live-in argument). The -// two operands to this are the token chain coming in and the register. -// The only result is the token chain going out. -ImplicitDef, - // UNDEF - An undefined node UNDEF, ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCISelPattern.cpp
Changes in directory llvm/lib/Target/PowerPC: PPCISelPattern.cpp updated: 1.193 - 1.194 --- Log message: remove dead code --- Diffs of the changes: (+0 -10) PPCISelPattern.cpp | 10 -- 1 files changed, 10 deletions(-) Index: llvm/lib/Target/PowerPC/PPCISelPattern.cpp diff -u llvm/lib/Target/PowerPC/PPCISelPattern.cpp:1.193 llvm/lib/Target/PowerPC/PPCISelPattern.cpp:1.194 --- llvm/lib/Target/PowerPC/PPCISelPattern.cpp:1.193Mon Nov 28 22:59:46 2005 +++ llvm/lib/Target/PowerPC/PPCISelPattern.cpp Thu Dec 22 15:14:57 2005 @@ -1601,16 +1601,6 @@ BuildMI(BB, PPC::OR4, 2, Tmp2).addReg(Tmp1).addReg(Tmp1); } return; - case ISD::ImplicitDef: -Select(N.getOperand(0)); -Tmp1 = castRegisterSDNode(N.getOperand(1))-getReg(); -if (N.getOperand(1).getValueType() == MVT::i32) - BuildMI(BB, PPC::IMPLICIT_DEF_GPR, 0, Tmp1); -else if (N.getOperand(1).getValueType() == MVT::f32) - BuildMI(BB, PPC::IMPLICIT_DEF_F4, 0, Tmp1); -else - BuildMI(BB, PPC::IMPLICIT_DEF_F8, 0, Tmp1); -return; case ISD::RET: switch (N.getNumOperands()) { default: ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp
Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.140 - 1.141 --- Log message: Revert previous patch. Additional tests fail. --- Diffs of the changes: (+0 -3) Constants.cpp |3 --- 1 files changed, 3 deletions(-) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.140 llvm/lib/VMCore/Constants.cpp:1.141 --- llvm/lib/VMCore/Constants.cpp:1.140 Thu Dec 22 15:07:29 2005 +++ llvm/lib/VMCore/Constants.cpp Thu Dec 22 15:46:37 2005 @@ -482,9 +482,6 @@ // TODO: Figure out how to test if a double can be cast to a float! case Type::FloatTyID: -float FV = float(Val); -double DV = double(FV); -return IsNAN(Val) || Val == DV; case Type::DoubleTyID: return true; // This is the largest type... } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAGNodes.h
Changes in directory llvm/include/llvm/CodeGen: SelectionDAGNodes.h updated: 1.83 - 1.84 --- Log message: add a new node --- Diffs of the changes: (+7 -0) SelectionDAGNodes.h |7 +++ 1 files changed, 7 insertions(+) Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.83 llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.84 --- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.83 Thu Dec 22 15:16:35 2005 +++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h Thu Dec 22 18:15:59 2005 @@ -214,6 +214,13 @@ // FP_EXTEND - Extend a smaller FP type into a larger FP type. FP_EXTEND, +// BIT_CONVERT - Theis operator converts between integer and FP values, as +// if one was stored to memory as integer and the other was loaded from the +// same address. The source and result are required to have the same bit +// size (e.g. f32 - i32). This can also be used for int-to-int or +// fp-to-fp conversions, but that is a noop, deleted by getNode(). +BIT_CONVERT, + // FNEG, FABS, FSQRT, FSIN, FCOS - Perform unary floating point negation, // absolute value, square root, sine and cosine operations. FNEG, FABS, FSQRT, FSIN, FCOS, ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp SelectionDAG.cpp
Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.242 - 1.243 SelectionDAG.cpp updated: 1.229 - 1.230 --- Log message: add very simple support for the BIT_CONVERT node --- Diffs of the changes: (+57 -2) LegalizeDAG.cpp | 52 ++-- SelectionDAG.cpp |7 +++ 2 files changed, 57 insertions(+), 2 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.242 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.243 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.242 Thu Dec 22 15:16:08 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Thu Dec 22 18:16:34 2005 @@ -130,6 +130,7 @@ SDOperand ExpandIntToFP(bool isSigned, MVT::ValueType DestTy, SDOperand Source); + SDOperand ExpandBIT_CONVERT(MVT::ValueType DestVT, SDOperand SrcOp); SDOperand ExpandLegalINT_TO_FP(bool isSigned, SDOperand LegalOp, MVT::ValueType DestVT); @@ -2119,7 +2120,25 @@ break; } break; - + + case ISD::BIT_CONVERT: +if (!isTypeLegal(Node-getOperand(0).getValueType())) + Result = ExpandBIT_CONVERT(Node-getValueType(0), Node-getOperand(0)); +else { + switch (TLI.getOperationAction(ISD::BIT_CONVERT, + Node-getOperand(0).getValueType())) { + default: assert(0 Unknown operation action!); + case TargetLowering::Expand: +Result = ExpandBIT_CONVERT(Node-getValueType(0), Node-getOperand(0)); +break; + case TargetLowering::Legal: +Tmp1 = LegalizeOp(Node-getOperand(0)); +if (Tmp1 != Node-getOperand(0)) + Result = DAG.getNode(ISD::BIT_CONVERT, Node-getValueType(0), Tmp1); +break; + } +} +break; // Conversion operators. The source and destination have different types. case ISD::SINT_TO_FP: case ISD::UINT_TO_FP: { @@ -2472,7 +2491,11 @@ break; } break; - + case ISD::BIT_CONVERT: +Result = ExpandBIT_CONVERT(Node-getValueType(0), Node-getOperand(0)); +Result = PromoteOp(Result); +break; + case ISD::FP_EXTEND: assert(0 Case not implemented. Dynamically dead with 2 FP types!); case ISD::FP_ROUND: @@ -2769,6 +2792,24 @@ return Result; } +/// ExpandBIT_CONVERT - Expand a BIT_CONVERT node into a store/load combination. +/// The resultant code need not be legal. +SDOperand SelectionDAGLegalize::ExpandBIT_CONVERT(MVT::ValueType DestVT, + SDOperand SrcOp) { + // Create the stack frame object. + MachineFrameInfo *FrameInfo = DAG.getMachineFunction().getFrameInfo(); + unsigned ByteSize = MVT::getSizeInBits(DestVT)/8; + int FrameIdx = FrameInfo-CreateFixedObject(ByteSize, ByteSize); + SDOperand FIPtr = DAG.getFrameIndex(FrameIdx, TLI.getPointerTy()); + + // Emit a store to the stack slot. + SDOperand Store = DAG.getNode(ISD::STORE, MVT::Other, DAG.getEntryNode(), +SrcOp.getOperand(0), FIPtr, +DAG.getSrcValue(NULL)); + // Result is a load from the stack slot. + return DAG.getLoad(DestVT, Store, FIPtr, DAG.getSrcValue(0)); +} + /// ExpandAddSub - Find a clever way to expand this add operation into /// subcomponents. void SelectionDAGLegalize:: @@ -3638,6 +3679,13 @@ Hi = DAG.getConstant(0, NVT); break; } + + case ISD::BIT_CONVERT: { +SDOperand Tmp = ExpandBIT_CONVERT(Node-getValueType(0), + Node-getOperand(0)); +ExpandOp(Tmp, Lo, Hi); +break; + } case ISD::READCYCLECOUNTER: { assert(TLI.getOperationAction(ISD::READCYCLECOUNTER, VT) == Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.229 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.230 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.229Thu Dec 22 15:16:08 2005 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Dec 22 18:16:34 2005 @@ -889,6 +889,12 @@ return Operand.Val-getOperand(0); } break; + case ISD::BIT_CONVERT: +// Basic sanity checking. +assert(MVT::getSizeInBits(VT)==MVT::getSizeInBits(Operand.getValueType()) + Cannot BIT_CONVERT between two different types!); +if (VT == Operand.getValueType()) return Operand; // noop conversion. +break; case ISD::FNEG: if (OpOpcode == ISD::FSUB) // -(X-Y) - (Y-X) return getNode(ISD::FSUB, VT, Operand.Val-getOperand(1), @@ -1931,6 +1937,7 @@ case ISD::UINT_TO_FP: return uint_to_fp; case ISD::FP_TO_SINT: return fp_to_sint; case ISD::FP_TO_UINT: return fp_to_uint; + case ISD::BIT_CONVERT: return bit_convert; // Control flow instructions case ISD::BR: return br;
[llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAGNodes.h
Changes in directory llvm/include/llvm/CodeGen: SelectionDAGNodes.h updated: 1.84 - 1.85 --- Log message: improve comment: mention vectors --- Diffs of the changes: (+4 -3) SelectionDAGNodes.h |7 --- 1 files changed, 4 insertions(+), 3 deletions(-) Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.84 llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.85 --- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.84 Thu Dec 22 18:15:59 2005 +++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h Thu Dec 22 18:46:10 2005 @@ -216,9 +216,10 @@ // BIT_CONVERT - Theis operator converts between integer and FP values, as // if one was stored to memory as integer and the other was loaded from the -// same address. The source and result are required to have the same bit -// size (e.g. f32 - i32). This can also be used for int-to-int or -// fp-to-fp conversions, but that is a noop, deleted by getNode(). +// same address (or equivalently for vector format conversions, etc). The +// source and result are required to have the same bit size (e.g. +// f32 - i32). This can also be used for int-to-int or fp-to-fp +// conversions, but that is a noop, deleted by getNode(). BIT_CONVERT, // FNEG, FABS, FSQRT, FSIN, FCOS - Perform unary floating point negation, ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.244 - 1.245 --- Log message: Fix a pasto --- Diffs of the changes: (+3 -2) LegalizeDAG.cpp |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.244 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.245 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.244 Thu Dec 22 18:50:25 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Thu Dec 22 18:52:30 2005 @@ -2793,13 +2793,14 @@ } /// ExpandBIT_CONVERT - Expand a BIT_CONVERT node into a store/load combination. -/// The resultant code need not be legal. +/// The resultant code need not be legal. Note that SrcOp is the input operand +/// to the BIT_CONVERT, not the BIT_CONVERT node itself. SDOperand SelectionDAGLegalize::ExpandBIT_CONVERT(MVT::ValueType DestVT, SDOperand SrcOp) { // Create the stack frame object. MachineFrameInfo *FrameInfo = DAG.getMachineFunction().getFrameInfo(); unsigned ByteSize = MVT::getSizeInBits(DestVT)/8; - int FrameIdx = FrameInfo-CreateFixedObject(ByteSize, ByteSize); + int FrameIdx = FrameInfo-CreateStackObject(ByteSize, ByteSize); SDOperand FIPtr = DAG.getFrameIndex(FrameIdx, TLI.getPointerTy()); // Emit a store to the stack slot. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
Changes in directory llvm/lib/Target/PowerPC: PPCISelLowering.cpp updated: 1.52 - 1.53 --- Log message: Simplify some code by using BIT_CONVERT --- Diffs of the changes: (+10 -21) PPCISelLowering.cpp | 31 ++- 1 files changed, 10 insertions(+), 21 deletions(-) Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp diff -u llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.52 llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.53 --- llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.52Mon Dec 19 18:26:01 2005 +++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp Thu Dec 22 18:59:59 2005 @@ -158,39 +158,28 @@ if (Src.getValueType() == MVT::f32) Src = DAG.getNode(ISD::FP_EXTEND, MVT::f64, Src); +SDOperand Tmp; switch (Op.getValueType()) { default: assert(0 Unhandled FP_TO_SINT type in custom expander!); case MVT::i32: - Op = DAG.getNode(PPCISD::FCTIWZ, MVT::f64, Src); + Tmp = DAG.getNode(PPCISD::FCTIWZ, MVT::f64, Src); break; case MVT::i64: - Op = DAG.getNode(PPCISD::FCTIDZ, MVT::f64, Src); + Tmp = DAG.getNode(PPCISD::FCTIDZ, MVT::f64, Src); break; } -int FrameIdx = - DAG.getMachineFunction().getFrameInfo()-CreateStackObject(8, 8); -SDOperand FI = DAG.getFrameIndex(FrameIdx, MVT::i32); -SDOperand ST = DAG.getNode(ISD::STORE, MVT::Other, DAG.getEntryNode(), - Op, FI, DAG.getSrcValue(0)); -if (Op.getOpcode() == PPCISD::FCTIDZ) { - Op = DAG.getLoad(MVT::i64, ST, FI, DAG.getSrcValue(0)); -} else { - FI = DAG.getNode(ISD::ADD, MVT::i32, FI, DAG.getConstant(4, MVT::i32)); - Op = DAG.getLoad(MVT::i32, ST, FI, DAG.getSrcValue(0)); -} -return Op; +// Convert the FP value to an int value through memory. +SDOperand Bits = DAG.getNode(ISD::BIT_CONVERT, MVT::i64, Tmp); +if (Op.getValueType() == MVT::i32) + Bits = DAG.getNode(ISD::TRUNCATE, MVT::i32, Bits); +return Bits; } case ISD::SINT_TO_FP: { assert(MVT::i64 == Op.getOperand(0).getValueType() Unhandled SINT_TO_FP type in custom expander!); -int FrameIdx = - DAG.getMachineFunction().getFrameInfo()-CreateStackObject(8, 8); -SDOperand FI = DAG.getFrameIndex(FrameIdx, MVT::i32); -SDOperand ST = DAG.getNode(ISD::STORE, MVT::Other, DAG.getEntryNode(), - Op.getOperand(0), FI, DAG.getSrcValue(0)); -SDOperand LD = DAG.getLoad(MVT::f64, ST, FI, DAG.getSrcValue(0)); -SDOperand FP = DAG.getNode(PPCISD::FCFID, MVT::f64, LD); +SDOperand Bits = DAG.getNode(ISD::BIT_CONVERT, MVT::f64, Op.getOperand(0)); +SDOperand FP = DAG.getNode(PPCISD::FCFID, MVT::f64, Bits); if (MVT::f32 == Op.getValueType()) FP = DAG.getNode(ISD::FP_ROUND, MVT::f32, FP); return FP; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp SparcV8InstrInfo.td
Changes in directory llvm/lib/Target/SparcV8: SparcV8ISelDAGToDAG.cpp updated: 1.32 - 1.33 SparcV8InstrInfo.td updated: 1.94 - 1.95 --- Log message: fix the int-fp instructions, which apparently take a single float register to represent the int part (because it's always 32-bits) --- Diffs of the changes: (+16 -26) SparcV8ISelDAGToDAG.cpp | 26 ++ SparcV8InstrInfo.td | 16 ++-- 2 files changed, 16 insertions(+), 26 deletions(-) Index: llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp diff -u llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp:1.32 llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp:1.33 --- llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp:1.32Thu Dec 22 20:31:39 2005 +++ llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp Thu Dec 22 23:00:16 2005 @@ -601,28 +601,14 @@ SDOperand Lo = DAG.getNode(V8ISD::Lo, MVT::i32, CP); return DAG.getNode(ISD::ADD, MVT::i32, Lo, Hi); } - case ISD::FP_TO_SINT: { + case ISD::FP_TO_SINT: // Convert the fp value to integer in an FP register. -Op = DAG.getNode(V8ISD::FTOI, Op.getOperand(0).getValueType(), - Op.getOperand(0)); -int Size = Op.getOperand(0).getValueType() == MVT::f32 ? 4 : 8; -int FrameIdx = - DAG.getMachineFunction().getFrameInfo()-CreateStackObject(Size, Size); -SDOperand FI = DAG.getFrameIndex(FrameIdx, MVT::i32); -SDOperand ST = DAG.getNode(ISD::STORE, MVT::Other, DAG.getEntryNode(), - Op, FI, DAG.getSrcValue(0)); -return DAG.getLoad(MVT::i32, ST, FI, DAG.getSrcValue(0)); - } +assert(Op.getValueType() == MVT::i32); +Op = DAG.getNode(V8ISD::FTOI, MVT::f32, Op.getOperand(0)); +return DAG.getNode(ISD::BIT_CONVERT, MVT::i32, Op); case ISD::SINT_TO_FP: { -int Size = Op.getOperand(0).getValueType() == MVT::f32 ? 4 : 8; -int FrameIdx = - DAG.getMachineFunction().getFrameInfo()-CreateStackObject(Size, Size); -SDOperand FI = DAG.getFrameIndex(FrameIdx, MVT::i32); -SDOperand ST = DAG.getNode(ISD::STORE, MVT::Other, DAG.getEntryNode(), - Op.getOperand(0), FI, DAG.getSrcValue(0)); - -Op = DAG.getLoad(Op.getValueType(), ST, FI, DAG.getSrcValue(0)); - +assert(Op.getOperand(0).getValueType() == MVT::i32); +Op = DAG.getNode(ISD::BIT_CONVERT, MVT::f32, Op); // Convert the int value to FP in an FP register. return DAG.getNode(V8ISD::ITOF, Op.getValueType(), Op); } Index: llvm/lib/Target/SparcV8/SparcV8InstrInfo.td diff -u llvm/lib/Target/SparcV8/SparcV8InstrInfo.td:1.94 llvm/lib/Target/SparcV8/SparcV8InstrInfo.td:1.95 --- llvm/lib/Target/SparcV8/SparcV8InstrInfo.td:1.94Thu Dec 22 15:18:39 2005 +++ llvm/lib/Target/SparcV8/SparcV8InstrInfo.td Thu Dec 22 23:00:16 2005 @@ -69,6 +69,10 @@ def SDTV8selectcc : SDTypeProfile1, 4, [SDTCisSameAs0, 1, SDTCisSameAs1, 2, SDTCisVT3, i32, SDTCisVT4, FlagVT]; +def SDTV8FTOI : +SDTypeProfile1, 1, [SDTCisVT0, f32, SDTCisFP1]; +def SDTV8ITOF : +SDTypeProfile1, 1, [SDTCisFP0, SDTCisVT1, f32]; def V8cmpicc : SDNodeV8ISD::CMPICC, SDTV8cmpicc; def V8cmpfcc : SDNodeV8ISD::CMPFCC, SDTV8cmpfcc; @@ -78,8 +82,8 @@ def V8hi: SDNodeV8ISD::Hi, SDTIntUnaryOp; def V8lo: SDNodeV8ISD::Lo, SDTIntUnaryOp; -def V8ftoi : SDNodeV8ISD::FTOI, SDTFPUnaryOp; -def V8itof : SDNodeV8ISD::ITOF, SDTFPUnaryOp; +def V8ftoi : SDNodeV8ISD::FTOI, SDTV8FTOI; +def V8itof : SDNodeV8ISD::ITOF, SDTV8ITOF; def V8selecticc : SDNodeV8ISD::SELECT_ICC, SDTV8selectcc; def V8selectfcc : SDNodeV8ISD::SELECT_FCC, SDTV8selectcc; @@ -597,9 +601,9 @@ fitos $src, $dst, [(set FPRegs:$dst, (V8itof FPRegs:$src))]; def FITOD : F3_32, 0b110100, 0b011001000, - (ops DFPRegs:$dst, DFPRegs:$src), + (ops DFPRegs:$dst, FPRegs:$src), fitod $src, $dst, - [(set DFPRegs:$dst, (V8itof DFPRegs:$src))]; + [(set DFPRegs:$dst, (V8itof FPRegs:$src))]; // Convert Floating-point to Integer Instructions, p. 142 def FSTOI : F3_32, 0b110100, 0b011010001, @@ -607,9 +611,9 @@ fstoi $src, $dst, [(set FPRegs:$dst, (V8ftoi FPRegs:$src))]; def FDTOI : F3_32, 0b110100, 0b011010010, - (ops DFPRegs:$dst, DFPRegs:$src), + (ops FPRegs:$dst, DFPRegs:$src), fdtoi $src, $dst, - [(set DFPRegs:$dst, (V8ftoi DFPRegs:$src))]; + [(set FPRegs:$dst, (V8ftoi DFPRegs:$src))]; // Convert between Floating-point Formats Instructions, p. 143 def FSTOD : F3_32, 0b110100, 0b011001001, ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/tools/bugpoint/OptimizerDriver.cpp
Changes in directory llvm/tools/bugpoint: OptimizerDriver.cpp updated: 1.34 - 1.35 --- Log message: Get bugpoint building with VC++ again. --- Diffs of the changes: (+1 -0) OptimizerDriver.cpp |1 + 1 files changed, 1 insertion(+) Index: llvm/tools/bugpoint/OptimizerDriver.cpp diff -u llvm/tools/bugpoint/OptimizerDriver.cpp:1.34 llvm/tools/bugpoint/OptimizerDriver.cpp:1.35 --- llvm/tools/bugpoint/OptimizerDriver.cpp:1.34Thu Dec 22 14:02:55 2005 +++ llvm/tools/bugpoint/OptimizerDriver.cpp Thu Dec 22 23:00:38 2005 @@ -29,6 +29,7 @@ #include llvm/Support/CommandLine.h #include llvm/System/Path.h #include llvm/System/Program.h +#include llvm/Config/alloca.h #include fstream using namespace llvm; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp
Changes in directory llvm/lib/Target/SparcV8: SparcV8ISelDAGToDAG.cpp updated: 1.33 - 1.34 --- Log message: make sure bit_converts are expanded --- Diffs of the changes: (+3 -0) SparcV8ISelDAGToDAG.cpp |3 +++ 1 files changed, 3 insertions(+) Index: llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp diff -u llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp:1.33 llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp:1.34 --- llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp:1.33Thu Dec 22 23:00:16 2005 +++ llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp Thu Dec 22 23:12:47 2005 @@ -108,6 +108,9 @@ setOperationAction(ISD::FP_TO_UINT, MVT::i32, Expand); setOperationAction(ISD::UINT_TO_FP, MVT::i32, Expand); + setOperationAction(ISD::BIT_CONVERT, MVT::f32, Expand); + setOperationAction(ISD::BIT_CONVERT, MVT::i32, Expand); + // Turn FP extload into load/fextend setOperationAction(ISD::EXTLOAD, MVT::f32, Expand); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp
Changes in directory llvm/lib/Target/X86: X86ISelLowering.cpp updated: 1.15 - 1.16 --- Log message: make sure bit_convert's are expanded --- Diffs of the changes: (+3 -0) X86ISelLowering.cpp |3 +++ 1 files changed, 3 insertions(+) Index: llvm/lib/Target/X86/X86ISelLowering.cpp diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.15 llvm/lib/Target/X86/X86ISelLowering.cpp:1.16 --- llvm/lib/Target/X86/X86ISelLowering.cpp:1.15Wed Dec 21 17:05:39 2005 +++ llvm/lib/Target/X86/X86ISelLowering.cpp Thu Dec 22 23:15:23 2005 @@ -80,6 +80,9 @@ setOperationAction(ISD::FP_TO_SINT , MVT::i8 , Promote); setOperationAction(ISD::FP_TO_SINT , MVT::i16 , Promote); + setOperationAction(ISD::BIT_CONVERT, MVT::f32, Expand); + setOperationAction(ISD::BIT_CONVERT, MVT::i32, Expand); + if (X86DAGIsel) { setOperationAction(ISD::BRCOND , MVT::Other, Custom); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp SelectionDAG.cpp
Changes in directory llvm/lib/CodeGen/SelectionDAG: DAGCombiner.cpp updated: 1.70 - 1.71 SelectionDAG.cpp updated: 1.230 - 1.231 --- Log message: constant fold bits_convert in getNode and in the dag combiner for fp-int conversions. This allows V8 to compiles this: void %test() { call float %test2( float 1.00e+00, float 2.00e+00, double 3.00e+00, double* null ) ret void } into: test: save -96, %o6, %o6 sethi 0, %o3 sethi 1049088, %o2 sethi 1048576, %o1 sethi 1040384, %o0 or %g0, %o3, %o4 call test2 nop restore %g0, %g0, %g0 retl nop instead of: test: save -112, %o6, %o6 sethi 0, %o4 sethi 1049088, %l0 st %o4, [%i6+-12] st %l0, [%i6+-16] ld [%i6+-12], %o3 ld [%i6+-16], %o2 sethi 1048576, %o1 sethi 1040384, %o0 call test2 nop restore %g0, %g0, %g0 retl nop --- Diffs of the changes: (+37 -0) DAGCombiner.cpp | 15 +++ SelectionDAG.cpp | 22 ++ 2 files changed, 37 insertions(+) Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.70 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.71 --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.70 Wed Dec 21 17:05:39 2005 +++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Thu Dec 22 23:30:37 2005 @@ -151,6 +151,7 @@ SDOperand visitZERO_EXTEND(SDNode *N); SDOperand visitSIGN_EXTEND_INREG(SDNode *N); SDOperand visitTRUNCATE(SDNode *N); +SDOperand visitBIT_CONVERT(SDNode *N); SDOperand visitFADD(SDNode *N); SDOperand visitFSUB(SDNode *N); @@ -609,6 +610,7 @@ case ISD::ZERO_EXTEND:return visitZERO_EXTEND(N); case ISD::SIGN_EXTEND_INREG: return visitSIGN_EXTEND_INREG(N); case ISD::TRUNCATE: return visitTRUNCATE(N); + case ISD::BIT_CONVERT:return visitBIT_CONVERT(N); case ISD::FADD: return visitFADD(N); case ISD::FSUB: return visitFSUB(N); case ISD::FMUL: return visitFMUL(N); @@ -1745,6 +1747,19 @@ return SDOperand(); } +SDOperand DAGCombiner::visitBIT_CONVERT(SDNode *N) { + SDOperand N0 = N-getOperand(0); + MVT::ValueType VT = N-getValueType(0); + + // If the input is a constant, let getNode() fold it. + if (isaConstantSDNode(N0) || isaConstantFPSDNode(N0)) { +SDOperand Res = DAG.getNode(ISD::BIT_CONVERT, VT, N0); +if (Res.Val != N) return Res; + } + + return SDOperand(); +} + SDOperand DAGCombiner::visitFADD(SDNode *N) { SDOperand N0 = N-getOperand(0); SDOperand N1 = N-getOperand(1); Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.230 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.231 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.230Thu Dec 22 18:16:34 2005 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Dec 22 23:30:37 2005 @@ -828,6 +828,7 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT, SDOperand Operand) { + // Constant fold unary operations with an integer constant operand. if (ConstantSDNode *C = dyn_castConstantSDNode(Operand.Val)) { uint64_t Val = C-getValue(); switch (Opcode) { @@ -838,13 +839,25 @@ case ISD::TRUNCATE:return getConstant(Val, VT); case ISD::SINT_TO_FP: return getConstantFP(C-getSignExtended(), VT); case ISD::UINT_TO_FP: return getConstantFP(C-getValue(), VT); +case ISD::BIT_CONVERT: + if (VT == MVT::f32) { +assert(C-getValueType(0) == MVT::i32 Invalid bit_convert!); +return getConstantFP(BitsToFloat(Val), VT); + } else if (VT == MVT::f64) { +assert(C-getValueType(0) == MVT::i64 Invalid bit_convert!); +return getConstantFP(BitsToDouble(Val), VT); + } + break; } } + // Constant fold unary operations with an floating point constant operand. if (ConstantFPSDNode *C = dyn_castConstantFPSDNode(Operand.Val)) switch (Opcode) { case ISD::FNEG: return getConstantFP(-C-getValue(), VT); +case ISD::FABS: + return getConstantFP(fabs(C-getValue()), VT); case ISD::FP_ROUND: case ISD::FP_EXTEND: return getConstantFP(C-getValue(), VT); @@ -852,6 +865,15 @@ return getConstant((int64_t)C-getValue(), VT); case ISD::FP_TO_UINT: return getConstant((uint64_t)C-getValue(), VT); +case ISD::BIT_CONVERT: + if (VT == MVT::i32) { +assert(C-getValueType(0) == MVT::f32 Invalid bit_convert!); +return getConstant(FloatToBits(C-getValue()), VT); + } else if (VT == MVT::i64) { +assert(C-getValueType(0) == MVT::f64 Invalid bit_convert!); +return getConstant(DoubleToBits(C-getValue()), VT); + } + break; } unsigned
[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp SelectionDAG.cpp
Changes in directory llvm/lib/CodeGen/SelectionDAG: DAGCombiner.cpp updated: 1.71 - 1.72 SelectionDAG.cpp updated: 1.231 - 1.232 --- Log message: Fold bitconv(bitconv(x)) - x. We now compile this: void foo(double); void bar(double X) { foo(X); } to this: bar: save -96, %o6, %o6 or %g0, %i0, %o0 or %g0, %i1, %o1 call foo nop restore %g0, %g0, %g0 retl nop instead of this: bar: save -112, %o6, %o6 st %i1, [%i6+-4] st %i0, [%i6+-8] ldd [%i6+-8], %f0 std %f0, [%i6+-16] ld [%i6+-12], %o1 ld [%i6+-16], %o0 call foo nop restore %g0, %g0, %g0 retl nop on V8. --- Diffs of the changes: (+5 -0) DAGCombiner.cpp |3 +++ SelectionDAG.cpp |2 ++ 2 files changed, 5 insertions(+) Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.71 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.72 --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.71 Thu Dec 22 23:30:37 2005 +++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Thu Dec 22 23:37:50 2005 @@ -1757,6 +1757,9 @@ if (Res.Val != N) return Res; } + if (N0.getOpcode() == ISD::BIT_CONVERT) // conv(conv(x,t1),t2) - conv(x,t2) +return DAG.getNode(ISD::BIT_CONVERT, VT, N0.getOperand(0)); + return SDOperand(); } Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.231 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.232 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.231Thu Dec 22 23:30:37 2005 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Dec 22 23:37:50 2005 @@ -916,6 +916,8 @@ assert(MVT::getSizeInBits(VT)==MVT::getSizeInBits(Operand.getValueType()) Cannot BIT_CONVERT between two different types!); if (VT == Operand.getValueType()) return Operand; // noop conversion. +if (OpOpcode == ISD::BIT_CONVERT) // bitconv(bitconv(x)) - bitconv(x) + return getNode(ISD::BIT_CONVERT, VT, Operand.getOperand(0)); break; case ISD::FNEG: if (OpOpcode == ISD::FSUB) // -(X-Y) - (Y-X) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Changes in directory llvm/lib/CodeGen/SelectionDAG: DAGCombiner.cpp updated: 1.72 - 1.73 --- Log message: fold (conv (load x)) - (load (conv*)x). This allows us to compile this: void foo(double); void bar(double *X) { foo(*X); } To this: bar: save -96, %o6, %o6 ld [%i0+4], %o1 ld [%i0], %o0 call foo nop restore %g0, %g0, %g0 retl nop instead of this: bar: save -104, %o6, %o6 ldd [%i0], %f0 std %f0, [%i6+-8] ld [%i6+-4], %o1 ld [%i6+-8], %o0 call foo nop restore %g0, %g0, %g0 retl nop on SparcV8. --- Diffs of the changes: (+10 -0) DAGCombiner.cpp | 10 ++ 1 files changed, 10 insertions(+) Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.72 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.73 --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.72 Thu Dec 22 23:37:50 2005 +++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Thu Dec 22 23:44:41 2005 @@ -1760,6 +1760,16 @@ if (N0.getOpcode() == ISD::BIT_CONVERT) // conv(conv(x,t1),t2) - conv(x,t2) return DAG.getNode(ISD::BIT_CONVERT, VT, N0.getOperand(0)); + // fold (conv (load x)) - (load (conv*)x) + if (N0.getOpcode() == ISD::LOAD N0.hasOneUse()) { +SDOperand Load = DAG.getLoad(VT, N0.getOperand(0), N0.getOperand(1), + N0.getOperand(2)); +WorkList.push_back(N); +CombineTo(N0.Val, DAG.getNode(ISD::BIT_CONVERT, N0.getValueType(), Load), + Load.getValue(1)); +return Load; + } + return SDOperand(); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/SparcV8/README.txt
Changes in directory llvm/lib/Target/SparcV8: README.txt updated: 1.40 - 1.41 --- Log message: remove benchmark list, remove issues addressed by the dag-dag isel --- Diffs of the changes: (+1 -68) README.txt | 67 - 1 files changed, 1 insertion(+), 66 deletions(-) Index: llvm/lib/Target/SparcV8/README.txt diff -u llvm/lib/Target/SparcV8/README.txt:1.40 llvm/lib/Target/SparcV8/README.txt:1.41 --- llvm/lib/Target/SparcV8/README.txt:1.40 Sat Dec 17 17:20:27 2005 +++ llvm/lib/Target/SparcV8/README.txt Fri Dec 23 00:09:30 2005 @@ -5,79 +5,12 @@ 2. ??? 3. profit! - -SparcV8 backend skeleton - - -This directory houses a 32-bit SPARC V8 backend employing an expander-based -instruction selector. It is not yet functionally complete. Watch -this space for more news coming soon! - -Current expected test failures --- - -Here are the currently-expected SingleSource failures for V8 -(Some C++ programs are crashing in libstdc++ at the moment; -I'm not sure why.) - - (llc) SingleSource/Regression/C++/EH/exception_spec_test - (llc) SingleSource/Regression/C++/EH/throw_rethrow_test - -Here are the currently-expected MultiSource failures for V8: - - (llc,cbe) MultiSource/Applications/d/make_dparser - (llc,cbe) MultiSource/Applications/hexxagon - (llc) MultiSource/Benchmarks/Fhourstones - (llc,cbe) MultiSource/Benchmarks/McCat/03-testtrie - (llc) MultiSource/Benchmarks/McCat/18-imp - (llc,cbe) MultiSource/Benchmarks/Prolangs-C/bison/mybison - (llc,cbe) MultiSource/Benchmarks/Prolangs-C/fixoutput - (llc,cbe) MultiSource/Benchmarks/Prolangs-C/gnugo - (llc,cbe) MultiSource/Benchmarks/Prolangs-C/plot2fig - (llc,cbe) MultiSource/Benchmarks/Ptrdist/anagram - (llc,cbe) MultiSource/Benchmarks/FreeBench/analyzer -* DANGER * analyzer will run the machine out of VM - (I don't know whether the following fail in cbe:) - (llc) MultiSource/Benchmarks/FreeBench/distray - (llc) MultiSource/Benchmarks/FreeBench/fourinarow - (llc) MultiSource/Benchmarks/FreeBench/pifft - (llc) MultiSource/Benchmarks/MallocBench/gs - (llc) MultiSource/Benchmarks/Prolangs-C++/deriv1 - (llc) MultiSource/Benchmarks/Prolangs-C++/deriv2 - -Known SPEC failures for V8 (probably not an exhaustive list): - - (llc) 134.perl - (llc) 177.mesa - (llc) 188.ammp -- FPMover bug? - (llc) 256.bzip2 - (llc,cbe) 130.li - (native,llc,cbe) 126.gcc - (native,llc,cbe) 255.vortex - To-do - -* support shl on longs (fourinarow needs this) -* support casting 64-bit integers to FP types (fhourstones needs this) -* support FP rem (call fmod) - +* open code 64-bit shifts * Keep the address of the constant pool in a register instead of forming its address all of the time. - -* Change code like this: -or %o0, %lo(.CPI_main_0), %o0 -ld [%o0+0], %o0 - into: -ld [%o0+%lo(.CPI_main_0)], %o0 - for constant pool access. - * We can fold small constant offsets into the %hi/%lo references to constant pool addresses as well. -* Directly support select instructions, and fold setcc instructions into them - where possible. I think this is what afflicts the inner loop of Olden/tsp - (hot block = tsp():no_exit.1.i, overall GCC/LLC = 0.03). - -$Date: 2005/12/17 23:20:27 $ - ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp
Changes in directory llvm/lib/Target/SparcV8: SparcV8ISelDAGToDAG.cpp updated: 1.34 - 1.35 --- Log message: implement vastart. The dag isel compiles this: void test3(va_list Y); void test2(int F, ...) { va_list X; va_start(X, F); test3(X); } into this: test2: save -104, %o6, %o6 st %i5, [%i6+88] st %i4, [%i6+84] st %i3, [%i6+80] st %i2, [%i6+76] st %i1, [%i6+72] add %i6, 72, %o0 st %o0, [%i6+-4] call test3 nop restore %g0, %g0, %g0 retl nop The simple isel emits: test2: save -96, %o6, %o6 st %i0, [%i6+68] st %i1, [%i6+72] st %i2, [%i6+76] st %i3, [%i6+80] st %i4, [%i6+84] st %i5, [%i6+88] or %g0, 1, %l0 or %g0, 4, %l1 umul %l0, %l1, %l0 add %l0, 7, %l0 and %l0, -8, %l0 sub %o6, %l0, %o6 add %o6, 96, %l0 add %i6, 72, %l1 st %l1, [%l0] ld [%l0], %o0 call test3 nop restore %g0, %g0, %g0 retl nop --- Diffs of the changes: (+5 -2) SparcV8ISelDAGToDAG.cpp |7 +-- 1 files changed, 5 insertions(+), 2 deletions(-) Index: llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp diff -u llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp:1.34 llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp:1.35 --- llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp:1.34Thu Dec 22 23:12:47 2005 +++ llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp Fri Dec 23 00:24:04 2005 @@ -568,8 +568,11 @@ LowerVAStart(SDOperand Chain, SDOperand VAListP, Value *VAListV, SelectionDAG DAG) { - assert(0 Unimp); - abort(); + SDOperand Offset = DAG.getNode(ISD::ADD, MVT::i32, + DAG.getRegister(V8::I6, MVT::i32), + DAG.getConstant(VarArgsFrameOffset, MVT::i32)); + return DAG.getNode(ISD::STORE, MVT::Other, Chain, Offset, + VAListP, DAG.getSrcValue(VAListV)); } std::pairSDOperand,SDOperand SparcV8TargetLowering:: ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp
Changes in directory llvm/lib/Target/SparcV8: SparcV8ISelDAGToDAG.cpp updated: 1.36 - 1.37 --- Log message: fix something-o --- Diffs of the changes: (+1 -1) SparcV8ISelDAGToDAG.cpp |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp diff -u llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp:1.36 llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp:1.37 --- llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp:1.36Fri Dec 23 00:37:38 2005 +++ llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp Fri Dec 23 01:08:39 2005 @@ -625,7 +625,7 @@ return DAG.getNode(ISD::BIT_CONVERT, MVT::i32, Op); case ISD::SINT_TO_FP: { assert(Op.getOperand(0).getValueType() == MVT::i32); -Op = DAG.getNode(ISD::BIT_CONVERT, MVT::f32, Op); +Op = DAG.getNode(ISD::BIT_CONVERT, MVT::f32, Op.getOperand(0)); // Convert the int value to FP in an FP register. return DAG.getNode(V8ISD::ITOF, Op.getValueType(), Op); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
Changes in directory llvm/lib/CodeGen/SelectionDAG: LegalizeDAG.cpp updated: 1.245 - 1.246 --- Log message: Allow custom lowering of LOAD, EXTLOAD, ZEXTLOAD, STORE, and TRUNCSTORE. Not currently used. --- Diffs of the changes: (+84 -15) LegalizeDAG.cpp | 99 +++- 1 files changed, 84 insertions(+), 15 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.245 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.246 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.245 Thu Dec 22 18:52:30 2005 +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Fri Dec 23 01:29:34 2005 @@ -1040,23 +1040,43 @@ Result = LegalizeOp(Result); // Relegalize new nodes. } break; - case ISD::LOAD: + case ISD::LOAD: { Tmp1 = LegalizeOp(Node-getOperand(0)); // Legalize the chain. Tmp2 = LegalizeOp(Node-getOperand(1)); // Legalize the pointer. -if (Tmp1 != Node-getOperand(0) || -Tmp2 != Node-getOperand(1)) - Result = DAG.getLoad(Node-getValueType(0), Tmp1, Tmp2, - Node-getOperand(2)); -else - Result = SDOperand(Node, 0); +MVT::ValueType VT = Node-getValueType(0); +switch (TLI.getOperationAction(Node-getOpcode(), VT)) { +default: assert(0 This action is not supported yet!); +case TargetLowering::Custom: { + SDOperand Op = DAG.getLoad(Node-getValueType(0), + Tmp1, Tmp2, Node-getOperand(2)); + SDOperand Tmp = TLI.LowerOperation(Op, DAG); + if (Tmp.Val) { +Result = LegalizeOp(Tmp); +// Since loads produce two values, make sure to remember that we legalized +// both of them. +AddLegalizedOperand(SDOperand(Node, 0), Result); +AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1)); +return Result.getValue(Op.ResNo); + } + // FALLTHROUGH if the target thinks it is legal. +} +case TargetLowering::Legal: + if (Tmp1 != Node-getOperand(0) || + Tmp2 != Node-getOperand(1)) +Result = DAG.getLoad(Node-getValueType(0), Tmp1, Tmp2, + Node-getOperand(2)); + else +Result = SDOperand(Node, 0); -// Since loads produce two values, make sure to remember that we legalized -// both of them. -AddLegalizedOperand(SDOperand(Node, 0), Result); -AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1)); -return Result.getValue(Op.ResNo); - + // Since loads produce two values, make sure to remember that we legalized + // both of them. + AddLegalizedOperand(SDOperand(Node, 0), Result); + AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1)); + return Result.getValue(Op.ResNo); +} +assert(0 Unreachable); + } case ISD::EXTLOAD: case ISD::SEXTLOAD: case ISD::ZEXTLOAD: { @@ -1076,6 +1096,21 @@ AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1)); return Result.getValue(Op.ResNo); +case TargetLowering::Custom: { + SDOperand Op = DAG.getExtLoad(Node-getOpcode(), Node-getValueType(0), +Tmp1, Tmp2, Node-getOperand(2), +SrcVT); + SDOperand Tmp = TLI.LowerOperation(Op, DAG); + if (Tmp.Val) { +Result = LegalizeOp(Tmp); +// Since loads produce two values, make sure to remember that we legalized +// both of them. +AddLegalizedOperand(SDOperand(Node, 0), Result); +AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1)); +return Result.getValue(Op.ResNo); + } + // FALLTHROUGH if the target thinks it is legal. +} case TargetLowering::Legal: if (Tmp1 != Node-getOperand(0) || Tmp2 != Node-getOperand(1)) @@ -1234,7 +1269,7 @@ } } break; - case ISD::STORE: + case ISD::STORE: { Tmp1 = LegalizeOp(Node-getOperand(0)); // Legalize the chain. Tmp2 = LegalizeOp(Node-getOperand(2)); // Legalize the pointer. @@ -1264,6 +1299,22 @@ Tmp2 != Node-getOperand(2)) Result = DAG.getNode(ISD::STORE, MVT::Other, Tmp1, Val, Tmp2, Node-getOperand(3)); + + MVT::ValueType VT = Result.Val-getOperand(1).getValueType(); + switch (TLI.getOperationAction(Result.Val-getOpcode(), VT)) { +default: assert(0 This action is not supported yet!); +case TargetLowering::Custom: { + SDOperand Tmp = TLI.LowerOperation(Result, DAG); + if (Tmp.Val) { +Result = LegalizeOp(Tmp); +break; + } + // FALLTHROUGH if the target thinks it is legal. +} +case TargetLowering::Legal: + // Nothing to do. + break; + } break; } case Promote: @@ -1305,6 +1356,7 @@ break; } break; + } case ISD::PCMARKER: Tmp1 =