From isanbard at gmail.com Mon Apr 7 00:47:52 2008 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 07 Apr 2008 05:47:52 -0000 Subject: [llvm-commits] [llvm] r49317 - /llvm/trunk/tools/bugpoint/CrashDebugger.cpp Message-ID: <200804070547.m375lrt5002862@zion.cs.uiuc.edu> Author: void Date: Mon Apr 7 00:47:52 2008 New Revision: 49317 URL: http://llvm.org/viewvc/llvm-project?rev=49317&view=rev Log: Remove tabs. Patch by Mike Stump! Modified: llvm/trunk/tools/bugpoint/CrashDebugger.cpp Modified: llvm/trunk/tools/bugpoint/CrashDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/CrashDebugger.cpp?rev=49317&r1=49316&r2=49317&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/CrashDebugger.cpp (original) +++ llvm/trunk/tools/bugpoint/CrashDebugger.cpp Mon Apr 7 00:47:52 2008 @@ -309,8 +309,8 @@ // Add a new return instruction of the appropriate type... const Type *RetTy = BB->getParent()->getReturnType(); - ReturnInst::Create(RetTy == Type::VoidTy ? 0 : - Constant::getNullValue(RetTy), BB); + ReturnInst::Create(RetTy == Type::VoidTy ? 0 : + Constant::getNullValue(RetTy), BB); } // The CFG Simplifier pass may delete one of the basic blocks we are From christopher.lamb at gmail.com Mon Apr 7 01:43:42 2008 From: christopher.lamb at gmail.com (Christopher Lamb) Date: Sun, 6 Apr 2008 23:43:42 -0700 Subject: [llvm-commits] [llvm] r49000 - /llvm/trunk/lib/System/Unix/Process.inc In-Reply-To: <200803312219.m2VMJQVN002954@zion.cs.uiuc.edu> References: <200803312219.m2VMJQVN002954@zion.cs.uiuc.edu> Message-ID: Hi Nate, This broke turning off crash dumping on my system, the previous code seemed to work fine. I'm running OS X 10.4.11. -- Chris On Mar 31, 2008, at 3:19 PM, Nate Begeman wrote: > Author: sampo > Date: Mon Mar 31 17:19:25 2008 > New Revision: 49000 > > URL: http://llvm.org/viewvc/llvm-project?rev=49000&view=rev > Log: > Actually disable crash reporting on Mac OS X, returning bugpoint to > speedy > crash miscompilations. > > Modified: > llvm/trunk/lib/System/Unix/Process.inc > > Modified: llvm/trunk/lib/System/Unix/Process.inc > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/ > Process.inc?rev=49000&r1=48999&r2=49000&view=diff > > ====================================================================== > ======== > --- llvm/trunk/lib/System/Unix/Process.inc (original) > +++ llvm/trunk/lib/System/Unix/Process.inc Mon Mar 31 17:19:25 2008 > @@ -123,10 +123,6 @@ > return getgid(); > } > > -#ifdef HAVE_MACH_MACH_H > -#include > -#endif > - > // Some LLVM programs such as bugpoint produce core files as a > normal part of > // their operation. To prevent the disk from filling up, this > function > // does what's necessary to prevent their generation. > @@ -138,25 +134,12 @@ > #endif > > #ifdef HAVE_MACH_MACH_H > - // Disable crash reporting on Mac OS/X. > - > - // get information about the original set of exception ports for > the task > - mach_msg_type_number_t Count = 0; > - exception_mask_t OriginalMasks[EXC_TYPES_COUNT]; > - exception_port_t OriginalPorts[EXC_TYPES_COUNT]; > - exception_behavior_t OriginalBehaviors[EXC_TYPES_COUNT]; > - thread_state_flavor_t OriginalFlavors[EXC_TYPES_COUNT]; > - kern_return_t err = > - task_get_exception_ports(mach_task_self(), EXC_MASK_ALL, > OriginalMasks, > - &Count, OriginalPorts, > OriginalBehaviors, > - OriginalFlavors); > - if (err == KERN_SUCCESS) { > - // replace each with MACH_PORT_NULL. > - for (unsigned i = 0; i != Count; ++i) > - task_set_exception_ports(mach_task_self(), OriginalMasks[i], > - MACH_PORT_NULL, OriginalBehaviors[i], > - OriginalFlavors[i]); > - } > + // Disable crash reporting on Mac OS X. > + signal(SIGABRT, _exit); > + signal(SIGILL, _exit); > + signal(SIGFPE, _exit); > + signal(SIGSEGV, _exit); > + signal(SIGBUS, _exit); > #endif > } > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -- Christopher Lamb -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080406/15de5ebe/attachment.html From edwintorok at gmail.com Mon Apr 7 01:49:41 2008 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Mon, 07 Apr 2008 09:49:41 +0300 Subject: [llvm-commits] [llvm] r49293 - in /llvm/trunk/lib/AsmParser: llvmAsmParser.cpp.cvs llvmAsmParser.h.cvs llvmAsmParser.y.cvs In-Reply-To: <200804062307.m36N7tmb024050@zion.cs.uiuc.edu> References: <200804062307.m36N7tmb024050@zion.cs.uiuc.edu> Message-ID: <47F9C405.1070609@gmail.com> Gabor Greif wrote: > Author: ggreif > Date: Sun Apr 6 18:07:54 2008 > New Revision: 49293 > > URL: http://llvm.org/viewvc/llvm-project?rev=49293&view=rev > Log: > regenerate > > Modified: > llvm/trunk/lib/AsmParser/llvmAsmParser.cpp.cvs > llvm/trunk/lib/AsmParser/llvmAsmParser.h.cvs > llvm/trunk/lib/AsmParser/llvmAsmParser.y.cvs > > Modified: llvm/trunk/lib/AsmParser/llvmAsmParser.cpp.cvs > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/llvmAsmParser.cpp.cvs?rev=49293&r1=49292&r2=49293&view=diff > > ============================================================================== > --- llvm/trunk/lib/AsmParser/llvmAsmParser.cpp.cvs (original) > +++ llvm/trunk/lib/AsmParser/llvmAsmParser.cpp.cvs Sun Apr 6 18:07:54 2008 > @@ -1,386 +1,167 @@ > -/* A Bison parser, made by GNU Bison 2.3. */ > > -/* Skeleton implementation for Bison's Yacc-like parsers in C > +/* A Bison parser, made from /Users/ggreif/llvm/lib/AsmParser/llvmAsmParser.y > + by GNU Bison version 1.28 */ Hi Gabor, Did you regenerate with an older bison? --Edwin From baldrick at free.fr Mon Apr 7 02:28:56 2008 From: baldrick at free.fr (Duncan Sands) Date: Mon, 7 Apr 2008 09:28:56 +0200 Subject: [llvm-commits] [llvm-gcc-4.2] r49253 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp In-Reply-To: References: <200804051841.m35IfRKR008765@zion.cs.uiuc.edu> Message-ID: <200804070928.56685.baldrick@free.fr> Hi, > On MacOS there are various parts of the system that need to be able to > do stack trackbacks at runtime. On x86-32 this is done by > disassembling the code; for this to work -fenable-fp-elim must be > turned off. There is a significant performance hit for that, so > x86-64 does it by looking at Dwarf unwind info. For this to work > unwind info must be present for all functions. This consideration is > independent of exceptions. > > The way this is done is that -funwind-tables is implicitly passed to > all compilations on Darwin x86-64. This has the effect of generating > the Dwarf traceback tables (what you call frame moves, I believe) in > all cases. (gcc does not even generate the ".eh=0" elision in leaf > functions; I think this is a bug in llvm-gcc, although so far it > hasn't broken anything.) For languages that normally use exceptions, C > ++ and Obj-C++, -fexceptions is also passed, which additionally > generates landing pad info. > > Now we can argue about what -funwind-tables and -fexceptions ought to > mean, it is certainly not clear in the documentation, but I think what > shipping gcc does with them is a good place to start. If these > switches behave differently in another environment I suppose we need > to make their behavior dependent on the environment; I have no > knowledge of that right now. In what follows I am going to use the > Darwin x86-64 meanings of these flags. > > -fexceptions does not imply -funwind-tables, although they generate > some of the same info. The difference is that info produced by virtue > of -funwind-tables cannot be removed; the OS needs it. It would be OK > for prune-eh to remove landing pad info. If -fexceptions is present > and -funwind-tables is not, it is OK to remove both. I believe the > current behavior matches this. I think we all agree about what the final effect of -funwind-tables should be. For me the only question is whether -funwind-tables should be represented in the IR or not, and if so how. My preference goes to an llc option. This has the disadvantage that you can't control the -funwind-tables effect on a per-function basis, but based on the Darwin use case you describe that isn't needed anyway (nor for Ada). > Now, how do we reconcile this with what Ada does, and what info do we > put in the IR to make it happen? Ada is getting -funwind-tables because it uses -fnon-call-exceptions (which we don't currently support). I actually don't see why -fnon-call-exceptions would need -funwind-tables; it will I guess become clear one way or another when support is added for -fnon-call-exceptions. However Ada also has a stack traceback facility which uses the dwarf unwinder, and for that to work it presumably needs -funwind-tables. In short: Ada doesn't seem to need anything particularly special here, it's basically the same as Darwin. Ciao, Duncan. From baldrick at free.fr Mon Apr 7 02:36:28 2008 From: baldrick at free.fr (Duncan Sands) Date: Mon, 7 Apr 2008 09:36:28 +0200 Subject: [llvm-commits] [llvm] r49299 - /llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp In-Reply-To: <200804070008.m3708nwM025822@zion.cs.uiuc.edu> References: <200804070008.m3708nwM025822@zion.cs.uiuc.edu> Message-ID: <200804070936.31569.baldrick@free.fr> Hi, > Mark calls to llvm.stacksave, llvm.stackrestore as > nounwind. When such calls are inlined into something > else that is invoked, they were getting changed to invokes, > which is badness. > CallInst *SavedPtr = CallInst::Create(StackSave, "savedstack", > FirstNewBlock->begin()); if you get hold of an intrinsic using Intrinsic::getDeclaration then it is automagically marked nounwind. Is there any reason not to use Intrinsic::getDeclaration here? Ciao, Duncan. From baldrick at free.fr Mon Apr 7 03:22:07 2008 From: baldrick at free.fr (Duncan Sands) Date: Mon, 7 Apr 2008 10:22:07 +0200 Subject: [llvm-commits] [llvm] r49299 - /llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp In-Reply-To: <200804070008.m3708nwM025822@zion.cs.uiuc.edu> References: <200804070008.m3708nwM025822@zion.cs.uiuc.edu> Message-ID: <200804071022.10433.baldrick@free.fr> > Mark calls to llvm.stacksave, llvm.stackrestore as > nounwind. When such calls are inlined into something > else that is invoked, they were getting changed to invokes, > which is badness. Testcase? D. From resistor at mac.com Mon Apr 7 04:59:11 2008 From: resistor at mac.com (Owen Anderson) Date: Mon, 07 Apr 2008 09:59:11 -0000 Subject: [llvm-commits] [llvm] r49329 - in /llvm/trunk: include/llvm/Analysis/Dominators.h lib/Transforms/Scalar/GVN.cpp Message-ID: <200804070959.m379xD5u019108@zion.cs.uiuc.edu> Author: resistor Date: Mon Apr 7 04:59:07 2008 New Revision: 49329 URL: http://llvm.org/viewvc/llvm-project?rev=49329&view=rev Log: Make GVN more memory efficient, particularly on code that contains a large number of allocations, which GVN can't optimize anyways. Modified: llvm/trunk/include/llvm/Analysis/Dominators.h llvm/trunk/lib/Transforms/Scalar/GVN.cpp Modified: llvm/trunk/include/llvm/Analysis/Dominators.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/Dominators.h?rev=49329&r1=49328&r2=49329&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/Dominators.h (original) +++ llvm/trunk/include/llvm/Analysis/Dominators.h Mon Apr 7 04:59:07 2008 @@ -103,6 +103,10 @@ return C; } + size_t getNumChildren() const { + return Children.size(); + } + void setIDom(DomTreeNodeBase *NewIDom) { assert(IDom && "No immediate dominator?"); if (IDom != NewIDom) { Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=49329&r1=49328&r2=49329&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Mon Apr 7 04:59:07 2008 @@ -1593,6 +1593,11 @@ if (StoreInst *SI = dyn_cast(I)) return processStore(SI, toErase); + // Allocations are always uniquely numbered, so we can save time and memory + // by fast failing them. + if (isa(I)) + return false; + if (MemCpyInst* M = dyn_cast(I)) { MemoryDependenceAnalysis& MD = getAnalysis(); @@ -1692,6 +1697,7 @@ SmallVector toErase; DenseMap lastSeenLoad; + DenseMap numChildrenVisited; // Top-down walk of the dominator tree for (df_iterator DI = df_begin(DT.getRootNode()), @@ -1704,8 +1710,16 @@ BasicBlock* BB = DI->getBlock(); // A block inherits AVAIL_OUT from its dominator - if (DI->getIDom() != 0) + if (DI->getIDom() != 0) { currAvail = availableOut[DI->getIDom()->getBlock()]; + + numChildrenVisited[DI->getIDom()]++; + + if (numChildrenVisited[DI->getIDom()] == DI->getIDom()->getNumChildren()) { + availableOut.erase(DI->getIDom()->getBlock()); + numChildrenVisited.erase(DI->getIDom()); + } + } for (BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE;) { From romix.llvm at googlemail.com Mon Apr 7 05:02:09 2008 From: romix.llvm at googlemail.com (Roman Levenstein) Date: Mon, 7 Apr 2008 11:02:09 +0100 Subject: [llvm-commits] Fwd: [llvm] r48822 - in /llvm/trunk: include/llvm/CodeGen/ScheduleDAG.h include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/DAGCombiner.cpp lib/CodeGen/SelectionDAG/LegalizeDAG.cpp lib/CodeGen/SelectionDAG/LegalizeTyp Message-ID: Hi Christopher, Thanks a lot! The set of commands suggested by you solves my problem. -Roman 2008/4/5, Christopher Lamb : > > > On Apr 4, 2008, at 8:39 AM, Roman Levenstein wrote: > > ---------- Forwarded message ---------- > From: Roman Levenstein > Date: 04.04.2008 16:28 > Subject: Re: [llvm-commits] [llvm] r48822 - in /llvm/trunk: > include/llvm/CodeGen/ScheduleDAG.h > include/llvm/CodeGen/SelectionDAGNodes.h > lib/CodeGen/SelectionDAG/DAGCombiner.cpp > lib/CodeGen/SelectionDAG/LegalizeDAG.cpp > lib/CodeGen/SelectionDAG/LegalizeTypes.cp > To: Duncan Sands > > > Hi Duncan, > > 2008/4/4, Duncan Sands : > > > Hi, > > > > I have a stupid question regarding this. My source tree is newer than > that revision and some other unrelated things are changed in the > affected files already. Therefore I cannot so simply commit the fix. > How can I do that? Probably I can edit the backed-out patch, but how > do I commit this patch file to the SVN? Is it possible to commit the > file containing a patch, i.e. without SVN analyzing the source files > on my side? > > > do > svn update > This will auto-merge in the upstream changes. If there is a conflict > you will see letter C and will need to fix up the conflict by hand-editing > (the conflicted parts are marked with <<<< etc in the file). Once you > have fixed up the conflict, you can do > svn resolved file_name > If everything seems fine, you can do > svn commit > > The basic rule is that you can't commit unless you have the latest version > of the file; using svn update makes sure you have the latest version. > > > Thanks for your comment. But I think I did not explained my problem > in a proper way. The original commit was approved and was implementing > a certain way of handling use lists for SDNode objects. Then this > commit was reverted by Evan, because Dan has found some issues with > this patch. But in the mean time I have changed a lot in the > implementation of the use-lists in my local copy. > > I know how to fix the original commit. Evan asked me to fix it and to > commit again this fixed OLD version of my use-lists patch. But I don't > have this version any more in my local copy, since I completely > changed it. I only have my old commit in a form of a patch file. My > question is: How can I commit the OLD version fixed by me? I hope the > situation is more clear now? > This problem is a bit of a pain to deal with. Here's what I normally do: > > save off my current changes: > svn diff > current_changes.patch > > revert the tree: > find llvm/ | xargs svn revert > > update to latest: > svn update > > apply the old patch: > patch -p0 < old_changes.patch > > resolve conflicts, modify files, build, test. If everything works: > svn commit > > then patch my latest working state back in: > patch -p0 < current_changes.patch > > I suppose you could get around some of this by maintaining two working > copies, but this is one of those annoying things about this style of SCM. > > -- > Christopher Lamb > > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > From romix.llvm at googlemail.com Mon Apr 7 05:06:39 2008 From: romix.llvm at googlemail.com (Roman Levenstein) Date: Mon, 07 Apr 2008 10:06:39 -0000 Subject: [llvm-commits] [llvm] r49330 - in /llvm/trunk: include/llvm/CodeGen/ScheduleDAG.h include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/DAGCombiner.cpp lib/CodeGen/SelectionDAG/LegalizeDAG.cpp lib/CodeGen/SelectionDAG/LegalizeTypes.cpp lib/CodeGen/SelectionDAG/LegalizeTypes.h lib/CodeGen/SelectionDAG/ScheduleDAG.cpp lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Target/PowerPC/PPCISelLowering.cpp lib/Target/X86/X86ISelDAGToDAG.cpp lib/Target/X86/X86ISelLowering.cpp Message-ID: <200804071006.m37A6h7n019338@zion.cs.uiuc.edu> Author: romix Date: Mon Apr 7 05:06:32 2008 New Revision: 49330 URL: http://llvm.org/viewvc/llvm-project?rev=49330&view=rev Log: Re-commit of the r48822, where the infinite looping problem discovered by Dan Gohman is fixed. Modified: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h?rev=49330&r1=49329&r2=49330&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h Mon Apr 7 05:06:32 2008 @@ -333,7 +333,7 @@ /// register number for the results of the node. /// void EmitNode(SDNode *Node, unsigned InstNo, - DenseMap &VRBaseMap); + DenseMap &VRBaseMap); /// EmitNoop - Emit a noop instruction. /// @@ -351,11 +351,11 @@ /// EmitSubregNode - Generate machine code for subreg nodes. /// void EmitSubregNode(SDNode *Node, - DenseMap &VRBaseMap); + DenseMap &VRBaseMap); /// getVR - Return the virtual register corresponding to the specified result /// of the specified node. - unsigned getVR(SDOperand Op, DenseMap &VRBaseMap); + unsigned getVR(SDOperand Op, DenseMap &VRBaseMap); /// getDstOfCopyToRegUse - If the only use of the specified result number of /// node is a CopyToReg, return its destination register. Return 0 otherwise. @@ -363,7 +363,7 @@ void AddOperand(MachineInstr *MI, SDOperand Op, unsigned IIOpNum, const TargetInstrDesc *II, - DenseMap &VRBaseMap); + DenseMap &VRBaseMap); void AddMemOperand(MachineInstr *MI, const MemOperand &MO); @@ -373,11 +373,11 @@ /// implicit physical register output. void EmitCopyFromReg(SDNode *Node, unsigned ResNo, unsigned InstNo, unsigned SrcReg, - DenseMap &VRBaseMap); + DenseMap &VRBaseMap); void CreateVirtualRegisters(SDNode *Node, MachineInstr *MI, const TargetInstrDesc &II, - DenseMap &VRBaseMap); + DenseMap &VRBaseMap); /// EmitLiveInCopy - Emit a copy for a live in physical register. If the /// physical register has only a single copy use, then coalesced the copy Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=49330&r1=49329&r2=49330&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Mon Apr 7 05:06:32 2008 @@ -779,7 +779,7 @@ //===----------------------------------------------------------------------===// -/// SDOperand - Unlike LLVM values, Selection DAG nodes may return multiple +/// SDOperandImpl - Unlike LLVM values, Selection DAG nodes may return multiple /// values as the result of a computation. Many nodes return multiple values, /// from loads (which define a token and a return value) to ADDC (which returns /// a result and a carry value), to calls (which may return an arbitrary number @@ -787,28 +787,28 @@ /// /// As such, each use of a SelectionDAG computation must indicate the node that /// computes it as well as which return value to use from that node. This pair -/// of information is represented with the SDOperand value type. +/// of information is represented with the SDOperandImpl value type. /// -class SDOperand { +class SDOperandImpl { public: SDNode *Val; // The node defining the value we are using. unsigned ResNo; // Which return value of the node we are using. - SDOperand() : Val(0), ResNo(0) {} - SDOperand(SDNode *val, unsigned resno) : Val(val), ResNo(resno) {} + SDOperandImpl() : Val(0), ResNo(0) {} + SDOperandImpl(SDNode *val, unsigned resno) : Val(val), ResNo(resno) {} - bool operator==(const SDOperand &O) const { + bool operator==(const SDOperandImpl &O) const { return Val == O.Val && ResNo == O.ResNo; } - bool operator!=(const SDOperand &O) const { + bool operator!=(const SDOperandImpl &O) const { return !operator==(O); } - bool operator<(const SDOperand &O) const { + bool operator<(const SDOperandImpl &O) const { return Val < O.Val || (Val == O.Val && ResNo < O.ResNo); } - SDOperand getValue(unsigned R) const { - return SDOperand(Val, R); + SDOperandImpl getValue(unsigned R) const { + return SDOperandImpl(Val, R); } // isOperandOf - Return true if this node is an operand of N. @@ -827,7 +827,7 @@ // Forwarding methods - These forward to the corresponding methods in SDNode. inline unsigned getOpcode() const; inline unsigned getNumOperands() const; - inline const SDOperand &getOperand(unsigned i) const; + inline const SDOperandImpl &getOperand(unsigned i) const; inline uint64_t getConstantOperandVal(unsigned i) const; inline bool isTargetOpcode() const; inline unsigned getTargetOpcode() const; @@ -838,7 +838,8 @@ /// side-effecting instructions. In practice, this looks through token /// factors and non-volatile loads. In order to remain efficient, this only /// looks a couple of nodes in, it does not do an exhaustive search. - bool reachesChainWithoutSideEffects(SDOperand Dest, unsigned Depth = 2) const; + bool reachesChainWithoutSideEffects(SDOperandImpl Dest, + unsigned Depth = 2) const; /// hasOneUse - Return true if there is exactly one operation using this /// result value of the defining operator. @@ -850,14 +851,18 @@ }; -template<> struct DenseMapInfo { - static inline SDOperand getEmptyKey() { return SDOperand((SDNode*)-1, -1U); } - static inline SDOperand getTombstoneKey() { return SDOperand((SDNode*)-1, 0);} - static unsigned getHashValue(const SDOperand &Val) { +template<> struct DenseMapInfo { + static inline SDOperandImpl getEmptyKey() { + return SDOperandImpl((SDNode*)-1, -1U); + } + static inline SDOperandImpl getTombstoneKey() { + return SDOperandImpl((SDNode*)-1, 0); + } + static unsigned getHashValue(const SDOperandImpl &Val) { return ((unsigned)((uintptr_t)Val.Val >> 4) ^ (unsigned)((uintptr_t)Val.Val >> 9)) + Val.ResNo; } - static bool isEqual(const SDOperand &LHS, const SDOperand &RHS) { + static bool isEqual(const SDOperandImpl &LHS, const SDOperandImpl &RHS) { return LHS == RHS; } static bool isPod() { return true; } @@ -865,6 +870,88 @@ /// simplify_type specializations - Allow casting operators to work directly on /// SDOperands as if they were SDNode*'s. +template<> struct simplify_type { + typedef SDNode* SimpleType; + static SimpleType getSimplifiedValue(const SDOperandImpl &Val) { + return static_cast(Val.Val); + } +}; +template<> struct simplify_type { + typedef SDNode* SimpleType; + static SimpleType getSimplifiedValue(const SDOperandImpl &Val) { + return static_cast(Val.Val); + } +}; + +/// SDOperand - Represents a use of the SDNode referred by +/// the SDOperandImpl. +class SDOperand: public SDOperandImpl { + /// parent - Parent node of this operand. + SDNode *parent; + /// Prev, next - Pointers to the uses list of the SDNode referred by + /// this operand. + SDOperand **Prev, *Next; +public: + friend class SDNode; + SDOperand(): SDOperandImpl(), parent(NULL), Prev(NULL), Next(NULL) {} + + SDOperand(SDNode *val, unsigned resno) : + SDOperandImpl(val,resno), parent(NULL), Prev(NULL), Next(NULL) {} + + SDOperand(const SDOperandImpl& Op): SDOperandImpl(Op),parent(NULL), + Prev(NULL), Next(NULL) { + } + + SDOperand& operator= (SDOperandImpl& Op) { + *(SDOperandImpl*)this = Op; + Next = NULL; + Prev = NULL; + return *this; + } + + SDOperand& operator= (const SDOperandImpl& Op) { + *(SDOperandImpl*)this = Op; + Next = NULL; + Prev = NULL; + return *this; + } + + SDOperand& operator= (SDOperand& Op) { + *(SDOperandImpl*)this = Op; + Next = NULL; + Prev = NULL; + return *this; + } + + SDOperand& operator= (const SDOperand& Op) { + *(SDOperandImpl*)this = Op; + Next = NULL; + Prev = NULL; + return *this; + } + + SDOperand * getNext() { return Next; } + + SDNode *getUser() { return parent; } + void setUser(SDNode *p) { parent = p; } + +protected: + void addToList(SDOperand **List) { + Next = *List; + if (Next) Next->Prev = &Next; + Prev = List; + *List = this; + } + + void removeFromList() { + *Prev = Next; + if (Next) Next->Prev = Prev; + } +}; + + +/// simplify_type specializations - Allow casting operators to work directly on +/// SDOperands as if they were SDNode*'s. template<> struct simplify_type { typedef SDNode* SimpleType; static SimpleType getSimplifiedValue(const SDOperand &Val) { @@ -882,6 +969,7 @@ /// SDNode - Represents one node in the SelectionDAG. /// class SDNode : public FoldingSetNode { +private: /// NodeType - The operation that this node performs. /// unsigned short NodeType; @@ -909,10 +997,15 @@ SDNode *Prev, *Next; friend struct ilist_traits; - /// Uses - These are all of the SDNode's that use a value produced by this - /// node. - SmallVector Uses; - + /// UsesSize - The size of the uses list. + unsigned UsesSize; + + /// Uses - List of uses for this SDNode. + SDOperand *Uses; + + /// addUse - add SDOperand to the list of uses. + void addUse(SDOperand &U) { U.addToList(&Uses); } + // Out-of-line virtual method to give class a home. virtual void ANCHOR(); public: @@ -931,9 +1024,9 @@ return NodeType - ISD::BUILTIN_OP_END; } - size_t use_size() const { return Uses.size(); } - bool use_empty() const { return Uses.empty(); } - bool hasOneUse() const { return Uses.size() == 1; } + size_t use_size() const { return UsesSize; } + bool use_empty() const { return Uses == NULL; } + bool hasOneUse() const { return use_size() == 1; } /// getNodeId - Return the unique node id. /// @@ -942,9 +1035,75 @@ /// setNodeId - Set unique node id. void setNodeId(int Id) { NodeId = Id; } - typedef SmallVector::const_iterator use_iterator; - use_iterator use_begin() const { return Uses.begin(); } - use_iterator use_end() const { return Uses.end(); } + /// use_iterator - This class provides iterator support for SDOperand + /// operands that use a specific SDNode. + class use_iterator + : public forward_iterator { + SDOperand *Op; + explicit use_iterator(SDOperand *op) : Op(op) { + } + friend class SDNode; + public: + typedef forward_iterator::reference reference; + typedef forward_iterator::pointer pointer; + + use_iterator(const use_iterator &I) : Op(I.Op) {} + use_iterator() : Op(0) {} + + bool operator==(const use_iterator &x) const { + return Op == x.Op; + } + bool operator!=(const use_iterator &x) const { + return !operator==(x); + } + + /// atEnd - return true if this iterator is at the end of uses list. + bool atEnd() const { return Op == 0; } + + // Iterator traversal: forward iteration only. + use_iterator &operator++() { // Preincrement + assert(Op && "Cannot increment end iterator!"); + Op = Op->getNext(); + return *this; + } + + use_iterator operator++(int) { // Postincrement + use_iterator tmp = *this; ++*this; return tmp; + } + + + /// getOperandNum - Retrive a number of a current operand. + unsigned getOperandNum() const { + assert(Op && "Cannot dereference end iterator!"); + return (Op - Op->getUser()->OperandList); + } + + /// Retrieve a reference to the current operand. + SDOperand &operator*() const { + assert(Op && "Cannot dereference end iterator!"); + return *Op; + } + + /// Retrieve a pointer to the current operand. + SDOperand *operator->() const { + assert(Op && "Cannot dereference end iterator!"); + return Op; + } + }; + + /// use_begin/use_end - Provide iteration support to walk over all uses + /// of an SDNode. + + use_iterator use_begin(SDNode *node) const { + return use_iterator(node->Uses); + } + + use_iterator use_begin() const { + return use_iterator(Uses); + } + + static use_iterator use_end() { return use_iterator(0); } + /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the /// indicated value. This method ignores uses of other values defined by this @@ -982,7 +1141,7 @@ return OperandList[Num]; } - typedef const SDOperand* op_iterator; + typedef SDOperand* op_iterator; op_iterator op_begin() const { return OperandList; } op_iterator op_end() const { return OperandList+NumOperands; } @@ -1039,25 +1198,28 @@ } SDNode(unsigned Opc, SDVTList VTs, const SDOperand *Ops, unsigned NumOps) - : NodeType(Opc), NodeId(-1) { + : NodeType(Opc), NodeId(-1), UsesSize(0), Uses(NULL) { OperandsNeedDelete = true; NumOperands = NumOps; OperandList = NumOps ? new SDOperand[NumOperands] : 0; for (unsigned i = 0; i != NumOps; ++i) { OperandList[i] = Ops[i]; - Ops[i].Val->Uses.push_back(this); + OperandList[i].setUser(this); + Ops[i].Val->addUse(OperandList[i]); + ++Ops[i].Val->UsesSize; } ValueList = VTs.VTs; NumValues = VTs.NumVTs; Prev = 0; Next = 0; } - SDNode(unsigned Opc, SDVTList VTs) : NodeType(Opc), NodeId(-1) { + + SDNode(unsigned Opc, SDVTList VTs) + : NodeType(Opc), NodeId(-1), UsesSize(0), Uses(NULL) { OperandsNeedDelete = false; // Operands set with InitOperands. NumOperands = 0; OperandList = 0; - ValueList = VTs.VTs; NumValues = VTs.NumVTs; Prev = 0; Next = 0; @@ -1070,9 +1232,14 @@ assert(OperandList == 0 && "Operands already set!"); NumOperands = NumOps; OperandList = Ops; + UsesSize = 0; + Uses = NULL; - for (unsigned i = 0; i != NumOps; ++i) - Ops[i].Val->Uses.push_back(this); + for (unsigned i = 0; i != NumOps; ++i) { + OperandList[i].setUser(this); + Ops[i].Val->addUse(OperandList[i]); + ++Ops[i].Val->UsesSize; + } } /// MorphNodeTo - This frees the operands of the current node, resets the @@ -1081,50 +1248,48 @@ void MorphNodeTo(unsigned Opc, SDVTList L, const SDOperand *Ops, unsigned NumOps); - void addUser(SDNode *User) { - Uses.push_back(User); + void addUser(unsigned i, SDNode *User) { + assert(User->OperandList[i].getUser() && "Node without parent"); + addUse(User->OperandList[i]); + ++UsesSize; } - void removeUser(SDNode *User) { - // Remove this user from the operand's use list. - for (unsigned i = Uses.size(); ; --i) { - assert(i != 0 && "Didn't find user!"); - if (Uses[i-1] == User) { - Uses[i-1] = Uses.back(); - Uses.pop_back(); - return; - } - } + + void removeUser(unsigned i, SDNode *User) { + assert(User->OperandList[i].getUser() && "Node without parent"); + SDOperand &Op = User->OperandList[i]; + Op.removeFromList(); + --UsesSize; } }; -// Define inline functions from the SDOperand class. +// Define inline functions from the SDOperandImpl class. -inline unsigned SDOperand::getOpcode() const { +inline unsigned SDOperandImpl::getOpcode() const { return Val->getOpcode(); } -inline MVT::ValueType SDOperand::getValueType() const { +inline MVT::ValueType SDOperandImpl::getValueType() const { return Val->getValueType(ResNo); } -inline unsigned SDOperand::getNumOperands() const { +inline unsigned SDOperandImpl::getNumOperands() const { return Val->getNumOperands(); } -inline const SDOperand &SDOperand::getOperand(unsigned i) const { +inline const SDOperandImpl &SDOperandImpl::getOperand(unsigned i) const { return Val->getOperand(i); } -inline uint64_t SDOperand::getConstantOperandVal(unsigned i) const { +inline uint64_t SDOperandImpl::getConstantOperandVal(unsigned i) const { return Val->getConstantOperandVal(i); } -inline bool SDOperand::isTargetOpcode() const { +inline bool SDOperandImpl::isTargetOpcode() const { return Val->isTargetOpcode(); } -inline unsigned SDOperand::getTargetOpcode() const { +inline unsigned SDOperandImpl::getTargetOpcode() const { return Val->getTargetOpcode(); } -inline bool SDOperand::hasOneUse() const { +inline bool SDOperandImpl::hasOneUse() const { return Val->hasNUsesOfValue(1, ResNo); } -inline bool SDOperand::use_empty() const { +inline bool SDOperandImpl::use_empty() const { return !Val->hasAnyUseOfValue(ResNo); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=49330&r1=49329&r2=49330&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Apr 7 05:06:32 2008 @@ -78,7 +78,7 @@ void AddUsersToWorkList(SDNode *N) { for (SDNode::use_iterator UI = N->use_begin(), UE = N->use_end(); UI != UE; ++UI) - AddToWorkList(*UI); + AddToWorkList(UI->getUser()); } /// visit - call the node-specific routine that knows how to fold each @@ -2704,7 +2704,7 @@ bool isTruncFree = TLI.isTruncateFree(N->getValueType(0), N0.getValueType()); for (SDNode::use_iterator UI = N0.Val->use_begin(), UE = N0.Val->use_end(); UI != UE; ++UI) { - SDNode *User = *UI; + SDNode *User = UI->getUser(); if (User == N) continue; // FIXME: Only extend SETCC N, N and SETCC N, c for now. @@ -2743,7 +2743,7 @@ bool BothLiveOut = false; for (SDNode::use_iterator UI = N->use_begin(), UE = N->use_end(); UI != UE; ++UI) { - SDNode *User = *UI; + SDNode *User = UI->getUser(); for (unsigned i = 0, e = User->getNumOperands(); i != e; ++i) { SDOperand UseOp = User->getOperand(i); if (UseOp.Val == N && UseOp.ResNo == 0) { @@ -3880,7 +3880,7 @@ MVT::ValueType VT = N->getValueType(0); // If this is fp_round(fpextend), don't fold it, allow ourselves to be folded. - if (N->hasOneUse() && (*N->use_begin())->getOpcode() == ISD::FP_ROUND) + if (N->hasOneUse() && (N->use_begin())->getOpcode() == ISD::FP_ROUND) return SDOperand(); // fold (fp_extend c1fp) -> c1fp @@ -4101,7 +4101,7 @@ bool RealUse = false; for (SDNode::use_iterator I = Ptr.Val->use_begin(), E = Ptr.Val->use_end(); I != E; ++I) { - SDNode *Use = *I; + SDNode *Use = I->getUser(); if (Use == N) continue; if (Use->isPredecessorOf(N)) @@ -4186,7 +4186,7 @@ for (SDNode::use_iterator I = Ptr.Val->use_begin(), E = Ptr.Val->use_end(); I != E; ++I) { - SDNode *Op = *I; + SDNode *Op = I->getUser(); if (Op == N || (Op->getOpcode() != ISD::ADD && Op->getOpcode() != ISD::SUB)) continue; @@ -4214,7 +4214,7 @@ bool TryNext = false; for (SDNode::use_iterator II = BasePtr.Val->use_begin(), EE = BasePtr.Val->use_end(); II != EE; ++II) { - SDNode *Use = *II; + SDNode *Use = II->getUser(); if (Use == Ptr.Val) continue; @@ -4224,7 +4224,7 @@ bool RealUse = false; for (SDNode::use_iterator III = Use->use_begin(), EEE = Use->use_end(); III != EEE; ++III) { - SDNode *UseUse = *III; + SDNode *UseUse = III->getUser(); if (!((UseUse->getOpcode() == ISD::LOAD && cast(UseUse)->getBasePtr().Val == Use) || (UseUse->getOpcode() == ISD::STORE && Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=49330&r1=49329&r2=49330&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Mon Apr 7 05:06:32 2008 @@ -85,17 +85,17 @@ /// LegalizedNodes - For nodes that are of legal width, and that have more /// than one use, this map indicates what regularized operand to use. This /// allows us to avoid legalizing the same thing more than once. - DenseMap LegalizedNodes; + DenseMap LegalizedNodes; /// PromotedNodes - For nodes that are below legal width, and that have more /// than one use, this map indicates what promoted value to use. This allows /// us to avoid promoting the same thing more than once. - DenseMap PromotedNodes; + DenseMap PromotedNodes; /// ExpandedNodes - For nodes that need to be expanded this map indicates /// which which operands are the expanded version of the input. This allows /// us to avoid expanding the same node more than once. - DenseMap > ExpandedNodes; + DenseMap > ExpandedNodes; /// SplitNodes - For vector nodes that need to be split, this map indicates /// which which operands are the split version of the input. This allows us @@ -308,7 +308,7 @@ // are now done. for (SDNode::use_iterator UI = N->use_begin(), E = N->use_end(); UI != E; ++UI) - Worklist.push_back(*UI); + Worklist.push_back(UI->getUser()); } assert(Order.size() == Visited.size() && @@ -381,7 +381,7 @@ E = Node->use_end(); UI != E; ++UI) { // Make sure to only follow users of our token chain. - SDNode *User = *UI; + SDNode *User = UI->getUser(); for (unsigned i = 0, e = User->getNumOperands(); i != e; ++i) if (User->getOperand(i) == TheChain) if (SDNode *Result = FindCallEndFromCallStart(User)) @@ -783,7 +783,7 @@ // Note that LegalizeOp may be reentered even from single-use nodes, which // means that we always must cache transformed nodes. - DenseMap::iterator I = LegalizedNodes.find(Op); + DenseMap::iterator I = LegalizedNodes.find(Op); if (I != LegalizedNodes.end()) return I->second; SDOperand Tmp1, Tmp2, Tmp3, Tmp4; @@ -1599,7 +1599,7 @@ // will cause this node to be legalized as well as handling libcalls right. if (LastCALLSEQ_END.Val != Node) { LegalizeOp(SDOperand(FindCallStartFromCallEnd(Node), 0)); - DenseMap::iterator I = LegalizedNodes.find(Op); + DenseMap::iterator I = LegalizedNodes.find(Op); assert(I != LegalizedNodes.end() && "Legalizing the call start should have legalized this node!"); return I->second; @@ -4136,7 +4136,7 @@ SDOperand Result; SDNode *Node = Op.Val; - DenseMap::iterator I = PromotedNodes.find(Op); + DenseMap::iterator I = PromotedNodes.find(Op); if (I != PromotedNodes.end()) return I->second; switch (Node->getOpcode()) { @@ -5841,7 +5841,7 @@ "Cannot expand to FP value or to larger int value!"); // See if we already expanded it. - DenseMap >::iterator I + DenseMap >::iterator I = ExpandedNodes.find(Op); if (I != ExpandedNodes.end()) { Lo = I->second.first; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp?rev=49330&r1=49329&r2=49330&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp Mon Apr 7 05:06:32 2008 @@ -137,7 +137,7 @@ for (SDNode::use_iterator UI = N->use_begin(), E = N->use_end(); UI != E; ++UI) { - SDNode *User = *UI; + SDNode *User = UI->getUser(); int NodeID = User->getNodeId(); assert(NodeID != ReadyToProcess && NodeID != Processed && "Invalid node id for user of unprocessed node!"); @@ -344,7 +344,7 @@ /// RemapNode - If the specified value was already legalized to another value, /// replace it by that value. void DAGTypeLegalizer::RemapNode(SDOperand &N) { - DenseMap::iterator I = ReplacedNodes.find(N); + DenseMap::iterator I = ReplacedNodes.find(N); if (I != ReplacedNodes.end()) { // Use path compression to speed up future lookups if values get multiply // replaced with other values. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h?rev=49330&r1=49329&r2=49330&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h Mon Apr 7 05:06:32 2008 @@ -110,27 +110,27 @@ /// PromotedNodes - For nodes that are below legal width, this map indicates /// what promoted value to use. - DenseMap PromotedNodes; + DenseMap PromotedNodes; /// ExpandedNodes - For nodes that need to be expanded this map indicates /// which operands are the expanded version of the input. - DenseMap > ExpandedNodes; + DenseMap > ExpandedNodes; /// FloatToIntedNodes - For floating point nodes converted to integers of /// the same size, this map indicates the converted value to use. - DenseMap FloatToIntedNodes; + DenseMap FloatToIntedNodes; /// ScalarizedNodes - For nodes that are <1 x ty>, this map indicates the /// scalar value of type 'ty' to use. - DenseMap ScalarizedNodes; + DenseMap ScalarizedNodes; /// SplitNodes - For nodes that need to be split this map indicates /// which operands are the expanded version of the input. - DenseMap > SplitNodes; + DenseMap > SplitNodes; /// ReplacedNodes - For nodes that have been replaced with another, /// indicates the replacement node to use. - DenseMap ReplacedNodes; + DenseMap ReplacedNodes; /// Worklist - This defines a worklist of nodes to process. In order to be /// pushed onto this worklist, all operands of a node must have already been Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp?rev=49330&r1=49329&r2=49330&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp Mon Apr 7 05:06:32 2008 @@ -137,11 +137,11 @@ bool HasFlagUse = false; for (SDNode::use_iterator UI = N->use_begin(), E = N->use_end(); UI != E; ++UI) - if (FlagVal.isOperandOf(*UI)) { + if (FlagVal.isOperandOf(UI->getUser())) { HasFlagUse = true; NodeSUnit->FlaggedNodes.push_back(N); SUnitMap[N].push_back(NodeSUnit); - N = *UI; + N = UI->getUser(); break; } if (!HasFlagUse) break; @@ -400,7 +400,7 @@ void ScheduleDAG::EmitCopyFromReg(SDNode *Node, unsigned ResNo, unsigned InstanceNo, unsigned SrcReg, - DenseMap &VRBaseMap) { + DenseMap &VRBaseMap) { unsigned VRBase = 0; if (TargetRegisterInfo::isVirtualRegister(SrcReg)) { // Just use the input register directly! @@ -416,7 +416,7 @@ bool MatchReg = true; for (SDNode::use_iterator UI = Node->use_begin(), E = Node->use_end(); UI != E; ++UI) { - SDNode *Use = *UI; + SDNode *Use = UI->getUser(); bool Match = true; if (Use->getOpcode() == ISD::CopyToReg && Use->getOperand(2).Val == Node && @@ -475,7 +475,7 @@ if (!Node->hasOneUse()) return 0; - SDNode *Use = *Node->use_begin(); + SDNode *Use = Node->use_begin()->getUser(); if (Use->getOpcode() == ISD::CopyToReg && Use->getOperand(2).Val == Node && Use->getOperand(2).ResNo == ResNo) { @@ -488,7 +488,7 @@ void ScheduleDAG::CreateVirtualRegisters(SDNode *Node, MachineInstr *MI, const TargetInstrDesc &II, - DenseMap &VRBaseMap) { + DenseMap &VRBaseMap) { assert(Node->getTargetOpcode() != TargetInstrInfo::IMPLICIT_DEF && "IMPLICIT_DEF should have been handled as a special case elsewhere!"); @@ -499,7 +499,7 @@ unsigned VRBase = 0; for (SDNode::use_iterator UI = Node->use_begin(), E = Node->use_end(); UI != E; ++UI) { - SDNode *Use = *UI; + SDNode *Use = UI->getUser(); if (Use->getOpcode() == ISD::CopyToReg && Use->getOperand(2).Val == Node && Use->getOperand(2).ResNo == i) { @@ -529,7 +529,7 @@ /// getVR - Return the virtual register corresponding to the specified result /// of the specified node. unsigned ScheduleDAG::getVR(SDOperand Op, - DenseMap &VRBaseMap) { + DenseMap &VRBaseMap) { if (Op.isTargetOpcode() && Op.getTargetOpcode() == TargetInstrInfo::IMPLICIT_DEF) { // Add an IMPLICIT_DEF instruction before every use. @@ -544,7 +544,7 @@ return VReg; } - DenseMap::iterator I = VRBaseMap.find(Op); + DenseMap::iterator I = VRBaseMap.find(Op); assert(I != VRBaseMap.end() && "Node emitted out of order - late"); return I->second; } @@ -557,7 +557,7 @@ void ScheduleDAG::AddOperand(MachineInstr *MI, SDOperand Op, unsigned IIOpNum, const TargetInstrDesc *II, - DenseMap &VRBaseMap) { + DenseMap &VRBaseMap) { if (Op.isTargetOpcode()) { // Note that this case is redundant with the final else block, but we // include it because it is the most common and it makes the logic @@ -688,7 +688,7 @@ /// EmitSubregNode - Generate machine code for subreg nodes. /// void ScheduleDAG::EmitSubregNode(SDNode *Node, - DenseMap &VRBaseMap) { + DenseMap &VRBaseMap) { unsigned VRBase = 0; unsigned Opc = Node->getTargetOpcode(); @@ -696,7 +696,7 @@ // the CopyToReg'd destination register instead of creating a new vreg. for (SDNode::use_iterator UI = Node->use_begin(), E = Node->use_end(); UI != E; ++UI) { - SDNode *Use = *UI; + SDNode *Use = UI->getUser(); if (Use->getOpcode() == ISD::CopyToReg && Use->getOperand(2).Val == Node) { unsigned DestReg = cast(Use->getOperand(1))->getReg(); @@ -779,7 +779,7 @@ /// EmitNode - Generate machine code for an node and needed dependencies. /// void ScheduleDAG::EmitNode(SDNode *Node, unsigned InstanceNo, - DenseMap &VRBaseMap) { + DenseMap &VRBaseMap) { // If machine instruction if (Node->isTargetOpcode()) { unsigned Opc = Node->getTargetOpcode(); @@ -1099,7 +1099,7 @@ } // Finally, emit the code for all of the scheduled instructions. - DenseMap VRBaseMap; + DenseMap VRBaseMap; DenseMap CopyVRBaseMap; for (unsigned i = 0, e = Sequence.size(); i != e; i++) { SUnit *SU = Sequence[i]; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=49330&r1=49329&r2=49330&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Mon Apr 7 05:06:32 2008 @@ -10,7 +10,6 @@ // This implements the SelectionDAG class. // //===----------------------------------------------------------------------===// - #include "llvm/CodeGen/SelectionDAG.h" #include "llvm/Constants.h" #include "llvm/GlobalAlias.h" @@ -465,14 +464,15 @@ // no cycles in the graph. for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I) { SDNode *Operand = I->Val; - Operand->removeUser(N); + Operand->removeUser(std::distance(N->op_begin(), I), N); // Now that we removed this operand, see if there are no uses of it left. if (Operand->use_empty()) DeadNodes.push_back(Operand); } - if (N->OperandsNeedDelete) + if (N->OperandsNeedDelete) { delete[] N->OperandList; + } N->OperandList = 0; N->NumOperands = 0; @@ -504,14 +504,15 @@ // no cycles in the graph. for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I) { SDNode *Operand = I->Val; - Operand->removeUser(N); + Operand->removeUser(std::distance(N->op_begin(), I), N); // Now that we removed this operand, see if there are no uses of it left. if (Operand->use_empty()) DeadNodes.push_back(Operand); } - if (N->OperandsNeedDelete) + if (N->OperandsNeedDelete) { delete[] N->OperandList; + } N->OperandList = 0; N->NumOperands = 0; @@ -538,9 +539,10 @@ // Drop all of the operands and decrement used nodes use counts. for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I) - I->Val->removeUser(N); - if (N->OperandsNeedDelete) + I->Val->removeUser(std::distance(N->op_begin(), I), N); + if (N->OperandsNeedDelete) { delete[] N->OperandList; + } N->OperandList = 0; N->NumOperands = 0; @@ -701,8 +703,9 @@ while (!AllNodes.empty()) { SDNode *N = AllNodes.begin(); N->SetNextInBucket(0); - if (N->OperandsNeedDelete) + if (N->OperandsNeedDelete) { delete [] N->OperandList; + } N->OperandList = 0; N->NumOperands = 0; AllNodes.pop_front(); @@ -2894,9 +2897,10 @@ RemoveNodeFromCSEMaps(N); // Now we update the operands. - N->OperandList[0].Val->removeUser(N); - Op.Val->addUser(N); + N->OperandList[0].Val->removeUser(0, N); N->OperandList[0] = Op; + N->OperandList[0].setUser(N); + Op.Val->addUser(0, N); // If this gets put into a CSE map, add it. if (InsertPos) CSEMap.InsertNode(N, InsertPos); @@ -2923,14 +2927,16 @@ // Now we update the operands. if (N->OperandList[0] != Op1) { - N->OperandList[0].Val->removeUser(N); - Op1.Val->addUser(N); + N->OperandList[0].Val->removeUser(0, N); N->OperandList[0] = Op1; + N->OperandList[0].setUser(N); + Op1.Val->addUser(0, N); } if (N->OperandList[1] != Op2) { - N->OperandList[1].Val->removeUser(N); - Op2.Val->addUser(N); + N->OperandList[1].Val->removeUser(1, N); N->OperandList[1] = Op2; + N->OperandList[1].setUser(N); + Op2.Val->addUser(1, N); } // If this gets put into a CSE map, add it. @@ -2958,7 +2964,6 @@ return UpdateNodeOperands(N, Ops, 5); } - SDOperand SelectionDAG:: UpdateNodeOperands(SDOperand InN, SDOperand *Ops, unsigned NumOps) { SDNode *N = InN.Val; @@ -2989,9 +2994,10 @@ // Now we update the operands. for (unsigned i = 0; i != NumOps; ++i) { if (N->OperandList[i] != Ops[i]) { - N->OperandList[i].Val->removeUser(N); - Ops[i].Val->addUser(N); + N->OperandList[i].Val->removeUser(i, N); N->OperandList[i] = Ops[i]; + N->OperandList[i].setUser(N); + Ops[i].Val->addUser(i, N); } } @@ -3000,7 +3006,6 @@ return InN; } - /// MorphNodeTo - This frees the operands of the current node, resets the /// opcode, types, and operands to the specified value. This should only be /// used by the SelectionDAG class. @@ -3013,13 +3018,14 @@ // Clear the operands list, updating used nodes to remove this from their // use list. for (op_iterator I = op_begin(), E = op_end(); I != E; ++I) - I->Val->removeUser(this); + I->Val->removeUser(std::distance(op_begin(), I), this); // If NumOps is larger than the # of operands we currently have, reallocate // the operand list. if (NumOps > NumOperands) { - if (OperandsNeedDelete) + if (OperandsNeedDelete) { delete [] OperandList; + } OperandList = new SDOperand[NumOps]; OperandsNeedDelete = true; } @@ -3029,8 +3035,10 @@ for (unsigned i = 0, e = NumOps; i != e; ++i) { OperandList[i] = Ops[i]; + OperandList[i].setUser(this); SDNode *N = OperandList[i].Val; - N->Uses.push_back(this); + N->addUser(i, this); + ++N->UsesSize; } } @@ -3298,21 +3306,22 @@ assert(From->getNumValues() == 1 && FromN.ResNo == 0 && "Cannot replace with this method!"); assert(From != To.Val && "Cannot replace uses of with self"); - + while (!From->use_empty()) { - // Process users until they are all gone. - SDNode *U = *From->use_begin(); - + SDNode::use_iterator UI = From->use_begin(); + SDNode *U = UI->getUser(); + // This node is about to morph, remove its old self from the CSE maps. RemoveNodeFromCSEMaps(U); - - for (SDOperand *I = U->OperandList, *E = U->OperandList+U->NumOperands; - I != E; ++I) + int operandNum = 0; + for (SDNode::op_iterator I = U->op_begin(), E = U->op_end(); + I != E; ++I, ++operandNum) if (I->Val == From) { - From->removeUser(U); + From->removeUser(operandNum, U); *I = To; - To.Val->addUser(U); - } + I->setUser(U); + To.Val->addUser(operandNum, U); + } // Now that we have modified U, add it back to the CSE maps. If it already // exists there, recursively merge the results together. @@ -3347,20 +3356,20 @@ UpdateListener); while (!From->use_empty()) { - // Process users until they are all gone. - SDNode *U = *From->use_begin(); - + SDNode::use_iterator UI = From->use_begin(); + SDNode *U = UI->getUser(); + // This node is about to morph, remove its old self from the CSE maps. RemoveNodeFromCSEMaps(U); - - for (SDOperand *I = U->OperandList, *E = U->OperandList+U->NumOperands; - I != E; ++I) + int operandNum = 0; + for (SDNode::op_iterator I = U->op_begin(), E = U->op_end(); + I != E; ++I, ++operandNum) if (I->Val == From) { - From->removeUser(U); + From->removeUser(operandNum, U); I->Val = To; - To->addUser(U); + To->addUser(operandNum, U); } - + // Now that we have modified U, add it back to the CSE maps. If it already // exists there, recursively merge the results together. if (SDNode *Existing = AddNonLeafNodeToCSEMaps(U)) { @@ -3390,21 +3399,22 @@ return ReplaceAllUsesWith(SDOperand(From, 0), To[0], UpdateListener); while (!From->use_empty()) { - // Process users until they are all gone. - SDNode *U = *From->use_begin(); - + SDNode::use_iterator UI = From->use_begin(); + SDNode *U = UI->getUser(); + // This node is about to morph, remove its old self from the CSE maps. RemoveNodeFromCSEMaps(U); - - for (SDOperand *I = U->OperandList, *E = U->OperandList+U->NumOperands; - I != E; ++I) + int operandNum = 0; + for (SDNode::op_iterator I = U->op_begin(), E = U->op_end(); + I != E; ++I, ++operandNum) if (I->Val == From) { const SDOperand &ToOp = To[I->ResNo]; - From->removeUser(U); + From->removeUser(operandNum, U); *I = ToOp; - ToOp.Val->addUser(U); + I->setUser(U); + ToOp.Val->addUser(operandNum, U); } - + // Now that we have modified U, add it back to the CSE maps. If it already // exists there, recursively merge the results together. if (SDNode *Existing = AddNonLeafNodeToCSEMaps(U)) { @@ -3434,7 +3444,7 @@ ChainedSetUpdaterListener(SmallSetVector &set, SelectionDAG::DAGUpdateListener *chain) : Set(set), Chain(chain) {} - + virtual void NodeDeleted(SDNode *N) { Set.remove(N); if (Chain) Chain->NodeDeleted(N); @@ -3462,7 +3472,13 @@ // Get all of the users of From.Val. We want these in a nice, // deterministically ordered and uniqued set, so we use a SmallSetVector. - SmallSetVector Users(From.Val->use_begin(), From.Val->use_end()); + SmallSetVector Users; + for (SDNode::use_iterator UI = From.Val->use_begin(), + E = From.Val->use_end(); UI != E; ++UI) { + SDNode *User = UI->getUser(); + if (!Users.count(User)) + Users.insert(User); + } // When one of the recursive merges deletes nodes from the graph, we need to // make sure that UpdateListener is notified *and* that the node is removed @@ -3476,7 +3492,7 @@ Users.pop_back(); // Scan for an operand that matches From. - SDOperand *Op = User->OperandList, *E = User->OperandList+User->NumOperands; + SDNode::op_iterator Op = User->op_begin(), E = User->op_end(); for (; Op != E; ++Op) if (*Op == From) break; @@ -3490,9 +3506,10 @@ // Update all operands that match "From" in case there are multiple uses. for (; Op != E; ++Op) { if (*Op == From) { - From.Val->removeUser(User); - *Op = To; - To.Val->addUser(User); + From.Val->removeUser(Op-User->op_begin(), User); + *Op = To; + Op->setUser(User); + To.Val->addUser(Op-User->op_begin(), User); } } @@ -3672,16 +3689,13 @@ SmallPtrSet UsersHandled; - for (SDNode::use_iterator UI = Uses.begin(), E = Uses.end(); UI != E; ++UI) { - SDNode *User = *UI; - if (User->getNumOperands() == 1 || - UsersHandled.insert(User)) // First time we've seen this? - for (unsigned i = 0, e = User->getNumOperands(); i != e; ++i) - if (User->getOperand(i) == TheValue) { - if (NUses == 0) - return false; // too many uses - --NUses; - } + // TODO: Only iterate over uses of a given value of the node + for (SDNode::use_iterator UI = use_begin(), E = use_end(); UI != E; ++UI) { + if (*UI == TheValue) { + if (NUses == 0) + return false; + --NUses; + } } // Found exactly the right number of uses? @@ -3700,8 +3714,8 @@ SmallPtrSet UsersHandled; - for (SDNode::use_iterator UI = Uses.begin(), E = Uses.end(); UI != E; ++UI) { - SDNode *User = *UI; + for (SDNode::use_iterator UI = use_begin(), E = use_end(); UI != E; ++UI) { + SDNode *User = UI->getUser(); if (User->getNumOperands() == 1 || UsersHandled.insert(User)) // First time we've seen this? for (unsigned i = 0, e = User->getNumOperands(); i != e; ++i) @@ -3719,7 +3733,7 @@ bool SDNode::isOnlyUseOf(SDNode *N) const { bool Seen = false; for (SDNode::use_iterator I = N->use_begin(), E = N->use_end(); I != E; ++I) { - SDNode *User = *I; + SDNode *User = I->getUser(); if (User == this) Seen = true; else @@ -3731,7 +3745,7 @@ /// isOperand - Return true if this node is an operand of N. /// -bool SDOperand::isOperandOf(SDNode *N) const { +bool SDOperandImpl::isOperandOf(SDNode *N) const { for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) if (*this == N->getOperand(i)) return true; @@ -3750,7 +3764,7 @@ /// side-effecting instructions. In practice, this looks through token /// factors and non-volatile loads. In order to remain efficient, this only /// looks a couple of nodes in, it does not do an exhaustive search. -bool SDOperand::reachesChainWithoutSideEffects(SDOperand Dest, +bool SDOperandImpl::reachesChainWithoutSideEffects(SDOperandImpl Dest, unsigned Depth) const { if (*this == Dest) return true; Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=49330&r1=49329&r2=49330&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Mon Apr 7 05:06:32 2008 @@ -3662,11 +3662,11 @@ SDNode *LHSN = N->getOperand(0).Val; for (SDNode::use_iterator UI = LHSN->use_begin(), E = LHSN->use_end(); UI != E; ++UI) - if ((*UI)->getOpcode() == PPCISD::VCMPo && - (*UI)->getOperand(1) == N->getOperand(1) && - (*UI)->getOperand(2) == N->getOperand(2) && - (*UI)->getOperand(0) == N->getOperand(0)) { - VCMPoNode = *UI; + if ((*UI).getUser()->getOpcode() == PPCISD::VCMPo && + (*UI).getUser()->getOperand(1) == N->getOperand(1) && + (*UI).getUser()->getOperand(2) == N->getOperand(2) && + (*UI).getUser()->getOperand(0) == N->getOperand(0)) { + VCMPoNode = UI->getUser(); break; } @@ -3682,7 +3682,7 @@ for (SDNode::use_iterator UI = VCMPoNode->use_begin(); FlagUser == 0; ++UI) { assert(UI != VCMPoNode->use_end() && "Didn't find user!"); - SDNode *User = *UI; + SDNode *User = UI->getUser(); for (unsigned i = 0, e = User->getNumOperands(); i != e; ++i) { if (User->getOperand(i) == SDOperand(VCMPoNode, 1)) { FlagUser = User; Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=49330&r1=49329&r2=49330&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Mon Apr 7 05:06:32 2008 @@ -225,7 +225,7 @@ static SDNode *findFlagUse(SDNode *N) { unsigned FlagResNo = N->getNumValues()-1; for (SDNode::use_iterator I = N->use_begin(), E = N->use_end(); I != E; ++I) { - SDNode *User = *I; + SDNode *User = I->getUser(); for (unsigned i = 0, e = User->getNumOperands(); i != e; ++i) { SDOperand Op = User->getOperand(i); if (Op.Val == N && Op.ResNo == FlagResNo) Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=49330&r1=49329&r2=49330&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Apr 7 05:06:32 2008 @@ -3734,7 +3734,7 @@ // result has a single use which is a store. if (!Op.hasOneUse()) return SDOperand(); - SDNode *User = *Op.Val->use_begin(); + SDNode *User = Op.Val->use_begin()->getUser(); if (User->getOpcode() != ISD::STORE) return SDOperand(); SDOperand Extract = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, MVT::i32, From romix.llvm at googlemail.com Mon Apr 7 05:10:32 2008 From: romix.llvm at googlemail.com (Roman Levenstein) Date: Mon, 7 Apr 2008 11:10:32 +0100 Subject: [llvm-commits] [llvm] r48822 - in /llvm/trunk: include/llvm/CodeGen/ScheduleDAG.h include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/DAGCombiner.cpp lib/CodeGen/SelectionDAG/LegalizeDAG.cpp lib/CodeGen/SelectionDAG/LegalizeTypes.cp Message-ID: Hi Evan, 2008/4/3, Evan Cheng : > I've backed this out for now. Please fix the infinite looping and then > re-commit. I fixed the problem and re-committed. The newer and better patch is ready, but it is not approved by Dan yet. Dan: Ping! ;-) -Roman > On Apr 2, 2008, at 2:28 PM, Dan Gohman wrote: > > > > > On Mar 26, 2008, at 5:39 AM, Roman Levenstein wrote: > >> > >> + > >> + SmallSetVector Users; > >> while (!From->use_empty()) { > >> - // Process users until they are all gone. > >> - SDNode *U = *From->use_begin(); > >> - > >> + SDNode::use_iterator UI = From->use_begin(); > >> + SDNode *U = UI->getUser(); > >> + > >> + // Remember that this node is about to morph. > >> + if (Users.count(U)) > >> + continue; > >> + Users.insert(U); > > > > Hi Roman, > > > > This code that remembers users is causing the loop to > > repeat infinitely in some cases. Actually, if Users.count(U) > > is ever true, it gooes into an infinite loop because > > nothing happens that will make From->use_list() > > get closer to being empty. > > > > You can reproduce this by unmerging revision 48994 and > > running llc on the attached testcase. 48994 is otherwise > > unrelated, but it happens to change the way this testcase > > gets compiled such that the above bug doesn't get triggered. > > > > Can you take a look at this? > > > > Thanks, > > > > Dan > > > > > > _______________________________________________ > > llvm-commits mailing list > > llvm-commits at cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From gabor at mac.com Mon Apr 7 05:50:34 2008 From: gabor at mac.com (Gabor Greif) Date: Mon, 07 Apr 2008 12:50:34 +0200 Subject: [llvm-commits] [llvm] r49293 - in /llvm/trunk/lib/AsmParser: llvmAsmParser.cpp.cvs llvmAsmParser.h.cvs llvmAsmParser.y.cvs In-Reply-To: <200804062307.m36N7tmb024050@zion.cs.uiuc.edu> References: <200804062307.m36N7tmb024050@zion.cs.uiuc.edu> Message-ID: <47F9FC7A.5040506@mac.com> > Hi Gabor, > > Did you regenerate with an older bison? Hmmm, obviously. Did you encounter problems because of this? Cheers, Gabor > > --Edwin From edwintorok at gmail.com Mon Apr 7 06:07:51 2008 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Mon, 07 Apr 2008 14:07:51 +0300 Subject: [llvm-commits] [llvm] r49293 - in /llvm/trunk/lib/AsmParser: llvmAsmParser.cpp.cvs llvmAsmParser.h.cvs llvmAsmParser.y.cvs In-Reply-To: <47F9FC7A.5040506@mac.com> References: <200804062307.m36N7tmb024050@zion.cs.uiuc.edu> <47F9FC7A.5040506@mac.com> Message-ID: <47FA0087.2040704@gmail.com> Gabor Greif wrote: >> Hi Gabor, >> >> Did you regenerate with an older bison? >> > > Hmmm, obviously. Did you encounter problems because of this? > > Cheers, > > Gabor Nope, I just wanted to point out that there is a significant version difference. I thought there is a reason for the downgrade. --Edwin From ggreif at gmail.com Mon Apr 7 06:37:15 2008 From: ggreif at gmail.com (Gabor Greif) Date: Mon, 07 Apr 2008 11:37:15 -0000 Subject: [llvm-commits] [llvm] r49331 - /llvm/branches/ggreif/use-diet/include/llvm/User.h Message-ID: <200804071137.m37BbFiX021956@zion.cs.uiuc.edu> Author: ggreif Date: Mon Apr 7 06:37:12 2008 New Revision: 49331 URL: http://llvm.org/viewvc/llvm-project?rev=49331&view=rev Log: minor corrections Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49331&r1=49330&r2=49331&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/User.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/User.h Mon Apr 7 06:37:12 2008 @@ -47,7 +47,7 @@ array from the User object and there may be a variable number of them. -Initially each layout will posses a direct pointer to the +Initially each layout will possess a direct pointer to the start of the array of Uses. Though not mandatory for layout a), we stick to this redundancy for the sake of simplicity. The User object will also store the number of Use objects it @@ -77,6 +77,9 @@ # | V | V | V | V | # '---'---'---'---''' + (In the above figures 'V' stands for the Value* that + is stored in each Use object) + Since the Use objects will be deprived of the direct pointer to their User objects, there must be a fast and exact method to @@ -90,10 +93,10 @@ 10 --> stop and calc (s) 11 --> full stop (S) -Given a Use*, all we have to do is walk till we get a -stop and we either have a User immediately behind or +Given a Use*, all we have to do is to walk till we get +a stop and we either have a User immediately behind or we have to walk to the next stop picking up digits -and calculate the offset: +and calculating the offset: .---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---------------- | 1 | s | 1 | 0 | 1 | 0 | s | 1 | 1 | 0 | s | 1 | 1 | s | 1 | S | User (or User*) From nicolas.geoffray at lip6.fr Mon Apr 7 07:22:57 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 07 Apr 2008 12:22:57 -0000 Subject: [llvm-commits] [vmkit] r49332 - in /vmkit/trunk/lib/N3/VMCore: CLIJit.cpp LowerArrayLength.cpp Opcodes.cpp VMCache.cpp Message-ID: <200804071222.m37CMv6O023395@zion.cs.uiuc.edu> Author: geoffray Date: Mon Apr 7 07:22:55 2008 New Revision: 49332 URL: http://llvm.org/viewvc/llvm-project?rev=49332&view=rev Log: Port to new LLVM interface for Values Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.cpp vmkit/trunk/lib/N3/VMCore/LowerArrayLength.cpp vmkit/trunk/lib/N3/VMCore/Opcodes.cpp vmkit/trunk/lib/N3/VMCore/VMCache.cpp Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.cpp?rev=49332&r1=49331&r2=49332&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/CLIJit.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/CLIJit.cpp Mon Apr 7 07:22:55 2008 @@ -14,59 +14,21 @@ #include "debug.h" #include "types.h" -#include -#include -#include #include -#include #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "llvm/Constants.h" -#include "llvm/DerivedTypes.h" -#include "llvm/Module.h" -#include "llvm/ModuleProvider.h" -#include "llvm/PassManager.h" -#include "llvm/ValueSymbolTable.h" -#include "llvm/Analysis/LoadValueNumbering.h" -#include "llvm/Analysis/LoopPass.h" -#include "llvm/Analysis/Verifier.h" -#include "llvm/Assembly/Writer.h" -#include "llvm/Assembly/PrintModulePass.h" -#include "llvm/Bitcode/ReaderWriter.h" -#include "llvm/CodeGen/RegAllocRegistry.h" -#include "llvm/CodeGen/SchedulerRegistry.h" -#include "llvm/CodeGen/ScheduleDAG.h" -#include "llvm/Target/SubtargetFeature.h" -#include "llvm/Target/TargetData.h" -#include "llvm/Target/TargetLowering.h" -#include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetMachineRegistry.h" -#include "llvm/Transforms/Scalar.h" -#include "llvm/Transforms/IPO.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/StringMap.h" -#include "llvm/Support/Streams.h" -#include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/MutexGuard.h" +#include +#include +#include +#include +#include +#include + -#include #include "mvm/JIT.h" #include "mvm/Method.h" -#include "mvm/VMLet.h" #include "Assembly.h" #include "CLIAccess.h" @@ -98,16 +60,17 @@ VMField* field = *i; if (field->signature->super == N3::pValue) { if (!field->signature->isPrimitive) { - Value* ptr = new GetElementPtrInst(arg, field->offset, "", + Value* ptr = GetElementPtrInst::Create(arg, field->offset, "", block); traceStruct(field->signature, block, ptr); - } else if (field->signature == N3::pIntPtr || field->signature == N3::pUIntPtr) { + } else if (field->signature == N3::pIntPtr || + field->signature == N3::pUIntPtr) { Value* valCast = new BitCastInst(arg, VMObject::llvmType, "", block); - new CallInst(CLIJit::markAndTraceLLVM, valCast, "", block); + CallInst::Create(CLIJit::markAndTraceLLVM, valCast, "", block); } } else if (field->signature->super != N3::pEnum) { Value* valCast = new BitCastInst(arg, VMObject::llvmType, "", block); - new CallInst(CLIJit::markAndTraceLLVM, valCast, "", block); + CallInst::Create(CLIJit::markAndTraceLLVM, valCast, "", block); } } } @@ -131,7 +94,7 @@ } else { args.push_back(field->offset); } - Value* ptr = new GetElementPtrInst(arg, args.begin(), args.end(), "", + Value* ptr = GetElementPtrInst::Create(arg, args.begin(), args.end(), "", block); traceStruct(field->signature, block, ptr); } else if (field->signature->super != N3::pEnum) { @@ -144,17 +107,17 @@ } else { args.push_back(field->offset); } - Value* ptr = new GetElementPtrInst(arg, args.begin(), args.end(), "", + Value* ptr = GetElementPtrInst::Create(arg, args.begin(), args.end(), "", block); Value* val = new LoadInst(ptr, "", block); Value* valCast = new BitCastInst(val, VMObject::llvmType, "", block); - new CallInst(CLIJit::markAndTraceLLVM, valCast, "", block); + CallInst::Create(CLIJit::markAndTraceLLVM, valCast, "", block); } } } VirtualTable* CLIJit::makeArrayVT(VMClassArray* cl) { - Function* func = new Function(markAndTraceLLVMType, + Function* func = Function::Create(markAndTraceLLVMType, GlobalValue::ExternalLinkage, "markAndTraceObject", cl->vm->module); @@ -169,9 +132,9 @@ // Function Definitions { - BasicBlock* label_entry = new BasicBlock("entry",func,0); - BasicBlock* label_bb = new BasicBlock("bb",func,0); - BasicBlock* label_return = new BasicBlock("return",func,0); + BasicBlock* label_entry = BasicBlock::Create("entry",func,0); + BasicBlock* label_bb = BasicBlock::Create("bb",func,0); + BasicBlock* label_return = BasicBlock::Create("return",func,0); Value* ptr_v = new BitCastInst(arg, cl->naturalType, "", label_entry); @@ -179,14 +142,23 @@ std::vector ptr_tmp918_indices; ptr_tmp918_indices.push_back(const_int32_8); ptr_tmp918_indices.push_back(const_int32_9); - Instruction* ptr_tmp918 = new GetElementPtrInst(ptr_v, ptr_tmp918_indices.begin(), ptr_tmp918_indices.end(), "tmp918", label_entry); - LoadInst* int32_tmp1019 = new LoadInst(ptr_tmp918, "tmp1019", false, label_entry); - ICmpInst* int1_tmp1221 = new ICmpInst(ICmpInst::ICMP_SGT, int32_tmp1019, const_int32_8, "tmp1221", label_entry); - new BranchInst(label_bb, label_return, int1_tmp1221, label_entry); + Instruction* ptr_tmp918 = + GetElementPtrInst::Create(ptr_v, ptr_tmp918_indices.begin(), + ptr_tmp918_indices.end(), "tmp918", + label_entry); + LoadInst* int32_tmp1019 = new LoadInst(ptr_tmp918, "tmp1019", false, + label_entry); + + ICmpInst* int1_tmp1221 = new ICmpInst(ICmpInst::ICMP_SGT, int32_tmp1019, + const_int32_8, "tmp1221", + label_entry); + + BranchInst::Create(label_bb, label_return, int1_tmp1221, label_entry); // Block bb (label_bb) Argument* fwdref_12 = new Argument(IntegerType::get(32)); - PHINode* int32_i_015_0 = new PHINode(IntegerType::get(32), "i.015.0", label_bb); + PHINode* int32_i_015_0 = PHINode::Create(Type::Int32Ty, "i.015.0", + label_bb); int32_i_015_0->reserveOperandSpace(2); int32_i_015_0->addIncoming(fwdref_12, label_bb); int32_i_015_0->addIncoming(const_int32_8, label_entry); @@ -195,21 +167,27 @@ ptr_tmp3_indices.push_back(const_int32_8); ptr_tmp3_indices.push_back(const_int32_10); ptr_tmp3_indices.push_back(int32_i_015_0); - Instruction* ptr_tmp3 = new GetElementPtrInst(ptr_v, ptr_tmp3_indices.begin(), ptr_tmp3_indices.end(), "tmp3", label_bb); + Instruction* ptr_tmp3 = + GetElementPtrInst::Create(ptr_v, ptr_tmp3_indices.begin(), + ptr_tmp3_indices.end(), "tmp3", label_bb); + if (cl->baseClass->super == N3::pValue) { traceStruct(cl->baseClass, label_bb, ptr_tmp3); } else if (cl->baseClass->super != N3::pEnum) { LoadInst* ptr_tmp4 = new LoadInst(ptr_tmp3, "tmp4", false, label_bb); Value* arg = new BitCastInst(ptr_tmp4, VMObject::llvmType, "", label_bb); - new CallInst(markAndTraceLLVM, arg, "", label_bb); + CallInst::Create(markAndTraceLLVM, arg, "", label_bb); } - BinaryOperator* int32_tmp6 = BinaryOperator::create(Instruction::Add, int32_i_015_0, const_int32_9, "tmp6", label_bb); + BinaryOperator* int32_tmp6 = + BinaryOperator::create(Instruction::Add, int32_i_015_0, const_int32_9, + "tmp6", label_bb); LoadInst* int32_tmp10 = new LoadInst(ptr_tmp918, "tmp10", false, label_bb); - ICmpInst* int1_tmp12 = new ICmpInst(ICmpInst::ICMP_SGT, int32_tmp10, int32_tmp6, "tmp12", label_bb); - new BranchInst(label_bb, label_return, int1_tmp12, label_bb); + ICmpInst* int1_tmp12 = new ICmpInst(ICmpInst::ICMP_SGT, int32_tmp10, + int32_tmp6, "tmp12", label_bb); + BranchInst::Create(label_bb, label_return, int1_tmp12, label_bb); // Block return (label_return) - new ReturnInst(label_return); + ReturnInst::Create(label_return); // Resolve Forward References fwdref_12->replaceAllUsesWith(int32_tmp6); delete fwdref_12; @@ -230,23 +208,23 @@ const Type* type = stat ? cl->staticType : cl->virtualType; std::vector &fields = stat ? cl->staticFields : cl->virtualFields; - Function* func = new Function(markAndTraceLLVMType, + Function* func = Function::Create(markAndTraceLLVMType, GlobalValue::ExternalLinkage, "markAndTraceObject", cl->vm->module); Argument* arg = func->arg_begin(); - BasicBlock* block = new BasicBlock("", func); + BasicBlock* block = BasicBlock::Create("", func); llvm::Value* realArg = new BitCastInst(arg, type, "", block); if (stat || cl->super == 0) { - new CallInst(vmObjectTracerLLVM, arg, "", block); + CallInst::Create(vmObjectTracerLLVM, arg, "", block); } else { - new CallInst(((VMClass*)cl->super)->virtualTracer, arg, "", block); + CallInst::Create(((VMClass*)cl->super)->virtualTracer, arg, "", block); } traceClass(cl, block, realArg, fields, (cl->super == N3::pValue && !stat)); - new ReturnInst(block); + ReturnInst::Create(block); VirtualTable * res = malloc(VT_SIZE); memcpy(res, VMObject::VT, VT_SIZE); @@ -265,7 +243,7 @@ } BasicBlock* CLIJit::createBasicBlock(const char* name) { - return new BasicBlock(name, llvmFunction); + return BasicBlock::Create(name, llvmFunction); } void CLIJit::setCurrentBlock(BasicBlock* newBlock) { @@ -292,7 +270,7 @@ for (std::vector::iterator i = jit->stack.begin(), e = jit->stack.end(); i!= e; ++i) { Value* cur = (*i); - PHINode* node = new PHINode(cur->getType(), "", dest); + PHINode* node = PHINode::Create(cur->getType(), "", dest); node->addIncoming(cur, insert); } } else { @@ -314,14 +292,14 @@ void CLIJit::branch(llvm::BasicBlock* dest, llvm::BasicBlock* insert) { testPHINodes(dest, insert, this); - new BranchInst(dest, insert); + BranchInst::Create(dest, insert); } void CLIJit::branch(llvm::Value* test, llvm::BasicBlock* ifTrue, llvm::BasicBlock* ifFalse, llvm::BasicBlock* insert) { testPHINodes(ifTrue, insert, this); testPHINodes(ifFalse, insert, this); - new BranchInst(ifTrue, ifFalse, test, insert); + BranchInst::Create(ifTrue, ifFalse, test, insert); } Value* CLIJit::pop() { @@ -347,7 +325,8 @@ // in cast it's a struct val = new LoadInst(val, "", currentBlock); } - else if (type->getPrimitiveSizeInBits() < valType->getPrimitiveSizeInBits()) { + else if (type->getPrimitiveSizeInBits() < + valType->getPrimitiveSizeInBits()) { val = new TruncInst(val, type, "", currentBlock); } else { val = new SExtInst(val, type, "", currentBlock); @@ -388,21 +367,30 @@ std::vector& args) { if (meth->name == N3::sqrt) { - return new CallInst(mvm::jit::func_llvm_sqrt_f64, args[0], "tmp1", currentBlock); + return CallInst::Create(mvm::jit::func_llvm_sqrt_f64, args[0], "tmp1", + currentBlock); } else if (meth->name == N3::sin) { - return new CallInst(mvm::jit::func_llvm_sin_f64, args[0], "tmp1", currentBlock); + return CallInst::Create(mvm::jit::func_llvm_sin_f64, args[0], "tmp1", + currentBlock); } else if (meth->name == N3::cos) { - return new CallInst(mvm::jit::func_llvm_cos_f64, args[0], "tmp1", currentBlock); + return CallInst::Create(mvm::jit::func_llvm_cos_f64, args[0], "tmp1", + currentBlock); } else if (meth->name == N3::exp) { - return new CallInst(mvm::jit::func_llvm_exp_f64, args[0], "tmp1", currentBlock); + return CallInst::Create(mvm::jit::func_llvm_exp_f64, args[0], "tmp1", + currentBlock); } else if (meth->name == N3::log) { - return new CallInst(mvm::jit::func_llvm_log_f64, args[0], "tmp1", currentBlock); + return CallInst::Create(mvm::jit::func_llvm_log_f64, args[0], "tmp1", + currentBlock); } else if (meth->name == N3::floor) { - return new CallInst(mvm::jit::func_llvm_floor_f64, args[0], "tmp1", currentBlock); + return CallInst::Create(mvm::jit::func_llvm_floor_f64, args[0], "tmp1", + currentBlock); } else if (meth->name == N3::log10) { - return new CallInst(mvm::jit::func_llvm_log10_f64, args[0], "tmp1", currentBlock); + return CallInst::Create(mvm::jit::func_llvm_log10_f64, args[0], "tmp1", + currentBlock); } else if (meth->name == N3::pow) { - Instruction* val = new CallInst(mvm::jit::func_llvm_pow_f64, args.begin(), args.end(), "tmp1", currentBlock); + Instruction* val = CallInst::Create(mvm::jit::func_llvm_pow_f64, + args.begin(), args.end(), "tmp1", + currentBlock); return val; } return 0; @@ -430,14 +418,15 @@ if (meth->classDef->isArray) { uint8 func = 0; - if (meth->name == VMThread::get()->vm->asciizConstructUTF8("Set")) { + VirtualMachine* vm = VMThread::get()->vm; + if (meth->name == vm->asciizConstructUTF8("Set")) { func = 0; - } else if (meth->name == VMThread::get()->vm->asciizConstructUTF8("Get")) { + } else if (meth->name == vm->asciizConstructUTF8("Get")) { func = 1; - } else if (meth->name == VMThread::get()->vm->asciizConstructUTF8("Address")) { + } else if (meth->name == vm->asciizConstructUTF8("Address")) { func = 2; } else { - VMThread::get()->vm->error("implement me %s", meth->name->printString()); + vm->error("implement me %s", meth->name->printString()); } VMClassArray* type = (VMClassArray*)meth->classDef; @@ -478,50 +467,63 @@ const llvm::FunctionType* type = meth->getSignature(); makeArgs(type, Args, meth->structReturn); - if (meth->classDef->nameSpace == N3::system && meth->classDef->name == N3::math) { + if (meth->classDef->nameSpace == N3::system && + meth->classDef->name == N3::math) { Value* val = lowerMathOps(meth, Args); if (val) { push(val); return; } - } else if (meth->classDef->nameSpace == N3::system && meth->classDef->name == N3::doubleName) { + } else if (meth->classDef->nameSpace == N3::system && + meth->classDef->name == N3::doubleName) { if (meth->name == N3::isNan) { - push(new FCmpInst(FCmpInst::FCMP_UNO, Args[0], mvm::jit::constantDoubleZero, "tmp1", currentBlock)); + push(new FCmpInst(FCmpInst::FCMP_UNO, Args[0], + mvm::jit::constantDoubleZero, "tmp1", currentBlock)); return; } else if (meth->name == N3::testInfinity) { BasicBlock* endBlock = createBasicBlock("end test infinity"); BasicBlock* minusInfinity = createBasicBlock("- infinity"); BasicBlock* noInfinity = createBasicBlock("no infinity"); - PHINode* node = new PHINode(Type::Int32Ty, "", endBlock); + PHINode* node = PHINode::Create(Type::Int32Ty, "", endBlock); node->addIncoming(mvm::jit::constantOne, currentBlock); node->addIncoming(mvm::jit::constantMinusOne, minusInfinity); node->addIncoming(mvm::jit::constantZero, noInfinity); - Value* val1 = new FCmpInst(FCmpInst::FCMP_OEQ, Args[0], mvm::jit::constantDoubleInfinity, "tmp1", currentBlock); - new BranchInst(endBlock, minusInfinity, val1, currentBlock); - Value* val2 = new FCmpInst(FCmpInst::FCMP_OEQ, Args[0], mvm::jit::constantDoubleMinusInfinity, "tmp1", minusInfinity); - new BranchInst(endBlock, noInfinity, val2, minusInfinity); - new BranchInst(endBlock, noInfinity); + Value* val1 = new FCmpInst(FCmpInst::FCMP_OEQ, Args[0], + mvm::jit::constantDoubleInfinity, "tmp1", + currentBlock); + BranchInst::Create(endBlock, minusInfinity, val1, currentBlock); + Value* val2 = new FCmpInst(FCmpInst::FCMP_OEQ, Args[0], + mvm::jit::constantDoubleMinusInfinity, "tmp1", + minusInfinity); + BranchInst::Create(endBlock, noInfinity, val2, minusInfinity); + BranchInst::Create(endBlock, noInfinity); currentBlock = endBlock; push(node); return; } - } else if (meth->classDef->nameSpace == N3::system && meth->classDef->name == N3::floatName) { + } else if (meth->classDef->nameSpace == N3::system && + meth->classDef->name == N3::floatName) { if (meth->name == N3::isNan) { - push(new FCmpInst(FCmpInst::FCMP_UNO, Args[0], mvm::jit::constantFloatZero, "tmp1", currentBlock)); + push(new FCmpInst(FCmpInst::FCMP_UNO, Args[0], + mvm::jit::constantFloatZero, "tmp1", currentBlock)); return; } else if (meth->name == N3::testInfinity) { BasicBlock* endBlock = createBasicBlock("end test infinity"); BasicBlock* minusInfinity = createBasicBlock("- infinity"); BasicBlock* noInfinity = createBasicBlock("no infinity"); - PHINode* node = new PHINode(Type::Int32Ty, "", endBlock); + PHINode* node = PHINode::Create(Type::Int32Ty, "", endBlock); node->addIncoming(mvm::jit::constantOne, currentBlock); node->addIncoming(mvm::jit::constantMinusOne, minusInfinity); node->addIncoming(mvm::jit::constantZero, noInfinity); - Value* val1 = new FCmpInst(FCmpInst::FCMP_OEQ, Args[0], mvm::jit::constantFloatInfinity, "tmp1", currentBlock); - new BranchInst(endBlock, minusInfinity, val1, currentBlock); - Value* val2 = new FCmpInst(FCmpInst::FCMP_OEQ, Args[0], mvm::jit::constantFloatMinusInfinity, "tmp1", minusInfinity); - new BranchInst(endBlock, noInfinity, val2, minusInfinity); - new BranchInst(endBlock, noInfinity); + Value* val1 = new FCmpInst(FCmpInst::FCMP_OEQ, Args[0], + mvm::jit::constantFloatInfinity, "tmp1", + currentBlock); + BranchInst::Create(endBlock, minusInfinity, val1, currentBlock); + Value* val2 = new FCmpInst(FCmpInst::FCMP_OEQ, Args[0], + mvm::jit::constantFloatMinusInfinity, "tmp1", + minusInfinity); + BranchInst::Create(endBlock, noInfinity, val2, minusInfinity); + BranchInst::Create(endBlock, noInfinity); currentBlock = endBlock; push(node); return; @@ -578,10 +580,11 @@ params.push_back(ConstantInt::get(Type::Int32Ty, size)); mvm::jit::unprotectConstants(); params.push_back(mvm::jit::constantZero); - new CallInst(mvm::jit::llvm_memset_i32, params.begin(), params.end(), "", currentBlock); + CallInst::Create(mvm::jit::llvm_memset_i32, params.begin(), params.end(), + "", currentBlock); } else { Value* var = new LoadInst(type->llvmVar(), "", currentBlock); - Value* val = new CallInst(objConsLLVM, var, "", currentBlock); + Value* val = CallInst::Create(objConsLLVM, var, "", currentBlock); obj = new BitCastInst(val, type->naturalType, "", currentBlock); } @@ -601,7 +604,8 @@ invoke(func, Args, "", currentBlock, meth->structReturn); } - if ((type->super == N3::pValue || type->super == N3::pEnum) && type->virtualFields.size() == 1) { + if ((type->super == N3::pValue || type->super == N3::pEnum) && + type->virtualFields.size() == 1) { push(new LoadInst(obj, "", currentBlock)); } else { push(obj); @@ -617,14 +621,16 @@ // struct! return obj; } else { - if (field->classDef->super != N3::pValue && field->classDef->super != N3::pEnum) { - obj = new BitCastInst(obj, field->classDef->naturalType, "", currentBlock); + if (field->classDef->super != N3::pValue && + field->classDef->super != N3::pEnum) { + obj = new BitCastInst(obj, field->classDef->naturalType, "", + currentBlock); } std::vector args; args.push_back(mvm::jit::constantZero); args.push_back(field->offset); - Value* ptr = new GetElementPtrInst(obj, args.begin(), args.end(), "", - currentBlock); + Value* ptr = GetElementPtrInst::Create(obj, args.begin(), args.end(), "", + currentBlock); return ptr; } } @@ -640,8 +646,8 @@ std::vector args; args.push_back(mvm::jit::constantZero); args.push_back(field->offset); - Value* ptr = new GetElementPtrInst(staticCl, args.begin(), args.end(), "", - currentBlock); + Value* ptr = GetElementPtrInst::Create(staticCl, args.begin(), args.end(), "", + currentBlock); return ptr; @@ -661,13 +667,14 @@ // struct! ptr = obj; } else { - if (field->classDef->super != N3::pValue && field->classDef->super != N3::pEnum) { + if (field->classDef->super != N3::pValue && + field->classDef->super != N3::pEnum) { obj = new BitCastInst(obj, field->classDef->naturalType, "", currentBlock); } std::vector args; args.push_back(mvm::jit::constantZero); args.push_back(field->offset); - ptr = new GetElementPtrInst(obj, args.begin(), args.end(), "", + ptr = GetElementPtrInst::Create(obj, args.begin(), args.end(), "", currentBlock); } @@ -694,7 +701,7 @@ std::vector args; args.push_back(mvm::jit::constantZero); args.push_back(field->offset); - Value* ptr = new GetElementPtrInst(staticCl, args.begin(), args.end(), "", + Value* ptr = GetElementPtrInst::Create(staticCl, args.begin(), args.end(), "", currentBlock); Value* val = pop(); const Type* type = field->signature->naturalType; @@ -720,15 +727,15 @@ BasicBlock* exit = jit->createBasicBlock("verifyNullExit"); BasicBlock* cont = jit->createBasicBlock("verifyNullCont"); - new BranchInst(exit, cont, test, jit->currentBlock); + BranchInst::Create(exit, cont, test, jit->currentBlock); std::vector args; if (currentExceptionBlock != endExceptionBlock) { - new InvokeInst(CLIJit::nullPointerExceptionLLVM, unifiedUnreachable, + InvokeInst::Create(CLIJit::nullPointerExceptionLLVM, unifiedUnreachable, currentExceptionBlock, args.begin(), args.end(), "", exit); } else { - new CallInst(CLIJit::nullPointerExceptionLLVM, args.begin(), + CallInst::Create(CLIJit::nullPointerExceptionLLVM, args.begin(), args.end(), "", exit); new UnreachableInst(exit); } @@ -749,7 +756,8 @@ if (true) { Value* size = arraySize(obj); - Value* cmp = new ICmpInst(ICmpInst::ICMP_SLT, index, size, "", currentBlock); + Value* cmp = new ICmpInst(ICmpInst::ICMP_SLT, index, size, "", + currentBlock); BasicBlock* ifTrue = createBasicBlock("true verifyAndComputePtr"); BasicBlock* ifFalse = createBasicBlock("false verifyAndComputePtr"); @@ -760,11 +768,12 @@ args.push_back(new BitCastInst(obj, VMObject::llvmType, "", ifFalse)); args.push_back(index); if (currentExceptionBlock != endExceptionBlock) { - new InvokeInst(CLIJit::indexOutOfBoundsExceptionLLVM, unifiedUnreachable, - currentExceptionBlock, args.begin(), - args.end(), "", ifFalse); + InvokeInst::Create(CLIJit::indexOutOfBoundsExceptionLLVM, + unifiedUnreachable, + currentExceptionBlock, args.begin(), + args.end(), "", ifFalse); } else { - new CallInst(CLIJit::indexOutOfBoundsExceptionLLVM, args.begin(), + CallInst::Create(CLIJit::indexOutOfBoundsExceptionLLVM, args.begin(), args.end(), "", ifFalse); new UnreachableInst(ifFalse); } @@ -779,8 +788,8 @@ indexes.push_back(zero); indexes.push_back(VMArray::elementsOffset()); indexes.push_back(index); - Value* ptr = new GetElementPtrInst(val, indexes.begin(), indexes.end(), - "", currentBlock); + Value* ptr = GetElementPtrInst::Create(val, indexes.begin(), indexes.end(), + "", currentBlock); return ptr; @@ -798,12 +807,12 @@ if (array->getType() != VMArray::llvmType) { array = new BitCastInst(array, VMArray::llvmType, "", currentBlock); } - return new CallInst(arrayLengthLLVM, array, "", currentBlock); + return CallInst::Create(arrayLengthLLVM, array, "", currentBlock); /* std::vector args; //size= 2 args.push_back(mvm::jit::constantZero); args.push_back(VMArray::sizeOffset()); - Value* ptr = new GetElementPtrInst(array, args.begin(), args.end(), + Value* ptr = GetElementPtrInst::Create(array, args.begin(), args.end(), "", currentBlock); return new LoadInst(ptr, "", currentBlock);*/ } @@ -821,16 +830,17 @@ std::vector elts; elts.push_back(mvm::jit::constantZero); elts.push_back(mvm::jit::constantOne); - Value* targetPtr = new GetElementPtrInst(obj, elts.begin(), elts.end(), "", - entry); + Value* targetPtr = GetElementPtrInst::Create(obj, elts.begin(), elts.end(), + "", entry); elts.pop_back(); elts.push_back(mvm::jit::constantTwo); - Value* handlePtr = new GetElementPtrInst(obj, elts.begin(), elts.end(), "", - entry); + Value* handlePtr = GetElementPtrInst::Create(obj, elts.begin(), elts.end(), + "", entry); + new StoreInst(target, targetPtr, false, entry); new StoreInst(handle, handlePtr, false, entry); - new ReturnInst(entry); + ReturnInst::Create(entry); return func; } @@ -849,7 +859,8 @@ else if (name == N3::invokeName) return invokeDelegate(); else VMThread::get()->vm->error("implement me"); } else { - VMThread::get()->vm->error("implement me %s", compilingClass->printString()); + VMThread::get()->vm->error("implement me %s", + compilingClass->printString()); } return 0; } @@ -884,13 +895,14 @@ PointerType::getUnqual(funcType)); mvm::jit::unprotectConstants(); - Value* result = new CallInst(valPtr, nativeArgs.begin(), nativeArgs.end(), "", currentBlock); + Value* result = CallInst::Create(valPtr, nativeArgs.begin(), + nativeArgs.end(), "", currentBlock); if (result->getType() != Type::VoidTy) - new ReturnInst(result, currentBlock); + ReturnInst::Create(result, currentBlock); else - new ReturnInst(currentBlock); + ReturnInst::Create(currentBlock); return llvmFunction; @@ -936,7 +948,8 @@ } if (!(opcodeInfos[ex->handlerOffset].newBlock)) { - opcodeInfos[ex->handlerOffset].newBlock = createBasicBlock("handlerException"); + opcodeInfos[ex->handlerOffset].newBlock = + createBasicBlock("handlerException"); } ex->handler = opcodeInfos[ex->handlerOffset].newBlock; @@ -999,7 +1012,8 @@ if (i + 1 != e) { next = *(i + 1); if (cur->tryOffset >= next->tryOffset && - cur->tryOffset + cur->tryLength <= next->tryOffset + next->tryLength) { + cur->tryOffset + cur->tryLength <= + next->tryOffset + next->tryLength) { bbNext = realEndExceptionBlock; } else { bbNext = next->realTest; @@ -1011,30 +1025,38 @@ if (cur->realTest != cur->test) { const PointerType* PointerTy_0 = mvm::jit::ptrType; std::vector int32_eh_select_params; - Instruction* ptr_eh_ptr = new CallInst(mvm::jit::llvmGetException, "eh_ptr", cur->test); + Instruction* ptr_eh_ptr = CallInst::Create(mvm::jit::llvmGetException, + "eh_ptr", cur->test); int32_eh_select_params.push_back(ptr_eh_ptr); mvm::jit::protectConstants(); - int32_eh_select_params.push_back(ConstantExpr::getCast(Instruction::BitCast, mvm::jit::personality, PointerTy_0)); + Constant* C = ConstantExpr::getCast(Instruction::BitCast, + mvm::jit::personality, PointerTy_0); + int32_eh_select_params.push_back(C); mvm::jit::unprotectConstants(); int32_eh_select_params.push_back(mvm::jit::constantPtrNull); - new CallInst(mvm::jit::exceptionSelector, int32_eh_select_params.begin(), int32_eh_select_params.end(), "eh_select", cur->test); - new BranchInst(cur->realTest, cur->test); + CallInst::Create(mvm::jit::exceptionSelector, + int32_eh_select_params.begin(), + int32_eh_select_params.end(), "eh_select", cur->test); + BranchInst::Create(cur->realTest, cur->test); } Value* cl = new LoadInst(cur->catchClass->llvmVar(), "", cur->realTest); - Value* cmp = new CallInst(compareExceptionLLVM, cl, "", cur->realTest); - new BranchInst(cur->handler, bbNext, cmp, cur->realTest); + Value* cmp = CallInst::Create(compareExceptionLLVM, cl, "", cur->realTest); + BranchInst::Create(cur->handler, bbNext, cmp, cur->realTest); if (cur->handler->empty()) { - Value* cpp = new CallInst(getCppExceptionLLVM, "", cur->handler); - Value* exc = new CallInst(getCLIExceptionLLVM, "", cur->handler); - new CallInst(clearExceptionLLVM, "", cur->handler); - new CallInst(mvm::jit::exceptionBeginCatch, cpp, "tmp8", cur->handler); + Value* cpp = CallInst::Create(getCppExceptionLLVM, "", cur->handler); + Value* exc = CallInst::Create(getCLIExceptionLLVM, "", cur->handler); + CallInst::Create(clearExceptionLLVM, "", cur->handler); + CallInst::Create(mvm::jit::exceptionBeginCatch, cpp, "tmp8", + cur->handler); std::vector void_28_params; - new CallInst(mvm::jit::exceptionEndCatch, void_28_params.begin(), void_28_params.end(), "", cur->handler); + CallInst::Create(mvm::jit::exceptionEndCatch, void_28_params.begin(), + void_28_params.end(), "", cur->handler); new StoreInst(exc, supplLocal, false, cur->handler); - for (uint16 i = cur->tryOffset; i < cur->tryOffset + cur->tryLength; ++i) { + for (uint16 i = cur->tryOffset; i < cur->tryOffset + cur->tryLength; + ++i) { opcodeInfos[i].exception = exc; } } @@ -1045,7 +1067,6 @@ } -#include Function* CLIJit::compileFatOrTiny() { PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "tiny or fat compile %s\n", compilingMethod->printString()); @@ -1132,13 +1153,15 @@ uint64 size = mvm::jit::getTypeSize(cl->naturalType); std::vector params; - params.push_back(new BitCastInst(alloc, PointerType::getUnqual(Type::Int8Ty), "", currentBlock)); + params.push_back(new BitCastInst(alloc, mvm::jit::ptrType, "", + currentBlock)); params.push_back(mvm::jit::constantInt8Zero); mvm::jit::protectConstants(); params.push_back(ConstantInt::get(Type::Int32Ty, size)); mvm::jit::unprotectConstants(); params.push_back(mvm::jit::constantZero); - new CallInst(mvm::jit::llvm_memset_i32, params.begin(), params.end(), "", currentBlock); + CallInst::Create(mvm::jit::llvm_memset_i32, params.begin(), + params.end(), "", currentBlock); } locals.push_back(alloc); @@ -1151,11 +1174,11 @@ const Type* endType = funcType->getReturnType(); if (endType != Type::VoidTy) { - endNode = new PHINode(endType, "", endBlock); + endNode = PHINode::Create(endType, "", endBlock); } else if (compilingMethod->structReturn) { const Type* lastType = funcType->getContainedType(funcType->getNumContainedTypes() - 1); - endNode = new PHINode(lastType, "", endBlock); + endNode = PHINode::Create(lastType, "", endBlock); } compileOpcodes(&compilingClass->assembly->bytes->elements[offset], codeLen); @@ -1167,23 +1190,26 @@ endBlock->eraseFromParent(); } else { if (endType != Type::VoidTy) { - new ReturnInst(endNode, endBlock); + ReturnInst::Create(endNode, endBlock); } else if (compilingMethod->structReturn) { const Type* lastType = funcType->getContainedType(funcType->getNumContainedTypes() - 1); uint64 size = mvm::jit::getTypeSize(lastType->getContainedType(0)); Value* obj = --llvmFunction->arg_end(); std::vector params; - params.push_back(new BitCastInst(obj, PointerType::getUnqual(Type::Int8Ty), "", currentBlock)); - params.push_back(new BitCastInst(endNode, PointerType::getUnqual(Type::Int8Ty), "", currentBlock)); + params.push_back(new BitCastInst(obj, mvm::jit::ptrType, "", + currentBlock)); + params.push_back(new BitCastInst(endNode, mvm::jit::ptrType, "", + currentBlock)); mvm::jit::protectConstants(); params.push_back(ConstantInt::get(Type::Int32Ty, size)); mvm::jit::unprotectConstants(); params.push_back(mvm::jit::constantFour); - new CallInst(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock); - new ReturnInst(currentBlock); + CallInst::Create(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(), + "", currentBlock); + ReturnInst::Create(currentBlock); } else { - new ReturnInst(endBlock); + ReturnInst::Create(endBlock); } } @@ -1192,9 +1218,9 @@ if (PI == PE) { endExceptionBlock->eraseFromParent(); } else { - CallInst* ptr_eh_ptr = new CallInst(getCppExceptionLLVM, "eh_ptr", + CallInst* ptr_eh_ptr = CallInst::Create(getCppExceptionLLVM, "eh_ptr", endExceptionBlock); - new CallInst(mvm::jit::unwindResume, ptr_eh_ptr, "", endExceptionBlock); + CallInst::Create(mvm::jit::unwindResume, ptr_eh_ptr, "", endExceptionBlock); new UnreachableInst(endExceptionBlock); } @@ -1305,13 +1331,15 @@ uint64 size = mvm::jit::getTypeSize(cl->naturalType); std::vector params; - params.push_back(new BitCastInst(alloc, PointerType::getUnqual(Type::Int8Ty), "", currentBlock)); + params.push_back(new BitCastInst(alloc, mvm::jit::ptrType, "", + currentBlock)); params.push_back(mvm::jit::constantInt8Zero); mvm::jit::protectConstants(); params.push_back(ConstantInt::get(Type::Int32Ty, size)); mvm::jit::unprotectConstants(); params.push_back(mvm::jit::constantZero); - new CallInst(mvm::jit::llvm_memset_i32, params.begin(), params.end(), "", currentBlock); + CallInst::Create(mvm::jit::llvm_memset_i32, params.begin(), + params.end(), "", currentBlock); } locals.push_back(alloc); @@ -1324,18 +1352,19 @@ const Type* endType = funcType->getReturnType(); if (endType != Type::VoidTy) { - endNode = new PHINode(endType, "", endBlock); + endNode = PHINode::Create(endType, "", endBlock); } else if (compilingMethod->structReturn) { const Type* lastType = funcType->getContainedType(funcType->getNumContainedTypes() - 1); - endNode = new PHINode(lastType, "", endBlock); + endNode = PHINode::Create(lastType, "", endBlock); } compileOpcodes(&compilingClass->assembly->bytes->elements[offset], codeLen); curBB = endBlock; - PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "end tiny or fat inline compile %s\n", + PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, + "end tiny or fat inline compile %s\n", compilingMethod->printString()); return endNode; @@ -1362,7 +1391,7 @@ else { classDef->aquire(); if (methPtr == 0) { - methPtr = new llvm::Function(getSignature(), GlobalValue::GhostLinkage, + methPtr = Function::Create(getSignature(), GlobalValue::GhostLinkage, printString(), classDef->vm->module); classDef->vm->functions->hash(methPtr, this); } @@ -1442,10 +1471,10 @@ { std::vector arg_types; - arg_types.insert (arg_types.begin (), llvm::PointerType::getUnqual(llvm::PointerType::getUnqual(llvm::Type::Int8Ty))); + arg_types.insert (arg_types.begin (), llvm::PointerType::getUnqual(mvm::jit::ptrType)); llvm::FunctionType *mtype = llvm::FunctionType::get (llvm::Type::VoidTy, arg_types, false); - new llvm::Function(mtype, llvm::GlobalValue::ExternalLinkage, "llvm.va_start", module); + Function::Create(mtype, llvm::GlobalValue::ExternalLinkage, "llvm.va_start", module); } { @@ -1453,7 +1482,7 @@ arg_types.insert (arg_types.begin (), llvm::Type::Int32Ty); llvm::FunctionType *mtype = llvm::FunctionType::get (llvm::PointerType::getUnqual(llvm::Type::Int8Ty), arg_types, false); - new llvm::Function(mtype, llvm::GlobalValue::ExternalLinkage, "llvm.frameaddress", module); + Function::Create(mtype, llvm::GlobalValue::ExternalLinkage, "llvm.frameaddress", module); } @@ -1462,7 +1491,7 @@ // Prototype malloc as "char* malloc(...)", because we don't know in // doInitialization whether size_t is int or long. FunctionType *FT = FunctionType::get(BPTy, std::vector(), true); - new llvm::Function(FT, llvm::GlobalValue::ExternalLinkage, "_ZN2gcnwEjP5gc_vt", module); + Function::Create(FT, llvm::GlobalValue::ExternalLinkage, "_ZN2gcnwEjP5gc_vt", module); } @@ -1546,7 +1575,7 @@ std::vector args; args.push_back(VMObject::llvmType); markAndTraceLLVMType = FunctionType::get(llvm::Type::VoidTy, args, false); - markAndTraceLLVM = new Function(markAndTraceLLVMType, + markAndTraceLLVM = Function::Create(markAndTraceLLVMType, GlobalValue::ExternalLinkage, "_ZNK2gc12markAndTraceEv", module); @@ -1557,7 +1586,7 @@ std::vector args; args.push_back(VMObject::llvmType); const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - vmObjectTracerLLVM = new Function(type, + vmObjectTracerLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN2n38VMObject6tracerEj", module); @@ -1568,7 +1597,7 @@ std::vector args; args.push_back(PointerType::getUnqual(Type::Int8Ty)); const FunctionType* type = FunctionType::get(VMObject::llvmType, args, false); - initialiseClassLLVM = new Function(type, + initialiseClassLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "initialiseClass", module); @@ -1583,7 +1612,7 @@ args.push_back(llvm::Type::Int32Ty); const FunctionType* type = FunctionType::get(VMObject::llvmType, args, false); - stringLookupLLVM = new Function(type, GlobalValue::ExternalLinkage, + stringLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5n37CLIJit12stringLookupEPKNS_4UTF8EPNS_5ClassEj", module); }*/ @@ -1597,7 +1626,7 @@ FunctionType::get(llvm::PointerType::getUnqual(llvm::Type::Int8Ty), args, false); - staticLookupLLVM = new Function(type, GlobalValue::ExternalLinkage, + staticLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5n37CLIJit12staticLookupEPNS_5ClassEj", module); }*/ @@ -1613,11 +1642,11 @@ const FunctionType* type = FunctionType::get(CacheNode::llvmType, args, false); - virtualLookupLLVM = new Function(type, GlobalValue::ExternalLinkage, + virtualLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "virtualLookup", module); /* - virtualLookupLLVM = new Function(type, GlobalValue::ExternalLinkage, + virtualLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5n37CLIJit13virtualLookupEPNS_10VMObjectEPNS_5ClassEj", module); */ @@ -1631,7 +1660,7 @@ const FunctionType* type = FunctionType::get(VMObject::llvmType, args, false); - newLookupLLVM = new Function(type, GlobalValue::ExternalLinkage, + newLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5n37CLIJit9newLookupEPNS_5ClassEj", module); }*/ @@ -1644,7 +1673,7 @@ const FunctionType* type = FunctionType::get(VMObject::llvmType, args, false); - arrayConsLLVM = new Function(type, GlobalValue::ExternalLinkage, + arrayConsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN2n312VMClassArray5doNewEj", module); } @@ -1656,7 +1685,7 @@ const FunctionType* type = FunctionType::get(VMObject::llvmType, args, false); - objConsLLVM = new Function(type, GlobalValue::ExternalLinkage, + objConsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN2n37VMClass5doNewEv", module); } @@ -1669,7 +1698,7 @@ const FunctionType* type = FunctionType::get(VMObject::llvmType, args, false); - objInitLLVM = new Function(type, GlobalValue::ExternalLinkage, + objInitLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN2n37VMClass16initialiseObjectEPNS_8VMObjectE", module); PAListPtr func_toto_PAL; @@ -1687,7 +1716,7 @@ args.push_back(VMArray::llvmType); const FunctionType* type = FunctionType::get(Type::Int32Ty, args, false); - arrayLengthLLVM = new Function(type, GlobalValue::ExternalLinkage, + arrayLengthLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "arrayLength", module); PAListPtr func_toto_PAL; @@ -1705,7 +1734,7 @@ std::vector args; const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - nullPointerExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage, + nullPointerExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "nullPointerException", module); } @@ -1715,7 +1744,7 @@ std::vector args; const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - classCastExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage, + classCastExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "classCastException", module); } @@ -1727,7 +1756,7 @@ args.push_back(Type::Int32Ty); const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - indexOutOfBoundsExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage, + indexOutOfBoundsExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "indexOutOfBounds", module); } @@ -1737,7 +1766,7 @@ std::vector args; const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - jniProceedPendingExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage, + jniProceedPendingExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5n37CLIJit26jniProceedPendingExceptionEv", module); }*/ @@ -1749,7 +1778,7 @@ args.push_back(Type::Int32Ty); const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - printExecutionLLVM = new Function(type, GlobalValue::ExternalLinkage, + printExecutionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN2n36CLIJit14printExecutionEPcPNS_8VMMethodE", module); } @@ -1760,7 +1789,7 @@ args.push_back(VMObject::llvmType); const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - throwExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage, + throwExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN2n38VMThread14throwExceptionEPNS_8VMObjectE", module); } @@ -1770,7 +1799,7 @@ std::vector args; const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - clearExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage, + clearExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN2n38VMThread14clearExceptionEv", module); } @@ -1782,7 +1811,7 @@ args.push_back(PointerType::getUnqual(Type::Int8Ty)); const FunctionType* type = FunctionType::get(Type::Int1Ty, args, false); - compareExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage, + compareExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN2n38VMThread16compareExceptionEPNS_7VMClassE", module); } @@ -1794,7 +1823,7 @@ args.push_back(PointerType::getUnqual(Type::Int8Ty)); const FunctionType* type = FunctionType::get(Type::Int32Ty, args, false); - instanceOfLLVM = new Function(type, GlobalValue::ExternalLinkage, + instanceOfLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN2n38VMObject10instanceOfEPNS_13VMCommonClassE", module); } @@ -1805,7 +1834,7 @@ args.push_back(VMObject::llvmType); const FunctionType* type = FunctionType::get(Type::Int1Ty, args, false); - isInCodeLLVM = new Function(type, GlobalValue::ExternalLinkage, "isInCode", + isInCodeLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "isInCode", module); } @@ -1816,7 +1845,7 @@ const FunctionType* type = FunctionType::get(VMObject::llvmType, args, true); - arrayMultiConsLLVM = new Function(type, GlobalValue::ExternalLinkage, + arrayMultiConsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "doMultiNew", module); } @@ -1828,7 +1857,7 @@ args.push_back(VMObject::llvmType); const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - aquireObjectLLVM = new Function(type, GlobalValue::ExternalLinkage, + aquireObjectLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5n310VMObject6aquireEv", module); } @@ -1839,7 +1868,7 @@ args.push_back(VMObject::llvmType); const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - releaseObjectLLVM = new Function(type, GlobalValue::ExternalLinkage, + releaseObjectLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5n310VMObject6unlockEv", module); } @@ -1855,35 +1884,35 @@ const FunctionType* type = FunctionType::get(VMObject::llvmType, args, false); - FloatAconsLLVM = new Function(type, GlobalValue::ExternalLinkage, + FloatAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5n310ArrayFloat5aconsEiPNS_10VMClassArrayE", module); - Int8AconsLLVM = new Function(type, GlobalValue::ExternalLinkage, + Int8AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5n310ArraySInt85aconsEiPNS_10VMClassArrayE", module); - DoubleAconsLLVM = new Function(type, GlobalValue::ExternalLinkage, + DoubleAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5n311ArrayDouble5aconsEiPNS_10VMClassArrayE", module); - Int16AconsLLVM = new Function(type, GlobalValue::ExternalLinkage, + Int16AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5n311ArraySInt165aconsEiPNS_10VMClassArrayE", module); - Int32AconsLLVM = new Function(type, GlobalValue::ExternalLinkage, + Int32AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5n311ArraySInt325aconsEiPNS_10VMClassArrayE", module); - UTF8AconsLLVM = new Function(type, GlobalValue::ExternalLinkage, + UTF8AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5n34UTF85aconsEiPNS_10VMClassArrayE", module); - LongAconsLLVM = new Function(type, GlobalValue::ExternalLinkage, + LongAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5n39ArrayLong5aconsEiPNS_10VMClassArrayE", module); - ObjectAconsLLVM = new Function(type, GlobalValue::ExternalLinkage, + ObjectAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5n311ArrayObject5aconsEiPNS_10VMClassArrayE", module); }*/ @@ -1894,7 +1923,7 @@ const FunctionType* type = FunctionType::get(mvm::jit::ptrType, args, false); - getCppExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage, + getCppExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN2n38VMThread15getCppExceptionEv", module); } @@ -1905,7 +1934,7 @@ const FunctionType* type = FunctionType::get(VMObject::llvmType, args, false); - getCLIExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage, + getCLIExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN2n38VMThread15getCLIExceptionEv", module); } @@ -1917,7 +1946,7 @@ const FunctionType* type = FunctionType::get(VMObject::llvmType, args, false); - newStringLLVM = new Function(type, GlobalValue::ExternalLinkage, + newStringLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "newString", module); } @@ -1935,17 +1964,17 @@ llvm::Value* arg = *i; const llvm::Type* type = arg->getType(); if (type == Type::Int8Ty || type == Type::Int16Ty || type == Type::Int1Ty) { - new CallInst(mvm::jit::printIntLLVM, new ZExtInst(arg, Type::Int32Ty, "", insertAt), "", insertAt); + CallInst::Create(mvm::jit::printIntLLVM, new ZExtInst(arg, Type::Int32Ty, "", insertAt), "", insertAt); } else if (type == Type::Int32Ty) { - new CallInst(mvm::jit::printIntLLVM, arg, "", insertAt); + CallInst::Create(mvm::jit::printIntLLVM, arg, "", insertAt); } else if (type == Type::Int64Ty) { - new CallInst(mvm::jit::printLongLLVM, arg, "", insertAt); + CallInst::Create(mvm::jit::printLongLLVM, arg, "", insertAt); } else if (type == Type::FloatTy) { - new CallInst(mvm::jit::printFloatLLVM, arg, "", insertAt); + CallInst::Create(mvm::jit::printFloatLLVM, arg, "", insertAt); } else if (type == Type::DoubleTy) { - new CallInst(mvm::jit::printDoubleLLVM, arg, "", insertAt); + CallInst::Create(mvm::jit::printDoubleLLVM, arg, "", insertAt); } else { - new CallInst(mvm::jit::printObjectLLVM, new BitCastInst(arg, VMObject::llvmType, "", insertAt), "", insertAt); + CallInst::Create(mvm::jit::printObjectLLVM, new BitCastInst(arg, VMObject::llvmType, "", insertAt), "", insertAt); } } @@ -1973,10 +2002,10 @@ if (currentExceptionBlock != endExceptionBlock) { BasicBlock* ifNormal = createBasicBlock("no exception block"); currentBlock = ifNormal; - val = new InvokeInst(F, ifNormal, currentExceptionBlock, args.begin(), + val = InvokeInst::Create(F, ifNormal, currentExceptionBlock, args.begin(), args.end(), Name, InsertAtEnd); } else { - val = new CallInst(F, args.begin(), args.end(), Name, InsertAtEnd); + val = CallInst::Create(F, args.begin(), args.end(), Name, InsertAtEnd); } if (ret) return ret; else return val; @@ -2006,10 +2035,10 @@ if (currentExceptionBlock != endExceptionBlock) { BasicBlock* ifNormal = createBasicBlock("no exception block"); currentBlock = ifNormal; - val = new InvokeInst(F, ifNormal, currentExceptionBlock, args.begin(), + val = InvokeInst::Create(F, ifNormal, currentExceptionBlock, args.begin(), args.end(), Name, InsertAtEnd); } else { - val = new CallInst(F, args.begin(), args.end(), Name, InsertAtEnd); + val = CallInst::Create(F, args.begin(), args.end(), Name, InsertAtEnd); } if (ret) return ret; @@ -2043,10 +2072,10 @@ if (currentExceptionBlock != endExceptionBlock) { BasicBlock* ifNormal = createBasicBlock("no exception block"); currentBlock = ifNormal; - val = new InvokeInst(F, ifNormal, currentExceptionBlock, args.begin(), + val = InvokeInst::Create(F, ifNormal, currentExceptionBlock, args.begin(), args.end(), Name, InsertAtEnd); } else { - val = new CallInst(F, args.begin(), args.end(), Name, InsertAtEnd); + val = CallInst::Create(F, args.begin(), args.end(), Name, InsertAtEnd); } if (ret) return ret; else return val; @@ -2072,10 +2101,10 @@ if (currentExceptionBlock != endExceptionBlock) { BasicBlock* ifNormal = createBasicBlock("no exception block"); currentBlock = ifNormal; - val = new InvokeInst(F, ifNormal, currentExceptionBlock, args.begin(), + val = InvokeInst::Create(F, ifNormal, currentExceptionBlock, args.begin(), args.end(), Name, InsertAtEnd); } else { - val = new CallInst(F, args.begin(), args.end(), Name, InsertAtEnd); + val = CallInst::Create(F, args.begin(), args.end(), Name, InsertAtEnd); } if (ret) return ret; else return val; Modified: vmkit/trunk/lib/N3/VMCore/LowerArrayLength.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/LowerArrayLength.cpp?rev=49332&r1=49331&r2=49332&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/LowerArrayLength.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/LowerArrayLength.cpp Mon Apr 7 07:22:55 2008 @@ -49,8 +49,8 @@ std::vector args; //size= 2 args.push_back(mvm::jit::constantZero); args.push_back(n3::VMArray::sizeOffset()); - Value* ptr = new GetElementPtrInst(val, args.begin(), args.end(), - "", CI); + Value* ptr = GetElementPtrInst::Create(val, args.begin(), args.end(), + "", CI); Value* load = new LoadInst(ptr, "", CI); CI->replaceAllUsesWith(load); CI->eraseFromParent(); Modified: vmkit/trunk/lib/N3/VMCore/Opcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Opcodes.cpp?rev=49332&r1=49331&r2=49332&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/Opcodes.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/Opcodes.cpp Mon Apr 7 07:22:55 2008 @@ -190,7 +190,7 @@ params.push_back(ConstantInt::get(Type::Int32Ty, size)); mvm::jit::unprotectConstants(); params.push_back(mvm::jit::constantZero); - new CallInst(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock); + CallInst::Create(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock); } } @@ -208,7 +208,7 @@ params.push_back(ConstantInt::get(Type::Int32Ty, size)); mvm::jit::unprotectConstants(); params.push_back(mvm::jit::constantZero); - new CallInst(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock); + CallInst::Create(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock); return ret; } } @@ -242,12 +242,12 @@ std::vector args; args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)OpcodeNames[bytecodes[i]])); args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod)); - new CallInst(printExecutionLLVM, args.begin(), args.end(), "", currentBlock); + CallInst::Create(printExecutionLLVM, args.begin(), args.end(), "", currentBlock); if (bytecodes[i] == 0xFE) { std::vector args; args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)OpcodeNamesFE[bytecodes[i + 1]])); args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod)); - new CallInst(printExecutionLLVM, args.begin(), args.end(), "", currentBlock); + CallInst::Create(printExecutionLLVM, args.begin(), args.end(), "", currentBlock); } mvm::jit::unprotectConstants(); #endif @@ -695,13 +695,13 @@ case ENDFINALLY : { Value* val = new LoadInst(supplLocal, "", currentBlock); - /*Value* call = new CallInst(isInCodeLLVM, val, "", currentBlock); + /*Value* call = CallInst::Create(isInCodeLLVM, val, "", currentBlock); BasicBlock* bb1 = createBasicBlock("end finally"); BasicBlock* bb2 = createBasicBlock("no end finally"); - new BranchInst(bb1, bb2, call, currentBlock); + BranchInst::Create(bb1, bb2, call, currentBlock); currentBlock = bb1;*/ val = new PtrToIntInst(val, Type::Int32Ty, "", currentBlock); - SwitchInst* inst = new SwitchInst(val, leaves[0], + SwitchInst* inst = SwitchInst::Create(val, leaves[0], leaves.size(), currentBlock); uint32 index = 0; @@ -1089,7 +1089,7 @@ } else if (compilingMethod->structReturn) { endNode->addIncoming(pop(), currentBlock); } - new BranchInst(endBlock, currentBlock); + BranchInst::Create(endBlock, currentBlock); break; } @@ -1273,7 +1273,7 @@ assert(type); Value* var = new LoadInst(type->llvmVar(), "", currentBlock); - Value* obj = new CallInst(objConsLLVM, var, "", currentBlock); + Value* obj = CallInst::Create(objConsLLVM, var, "", currentBlock); Value* val = pop(); obj = new BitCastInst(obj, type->virtualType, "", currentBlock); @@ -1281,7 +1281,7 @@ std::vector ptrs; ptrs.push_back(mvm::jit::constantZero); ptrs.push_back(mvm::jit::constantOne); - Value* ptr = new GetElementPtrInst(obj, ptrs.begin(), ptrs.end(), "", + Value* ptr = GetElementPtrInst::Create(obj, ptrs.begin(), ptrs.end(), "", currentBlock); if (val->getType()->getTypeID() != Type::PointerTyID) { @@ -1301,7 +1301,7 @@ params.push_back(ConstantInt::get(Type::Int32Ty, size)); mvm::jit::unprotectConstants(); params.push_back(mvm::jit::constantZero); - new CallInst(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock); + CallInst::Create(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock); push(obj); @@ -1335,7 +1335,7 @@ std::vector args; args.push_back(obj); args.push_back(clVar); - Value* call = new CallInst(instanceOfLLVM, args.begin(), args.end(), + Value* call = CallInst::Create(instanceOfLLVM, args.begin(), args.end(), "", ifFalse); cmp = new ICmpInst(ICmpInst::ICMP_EQ, call, @@ -1346,9 +1346,9 @@ std::vector exArgs; if (currentExceptionBlock != endExceptionBlock) { - new InvokeInst(classCastExceptionLLVM, unifiedUnreachable, currentExceptionBlock, exArgs.begin(), exArgs.end(), "", ex); + InvokeInst::Create(classCastExceptionLLVM, unifiedUnreachable, currentExceptionBlock, exArgs.begin(), exArgs.end(), "", ex); } else { - new CallInst(classCastExceptionLLVM, exArgs.begin(), exArgs.end(), "", ex); + CallInst::Create(classCastExceptionLLVM, exArgs.begin(), exArgs.end(), "", ex); new UnreachableInst(ex); } @@ -1380,21 +1380,21 @@ BasicBlock* isInstEndBlock = createBasicBlock("end isinst"); - PHINode* node = new PHINode(dcl->virtualType, "", isInstEndBlock); + PHINode* node = PHINode::Create(dcl->virtualType, "", isInstEndBlock); BasicBlock* ifFalse = createBasicBlock("non null isinst"); BasicBlock* ifTrue = createBasicBlock("null isinst"); - new BranchInst(ifTrue, ifFalse, cmp, currentBlock); + BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock); node->addIncoming(nullVirtual, ifTrue); - new BranchInst(isInstEndBlock, ifTrue); + BranchInst::Create(isInstEndBlock, ifTrue); Value* clVar = new LoadInst(dcl->llvmVar(), "", ifFalse); std::vector args; args.push_back(new BitCastInst(obj, VMObject::llvmType, "", ifFalse)); args.push_back(clVar); - Value* call = new CallInst(instanceOfLLVM, args.begin(), args.end(), + Value* call = CallInst::Create(instanceOfLLVM, args.begin(), args.end(), "", ifFalse); cmp = new ICmpInst(ICmpInst::ICMP_EQ, call, @@ -1402,13 +1402,13 @@ BasicBlock* falseInst = createBasicBlock("false isinst"); BasicBlock* trueInst = createBasicBlock("true isinst"); - new BranchInst(falseInst, trueInst, cmp, ifFalse); + BranchInst::Create(falseInst, trueInst, cmp, ifFalse); node->addIncoming(new BitCastInst(obj, dcl->virtualType, "", trueInst), trueInst); - new BranchInst(isInstEndBlock, trueInst); + BranchInst::Create(isInstEndBlock, trueInst); node->addIncoming(nullVirtual, falseInst); - new BranchInst(isInstEndBlock, falseInst); + BranchInst::Create(isInstEndBlock, falseInst); currentBlock = isInstEndBlock; push(node); @@ -1571,7 +1571,7 @@ Value* val = ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, (int64_t)utf8), mvm::jit::ptrType); mvm::jit::unprotectConstants(); - Value* res = new CallInst(newStringLLVM, val, "", currentBlock); + Value* res = CallInst::Create(newStringLLVM, val, "", currentBlock); /*CLIString * str = (CLIString*)(((N3*)VMThread::get()->vm)->UTF8ToStr(utf8)); GlobalVariable* gv = str->llvmVar(); @@ -1644,7 +1644,7 @@ std::vector args; args.push_back(var); args.push_back(pop()); - Value* val = new CallInst(arrayConsLLVM, args.begin(), args.end(), "", + Value* val = CallInst::Create(arrayConsLLVM, args.begin(), args.end(), "", currentBlock); push(new BitCastInst(val, type->naturalType, "", currentBlock)); break; @@ -1764,9 +1764,9 @@ std::vector args; args.push_back(arg); if (currentExceptionBlock != endExceptionBlock) { - new InvokeInst(throwExceptionLLVM, unifiedUnreachable, currentExceptionBlock, args.begin(), args.end(), "", currentBlock); + InvokeInst::Create(throwExceptionLLVM, unifiedUnreachable, currentExceptionBlock, args.begin(), args.end(), "", currentBlock); } else { - new CallInst(throwExceptionLLVM, args.begin(), args.end(), "", currentBlock); + CallInst::Create(throwExceptionLLVM, args.begin(), args.end(), "", currentBlock); new UnreachableInst(currentBlock); } break; @@ -1790,7 +1790,7 @@ std::vector ptrs; ptrs.push_back(mvm::jit::constantZero); ptrs.push_back(mvm::jit::constantOne); - Value* ptr = new GetElementPtrInst(obj, ptrs.begin(), ptrs.end(), "", + Value* ptr = GetElementPtrInst::Create(obj, ptrs.begin(), ptrs.end(), "", currentBlock); uint64 size = mvm::jit::getTypeSize(type->naturalType); @@ -1802,7 +1802,7 @@ params.push_back(ConstantInt::get(Type::Int32Ty, size)); mvm::jit::unprotectConstants(); params.push_back(mvm::jit::constantZero); - new CallInst(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock); + CallInst::Create(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock); push(val); @@ -1853,7 +1853,7 @@ args.push_back(one); args.push_back(two); args.push_back(three); - new CallInst(mvm::jit::llvm_memcpy_i32, + CallInst::Create(mvm::jit::llvm_memcpy_i32, args.begin(), args.end(), "", currentBlock); break; } @@ -1899,7 +1899,7 @@ args.push_back(one); args.push_back(two); args.push_back(three); - new CallInst(mvm::jit::llvm_memset_i32, + CallInst::Create(mvm::jit::llvm_memset_i32, args.begin(), args.end(), "", currentBlock); break; } @@ -1959,9 +1959,9 @@ args.push_back(CLIJit::constantVMObjectNull); } if (currentExceptionBlock != endExceptionBlock) { - new InvokeInst(throwExceptionLLVM, unifiedUnreachable, currentExceptionBlock, args.begin(), args.end(), "", currentBlock); + InvokeInst::Create(throwExceptionLLVM, unifiedUnreachable, currentExceptionBlock, args.begin(), args.end(), "", currentBlock); } else { - new CallInst(throwExceptionLLVM, args.begin(), args.end(), "", currentBlock); + CallInst::Create(throwExceptionLLVM, args.begin(), args.end(), "", currentBlock); new UnreachableInst(currentBlock); } break; Modified: vmkit/trunk/lib/N3/VMCore/VMCache.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMCache.cpp?rev=49332&r1=49331&r2=49332&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/VMCache.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/VMCache.cpp Mon Apr 7 07:22:55 2008 @@ -74,7 +74,7 @@ makeArgs(funcType, args, origMeth->structReturn); BasicBlock* callBlock = createBasicBlock("call virtual invoke"); - PHINode* node = new PHINode(CacheNode::llvmType, "", callBlock); + PHINode* node = PHINode::Create(CacheNode::llvmType, "", callBlock); Value* argObj = args[0]; if (argObj->getType() != VMObject::llvmType) { @@ -100,14 +100,14 @@ std::vector args1; args1.push_back(zero); args1.push_back(one); - Value* cachePtr = new GetElementPtrInst(llvmEnv, args1.begin(), args1.end(), + Value* cachePtr = GetElementPtrInst::Create(llvmEnv, args1.begin(), args1.end(), "", currentBlock); Value* cache = new LoadInst(cachePtr, "", currentBlock); std::vector args2; args2.push_back(zero); args2.push_back(VMObject::classOffset()); - Value* classPtr = new GetElementPtrInst(argObj, args2.begin(), + Value* classPtr = GetElementPtrInst::Create(argObj, args2.begin(), args2.end(), "", currentBlock); @@ -115,23 +115,23 @@ std::vector args3; args3.push_back(zero); args3.push_back(two); - Value* lastCiblePtr = new GetElementPtrInst(cache, args3.begin(), args3.end(), + Value* lastCiblePtr = GetElementPtrInst::Create(cache, args3.begin(), args3.end(), "", currentBlock); Value* lastCible = new LoadInst(lastCiblePtr, "", currentBlock); Value* cmp = new ICmpInst(ICmpInst::ICMP_EQ, cl, lastCible, "", currentBlock); BasicBlock* ifFalse = createBasicBlock("cache not ok"); - new BranchInst(callBlock, ifFalse, cmp, currentBlock); + BranchInst::Create(callBlock, ifFalse, cmp, currentBlock); node->addIncoming(cache, currentBlock); currentBlock = ifFalse; Value* newCache = invoke(virtualLookupLLVM, cache, argObj, "", ifFalse, false); node->addIncoming(newCache, currentBlock); - new BranchInst(callBlock, currentBlock); + BranchInst::Create(callBlock, currentBlock); currentBlock = callBlock; - Value* methPtr = new GetElementPtrInst(node, args1.begin(), args1.end(), + Value* methPtr = GetElementPtrInst::Create(node, args1.begin(), args1.end(), "", currentBlock); Value* _meth = new LoadInst(methPtr, "", currentBlock); @@ -142,13 +142,13 @@ std::vector args4; args4.push_back(zero); args4.push_back(five); - Value* boxedptr = new GetElementPtrInst(node, args4.begin(), args4.end(), "", currentBlock); + Value* boxedptr = GetElementPtrInst::Create(node, args4.begin(), args4.end(), "", currentBlock); Value* boxed = new LoadInst(boxedptr, "", currentBlock); /* I put VMArray::llvmType here, but in should be something else... */ Value* unboxed = new BitCastInst(args[0], VMArray::llvmType, "", currentBlock); - Value* unboxedptr = new GetElementPtrInst(unboxed, args1.begin(), args1.end(), "", currentBlock); + Value* unboxedptr = GetElementPtrInst::Create(unboxed, args1.begin(), args1.end(), "", currentBlock); Value* fakeunboxedptr = new BitCastInst(unboxedptr, args[0]->getType(), "", currentBlock); - args[0] = new SelectInst(boxed, fakeunboxedptr, args[0], "", currentBlock); + args[0] = SelectInst::Create(boxed, fakeunboxedptr, args[0], "", currentBlock); Value* ret = invoke(meth, args, "", currentBlock, origMeth->structReturn); From nicolas.geoffray at lip6.fr Mon Apr 7 07:30:02 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 07 Apr 2008 12:30:02 -0000 Subject: [llvm-commits] [vmkit] r49333 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaCache.cpp JavaClass.cpp JavaConstantPool.cpp JavaIsolate.cpp JavaJIT.cpp JavaJITInitialise.cpp JavaJITOpcodes.cpp JavaMetaJIT.cpp JavaTypes.cpp JavaTypes.h JavaUpcalls.cpp LowerArrayLength.cpp Message-ID: <200804071230.m37CU3ig023589@zion.cs.uiuc.edu> Author: geoffray Date: Mon Apr 7 07:30:00 2008 New Revision: 49333 URL: http://llvm.org/viewvc/llvm-project?rev=49333&view=rev Log: SERVICE_VM bugfixes and port to the new LLVM Value interface Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp vmkit/trunk/lib/JnJVM/VMCore/LowerArrayLength.cpp Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp?rev=49333&r1=49332&r2=49333&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp Mon Apr 7 07:30:00 2008 @@ -80,7 +80,7 @@ BasicBlock* endBlock = createBasicBlock("end virtual invoke"); PHINode * node = 0; if (retType != Type::VoidTy) { - node = new PHINode(retType, "", endBlock); + node = PHINode::Create(retType, "", endBlock); } // ok now the cache @@ -103,14 +103,14 @@ std::vector args1; args1.push_back(zero); args1.push_back(one); - Value* cachePtr = new GetElementPtrInst(llvmEnv, args1.begin(), args1.end(), + Value* cachePtr = GetElementPtrInst::Create(llvmEnv, args1.begin(), args1.end(), "", currentBlock); Value* cache = new LoadInst(cachePtr, "", currentBlock); std::vector args2; args2.push_back(zero); args2.push_back(JavaObject::classOffset()); - Value* classPtr = new GetElementPtrInst(args[0], args2.begin(), + Value* classPtr = GetElementPtrInst::Create(args[0], args2.begin(), args2.end(), "", currentBlock); @@ -118,7 +118,7 @@ std::vector args3; args3.push_back(zero); args3.push_back(two); - Value* lastCiblePtr = new GetElementPtrInst(cache, args3.begin(), args3.end(), + Value* lastCiblePtr = GetElementPtrInst::Create(cache, args3.begin(), args3.end(), "", currentBlock); Value* lastCible = new LoadInst(lastCiblePtr, "", currentBlock); @@ -126,7 +126,7 @@ BasicBlock* ifTrue = createBasicBlock("cache ok"); BasicBlock* ifFalse = createBasicBlock("cache not ok"); - new BranchInst(ifTrue, ifFalse, cmp, currentBlock); + BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock); currentBlock = ifFalse; Value* _meth = invoke(virtualLookupLLVM, cache, args[0], "", ifFalse); @@ -136,18 +136,18 @@ if (node) { node->addIncoming(ret, currentBlock); } - new BranchInst(endBlock, currentBlock); + BranchInst::Create(endBlock, currentBlock); currentBlock = ifTrue; - Value* methPtr = new GetElementPtrInst(cache, args1.begin(), args1.end(), + Value* methPtr = GetElementPtrInst::Create(cache, args1.begin(), args1.end(), "", currentBlock); _meth = new LoadInst(methPtr, "", currentBlock); meth = new BitCastInst(_meth, signature->virtualTypePtr, "", currentBlock); ret = invoke(meth, args, "", currentBlock); - new BranchInst(endBlock, currentBlock); + BranchInst::Create(endBlock, currentBlock); if (node) { node->addIncoming(ret, currentBlock); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=49333&r1=49332&r2=49333&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Mon Apr 7 07:30:00 2008 @@ -607,7 +607,7 @@ } JavaObject* Class::createStaticInstance() { - JavaObject* val = (JavaObject*)mvm::Object::gcmalloc(staticSize, staticVT); + JavaObject* val = (JavaObject*)gc::operator new(staticSize, staticVT); val->initialise(this); for (std::vector::iterator i = this->staticFields.begin(), e = this->staticFields.end(); i!= e; ++i) { Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp?rev=49333&r1=49332&r2=49333&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp Mon Apr 7 07:30:00 2008 @@ -428,9 +428,10 @@ } else { type = sign->virtualType; } - llvm::Function* func = new llvm::Function(type, - llvm::GlobalValue::GhostLinkage, - "callback", classDef->isolate->module); + llvm::Function* func = llvm::Function::Create(type, + llvm::GlobalValue::GhostLinkage, + "callback", + classDef->isolate->module); classDef->isolate->TheModuleProvider->functions->hash(func, new std::pair(classDef, index)); ctpRes[index] = func; Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp?rev=49333&r1=49332&r2=49333&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp Mon Apr 7 07:30:00 2008 @@ -501,7 +501,8 @@ #ifndef SINGLE_VM isolate->statics = StaticInstanceMap::allocate(); isolate->delegatees = DelegateeMap::allocate(); -#else +#endif +#if defined(SINGLE_VM) || defined(SERVICE_VM) isolate->threadSystem = ThreadSystem::allocateThreadSystem(); #endif Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=49333&r1=49332&r2=49333&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Mon Apr 7 07:30:00 2008 @@ -14,55 +14,14 @@ #include -#include -#include -#include #include -#include #include #include #include -#include -#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include "llvm/Constants.h" -#include "llvm/DerivedTypes.h" -#include "llvm/Module.h" -#include "llvm/ModuleProvider.h" -#include "llvm/PassManager.h" -#include "llvm/ValueSymbolTable.h" -#include "llvm/Analysis/LoadValueNumbering.h" -#include "llvm/Analysis/LoopPass.h" -#include "llvm/Analysis/Verifier.h" -#include "llvm/Assembly/Writer.h" -#include "llvm/Assembly/PrintModulePass.h" -#include "llvm/Bitcode/ReaderWriter.h" -#include "llvm/CodeGen/RegAllocRegistry.h" -#include "llvm/CodeGen/SchedulerRegistry.h" -#include "llvm/CodeGen/ScheduleDAG.h" -#include "llvm/Target/SubtargetFeature.h" -#include "llvm/Target/TargetData.h" -#include "llvm/Target/TargetLowering.h" -#include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetMachineRegistry.h" -#include "llvm/Transforms/Scalar.h" -#include "llvm/Transforms/IPO.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/StringMap.h" -#include "llvm/Support/Streams.h" -#include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/MemoryBuffer.h" - -#include - +#include #include "mvm/JIT.h" #include "mvm/Method.h" @@ -84,9 +43,6 @@ #include "Reader.h" #include "Zip.h" -#include - - using namespace jnjvm; using namespace llvm; @@ -99,7 +55,7 @@ } BasicBlock* JavaJIT::createBasicBlock(const char* name) { - return new BasicBlock(name, llvmFunction); + return llvm::BasicBlock::Create(name, llvmFunction); } Value* JavaJIT::top() { @@ -164,15 +120,15 @@ bool jnjvm = false; natPtr = natPtr ? natPtr : - NativeUtil::nativeLookup(compilingClass, compilingMethod, jnjvm); + NativeUtil::nativeLookup(compilingClass, compilingMethod, jnjvm); compilingClass->isolate->protectModule->lock(); - Function* func = llvmFunction = new llvm::Function(funcType, - GlobalValue::ExternalLinkage, - compilingMethod->printString(), - compilingClass->isolate->module); + Function* func = llvmFunction = + llvm::Function::Create(funcType, GlobalValue::ExternalLinkage, + compilingMethod->printString(), + compilingClass->isolate->module); compilingClass->isolate->protectModule->unlock(); if (jnjvm) { @@ -184,37 +140,44 @@ BasicBlock* executeBlock = createBasicBlock("execute"); endBlock = createBasicBlock("end block"); if (funcType->getReturnType() != Type::VoidTy) - endNode = new PHINode(funcType->getReturnType(), "", endBlock); + endNode = llvm::PHINode::Create(funcType->getReturnType(), "", endBlock); - Value* buf = new CallInst(getSJLJBufferLLVM, "", currentBlock); - Value* test = new CallInst(mvm::jit::setjmpLLVM, buf, "", currentBlock); - test = new ICmpInst(ICmpInst::ICMP_EQ, test, mvm::jit::constantZero, "", currentBlock); - new BranchInst(executeBlock, endBlock, test, currentBlock); - if (compilingMethod->signature->ret->funcs != AssessorDesc::dVoid) - endNode->addIncoming(compilingMethod->signature->ret->funcs->llvmNullConstant, currentBlock); + Value* buf = llvm::CallInst::Create(getSJLJBufferLLVM, "", currentBlock); + Value* test = llvm::CallInst::Create(mvm::jit::setjmpLLVM, buf, "", currentBlock); + test = new ICmpInst(ICmpInst::ICMP_EQ, test, mvm::jit::constantZero, "", + currentBlock); + llvm::BranchInst::Create(executeBlock, endBlock, test, currentBlock); + + if (compilingMethod->signature->ret->funcs != AssessorDesc::dVoid) { + Constant* C = compilingMethod->signature->ret->funcs->llvmNullConstant; + endNode->addIncoming(C, currentBlock); + } currentBlock = executeBlock; if (isSynchro(compilingMethod->access)) beginSynchronize(); - uint32 nargs = func->arg_size() + 1 + (stat ? 1 : 0); // + vm + cl/obj + uint32 nargs = func->arg_size() + 1 + (stat ? 1 : 0); std::vector nativeArgs; - mvm::jit::protectConstants();//->lock(); + mvm::jit::protectConstants(); + int64_t jniEnv = (int64_t)&(compilingClass->isolate->jniEnv); nativeArgs.push_back( - ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, - (int64_t)&(compilingClass->isolate->jniEnv)), - mvm::jit::ptrType)); - mvm::jit::unprotectConstants();//->unlock(); + ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, jniEnv), + mvm::jit::ptrType)); + mvm::jit::unprotectConstants(); uint32 index = 0; if (stat) { #ifdef SINGLE_VM - nativeArgs.push_back(new LoadInst(compilingClass->llvmDelegatee(), "", currentBlock)); + nativeArgs.push_back(new LoadInst(compilingClass->llvmDelegatee(), "", + currentBlock)); #else - Value* ld = new LoadInst(compilingClass->llvmVar(compilingClass->isolate->module), "", currentBlock); - nativeArgs.push_back(new CallInst(getClassDelegateeLLVM, ld, "", currentBlock)); + Module* M = compilingClass->isolate->module; + Value* ld = new LoadInst(compilingClass->llvmVar(M), "", currentBlock); + nativeArgs.push_back(llvm::CallInst::Create(getClassDelegateeLLVM, ld, "", + currentBlock)); #endif index = 2; } else { @@ -234,21 +197,23 @@ valPtrType); mvm::jit::unprotectConstants();//->unlock(); - Value* result = new CallInst(valPtr, nativeArgs.begin(), nativeArgs.end(), "", currentBlock); + Value* result = llvm::CallInst::Create(valPtr, nativeArgs.begin(), nativeArgs.end(), + "", currentBlock); + if (funcType->getReturnType() != Type::VoidTy) endNode->addIncoming(result, currentBlock); - new BranchInst(endBlock, currentBlock); + llvm::BranchInst::Create(endBlock, currentBlock); currentBlock = endBlock; if (isSynchro(compilingMethod->access)) endSynchronize(); - new CallInst(jniProceedPendingExceptionLLVM, "", currentBlock); + llvm::CallInst::Create(jniProceedPendingExceptionLLVM, "", currentBlock); if (funcType->getReturnType() != Type::VoidTy) - new ReturnInst(result, currentBlock); + llvm::ReturnInst::Create(result, currentBlock); else - new ReturnInst(currentBlock); + llvm::ReturnInst::Create(currentBlock); PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "end native compile %s\n", compilingMethod->printString()); @@ -261,15 +226,16 @@ if (isVirtual(compilingMethod->access)) { argsSync.push_back(llvmFunction->arg_begin()); } else { - Value* arg = new LoadInst(compilingClass->staticVar(compilingClass->isolate->module), "", currentBlock); + Module* M = compilingClass->isolate->module; + Value* arg = new LoadInst(compilingClass->staticVar(M), "", currentBlock); #ifndef SINGLE_VM if (compilingClass->isolate == Jnjvm::bootstrapVM) { - arg = new CallInst(getStaticInstanceLLVM, arg, "", currentBlock); + arg = llvm::CallInst::Create(getStaticInstanceLLVM, arg, "", currentBlock); } #endif argsSync.push_back(arg); } - new CallInst(aquireObjectLLVM, argsSync.begin(), argsSync.end(), "", currentBlock); + llvm::CallInst::Create(aquireObjectLLVM, argsSync.begin(), argsSync.end(), "", currentBlock); } void JavaJIT::endSynchronize() { @@ -277,19 +243,22 @@ if (isVirtual(compilingMethod->access)) { argsSync.push_back(llvmFunction->arg_begin()); } else { - Value* arg = new LoadInst(compilingClass->staticVar(compilingClass->isolate->module), "", currentBlock); + Module* M = compilingClass->isolate->module; + Value* arg = new LoadInst(compilingClass->staticVar(M), "", currentBlock); #ifndef SINGLE_VM if (compilingClass->isolate == Jnjvm::bootstrapVM) { - arg = new CallInst(getStaticInstanceLLVM, arg, "", currentBlock); + arg = llvm::CallInst::Create(getStaticInstanceLLVM, arg, "", currentBlock); } #endif argsSync.push_back(arg); } - new CallInst(releaseObjectLLVM, argsSync.begin(), argsSync.end(), "", currentBlock); + llvm::CallInst::Create(releaseObjectLLVM, argsSync.begin(), argsSync.end(), "", + currentBlock); } -Instruction* JavaJIT::inlineCompile(Function* parentFunction, BasicBlock*& curBB, +Instruction* JavaJIT::inlineCompile(Function* parentFunction, + BasicBlock*& curBB, BasicBlock* endExBlock, std::vector& args) { PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "inline compile %s\n", @@ -299,9 +268,11 @@ Attribut* codeAtt = Attribut::lookup(&compilingMethod->attributs, Attribut::codeAttribut); - if (!codeAtt) - JavaThread::get()->isolate->unknownError("unable to find the code attribut in %s", - compilingMethod->printString()); + if (!codeAtt) { + Jnjvm* vm = JavaThread::get()->isolate; + vm->unknownError("unable to find the code attribut in %s", + compilingMethod->printString()); + } Reader* reader = codeAtt->toReader(compilingClass->bytes, codeAtt); maxStack = reader->readU2(); @@ -335,8 +306,13 @@ uint32 index = 0; uint32 count = 0; +#ifdef SERVICE_VM + uint32 max = args.size() - 1; +#else + uint32 max = args.size(); +#endif for (std::vector::iterator i = args.begin(); - count < args.size(); ++i, ++index, ++count) { + count < max; ++i, ++index, ++count) { const Type* cur = (*i)->getType(); @@ -363,7 +339,7 @@ endBlock = createBasicBlock("end"); if (returnType != Type::VoidTy) { - endNode = new PHINode(returnType, "", endBlock); + endNode = llvm::PHINode::Create(returnType, "", endBlock); } compileOpcodes(&compilingClass->bytes->elements[start], codeLen); @@ -385,9 +361,11 @@ Attribut* codeAtt = Attribut::lookup(&compilingMethod->attributs, Attribut::codeAttribut); - if (!codeAtt) - JavaThread::get()->isolate->unknownError("unable to find the code attribut in %s", - compilingMethod->printString()); + if (!codeAtt) { + Jnjvm* vm = JavaThread::get()->isolate; + vm->unknownError("unable to find the code attribut in %s", + compilingMethod->printString()); + } Reader* reader = codeAtt->toReader(compilingClass->bytes, codeAtt); maxStack = reader->readU2(); @@ -401,10 +379,10 @@ returnType = funcType->getReturnType(); compilingClass->isolate->protectModule->lock(); - Function* func = llvmFunction = new llvm::Function(funcType, - GlobalValue::ExternalLinkage, - compilingMethod->printString(), - compilingClass->isolate->module); + Function* func = llvmFunction = + llvm::Function::Create(funcType, GlobalValue::ExternalLinkage, + compilingMethod->printString(), + compilingClass->isolate->module); compilingClass->isolate->protectModule->unlock(); currentBlock = createBasicBlock("start"); @@ -423,7 +401,7 @@ mvm::jit::protectConstants();//->lock(); args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod)); mvm::jit::unprotectConstants();//->unlock(); - new CallInst(printMethodStartLLVM, args.begin(), args.end(), "", currentBlock); + llvm::CallInst::Create(printMethodStartLLVM, args.begin(), args.end(), "", currentBlock); } #endif @@ -440,8 +418,13 @@ uint32 index = 0; uint32 count = 0; +#ifdef SERVICE_VM + uint32 max = func->arg_size() - 1; +#else + uint32 max = func->arg_size(); +#endif for (Function::arg_iterator i = func->arg_begin(); - count < func->arg_size(); ++i, ++index, ++count) { + count < max; ++i, ++index, ++count) { const Type* cur = i->getType(); @@ -471,7 +454,7 @@ endBlock = createBasicBlock("end"); if (returnType != Type::VoidTy) { - endNode = new PHINode(returnType, "", endBlock); + endNode = llvm::PHINode::Create(returnType, "", endBlock); } if (isSynchro(compilingMethod->access)) @@ -489,23 +472,23 @@ mvm::jit::protectConstants();//->lock(); args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod)); mvm::jit::unprotectConstants();//->unlock(); - new CallInst(printMethodEndLLVM, args.begin(), args.end(), "", currentBlock); + llvm::CallInst::Create(printMethodEndLLVM, args.begin(), args.end(), "", currentBlock); } #endif if (returnType != Type::VoidTy) - new ReturnInst(endNode, endBlock); + llvm::ReturnInst::Create(endNode, endBlock); else - new ReturnInst(endBlock); + llvm::ReturnInst::Create(endBlock); pred_iterator PI = pred_begin(endExceptionBlock); pred_iterator PE = pred_end(endExceptionBlock); if (PI == PE) { endExceptionBlock->eraseFromParent(); } else { - CallInst* ptr_eh_ptr = new CallInst(getExceptionLLVM, "eh_ptr", + CallInst* ptr_eh_ptr = llvm::CallInst::Create(getExceptionLLVM, "eh_ptr", endExceptionBlock); - new CallInst(mvm::jit::unwindResume, ptr_eh_ptr, "", endExceptionBlock); + llvm::CallInst::Create(mvm::jit::unwindResume, ptr_eh_ptr, "", endExceptionBlock); new UnreachableInst(endExceptionBlock); } @@ -567,22 +550,22 @@ Value* arg = new LoadInst(compilingClass->staticVar(compilingClass->isolate->module), "", currentBlock); #ifndef SINGLE_VM if (compilingClass->isolate == Jnjvm::bootstrapVM) { - arg = new CallInst(getStaticInstanceLLVM, arg, "", currentBlock); + arg = llvm::CallInst::Create(getStaticInstanceLLVM, arg, "", currentBlock); } #endif argsSync.push_back(arg); } - new CallInst(releaseObjectLLVM, argsSync.begin(), argsSync.end(), "", synchronizeExceptionBlock); - new BranchInst(endExceptionBlock, synchronizeExceptionBlock); + llvm::CallInst::Create(releaseObjectLLVM, argsSync.begin(), argsSync.end(), "", synchronizeExceptionBlock); + llvm::BranchInst::Create(endExceptionBlock, synchronizeExceptionBlock); const PointerType* PointerTy_0 = mvm::jit::ptrType; std::vector int32_eh_select_params; - Instruction* ptr_eh_ptr = new CallInst(mvm::jit::llvmGetException, "eh_ptr", trySynchronizeExceptionBlock); + Instruction* ptr_eh_ptr = llvm::CallInst::Create(mvm::jit::llvmGetException, "eh_ptr", trySynchronizeExceptionBlock); int32_eh_select_params.push_back(ptr_eh_ptr); int32_eh_select_params.push_back(ConstantExpr::getCast(Instruction::BitCast, mvm::jit::personality, PointerTy_0)); int32_eh_select_params.push_back(mvm::jit::constantPtrNull); - new CallInst(mvm::jit::exceptionSelector, int32_eh_select_params.begin(), int32_eh_select_params.end(), "eh_select", trySynchronizeExceptionBlock); - new BranchInst(synchronizeExceptionBlock, trySynchronizeExceptionBlock); + llvm::CallInst::Create(mvm::jit::exceptionSelector, int32_eh_select_params.begin(), int32_eh_select_params.end(), "eh_select", trySynchronizeExceptionBlock); + llvm::BranchInst::Create(synchronizeExceptionBlock, trySynchronizeExceptionBlock); for (uint16 i = 0; i < codeLen; ++i) { if (opcodeInfos[i].exceptionBlock == endExceptionBlock) { @@ -641,7 +624,7 @@ cur->realTest = cur->test; } - cur->exceptionPHI = new PHINode(mvm::jit::ptrType, "", cur->realTest); + cur->exceptionPHI = llvm::PHINode::Create(mvm::jit::ptrType, "", cur->realTest); if (next && cur->startpc == next->startpc && cur->endpc == next->endpc) first = false; @@ -672,29 +655,29 @@ if (cur->realTest != cur->test) { const PointerType* PointerTy_0 = mvm::jit::ptrType; std::vector int32_eh_select_params; - Instruction* ptr_eh_ptr = new CallInst(mvm::jit::llvmGetException, "eh_ptr", cur->test); + Instruction* ptr_eh_ptr = llvm::CallInst::Create(mvm::jit::llvmGetException, "eh_ptr", cur->test); int32_eh_select_params.push_back(ptr_eh_ptr); int32_eh_select_params.push_back(ConstantExpr::getCast(Instruction::BitCast, mvm::jit::personality, PointerTy_0)); int32_eh_select_params.push_back(mvm::jit::constantPtrNull); - new CallInst(mvm::jit::exceptionSelector, int32_eh_select_params.begin(), int32_eh_select_params.end(), "eh_select", cur->test); - new BranchInst(cur->realTest, cur->test); + llvm::CallInst::Create(mvm::jit::exceptionSelector, int32_eh_select_params.begin(), int32_eh_select_params.end(), "eh_select", cur->test); + llvm::BranchInst::Create(cur->realTest, cur->test); cur->exceptionPHI->addIncoming(ptr_eh_ptr, cur->test); } Value* cl = new LoadInst(cur->catchClass->llvmVar(compilingClass->isolate->module), "", cur->realTest); - Value* cmp = new CallInst(compareExceptionLLVM, cl, "", cur->realTest); - new BranchInst(cur->handler, bbNext, cmp, cur->realTest); + Value* cmp = llvm::CallInst::Create(compareExceptionLLVM, cl, "", cur->realTest); + llvm::BranchInst::Create(cur->handler, bbNext, cmp, cur->realTest); if (nodeNext) nodeNext->addIncoming(cur->exceptionPHI, cur->realTest); if (cur->handler->empty()) { - cur->handlerPHI = new PHINode(mvm::jit::ptrType, "", cur->handler); + cur->handlerPHI = llvm::PHINode::Create(mvm::jit::ptrType, "", cur->handler); cur->handlerPHI->addIncoming(cur->exceptionPHI, cur->realTest); - Value* exc = new CallInst(getJavaExceptionLLVM, "", cur->handler); - new CallInst(clearExceptionLLVM, "", cur->handler); - new CallInst(mvm::jit::exceptionBeginCatch, cur->handlerPHI, "tmp8", cur->handler); + Value* exc = llvm::CallInst::Create(getJavaExceptionLLVM, "", cur->handler); + llvm::CallInst::Create(clearExceptionLLVM, "", cur->handler); + llvm::CallInst::Create(mvm::jit::exceptionBeginCatch, cur->handlerPHI, "tmp8", cur->handler); std::vector void_28_params; - new CallInst(mvm::jit::exceptionEndCatch, void_28_params.begin(), void_28_params.end(), "", cur->handler); + llvm::CallInst::Create(mvm::jit::exceptionEndCatch, void_28_params.begin(), void_28_params.end(), "", cur->handler); new StoreInst(exc, supplLocal, false, cur->handler); } else { Instruction* insn = cur->handler->begin(); @@ -713,11 +696,11 @@ Value* minus = mvm::jit::constantMinusOne; Value* c = new FCmpInst(FCmpInst::FCMP_UGT, val1, val2, "", currentBlock); - Value* r = new SelectInst(c, one, zero, "", currentBlock); + Value* r = llvm::SelectInst::Create(c, one, zero, "", currentBlock); c = new FCmpInst(FCmpInst::FCMP_ULT, val1, val2, "", currentBlock); - r = new SelectInst(c, minus, r, "", currentBlock); + r = llvm::SelectInst::Create(c, minus, r, "", currentBlock); c = new FCmpInst(FCmpInst::FCMP_UNO, val1, val2, "", currentBlock); - r = new SelectInst(c, l ? one : minus, r, "", currentBlock); + r = llvm::SelectInst::Create(c, l ? one : minus, r, "", currentBlock); push(r, AssessorDesc::dInt); @@ -776,7 +759,7 @@ } #ifndef SINGLE_VM if (compilingClass->isolate == Jnjvm::bootstrapVM) - push(new CallInst(runtimeUTF8ToStrLLVM, toPush, "", currentBlock), AssessorDesc::dRef); + push(llvm::CallInst::Create(runtimeUTF8ToStrLLVM, toPush, "", currentBlock), AssessorDesc::dRef); else #endif push(toPush, AssessorDesc::dRef); @@ -813,14 +796,14 @@ BasicBlock* exit = jit->createBasicBlock("verifyNullExit"); BasicBlock* cont = jit->createBasicBlock("verifyNullCont"); - new BranchInst(exit, cont, test, jit->currentBlock); + llvm::BranchInst::Create(exit, cont, test, jit->currentBlock); std::vector args; if (currentExceptionBlock != endExceptionBlock) { - new InvokeInst(JavaJIT::nullPointerExceptionLLVM, unifiedUnreachable, + llvm::InvokeInst::Create(JavaJIT::nullPointerExceptionLLVM, unifiedUnreachable, currentExceptionBlock, args.begin(), args.end(), "", exit); } else { - new CallInst(JavaJIT::nullPointerExceptionLLVM, args.begin(), + llvm::CallInst::Create(JavaJIT::nullPointerExceptionLLVM, args.begin(), args.end(), "", exit); new UnreachableInst(exit); } @@ -852,11 +835,11 @@ args.push_back(obj); args.push_back(index); if (currentExceptionBlock != endExceptionBlock) { - new InvokeInst(JavaJIT::indexOutOfBoundsExceptionLLVM, unifiedUnreachable, + llvm::InvokeInst::Create(JavaJIT::indexOutOfBoundsExceptionLLVM, unifiedUnreachable, currentExceptionBlock, args.begin(), args.end(), "", ifFalse); } else { - new CallInst(JavaJIT::indexOutOfBoundsExceptionLLVM, args.begin(), + llvm::CallInst::Create(JavaJIT::indexOutOfBoundsExceptionLLVM, args.begin(), args.end(), "", ifFalse); new UnreachableInst(ifFalse); } @@ -871,7 +854,7 @@ indexes.push_back(zero); indexes.push_back(JavaArray::elementsOffset()); indexes.push_back(index); - Value* ptr = new GetElementPtrInst(val, indexes.begin(), indexes.end(), + Value* ptr = llvm::GetElementPtrInst::Create(val, indexes.begin(), indexes.end(), "", currentBlock); return ptr; @@ -910,13 +893,13 @@ const AssessorDesc* func = i->second; PHINode* node = 0; if (func == AssessorDesc::dChar || func == AssessorDesc::dBool) { - node = new PHINode(Type::Int32Ty, "", dest); + node = llvm::PHINode::Create(Type::Int32Ty, "", dest); cur = new ZExtInst(cur, Type::Int32Ty, "", jit->currentBlock); } else if (func == AssessorDesc::dByte || func == AssessorDesc::dShort) { - node = new PHINode(Type::Int32Ty, "", dest); + node = llvm::PHINode::Create(Type::Int32Ty, "", dest); cur = new SExtInst(cur, Type::Int32Ty, "", jit->currentBlock); } else { - node = new PHINode(cur->getType(), "", dest); + node = llvm::PHINode::Create(cur->getType(), "", dest); } node->addIncoming(cur, insert); } @@ -946,21 +929,31 @@ void JavaJIT::branch(llvm::BasicBlock* dest, llvm::BasicBlock* insert) { testPHINodes(dest, insert, this); - new BranchInst(dest, insert); + llvm::BranchInst::Create(dest, insert); } void JavaJIT::branch(llvm::Value* test, llvm::BasicBlock* ifTrue, llvm::BasicBlock* ifFalse, llvm::BasicBlock* insert) { testPHINodes(ifTrue, insert, this); testPHINodes(ifFalse, insert, this); - new BranchInst(ifTrue, ifFalse, test, insert); + llvm::BranchInst::Create(ifTrue, ifFalse, test, insert); } void JavaJIT::makeArgs(FunctionType::param_iterator it, uint32 index, std::vector& Args, uint32 nb) { +#ifdef SERVICE_VM + nb++; +#endif Args.reserve(nb + 2); Value* args[nb]; - for (sint32 i = nb - 1; i >= 0; --i) { +#ifdef SERVICE_VM + args[nb - 1] = mvm::jit::constantPtrNull; + sint32 start = nb - 2; + it--; +#else + sint32 start = nb - 1; +#endif + for (sint32 i = start; i >= 0; --i) { it--; if (it->get() == Type::Int64Ty || it->get() == Type::DoubleTy) { pop(); @@ -999,62 +992,62 @@ ConstantInt* const_int32_10 = mvm::jit::constantMinusOne; BinaryOperator* int32_tmpneg = BinaryOperator::create(Instruction::Sub, const_int32_9, args[0], "tmpneg", currentBlock); ICmpInst* int1_abscond = new ICmpInst(ICmpInst::ICMP_SGT, args[0], const_int32_10, "abscond", currentBlock); - return new SelectInst(int1_abscond, args[0], int32_tmpneg, "abs", currentBlock); + return llvm::SelectInst::Create(int1_abscond, args[0], int32_tmpneg, "abs", currentBlock); } else if (Ty == Type::Int64Ty) { Constant* const_int64_9 = mvm::jit::constantLongZero; ConstantInt* const_int64_10 = mvm::jit::constantLongMinusOne; BinaryOperator* int64_tmpneg = BinaryOperator::create(Instruction::Sub, const_int64_9, args[0], "tmpneg", currentBlock); ICmpInst* int1_abscond = new ICmpInst(ICmpInst::ICMP_SGT, args[0], const_int64_10, "abscond", currentBlock); - return new SelectInst(int1_abscond, args[0], int64_tmpneg, "abs", currentBlock); + return llvm::SelectInst::Create(int1_abscond, args[0], int64_tmpneg, "abs", currentBlock); } else if (Ty == Type::FloatTy) { - return new CallInst(mvm::jit::func_llvm_fabs_f32, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_fabs_f32, args[0], "tmp1", currentBlock); } else if (Ty == Type::DoubleTy) { - return new CallInst(mvm::jit::func_llvm_fabs_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_fabs_f64, args[0], "tmp1", currentBlock); } } else if (name == Jnjvm::sqrt) { - return new CallInst(mvm::jit::func_llvm_sqrt_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_sqrt_f64, args[0], "tmp1", currentBlock); } else if (name == Jnjvm::sin) { - return new CallInst(mvm::jit::func_llvm_sin_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_sin_f64, args[0], "tmp1", currentBlock); } else if (name == Jnjvm::cos) { - return new CallInst(mvm::jit::func_llvm_cos_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_cos_f64, args[0], "tmp1", currentBlock); } else if (name == Jnjvm::tan) { - return new CallInst(mvm::jit::func_llvm_tan_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_tan_f64, args[0], "tmp1", currentBlock); } else if (name == Jnjvm::asin) { - return new CallInst(mvm::jit::func_llvm_asin_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_asin_f64, args[0], "tmp1", currentBlock); } else if (name == Jnjvm::acos) { - return new CallInst(mvm::jit::func_llvm_acos_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_acos_f64, args[0], "tmp1", currentBlock); } else if (name == Jnjvm::atan) { - return new CallInst(mvm::jit::func_llvm_atan_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_atan_f64, args[0], "tmp1", currentBlock); } else if (name == Jnjvm::atan2) { - return new CallInst(mvm::jit::func_llvm_atan2_f64, args.begin(), args.end(), "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_atan2_f64, args.begin(), args.end(), "tmp1", currentBlock); } else if (name == Jnjvm::exp) { - return new CallInst(mvm::jit::func_llvm_exp_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_exp_f64, args[0], "tmp1", currentBlock); } else if (name == Jnjvm::log) { - return new CallInst(mvm::jit::func_llvm_log_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_log_f64, args[0], "tmp1", currentBlock); } else if (name == Jnjvm::pow) { - return new CallInst(mvm::jit::func_llvm_pow_f64, args.begin(), args.end(), "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_pow_f64, args.begin(), args.end(), "tmp1", currentBlock); } else if (name == Jnjvm::ceil) { - return new CallInst(mvm::jit::func_llvm_ceil_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_ceil_f64, args[0], "tmp1", currentBlock); } else if (name == Jnjvm::floor) { - return new CallInst(mvm::jit::func_llvm_floor_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_floor_f64, args[0], "tmp1", currentBlock); } else if (name == Jnjvm::rint) { - return new CallInst(mvm::jit::func_llvm_rint_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_rint_f64, args[0], "tmp1", currentBlock); } else if (name == Jnjvm::cbrt) { - return new CallInst(mvm::jit::func_llvm_cbrt_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_cbrt_f64, args[0], "tmp1", currentBlock); } else if (name == Jnjvm::cosh) { - return new CallInst(mvm::jit::func_llvm_cosh_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_cosh_f64, args[0], "tmp1", currentBlock); } else if (name == Jnjvm::expm1) { - return new CallInst(mvm::jit::func_llvm_expm1_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_expm1_f64, args[0], "tmp1", currentBlock); } else if (name == Jnjvm::hypot) { - return new CallInst(mvm::jit::func_llvm_hypot_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_hypot_f64, args[0], "tmp1", currentBlock); } else if (name == Jnjvm::log10) { - return new CallInst(mvm::jit::func_llvm_log10_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_log10_f64, args[0], "tmp1", currentBlock); } else if (name == Jnjvm::log1p) { - return new CallInst(mvm::jit::func_llvm_log1p_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_log1p_f64, args[0], "tmp1", currentBlock); } else if (name == Jnjvm::sinh) { - return new CallInst(mvm::jit::func_llvm_sinh_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_sinh_f64, args[0], "tmp1", currentBlock); } else if (name == Jnjvm::tanh) { - return new CallInst(mvm::jit::func_llvm_tanh_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_tanh_f64, args[0], "tmp1", currentBlock); } return 0; @@ -1172,9 +1165,9 @@ BasicBlock* trueCl = createBasicBlock("Cl OK"); BasicBlock* falseCl = createBasicBlock("Cl Not OK"); - PHINode* node = new PHINode(PtrTy, "", trueCl); + PHINode* node = llvm::PHINode::Create(PtrTy, "", trueCl); node->addIncoming(arg1, currentBlock); - new BranchInst(falseCl, trueCl, test, currentBlock); + llvm::BranchInst::Create(falseCl, trueCl, test, currentBlock); currentBlock = falseCl; @@ -1191,7 +1184,7 @@ Value* res = invoke(newLookupLLVM, Args, "", currentBlock); node->addIncoming(res, currentBlock); - new BranchInst(trueCl, currentBlock); + llvm::BranchInst::Create(trueCl, currentBlock); currentBlock = trueCl; return node; @@ -1218,13 +1211,13 @@ } Value* JavaJIT::arraySize(Value* val) { - return new CallInst(arrayLengthLLVM, val, "", currentBlock); + return llvm::CallInst::Create(arrayLengthLLVM, val, "", currentBlock); /* Value* array = new BitCastInst(val, JavaArray::llvmType, "", currentBlock); std::vector args; //size= 2 args.push_back(mvm::jit::constantZero); args.push_back(JavaArray::sizeOffset()); - Value* ptr = new GetElementPtrInst(array, args.begin(), args.end(), + Value* ptr = llvm::GetElementPtrInst::Create(array, args.begin(), args.end(), "", currentBlock); return new LoadInst(ptr, "", currentBlock);*/ } @@ -1238,7 +1231,7 @@ std::vector args; // size = 2 args.push_back(zero); args.push_back(offset); - llvm::Value* ptr = new GetElementPtrInst(objectConvert, args.begin(), + llvm::Value* ptr = llvm::GetElementPtrInst::Create(objectConvert, args.begin(), args.end(), "", jit->currentBlock); return ptr; } @@ -1256,7 +1249,7 @@ #ifndef SINGLE_VM if (stat && field->classDef->isolate == Jnjvm::bootstrapVM) { - object = new CallInst(getStaticInstanceLLVM, object, "", currentBlock); + object = llvm::CallInst::Create(getStaticInstanceLLVM, object, "", currentBlock); } #endif return fieldGetter(this, type, object, field->offset); @@ -1282,8 +1275,8 @@ BasicBlock* ifTrue = createBasicBlock("true ldResolved"); BasicBlock* ifFalse = createBasicBlock("false ldResolved"); BasicBlock* endBlock = createBasicBlock("end ldResolved"); - PHINode * node = new PHINode(mvm::jit::ptrType, "", endBlock); - new BranchInst(ifTrue, ifFalse, cmp, currentBlock); + PHINode * node = llvm::PHINode::Create(mvm::jit::ptrType, "", endBlock); + llvm::BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock); // ---------- In case we already resolved something --------------------- // currentBlock = ifTrue; @@ -1293,7 +1286,7 @@ std::vector gepArgs; // size = 1 gepArgs.push_back(zero); gepArgs.push_back(val); - resPtr = new GetElementPtrInst(ptr, gepArgs.begin(), gepArgs.end(), + resPtr = llvm::GetElementPtrInst::Create(ptr, gepArgs.begin(), gepArgs.end(), "", currentBlock); } else { @@ -1301,7 +1294,7 @@ } node->addIncoming(resPtr, currentBlock); - new BranchInst(endBlock, currentBlock); + llvm::BranchInst::Create(endBlock, currentBlock); // ---------- In case we have to resolve -------------------------------- // currentBlock = ifFalse; @@ -1321,7 +1314,7 @@ args.push_back(gv); Value* tmp = invoke(JavaJIT::fieldLookupLLVM, args, "", currentBlock); node->addIncoming(tmp, currentBlock); - new BranchInst(endBlock, currentBlock); + llvm::BranchInst::Create(endBlock, currentBlock); currentBlock = endBlock;; return new BitCastInst(node, fieldTypePtr, "", currentBlock); @@ -1405,10 +1398,10 @@ if (currentExceptionBlock != endExceptionBlock) { BasicBlock* ifNormal = createBasicBlock("no exception block"); currentBlock = ifNormal; - return new InvokeInst(F, ifNormal, currentExceptionBlock, args.begin(), + return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock, args.begin(), args.end(), Name, InsertAtEnd); } else { - return new CallInst(F, args.begin(), args.end(), Name, InsertAtEnd); + return llvm::CallInst::Create(F, args.begin(), args.end(), Name, InsertAtEnd); } } @@ -1421,10 +1414,10 @@ currentBlock = ifNormal; std::vector arg; arg.push_back(arg1); - return new InvokeInst(F, ifNormal, currentExceptionBlock, arg.begin(), + return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock, arg.begin(), arg.end(), Name, InsertAtEnd); } else { - return new CallInst(F, arg1, Name, InsertAtEnd); + return llvm::CallInst::Create(F, arg1, Name, InsertAtEnd); } } @@ -1439,10 +1432,10 @@ if (currentExceptionBlock != endExceptionBlock) { BasicBlock* ifNormal = createBasicBlock("no exception block"); currentBlock = ifNormal; - return new InvokeInst(F, ifNormal, currentExceptionBlock, args.begin(), + return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock, args.begin(), args.end(), Name, InsertAtEnd); } else { - return new CallInst(F, args.begin(), args.end(), Name, InsertAtEnd); + return llvm::CallInst::Create(F, args.begin(), args.end(), Name, InsertAtEnd); } } @@ -1453,10 +1446,10 @@ BasicBlock* ifNormal = createBasicBlock("no exception block"); currentBlock = ifNormal; std::vector args; - return new InvokeInst(F, ifNormal, currentExceptionBlock, args.begin(), + return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock, args.begin(), args.end(), Name, InsertAtEnd); } else { - return new CallInst(F, Name, InsertAtEnd); + return llvm::CallInst::Create(F, Name, InsertAtEnd); } } Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp?rev=49333&r1=49332&r2=49333&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp Mon Apr 7 07:30:00 2008 @@ -176,7 +176,7 @@ std::vector args; args.push_back(JavaObject::llvmType); const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - javaObjectTracerLLVM = new Function(type, + javaObjectTracerLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm10JavaObject6tracerEj", module); @@ -193,7 +193,7 @@ const FunctionType* type = FunctionType::get(mvm::jit::ptrType, args, false); - virtualLookupLLVM = new Function(type, GlobalValue::ExternalLinkage, + virtualLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "virtualLookup", module); } @@ -205,7 +205,7 @@ const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, false); - doNewLLVM = new Function(type, GlobalValue::ExternalLinkage, + doNewLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm5Class5doNewEv", module); } @@ -217,7 +217,7 @@ const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, false); - doNewUnknownLLVM = new Function(type, GlobalValue::ExternalLinkage, + doNewUnknownLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm5Class12doNewUnknownEv", module); } @@ -230,7 +230,7 @@ const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, false); - initialiseObjectLLVM = new Function(type, GlobalValue::ExternalLinkage, + initialiseObjectLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm5Class16initialiseObjectEPNS_10JavaObjectE", module); PAListPtr func_toto_PAL; @@ -248,7 +248,7 @@ args.push_back(JavaObject::llvmType); const FunctionType* type = FunctionType::get(Type::Int32Ty, args, false); - arrayLengthLLVM = new Function(type, GlobalValue::ExternalLinkage, + arrayLengthLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "arrayLength", module); PAListPtr func_toto_PAL; @@ -269,7 +269,7 @@ const FunctionType* type = FunctionType::get(mvm::jit::ptrType, args, false); - newLookupLLVM = new Function(type, GlobalValue::ExternalLinkage, + newLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "newLookup", module); } @@ -282,7 +282,7 @@ const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, false); - doNewIsolateLLVM = new Function(type, GlobalValue::ExternalLinkage, + doNewIsolateLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm5Class12doNewIsolateEv", module); } @@ -301,7 +301,7 @@ FunctionType::get(mvm::jit::ptrType, args, false); - fieldLookupLLVM = new Function(type, GlobalValue::ExternalLinkage, + fieldLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "fieldLookup", module); } @@ -311,7 +311,7 @@ std::vector args; const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - nullPointerExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage, + nullPointerExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "nullPointerException", module); } @@ -323,7 +323,7 @@ args.push_back(mvm::jit::ptrType); const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - classCastExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage, + classCastExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "classCastException", module); } @@ -335,7 +335,7 @@ args.push_back(Type::Int32Ty); const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - indexOutOfBoundsExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage, + indexOutOfBoundsExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "indexOutOfBoundsException", module); } @@ -345,7 +345,7 @@ std::vector args; const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - jniProceedPendingExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage, + jniProceedPendingExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "jniProceedPendingException", module); } @@ -358,7 +358,7 @@ args.push_back(Type::Int32Ty); const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - printExecutionLLVM = new Function(type, GlobalValue::ExternalLinkage, + printExecutionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "printExecution", module); } @@ -369,7 +369,7 @@ args.push_back(Type::Int32Ty); const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - printMethodStartLLVM = new Function(type, GlobalValue::ExternalLinkage, + printMethodStartLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "printMethodStart", module); } @@ -380,7 +380,7 @@ args.push_back(Type::Int32Ty); const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - printMethodEndLLVM = new Function(type, GlobalValue::ExternalLinkage, + printMethodEndLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "printMethodEnd", module); } @@ -391,7 +391,7 @@ args.push_back(JavaObject::llvmType); const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - throwExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage, + throwExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm10JavaThread14throwExceptionEPNS_10JavaObjectE", module); } @@ -401,7 +401,7 @@ std::vector args; const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - clearExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage, + clearExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm10JavaThread14clearExceptionEv", module); } @@ -414,7 +414,7 @@ const FunctionType* type = FunctionType::get(mvm::jit::ptrType, args, false); - getExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage, + getExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm10JavaThread12getExceptionEv", module); } @@ -425,7 +425,7 @@ const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, false); - getJavaExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage, + getJavaExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm10JavaThread16getJavaExceptionEv", module); } @@ -436,7 +436,7 @@ args.push_back(mvm::jit::ptrType); const FunctionType* type = FunctionType::get(Type::Int1Ty, args, false); - compareExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage, + compareExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm10JavaThread16compareExceptionEPNS_5ClassE", module); } @@ -447,7 +447,7 @@ args.push_back(mvm::jit::ptrType); const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, false); - getStaticInstanceLLVM = new Function(type, GlobalValue::ExternalLinkage, + getStaticInstanceLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "getStaticInstance", module); } @@ -458,7 +458,7 @@ args.push_back(mvm::jit::ptrType); const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, false); - getClassDelegateeLLVM = new Function(type, GlobalValue::ExternalLinkage, + getClassDelegateeLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "getClassDelegatee", module); } @@ -470,7 +470,7 @@ args.push_back(mvm::jit::ptrType); const FunctionType* type = FunctionType::get(Type::Int32Ty, args, false); - instanceOfLLVM = new Function(type, GlobalValue::ExternalLinkage, + instanceOfLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm10JavaObject10instanceOfEPNS_11CommonClassE", module); } @@ -481,7 +481,7 @@ args.push_back(JavaObject::llvmType); const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - aquireObjectLLVM = new Function(type, GlobalValue::ExternalLinkage, + aquireObjectLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm10JavaObject6aquireEv", module); } @@ -492,7 +492,7 @@ args.push_back(JavaObject::llvmType); const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - releaseObjectLLVM = new Function(type, GlobalValue::ExternalLinkage, + releaseObjectLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm10JavaObject6unlockEv", module); } @@ -505,7 +505,7 @@ const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, true); - multiCallNewLLVM = new Function(type, GlobalValue::ExternalLinkage, + multiCallNewLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm9JavaArray12multiCallNewEPNS_10ClassArrayEjz", module); } @@ -520,35 +520,35 @@ const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, false); - FloatAconsLLVM = new Function(type, GlobalValue::ExternalLinkage, + FloatAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm10ArrayFloat5aconsEiPNS_10ClassArrayE", module); - Int8AconsLLVM = new Function(type, GlobalValue::ExternalLinkage, + Int8AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm10ArraySInt85aconsEiPNS_10ClassArrayE", module); - DoubleAconsLLVM = new Function(type, GlobalValue::ExternalLinkage, + DoubleAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm11ArrayDouble5aconsEiPNS_10ClassArrayE", module); - Int16AconsLLVM = new Function(type, GlobalValue::ExternalLinkage, + Int16AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm11ArraySInt165aconsEiPNS_10ClassArrayE", module); - Int32AconsLLVM = new Function(type, GlobalValue::ExternalLinkage, + Int32AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm11ArraySInt325aconsEiPNS_10ClassArrayE", module); - UTF8AconsLLVM = new Function(type, GlobalValue::ExternalLinkage, + UTF8AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm4UTF85aconsEiPNS_10ClassArrayE", module); - LongAconsLLVM = new Function(type, GlobalValue::ExternalLinkage, + LongAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm9ArrayLong5aconsEiPNS_10ClassArrayE", module); - ObjectAconsLLVM = new Function(type, GlobalValue::ExternalLinkage, + ObjectAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "_ZN5jnjvm11ArrayObject5aconsEiPNS_10ClassArrayE", module); } @@ -560,7 +560,7 @@ /*Result=*/JavaObject::llvmType, /*Params=*/args, /*isVarArg=*/false); - runtimeUTF8ToStrLLVM = new Function(FuncTy, GlobalValue::ExternalLinkage, + runtimeUTF8ToStrLLVM = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "runtimeUTF8ToStr", module); } @@ -571,7 +571,7 @@ const FunctionType* type = FunctionType::get(mvm::jit::ptrType, args, false); - getSJLJBufferLLVM = new Function(type, GlobalValue::ExternalLinkage, + getSJLJBufferLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "getSJLJBuffer", module); @@ -583,7 +583,7 @@ std::vector args; args.push_back(JavaObject::llvmType); markAndTraceLLVMType = FunctionType::get(llvm::Type::VoidTy, args, false); - markAndTraceLLVM = new Function(markAndTraceLLVMType, + markAndTraceLLVM = Function::Create(markAndTraceLLVMType, GlobalValue::ExternalLinkage, "_ZNK2gc12markAndTraceEv", module); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp?rev=49333&r1=49332&r2=49333&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Mon Apr 7 07:30:00 2008 @@ -169,7 +169,7 @@ args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)i)); args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod)); mvm::jit::unprotectConstants();//->unlock(); - new CallInst(printExecutionLLVM, args.begin(), args.end(), "", currentBlock); + CallInst::Create(printExecutionLLVM, args.begin(), args.end(), "", currentBlock); } #endif @@ -1102,11 +1102,11 @@ currentBlock); BasicBlock* res = createBasicBlock("F2I"); - PHINode* node = new PHINode(llvm::Type::Int32Ty, "", res); + PHINode* node = PHINode::Create(llvm::Type::Int32Ty, "", res); node->addIncoming(mvm::jit::constantZero, currentBlock); BasicBlock* cont = createBasicBlock("F2I"); - new BranchInst(res, cont, test, currentBlock); + BranchInst::Create(res, cont, test, currentBlock); currentBlock = cont; @@ -1116,7 +1116,7 @@ cont = createBasicBlock("F2I"); - new BranchInst(res, cont, test, currentBlock); + BranchInst::Create(res, cont, test, currentBlock); node->addIncoming(mvm::jit::constantMaxInt, currentBlock); @@ -1128,13 +1128,13 @@ cont = createBasicBlock("F2I"); - new BranchInst(res, cont, test, currentBlock); + BranchInst::Create(res, cont, test, currentBlock); node->addIncoming(mvm::jit::constantMinInt, currentBlock); currentBlock = cont; llvm::Value* newVal = new FPToSIInst(val, Type::Int32Ty, "", currentBlock); - new BranchInst(res, currentBlock); + BranchInst::Create(res, currentBlock); node->addIncoming(newVal, currentBlock); @@ -1150,11 +1150,11 @@ currentBlock); BasicBlock* res = createBasicBlock("F2L"); - PHINode* node = new PHINode(llvm::Type::Int64Ty, "", res); + PHINode* node = PHINode::Create(llvm::Type::Int64Ty, "", res); node->addIncoming(mvm::jit::constantLongZero, currentBlock); BasicBlock* cont = createBasicBlock("F2L"); - new BranchInst(res, cont, test, currentBlock); + BranchInst::Create(res, cont, test, currentBlock); currentBlock = cont; @@ -1164,7 +1164,7 @@ cont = createBasicBlock("F2L"); - new BranchInst(res, cont, test, currentBlock); + BranchInst::Create(res, cont, test, currentBlock); node->addIncoming(mvm::jit::constantMaxLong, currentBlock); currentBlock = cont; @@ -1174,13 +1174,13 @@ cont = createBasicBlock("F2L"); - new BranchInst(res, cont, test, currentBlock); + BranchInst::Create(res, cont, test, currentBlock); node->addIncoming(mvm::jit::constantMinLong, currentBlock); currentBlock = cont; llvm::Value* newVal = new FPToSIInst(val, Type::Int64Ty, "", currentBlock); - new BranchInst(res, currentBlock); + BranchInst::Create(res, currentBlock); node->addIncoming(newVal, currentBlock); @@ -1203,11 +1203,11 @@ currentBlock); BasicBlock* res = createBasicBlock("D2I"); - PHINode* node = new PHINode(llvm::Type::Int32Ty, "", res); + PHINode* node = PHINode::Create(llvm::Type::Int32Ty, "", res); node->addIncoming(mvm::jit::constantZero, currentBlock); BasicBlock* cont = createBasicBlock("D2I"); - new BranchInst(res, cont, test, currentBlock); + BranchInst::Create(res, cont, test, currentBlock); currentBlock = cont; @@ -1216,7 +1216,7 @@ cont = createBasicBlock("D2I"); - new BranchInst(res, cont, test, currentBlock); + BranchInst::Create(res, cont, test, currentBlock); node->addIncoming(mvm::jit::constantMaxInt, currentBlock); currentBlock = cont; @@ -1226,13 +1226,13 @@ cont = createBasicBlock("D2I"); - new BranchInst(res, cont, test, currentBlock); + BranchInst::Create(res, cont, test, currentBlock); node->addIncoming(mvm::jit::constantMinInt, currentBlock); currentBlock = cont; llvm::Value* newVal = new FPToSIInst(val, Type::Int32Ty, "", currentBlock); - new BranchInst(res, currentBlock); + BranchInst::Create(res, currentBlock); node->addIncoming(newVal, currentBlock); @@ -1250,11 +1250,11 @@ currentBlock); BasicBlock* res = createBasicBlock("D2L"); - PHINode* node = new PHINode(llvm::Type::Int64Ty, "", res); + PHINode* node = PHINode::Create(llvm::Type::Int64Ty, "", res); node->addIncoming(mvm::jit::constantLongZero, currentBlock); BasicBlock* cont = createBasicBlock("D2L"); - new BranchInst(res, cont, test, currentBlock); + BranchInst::Create(res, cont, test, currentBlock); currentBlock = cont; @@ -1263,7 +1263,7 @@ cont = createBasicBlock("D2L"); - new BranchInst(res, cont, test, currentBlock); + BranchInst::Create(res, cont, test, currentBlock); node->addIncoming(mvm::jit::constantMaxLong, currentBlock); currentBlock = cont; @@ -1274,13 +1274,13 @@ cont = createBasicBlock("D2L"); - new BranchInst(res, cont, test, currentBlock); + BranchInst::Create(res, cont, test, currentBlock); node->addIncoming(mvm::jit::constantMinLong, currentBlock); currentBlock = cont; llvm::Value* newVal = new FPToSIInst(val, Type::Int64Ty, "", currentBlock); - new BranchInst(res, currentBlock); + BranchInst::Create(res, currentBlock); node->addIncoming(newVal, currentBlock); @@ -1334,20 +1334,20 @@ BasicBlock* cont = createBasicBlock("LCMP"); BasicBlock* res = createBasicBlock("LCMP"); - PHINode* node = new PHINode(llvm::Type::Int32Ty, "", res); + PHINode* node = PHINode::Create(llvm::Type::Int32Ty, "", res); node->addIncoming(mvm::jit::constantZero, currentBlock); - new BranchInst(res, cont, test, currentBlock); + BranchInst::Create(res, cont, test, currentBlock); currentBlock = cont; test = new ICmpInst(ICmpInst::ICMP_SLT, val1, val2, "", currentBlock); node->addIncoming(mvm::jit::constantMinusOne, currentBlock); cont = createBasicBlock("LCMP"); - new BranchInst(res, cont, test, currentBlock); + BranchInst::Create(res, cont, test, currentBlock); currentBlock = cont; node->addIncoming(mvm::jit::constantOne, currentBlock); - new BranchInst(res, currentBlock); + BranchInst::Create(res, currentBlock); currentBlock = res; push(node, AssessorDesc::dInt); @@ -1593,7 +1593,7 @@ mvm::jit::unprotectConstants();//->unlock(); new StoreInst(expr, supplLocal, false, currentBlock); - new BranchInst(opcodeInfos[tmp + readS2(bytecodes, i)].newBlock, + BranchInst::Create(opcodeInfos[tmp + readS2(bytecodes, i)].newBlock, currentBlock); break; } @@ -1602,7 +1602,7 @@ uint8 local = readU1(bytecodes, i); Value* _val = new LoadInst(objectLocals[local], "", currentBlock); Value* val = new PtrToIntInst(_val, Type::Int32Ty, "", currentBlock); - SwitchInst* inst = new SwitchInst(val, jsrs[0], jsrs.size(), + SwitchInst* inst = SwitchInst::Create(val, jsrs[0], jsrs.size(), currentBlock); uint32 index = 0; @@ -1684,33 +1684,33 @@ convertValue(val, returnType, currentBlock, ass == AssessorDesc::dChar || ass == AssessorDesc::dBool); endNode->addIncoming(val, currentBlock); - new BranchInst(endBlock, currentBlock); + BranchInst::Create(endBlock, currentBlock); break; } case LRETURN : pop(); // remove the 0 on the stack endNode->addIncoming(pop(), currentBlock); - new BranchInst(endBlock, currentBlock); + BranchInst::Create(endBlock, currentBlock); break; case FRETURN : endNode->addIncoming(pop(), currentBlock); - new BranchInst(endBlock, currentBlock); + BranchInst::Create(endBlock, currentBlock); break; case DRETURN : pop(); // remove the 0 on the stack endNode->addIncoming(pop(), currentBlock); - new BranchInst(endBlock, currentBlock); + BranchInst::Create(endBlock, currentBlock); break; case ARETURN : endNode->addIncoming(pop(), currentBlock); - new BranchInst(endBlock, currentBlock); + BranchInst::Create(endBlock, currentBlock); break; case RETURN : - new BranchInst(endBlock, currentBlock); + BranchInst::Create(endBlock, currentBlock); break; case GETSTATIC : { @@ -1825,9 +1825,9 @@ std::vector args; args.push_back(arg); if (currentExceptionBlock != endExceptionBlock) { - new InvokeInst(throwExceptionLLVM, unifiedUnreachable, currentExceptionBlock, args.begin(), args.end(), "", currentBlock); + InvokeInst::Create(throwExceptionLLVM, unifiedUnreachable, currentExceptionBlock, args.begin(), args.end(), "", currentBlock); } else { - new CallInst(throwExceptionLLVM, args.begin(), args.end(), "", currentBlock); + CallInst::Create(throwExceptionLLVM, args.begin(), args.end(), "", currentBlock); new UnreachableInst(currentBlock); } break; @@ -1847,7 +1847,7 @@ BasicBlock* ifTrue = createBasicBlock("null checkcast"); BasicBlock* ifFalse = createBasicBlock("non null checkcast"); - new BranchInst(ifTrue, ifFalse, cmp, currentBlock); + BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock); currentBlock = ifFalse; Value* clVar = 0; if (dcl && dcl->isReady()) { @@ -1858,22 +1858,22 @@ std::vector args; args.push_back(obj); args.push_back(clVar); - Value* call = new CallInst(instanceOfLLVM, args.begin(), args.end(), + Value* call = CallInst::Create(instanceOfLLVM, args.begin(), args.end(), "", currentBlock); cmp = new ICmpInst(ICmpInst::ICMP_EQ, call, mvm::jit::constantZero, "", currentBlock); BasicBlock* ex = createBasicBlock("false checkcast"); - new BranchInst(ex, ifTrue, cmp, currentBlock); + BranchInst::Create(ex, ifTrue, cmp, currentBlock); std::vector exArgs; exArgs.push_back(obj); exArgs.push_back(clVar); if (currentExceptionBlock != endExceptionBlock) { - new InvokeInst(classCastExceptionLLVM, unifiedUnreachable, currentExceptionBlock, exArgs.begin(), exArgs.end(), "", ex); + InvokeInst::Create(classCastExceptionLLVM, unifiedUnreachable, currentExceptionBlock, exArgs.begin(), exArgs.end(), "", ex); } else { - new CallInst(classCastExceptionLLVM, exArgs.begin(), exArgs.end(), "", ex); + CallInst::Create(classCastExceptionLLVM, exArgs.begin(), exArgs.end(), "", ex); new UnreachableInst(ex); } @@ -1895,7 +1895,7 @@ std::vector args; args.push_back(pop()); args.push_back(clVar); - push(new CallInst(instanceOfLLVM, args.begin(), args.end(), "", currentBlock), AssessorDesc::dInt); + push(CallInst::Create(instanceOfLLVM, args.begin(), args.end(), "", currentBlock), AssessorDesc::dInt); break; } Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp?rev=49333&r1=49332&r2=49333&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp Mon Apr 7 07:30:00 2008 @@ -95,19 +95,19 @@ release(); return _staticVar; } else { - isolate->protectModule->lock(); - _staticVar = new GlobalVariable(JavaObject::llvmType, false, - GlobalValue::ExternalLinkage, - JavaJIT::constantJavaObjectNull, "", - isolate->module); - isolate->protectModule->unlock(); + isolate->protectModule->lock(); + _staticVar = new GlobalVariable(JavaObject::llvmType, false, + GlobalValue::ExternalLinkage, + JavaJIT::constantJavaObjectNull, "", + isolate->module); + isolate->protectModule->unlock(); - // TODO: put an initializer in here - void* ptr = mvm::jit::executionEngine->getPointerToGlobal(_staticVar); - GenericValue Val = GenericValue((void*)staticInstance()); - llvm::GenericValue * Ptr = (llvm::GenericValue*)ptr; - mvm::jit::executionEngine->StoreValueToMemory(Val, Ptr, staticType); - } + // TODO: put an initializer in here + void* ptr = mvm::jit::executionEngine->getPointerToGlobal(_staticVar); + GenericValue Val = GenericValue((void*)staticInstance()); + llvm::GenericValue * Ptr = (llvm::GenericValue*)ptr; + mvm::jit::executionEngine->StoreValueToMemory(Val, Ptr, staticType); + } } release(); } @@ -240,21 +240,21 @@ std::vector &fields = stat ? cl->staticFields : cl->virtualFields; cl->isolate->protectModule->lock(); - Function* func = new Function(markAndTraceLLVMType, - GlobalValue::ExternalLinkage, - "markAndTraceObject", - cl->isolate->module); + Function* func = Function::Create(markAndTraceLLVMType, + GlobalValue::ExternalLinkage, + "markAndTraceObject", + cl->isolate->module); cl->isolate->protectModule->unlock(); Constant* zero = mvm::jit::constantZero; Argument* arg = func->arg_begin(); - BasicBlock* block = new BasicBlock("", func); + BasicBlock* block = BasicBlock::Create("", func); llvm::Value* realArg = new BitCastInst(arg, type, "", block); if (stat || cl->super == 0) { - new CallInst(javaObjectTracerLLVM, arg, "", block); + CallInst::Create(javaObjectTracerLLVM, arg, "", block); } else { - new CallInst(((Class*)cl->super)->virtualTracer, arg, "", block); + CallInst::Create(((Class*)cl->super)->virtualTracer, arg, "", block); } for (std::vector::iterator i = fields.begin(), @@ -263,15 +263,15 @@ std::vector args; //size = 2 args.push_back(zero); args.push_back((*i)->offset); - Value* ptr = new GetElementPtrInst(realArg, args.begin(), args.end(), "", + Value* ptr = GetElementPtrInst::Create(realArg, args.begin(), args.end(), "", block); Value* val = new LoadInst(ptr, "", block); Value* valCast = new BitCastInst(val, JavaObject::llvmType, "", block); - new CallInst(markAndTraceLLVM, valCast, "", block); + CallInst::Create(markAndTraceLLVM, valCast, "", block); } } - new ReturnInst(block); + ReturnInst::Create(block); VirtualTable * res = malloc(VT_SIZE); memcpy(res, JavaObject::VT, VT_SIZE); @@ -780,13 +780,13 @@ std::vector Args; isolate->protectModule->lock(); - Function* res = new llvm::Function(virt ? virtualBufType : staticBufType, + Function* res = Function::Create(virt ? virtualBufType : staticBufType, GlobalValue::ExternalLinkage, this->printString(), isolate->module); isolate->protectModule->unlock(); - BasicBlock* currentBlock = new BasicBlock("enter", res); + BasicBlock* currentBlock = BasicBlock::Create("enter", res); Function::arg_iterator i = res->arg_begin(); Value *obj, *ptr, *func; func = i; @@ -802,7 +802,7 @@ e = args.end(); i!= e; ++i) { const AssessorDesc* funcs = (*i)->funcs; - ptr = new GetElementPtrInst(ptr, CI, "", currentBlock); + ptr = GetElementPtrInst::Create(ptr, CI, "", currentBlock); Value* val = new BitCastInst(ptr, funcs->llvmTypePtr, "", currentBlock); Value* arg = new LoadInst(val, "", currentBlock); Args.push_back(arg); @@ -812,11 +812,16 @@ CI = mvm::jit::constantOne; } } - Value* val = new CallInst(func, Args.begin(), Args.end(), "", currentBlock); + +#ifdef SERVICE_VM + Args.push_back(mvm::jit::constantPtrNull); +#endif + + Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", currentBlock); if (ret->funcs != AssessorDesc::dVoid) - new ReturnInst(val, currentBlock); + ReturnInst::Create(val, currentBlock); else - new ReturnInst(currentBlock); + ReturnInst::Create(currentBlock); return res; } @@ -826,13 +831,13 @@ std::vector Args; isolate->protectModule->lock(); - Function* res = new llvm::Function(virt ? virtualBufType : staticBufType, + Function* res = Function::Create(virt ? virtualBufType : staticBufType, GlobalValue::ExternalLinkage, this->printString(), isolate->module); isolate->protectModule->unlock(); - BasicBlock* currentBlock = new BasicBlock("enter", res); + BasicBlock* currentBlock = BasicBlock::Create("enter", res); Function::arg_iterator i = res->arg_begin(); Value *obj, *ap, *func; func = i; @@ -850,28 +855,19 @@ Args.push_back(new VAArgInst(ap, (*i)->funcs->llvmType, "", currentBlock)); } - Value* val = new CallInst(func, Args.begin(), Args.end(), "", currentBlock); +#ifdef SERVICE_VM + Args.push_back(mvm::jit::constantPtrNull); +#endif + + Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", currentBlock); if (ret->funcs != AssessorDesc::dVoid) - new ReturnInst(val, currentBlock); + ReturnInst::Create(val, currentBlock); else - new ReturnInst(currentBlock); + ReturnInst::Create(currentBlock); return res; } -void Signdef::createFuncPtrsCalls() { - assert(0 && "do not call me"); - Function* virtBuf = createFunctionCallBuf(true); - Function* statBuf = createFunctionCallBuf(false); - Function* virtAP = createFunctionCallAP(true); - Function* statAP = createFunctionCallAP(false); - - _staticCallBuf = (mvm::Code*)mvm::jit::executionEngine->getPointerToGlobal(statBuf); - _virtualCallBuf = (mvm::Code*)mvm::jit::executionEngine->getPointerToGlobal(virtBuf); - _staticCallAP = (mvm::Code*)mvm::jit::executionEngine->getPointerToGlobal(statAP); - _virtualCallAP = (mvm::Code*)mvm::jit::executionEngine->getPointerToGlobal(virtAP); -} - void* Signdef::staticCallBuf() { if (!_staticCallBuf) { Function* statBuf = createFunctionCallBuf(false); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp?rev=49333&r1=49332&r2=49333&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp Mon Apr 7 07:30:00 2008 @@ -473,7 +473,10 @@ for (uint32 i = 0; i < size; ++i) { llvmArgs.push_back(args->at(i)->funcs->llvmType); } - + +#ifdef SERVICE_VM + llvmArgs.push_back(mvm::jit::ptrType); // domain +#endif mvm::jit::protectTypes();//->lock(); llvm::FunctionType* res = llvm::FunctionType::get(ret->funcs->llvmType, @@ -493,6 +496,10 @@ for (uint32 i = 0; i < size; ++i) { llvmArgs.push_back(args->at(i)->funcs->llvmType); } + +#ifdef SERVICE_VM + llvmArgs.push_back(mvm::jit::ptrType); // domain +#endif mvm::jit::protectTypes();//->lock(); llvm::FunctionType* res = llvm::FunctionType::get(ret->funcs->llvmType, @@ -513,6 +520,10 @@ for (uint32 i = 0; i < size; ++i) { llvmArgs.push_back(args->at(i)->funcs->llvmType); } + +#ifdef SERVICE_VM + llvmArgs.push_back(mvm::jit::ptrType); // domain +#endif mvm::jit::protectTypes();//->lock(); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h?rev=49333&r1=49332&r2=49333&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h Mon Apr 7 07:30:00 2008 @@ -161,7 +161,6 @@ llvm::Function* createFunctionCallBuf(bool virt); llvm::Function* createFunctionCallAP(bool virt); - void createFuncPtrsCalls(); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp?rev=49333&r1=49332&r2=49333&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp Mon Apr 7 07:30:00 2008 @@ -12,6 +12,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/ExecutionEngine/GenericValue.h" +#include "mvm/JIT.h" #include "JavaAccess.h" #include "JavaClass.h" @@ -220,11 +221,14 @@ // Create getCallingClassLoader { std::vector args; +#ifdef SERVICE_VM + args.push_back(mvm::jit::ptrType); +#endif const llvm::FunctionType* type = llvm::FunctionType::get(JavaObject::llvmType, args, false); Classpath::getCallingClassLoader->methPtr = - new llvm::Function(type, llvm::GlobalValue::ExternalLinkage, + llvm::Function::Create(type, llvm::GlobalValue::ExternalLinkage, "_ZN5jnjvm7JavaJIT21getCallingClassLoaderEv", vm->module); } @@ -234,11 +238,14 @@ { std::vector args; args.push_back(JavaObject::llvmType); +#ifdef SERVICE_VM + args.push_back(mvm::jit::ptrType); +#endif const llvm::FunctionType* type = llvm::FunctionType::get(JavaObject::llvmType, args, false); internString->methPtr = - new llvm::Function(type, llvm::GlobalValue::ExternalLinkage, + llvm::Function::Create(type, llvm::GlobalValue::ExternalLinkage, "internString", vm->module); } @@ -248,11 +255,13 @@ { std::vector args; args.push_back(JavaObject::llvmType); +#ifdef SERVICE_VM + args.push_back(mvm::jit::ptrType); +#endif const llvm::FunctionType* type = llvm::FunctionType::get(llvm::Type::Int8Ty, args, false); - isArray->methPtr = - new llvm::Function(type, llvm::GlobalValue::ExternalLinkage, + llvm::Function::Create(type, llvm::GlobalValue::ExternalLinkage, "isArray", vm->module); } @@ -272,11 +281,14 @@ JavaMethod* getCallingClass = UPCALL_METHOD(vm, "gnu/classpath/VMStackWalker", "getCallingClass", "()Ljava/lang/Object;", ACC_STATIC); { std::vector args; +#ifdef SERVICE_VM + args.push_back(mvm::jit::ptrType); +#endif const llvm::FunctionType* type = llvm::FunctionType::get(JavaObject::llvmType, args, false); getCallingClass->methPtr = - new llvm::Function(type, llvm::GlobalValue::ExternalLinkage, + llvm::Function::Create(type, llvm::GlobalValue::ExternalLinkage, "getCallingClass", vm->module); } @@ -284,11 +296,14 @@ JavaMethod* getCallingClassLoader = UPCALL_METHOD(vm, "gnu/classpath/VMStackWalker", "getCallingClassLoader", "()Ljava/lang/Object;", ACC_STATIC); { std::vector args; +#ifdef SERVICE_VM + args.push_back(mvm::jit::ptrType); +#endif const llvm::FunctionType* type = llvm::FunctionType::get(JavaObject::llvmType, args, false); getCallingClassLoader->methPtr = - new llvm::Function(type, llvm::GlobalValue::ExternalLinkage, + llvm::Function::Create(type, llvm::GlobalValue::ExternalLinkage, "getCallingClassLoader", vm->module); } Modified: vmkit/trunk/lib/JnJVM/VMCore/LowerArrayLength.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/LowerArrayLength.cpp?rev=49333&r1=49332&r2=49333&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/LowerArrayLength.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/LowerArrayLength.cpp Mon Apr 7 07:30:00 2008 @@ -49,7 +49,7 @@ std::vector args; //size= 2 args.push_back(mvm::jit::constantZero); args.push_back(jnjvm::JavaArray::sizeOffset()); - Value* ptr = new GetElementPtrInst(array, args.begin(), args.end(), + Value* ptr = GetElementPtrInst::Create(array, args.begin(), args.end(), "", CI); Value* load = new LoadInst(ptr, "", CI); CI->replaceAllUsesWith(load); From nicolas.geoffray at lip6.fr Mon Apr 7 07:33:34 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 07 Apr 2008 12:33:34 -0000 Subject: [llvm-commits] [vmkit] r49334 - in /vmkit/trunk/lib/Mvm: EscapeAnalysis.cpp JIT.cpp Message-ID: <200804071233.m37CXYX9023682@zion.cs.uiuc.edu> Author: geoffray Date: Mon Apr 7 07:33:33 2008 New Revision: 49334 URL: http://llvm.org/viewvc/llvm-project?rev=49334&view=rev Log: Port to the new LLVM Value interface Modified: vmkit/trunk/lib/Mvm/EscapeAnalysis.cpp vmkit/trunk/lib/Mvm/JIT.cpp Modified: vmkit/trunk/lib/Mvm/EscapeAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/EscapeAnalysis.cpp?rev=49334&r1=49333&r2=49334&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/EscapeAnalysis.cpp (original) +++ vmkit/trunk/lib/Mvm/EscapeAnalysis.cpp Mon Apr 7 07:33:33 2008 @@ -123,9 +123,9 @@ Args.push_back(BI); Instruction* CI; if (isa(Alloc)) { - CI = new CallInst(Initialize, Args.begin(), Args.end(), "", Alloc); + CI = CallInst::Create(Initialize, Args.begin(), Args.end(), "", Alloc); } else { - CI = new InvokeInst(Initialize, ((InvokeInst*)Alloc)->getNormalDest(), + CI = InvokeInst::Create(Initialize, ((InvokeInst*)Alloc)->getNormalDest(), ((InvokeInst*)Alloc)->getUnwindDest(), Args.begin(), Args.end(), "", Alloc->getParent()); } Modified: vmkit/trunk/lib/Mvm/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/JIT.cpp?rev=49334&r1=49333&r2=49334&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/JIT.cpp (original) +++ vmkit/trunk/lib/Mvm/JIT.cpp Mon Apr 7 07:33:33 2008 @@ -337,7 +337,7 @@ arg_types.insert (arg_types.begin (), llvm::PointerType::getUnqual(ptrType)); llvm::FunctionType *mtype = llvm::FunctionType::get (llvm::Type::VoidTy, arg_types, false); - new llvm::Function(mtype, llvm::GlobalValue::ExternalLinkage, "llvm.va_start", module); + llvm::Function::Create(mtype, llvm::GlobalValue::ExternalLinkage, "llvm.va_start", module); } { @@ -345,7 +345,7 @@ arg_types.insert (arg_types.begin (), llvm::Type::Int32Ty); llvm::FunctionType *mtype = llvm::FunctionType::get (ptrType, arg_types, false); - new llvm::Function(mtype, llvm::GlobalValue::ExternalLinkage, "llvm.frameaddress", module); + llvm::Function::Create(mtype, llvm::GlobalValue::ExternalLinkage, "llvm.frameaddress", module); } { @@ -353,7 +353,7 @@ // Prototype malloc as "char* malloc(...)", because we don't know in // doInitialization whether size_t is int or long. FunctionType *FT = FunctionType::get(BPTy, std::vector(), true); - new llvm::Function(FT, llvm::GlobalValue::ExternalLinkage, "_ZN2gcnwEjP5gc_vt", module); + llvm::Function::Create(FT, llvm::GlobalValue::ExternalLinkage, "_ZN2gcnwEjP5gc_vt", module); } @@ -363,7 +363,7 @@ args.push_back(Type::FloatTy); const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - printFloatLLVM = new Function(type, GlobalValue::ExternalLinkage, + printFloatLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "printFloat", module); } @@ -374,7 +374,7 @@ args.push_back(Type::DoubleTy); const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - printDoubleLLVM = new Function(type, GlobalValue::ExternalLinkage, + printDoubleLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "printDouble", module); } @@ -385,7 +385,7 @@ args.push_back(Type::Int64Ty); const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - printLongLLVM = new Function(type, GlobalValue::ExternalLinkage, + printLongLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "printLong", module); } @@ -396,7 +396,7 @@ args.push_back(Type::Int32Ty); const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - printIntLLVM = new Function(type, GlobalValue::ExternalLinkage, + printIntLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "printInt", module); } @@ -407,7 +407,7 @@ args.push_back(ptrType); const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - printObjectLLVM = new Function(type, GlobalValue::ExternalLinkage, + printObjectLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "printObject", module); } @@ -439,7 +439,7 @@ /*Params=*/FuncTy_11_args, /*isVarArg=*/false); - llvmGetException = new Function( + llvmGetException = Function::Create( /*Type=*/FuncTy_11, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"llvm.eh.exception", module); // (external, no body) @@ -453,12 +453,12 @@ /*isVarArg=*/true); if (sizeof(void*) == 4) { - exceptionSelector = new Function( + exceptionSelector = Function::Create( /*Type=*/FuncTy_13, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"llvm.eh.selector.i32", module); // (external, no body) } else { - exceptionSelector = new Function( + exceptionSelector = Function::Create( /*Type=*/FuncTy_13, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"llvm.eh.selector.i64", module); // (external, no body) @@ -470,12 +470,12 @@ /*Params=*/FuncTy_19_args, /*isVarArg=*/false); - personality = new Function( + personality = Function::Create( /*Type=*/FuncTy_19, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"__gxx_personality_v0", module); // (external, no body) - unwindResume = new Function( + unwindResume = Function::Create( /*Type=*/FuncTy_9, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"_Unwind_Resume_or_Rethrow", module); // (external, no body) @@ -488,12 +488,12 @@ /*Params=*/FuncTy_17_args, /*isVarArg=*/false); - exceptionBeginCatch = new Function( + exceptionBeginCatch = Function::Create( /*Type=*/FuncTy_17, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"__cxa_begin_catch", module); // (external, no body) - exceptionEndCatch = new Function( + exceptionEndCatch = Function::Create( /*Type=*/FuncTy_19, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"__cxa_end_catch", module); // (external, no body) @@ -508,25 +508,25 @@ /*Params=*/args1, /*isVarArg=*/false); - func_llvm_sqrt_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "llvm.sqrt.f64", module); - func_llvm_sin_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "llvm.sin.f64", module); - func_llvm_cos_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "llvm.cos.f64", module); - func_llvm_tan_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "tan", module); - func_llvm_asin_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "asin", module); - func_llvm_acos_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "acos", module); - func_llvm_atan_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "atan", module); - func_llvm_exp_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "exp", module); - func_llvm_log_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "log", module); - func_llvm_ceil_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "ceil", module); - func_llvm_floor_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "floor", module); - func_llvm_cbrt_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "cbrt", module); - func_llvm_cosh_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "cosh", module); - func_llvm_expm1_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "expm1", module); - func_llvm_log10_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "log10", module); - func_llvm_log1p_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "log1p", module); - func_llvm_sinh_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "sinh", module); - func_llvm_tanh_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "tanh", module); - func_llvm_fabs_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "fabs", module); + func_llvm_sqrt_f64 = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "llvm.sqrt.f64", module); + func_llvm_sin_f64 = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "llvm.sin.f64", module); + func_llvm_cos_f64 = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "llvm.cos.f64", module); + func_llvm_tan_f64 = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "tan", module); + func_llvm_asin_f64 = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "asin", module); + func_llvm_acos_f64 = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "acos", module); + func_llvm_atan_f64 = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "atan", module); + func_llvm_exp_f64 = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "exp", module); + func_llvm_log_f64 = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "log", module); + func_llvm_ceil_f64 = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "ceil", module); + func_llvm_floor_f64 = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "floor", module); + func_llvm_cbrt_f64 = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "cbrt", module); + func_llvm_cosh_f64 = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "cosh", module); + func_llvm_expm1_f64 = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "expm1", module); + func_llvm_log10_f64 = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "log10", module); + func_llvm_log1p_f64 = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "log1p", module); + func_llvm_sinh_f64 = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "sinh", module); + func_llvm_tanh_f64 = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "tanh", module); + func_llvm_fabs_f64 = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "fabs", module); std::vectorargs2; args2.push_back(Type::DoubleTy); @@ -536,10 +536,10 @@ /*Params=*/args2, /*isVarArg=*/false); - func_llvm_hypot_f64 = new Function(FuncTy2, GlobalValue::ExternalLinkage, "hypot", module); - //func_llvm_pow_f64 = new Function(FuncTy2, GlobalValue::ExternalLinkage, "llvm.pow.f64", module); - func_llvm_pow_f64 = new Function(FuncTy2, GlobalValue::ExternalLinkage, "pow", module); - func_llvm_atan2_f64 = new Function(FuncTy2, GlobalValue::ExternalLinkage, "atan2", module); + func_llvm_hypot_f64 = Function::Create(FuncTy2, GlobalValue::ExternalLinkage, "hypot", module); + //func_llvm_pow_f64 = Function::Create(FuncTy2, GlobalValue::ExternalLinkage, "llvm.pow.f64", module); + func_llvm_pow_f64 = Function::Create(FuncTy2, GlobalValue::ExternalLinkage, "pow", module); + func_llvm_atan2_f64 = Function::Create(FuncTy2, GlobalValue::ExternalLinkage, "atan2", module); std::vectorargs3; args3.push_back(Type::DoubleTy); @@ -548,7 +548,7 @@ /*Params=*/args3, /*isVarArg=*/false); - func_llvm_rint_f64 = new Function(FuncTy3, GlobalValue::ExternalLinkage, "rint", module); + func_llvm_rint_f64 = Function::Create(FuncTy3, GlobalValue::ExternalLinkage, "rint", module); std::vectorargs4; args4.push_back(Type::FloatTy); @@ -557,7 +557,7 @@ /*Params=*/args4, /*isVarArg=*/false); - func_llvm_fabs_f32 = new Function(FuncTyF, GlobalValue::ExternalLinkage, "fabsf", module); + func_llvm_fabs_f32 = Function::Create(FuncTyF, GlobalValue::ExternalLinkage, "fabsf", module); } @@ -568,7 +568,7 @@ const FunctionType* type = FunctionType::get(Type::Int32Ty, args, false); - setjmpLLVM = new Function(type, GlobalValue::ExternalLinkage, + setjmpLLVM = Function::Create(type, GlobalValue::ExternalLinkage, "setjmp", module); @@ -586,7 +586,7 @@ /*Result=*/Type::VoidTy, /*Params=*/FuncTy_4_args, /*isVarArg=*/false); - llvm_memcpy_i32 = new Function( + llvm_memcpy_i32 = Function::Create( /*Type=*/FuncTy_4, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"llvm.memcpy.i32", module); // (external, no body) @@ -604,7 +604,7 @@ /*Result=*/Type::VoidTy, /*Params=*/FuncTy_4_args, /*isVarArg=*/false); - llvm_memset_i32 = new Function( + llvm_memset_i32 = Function::Create( /*Type=*/FuncTy_4, /*Linkage=*/GlobalValue::ExternalLinkage, /*Name=*/"llvm.memset.i32", module); // (external, no body) From baldrick at free.fr Mon Apr 7 08:39:14 2008 From: baldrick at free.fr (Duncan Sands) Date: Mon, 07 Apr 2008 13:39:14 -0000 Subject: [llvm-commits] [llvm] r49335 - in /llvm/trunk/lib/VMCore: Function.cpp Verifier.cpp Message-ID: <200804071339.m37DdEAt025537@zion.cs.uiuc.edu> Author: baldrick Date: Mon Apr 7 08:39:11 2008 New Revision: 49335 URL: http://llvm.org/viewvc/llvm-project?rev=49335&view=rev Log: Make sure that intrinsics automagically get the right parameter attributes no matter how they are obtained. Modified: llvm/trunk/lib/VMCore/Function.cpp llvm/trunk/lib/VMCore/Verifier.cpp Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=49335&r1=49334&r2=49335&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Mon Apr 7 08:39:11 2008 @@ -160,6 +160,10 @@ if (ParentModule) ParentModule->getFunctionList().push_back(this); + + // Ensure intrinsics have the right parameter attributes. + if (unsigned IID = getIntrinsicID(true)) + setParamAttrs(Intrinsic::getParamAttrs(Intrinsic::ID(IID))); } Function::~Function() { @@ -328,11 +332,9 @@ unsigned numTys) { // There can never be multiple globals with the same name of different types, // because intrinsics must be a specific type. - Function *F = + return cast(M->getOrInsertFunction(getName(id, Tys, numTys), getType(id, Tys, numTys))); - F->setParamAttrs(getParamAttrs(id)); - return F; } Value *IntrinsicInst::StripPointerCasts(Value *Ptr) { Modified: llvm/trunk/lib/VMCore/Verifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=49335&r1=49334&r2=49335&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Verifier.cpp (original) +++ llvm/trunk/lib/VMCore/Verifier.cpp Mon Apr 7 08:39:11 2008 @@ -1452,6 +1452,10 @@ F->getName().substr(Name.length()) + "'. It should be '" + Suffix + "'", F); } + + // Check parameter attributes. + Assert1(F->getParamAttrs() == Intrinsic::getParamAttrs(ID), + "Intrinsic has wrong parameter attributes!", F); } From baldrick at free.fr Mon Apr 7 08:41:19 2008 From: baldrick at free.fr (Duncan Sands) Date: Mon, 07 Apr 2008 13:41:19 -0000 Subject: [llvm-commits] [llvm] r49336 - /llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp Message-ID: <200804071341.m37DfJs6025604@zion.cs.uiuc.edu> Author: baldrick Date: Mon Apr 7 08:41:19 2008 New Revision: 49336 URL: http://llvm.org/viewvc/llvm-project?rev=49336&view=rev Log: Use Intrinsic::getDeclaration to get hold of intrinsics. Fix up the argument type (should be i8*, was an array*). Modified: llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp Modified: llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp?rev=49336&r1=49335&r2=49336&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp Mon Apr 7 08:41:19 2008 @@ -39,6 +39,7 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Instructions.h" +#include "llvm/Intrinsics.h" #include "llvm/Module.h" #include "llvm/Pass.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" @@ -142,12 +143,8 @@ Constant::getNullValue(PtrJBList), "llvm.sjljeh.jblist", &M); } - SetJmpFn = M.getOrInsertFunction("llvm.setjmp", Type::Int32Ty, - PointerType::getUnqual(JmpBufTy), - (Type *)0); - LongJmpFn = M.getOrInsertFunction("llvm.longjmp", Type::VoidTy, - PointerType::getUnqual(JmpBufTy), - Type::Int32Ty, (Type *)0); + SetJmpFn = Intrinsic::getDeclaration(&M, Intrinsic::setjmp); + LongJmpFn = Intrinsic::getDeclaration(&M, Intrinsic::longjmp); } // We need the 'write' and 'abort' functions for both models. @@ -505,9 +502,11 @@ Value *JmpBufPtr = GetElementPtrInst::Create(JmpBuf, Idx.begin(), Idx.end(), "TheJmpBuf", EntryBB->getTerminator()); + JmpBufPtr = new BitCastInst(JmpBufPtr, PointerType::getUnqual(Type::Int8Ty), + "tmp", EntryBB->getTerminator()); Value *SJRet = CallInst::Create(SetJmpFn, JmpBufPtr, "sjret", EntryBB->getTerminator()); - + // Compare the return value to zero. Value *IsNormal = new ICmpInst(ICmpInst::ICMP_EQ, SJRet, Constant::getNullValue(SJRet->getType()), @@ -555,6 +554,8 @@ Idx.push_back(ConstantInt::get(Type::Int32Ty, 0)); Idx[0] = GetElementPtrInst::Create(BufPtr, Idx.begin(), Idx.end(), "JmpBuf", UnwindBlock); + Idx[0] = new BitCastInst(Idx[0], PointerType::getUnqual(Type::Int8Ty), + "tmp", UnwindBlock); Idx[1] = ConstantInt::get(Type::Int32Ty, 1); CallInst::Create(LongJmpFn, Idx.begin(), Idx.end(), "", UnwindBlock); new UnreachableInst(UnwindBlock); From baldrick at free.fr Mon Apr 7 08:43:58 2008 From: baldrick at free.fr (Duncan Sands) Date: Mon, 07 Apr 2008 13:43:58 -0000 Subject: [llvm-commits] [llvm] r49337 - /llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Message-ID: <200804071343.m37DhwPf025706@zion.cs.uiuc.edu> Author: baldrick Date: Mon Apr 7 08:43:58 2008 New Revision: 49337 URL: http://llvm.org/viewvc/llvm-project?rev=49337&view=rev Log: The "stacksave is not nounwind problem" no longer needs to be fixed here - a previous commit made sure that intrinsics always get the right attributes. So remove no-longer needed code, and while there use Intrinsic::getDeclaration rather than getOrInsertFunction. Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=49337&r1=49336&r2=49337&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Mon Apr 7 08:43:58 2008 @@ -347,12 +347,10 @@ // code with llvm.stacksave/llvm.stackrestore intrinsics. if (InlinedFunctionInfo.ContainsDynamicAllocas) { Module *M = Caller->getParent(); - const Type *BytePtr = PointerType::getUnqual(Type::Int8Ty); // Get the two intrinsics we care about. Constant *StackSave, *StackRestore; - StackSave = M->getOrInsertFunction("llvm.stacksave", BytePtr, NULL); - StackRestore = M->getOrInsertFunction("llvm.stackrestore", Type::VoidTy, - BytePtr, NULL); + StackSave = Intrinsic::getDeclaration(M, Intrinsic::stacksave); + StackRestore = Intrinsic::getDeclaration(M, Intrinsic::stackrestore); // If we are preserving the callgraph, add edges to the stacksave/restore // functions for the calls we insert. @@ -368,14 +366,12 @@ // Insert the llvm.stacksave. CallInst *SavedPtr = CallInst::Create(StackSave, "savedstack", FirstNewBlock->begin()); - SavedPtr->setDoesNotThrow(); if (CG) CallerNode->addCalledFunction(SavedPtr, StackSaveCGN); // Insert a call to llvm.stackrestore before any return instructions in the // inlined function. for (unsigned i = 0, e = Returns.size(); i != e; ++i) { CallInst *CI = CallInst::Create(StackRestore, SavedPtr, "", Returns[i]); - CI->setDoesNotThrow(); if (CG) CallerNode->addCalledFunction(CI, StackRestoreCGN); } @@ -388,8 +384,7 @@ for (Function::iterator BB = FirstNewBlock, E = Caller->end(); BB != E; ++BB) if (UnwindInst *UI = dyn_cast(BB->getTerminator())) { - CallInst *CI = CallInst::Create(StackRestore, SavedPtr, "", UI); - CI->setDoesNotThrow(); + CallInst::Create(StackRestore, SavedPtr, "", UI); ++NumStackRestores; } } From baldrick at free.fr Mon Apr 7 08:45:04 2008 From: baldrick at free.fr (Duncan Sands) Date: Mon, 07 Apr 2008 13:45:04 -0000 Subject: [llvm-commits] [llvm] r49338 - in /llvm/trunk: examples/BrainF/BrainF.cpp lib/Transforms/IPO/SimplifyLibCalls.cpp lib/Transforms/Instrumentation/RSProfiling.cpp tools/llvm-upgrade/UpgradeParser.y Message-ID: <200804071345.m37Dj4oc025746@zion.cs.uiuc.edu> Author: baldrick Date: Mon Apr 7 08:45:04 2008 New Revision: 49338 URL: http://llvm.org/viewvc/llvm-project?rev=49338&view=rev Log: Use Intrinsic::getDeclaration in more places. Modified: llvm/trunk/examples/BrainF/BrainF.cpp llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp llvm/trunk/tools/llvm-upgrade/UpgradeParser.y Modified: llvm/trunk/examples/BrainF/BrainF.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainF.cpp?rev=49338&r1=49337&r2=49338&view=diff ============================================================================== --- llvm/trunk/examples/BrainF/BrainF.cpp (original) +++ llvm/trunk/examples/BrainF/BrainF.cpp Mon Apr 7 08:45:04 2008 @@ -25,6 +25,7 @@ #include "BrainF.h" #include "llvm/Constants.h" +#include "llvm/Intrinsics.h" #include "llvm/ADT/STLExtras.h" using namespace llvm; @@ -52,11 +53,7 @@ //Function prototypes //declare void @llvm.memset.i32(i8 *, i8, i32, i32) - Function *memset_func = cast(module-> - getOrInsertFunction("llvm.memset.i32", Type::VoidTy, - PointerType::getUnqual(IntegerType::Int8Ty), - IntegerType::Int8Ty, IntegerType::Int32Ty, - IntegerType::Int32Ty, NULL)); + Function *memset_func = Intrinsic::getDeclaration(module, Intrinsic::memset_i32); //declare i32 @getchar() getchar_func = cast(module-> Modified: llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp?rev=49338&r1=49337&r2=49338&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp Mon Apr 7 08:45:04 2008 @@ -21,6 +21,7 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Instructions.h" +#include "llvm/Intrinsics.h" #include "llvm/Module.h" #include "llvm/Pass.h" #include "llvm/ADT/StringMap.h" @@ -320,12 +321,9 @@ /// @brief Return a Function* for the memcpy libcall Constant *get_memcpy() { if (!memcpy_func) { - const Type *SBP = PointerType::getUnqual(Type::Int8Ty); - const char *N = TD->getIntPtrType() == Type::Int32Ty ? - "llvm.memcpy.i32" : "llvm.memcpy.i64"; - memcpy_func = M->getOrInsertFunction(N, Type::VoidTy, SBP, SBP, - TD->getIntPtrType(), Type::Int32Ty, - NULL); + Intrinsic::ID IID = (TD->getIntPtrType() == Type::Int32Ty) ? + Intrinsic::memcpy_i32 : Intrinsic::memcpy_i64; + memcpy_func = Intrinsic::getDeclaration(M, IID); } return memcpy_func; } @@ -1696,23 +1694,11 @@ // ffsl(x) -> x == 0 ? 0 : llvm.cttz(x)+1 // ffsll(x) -> x == 0 ? 0 : llvm.cttz(x)+1 const Type *ArgType = TheCall->getOperand(1)->getType(); - const char *CTTZName; assert(ArgType->getTypeID() == Type::IntegerTyID && "llvm.cttz argument is not an integer?"); - unsigned BitWidth = cast(ArgType)->getBitWidth(); - if (BitWidth == 8) - CTTZName = "llvm.cttz.i8"; - else if (BitWidth == 16) - CTTZName = "llvm.cttz.i16"; - else if (BitWidth == 32) - CTTZName = "llvm.cttz.i32"; - else { - assert(BitWidth == 64 && "Unknown bitwidth"); - CTTZName = "llvm.cttz.i64"; - } - - Constant *F = SLC.getModule()->getOrInsertFunction(CTTZName, ArgType, - ArgType, NULL); + Constant *F = Intrinsic::getDeclaration(SLC.getModule(), + Intrinsic::cttz, &ArgType, 1); + Value *V = CastInst::createIntegerCast(TheCall->getOperand(1), ArgType, false/*ZExt*/, "tmp", TheCall); Value *V2 = CallInst::Create(F, V, "tmp", TheCall); Modified: llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp?rev=49338&r1=49337&r2=49338&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp Mon Apr 7 08:45:04 2008 @@ -37,6 +37,7 @@ #include "llvm/Instructions.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" +#include "llvm/Intrinsics.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Support/CommandLine.h" @@ -301,7 +302,7 @@ CycleCounter::CycleCounter(Module& m, uint64_t resetmask) : rm(resetmask) { - F = m.getOrInsertFunction("llvm.readcyclecounter", Type::Int64Ty, NULL); + F = Intrinsic::getDeclaration(&m, Intrinsic::readcyclecounter); } CycleCounter::~CycleCounter() {} Modified: llvm/trunk/tools/llvm-upgrade/UpgradeParser.y URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-upgrade/UpgradeParser.y?rev=49338&r1=49337&r2=49338&view=diff ============================================================================== --- llvm/trunk/tools/llvm-upgrade/UpgradeParser.y (original) +++ llvm/trunk/tools/llvm-upgrade/UpgradeParser.y Mon Apr 7 08:45:04 2008 @@ -1593,8 +1593,7 @@ const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); const Type* ArgTy = F->getFunctionType()->getReturnType(); const Type* ArgTyPtr = PointerType::getUnqual(ArgTy); - Function* NF = cast(Result->getOrInsertFunction( - "llvm.va_start", RetTy, ArgTyPtr, (Type *)0)); + Function* NF = Intrinsic::getDeclaration(Result, Intrinsic::va_start); while (!F->use_empty()) { CallInst* CI = cast(F->use_back()); @@ -1620,8 +1619,7 @@ const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); const Type* ArgTy = F->getFunctionType()->getParamType(0); const Type* ArgTyPtr = PointerType::getUnqual(ArgTy); - Function* NF = cast(Result->getOrInsertFunction( - "llvm.va_end", RetTy, ArgTyPtr, (Type *)0)); + Function* NF = Intrinsic::getDeclaration(Result, Intrinsic::va_end); while (!F->use_empty()) { CallInst* CI = cast(F->use_back()); @@ -1649,8 +1647,7 @@ const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); const Type* ArgTy = F->getFunctionType()->getReturnType(); const Type* ArgTyPtr = PointerType::getUnqual(ArgTy); - Function* NF = cast(Result->getOrInsertFunction( - "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0)); + Function* NF = Intrinsic::getDeclaration(Result, Intrinsic::va_copy); while (!F->use_empty()) { CallInst* CI = cast(F->use_back()); @@ -3551,8 +3548,8 @@ const Type* ArgTy = $2.V->getType(); const Type* DstTy = $4.PAT->get(); ObsoleteVarArgs = true; - Function* NF = cast(CurModule.CurrentModule-> - getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0)); + Function* NF = Intrinsic::getDeclaration(CurModule.CurrentModule, + Intrinsic::va_copy); //b = vaarg a, t -> //foo = alloca 1 of t @@ -3572,8 +3569,8 @@ const Type* ArgTy = $2.V->getType(); const Type* DstTy = $4.PAT->get(); ObsoleteVarArgs = true; - Function* NF = cast(CurModule.CurrentModule-> - getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0)); + Function* NF = Intrinsic::getDeclaration(CurModule.CurrentModule, + Intrinsic::va_copy); //b = vanext a, t -> //foo = alloca 1 of t From dberlin at dberlin.org Mon Apr 7 09:20:51 2008 From: dberlin at dberlin.org (Daniel Berlin) Date: Mon, 07 Apr 2008 14:20:51 -0000 Subject: [llvm-commits] [llvm] r49339 - /llvm/trunk/lib/Analysis/IPA/Andersens.cpp Message-ID: <200804071420.m37EKqf3026903@zion.cs.uiuc.edu> Author: dannyb Date: Mon Apr 7 09:20:50 2008 New Revision: 49339 URL: http://llvm.org/viewvc/llvm-project?rev=49339&view=rev Log: Fix PR 2169. Modified: llvm/trunk/lib/Analysis/IPA/Andersens.cpp Modified: llvm/trunk/lib/Analysis/IPA/Andersens.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/Andersens.cpp?rev=49339&r1=49338&r2=49339&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IPA/Andersens.cpp (original) +++ llvm/trunk/lib/Analysis/IPA/Andersens.cpp Mon Apr 7 09:20:50 2008 @@ -957,6 +957,9 @@ FirstArg, TempArg)); Constraints.push_back(Constraint(Constraint::Load, TempArg, SecondArg)); + // In addition, Dest = Src + Constraints.push_back(Constraint(Constraint::Copy, + FirstArg, SecondArg)); return true; } From criswell at uiuc.edu Mon Apr 7 10:09:42 2008 From: criswell at uiuc.edu (John Criswell) Date: Mon, 07 Apr 2008 15:09:42 -0000 Subject: [llvm-commits] [poolalloc] r49340 - in /poolalloc/trunk: include/poolalloc/PoolAllocate.h lib/PoolAllocate/AccessTrace.cpp lib/PoolAllocate/PASimple.cpp lib/PoolAllocate/PointerCompress.cpp lib/PoolAllocate/PoolAllocate.cpp lib/PoolAllocate/PoolOptimize.cpp lib/PoolAllocate/TransformFunctionBody.cpp Message-ID: <200804071509.m37F9g7I028323@zion.cs.uiuc.edu> Author: criswell Date: Mon Apr 7 10:09:40 2008 New Revision: 49340 URL: http://llvm.org/viewvc/llvm-project?rev=49340&view=rev Log: Updated Pool Allocation to new LLVM API. Added the PoolAllocateGroup analysis group. Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h poolalloc/trunk/lib/PoolAllocate/AccessTrace.cpp poolalloc/trunk/lib/PoolAllocate/PASimple.cpp poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp poolalloc/trunk/lib/PoolAllocate/PoolOptimize.cpp poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/poolalloc/PoolAllocate.h?rev=49340&r1=49339&r2=49340&view=diff ============================================================================== --- poolalloc/trunk/include/poolalloc/PoolAllocate.h (original) +++ poolalloc/trunk/include/poolalloc/PoolAllocate.h Mon Apr 7 10:09:40 2008 @@ -109,6 +109,22 @@ } // end PA namespace +class PoolAllocateGroup : public ImmutablePass { +public: + static char ID; + virtual PA::FuncInfo *getFuncInfo(Function &F); + virtual PA::FuncInfo *getFuncInfoOrClone(Function &F); + virtual DSGraph & getDSGraph (const Function & F) const; + + virtual DSGraph & getGlobalsGraph () const; + + virtual Value * getPool (const DSNode * N, Function & F); + + virtual Value * getGlobalPool (const DSNode * Node); + + virtual CompleteBUDataStructures::callee_iterator callee_begin (CallInst *CI); + virtual CompleteBUDataStructures::callee_iterator callee_end (CallInst *CI); +}; /// PoolAllocate - The main pool allocation pass /// Modified: poolalloc/trunk/lib/PoolAllocate/AccessTrace.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/AccessTrace.cpp?rev=49340&r1=49339&r2=49340&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/AccessTrace.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/AccessTrace.cpp Mon Apr 7 10:09:40 2008 @@ -95,7 +95,7 @@ // Insert the trace call. Value *Opts[2] = {Ptr, PD}; - new CallInst(PoolAccessTraceFn, Opts, Opts + 2, "", I); + CallInst::Create (PoolAccessTraceFn, Opts, Opts + 2, "", I); } bool PoolAccessTrace::runOnModule(Module &M) { @@ -108,7 +108,7 @@ Function *MainFunc = M.getFunction("main"); if (MainFunc && !MainFunc->isDeclaration()) // Insert a call to the library init function into the beginning of main. - new CallInst(AccessTraceInitFn, "", MainFunc->begin()->begin()); + CallInst::Create (AccessTraceInitFn, "", MainFunc->begin()->begin()); // Look at all of the loads in the program. for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) { Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PASimple.cpp?rev=49340&r1=49339&r2=49340&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PASimple.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Mon Apr 7 10:09:40 2008 @@ -46,6 +46,8 @@ namespace { RegisterPass X("poolalloc-simple", "Pool allocate everything into a single global pool"); + + RegisterAnalysisGroup PAGroup1(X); } static inline Value * @@ -74,6 +76,7 @@ AU.addRequired(); AU.addRequiredTransitive(); AU.addPreserved(); + AU.setPreservesAll(); } bool PoolAllocateSimple::runOnModule(Module &M) { @@ -153,7 +156,7 @@ } Value* args[] = {TheGlobalPool, AllocSize}; - Instruction* x = new CallInst(PoolAlloc, &args[0], &args[2], MI->getName(), ii); + Instruction* x = CallInst::Create(PoolAlloc, &args[0], &args[2], MI->getName(), ii); ii->replaceAllUsesWith(CastInst::createPointerCast(x, ii->getType(), "", ii)); } else if (AllocaInst * AI = dyn_cast(ii)) { #if 0 @@ -162,7 +165,7 @@ toDelete.push_back(ii); //Fixme: fixup size Value* args[] = {TheGlobalPool, ii->getOperand(0)}; - Instruction* x = new CallInst(PoolAlloc, &args[0], &args[2], AI->getName(), ii); + Instruction* x = CallInst::Create(PoolAlloc, &args[0], &args[2], AI->getName(), ii); ToFree.push_back(x); ii->replaceAllUsesWith(CastInst::createPointerCast(x, ii->getType(), "", ii)); #endif @@ -203,7 +206,7 @@ std::string Name = CI->getName(); CI->setName(""); Value* Opts[3] = {TheGlobalPool, OldPtr, Size}; - Instruction *V = new CallInst (PoolRealloc, + Instruction *V = CallInst::Create (PoolRealloc, Opts, Opts + 3, Name, @@ -220,7 +223,7 @@ Value * FreedNode = castTo (FI->getPointerOperand(), VoidPtrTy, "cast", ii); toDelete.push_back(ii); Value* args[] = {TheGlobalPool, FreedNode}; - new CallInst(PoolFree, &args[0], &args[2], "", ii); + CallInst::Create(PoolFree, &args[0], &args[2], "", ii); } else if (isa(ii)) { Returns.push_back(cast(ii)); } @@ -234,7 +237,7 @@ std::vector args; args.push_back (TheGlobalPool); args.push_back (*ii); - new CallInst(PoolFree, args.begin(), args.end(), "", *i); + CallInst::Create(PoolFree, args.begin(), args.end(), "", *i); } //delete malloc and alloca insts @@ -269,7 +272,7 @@ Value *ElSize = ConstantInt::get(Type::Int32Ty, RecSize); Value *AlignV = ConstantInt::get(Type::Int32Ty, Align); Value* Opts[3] = {GV, ElSize, AlignV}; - new CallInst(PoolInit, Opts, Opts + 3, "", InsertPt); + CallInst::Create(PoolInit, Opts, Opts + 3, "", InsertPt); return GV; } Modified: poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp?rev=49340&r1=49339&r2=49340&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp Mon Apr 7 10:09:40 2008 @@ -289,7 +289,7 @@ // Get the pool base pointer. Constant *Zero = Constant::getNullValue(Type::Int32Ty); Value *Opts[2] = {Zero, Zero}; - Value *BasePtrPtr = new GetElementPtrInst(getPoolDesc(), Opts, Opts + 2, + Value *BasePtrPtr = GetElementPtrInst::Create(getPoolDesc(), Opts, Opts + 2, "poolbaseptrptr", &I); return new LoadInst(BasePtrPtr, "poolbaseptr", &I); } else { @@ -301,7 +301,7 @@ while (isa(IP)) ++IP; Constant *Zero = Constant::getNullValue(Type::Int32Ty); Value *Opts[2] = {Zero, Zero}; - Value *BasePtrPtr = new GetElementPtrInst(getPoolDesc(), Opts, Opts + 2, + Value *BasePtrPtr = GetElementPtrInst::Create(getPoolDesc(), Opts, Opts + 2, "poolbaseptrptr", IP); PoolBase = new LoadInst(BasePtrPtr, "poolbaseptr", IP); } @@ -575,7 +575,7 @@ if (RI.getNumOperands() && isa(RI.getOperand(0)->getType())) if (!isa(RI.getParent()->getParent()->getReturnType())) { // Compressing the return value. - new ReturnInst(getTransformedValue(RI.getOperand(0)), &RI); + ReturnInst::Create(getTransformedValue(RI.getOperand(0)), &RI); RI.eraseFromParent(); } } @@ -604,7 +604,7 @@ const CompressedPoolInfo *DestPI = getPoolInfo(&PN); if (DestPI == 0) return; - PHINode *New = new PHINode(SCALARUINTTYPE, PN.getName(), &PN); + PHINode *New = PHINode::Create (SCALARUINTTYPE, PN.getName(), &PN); New->reserveOperandSpace(PN.getNumIncomingValues()); for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) @@ -617,7 +617,7 @@ const CompressedPoolInfo *DestPI = getPoolInfo(&SI); if (DestPI == 0) return; - setTransformedValue(SI, new SelectInst(SI.getOperand(0), + setTransformedValue(SI, SelectInst::Create(SI.getOperand(0), getTransformedValue(SI.getOperand(1)), getTransformedValue(SI.getOperand(2)), SI.getName(), &SI)); @@ -773,7 +773,7 @@ Value* Ops = getTransformedValue(LI.getOperand(0)); if (Ops->getType() == Type::Int16Ty) Ops = CastInst::createZExtOrBitCast(Ops, Type::Int32Ty, "extend_idx", &LI); - Value *SrcPtr = new GetElementPtrInst(BasePtr, Ops, + Value *SrcPtr = GetElementPtrInst::Create(BasePtr, Ops, LI.getOperand(0)->getName()+".pp", &LI); const Type *DestTy = LoadingCompressedPtr ? MEMUINTTYPE : LI.getType(); SrcPtr = CastInst::createPointerCast(SrcPtr, PointerType::getUnqual(DestTy), @@ -839,7 +839,7 @@ if (Ops->getType() == Type::Int16Ty) Ops = CastInst::createZExtOrBitCast(Ops, Type::Int32Ty, "extend_idx", &SI); - Value *DestPtr = new GetElementPtrInst(BasePtr, Ops, + Value *DestPtr = GetElementPtrInst::Create(BasePtr, Ops, SI.getOperand(1)->getName()+".pp", &SI); DestPtr = CastInst::createPointerCast(DestPtr, @@ -869,7 +869,7 @@ Ops.push_back(ConstantInt::get(Type::Int32Ty, PA::Heuristic::getRecommendedAlignment(PI->getNewType(), TD))); // TODO: Compression could reduce the alignment restriction for the pool! - Value *PB = new CallInst(PtrComp.PoolInitPC, Ops.begin(), Ops.end(), "", &CI); + Value *PB = CallInst::Create(PtrComp.PoolInitPC, Ops.begin(), Ops.end(), "", &CI); if (!DisablePoolBaseASR) { // Load the pool base immediately. PB->setName(CI.getOperand(1)->getName()+".poolbase"); @@ -886,7 +886,7 @@ const CompressedPoolInfo *PI = getPoolInfoForPoolDesc(CI.getOperand(1)); if (PI == 0) return; // Pool isn't compressed. - new CallInst(PtrComp.PoolDestroyPC, CI.getOperand(1), "", &CI); + CallInst::Create(PtrComp.PoolDestroyPC, CI.getOperand(1), "", &CI); CI.eraseFromParent(); } @@ -912,7 +912,7 @@ } Value *Opts[2] = {CI.getOperand(1), Size}; - Value *NC = new CallInst(PtrComp.PoolAllocPC, Opts, Opts + 2, CI.getName(), &CI); + Value *NC = CallInst::Create(PtrComp.PoolAllocPC, Opts, Opts + 2, CI.getName(), &CI); setTransformedValue(CI, NC); } @@ -968,7 +968,7 @@ } else if (Callee->getName() == "read") { if (const CompressedPoolInfo *DestPI = getPoolInfo(CI.getOperand(2))) { Value *BasePtr = DestPI->EmitPoolBaseLoad(CI); - Value *SrcPtr = new GetElementPtrInst(BasePtr, getTransformedValue(CI.getOperand(2)), + Value *SrcPtr = GetElementPtrInst::Create(BasePtr, getTransformedValue(CI.getOperand(2)), CI.getOperand(2)->getName()+".pp", &CI); SrcPtr = CastInst::createPointerCast(SrcPtr, CI.getOperand(2)->getType(), "", &CI); CI.setOperand(2, SrcPtr); @@ -977,7 +977,7 @@ } else if (Callee->getName() == "fwrite") { if (const CompressedPoolInfo *DestPI = getPoolInfo(CI.getOperand(1))) { Value *BasePtr = DestPI->EmitPoolBaseLoad(CI); - Value *SrcPtr = new GetElementPtrInst(BasePtr, getTransformedValue(CI.getOperand(1)), + Value *SrcPtr = GetElementPtrInst::Create(BasePtr, getTransformedValue(CI.getOperand(1)), CI.getOperand(1)->getName()+".pp", &CI); SrcPtr = CastInst::createPointerCast(SrcPtr, CI.getOperand(1)->getType(), "", &CI); CI.setOperand(1, SrcPtr); @@ -988,7 +988,7 @@ Callee->getName() == "llvm.memset.i64") { if (const CompressedPoolInfo *DestPI = getPoolInfo(CI.getOperand(1))) { Value *BasePtr = DestPI->EmitPoolBaseLoad(CI); - Value *SrcPtr = new GetElementPtrInst(BasePtr, getTransformedValue(CI.getOperand(1)), + Value *SrcPtr = GetElementPtrInst::Create(BasePtr, getTransformedValue(CI.getOperand(1)), CI.getOperand(1)->getName()+".pp", &CI); SrcPtr = CastInst::createPointerCast(SrcPtr, CI.getOperand(1)->getType(), "", &CI); CI.setOperand(1, SrcPtr); @@ -1000,7 +1000,7 @@ bool doret = false; if (const CompressedPoolInfo *DestPI = getPoolInfo(CI.getOperand(1))) { Value *BasePtr = DestPI->EmitPoolBaseLoad(CI); - Value *SrcPtr = new GetElementPtrInst(BasePtr, getTransformedValue(CI.getOperand(1)), + Value *SrcPtr = GetElementPtrInst::Create(BasePtr, getTransformedValue(CI.getOperand(1)), CI.getOperand(1)->getName()+".pp", &CI); SrcPtr = CastInst::createPointerCast(SrcPtr, CI.getOperand(1)->getType(), "", &CI); CI.setOperand(1, SrcPtr); @@ -1008,7 +1008,7 @@ } if (const CompressedPoolInfo *DestPI = getPoolInfo(CI.getOperand(2))) { Value *BasePtr = DestPI->EmitPoolBaseLoad(CI); - Value *SrcPtr = new GetElementPtrInst(BasePtr, getTransformedValue(CI.getOperand(2)), + Value *SrcPtr = GetElementPtrInst::Create(BasePtr, getTransformedValue(CI.getOperand(2)), CI.getOperand(2)->getName()+".pp", &CI); SrcPtr = CastInst::createPointerCast(SrcPtr, CI.getOperand(2)->getType(), "", &CI); CI.setOperand(2, SrcPtr); @@ -1037,7 +1037,7 @@ } Function *Clone = PtrComp.GetExtFunctionClone(Callee, CompressedArgs); - Value *NC = new CallInst(Clone, Operands.begin(), Operands.end(), CI.getName(), &CI); + Value *NC = CallInst::Create(Clone, Operands.begin(), Operands.end(), CI.getName(), &CI); if (NC->getType() != CI.getType()) // Compressing return value? setTransformedValue(CI, NC); else { @@ -1114,7 +1114,7 @@ else Operands.push_back(CI.getOperand(i)); - Value *NC = new CallInst(Clone, Operands.begin(), Operands.end(), CI.getName(), &CI); + Value *NC = CallInst::Create(Clone, Operands.begin(), Operands.end(), CI.getName(), &CI); if (NC->getType() != CI.getType()) // Compressing return value? setTransformedValue(CI, NC); else { @@ -1353,7 +1353,7 @@ FunctionType *CFTy = FunctionType::get(RetTy, ParamTypes, FTy->isVarArg()); // Next, create the clone prototype and insert it into the module. - Clone = new Function(CFTy, GlobalValue::ExternalLinkage, + Clone = Function::Create (CFTy, GlobalValue::ExternalLinkage, F->getName()+"_pc"); F->getParent()->getFunctionList().insert(F, Clone); return Clone; @@ -1399,8 +1399,8 @@ FunctionType *CFTy = FunctionType::get(RetTy, ParamTypes, FTy->isVarArg()); // Next, create the clone prototype and insert it into the module. - Clone = new Function(CFTy, GlobalValue::InternalLinkage, - F->getName()+".pc"); + Clone = Function::Create (CFTy, GlobalValue::InternalLinkage, + F->getName()+".pc"); F->getParent()->getFunctionList().insert(F, Clone); // Remember where this clone came from. Modified: poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp?rev=49340&r1=49339&r2=49340&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Mon Apr 7 10:09:40 2008 @@ -46,6 +46,7 @@ char PoolAllocate::ID = 0; char PoolAllocatePassAllPools::ID = 0; +char PoolAllocateGroup::ID = 0; const Type *PoolAllocate::PoolDescPtrTy = 0; @@ -59,9 +60,13 @@ namespace { RegisterPass X("poolalloc", "Pool allocate disjoint data structures"); + RegisterPass Y("poolalloc-passing-all-pools", "Pool allocate disjoint data structures"); + RegisterAnalysisGroup PAGroup ("Pool Allocation Group"); + RegisterAnalysisGroup PAGroup1(X); + STATISTIC (NumArgsAdded, "Number of function arguments added"); STATISTIC (MaxArgsAdded, "Maximum function arguments added to one function"); STATISTIC (NumCloned , "Number of functions cloned"); @@ -393,7 +398,7 @@ FunctionType *FuncTy = FunctionType::get(OldFuncTy->getReturnType(), ArgTys, OldFuncTy->isVarArg()); // Create the new function... - Function *New = new Function(FuncTy, Function::InternalLinkage, F.getName()); + Function *New = Function::Create(FuncTy, Function::InternalLinkage, F.getName()); F.getParent()->getFunctionList().insert(&F, New); CloneToOrigMap[New] = &F; // Remember original function. @@ -573,7 +578,7 @@ Value *ElSize = ConstantInt::get(Type::Int32Ty, RecSize); Value *AlignV = ConstantInt::get(Type::Int32Ty, Align); Value* Opts[3] = {GV, ElSize, AlignV}; - new CallInst(PoolInit, Opts, Opts + 3, "", InsertPt); + CallInst::Create(PoolInit, Opts, Opts + 3, "", InsertPt); ++NumPools; return GV; } @@ -914,7 +919,7 @@ for (unsigned i = 0, e = PoolInitPoints.size(); i != e; ++i) { Value* Opts[3] = {PD, ElSize, Align}; - new CallInst(PoolInit, Opts, Opts + 3, "", PoolInitPoints[i]); + CallInst::Create(PoolInit, Opts, Opts + 3, "", PoolInitPoints[i]); DEBUG(std::cerr << PoolInitPoints[i]->getParent()->getName() << " "); } @@ -923,7 +928,7 @@ // Loop over all of the places to insert pooldestroy's... for (unsigned i = 0, e = PoolDestroyPoints.size(); i != e; ++i) { // Insert the pooldestroy call for this pool. - new CallInst(PoolDestroy, PD, "", PoolDestroyPoints[i]); + CallInst::Create(PoolDestroy, PD, "", PoolDestroyPoints[i]); DEBUG(std::cerr << PoolDestroyPoints[i]->getParent()->getName()<<" "); } DEBUG(std::cerr << "\n\n"); Modified: poolalloc/trunk/lib/PoolAllocate/PoolOptimize.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolOptimize.cpp?rev=49340&r1=49339&r2=49340&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PoolOptimize.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PoolOptimize.cpp Mon Apr 7 10:09:40 2008 @@ -117,7 +117,7 @@ // poolrealloc(PD, null, X) -> poolalloc(PD, X) if (isa(CI->getOperand(2))) { Value* Opts[2] = {CI->getOperand(1), CI->getOperand(3)}; - Value *New = new CallInst(PoolAlloc, Opts, Opts + 2, + Value *New = CallInst::Create(PoolAlloc, Opts, Opts + 2, CI->getName(), CI); CI->replaceAllUsesWith(New); CI->eraseFromParent(); @@ -125,13 +125,13 @@ cast(CI->getOperand(3))->isNullValue()) { // poolrealloc(PD, X, 0) -> poolfree(PD, X) Value* Opts[2] = {CI->getOperand(1), CI->getOperand(2)}; - new CallInst(PoolFree, Opts, Opts + 2, "", CI); + CallInst::Create(PoolFree, Opts, Opts + 2, "", CI); CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); CI->eraseFromParent(); } else if (isa(CI->getOperand(1))) { // poolrealloc(null, X, Y) -> realloc(X, Y) Value* Opts[2] = {CI->getOperand(2), CI->getOperand(3)}; - Value *New = new CallInst(Realloc, Opts, Opts + 2, + Value *New = CallInst::Create(Realloc, Opts, Opts + 2, CI->getName(), CI); CI->replaceAllUsesWith(New); CI->eraseFromParent(); @@ -159,7 +159,7 @@ // poolmemalign(null, X, Y) -> memalign(X, Y) if (isa(CI->getOperand(1))) { Value* Opts[2] = {CI->getOperand(2), CI->getOperand(3)}; - Value *New = new CallInst(MemAlign, Opts, Opts + 2, CI->getName(), CI); + Value *New = CallInst::Create(MemAlign, Opts, Opts + 2, CI->getName(), CI); CI->replaceAllUsesWith(New); CI->eraseFromParent(); } @@ -230,18 +230,18 @@ std::vector Args; if (CI->getCalledFunction() == PoolAlloc) { Args.assign(CI->op_begin()+1, CI->op_end()); - Value *New = new CallInst(PoolAllocBP, Args.begin(), Args.end(), CI->getName(), CI); + Value *New = CallInst::Create(PoolAllocBP, Args.begin(), Args.end(), CI->getName(), CI); CI->replaceAllUsesWith(New); CI->eraseFromParent(); } else if (CI->getCalledFunction() == PoolInit) { Args.assign(CI->op_begin()+1, CI->op_end()); Args.erase(Args.begin()+1); // Drop the size argument. - new CallInst(PoolInitBP, Args.begin(), Args.end(), "", CI); + CallInst::Create(PoolInitBP, Args.begin(), Args.end(), "", CI); CI->eraseFromParent(); } else { assert(CI->getCalledFunction() == PoolDestroy); Args.assign(CI->op_begin()+1, CI->op_end()); - new CallInst(PoolDestroyBP, Args.begin(), Args.end(), "", CI); + CallInst::Create(PoolDestroyBP, Args.begin(), Args.end(), "", CI); CI->eraseFromParent(); } } Modified: poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp?rev=49340&r1=49339&r2=49340&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Mon Apr 7 10:09:40 2008 @@ -157,7 +157,7 @@ Value *PH = getPoolHandle(I); Value* Opts[2] = {PH, Size}; - Instruction *V = new CallInst(PAInfo.PoolAlloc, Opts, Opts + 2, Name, I); + Instruction *V = CallInst::Create(PAInfo.PoolAlloc, Opts, Opts + 2, Name, I); AddPoolUse(*V, PH, PoolUses); @@ -181,7 +181,7 @@ // If this was an invoke, fix up the CFG. if (InvokeInst *II = dyn_cast(I)) { - new BranchInst(II->getNormalDest(), I); + BranchInst::Create (II->getNormalDest(), I); II->getUnwindDest()->removePredecessor(II->getParent(), true); } @@ -234,7 +234,7 @@ Casted = CastInst::createPointerCast(AI, PointerType::getUnqual(Type::Int8Ty), AI->getName()+".casted",aiNext); - Instruction *V = new CallInst(PAInfo.PoolRegister, + Instruction *V = CallInst::Create(PAInfo.PoolRegister, make_vector(PH, AllocSize, Casted, 0), "", aiNext); AddPoolUse(*V, PH, PoolUses); } @@ -270,7 +270,7 @@ args.push_back (PH); args.push_back (Casted); args.push_back (AllocSize); - Instruction *V = new CallInst(PAInfo.PoolRegister, + Instruction *V = CallInst::Create(PAInfo.PoolRegister, args.begin(), args.end(), "", InsertPt); AddPoolUse(*V, PH, PoolUses); } @@ -291,7 +291,7 @@ } Value* Opts[2] = {PH, Casted}; - CallInst *FreeI = new CallInst(PAInfo.PoolFree, Opts, Opts + 2, "", Where); + CallInst *FreeI = CallInst::Create(PAInfo.PoolFree, Opts, Opts + 2, "", Where); AddPoolUse(*FreeI, PH, PoolFrees); return FreeI; } @@ -352,7 +352,7 @@ // We know that the memory returned by poolalloc is at least 4 byte aligned. Value* Opts[4] = {Ptr, ConstantInt::get(Type::Int8Ty, 0), V2, ConstantInt::get(Type::Int32Ty, 4)}; - new CallInst(MemSet, Opts, Opts + 4, "", BBI); + CallInst::Create(MemSet, Opts, Opts + 4, "", BBI); } @@ -372,7 +372,7 @@ std::string Name = I->getName(); I->setName(""); Value* Opts[3] = {PH, OldPtr, Size}; - Instruction *V = new CallInst(PAInfo.PoolRealloc, Opts, Opts + 3, Name, I); + Instruction *V = CallInst::Create(PAInfo.PoolRealloc, Opts, Opts + 3, Name, I); Instruction *Casted = V; if (V->getType() != I->getType()) Casted = CastInst::createPointerCast(V, I->getType(), V->getName(), I); @@ -392,7 +392,7 @@ // If this was an invoke, fix up the CFG. if (InvokeInst *II = dyn_cast(I)) { - new BranchInst(II->getNormalDest(), I); + BranchInst::Create (II->getNormalDest(), I); II->getUnwindDest()->removePredecessor(II->getParent(), true); } @@ -440,7 +440,7 @@ std::string Name = I->getName(); I->setName(""); Value* Opts[3] = {PH, Align, Size}; - Instruction *V = new CallInst(PAInfo.PoolMemAlign, Opts, Opts + 3, Name, I); + Instruction *V = CallInst::Create(PAInfo.PoolMemAlign, Opts, Opts + 3, Name, I); Instruction *Casted = V; if (V->getType() != I->getType()) @@ -463,7 +463,7 @@ // If this was an invoke, fix up the CFG. if (InvokeInst *II = dyn_cast(I)) { - new BranchInst(II->getNormalDest(), I); + BranchInst::Create (II->getNormalDest(), I); II->getUnwindDest()->removePredecessor(II->getParent(), true); } @@ -495,7 +495,7 @@ std::string Name = I->getName(); I->setName(""); Value* Opts[3] = {PH, OldPtr, 0}; - Instruction *V = new CallInst(PAInfo.PoolStrdup, Opts, Opts + 2, Name, I); + Instruction *V = CallInst::Create(PAInfo.PoolStrdup, Opts, Opts + 2, Name, I); Instruction *Casted = V; if (V->getType() != I->getType()) Casted = CastInst::createPointerCast(V, I->getType(), V->getName(), I); @@ -515,7 +515,7 @@ // If this was an invoke, fix up the CFG. if (InvokeInst *II = dyn_cast(I)) { - new BranchInst(II->getNormalDest(), I); + BranchInst::Create (II->getNormalDest(), I); II->getUnwindDest()->removePredecessor(II->getParent(), true); } @@ -733,9 +733,9 @@ Value *ElSize = ConstantInt::get(Type::Int32Ty,0); Value *Align = ConstantInt::get(Type::Int32Ty,0); Value* Opts[3] = {ArgVal, ElSize, Align}; - new CallInst(PAInfo.PoolInit, Opts, Opts + 3,"", TheCall); + CallInst::Create(PAInfo.PoolInit, Opts, Opts + 3,"", TheCall); BasicBlock::iterator BBI = TheCall; - new CallInst(PAInfo.PoolDestroy, ArgVal, "", ++BBI); + CallInst::Create(PAInfo.PoolDestroy, ArgVal, "", ++BBI); } //probably need to update DSG @@ -753,10 +753,12 @@ std::string Name = TheCall->getName(); TheCall->setName(""); if (InvokeInst *II = dyn_cast(TheCall)) { - NewCall = new InvokeInst(NewCallee, II->getNormalDest(), - II->getUnwindDest(), Args.begin(), Args.end(), Name, TheCall); + NewCall = InvokeInst::Create (NewCallee, II->getNormalDest(), + II->getUnwindDest(), + Args.begin(), Args.end(), Name, TheCall); } else { - NewCall = new CallInst(NewCallee, Args.begin(), Args.end(), Name, TheCall); + NewCall = CallInst::Create (NewCallee, Args.begin(), Args.end(), Name, + TheCall); } // Add all of the uses of the pool descriptor From echristo at apple.com Mon Apr 7 11:27:56 2008 From: echristo at apple.com (Eric Christopher) Date: Mon, 7 Apr 2008 09:27:56 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r49171 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp llvm-types.cpp In-Reply-To: <200804062303.26210.baldrick@free.fr> References: <200804031727.m33HRR6h004565@zion.cs.uiuc.edu> <200804062303.26210.baldrick@free.fr> Message-ID: >> > > Since there is no difficulty in doing the slightly more general "this > file does not have to deal with the possibility that exceptions get > thrown or unwound *in this file*", why not do so? I think there is a slight difference. There's the "this file doesn't throw exceptions" and "this file doesn't throw or propagate exceptions". I think Dale is doing the first, though I'd like to personally have files able to unwind across even if nothing in the file throws. -eric From evan.cheng at apple.com Mon Apr 7 11:30:08 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 7 Apr 2008 09:30:08 -0700 Subject: [llvm-commits] [llvm] r48822 - in /llvm/trunk: include/llvm/CodeGen/ScheduleDAG.h include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/DAGCombiner.cpp lib/CodeGen/SelectionDAG/LegalizeDAG.cpp lib/CodeGen/SelectionDAG/LegalizeTypes.cp In-Reply-To: References: Message-ID: <256C89DC-FD83-45EA-B483-DE44722726DA@apple.com> On Apr 7, 2008, at 3:10 AM, Roman Levenstein wrote: > Hi Evan, > > 2008/4/3, Evan Cheng : >> I've backed this out for now. Please fix the infinite looping and >> then >> re-commit. > > I fixed the problem and re-committed. The newer and better patch is > ready, but it is not approved by Dan yet. > > Dan: Ping! ;-) Thanks. Evan > > > -Roman > >> On Apr 2, 2008, at 2:28 PM, Dan Gohman wrote: >> >>> >>> On Mar 26, 2008, at 5:39 AM, Roman Levenstein wrote: >>>> >>>> + >>>> + SmallSetVector Users; >>>> while (!From->use_empty()) { >>>> - // Process users until they are all gone. >>>> - SDNode *U = *From->use_begin(); >>>> - >>>> + SDNode::use_iterator UI = From->use_begin(); >>>> + SDNode *U = UI->getUser(); >>>> + >>>> + // Remember that this node is about to morph. >>>> + if (Users.count(U)) >>>> + continue; >>>> + Users.insert(U); >>> >>> Hi Roman, >>> >>> This code that remembers users is causing the loop to >>> repeat infinitely in some cases. Actually, if Users.count(U) >>> is ever true, it gooes into an infinite loop because >>> nothing happens that will make From->use_list() >>> get closer to being empty. >>> >>> You can reproduce this by unmerging revision 48994 and >>> running llc on the attached testcase. 48994 is otherwise >>> unrelated, but it happens to change the way this testcase >>> gets compiled such that the above bug doesn't get triggered. >>> >>> Can you take a look at this? >>> >>> Thanks, >>> >>> Dan >> >>> >> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From baldrick at free.fr Mon Apr 7 11:39:53 2008 From: baldrick at free.fr (Duncan Sands) Date: Mon, 7 Apr 2008 18:39:53 +0200 Subject: [llvm-commits] =?ansi_x3.4-1968?q?=5Bllvm-gcc-4=2E2=5D_r49171_-_i?= =?ansi_x3.4-1968?q?n=09/llvm-gcc-4=2E2/trunk/gcc=3A_llvm-convert=2Ecpp_ll?= =?ansi_x3.4-1968?q?vm-types=2Ecpp?= In-Reply-To: References: <200804031727.m33HRR6h004565@zion.cs.uiuc.edu> <200804062303.26210.baldrick@free.fr> Message-ID: <200804071839.58180.baldrick@free.fr> Hi Eric, > > Since there is no difficulty in doing the slightly more general "this > > file does not have to deal with the possibility that exceptions get > > thrown or unwound *in this file*", why not do so? > > > I think there is a slight difference. There's the "this file doesn't > throw > exceptions" and "this file doesn't throw or propagate exceptions". it's a bit different: we're discussing what you should get if a file is compiled with -fno-exceptions, which is a gcc flag saying that this file doesn't need to support exceptions unwinding through it (it also means that nothing in the file throws or catches exceptions). > I > think > Dale is doing the first, though I'd like to personally have files able > to unwind across even if nothing in the file throws. If a function does not throw exceptions and the compiler can prove that functions it calls don't throw exceptions either (or, rather, any exceptions they throw don't unwind out of the function), then the compiler can discard some exception handling info needed to unwind out of it because that info is pointless. But that's a different issue to what we're discussing here. Best wishes, Duncan. From dpatel at apple.com Mon Apr 7 11:46:22 2008 From: dpatel at apple.com (Devang Patel) Date: Mon, 7 Apr 2008 09:46:22 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r49231 - in /llvm-gcc-4.2/trunk/gcc: llvm-abi.h llvm-convert.cpp llvm-types.cpp In-Reply-To: <200804061022.56086.baldrick@free.fr> References: <200804042115.m34LF6YA029677@zion.cs.uiuc.edu> <200804050838.40831.baldrick@free.fr> <1ADA393A-F2ED-4073-B9D2-084215386A1A@apple.com> <200804061022.56086.baldrick@free.fr> Message-ID: <53D07A6D-4F47-4FE1-93C6-DBD2CBA461B4@apple.com> On Apr 6, 2008, at 1:22 AM, Duncan Sands wrote: >>> The ABI is used in two places in llvm-convert: setting up arguments >>> to calls, >>> and extracting arguments inside function bodies. But you only >>> modified one... >> >> which one did I miss ? > > FunctionPrologArgumentConversion. This one handles arguments where as new hook, HandleAggregateResultAsAggregate(), is for return values. FunctionPrologArgumentConversion does not override HandleAggregateResultAsScalar() either. - Devang From evan.cheng at apple.com Mon Apr 7 11:49:21 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 7 Apr 2008 09:49:21 -0700 Subject: [llvm-commits] [llvm] r49243 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp In-Reply-To: References: <200804042348.m34NmWkJ001615@zion.cs.uiuc.edu> <8733BA63-45D5-4D88-B0DA-BDB267D89EF9@apple.com> Message-ID: <194F0FE7-B571-4601-BB26-1B0408476B75@apple.com> Ok, can you add a "set root to first pending load and flush" function when you have a chance? Thanks. Evan On Apr 5, 2008, at 10:15 AM, Dale Johannesen wrote: > > On Apr 5, 2008, at 1:57 AM, Evan Cheng wrote: > >> Is this fixing a regression from Dan's patch? Can you separate out >> the >> flushing functionality from getroot? It seems a bit strange to use >> getRoot for its side effects. >> >> Evan > > Well, things named getXXX should not have side effects, IMO. If I > were going > to work on naming I would probably rename getRoot and getControlRoot > to something > more descriptive rather than add a new function. But in general I > prefer minimal > changes to more invasive ones. (I wasn't familiar with this code > either.) > > Glad this fixed some Ada regressions, not too surprising. > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From dalej at apple.com Mon Apr 7 11:52:16 2008 From: dalej at apple.com (Dale Johannesen) Date: Mon, 7 Apr 2008 09:52:16 -0700 Subject: [llvm-commits] [llvm] r49243 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp In-Reply-To: <194F0FE7-B571-4601-BB26-1B0408476B75@apple.com> References: <200804042348.m34NmWkJ001615@zion.cs.uiuc.edu> <8733BA63-45D5-4D88-B0DA-BDB267D89EF9@apple.com> <194F0FE7-B571-4601-BB26-1B0408476B75@apple.com> Message-ID: <327B23EF-8FA9-4106-BCFD-5D044BB5CA9D@apple.com> On Apr 7, 2008, at 9:49 AM, Evan Cheng wrote: > Ok, can you add a "set root to first pending load and flush" function > when you have a chance? > > Thanks. > > Evan No, as I said, I do not believe adding a new function is a good idea. If you want to change something here the right thing is to rename getRoot and getControlRoot to something like flushXXXandAdvanceRoot. > On Apr 5, 2008, at 10:15 AM, Dale Johannesen wrote: > >> >> On Apr 5, 2008, at 1:57 AM, Evan Cheng wrote: >> >>> Is this fixing a regression from Dan's patch? Can you separate out >>> the >>> flushing functionality from getroot? It seems a bit strange to use >>> getRoot for its side effects. >>> >>> Evan >> >> Well, things named getXXX should not have side effects, IMO. If I >> were going >> to work on naming I would probably rename getRoot and getControlRoot >> to something >> more descriptive rather than add a new function. But in general I >> prefer minimal >> changes to more invasive ones. (I wasn't familiar with this code >> either.) >> >> Glad this fixed some Ada regressions, not too surprising. >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From ggreif at gmail.com Mon Apr 7 11:53:00 2008 From: ggreif at gmail.com (Gabor Greif) Date: Mon, 07 Apr 2008 16:53:00 -0000 Subject: [llvm-commits] [llvm] r49341 - in /llvm/branches/ggreif/use-diet: include/llvm/Use.h lib/VMCore/Use.cpp Message-ID: <200804071653.m37Gr0pF031577@zion.cs.uiuc.edu> Author: ggreif Date: Mon Apr 7 11:52:59 2008 New Revision: 49341 URL: http://llvm.org/viewvc/llvm-project?rev=49341&view=rev Log: add functionality for initial encoding of tags Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Use.h?rev=49341&r1=49340&r2=49341&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Use.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Use.h Mon Apr 7 11:52:59 2008 @@ -41,7 +41,7 @@ if (Val) removeFromList(); } - /// Default ctor - This leaves the Use completely unitialized. The only thing + /// Default ctor - This leaves the Use completely uninitialized. The only thing /// that is valid to do with this use is to call the "init" method. inline Use() : Val(0) {} @@ -50,6 +50,7 @@ Value *get() const { return Val; } User *getUser() const { return U; } const Use* getImpliedUser() const; + void initTags(Use* start, Use* stop, ptrdiff_t done = 0); inline void set(Value *Val); Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp?rev=49341&r1=49340&r2=49341&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Mon Apr 7 11:52:59 2008 @@ -19,31 +19,51 @@ // Use getImpliedUser Implementation //===----------------------------------------------------------------------===// +enum ValuePtrTag { zeroDigitTag = 0, oneDigitTag = 1, stopTag = 0x2, fullStopTag = 0x3 }; + const Use *Use::getImpliedUser() const { bool StopEncountered = false; ptrdiff_t Offset = 0; const Use *Current = this; - enum { stop = 0x2, fullstop = 0x3 }; while (true) { unsigned Tag = unsigned(Current->Val) & 0x3; switch (Tag) { - case 0: - case 1: // digits - if (StopEncountered) - Offset = (Offset << 1) + Tag; - break; - case stop: - if (StopEncountered) - return Current + Offset; - StopEncountered = true; - break; - case fullstop: - return Current + 1; + case zeroDigitTag: + case oneDigitTag: + if (StopEncountered) + Offset = (Offset << 1) + Tag; + break; + case stopTag: + if (StopEncountered) + return Current + Offset; + StopEncountered = true; + break; + case fullStopTag: + return Current + 1; } ++Current; } } + +void Use::initTags(Use* start, Use* stop, ptrdiff_t done) { + ptrdiff_t Count = 0; + while (start != stop) + { + --stop; + if (!Count) { + stop->Val = reinterpret_cast(done == 0 ? fullStopTag : stopTag); + ++done; + Count = done; + } else { + stop->Val = reinterpret_cast(Count & 1); + Count >>= 1; + ++done; + } + } +} + + } From ggreif at gmail.com Mon Apr 7 11:58:34 2008 From: ggreif at gmail.com (Gabor Greif) Date: Mon, 07 Apr 2008 16:58:34 -0000 Subject: [llvm-commits] [llvm] r49342 - in /llvm/branches/ggreif/use-diet: include/llvm/Use.h lib/VMCore/Use.cpp Message-ID: <200804071658.m37GwYlu031768@zion.cs.uiuc.edu> Author: ggreif Date: Mon Apr 7 11:58:34 2008 New Revision: 49342 URL: http://llvm.org/viewvc/llvm-project?rev=49342&view=rev Log: coding standard Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Use.h?rev=49342&r1=49341&r2=49342&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Use.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Use.h Mon Apr 7 11:58:34 2008 @@ -50,7 +50,7 @@ Value *get() const { return Val; } User *getUser() const { return U; } const Use* getImpliedUser() const; - void initTags(Use* start, Use* stop, ptrdiff_t done = 0); + void initTags(Use *Start, Use *Stop, ptrdiff_t Done = 0); inline void set(Value *Val); Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp?rev=49342&r1=49341&r2=49342&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Mon Apr 7 11:58:34 2008 @@ -48,21 +48,21 @@ } } -void Use::initTags(Use* start, Use* stop, ptrdiff_t done) { - ptrdiff_t Count = 0; - while (start != stop) - { - --stop; - if (!Count) { - stop->Val = reinterpret_cast(done == 0 ? fullStopTag : stopTag); - ++done; - Count = done; - } else { - stop->Val = reinterpret_cast(Count & 1); - Count >>= 1; - ++done; - } +void Use::initTags(Use *Start, Use *Stop, ptrdiff_t Done) { + ptrdiff_t Count = 0; + while (Start != Stop) + { + --Stop; + if (!Count) { + Stop->Val = reinterpret_cast(Done == 0 ? fullStopTag : stopTag); + ++Done; + Count = Done; + } else { + Stop->Val = reinterpret_cast(Count & 1); + Count >>= 1; + ++Done; } + } } From evan.cheng at apple.com Mon Apr 7 12:02:18 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 07 Apr 2008 17:02:18 -0000 Subject: [llvm-commits] [llvm] r49343 - /llvm/trunk/test/CodeGen/X86/vec_shuffle-16.ll Message-ID: <200804071702.m37H2I0u031927@zion.cs.uiuc.edu> Author: evancheng Date: Mon Apr 7 12:02:18 2008 New Revision: 49343 URL: http://llvm.org/viewvc/llvm-project?rev=49343&view=rev Log: Fix test. Modified: llvm/trunk/test/CodeGen/X86/vec_shuffle-16.ll Modified: llvm/trunk/test/CodeGen/X86/vec_shuffle-16.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_shuffle-16.ll?rev=49343&r1=49342&r2=49343&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_shuffle-16.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_shuffle-16.ll Mon Apr 7 12:02:18 2008 @@ -1,5 +1,5 @@ -; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse | grep shufps | count 4 -; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse | grep mov | count 2 +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse,-sse2 | grep shufps | count 4 +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse,-sse2 | grep mov | count 2 ; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep pshufd | count 4 ; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | not grep shufps ; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | not grep mov From baldrick at free.fr Mon Apr 7 12:03:17 2008 From: baldrick at free.fr (Duncan Sands) Date: Mon, 07 Apr 2008 17:03:17 -0000 Subject: [llvm-commits] [llvm] r49344 - /llvm/trunk/test/Analysis/Andersens/2008-04-07-Memcpy.ll Message-ID: <200804071703.m37H3HM8032000@zion.cs.uiuc.edu> Author: baldrick Date: Mon Apr 7 12:03:16 2008 New Revision: 49344 URL: http://llvm.org/viewvc/llvm-project?rev=49344&view=rev Log: Testcase for pr2169. Added: llvm/trunk/test/Analysis/Andersens/2008-04-07-Memcpy.ll Added: llvm/trunk/test/Analysis/Andersens/2008-04-07-Memcpy.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/Andersens/2008-04-07-Memcpy.ll?rev=49344&view=auto ============================================================================== --- llvm/trunk/test/Analysis/Andersens/2008-04-07-Memcpy.ll (added) +++ llvm/trunk/test/Analysis/Andersens/2008-04-07-Memcpy.ll Mon Apr 7 12:03:16 2008 @@ -0,0 +1,14 @@ +; RUN: llvm-as < %s | opt -anders-aa -gvn | llvm-dis | not grep undef +; PR2169 + +declare void @llvm.memcpy.i32(i8*, i8*, i32, i32) nounwind +declare void @use(i8) + +define void @f(i8* %x) { +entry: + %copy = alloca i8 ; [#uses=6] + call void @llvm.memcpy.i32( i8* %copy, i8* %x, i32 1, i32 4 ) + %tmp = load i8* %copy ; [#uses=1] + call void @use(i8 %tmp) + ret void +} From baldrick at free.fr Mon Apr 7 12:07:55 2008 From: baldrick at free.fr (Duncan Sands) Date: Mon, 7 Apr 2008 19:07:55 +0200 Subject: [llvm-commits] [llvm-gcc-4.2] r49231 - in /llvm-gcc-4.2/trunk/gcc: llvm-abi.h llvm-convert.cpp llvm-types.cpp In-Reply-To: <53D07A6D-4F47-4FE1-93C6-DBD2CBA461B4@apple.com> References: <200804042115.m34LF6YA029677@zion.cs.uiuc.edu> <200804061022.56086.baldrick@free.fr> <53D07A6D-4F47-4FE1-93C6-DBD2CBA461B4@apple.com> Message-ID: <200804071908.00210.baldrick@free.fr> > >> which one did I miss ? > > > > FunctionPrologArgumentConversion. > > This one handles arguments where as new hook, > HandleAggregateResultAsAggregate(), is for return values. > FunctionPrologArgumentConversion does not override > HandleAggregateResultAsScalar() either. OK, I was assuming that it (for example) assigned DECL_LLVM for the RESULT_DECL and that kind of thing. Sorry for the noise. Ciao, Duncan. From echristo at apple.com Mon Apr 7 12:36:06 2008 From: echristo at apple.com (Eric Christopher) Date: Mon, 7 Apr 2008 10:36:06 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r49171 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp llvm-types.cpp In-Reply-To: <200804071839.58180.baldrick@free.fr> References: <200804031727.m33HRR6h004565@zion.cs.uiuc.edu> <200804062303.26210.baldrick@free.fr> <200804071839.58180.baldrick@free.fr> Message-ID: <5F7C1FC3-2F61-40CD-909F-D3DB3AFA578A@apple.com> >> >> I think there is a slight difference. There's the "this file doesn't >> throw >> exceptions" and "this file doesn't throw or propagate exceptions". > > it's a bit different: we're discussing what you should get if a file > is compiled with -fno-exceptions, which is a gcc flag saying that this > file doesn't need to support exceptions unwinding through it (it also > means that nothing in the file throws or catches exceptions). > I agree. This is why some targets in gcc specify that the unwind tables should exist even if you compile with -fno-exceptions. Look for the -fasynchronus-unwind-tables code in gcc. >> I >> think >> Dale is doing the first, though I'd like to personally have files >> able >> to unwind across even if nothing in the file throws. > > If a function does not throw exceptions and the compiler can prove > that > functions it calls don't throw exceptions either (or, rather, any > exceptions > they throw don't unwind out of the function), then the compiler can > discard > some exception handling info needed to unwind out of it because that > info > is pointless. But that's a different issue to what we're discussing > here. Agreed, but that's not what I'm saying either. :) -eric From resistor at mac.com Mon Apr 7 12:38:23 2008 From: resistor at mac.com (Owen Anderson) Date: Mon, 07 Apr 2008 17:38:23 -0000 Subject: [llvm-commits] [llvm] r49345 - in /llvm/trunk: include/llvm/ADT/SparseBitVector.h lib/Transforms/Scalar/GVN.cpp Message-ID: <200804071738.m37HcNpJ000604@zion.cs.uiuc.edu> Author: resistor Date: Mon Apr 7 12:38:23 2008 New Revision: 49345 URL: http://llvm.org/viewvc/llvm-project?rev=49345&view=rev Log: Add operator= implementations to SparseBitVector, allowing it to be used in GVN. This results in both time and memory savings for GVN. For example, one testcase went from 10.5s to 6s with this patch. Modified: llvm/trunk/include/llvm/ADT/SparseBitVector.h llvm/trunk/lib/Transforms/Scalar/GVN.cpp Modified: llvm/trunk/include/llvm/ADT/SparseBitVector.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SparseBitVector.h?rev=49345&r1=49344&r2=49345&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/SparseBitVector.h (original) +++ llvm/trunk/include/llvm/ADT/SparseBitVector.h Mon Apr 7 12:38:23 2008 @@ -89,6 +89,14 @@ ElementIndex = RHS.ElementIndex; std::copy(&RHS.Bits[0], &RHS.Bits[BITWORDS_PER_ELEMENT], Bits); } + + // Assignment + SparseBitVectorElement& operator=(const SparseBitVectorElement& RHS) { + ElementIndex = RHS.ElementIndex; + std::copy(&RHS.Bits[0], &RHS.Bits[BITWORDS_PER_ELEMENT], Bits); + + return *this; + } // Comparison. bool operator==(const SparseBitVectorElement &RHS) const { @@ -483,6 +491,21 @@ CurrElementIter = Elements.begin (); } + + // Assignment + SparseBitVector& operator=(const SparseBitVector& RHS) { + Elements.clear(); + + ElementListConstIter ElementIter = RHS.Elements.begin(); + while (ElementIter != RHS.Elements.end()) { + Elements.push_back(SparseBitVectorElement(*ElementIter)); + ++ElementIter; + } + + CurrElementIter = Elements.begin (); + + return *this; + } // Test, Reset, and Set a bit in the bitmap. bool test(unsigned Idx) { Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=49345&r1=49344&r2=49345&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Mon Apr 7 12:38:23 2008 @@ -22,11 +22,11 @@ #include "llvm/Instructions.h" #include "llvm/ParameterAttributes.h" #include "llvm/Value.h" -#include "llvm/ADT/BitVector.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/SparseBitVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/AliasAnalysis.h" @@ -590,9 +590,9 @@ class VISIBILITY_HIDDEN ValueNumberedSet { private: SmallPtrSet contents; - BitVector numbers; + SparseBitVector<64> numbers; public: - ValueNumberedSet() { numbers.resize(1); } + ValueNumberedSet() { } ValueNumberedSet(const ValueNumberedSet& other) { numbers = other.numbers; contents = other.contents; @@ -610,9 +610,6 @@ size_t size() { return contents.size(); } void set(unsigned i) { - if (i >= numbers.size()) - numbers.resize(i+1); - numbers.set(i); } @@ -622,21 +619,12 @@ } void reset(unsigned i) { - if (i < numbers.size()) - numbers.reset(i); + numbers.reset(i); } bool test(unsigned i) { - if (i >= numbers.size()) - return false; - return numbers.test(i); } - - void clear() { - contents.clear(); - numbers.clear(); - } }; } @@ -1598,6 +1586,10 @@ if (isa(I)) return false; + // Allocations are always unique, so don't bother value numbering them. + if (isa(I)) + return false; + if (MemCpyInst* M = dyn_cast(I)) { MemoryDependenceAnalysis& MD = getAnalysis(); From evan.cheng at apple.com Mon Apr 7 12:39:44 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 7 Apr 2008 10:39:44 -0700 Subject: [llvm-commits] [llvm] r49243 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp In-Reply-To: <327B23EF-8FA9-4106-BCFD-5D044BB5CA9D@apple.com> References: <200804042348.m34NmWkJ001615@zion.cs.uiuc.edu> <8733BA63-45D5-4D88-B0DA-BDB267D89EF9@apple.com> <194F0FE7-B571-4601-BB26-1B0408476B75@apple.com> <327B23EF-8FA9-4106-BCFD-5D044BB5CA9D@apple.com> Message-ID: On Apr 7, 2008, at 9:52 AM, Dale Johannesen wrote: > > On Apr 7, 2008, at 9:49 AM, Evan Cheng wrote: > >> Ok, can you add a "set root to first pending load and flush" function >> when you have a chance? >> >> Thanks. >> >> Evan > > No, as I said, I do not believe adding a new function is a good idea. > If you want to change something here the right thing is to rename > getRoot and getControlRoot to something like flushXXXandAdvanceRoot. Sounds good. :-) Can you take care of it when you have a chance? Evan > > >> On Apr 5, 2008, at 10:15 AM, Dale Johannesen wrote: >> >>> >>> On Apr 5, 2008, at 1:57 AM, Evan Cheng wrote: >>> >>>> Is this fixing a regression from Dan's patch? Can you separate out >>>> the >>>> flushing functionality from getroot? It seems a bit strange to use >>>> getRoot for its side effects. >>>> >>>> Evan >>> >>> Well, things named getXXX should not have side effects, IMO. If I >>> were going >>> to work on naming I would probably rename getRoot and getControlRoot >>> to something >>> more descriptive rather than add a new function. But in general I >>> prefer minimal >>> changes to more invasive ones. (I wasn't familiar with this code >>> either.) >>> >>> Glad this fixed some Ada regressions, not too surprising. >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From dalej at apple.com Mon Apr 7 12:43:28 2008 From: dalej at apple.com (Dale Johannesen) Date: Mon, 7 Apr 2008 10:43:28 -0700 Subject: [llvm-commits] [llvm] r49243 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp In-Reply-To: References: <200804042348.m34NmWkJ001615@zion.cs.uiuc.edu> <8733BA63-45D5-4D88-B0DA-BDB267D89EF9@apple.com> <194F0FE7-B571-4601-BB26-1B0408476B75@apple.com> <327B23EF-8FA9-4106-BCFD-5D044BB5CA9D@apple.com> Message-ID: On Apr 7, 2008, at 10:39 AM, Evan Cheng wrote: > > On Apr 7, 2008, at 9:52 AM, Dale Johannesen wrote: > >> >> On Apr 7, 2008, at 9:49 AM, Evan Cheng wrote: >> >>> Ok, can you add a "set root to first pending load and flush" >>> function >>> when you have a chance? >>> >>> Thanks. >>> >>> Evan >> >> No, as I said, I do not believe adding a new function is a good idea. >> If you want to change something here the right thing is to rename >> getRoot and getControlRoot to something like flushXXXandAdvanceRoot. > > Sounds good. :-) Can you take care of it when you have a chance? > > Evan I suppose. It's not going to be a high priority. >>> On Apr 5, 2008, at 10:15 AM, Dale Johannesen wrote: >>> >>>> On Apr 5, 2008, at 1:57 AM, Evan Cheng wrote: >>>> >>>>> Is this fixing a regression from Dan's patch? Can you separate out >>>>> the >>>>> flushing functionality from getroot? It seems a bit strange to use >>>>> getRoot for its side effects. >>>>> >>>>> Evan >>>> >>>> Well, things named getXXX should not have side effects, IMO. If I >>>> were going >>>> to work on naming I would probably rename getRoot and >>>> getControlRoot >>>> to something >>>> more descriptive rather than add a new function. But in general I >>>> prefer minimal >>>> changes to more invasive ones. (I wasn't familiar with this code >>>> either.) >>>> >>>> Glad this fixed some Ada regressions, not too surprising. >>>> >>>> _______________________________________________ >>>> llvm-commits mailing list >>>> llvm-commits at cs.uiuc.edu >>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From edwintorok at gmail.com Mon Apr 7 12:48:47 2008 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Mon, 07 Apr 2008 20:48:47 +0300 Subject: [llvm-commits] [llvm] r49345 - in /llvm/trunk: include/llvm/ADT/SparseBitVector.h lib/Transforms/Scalar/GVN.cpp In-Reply-To: <200804071738.m37HcNpJ000604@zion.cs.uiuc.edu> References: <200804071738.m37HcNpJ000604@zion.cs.uiuc.edu> Message-ID: <47FA5E7F.5090705@gmail.com> Owen Anderson wrote: > @@ -1598,6 +1586,10 @@ > if (isa(I)) > return false; > > + // Allocations are always unique, so don't bother value numbering them. > + if (isa(I)) > + return false; > + > if (MemCpyInst* M = dyn_cast(I)) { > MemoryDependenceAnalysis& MD = getAnalysis(); > Why do same test twice? Patch applied twice? Best regards, --Edwin From resistor at mac.com Mon Apr 7 13:18:53 2008 From: resistor at mac.com (Owen Anderson) Date: Mon, 07 Apr 2008 11:18:53 -0700 Subject: [llvm-commits] [llvm] r49345 - in /llvm/trunk: include/llvm/ADT/SparseBitVector.h lib/Transforms/Scalar/GVN.cpp In-Reply-To: <47FA5E7F.5090705@gmail.com> References: <200804071738.m37HcNpJ000604@zion.cs.uiuc.edu> <47FA5E7F.5090705@gmail.com> Message-ID: <6810DE29-0119-1000-8254-64C642EC17FA-Webmail-10011@mac.com> Yup. Sorry, will fix when I get back to my development machine. --Owen On Monday, April 07, 2008, at 12:49PM, "T?r?k Edwin" wrote: >Owen Anderson wrote: >> @@ -1598,6 +1586,10 @@ >> if (isa(I)) >> return false; >> >> + // Allocations are always unique, so don't bother value numbering them. >> + if (isa(I)) >> + return false; >> + >> if (MemCpyInst* M = dyn_cast(I)) { >> MemoryDependenceAnalysis& MD = getAnalysis(); >> > >Why do same test twice? Patch applied twice? > >Best regards, >--Edwin >_______________________________________________ >llvm-commits mailing list >llvm-commits at cs.uiuc.edu >http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > From nbegeman at apple.com Mon Apr 7 13:28:08 2008 From: nbegeman at apple.com (Nate Begeman) Date: Mon, 7 Apr 2008 11:28:08 -0700 Subject: [llvm-commits] [llvm] r49000 - /llvm/trunk/lib/System/Unix/Process.inc In-Reply-To: References: <200803312219.m2VMJQVN002954@zion.cs.uiuc.edu> Message-ID: <443306D7-F5C2-4CF9-9FB0-A5206DA253F4@apple.com> OK, sounds like we need to include availability macros or something and do different things on 10.4 and 10.5. I'll put it in my queue. Thanks, Nate On Apr 6, 2008, at 11:43 PM, Christopher Lamb wrote: > Hi Nate, > > This broke turning off crash dumping on my system, the previous code > seemed to work fine. I'm running OS X 10.4.11. > -- > Chris > > On Mar 31, 2008, at 3:19 PM, Nate Begeman wrote: >> Author: sampo >> Date: Mon Mar 31 17:19:25 2008 >> New Revision: 49000 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=49000&view=rev >> Log: >> Actually disable crash reporting on Mac OS X, returning bugpoint to >> speedy >> crash miscompilations. >> >> Modified: >> llvm/trunk/lib/System/Unix/Process.inc >> >> Modified: llvm/trunk/lib/System/Unix/Process.inc >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Process.inc?rev=49000&r1=48999&r2=49000&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/System/Unix/Process.inc (original) >> +++ llvm/trunk/lib/System/Unix/Process.inc Mon Mar 31 17:19:25 2008 >> @@ -123,10 +123,6 @@ >> return getgid(); >> } >> >> -#ifdef HAVE_MACH_MACH_H >> -#include >> -#endif >> - >> // Some LLVM programs such as bugpoint produce core files as a >> normal part of >> // their operation. To prevent the disk from filling up, this >> function >> // does what's necessary to prevent their generation. >> @@ -138,25 +134,12 @@ >> #endif >> >> #ifdef HAVE_MACH_MACH_H >> - // Disable crash reporting on Mac OS/X. >> - >> - // get information about the original set of exception ports for >> the task >> - mach_msg_type_number_t Count = 0; >> - exception_mask_t OriginalMasks[EXC_TYPES_COUNT]; >> - exception_port_t OriginalPorts[EXC_TYPES_COUNT]; >> - exception_behavior_t OriginalBehaviors[EXC_TYPES_COUNT]; >> - thread_state_flavor_t OriginalFlavors[EXC_TYPES_COUNT]; >> - kern_return_t err = >> - task_get_exception_ports(mach_task_self(), EXC_MASK_ALL, >> OriginalMasks, >> - &Count, OriginalPorts, >> OriginalBehaviors, >> - OriginalFlavors); >> - if (err == KERN_SUCCESS) { >> - // replace each with MACH_PORT_NULL. >> - for (unsigned i = 0; i != Count; ++i) >> - task_set_exception_ports(mach_task_self(), OriginalMasks[i], >> - MACH_PORT_NULL, OriginalBehaviors[i], >> - OriginalFlavors[i]); >> - } >> + // Disable crash reporting on Mac OS X. >> + signal(SIGABRT, _exit); >> + signal(SIGILL, _exit); >> + signal(SIGFPE, _exit); >> + signal(SIGSEGV, _exit); >> + signal(SIGBUS, _exit); >> #endif >> } >> >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > -- > Christopher Lamb > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080407/00e94143/attachment.html From tonic at nondot.org Mon Apr 7 13:32:26 2008 From: tonic at nondot.org (Tanya Lattner) Date: Mon, 07 Apr 2008 18:32:26 -0000 Subject: [llvm-commits] [llvm] r49346 - in /llvm/trunk/docs: CommandGuide/index.html CommandGuide/llvm-upgrade.pod GettingStarted.html Message-ID: <200804071832.m37IWQ8Y002165@zion.cs.uiuc.edu> Author: tbrethou Date: Mon Apr 7 13:32:25 2008 New Revision: 49346 URL: http://llvm.org/viewvc/llvm-project?rev=49346&view=rev Log: Added note to getting started guide to use llvm-gcc4.2. Removed llvm-upgrade from documentations. Removed: llvm/trunk/docs/CommandGuide/llvm-upgrade.pod Modified: llvm/trunk/docs/CommandGuide/index.html llvm/trunk/docs/GettingStarted.html Modified: llvm/trunk/docs/CommandGuide/index.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/index.html?rev=49346&r1=49345&r2=49346&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/index.html (original) +++ llvm/trunk/docs/CommandGuide/index.html Mon Apr 7 13:32:25 2008 @@ -38,9 +38,6 @@
  • llvm-dis - disassemble a bytecode file into a human-readable .ll file
  • -
  • llvm-upgrade - - upgrade LLVM assembly from previous version
  • -
  • opt - run a series of LLVM-to-LLVM optimizations on a bytecode file
  • Removed: llvm/trunk/docs/CommandGuide/llvm-upgrade.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvm-upgrade.pod?rev=49345&view=auto ============================================================================== --- llvm/trunk/docs/CommandGuide/llvm-upgrade.pod (original) +++ llvm/trunk/docs/CommandGuide/llvm-upgrade.pod (removed) @@ -1,66 +0,0 @@ -=pod - -=head1 NAME - -llvm-upgrade - LLVM assembly upgrade tool - -=head1 SYNOPSIS - -B [I] [I] - -=head1 DESCRIPTION - -B is the LLVM assembly upgrade tool. It reads a file containing -human-readable LLVM assembly language, and upgrades that assembly to the current -version of LLVM. If the input is in the form currently accepted by LLVM, then -no upgrades are performed. - -The expected usage of this tool is as a filter, like this: - -=over - -B - -=back - -If F is omitted or is C<->, then B reads its input from -standard input. - -If an output file is not specified with the B<-o> option, then -B sends its output to standard output. - -=head1 OPTIONS - -=over - -=item B<-f> - -Force overwrite. Normally, B will refuse to overwrite an -output file that already exists. With this option, B -will overwrite the output file. - -=item B<--help> - -Print a summary of command line options. - -=item B<-o> F - -Specify the output file name. If F is C<->, then B -sends its output to standard output. - -=back - -=head1 EXIT STATUS - -If B succeeds, it will exit with 0. Otherwise, if an error -occurs, it will exit with a non-zero value. - -=head1 SEE ALSO - -L, L - -=head1 AUTHORS - -Maintained by the LLVM Team (L). - -=cut Modified: llvm/trunk/docs/GettingStarted.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/GettingStarted.html?rev=49346&r1=49345&r2=49346&view=diff ============================================================================== --- llvm/trunk/docs/GettingStarted.html (original) +++ llvm/trunk/docs/GettingStarted.html Mon Apr 7 13:32:25 2008 @@ -114,7 +114,7 @@
  • Read the documentation.
  • Read the documentation.
  • Remember that you were warned twice about reading the documentation.
  • -
  • Install the llvm-gcc4.0 (or llvm-gcc4.2) front end if you intend to compile C or C++: +
  • Install the llvm-gcc4.2 front end if you intend to compile C or C++:
    1. cd where-you-want-the-C-front-end-to-live
    2. gunzip --stdout llvm-gcc.platform.tar.gz | tar -xvf - From tonic at nondot.org Mon Apr 7 13:32:47 2008 From: tonic at nondot.org (Tanya Lattner) Date: Mon, 07 Apr 2008 18:32:47 -0000 Subject: [llvm-commits] [llvm] r49347 - /llvm/trunk/tools/llvm-upgrade/ Message-ID: <200804071832.m37IWlX8002189@zion.cs.uiuc.edu> Author: tbrethou Date: Mon Apr 7 13:32:47 2008 New Revision: 49347 URL: http://llvm.org/viewvc/llvm-project?rev=49347&view=rev Log: Remove llvm-upgrade. Removed: llvm/trunk/tools/llvm-upgrade/ From dalej at apple.com Mon Apr 7 13:37:41 2008 From: dalej at apple.com (Dale Johannesen) Date: Mon, 7 Apr 2008 11:37:41 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r49253 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp In-Reply-To: <200804070928.56685.baldrick@free.fr> References: <200804051841.m35IfRKR008765@zion.cs.uiuc.edu> <200804070928.56685.baldrick@free.fr> Message-ID: <7964E68C-9495-4FCE-B978-2EBD1B517DD9@apple.com> On Apr 7, 2008, at 12:28 AM, Duncan Sands wrote: > > I think we all agree about what the final effect of -funwind-tables > should > be. For me the only question is whether -funwind-tables should be > represented > in the IR or not, and if so how. My preference goes to an llc > option. This > has the disadvantage that you can't control the -funwind-tables > effect on a > per-function basis, but based on the Darwin use case you describe > that isn't > needed anyway (nor for Ada). > >> Now, how do we reconcile this with what Ada does, and what info do we >> put in the IR to make it happen? > > Ada is getting -funwind-tables because it uses -fnon-call-exceptions > (which > we don't currently support). I actually don't see why -fnon-call- > exceptions > would need -funwind-tables; it will I guess become clear one way or > another > when support is added for -fnon-call-exceptions. However Ada also > has a stack > traceback facility which uses the dwarf unwinder, and for that to > work it > presumably needs -funwind-tables. In short: Ada doesn't seem to > need anything > particularly special here, it's basically the same as Darwin. Ok, good. It's certainly possible to compile some files with -funwind-tables and others without. Unlike exceptions, however, I can't think of a case where this happens or is useful. Perhaps an llc flag is good enough; the default should be not to prune unwinding info, however, which is conservatively correct. I'll look at that. From baldrick at free.fr Mon Apr 7 14:07:47 2008 From: baldrick at free.fr (Duncan Sands) Date: Mon, 7 Apr 2008 21:07:47 +0200 Subject: [llvm-commits] [llvm-gcc-4.2] r49171 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp llvm-types.cpp In-Reply-To: References: <200804031727.m33HRR6h004565@zion.cs.uiuc.edu> Message-ID: <200804072107.47358.baldrick@free.fr> > I think a point I made earlier has gotten lost: it is not possible to > handle this without changing the linker. I've created PR2205 for this. Ciao, Duncan. From dpatel at apple.com Mon Apr 7 14:27:12 2008 From: dpatel at apple.com (Devang Patel) Date: Mon, 7 Apr 2008 12:27:12 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r49171 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp llvm-types.cpp In-Reply-To: <200804072107.47358.baldrick@free.fr> References: <200804031727.m33HRR6h004565@zion.cs.uiuc.edu> <200804072107.47358.baldrick@free.fr> Message-ID: <5939073A-D1EF-43B1-B57B-AB43293BE324@apple.com> On Apr 7, 2008, at 12:07 PM, Duncan Sands wrote: >> I think a point I made earlier has gotten lost: it is not possible >> to >> handle this without changing the linker. > > I've created PR2205 for this. What about the case when system linker (e.g. gnu ld or darwin ld on Mac OS X) ? - Devan From gohman at apple.com Mon Apr 7 14:35:22 2008 From: gohman at apple.com (Dan Gohman) Date: Mon, 07 Apr 2008 19:35:22 -0000 Subject: [llvm-commits] [llvm] r49348 - in /llvm/trunk: include/llvm/CodeGen/MachineInstr.h include/llvm/CodeGen/MachineInstrBuilder.h include/llvm/CodeGen/MachineMemOperand.h include/llvm/CodeGen/MemOperand.h include/llvm/CodeGen/ScheduleDAG.h include/llvm/CodeGen/SelectionDAG.h include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/MachineInstr.cpp lib/CodeGen/SelectionDAG/ScheduleDAG.cpp lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Target/PowerPC/PPCISelLowering.cpp lib/Target/X86/X86InstrInfo.cpp Message-ID: <200804071935.m37JZNGm004064@zion.cs.uiuc.edu> Author: djg Date: Mon Apr 7 14:35:22 2008 New Revision: 49348 URL: http://llvm.org/viewvc/llvm-project?rev=49348&view=rev Log: Rename MemOperand to MachineMemOperand. This was suggested by review feedback from Chris quite a while ago. No functionality change. Added: llvm/trunk/include/llvm/CodeGen/MachineMemOperand.h - copied, changed from r49345, llvm/trunk/include/llvm/CodeGen/MemOperand.h Removed: llvm/trunk/include/llvm/CodeGen/MemOperand.h Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h llvm/trunk/include/llvm/CodeGen/SelectionDAG.h llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h llvm/trunk/lib/CodeGen/MachineInstr.cpp llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstr.h?rev=49348&r1=49347&r2=49348&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineInstr.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineInstr.h Mon Apr 7 14:35:22 2008 @@ -17,7 +17,7 @@ #define LLVM_CODEGEN_MACHINEINSTR_H #include "llvm/CodeGen/MachineOperand.h" -#include "llvm/CodeGen/MemOperand.h" +#include "llvm/CodeGen/MachineMemOperand.h" namespace llvm { @@ -37,7 +37,7 @@ // are determined at construction time). std::vector Operands; // the operands - std::vector MemOperands; // information on memory references + std::vector MemOperands;// information on memory references MachineInstr *Prev, *Next; // Links for MBB's intrusive list. MachineBasicBlock *Parent; // Pointer to the owning basic block. @@ -100,11 +100,11 @@ /// Access to memory operands of the instruction unsigned getNumMemOperands() const { return MemOperands.size(); } - const MemOperand& getMemOperand(unsigned i) const { + const MachineMemOperand& getMemOperand(unsigned i) const { assert(i < getNumMemOperands() && "getMemOperand() out of range!"); return MemOperands[i]; } - MemOperand& getMemOperand(unsigned i) { + MachineMemOperand& getMemOperand(unsigned i) { assert(i < getNumMemOperands() && "getMemOperand() out of range!"); return MemOperands[i]; } @@ -268,9 +268,9 @@ /// void RemoveOperand(unsigned i); - /// addMemOperand - Add a MemOperand to the machine instruction, referencing - /// arbitrary storage. - void addMemOperand(const MemOperand &MO) { + /// addMemOperand - Add a MachineMemOperand to the machine instruction, + /// referencing arbitrary storage. + void addMemOperand(const MachineMemOperand &MO) { MemOperands.push_back(MO); } Modified: llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h?rev=49348&r1=49347&r2=49348&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h Mon Apr 7 14:35:22 2008 @@ -85,7 +85,7 @@ } /// addMemOperand - Add a memory operand to the machine instruction. - const MachineInstrBuilder &addMemOperand(const MemOperand &MO) const { + const MachineInstrBuilder &addMemOperand(const MachineMemOperand &MO) const { MI->addMemOperand(MO); return *this; } Copied: llvm/trunk/include/llvm/CodeGen/MachineMemOperand.h (from r49345, llvm/trunk/include/llvm/CodeGen/MemOperand.h) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineMemOperand.h?p2=llvm/trunk/include/llvm/CodeGen/MachineMemOperand.h&p1=llvm/trunk/include/llvm/CodeGen/MemOperand.h&r1=49345&r2=49348&rev=49348&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MemOperand.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineMemOperand.h Mon Apr 7 14:35:22 2008 @@ -1,4 +1,4 @@ -//===-- llvm/CodeGen/MemOperand.h - MemOperand class ------------*- C++ -*-===// +//==- llvm/CodeGen/MachineMemOperand.h - MachineMemOperand class -*- C++ -*-==// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file contains the declaration of the MemOperand class, which is a +// This file contains the declaration of the MachineMemOperand class, which is a // description of a memory reference. It is used to help track dependencies // in the backend. // @@ -21,14 +21,14 @@ class Value; //===----------------------------------------------------------------------===// -/// MemOperand - A description of a memory reference used in the backend. +/// MachineMemOperand - A description of a memory reference used in the backend. /// Instead of holding a StoreInst or LoadInst, this class holds the address /// Value of the reference along with a byte size and offset. This allows it /// to describe lowered loads and stores. Also, the special PseudoSourceValue /// objects can be used to represent loads and stores to memory locations /// that aren't explicit in the regular LLVM IR. /// -class MemOperand { +class MachineMemOperand { const Value *V; unsigned int Flags; int64_t Offset; @@ -46,10 +46,10 @@ MOVolatile = 4 }; - /// MemOperand - Construct an MemOperand object with the specified - /// address Value, flags, offset, size, and alignment. - MemOperand(const Value *v, unsigned int f, int64_t o, uint64_t s, - unsigned int a) + /// MachineMemOperand - Construct an MachineMemOperand object with the + /// specified address Value, flags, offset, size, and alignment. + MachineMemOperand(const Value *v, unsigned int f, int64_t o, uint64_t s, + unsigned int a) : V(v), Flags(f), Offset(o), Size(s), Alignment(a) {} /// getValue - Return the base address of the memory access. Removed: llvm/trunk/include/llvm/CodeGen/MemOperand.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MemOperand.h?rev=49347&view=auto ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MemOperand.h (original) +++ llvm/trunk/include/llvm/CodeGen/MemOperand.h (removed) @@ -1,83 +0,0 @@ -//===-- llvm/CodeGen/MemOperand.h - MemOperand class ------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains the declaration of the MemOperand class, which is a -// description of a memory reference. It is used to help track dependencies -// in the backend. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CODEGEN_MEMOPERAND_H -#define LLVM_CODEGEN_MEMOPERAND_H - -namespace llvm { - -class Value; - -//===----------------------------------------------------------------------===// -/// MemOperand - A description of a memory reference used in the backend. -/// Instead of holding a StoreInst or LoadInst, this class holds the address -/// Value of the reference along with a byte size and offset. This allows it -/// to describe lowered loads and stores. Also, the special PseudoSourceValue -/// objects can be used to represent loads and stores to memory locations -/// that aren't explicit in the regular LLVM IR. -/// -class MemOperand { - const Value *V; - unsigned int Flags; - int64_t Offset; - uint64_t Size; - unsigned int Alignment; - -public: - /// Flags values. These may be or'd together. - enum MemOperandFlags { - /// The memory access reads data. - MOLoad = 1, - /// The memory access writes data. - MOStore = 2, - /// The memory access is volatile. - MOVolatile = 4 - }; - - /// MemOperand - Construct an MemOperand object with the specified - /// address Value, flags, offset, size, and alignment. - MemOperand(const Value *v, unsigned int f, int64_t o, uint64_t s, - unsigned int a) - : V(v), Flags(f), Offset(o), Size(s), Alignment(a) {} - - /// getValue - Return the base address of the memory access. - /// Special values are PseudoSourceValue::FPRel, PseudoSourceValue::SPRel, - /// and the other PseudoSourceValue members which indicate references to - /// frame/stack pointer relative references and other special references. - const Value *getValue() const { return V; } - - /// getFlags - Return the raw flags of the source value, \see MemOperandFlags. - unsigned int getFlags() const { return Flags; } - - /// getOffset - For normal values, this is a byte offset added to the base - /// address. For PseudoSourceValue::FPRel values, this is the FrameIndex - /// number. - int64_t getOffset() const { return Offset; } - - /// getSize - Return the size in bytes of the memory reference. - uint64_t getSize() const { return Size; } - - /// getAlignment - Return the minimum known alignment in bytes of the - /// memory reference. - unsigned int getAlignment() const { return Alignment; } - - bool isLoad() const { return Flags & MOLoad; } - bool isStore() const { return Flags & MOStore; } - bool isVolatile() const { return Flags & MOVolatile; } -}; - -} // End llvm namespace - -#endif Modified: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h?rev=49348&r1=49347&r2=49348&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h Mon Apr 7 14:35:22 2008 @@ -365,7 +365,7 @@ const TargetInstrDesc *II, DenseMap &VRBaseMap); - void AddMemOperand(MachineInstr *MI, const MemOperand &MO); + void AddMemOperand(MachineInstr *MI, const MachineMemOperand &MO); void EmitCrossRCCopy(SUnit *SU, DenseMap &VRBaseMap); Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=49348&r1=49347&r2=49348&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Mon Apr 7 14:35:22 2008 @@ -401,7 +401,7 @@ // getMemOperand - Construct a node to track a memory reference // through the backend. - SDOperand getMemOperand(const MemOperand &MO); + SDOperand getMemOperand(const MachineMemOperand &MO); /// UpdateNodeOperands - *Mutate* the specified node in-place to have the /// specified operands. If the resultant node already exists in the DAG, Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=49348&r1=49347&r2=49348&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Mon Apr 7 14:35:22 2008 @@ -26,7 +26,7 @@ #include "llvm/ADT/APFloat.h" #include "llvm/ADT/APInt.h" #include "llvm/CodeGen/ValueTypes.h" -#include "llvm/CodeGen/MemOperand.h" +#include "llvm/CodeGen/MachineMemOperand.h" #include "llvm/Support/DataTypes.h" #include @@ -530,9 +530,9 @@ // make reference to a value in the LLVM IR. SRCVALUE, - // MEMOPERAND - This is a node that contains a MemOperand which records - // information about a memory reference. This is used to make AliasAnalysis - // queries from the backend. + // MEMOPERAND - This is a node that contains a MachineMemOperand which + // records information about a memory reference. This is used to make + // AliasAnalysis queries from the backend. MEMOPERAND, // PCMARKER - This corresponds to the pcmarker intrinsic. @@ -1645,7 +1645,7 @@ }; -/// MemOperandSDNode - An SDNode that holds a MemOperand. This is +/// MemOperandSDNode - An SDNode that holds a MachineMemOperand. This is /// used to represent a reference to memory after ISD::LOAD /// and ISD::STORE have been lowered. /// @@ -1653,13 +1653,13 @@ virtual void ANCHOR(); // Out-of-line virtual method to give class a home. protected: friend class SelectionDAG; - /// Create a MemOperand node - explicit MemOperandSDNode(const MemOperand &mo) + /// Create a MachineMemOperand node + explicit MemOperandSDNode(const MachineMemOperand &mo) : SDNode(ISD::MEMOPERAND, getSDVTList(MVT::Other)), MO(mo) {} public: - /// MO - The contained MemOperand. - const MemOperand MO; + /// MO - The contained MachineMemOperand. + const MachineMemOperand MO; static bool classof(const MemOperandSDNode *) { return true; } static bool classof(const SDNode *N) { @@ -1906,9 +1906,9 @@ /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store. bool isUnindexed() const { return AddrMode == ISD::UNINDEXED; } - /// getMemOperand - Return a MemOperand object describing the memory + /// getMemOperand - Return a MachineMemOperand object describing the memory /// reference performed by this load or store. - MemOperand getMemOperand() const; + MachineMemOperand getMemOperand() const; static bool classof(const LSBaseSDNode *N) { return true; } static bool classof(const SDNode *N) { Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=49348&r1=49347&r2=49348&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Mon Apr 7 14:35:22 2008 @@ -693,7 +693,7 @@ if (getNumMemOperands() > 0) { OS << ", Mem:"; for (unsigned i = 0; i < getNumMemOperands(); i++) { - const MemOperand &MRO = getMemOperand(i); + const MachineMemOperand &MRO = getMemOperand(i); const Value *V = MRO.getValue(); assert((MRO.isLoad() || MRO.isStore()) && Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp?rev=49348&r1=49347&r2=49348&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp Mon Apr 7 14:35:22 2008 @@ -369,7 +369,7 @@ unsigned ScheduleDAG::CountOperands(SDNode *Node) { unsigned N = ComputeMemOperandsEnd(Node); while (N && isa(Node->getOperand(N - 1).Val)) - --N; // Ignore MemOperand nodes + --N; // Ignore MEMOPERAND nodes return N; } @@ -656,7 +656,7 @@ } -void ScheduleDAG::AddMemOperand(MachineInstr *MI, const MemOperand &MO) { +void ScheduleDAG::AddMemOperand(MachineInstr *MI, const MachineMemOperand &MO) { MI->addMemOperand(MO); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=49348&r1=49347&r2=49348&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Mon Apr 7 14:35:22 2008 @@ -385,7 +385,7 @@ ID.AddPointer(cast(N)->getValue()); break; case ISD::MEMOPERAND: { - const MemOperand &MO = cast(N)->MO; + const MachineMemOperand &MO = cast(N)->MO; ID.AddPointer(MO.getValue()); ID.AddInteger(MO.getFlags()); ID.AddInteger(MO.getOffset()); @@ -1014,7 +1014,7 @@ return SDOperand(N, 0); } -SDOperand SelectionDAG::getMemOperand(const MemOperand &MO) { +SDOperand SelectionDAG::getMemOperand(const MachineMemOperand &MO) { const Value *v = MO.getValue(); assert((!v || isa(v->getType())) && "SrcValue is not a pointer?"); @@ -3635,24 +3635,25 @@ TheGlobal = const_cast(GA); } -/// getMemOperand - Return a MemOperand object describing the memory +/// getMemOperand - Return a MachineMemOperand object describing the memory /// reference performed by this load or store. -MemOperand LSBaseSDNode::getMemOperand() const { +MachineMemOperand LSBaseSDNode::getMemOperand() const { int Size = (MVT::getSizeInBits(getMemoryVT()) + 7) >> 3; int Flags = - getOpcode() == ISD::LOAD ? MemOperand::MOLoad : MemOperand::MOStore; - if (IsVolatile) Flags |= MemOperand::MOVolatile; + getOpcode() == ISD::LOAD ? MachineMemOperand::MOLoad : + MachineMemOperand::MOStore; + if (IsVolatile) Flags |= MachineMemOperand::MOVolatile; // Check if the load references a frame index, and does not have // an SV attached. const FrameIndexSDNode *FI = dyn_cast(getBasePtr().Val); if (!getSrcValue() && FI) - return MemOperand(PseudoSourceValue::getFixedStack(), Flags, - FI->getIndex(), Size, Alignment); + return MachineMemOperand(PseudoSourceValue::getFixedStack(), Flags, + FI->getIndex(), Size, Alignment); else - return MemOperand(getSrcValue(), Flags, - getSrcValueOffset(), Size, Alignment); + return MachineMemOperand(getSrcValue(), Flags, + getSrcValueOffset(), Size, Alignment); } /// Profile - Gather unique data for the node. Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=49348&r1=49347&r2=49348&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Mon Apr 7 14:35:22 2008 @@ -2500,8 +2500,8 @@ Op.getOperand(0)); // STD the extended value into the stack slot. - MemOperand MO(PseudoSourceValue::getFixedStack(), - MemOperand::MOStore, FrameIdx, 8, 8); + MachineMemOperand MO(PseudoSourceValue::getFixedStack(), + MachineMemOperand::MOStore, FrameIdx, 8, 8); SDOperand Store = DAG.getNode(PPCISD::STD_32, MVT::Other, DAG.getEntryNode(), Ext64, FIdx, DAG.getMemOperand(MO)); Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=49348&r1=49347&r2=49348&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Mon Apr 7 14:35:22 2008 @@ -1930,7 +1930,7 @@ unsigned Alignment = 0; for (unsigned i = 0, e = LoadMI->getNumMemOperands(); i != e; ++i) { - const MemOperand &MRO = LoadMI->getMemOperand(i); + const MachineMemOperand &MRO = LoadMI->getMemOperand(i); unsigned Align = MRO.getAlignment(); if (Align > Alignment) Alignment = Align; From clattner at apple.com Mon Apr 7 15:39:23 2008 From: clattner at apple.com (Chris Lattner) Date: Mon, 7 Apr 2008 13:39:23 -0700 Subject: [llvm-commits] [llvm] r49000 - /llvm/trunk/lib/System/Unix/Process.inc In-Reply-To: <443306D7-F5C2-4CF9-9FB0-A5206DA253F4@apple.com> References: <200803312219.m2VMJQVN002954@zion.cs.uiuc.edu> <443306D7-F5C2-4CF9-9FB0-A5206DA253F4@apple.com> Message-ID: <978F81BB-D727-4E50-B9EC-A77450DC1739@apple.com> On Apr 7, 2008, at 11:28 AM, Nate Begeman wrote: > OK, sounds like we need to include availability macros or something > and do different things on 10.4 and 10.5. > > I'll put it in my queue. It shouldn't hurt to do both things, would it? Availability macros won't work, we'd need dynamic detection of the OS. -Chris From sam at bishop.dhs.org Mon Apr 7 16:36:46 2008 From: sam at bishop.dhs.org (Sam Bishop) Date: Mon, 07 Apr 2008 21:36:46 -0000 Subject: [llvm-commits] [llvm] r49350 - /llvm/trunk/include/llvm/Bitcode/Deserialize.h Message-ID: <200804072136.m37Lak57007679@zion.cs.uiuc.edu> Author: sbishop Date: Mon Apr 7 16:36:46 2008 New Revision: 49350 URL: http://llvm.org/viewvc/llvm-project?rev=49350&view=rev Log: Added support for Create() calls that take an argument besides the deserializer. Modified: llvm/trunk/include/llvm/Bitcode/Deserialize.h Modified: llvm/trunk/include/llvm/Bitcode/Deserialize.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/Deserialize.h?rev=49350&r1=49349&r2=49350&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/Deserialize.h (original) +++ llvm/trunk/include/llvm/Bitcode/Deserialize.h Mon Apr 7 16:36:46 2008 @@ -172,7 +172,22 @@ return x; } - + + template + inline T* ReadOwnedPtr(Arg1& arg1, bool AutoRegister = true) { + SerializedPtrID PtrID = ReadPtrID(); + + if (!PtrID) + return NULL; + + T* x = SerializeTrait::Create(*this, arg1); + + if (AutoRegister) + RegisterPtr(PtrID,x); + + return x; + } + template inline void ReadOwnedPtr(T*& Ptr, bool AutoRegister = true) { Ptr = ReadOwnedPtr(AutoRegister); @@ -192,6 +207,20 @@ if (ID2 && A2) RegisterPtr(ID2,P2); } + template + void BatchReadOwnedPtrs(T1*& P1, T2*& P2, Arg1& arg1, + bool A1=true, bool A2=true) { + + SerializedPtrID ID1 = ReadPtrID(); + SerializedPtrID ID2 = ReadPtrID(); + + P1 = (ID1) ? SerializeTrait::Create(*this, arg1) : NULL; + if (ID1 && A1) RegisterPtr(ID1,P1); + + P2 = (ID2) ? SerializeTrait::Create(*this, arg1) : NULL; + if (ID2 && A2) RegisterPtr(ID2,P2); + } + template void BatchReadOwnedPtrs(T1*& P1, T2*& P2, T3*& P3, bool A1=true, bool A2=true, bool A3=true) { @@ -209,7 +238,25 @@ P3 = (ID3) ? SerializeTrait::Create(*this) : NULL; if (ID3 && A3) RegisterPtr(ID3,P3); } - + + template + void BatchReadOwnedPtrs(T1*& P1, T2*& P2, T3*& P3, Arg1& arg1, + bool A1=true, bool A2=true, bool A3=true) { + + SerializedPtrID ID1 = ReadPtrID(); + SerializedPtrID ID2 = ReadPtrID(); + SerializedPtrID ID3 = ReadPtrID(); + + P1 = (ID1) ? SerializeTrait::Create(*this, arg1) : NULL; + if (ID1 && A1) RegisterPtr(ID1,P1); + + P2 = (ID2) ? SerializeTrait::Create(*this, arg1) : NULL; + if (ID2 && A2) RegisterPtr(ID2,P2); + + P3 = (ID3) ? SerializeTrait::Create(*this, arg1) : NULL; + if (ID3 && A3) RegisterPtr(ID3,P3); + } + template void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs, bool AutoRegister=true) { llvm::SmallVector BatchIDVec; @@ -229,6 +276,27 @@ } } + template + void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs, Arg1& arg1, + bool AutoRegister=true) { + + llvm::SmallVector BatchIDVec; + + for (unsigned i = 0; i < NumPtrs; ++i) + BatchIDVec.push_back(ReadPtrID()); + + for (unsigned i = 0; i < NumPtrs; ++i) { + SerializedPtrID& PtrID = BatchIDVec[i]; + + T* p = PtrID ? SerializeTrait::Create(*this, arg1) : NULL; + + if (PtrID && AutoRegister) + RegisterPtr(PtrID,p); + + Ptrs[i] = p; + } + } + template void BatchReadOwnedPtrs(unsigned NumT1Ptrs, T1** Ptrs, T2*& P2, bool A1=true, bool A2=true) { @@ -255,6 +323,32 @@ if (ID2 && A2) RegisterPtr(ID2,P2); } + template + void BatchReadOwnedPtrs(unsigned NumT1Ptrs, T1** Ptrs, T2*& P2, Arg1& arg1, + bool A1=true, bool A2=true) { + + llvm::SmallVector BatchIDVec; + + for (unsigned i = 0; i < NumT1Ptrs; ++i) + BatchIDVec.push_back(ReadPtrID()); + + SerializedPtrID ID2 = ReadPtrID(); + + for (unsigned i = 0; i < NumT1Ptrs; ++i) { + SerializedPtrID& PtrID = BatchIDVec[i]; + + T1* p = PtrID ? SerializeTrait::Create(*this, arg1) : NULL; + + if (PtrID && A1) + RegisterPtr(PtrID,p); + + Ptrs[i] = p; + } + + P2 = (ID2) ? SerializeTrait::Create(*this, arg1) : NULL; + if (ID2 && A2) RegisterPtr(ID2,P2); + } + template void BatchReadOwnedPtrs(unsigned NumT1Ptrs, T1** Ptrs, T2*& P2, T3*& P3, @@ -285,7 +379,38 @@ P3 = (ID3) ? SerializeTrait::Create(*this) : NULL; if (ID3 && A3) RegisterPtr(ID3,P3); } - + + template + void BatchReadOwnedPtrs(unsigned NumT1Ptrs, T1** Ptrs, + T2*& P2, T3*& P3, Arg1& arg1, + bool A1=true, bool A2=true, bool A3=true) { + + llvm::SmallVector BatchIDVec; + + for (unsigned i = 0; i < NumT1Ptrs; ++i) + BatchIDVec.push_back(ReadPtrID()); + + SerializedPtrID ID2 = ReadPtrID(); + SerializedPtrID ID3 = ReadPtrID(); + + for (unsigned i = 0; i < NumT1Ptrs; ++i) { + SerializedPtrID& PtrID = BatchIDVec[i]; + + T1* p = PtrID ? SerializeTrait::Create(*this, arg1) : NULL; + + if (PtrID && A1) + RegisterPtr(PtrID,p); + + Ptrs[i] = p; + } + + P2 = (ID2) ? SerializeTrait::Create(*this, arg1) : NULL; + if (ID2 && A2) RegisterPtr(ID2,P2); + + P3 = (ID3) ? SerializeTrait::Create(*this, arg1) : NULL; + if (ID3 && A3) RegisterPtr(ID3,P3); + } + template void ReadPtr(T*& PtrRef, bool AllowBackpatch = true) { ReadUIntPtr(reinterpret_cast(PtrRef), AllowBackpatch); From ggreif at gmail.com Mon Apr 7 16:45:54 2008 From: ggreif at gmail.com (Gabor Greif) Date: Mon, 07 Apr 2008 21:45:54 -0000 Subject: [llvm-commits] [llvm] r49351 - /llvm/branches/ggreif/README Message-ID: <200804072145.m37LjsVJ007919@zion.cs.uiuc.edu> Author: ggreif Date: Mon Apr 7 16:45:54 2008 New Revision: 49351 URL: http://llvm.org/viewvc/llvm-project?rev=49351&view=rev Log: some updates Modified: llvm/branches/ggreif/README Modified: llvm/branches/ggreif/README URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/README?rev=49351&r1=49350&r2=49351&view=diff ============================================================================== --- llvm/branches/ggreif/README (original) +++ llvm/branches/ggreif/README Mon Apr 7 16:45:54 2008 @@ -8,7 +8,7 @@ 1) Parallel "make check". Modelled after the successful clang "make test -jX" experiment, I am now bold enough to sink my teeth into the LLVM test suite. -I have a prototype implementation, along the same lines, ready. +I have a functional implementation, along the same lines, ready. BRANCH NAME: parallelized-test USAGE: @@ -31,11 +31,20 @@ collateral improvements too. This project is in its very early implementation phase. +WHY ON A BRANCH: +Contrary to the accepted development model of LLVM, which +predominantly uses the trunk for ongoing (even disruptive) +development, I am more comfortable with developing on a branch, +because I tend to perform many small changes on different +machines and cannot guarantee compilability when checking in. + SYNOPSIS: -There will be six waves until this project can be closed. A +There will be seven waves until this project can be closed. A wave is defined as a point in the implementation that is consistent, -correct and mergable to trunk. Each wave ends with a code review -and the necessary rework (which may require a new review, etc.). +correct and mergable to trunk. Each wave starts with some general +discussion of how I should proceed, and what the exact scope of the +wave should be. Each wave ends with a code review and +the necessary rework (which may require a new review, etc.). Whether a merge actually takes place will be decided on a case-by-case basis. @@ -53,7 +62,10 @@ WAVE5: Stylistic and performance tweaks. Valgrind testing. -WAVE6: Measurements, finishing touches. +WAVE6: Realizing additional savings. Several space vs. time tradeoffs to + be balanced. May involve tweaking some basic interfaces. + +WAVE7: Measurements, finishing touches. BRANCH NAME: use-diet USAGE: From kremenek at apple.com Mon Apr 7 16:53:57 2008 From: kremenek at apple.com (Ted Kremenek) Date: Mon, 07 Apr 2008 21:53:57 -0000 Subject: [llvm-commits] [llvm] r49352 - in /llvm/trunk: include/llvm/System/Path.h lib/System/Path.cpp lib/System/Unix/Path.inc lib/System/Win32/Path.inc Message-ID: <200804072153.m37LrvqV008132@zion.cs.uiuc.edu> Author: kremenek Date: Mon Apr 7 16:53:57 2008 New Revision: 49352 URL: http://llvm.org/viewvc/llvm-project?rev=49352&view=rev Log: Added method Path::getDirname(). Modified: llvm/trunk/include/llvm/System/Path.h llvm/trunk/lib/System/Path.cpp llvm/trunk/lib/System/Unix/Path.inc llvm/trunk/lib/System/Win32/Path.inc Modified: llvm/trunk/include/llvm/System/Path.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Path.h?rev=49352&r1=49351&r2=49352&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Path.h (original) +++ llvm/trunk/include/llvm/System/Path.h Mon Apr 7 16:53:57 2008 @@ -269,6 +269,10 @@ /// @returns std::string containing the basename of the path /// @brief Get the base name of the path std::string getBasename() const; + + /// This function strips off the suffix of the path beginning with the + /// path separator ('/' on Unix, '\' on Windows) and returns the result. + std::string getDirname() const; /// This function strips off the path and basename(up to and /// including the last dot) of the file or directory name and @@ -567,11 +571,19 @@ /// MemoryBuffer::getFile instead. static void UnMapFilePages(const char *Base, uint64_t FileSize); + + /// @} + /// @name Internal methods. + /// @{ + protected: + std::string getDirnameCharSep(char Sep) const; + /// @} /// @name Data /// @{ protected: mutable std::string path; ///< Storage for the path name. + /// @} }; Modified: llvm/trunk/lib/System/Path.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Path.cpp?rev=49352&r1=49351&r2=49352&view=diff ============================================================================== --- llvm/trunk/lib/System/Path.cpp (original) +++ llvm/trunk/lib/System/Path.cpp Mon Apr 7 16:53:57 2008 @@ -196,6 +196,45 @@ Paths.push_back(tmpPath); } +std::string Path::getDirnameCharSep(char Sep) const { + + if (path.empty()) + return "."; + + // If the path is all slashes, return a single slash. + // Otherwise, remove all trailing slashes. + + signed pos = path.size() - 1; + + while (pos >= 0 && path[pos] == Sep) + --pos; + + if (pos < 0) + return path[0] == Sep ? std::string(1, Sep) : std::string("."); + + // Any slashes left? + signed i = 0; + + while (i < pos && path[i] != Sep) + ++i; + + if (i == pos) // No slashes? Return "." + return "."; + + // There is at least one slash left. Remove all trailing non-slashes. + while (pos >= 0 && path[pos] != Sep) + --pos; + + // Remove any trailing slashes. + while (pos >= 0 && path[pos] == Sep) + --pos; + + if (pos < 0) + return path[0] == Sep ? std::string(1, Sep) : std::string("."); + + return path.substr(0, pos+1); +} + // Include the truly platform-specific parts of this class. #if defined(LLVM_ON_UNIX) #include "Unix/Path.inc" Modified: llvm/trunk/lib/System/Unix/Path.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Path.inc?rev=49352&r1=49351&r2=49352&view=diff ============================================================================== --- llvm/trunk/lib/System/Unix/Path.inc (original) +++ llvm/trunk/lib/System/Unix/Path.inc Mon Apr 7 16:53:57 2008 @@ -277,16 +277,18 @@ } +std::string Path::getDirname() const { return getDirnameCharSep('/'); } + std::string Path::getBasename() const { // Find the last slash - size_t slash = path.rfind('/'); + std::string::size_type slash = path.rfind('/'); if (slash == std::string::npos) slash = 0; else slash++; - size_t dot = path.rfind('.'); + std::string::size_type dot = path.rfind('.'); if (dot == std::string::npos || dot < slash) return path.substr(slash); else Modified: llvm/trunk/lib/System/Win32/Path.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Path.inc?rev=49352&r1=49351&r2=49352&view=diff ============================================================================== --- llvm/trunk/lib/System/Win32/Path.inc (original) +++ llvm/trunk/lib/System/Win32/Path.inc Mon Apr 7 16:53:57 2008 @@ -229,6 +229,8 @@ return len > 0 && path[len-1] == '/'; } +std::string Path::getDirname() const { return getDirnameCharSep('\\'); } + std::string Path::getBasename() const { // Find the last slash From kremenek at apple.com Mon Apr 7 17:01:32 2008 From: kremenek at apple.com (Ted Kremenek) Date: Mon, 07 Apr 2008 22:01:32 -0000 Subject: [llvm-commits] [llvm] r49354 - in /llvm/trunk: include/llvm/System/Path.h lib/System/Path.cpp lib/System/Unix/Path.inc lib/System/Win32/Path.inc Message-ID: <200804072201.m37M1Wdk008429@zion.cs.uiuc.edu> Author: kremenek Date: Mon Apr 7 17:01:32 2008 New Revision: 49354 URL: http://llvm.org/viewvc/llvm-project?rev=49354&view=rev Log: Make getDirnameSep a static method (not part of Path's interface). Modified: llvm/trunk/include/llvm/System/Path.h llvm/trunk/lib/System/Path.cpp llvm/trunk/lib/System/Unix/Path.inc llvm/trunk/lib/System/Win32/Path.inc Modified: llvm/trunk/include/llvm/System/Path.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Path.h?rev=49354&r1=49353&r2=49354&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Path.h (original) +++ llvm/trunk/include/llvm/System/Path.h Mon Apr 7 17:01:32 2008 @@ -571,13 +571,6 @@ /// MemoryBuffer::getFile instead. static void UnMapFilePages(const char *Base, uint64_t FileSize); - - /// @} - /// @name Internal methods. - /// @{ - protected: - std::string getDirnameCharSep(char Sep) const; - /// @} /// @name Data /// @{ Modified: llvm/trunk/lib/System/Path.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Path.cpp?rev=49354&r1=49353&r2=49354&view=diff ============================================================================== --- llvm/trunk/lib/System/Path.cpp (original) +++ llvm/trunk/lib/System/Path.cpp Mon Apr 7 17:01:32 2008 @@ -196,7 +196,7 @@ Paths.push_back(tmpPath); } -std::string Path::getDirnameCharSep(char Sep) const { +static std::string getDirnameCharSep(const std::string& path, char Sep) { if (path.empty()) return "."; Modified: llvm/trunk/lib/System/Unix/Path.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Path.inc?rev=49354&r1=49353&r2=49354&view=diff ============================================================================== --- llvm/trunk/lib/System/Unix/Path.inc (original) +++ llvm/trunk/lib/System/Unix/Path.inc Mon Apr 7 17:01:32 2008 @@ -277,7 +277,9 @@ } -std::string Path::getDirname() const { return getDirnameCharSep('/'); } +std::string Path::getDirname() const { + return getDirnameCharSep(path, '/'); +} std::string Path::getBasename() const { Modified: llvm/trunk/lib/System/Win32/Path.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Path.inc?rev=49354&r1=49353&r2=49354&view=diff ============================================================================== --- llvm/trunk/lib/System/Win32/Path.inc (original) +++ llvm/trunk/lib/System/Win32/Path.inc Mon Apr 7 17:01:32 2008 @@ -229,7 +229,9 @@ return len > 0 && path[len-1] == '/'; } -std::string Path::getDirname() const { return getDirnameCharSep('\\'); } +std::string Path::getDirname() const { + return getDirnameCharSep(path, '\\'); +} std::string Path::getBasename() const { From arnold.schwaighofer at gmail.com Mon Apr 7 17:17:11 2008 From: arnold.schwaighofer at gmail.com (Arnold Schwaighofer) Date: Tue, 8 Apr 2008 00:17:11 +0200 Subject: [llvm-commits] PATCH: Tailcallopt x86 byval argument handling Message-ID: Hi Evan (and everyone else who wants to bash this patch :), this patch corrects handling of byval arguments for tailcall optimized x86-64 (and x86) calls so that they work (... at least for my test cases). Should fix the following problems: Problem 1: when i introduced the optimized handling of arguments for tail called functions (not always moving them to a spill slot - actually moving to the destination of the arg if the call were to be a normal function call - before storing them at their 'tailcall' position but using virtual registers) i did not handle byval arguments correctly. Problem 2: on x86-64 after the arguments of the tail called function are moved to their registers (which include ESI/RSI etc), tail call optimization performs byval lowering which causes xSI,xDI, xCX registers to be overwritten. this is handled in this patch by moving the arguments to virtual registers first and after the byval lowering the arguments are moved from those virtual registers back to RSI/RDI/RCX. Okay to commit? regards arnold -------------- next part -------------- A non-text attachment was scrubbed... Name: x86-byval.patch Type: text/x-patch Size: 12729 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080408/40d4ba89/attachment.bin From natebegeman at mac.com Mon Apr 7 18:45:35 2008 From: natebegeman at mac.com (Nate Begeman) Date: Mon, 7 Apr 2008 16:45:35 -0700 Subject: [llvm-commits] [llvm] r49000 - /llvm/trunk/lib/System/Unix/Process.inc In-Reply-To: <978F81BB-D727-4E50-B9EC-A77450DC1739@apple.com> References: <200803312219.m2VMJQVN002954@zion.cs.uiuc.edu> <443306D7-F5C2-4CF9-9FB0-A5206DA253F4@apple.com> <978F81BB-D727-4E50-B9EC-A77450DC1739@apple.com> Message-ID: <616807CF-D3F2-4B68-8341-3A9DA233F579@mac.com> On Apr 7, 2008, at 1:39 PM, Chris Lattner wrote: > > On Apr 7, 2008, at 11:28 AM, Nate Begeman wrote: > >> OK, sounds like we need to include availability macros or something >> and do different things on 10.4 and 10.5. >> >> I'll put it in my queue. > > It shouldn't hurt to do both things, would it? Availability macros > won't work, we'd need dynamic detection of the OS. No, it shouldn't; I followed up with Chris Lamb off list afterwards asking him if he could try with both the null-ing out of the exception ports and the signal handlers. Nate From isanbard at gmail.com Mon Apr 7 19:10:14 2008 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 08 Apr 2008 00:10:14 -0000 Subject: [llvm-commits] [llvm] r49360 - in /llvm/tags/Apple/llvmCore-2030-03: ./ include/llvm/CodeGen/ lib/CodeGen/SelectionDAG/ lib/Target/PowerPC/ lib/Target/X86/ Message-ID: <200804080010.m380AFRo012338@zion.cs.uiuc.edu> Author: void Date: Mon Apr 7 19:10:14 2008 New Revision: 49360 URL: http://llvm.org/viewvc/llvm-project?rev=49360&view=rev Log: This is llvmCore-2030-02 with SSE4 enabled. Added: llvm/tags/Apple/llvmCore-2030-03/ - copied from r48928, llvm/tags/Apple/llvmCore-2030/ Modified: llvm/tags/Apple/llvmCore-2030-03/include/llvm/CodeGen/ScheduleDAG.h llvm/tags/Apple/llvmCore-2030-03/include/llvm/CodeGen/SelectionDAGNodes.h llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/DAGCombiner.cpp llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/LegalizeTypes.h llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/tags/Apple/llvmCore-2030-03/lib/Target/PowerPC/PPCISelLowering.cpp llvm/tags/Apple/llvmCore-2030-03/lib/Target/X86/X86CodeEmitter.cpp llvm/tags/Apple/llvmCore-2030-03/lib/Target/X86/X86ISelDAGToDAG.cpp llvm/tags/Apple/llvmCore-2030-03/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/tags/Apple/llvmCore-2030-03/include/llvm/CodeGen/ScheduleDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/tags/Apple/llvmCore-2030-03/include/llvm/CodeGen/ScheduleDAG.h?rev=49360&r1=48928&r2=49360&view=diff ============================================================================== --- llvm/tags/Apple/llvmCore-2030-03/include/llvm/CodeGen/ScheduleDAG.h (original) +++ llvm/tags/Apple/llvmCore-2030-03/include/llvm/CodeGen/ScheduleDAG.h Mon Apr 7 19:10:14 2008 @@ -331,7 +331,7 @@ /// register number for the results of the node. /// void EmitNode(SDNode *Node, unsigned InstNo, - DenseMap &VRBaseMap); + DenseMap &VRBaseMap); /// EmitNoop - Emit a noop instruction. /// @@ -343,11 +343,11 @@ /// implicit physical register output. void EmitCopyFromReg(SDNode *Node, unsigned ResNo, unsigned InstNo, unsigned SrcReg, - DenseMap &VRBaseMap); + DenseMap &VRBaseMap); void CreateVirtualRegisters(SDNode *Node, MachineInstr *MI, const TargetInstrDesc &II, - DenseMap &VRBaseMap); + DenseMap &VRBaseMap); /// EmitLiveInCopy - Emit a copy for a live in physical register. If the /// physical register has only a single copy use, then coalesced the copy @@ -375,11 +375,11 @@ /// EmitSubregNode - Generate machine code for subreg nodes. /// void EmitSubregNode(SDNode *Node, - DenseMap &VRBaseMap); + DenseMap &VRBaseMap); void AddOperand(MachineInstr *MI, SDOperand Op, unsigned IIOpNum, const TargetInstrDesc *II, - DenseMap &VRBaseMap); + DenseMap &VRBaseMap); void AddMemOperand(MachineInstr *MI, const MemOperand &MO); }; Modified: llvm/tags/Apple/llvmCore-2030-03/include/llvm/CodeGen/SelectionDAGNodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/tags/Apple/llvmCore-2030-03/include/llvm/CodeGen/SelectionDAGNodes.h?rev=49360&r1=48928&r2=49360&view=diff ============================================================================== --- llvm/tags/Apple/llvmCore-2030-03/include/llvm/CodeGen/SelectionDAGNodes.h (original) +++ llvm/tags/Apple/llvmCore-2030-03/include/llvm/CodeGen/SelectionDAGNodes.h Mon Apr 7 19:10:14 2008 @@ -779,7 +779,7 @@ //===----------------------------------------------------------------------===// -/// SDOperandImpl - Unlike LLVM values, Selection DAG nodes may return multiple +/// SDOperand - Unlike LLVM values, Selection DAG nodes may return multiple /// values as the result of a computation. Many nodes return multiple values, /// from loads (which define a token and a return value) to ADDC (which returns /// a result and a carry value), to calls (which may return an arbitrary number @@ -787,28 +787,28 @@ /// /// As such, each use of a SelectionDAG computation must indicate the node that /// computes it as well as which return value to use from that node. This pair -/// of information is represented with the SDOperandImpl value type. +/// of information is represented with the SDOperand value type. /// -class SDOperandImpl { +class SDOperand { public: SDNode *Val; // The node defining the value we are using. unsigned ResNo; // Which return value of the node we are using. - SDOperandImpl() : Val(0), ResNo(0) {} - SDOperandImpl(SDNode *val, unsigned resno) : Val(val), ResNo(resno) {} + SDOperand() : Val(0), ResNo(0) {} + SDOperand(SDNode *val, unsigned resno) : Val(val), ResNo(resno) {} - bool operator==(const SDOperandImpl &O) const { + bool operator==(const SDOperand &O) const { return Val == O.Val && ResNo == O.ResNo; } - bool operator!=(const SDOperandImpl &O) const { + bool operator!=(const SDOperand &O) const { return !operator==(O); } - bool operator<(const SDOperandImpl &O) const { + bool operator<(const SDOperand &O) const { return Val < O.Val || (Val == O.Val && ResNo < O.ResNo); } - SDOperandImpl getValue(unsigned R) const { - return SDOperandImpl(Val, R); + SDOperand getValue(unsigned R) const { + return SDOperand(Val, R); } // isOperandOf - Return true if this node is an operand of N. @@ -827,7 +827,7 @@ // Forwarding methods - These forward to the corresponding methods in SDNode. inline unsigned getOpcode() const; inline unsigned getNumOperands() const; - inline const SDOperandImpl &getOperand(unsigned i) const; + inline const SDOperand &getOperand(unsigned i) const; inline uint64_t getConstantOperandVal(unsigned i) const; inline bool isTargetOpcode() const; inline unsigned getTargetOpcode() const; @@ -838,8 +838,7 @@ /// side-effecting instructions. In practice, this looks through token /// factors and non-volatile loads. In order to remain efficient, this only /// looks a couple of nodes in, it does not do an exhaustive search. - bool reachesChainWithoutSideEffects(SDOperandImpl Dest, - unsigned Depth = 2) const; + bool reachesChainWithoutSideEffects(SDOperand Dest, unsigned Depth = 2) const; /// hasOneUse - Return true if there is exactly one operation using this /// result value of the defining operator. @@ -851,18 +850,14 @@ }; -template<> struct DenseMapInfo { - static inline SDOperandImpl getEmptyKey() { - return SDOperandImpl((SDNode*)-1, -1U); - } - static inline SDOperandImpl getTombstoneKey() { - return SDOperandImpl((SDNode*)-1, 0); - } - static unsigned getHashValue(const SDOperandImpl &Val) { +template<> struct DenseMapInfo { + static inline SDOperand getEmptyKey() { return SDOperand((SDNode*)-1, -1U); } + static inline SDOperand getTombstoneKey() { return SDOperand((SDNode*)-1, 0);} + static unsigned getHashValue(const SDOperand &Val) { return ((unsigned)((uintptr_t)Val.Val >> 4) ^ (unsigned)((uintptr_t)Val.Val >> 9)) + Val.ResNo; } - static bool isEqual(const SDOperandImpl &LHS, const SDOperandImpl &RHS) { + static bool isEqual(const SDOperand &LHS, const SDOperand &RHS) { return LHS == RHS; } static bool isPod() { return true; } @@ -870,88 +865,6 @@ /// simplify_type specializations - Allow casting operators to work directly on /// SDOperands as if they were SDNode*'s. -template<> struct simplify_type { - typedef SDNode* SimpleType; - static SimpleType getSimplifiedValue(const SDOperandImpl &Val) { - return static_cast(Val.Val); - } -}; -template<> struct simplify_type { - typedef SDNode* SimpleType; - static SimpleType getSimplifiedValue(const SDOperandImpl &Val) { - return static_cast(Val.Val); - } -}; - -/// SDOperand - Represents a use of the SDNode referred by -/// the SDOperandImpl. -class SDOperand: public SDOperandImpl { - /// parent - Parent node of this operand. - SDNode *parent; - /// Prev, next - Pointers to the uses list of the SDNode referred by - /// this operand. - SDOperand **Prev, *Next; -public: - friend class SDNode; - SDOperand(): SDOperandImpl(), parent(NULL), Prev(NULL), Next(NULL) {} - - SDOperand(SDNode *val, unsigned resno) : - SDOperandImpl(val,resno), parent(NULL), Prev(NULL), Next(NULL) {} - - SDOperand(const SDOperandImpl& Op): SDOperandImpl(Op),parent(NULL), - Prev(NULL), Next(NULL) { - } - - SDOperand& operator= (SDOperandImpl& Op) { - *(SDOperandImpl*)this = Op; - Next = NULL; - Prev = NULL; - return *this; - } - - SDOperand& operator= (const SDOperandImpl& Op) { - *(SDOperandImpl*)this = Op; - Next = NULL; - Prev = NULL; - return *this; - } - - SDOperand& operator= (SDOperand& Op) { - *(SDOperandImpl*)this = Op; - Next = NULL; - Prev = NULL; - return *this; - } - - SDOperand& operator= (const SDOperand& Op) { - *(SDOperandImpl*)this = Op; - Next = NULL; - Prev = NULL; - return *this; - } - - SDOperand * getNext() { return Next; } - - SDNode *getUser() { return parent; } - void setUser(SDNode *p) { parent = p; } - -protected: - void addToList(SDOperand **List) { - Next = *List; - if (Next) Next->Prev = &Next; - Prev = List; - *List = this; - } - - void removeFromList() { - *Prev = Next; - if (Next) Next->Prev = Prev; - } -}; - - -/// simplify_type specializations - Allow casting operators to work directly on -/// SDOperands as if they were SDNode*'s. template<> struct simplify_type { typedef SDNode* SimpleType; static SimpleType getSimplifiedValue(const SDOperand &Val) { @@ -969,7 +882,6 @@ /// SDNode - Represents one node in the SelectionDAG. /// class SDNode : public FoldingSetNode { -private: /// NodeType - The operation that this node performs. /// unsigned short NodeType; @@ -997,15 +909,10 @@ SDNode *Prev, *Next; friend struct ilist_traits; - /// UsesSize - The size of the uses list. - unsigned UsesSize; - - /// Uses - List of uses for this SDNode. - SDOperand *Uses; - - /// addUse - add SDOperand to the list of uses. - void addUse(SDOperand &U) { U.addToList(&Uses); } - + /// Uses - These are all of the SDNode's that use a value produced by this + /// node. + SmallVector Uses; + // Out-of-line virtual method to give class a home. virtual void ANCHOR(); public: @@ -1024,9 +931,9 @@ return NodeType - ISD::BUILTIN_OP_END; } - size_t use_size() const { return UsesSize; } - bool use_empty() const { return Uses == NULL; } - bool hasOneUse() const { return use_size() == 1; } + size_t use_size() const { return Uses.size(); } + bool use_empty() const { return Uses.empty(); } + bool hasOneUse() const { return Uses.size() == 1; } /// getNodeId - Return the unique node id. /// @@ -1035,75 +942,9 @@ /// setNodeId - Set unique node id. void setNodeId(int Id) { NodeId = Id; } - /// use_iterator - This class provides iterator support for SDOperand - /// operands that use a specific SDNode. - class use_iterator - : public forward_iterator { - SDOperand *Op; - explicit use_iterator(SDOperand *op) : Op(op) { - } - friend class SDNode; - public: - typedef forward_iterator::reference reference; - typedef forward_iterator::pointer pointer; - - use_iterator(const use_iterator &I) : Op(I.Op) {} - use_iterator() : Op(0) {} - - bool operator==(const use_iterator &x) const { - return Op == x.Op; - } - bool operator!=(const use_iterator &x) const { - return !operator==(x); - } - - /// atEnd - return true if this iterator is at the end of uses list. - bool atEnd() const { return Op == 0; } - - // Iterator traversal: forward iteration only. - use_iterator &operator++() { // Preincrement - assert(Op && "Cannot increment end iterator!"); - Op = Op->getNext(); - return *this; - } - - use_iterator operator++(int) { // Postincrement - use_iterator tmp = *this; ++*this; return tmp; - } - - - /// getOperandNum - Retrive a number of a current operand. - unsigned getOperandNum() const { - assert(Op && "Cannot dereference end iterator!"); - return (Op - Op->getUser()->OperandList); - } - - /// Retrieve a reference to the current operand. - SDOperand &operator*() const { - assert(Op && "Cannot dereference end iterator!"); - return *Op; - } - - /// Retrieve a pointer to the current operand. - SDOperand *operator->() const { - assert(Op && "Cannot dereference end iterator!"); - return Op; - } - }; - - /// use_begin/use_end - Provide iteration support to walk over all uses - /// of an SDNode. - - use_iterator use_begin(SDNode *node) const { - return use_iterator(node->Uses); - } - - use_iterator use_begin() const { - return use_iterator(Uses); - } - - static use_iterator use_end() { return use_iterator(0); } - + typedef SmallVector::const_iterator use_iterator; + use_iterator use_begin() const { return Uses.begin(); } + use_iterator use_end() const { return Uses.end(); } /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the /// indicated value. This method ignores uses of other values defined by this @@ -1141,7 +982,7 @@ return OperandList[Num]; } - typedef SDOperand* op_iterator; + typedef const SDOperand* op_iterator; op_iterator op_begin() const { return OperandList; } op_iterator op_end() const { return OperandList+NumOperands; } @@ -1198,28 +1039,25 @@ } SDNode(unsigned Opc, SDVTList VTs, const SDOperand *Ops, unsigned NumOps) - : NodeType(Opc), NodeId(-1), UsesSize(0), Uses(NULL) { + : NodeType(Opc), NodeId(-1) { OperandsNeedDelete = true; NumOperands = NumOps; OperandList = NumOps ? new SDOperand[NumOperands] : 0; for (unsigned i = 0; i != NumOps; ++i) { OperandList[i] = Ops[i]; - OperandList[i].setUser(this); - Ops[i].Val->addUse(OperandList[i]); - ++Ops[i].Val->UsesSize; + Ops[i].Val->Uses.push_back(this); } ValueList = VTs.VTs; NumValues = VTs.NumVTs; Prev = 0; Next = 0; } - - SDNode(unsigned Opc, SDVTList VTs) - : NodeType(Opc), NodeId(-1), UsesSize(0), Uses(NULL) { + SDNode(unsigned Opc, SDVTList VTs) : NodeType(Opc), NodeId(-1) { OperandsNeedDelete = false; // Operands set with InitOperands. NumOperands = 0; OperandList = 0; + ValueList = VTs.VTs; NumValues = VTs.NumVTs; Prev = 0; Next = 0; @@ -1232,14 +1070,9 @@ assert(OperandList == 0 && "Operands already set!"); NumOperands = NumOps; OperandList = Ops; - UsesSize = 0; - Uses = NULL; - for (unsigned i = 0; i != NumOps; ++i) { - OperandList[i].setUser(this); - Ops[i].Val->addUse(OperandList[i]); - ++Ops[i].Val->UsesSize; - } + for (unsigned i = 0; i != NumOps; ++i) + Ops[i].Val->Uses.push_back(this); } /// MorphNodeTo - This frees the operands of the current node, resets the @@ -1248,48 +1081,50 @@ void MorphNodeTo(unsigned Opc, SDVTList L, const SDOperand *Ops, unsigned NumOps); - void addUser(unsigned i, SDNode *User) { - assert(User->OperandList[i].getUser() && "Node without parent"); - addUse(User->OperandList[i]); - ++UsesSize; + void addUser(SDNode *User) { + Uses.push_back(User); } - - void removeUser(unsigned i, SDNode *User) { - assert(User->OperandList[i].getUser() && "Node without parent"); - SDOperand &Op = User->OperandList[i]; - Op.removeFromList(); - --UsesSize; + void removeUser(SDNode *User) { + // Remove this user from the operand's use list. + for (unsigned i = Uses.size(); ; --i) { + assert(i != 0 && "Didn't find user!"); + if (Uses[i-1] == User) { + Uses[i-1] = Uses.back(); + Uses.pop_back(); + return; + } + } } }; -// Define inline functions from the SDOperandImpl class. +// Define inline functions from the SDOperand class. -inline unsigned SDOperandImpl::getOpcode() const { +inline unsigned SDOperand::getOpcode() const { return Val->getOpcode(); } -inline MVT::ValueType SDOperandImpl::getValueType() const { +inline MVT::ValueType SDOperand::getValueType() const { return Val->getValueType(ResNo); } -inline unsigned SDOperandImpl::getNumOperands() const { +inline unsigned SDOperand::getNumOperands() const { return Val->getNumOperands(); } -inline const SDOperandImpl &SDOperandImpl::getOperand(unsigned i) const { +inline const SDOperand &SDOperand::getOperand(unsigned i) const { return Val->getOperand(i); } -inline uint64_t SDOperandImpl::getConstantOperandVal(unsigned i) const { +inline uint64_t SDOperand::getConstantOperandVal(unsigned i) const { return Val->getConstantOperandVal(i); } -inline bool SDOperandImpl::isTargetOpcode() const { +inline bool SDOperand::isTargetOpcode() const { return Val->isTargetOpcode(); } -inline unsigned SDOperandImpl::getTargetOpcode() const { +inline unsigned SDOperand::getTargetOpcode() const { return Val->getTargetOpcode(); } -inline bool SDOperandImpl::hasOneUse() const { +inline bool SDOperand::hasOneUse() const { return Val->hasNUsesOfValue(1, ResNo); } -inline bool SDOperandImpl::use_empty() const { +inline bool SDOperand::use_empty() const { return !Val->hasAnyUseOfValue(ResNo); } Modified: llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/DAGCombiner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=49360&r1=48928&r2=49360&view=diff ============================================================================== --- llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Apr 7 19:10:14 2008 @@ -78,7 +78,7 @@ void AddUsersToWorkList(SDNode *N) { for (SDNode::use_iterator UI = N->use_begin(), UE = N->use_end(); UI != UE; ++UI) - AddToWorkList(UI->getUser()); + AddToWorkList(*UI); } /// visit - call the node-specific routine that knows how to fold each @@ -2704,7 +2704,7 @@ bool isTruncFree = TLI.isTruncateFree(N->getValueType(0), N0.getValueType()); for (SDNode::use_iterator UI = N0.Val->use_begin(), UE = N0.Val->use_end(); UI != UE; ++UI) { - SDNode *User = UI->getUser(); + SDNode *User = *UI; if (User == N) continue; // FIXME: Only extend SETCC N, N and SETCC N, c for now. @@ -2743,7 +2743,7 @@ bool BothLiveOut = false; for (SDNode::use_iterator UI = N->use_begin(), UE = N->use_end(); UI != UE; ++UI) { - SDNode *User = UI->getUser(); + SDNode *User = *UI; for (unsigned i = 0, e = User->getNumOperands(); i != e; ++i) { SDOperand UseOp = User->getOperand(i); if (UseOp.Val == N && UseOp.ResNo == 0) { @@ -3880,7 +3880,7 @@ MVT::ValueType VT = N->getValueType(0); // If this is fp_round(fpextend), don't fold it, allow ourselves to be folded. - if (N->hasOneUse() && (N->use_begin())->getOpcode() == ISD::FP_ROUND) + if (N->hasOneUse() && (*N->use_begin())->getOpcode() == ISD::FP_ROUND) return SDOperand(); // fold (fp_extend c1fp) -> c1fp @@ -4101,7 +4101,7 @@ bool RealUse = false; for (SDNode::use_iterator I = Ptr.Val->use_begin(), E = Ptr.Val->use_end(); I != E; ++I) { - SDNode *Use = I->getUser(); + SDNode *Use = *I; if (Use == N) continue; if (Use->isPredecessorOf(N)) @@ -4186,7 +4186,7 @@ for (SDNode::use_iterator I = Ptr.Val->use_begin(), E = Ptr.Val->use_end(); I != E; ++I) { - SDNode *Op = I->getUser(); + SDNode *Op = *I; if (Op == N || (Op->getOpcode() != ISD::ADD && Op->getOpcode() != ISD::SUB)) continue; @@ -4214,7 +4214,7 @@ bool TryNext = false; for (SDNode::use_iterator II = BasePtr.Val->use_begin(), EE = BasePtr.Val->use_end(); II != EE; ++II) { - SDNode *Use = II->getUser(); + SDNode *Use = *II; if (Use == Ptr.Val) continue; @@ -4224,7 +4224,7 @@ bool RealUse = false; for (SDNode::use_iterator III = Use->use_begin(), EEE = Use->use_end(); III != EEE; ++III) { - SDNode *UseUse = III->getUser(); + SDNode *UseUse = *III; if (!((UseUse->getOpcode() == ISD::LOAD && cast(UseUse)->getBasePtr().Val == Use) || (UseUse->getOpcode() == ISD::STORE && Modified: llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=49360&r1=48928&r2=49360&view=diff ============================================================================== --- llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original) +++ llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Mon Apr 7 19:10:14 2008 @@ -85,17 +85,17 @@ /// LegalizedNodes - For nodes that are of legal width, and that have more /// than one use, this map indicates what regularized operand to use. This /// allows us to avoid legalizing the same thing more than once. - DenseMap LegalizedNodes; + DenseMap LegalizedNodes; /// PromotedNodes - For nodes that are below legal width, and that have more /// than one use, this map indicates what promoted value to use. This allows /// us to avoid promoting the same thing more than once. - DenseMap PromotedNodes; + DenseMap PromotedNodes; /// ExpandedNodes - For nodes that need to be expanded this map indicates /// which which operands are the expanded version of the input. This allows /// us to avoid expanding the same node more than once. - DenseMap > ExpandedNodes; + DenseMap > ExpandedNodes; /// SplitNodes - For vector nodes that need to be split, this map indicates /// which which operands are the split version of the input. This allows us @@ -308,7 +308,7 @@ // are now done. for (SDNode::use_iterator UI = N->use_begin(), E = N->use_end(); UI != E; ++UI) - Worklist.push_back(UI->getUser()); + Worklist.push_back(*UI); } assert(Order.size() == Visited.size() && @@ -381,7 +381,7 @@ E = Node->use_end(); UI != E; ++UI) { // Make sure to only follow users of our token chain. - SDNode *User = UI->getUser(); + SDNode *User = *UI; for (unsigned i = 0, e = User->getNumOperands(); i != e; ++i) if (User->getOperand(i) == TheChain) if (SDNode *Result = FindCallEndFromCallStart(User)) @@ -783,7 +783,7 @@ // Note that LegalizeOp may be reentered even from single-use nodes, which // means that we always must cache transformed nodes. - DenseMap::iterator I = LegalizedNodes.find(Op); + DenseMap::iterator I = LegalizedNodes.find(Op); if (I != LegalizedNodes.end()) return I->second; SDOperand Tmp1, Tmp2, Tmp3, Tmp4; @@ -1599,7 +1599,7 @@ // will cause this node to be legalized as well as handling libcalls right. if (LastCALLSEQ_END.Val != Node) { LegalizeOp(SDOperand(FindCallStartFromCallEnd(Node), 0)); - DenseMap::iterator I = LegalizedNodes.find(Op); + DenseMap::iterator I = LegalizedNodes.find(Op); assert(I != LegalizedNodes.end() && "Legalizing the call start should have legalized this node!"); return I->second; @@ -4136,7 +4136,7 @@ SDOperand Result; SDNode *Node = Op.Val; - DenseMap::iterator I = PromotedNodes.find(Op); + DenseMap::iterator I = PromotedNodes.find(Op); if (I != PromotedNodes.end()) return I->second; switch (Node->getOpcode()) { @@ -5833,7 +5833,7 @@ "Cannot expand to FP value or to larger int value!"); // See if we already expanded it. - DenseMap >::iterator I + DenseMap >::iterator I = ExpandedNodes.find(Op); if (I != ExpandedNodes.end()) { Lo = I->second.first; Modified: llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp?rev=49360&r1=48928&r2=49360&view=diff ============================================================================== --- llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp (original) +++ llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp Mon Apr 7 19:10:14 2008 @@ -137,7 +137,7 @@ for (SDNode::use_iterator UI = N->use_begin(), E = N->use_end(); UI != E; ++UI) { - SDNode *User = UI->getUser(); + SDNode *User = *UI; int NodeID = User->getNodeId(); assert(NodeID != ReadyToProcess && NodeID != Processed && "Invalid node id for user of unprocessed node!"); @@ -344,7 +344,7 @@ /// RemapNode - If the specified value was already legalized to another value, /// replace it by that value. void DAGTypeLegalizer::RemapNode(SDOperand &N) { - DenseMap::iterator I = ReplacedNodes.find(N); + DenseMap::iterator I = ReplacedNodes.find(N); if (I != ReplacedNodes.end()) { // Use path compression to speed up future lookups if values get multiply // replaced with other values. Modified: llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/LegalizeTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/LegalizeTypes.h?rev=49360&r1=48928&r2=49360&view=diff ============================================================================== --- llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/LegalizeTypes.h (original) +++ llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/LegalizeTypes.h Mon Apr 7 19:10:14 2008 @@ -110,27 +110,27 @@ /// PromotedNodes - For nodes that are below legal width, this map indicates /// what promoted value to use. - DenseMap PromotedNodes; + DenseMap PromotedNodes; /// ExpandedNodes - For nodes that need to be expanded this map indicates /// which operands are the expanded version of the input. - DenseMap > ExpandedNodes; + DenseMap > ExpandedNodes; /// FloatToIntedNodes - For floating point nodes converted to integers of /// the same size, this map indicates the converted value to use. - DenseMap FloatToIntedNodes; + DenseMap FloatToIntedNodes; /// ScalarizedNodes - For nodes that are <1 x ty>, this map indicates the /// scalar value of type 'ty' to use. - DenseMap ScalarizedNodes; + DenseMap ScalarizedNodes; /// SplitNodes - For nodes that need to be split this map indicates /// which operands are the expanded version of the input. - DenseMap > SplitNodes; + DenseMap > SplitNodes; /// ReplacedNodes - For nodes that have been replaced with another, /// indicates the replacement node to use. - DenseMap ReplacedNodes; + DenseMap ReplacedNodes; /// Worklist - This defines a worklist of nodes to process. In order to be /// pushed onto this worklist, all operands of a node must have already been Modified: llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp?rev=49360&r1=48928&r2=49360&view=diff ============================================================================== --- llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp (original) +++ llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp Mon Apr 7 19:10:14 2008 @@ -135,11 +135,11 @@ bool HasFlagUse = false; for (SDNode::use_iterator UI = N->use_begin(), E = N->use_end(); UI != E; ++UI) - if (FlagVal.isOperandOf(UI->getUser())) { + if (FlagVal.isOperandOf(*UI)) { HasFlagUse = true; NodeSUnit->FlaggedNodes.push_back(N); SUnitMap[N].push_back(NodeSUnit); - N = UI->getUser(); + N = *UI; break; } if (!HasFlagUse) break; @@ -398,7 +398,7 @@ void ScheduleDAG::EmitCopyFromReg(SDNode *Node, unsigned ResNo, unsigned InstanceNo, unsigned SrcReg, - DenseMap &VRBaseMap) { + DenseMap &VRBaseMap) { unsigned VRBase = 0; if (TargetRegisterInfo::isVirtualRegister(SrcReg)) { // Just use the input register directly! @@ -414,7 +414,7 @@ bool MatchReg = true; for (SDNode::use_iterator UI = Node->use_begin(), E = Node->use_end(); UI != E; ++UI) { - SDNode *Use = UI->getUser(); + SDNode *Use = *UI; bool Match = true; if (Use->getOpcode() == ISD::CopyToReg && Use->getOperand(2).Val == Node && @@ -469,7 +469,7 @@ void ScheduleDAG::CreateVirtualRegisters(SDNode *Node, MachineInstr *MI, const TargetInstrDesc &II, - DenseMap &VRBaseMap) { + DenseMap &VRBaseMap) { for (unsigned i = 0; i < II.getNumDefs(); ++i) { // If the specific node value is only used by a CopyToReg and the dest reg // is a vreg, use the CopyToReg'd destination register instead of creating @@ -477,7 +477,7 @@ unsigned VRBase = 0; for (SDNode::use_iterator UI = Node->use_begin(), E = Node->use_end(); UI != E; ++UI) { - SDNode *Use = UI->getUser(); + SDNode *Use = *UI; if (Use->getOpcode() == ISD::CopyToReg && Use->getOperand(2).Val == Node && Use->getOperand(2).ResNo == i) { @@ -512,8 +512,8 @@ /// getVR - Return the virtual register corresponding to the specified result /// of the specified node. -static unsigned getVR(SDOperand Op, DenseMap &VRBaseMap) { - DenseMap::iterator I = VRBaseMap.find(Op); +static unsigned getVR(SDOperand Op, DenseMap &VRBaseMap) { + DenseMap::iterator I = VRBaseMap.find(Op); assert(I != VRBaseMap.end() && "Node emitted out of order - late"); return I->second; } @@ -526,7 +526,7 @@ void ScheduleDAG::AddOperand(MachineInstr *MI, SDOperand Op, unsigned IIOpNum, const TargetInstrDesc *II, - DenseMap &VRBaseMap) { + DenseMap &VRBaseMap) { if (Op.isTargetOpcode()) { // Note that this case is redundant with the final else block, but we // include it because it is the most common and it makes the logic @@ -658,7 +658,7 @@ /// EmitSubregNode - Generate machine code for subreg nodes. /// void ScheduleDAG::EmitSubregNode(SDNode *Node, - DenseMap &VRBaseMap) { + DenseMap &VRBaseMap) { unsigned VRBase = 0; unsigned Opc = Node->getTargetOpcode(); @@ -666,7 +666,7 @@ // the CopyToReg'd destination register instead of creating a new vreg. for (SDNode::use_iterator UI = Node->use_begin(), E = Node->use_end(); UI != E; ++UI) { - SDNode *Use = UI->getUser(); + SDNode *Use = *UI; if (Use->getOpcode() == ISD::CopyToReg && Use->getOperand(2).Val == Node) { unsigned DestReg = cast(Use->getOperand(1))->getReg(); @@ -750,7 +750,7 @@ /// EmitNode - Generate machine code for an node and needed dependencies. /// void ScheduleDAG::EmitNode(SDNode *Node, unsigned InstanceNo, - DenseMap &VRBaseMap) { + DenseMap &VRBaseMap) { // If machine instruction if (Node->isTargetOpcode()) { unsigned Opc = Node->getTargetOpcode(); @@ -1067,7 +1067,7 @@ } // Finally, emit the code for all of the scheduled instructions. - DenseMap VRBaseMap; + DenseMap VRBaseMap; DenseMap CopyVRBaseMap; for (unsigned i = 0, e = Sequence.size(); i != e; i++) { if (SUnit *SU = Sequence[i]) { Modified: llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=49360&r1=48928&r2=49360&view=diff ============================================================================== --- llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/tags/Apple/llvmCore-2030-03/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Mon Apr 7 19:10:14 2008 @@ -10,6 +10,7 @@ // This implements the SelectionDAG class. // //===----------------------------------------------------------------------===// + #include "llvm/CodeGen/SelectionDAG.h" #include "llvm/Constants.h" #include "llvm/GlobalAlias.h" @@ -464,15 +465,14 @@ // no cycles in the graph. for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I) { SDNode *Operand = I->Val; - Operand->removeUser(std::distance(N->op_begin(), I), N); + Operand->removeUser(N); // Now that we removed this operand, see if there are no uses of it left. if (Operand->use_empty()) DeadNodes.push_back(Operand); } - if (N->OperandsNeedDelete) { + if (N->OperandsNeedDelete) delete[] N->OperandList; - } N->OperandList = 0; N->NumOperands = 0; @@ -504,15 +504,14 @@ // no cycles in the graph. for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I) { SDNode *Operand = I->Val; - Operand->removeUser(std::distance(N->op_begin(), I), N); + Operand->removeUser(N); // Now that we removed this operand, see if there are no uses of it left. if (Operand->use_empty()) DeadNodes.push_back(Operand); } - if (N->OperandsNeedDelete) { + if (N->OperandsNeedDelete) delete[] N->OperandList; - } N->OperandList = 0; N->NumOperands = 0; @@ -539,10 +538,9 @@ // Drop all of the operands and decrement used nodes use counts. for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I) - I->Val->removeUser(std::distance(N->op_begin(), I), N); - if (N->OperandsNeedDelete) { + I->Val->removeUser(N); + if (N->OperandsNeedDelete) delete[] N->OperandList; - } N->OperandList = 0; N->NumOperands = 0; @@ -703,9 +701,8 @@ while (!AllNodes.empty()) { SDNode *N = AllNodes.begin(); N->SetNextInBucket(0); - if (N->OperandsNeedDelete) { + if (N->OperandsNeedDelete) delete [] N->OperandList; - } N->OperandList = 0; N->NumOperands = 0; AllNodes.pop_front(); @@ -2897,10 +2894,9 @@ RemoveNodeFromCSEMaps(N); // Now we update the operands. - N->OperandList[0].Val->removeUser(0, N); + N->OperandList[0].Val->removeUser(N); + Op.Val->addUser(N); N->OperandList[0] = Op; - N->OperandList[0].setUser(N); - Op.Val->addUser(0, N); // If this gets put into a CSE map, add it. if (InsertPos) CSEMap.InsertNode(N, InsertPos); @@ -2927,16 +2923,14 @@ // Now we update the operands. if (N->OperandList[0] != Op1) { - N->OperandList[0].Val->removeUser(0, N); + N->OperandList[0].Val->removeUser(N); + Op1.Val->addUser(N); N->OperandList[0] = Op1; - N->OperandList[0].setUser(N); - Op1.Val->addUser(0, N); } if (N->OperandList[1] != Op2) { - N->OperandList[1].Val->removeUser(1, N); + N->OperandList[1].Val->removeUser(N); + Op2.Val->addUser(N); N->OperandList[1] = Op2; - N->OperandList[1].setUser(N); - Op2.Val->addUser(1, N); } // If this gets put into a CSE map, add it. @@ -2964,6 +2958,7 @@ return UpdateNodeOperands(N, Ops, 5); } + SDOperand SelectionDAG:: UpdateNodeOperands(SDOperand InN, SDOperand *Ops, unsigned NumOps) { SDNode *N = InN.Val; @@ -2994,10 +2989,9 @@ // Now we update the operands. for (unsigned i = 0; i != NumOps; ++i) { if (N->OperandList[i] != Ops[i]) { - N->OperandList[i].Val->removeUser(i, N); + N->OperandList[i].Val->removeUser(N); + Ops[i].Val->addUser(N); N->OperandList[i] = Ops[i]; - N->OperandList[i].setUser(N); - Ops[i].Val->addUser(i, N); } } @@ -3006,6 +3000,7 @@ return InN; } + /// MorphNodeTo - This frees the operands of the current node, resets the /// opcode, types, and operands to the specified value. This should only be /// used by the SelectionDAG class. @@ -3018,14 +3013,13 @@ // Clear the operands list, updating used nodes to remove this from their // use list. for (op_iterator I = op_begin(), E = op_end(); I != E; ++I) - I->Val->removeUser(std::distance(op_begin(), I), this); + I->Val->removeUser(this); // If NumOps is larger than the # of operands we currently have, reallocate // the operand list. if (NumOps > NumOperands) { - if (OperandsNeedDelete) { + if (OperandsNeedDelete) delete [] OperandList; - } OperandList = new SDOperand[NumOps]; OperandsNeedDelete = true; } @@ -3035,10 +3029,8 @@ for (unsigned i = 0, e = NumOps; i != e; ++i) { OperandList[i] = Ops[i]; - OperandList[i].setUser(this); SDNode *N = OperandList[i].Val; - N->addUser(i, this); - ++N->UsesSize; + N->Uses.push_back(this); } } @@ -3306,27 +3298,21 @@ assert(From->getNumValues() == 1 && FromN.ResNo == 0 && "Cannot replace with this method!"); assert(From != To.Val && "Cannot replace uses of with self"); - - SmallSetVector Users; + while (!From->use_empty()) { - SDNode::use_iterator UI = From->use_begin(); - SDNode *U = UI->getUser(); - - // Remember that this node is about to morph. - if (Users.count(U)) - continue; - Users.insert(U); + // Process users until they are all gone. + SDNode *U = *From->use_begin(); + // This node is about to morph, remove its old self from the CSE maps. RemoveNodeFromCSEMaps(U); - int operandNum = 0; - for (SDNode::op_iterator I = U->op_begin(), E = U->op_end(); - I != E; ++I, ++operandNum) + + for (SDOperand *I = U->OperandList, *E = U->OperandList+U->NumOperands; + I != E; ++I) if (I->Val == From) { - From->removeUser(operandNum, U); + From->removeUser(U); *I = To; - I->setUser(U); - To.Val->addUser(operandNum, U); - } + To.Val->addUser(U); + } // Now that we have modified U, add it back to the CSE maps. If it already // exists there, recursively merge the results together. @@ -3360,26 +3346,21 @@ return ReplaceAllUsesWith(SDOperand(From, 0), SDOperand(To, 0), UpdateListener); - SmallSetVector Users; while (!From->use_empty()) { - SDNode::use_iterator UI = From->use_begin(); - SDNode *U = UI->getUser(); - - // Remember that this node is about to morph. - if (Users.count(U)) - continue; - Users.insert(U); + // Process users until they are all gone. + SDNode *U = *From->use_begin(); + // This node is about to morph, remove its old self from the CSE maps. RemoveNodeFromCSEMaps(U); - int operandNum = 0; - for (SDNode::op_iterator I = U->op_begin(), E = U->op_end(); - I != E; ++I, ++operandNum) + + for (SDOperand *I = U->OperandList, *E = U->OperandList+U->NumOperands; + I != E; ++I) if (I->Val == From) { - From->removeUser(operandNum, U); + From->removeUser(U); I->Val = To; - To->addUser(operandNum, U); + To->addUser(U); } - + // Now that we have modified U, add it back to the CSE maps. If it already // exists there, recursively merge the results together. if (SDNode *Existing = AddNonLeafNodeToCSEMaps(U)) { @@ -3408,28 +3389,22 @@ if (From->getNumValues() == 1) // Handle the simple case efficiently. return ReplaceAllUsesWith(SDOperand(From, 0), To[0], UpdateListener); - SmallSetVector Users; while (!From->use_empty()) { - SDNode::use_iterator UI = From->use_begin(); - SDNode *U = UI->getUser(); - - // Remember that this node is about to morph. - if (Users.count(U)) - continue; - Users.insert(U); + // Process users until they are all gone. + SDNode *U = *From->use_begin(); + // This node is about to morph, remove its old self from the CSE maps. RemoveNodeFromCSEMaps(U); - int operandNum = 0; - for (SDNode::op_iterator I = U->op_begin(), E = U->op_end(); - I != E; ++I, ++operandNum) + + for (SDOperand *I = U->OperandList, *E = U->OperandList+U->NumOperands; + I != E; ++I) if (I->Val == From) { const SDOperand &ToOp = To[I->ResNo]; - From->removeUser(operandNum, U); + From->removeUser(U); *I = ToOp; - I->setUser(U); - ToOp.Val->addUser(operandNum, U); + ToOp.Val->addUser(U); } - + // Now that we have modified U, add it back to the CSE maps. If it already // exists there, recursively merge the results together. if (SDNode *Existing = AddNonLeafNodeToCSEMaps(U)) { @@ -3459,7 +3434,7 @@ ChainedSetUpdaterListener(SmallSetVector &set, SelectionDAG::DAGUpdateListener *chain) : Set(set), Chain(chain) {} - + virtual void NodeDeleted(SDNode *N) { Set.remove(N); if (Chain) Chain->NodeDeleted(N); @@ -3487,13 +3462,7 @@ // Get all of the users of From.Val. We want these in a nice, // deterministically ordered and uniqued set, so we use a SmallSetVector. - SmallSetVector Users; - for (SDNode::use_iterator UI = From.Val->use_begin(), - E = From.Val->use_end(); UI != E; ++UI) { - SDNode *User = UI->getUser(); - if (!Users.count(User)) - Users.insert(User); - } + SmallSetVector Users(From.Val->use_begin(), From.Val->use_end()); // When one of the recursive merges deletes nodes from the graph, we need to // make sure that UpdateListener is notified *and* that the node is removed @@ -3507,7 +3476,7 @@ Users.pop_back(); // Scan for an operand that matches From. - SDNode::op_iterator Op = User->op_begin(), E = User->op_end(); + SDOperand *Op = User->OperandList, *E = User->OperandList+User->NumOperands; for (; Op != E; ++Op) if (*Op == From) break; @@ -3521,10 +3490,9 @@ // Update all operands that match "From" in case there are multiple uses. for (; Op != E; ++Op) { if (*Op == From) { - From.Val->removeUser(Op-User->op_begin(), User); - *Op = To; - Op->setUser(User); - To.Val->addUser(Op-User->op_begin(), User); + From.Val->removeUser(User); + *Op = To; + To.Val->addUser(User); } } @@ -3704,13 +3672,16 @@ SmallPtrSet UsersHandled; - // TODO: Only iterate over uses of a given value of the node - for (SDNode::use_iterator UI = use_begin(), E = use_end(); UI != E; ++UI) { - if (*UI == TheValue) { - if (NUses == 0) - return false; - --NUses; - } + for (SDNode::use_iterator UI = Uses.begin(), E = Uses.end(); UI != E; ++UI) { + SDNode *User = *UI; + if (User->getNumOperands() == 1 || + UsersHandled.insert(User)) // First time we've seen this? + for (unsigned i = 0, e = User->getNumOperands(); i != e; ++i) + if (User->getOperand(i) == TheValue) { + if (NUses == 0) + return false; // too many uses + --NUses; + } } // Found exactly the right number of uses? @@ -3729,8 +3700,8 @@ SmallPtrSet UsersHandled; - for (SDNode::use_iterator UI = use_begin(), E = use_end(); UI != E; ++UI) { - SDNode *User = UI->getUser(); + for (SDNode::use_iterator UI = Uses.begin(), E = Uses.end(); UI != E; ++UI) { + SDNode *User = *UI; if (User->getNumOperands() == 1 || UsersHandled.insert(User)) // First time we've seen this? for (unsigned i = 0, e = User->getNumOperands(); i != e; ++i) @@ -3748,7 +3719,7 @@ bool SDNode::isOnlyUseOf(SDNode *N) const { bool Seen = false; for (SDNode::use_iterator I = N->use_begin(), E = N->use_end(); I != E; ++I) { - SDNode *User = I->getUser(); + SDNode *User = *I; if (User == this) Seen = true; else @@ -3760,7 +3731,7 @@ /// isOperand - Return true if this node is an operand of N. /// -bool SDOperandImpl::isOperandOf(SDNode *N) const { +bool SDOperand::isOperandOf(SDNode *N) const { for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) if (*this == N->getOperand(i)) return true; @@ -3779,7 +3750,7 @@ /// side-effecting instructions. In practice, this looks through token /// factors and non-volatile loads. In order to remain efficient, this only /// looks a couple of nodes in, it does not do an exhaustive search. -bool SDOperandImpl::reachesChainWithoutSideEffects(SDOperandImpl Dest, +bool SDOperand::reachesChainWithoutSideEffects(SDOperand Dest, unsigned Depth) const { if (*this == Dest) return true; Modified: llvm/tags/Apple/llvmCore-2030-03/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/tags/Apple/llvmCore-2030-03/lib/Target/PowerPC/PPCISelLowering.cpp?rev=49360&r1=48928&r2=49360&view=diff ============================================================================== --- llvm/tags/Apple/llvmCore-2030-03/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/tags/Apple/llvmCore-2030-03/lib/Target/PowerPC/PPCISelLowering.cpp Mon Apr 7 19:10:14 2008 @@ -3660,11 +3660,11 @@ SDNode *LHSN = N->getOperand(0).Val; for (SDNode::use_iterator UI = LHSN->use_begin(), E = LHSN->use_end(); UI != E; ++UI) - if ((*UI).getUser()->getOpcode() == PPCISD::VCMPo && - (*UI).getUser()->getOperand(1) == N->getOperand(1) && - (*UI).getUser()->getOperand(2) == N->getOperand(2) && - (*UI).getUser()->getOperand(0) == N->getOperand(0)) { - VCMPoNode = UI->getUser(); + if ((*UI)->getOpcode() == PPCISD::VCMPo && + (*UI)->getOperand(1) == N->getOperand(1) && + (*UI)->getOperand(2) == N->getOperand(2) && + (*UI)->getOperand(0) == N->getOperand(0)) { + VCMPoNode = *UI; break; } @@ -3680,7 +3680,7 @@ for (SDNode::use_iterator UI = VCMPoNode->use_begin(); FlagUser == 0; ++UI) { assert(UI != VCMPoNode->use_end() && "Didn't find user!"); - SDNode *User = UI->getUser(); + SDNode *User = *UI; for (unsigned i = 0, e = User->getNumOperands(); i != e; ++i) { if (User->getOperand(i) == SDOperand(VCMPoNode, 1)) { FlagUser = User; Modified: llvm/tags/Apple/llvmCore-2030-03/lib/Target/X86/X86CodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/tags/Apple/llvmCore-2030-03/lib/Target/X86/X86CodeEmitter.cpp?rev=49360&r1=48928&r2=49360&view=diff ============================================================================== --- llvm/tags/Apple/llvmCore-2030-03/lib/Target/X86/X86CodeEmitter.cpp (original) +++ llvm/tags/Apple/llvmCore-2030-03/lib/Target/X86/X86CodeEmitter.cpp Mon Apr 7 19:10:14 2008 @@ -558,16 +558,10 @@ bool Need0FPrefix = false; switch (Desc->TSFlags & X86II::Op0Mask) { - case X86II::TB: - Need0FPrefix = true; // Two-byte opcode prefix - break; - case X86II::T8: - MCE.emitByte(0x0F); - MCE.emitByte(0x38); - break; - case X86II::TA: - MCE.emitByte(0x0F); - MCE.emitByte(0x3A); + case X86II::TB: // Two-byte opcode prefix + case X86II::T8: // 0F 38 + case X86II::TA: // 0F 3A + Need0FPrefix = true; break; case X86II::REP: break; // already handled. case X86II::XS: // F3 0F @@ -599,6 +593,15 @@ if (Need0FPrefix) MCE.emitByte(0x0F); + switch (Desc->TSFlags & X86II::Op0Mask) { + case X86II::T8: // 0F 38 + MCE.emitByte(0x38); + break; + case X86II::TA: // 0F 3A + MCE.emitByte(0x3A); + break; + } + // If this is a two-address instruction, skip one of the register operands. unsigned NumOps = Desc->getNumOperands(); unsigned CurOp = 0; Modified: llvm/tags/Apple/llvmCore-2030-03/lib/Target/X86/X86ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/tags/Apple/llvmCore-2030-03/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=49360&r1=48928&r2=49360&view=diff ============================================================================== --- llvm/tags/Apple/llvmCore-2030-03/lib/Target/X86/X86ISelDAGToDAG.cpp (original) +++ llvm/tags/Apple/llvmCore-2030-03/lib/Target/X86/X86ISelDAGToDAG.cpp Mon Apr 7 19:10:14 2008 @@ -225,7 +225,7 @@ static SDNode *findFlagUse(SDNode *N) { unsigned FlagResNo = N->getNumValues()-1; for (SDNode::use_iterator I = N->use_begin(), E = N->use_end(); I != E; ++I) { - SDNode *User = I->getUser(); + SDNode *User = *I; for (unsigned i = 0, e = User->getNumOperands(); i != e; ++i) { SDOperand Op = User->getOperand(i); if (Op.Val == N && Op.ResNo == FlagResNo) Modified: llvm/tags/Apple/llvmCore-2030-03/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/tags/Apple/llvmCore-2030-03/lib/Target/X86/X86ISelLowering.cpp?rev=49360&r1=48928&r2=49360&view=diff ============================================================================== --- llvm/tags/Apple/llvmCore-2030-03/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/tags/Apple/llvmCore-2030-03/lib/Target/X86/X86ISelLowering.cpp Mon Apr 7 19:10:14 2008 @@ -3724,7 +3724,7 @@ // result has a single use which is a store. if (!Op.hasOneUse()) return SDOperand(); - SDNode *User = Op.Val->use_begin()->getUser(); + SDNode *User = *Op.Val->use_begin(); if (User->getOpcode() != ISD::STORE) return SDOperand(); SDOperand Extract = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, MVT::i32, From dalej at apple.com Mon Apr 7 19:10:24 2008 From: dalej at apple.com (Dale Johannesen) Date: Tue, 08 Apr 2008 00:10:24 -0000 Subject: [llvm-commits] [llvm] r49361 - in /llvm/trunk: include/llvm/Target/TargetOptions.h lib/CodeGen/DwarfWriter.cpp lib/Target/PowerPC/PPCRegisterInfo.cpp lib/Target/TargetMachine.cpp lib/Target/X86/X86RegisterInfo.cpp Message-ID: <200804080010.m380AOMa012356@zion.cs.uiuc.edu> Author: johannes Date: Mon Apr 7 19:10:24 2008 New Revision: 49361 URL: http://llvm.org/viewvc/llvm-project?rev=49361&view=rev Log: Implement new llc flag -disable-required-unwind-tables. Corresponds to -fno-unwind-tables (usually default in gcc). Modified: llvm/trunk/include/llvm/Target/TargetOptions.h llvm/trunk/lib/CodeGen/DwarfWriter.cpp llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp llvm/trunk/lib/Target/TargetMachine.cpp llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Modified: llvm/trunk/include/llvm/Target/TargetOptions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetOptions.h?rev=49361&r1=49360&r2=49361&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetOptions.h (original) +++ llvm/trunk/include/llvm/Target/TargetOptions.h Mon Apr 7 19:10:24 2008 @@ -74,13 +74,18 @@ /// be emitted. extern bool ExceptionHandling; + /// UnwindTablesOptional - This flag indicates that unwind tables need not + /// be emitted for all functions. Exception handling may still require them + /// for some functions. + extern bool UnwindTablesOptional; + /// PerformTailCallOpt - This flag is enabled when -tailcallopt is specified /// on the commandline. When the flag is on, the target will perform tail call /// optimization (pop the caller's stack) providing it supports it. extern bool PerformTailCallOpt; - /// OptimizeForSize - When this flags is set, code generator avoids optimization - /// that increases size. + /// OptimizeForSize - When this flag is set, the code generator avoids + /// optimizations that increase size. extern bool OptimizeForSize; } // End llvm namespace Modified: llvm/trunk/lib/CodeGen/DwarfWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfWriter.cpp?rev=49361&r1=49360&r2=49361&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/DwarfWriter.cpp (original) +++ llvm/trunk/lib/CodeGen/DwarfWriter.cpp Mon Apr 7 19:10:24 2008 @@ -2905,8 +2905,11 @@ // If there are no calls then you can't unwind. This may mean we can // omit the EH Frame, but some environments do not handle weak absolute - // symbols. + // symbols. + // If UnwindTablesOptional is not set we cannot do this optimization; the + // unwind info is to be available for non-EH uses. if (!EHFrameInfo.hasCalls && + UnwindTablesOptional && ((linkage != Function::WeakLinkage && linkage != Function::LinkOnceLinkage) || !TAI->getWeakDefDirective() || @@ -3427,7 +3430,9 @@ shouldEmitTable = true; // See if we need frame move info. - if (MMI->hasDebugInfo() || !MF->getFunction()->doesNotThrow()) + if (MMI->hasDebugInfo() || + !MF->getFunction()->doesNotThrow() || + !UnwindTablesOptional) shouldEmitMoves = true; if (shouldEmitMoves || shouldEmitTable) Modified: llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp?rev=49361&r1=49360&r2=49361&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp Mon Apr 7 19:10:24 2008 @@ -948,7 +948,8 @@ MachineFrameInfo *MFI = MF.getFrameInfo(); MachineModuleInfo *MMI = MFI->getMachineModuleInfo(); bool needsFrameMoves = (MMI && MMI->hasDebugInfo()) || - !MF.getFunction()->doesNotThrow(); + !MF.getFunction()->doesNotThrow() || + !UnwindTablesOptional; // Prepare for frame info. unsigned FrameLabelId = 0; Modified: llvm/trunk/lib/Target/TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachine.cpp?rev=49361&r1=49360&r2=49361&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/TargetMachine.cpp Mon Apr 7 19:10:24 2008 @@ -31,6 +31,7 @@ bool UseSoftFloat; bool NoZerosInBSS; bool ExceptionHandling; + bool UnwindTablesOptional; Reloc::Model RelocationModel; CodeModel::Model CMModel; bool PerformTailCallOpt; @@ -80,9 +81,14 @@ cl::init(false)); cl::opt EnableExceptionHandling("enable-eh", - cl::desc("Exception handling should be emitted."), + cl::desc("Emit DWARF exception handling (default if target supports)"), cl::location(ExceptionHandling), cl::init(false)); + cl::opt + DisableUnwindTables("disable-required-unwind-tables", + cl::desc("Do not require unwinding info for all functions"), + cl::location(UnwindTablesOptional), + cl::init(false)); cl::opt DefRelocationModel( Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=49361&r1=49360&r2=49361&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Mon Apr 7 19:10:24 2008 @@ -504,7 +504,9 @@ MachineModuleInfo *MMI = MFI->getMachineModuleInfo(); X86MachineFunctionInfo *X86FI = MF.getInfo(); MachineBasicBlock::iterator MBBI = MBB.begin(); - bool needsFrameMoves = (MMI && MMI->hasDebugInfo()) || !Fn->doesNotThrow(); + bool needsFrameMoves = (MMI && MMI->hasDebugInfo()) || + !Fn->doesNotThrow() || + !UnwindTablesOptional; // Prepare for frame info. unsigned FrameLabelId = 0; From dalej at apple.com Mon Apr 7 19:11:19 2008 From: dalej at apple.com (Dale Johannesen) Date: Tue, 08 Apr 2008 00:11:19 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49362 - in /llvm-gcc-4.2/trunk/gcc: config/i386/llvm-i386-target.h llvm-backend.cpp Message-ID: <200804080011.m380BJel012391@zion.cs.uiuc.edu> Author: johannes Date: Mon Apr 7 19:11:19 2008 New Revision: 49362 URL: http://llvm.org/viewvc/llvm-project?rev=49362&view=rev Log: Redo flag-unwind-tables handling to use -disable-required-unwind-tables. Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h?rev=49362&r1=49361&r2=49362&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h Mon Apr 7 19:11:19 2008 @@ -83,8 +83,6 @@ } \ } -#define LLVM_PRESERVE_UNWIND_TABLES (TARGET_MACHO && TARGET_64BIT) - #ifdef LLVM_ABI_H /* Objects containing SSE vectors are 16 byte aligned, everything else 4. */ Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=49362&r1=49361&r2=49362&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Mon Apr 7 19:11:19 2008 @@ -131,6 +131,8 @@ if (optimize_size) // Reduce inline limit. Default limit is 200. Args.push_back("--inline-threshold=100"); + if (!flag_unwind_tables) + Args.push_back("--disable-required-unwind-tables"); // If there are options that should be passed through to the LLVM backend // directly from the command line, do so now. This is mainly for debugging @@ -297,10 +299,6 @@ OptimizationPassesCreated = false; } -#ifndef LLVM_PRESERVE_UNWIND_TABLES -#define LLVM_PRESERVE_UNWIND_TABLES 0 -#endif - static void createOptimizationPasses() { assert(OptimizationPassesCreated || (!PerFunctionPasses && !PerModulePasses && !CodeGenPasses)); @@ -355,8 +353,7 @@ // DISABLE PREDSIMPLIFY UNTIL PR967 is fixed. //PM->add(createPredicateSimplifierPass()); // Canonicalize registers PM->add(createCFGSimplificationPass()); // Clean up after IPCP & DAE - if (flag_unit_at_a_time && - (!flag_unwind_tables || !LLVM_PRESERVE_UNWIND_TABLES)) + if (flag_unit_at_a_time) PM->add(createPruneEHPass()); // Remove dead EH info if (optimize > 1) { From isanbard at gmail.com Mon Apr 7 19:13:25 2008 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 08 Apr 2008 00:13:25 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49363 - /llvm-gcc-4.2/tags/Apple/llvmgcc42-2030-03/ Message-ID: <200804080013.m380DQLL012448@zion.cs.uiuc.edu> Author: void Date: Mon Apr 7 19:13:25 2008 New Revision: 49363 URL: http://llvm.org/viewvc/llvm-project?rev=49363&view=rev Log: Copying 2030 Added: llvm-gcc-4.2/tags/Apple/llvmgcc42-2030-03/ - copied from r48929, llvm-gcc-4.2/tags/Apple/llvmgcc42-2030/ From dalej at apple.com Mon Apr 7 19:14:17 2008 From: dalej at apple.com (Dale Johannesen) Date: Tue, 08 Apr 2008 00:14:17 -0000 Subject: [llvm-commits] [llvm] r49364 - in /llvm/trunk/test/CodeGen: PowerPC/compare-fcmp-ord.ll PowerPC/reg-coalesce-simple.ll PowerPC/rotl-2.ll X86/2006-03-02-InstrSchedBug.ll X86/2006-05-02-InstrSched1.ll X86/2006-05-02-InstrSched2.ll X86/2006-05-11-InstrSched.ll X86/2007-09-17-ObjcFrameEH.ll X86/constant-pool-remat-0.ll X86/dagcombine-cse.ll X86/iabs.ll X86/or-branch.ll X86/select.ll X86/setuge.ll X86/x86-64-mem.ll X86/zero-remat.ll Message-ID: <200804080014.m380EI9C012513@zion.cs.uiuc.edu> Author: johannes Date: Mon Apr 7 19:14:17 2008 New Revision: 49364 URL: http://llvm.org/viewvc/llvm-project?rev=49364&view=rev Log: Add -disable-required-unwind-tables to tests that need it (usually, grepping for some string found in unwind info) Modified: llvm/trunk/test/CodeGen/PowerPC/compare-fcmp-ord.ll llvm/trunk/test/CodeGen/PowerPC/reg-coalesce-simple.ll llvm/trunk/test/CodeGen/PowerPC/rotl-2.ll llvm/trunk/test/CodeGen/X86/2006-03-02-InstrSchedBug.ll llvm/trunk/test/CodeGen/X86/2006-05-02-InstrSched1.ll llvm/trunk/test/CodeGen/X86/2006-05-02-InstrSched2.ll llvm/trunk/test/CodeGen/X86/2006-05-11-InstrSched.ll llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll llvm/trunk/test/CodeGen/X86/constant-pool-remat-0.ll llvm/trunk/test/CodeGen/X86/dagcombine-cse.ll llvm/trunk/test/CodeGen/X86/iabs.ll llvm/trunk/test/CodeGen/X86/or-branch.ll llvm/trunk/test/CodeGen/X86/select.ll llvm/trunk/test/CodeGen/X86/setuge.ll llvm/trunk/test/CodeGen/X86/x86-64-mem.ll llvm/trunk/test/CodeGen/X86/zero-remat.ll Modified: llvm/trunk/test/CodeGen/PowerPC/compare-fcmp-ord.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/compare-fcmp-ord.ll?rev=49364&r1=49363&r2=49364&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/compare-fcmp-ord.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/compare-fcmp-ord.ll Mon Apr 7 19:14:17 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=ppc32 | grep or | count 3 +; RUN: llvm-as < %s | llc -march=ppc32 -disable-required-unwind-tables | grep or | count 3 ; This should produce one 'or' or 'cror' instruction per function. define i32 @test(double %x, double %y) nounwind { Modified: llvm/trunk/test/CodeGen/PowerPC/reg-coalesce-simple.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/reg-coalesce-simple.ll?rev=49364&r1=49363&r2=49364&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/reg-coalesce-simple.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/reg-coalesce-simple.ll Mon Apr 7 19:14:17 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=ppc32 | not grep or +; RUN: llvm-as < %s | llc -march=ppc32 -disable-required-unwind-tables | not grep or %struct.foo = type { i32, i32, [0 x i8] } Modified: llvm/trunk/test/CodeGen/PowerPC/rotl-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/rotl-2.ll?rev=49364&r1=49363&r2=49364&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/rotl-2.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/rotl-2.ll Mon Apr 7 19:14:17 2008 @@ -1,6 +1,6 @@ -; RUN: llvm-as < %s | llc -march=ppc32 | grep rlwinm | count 4 -; RUN: llvm-as < %s | llc -march=ppc32 | grep rlwnm | count 2 -; RUN: llvm-as < %s | llc -march=ppc32 | not grep or +; RUN: llvm-as < %s | llc -march=ppc32 -disable-required-unwind-tables | grep rlwinm | count 4 +; RUN: llvm-as < %s | llc -march=ppc32 -disable-required-unwind-tables | grep rlwnm | count 2 +; RUN: llvm-as < %s | llc -march=ppc32 -disable-required-unwind-tables | not grep or define i32 @rotl32(i32 %A, i8 %Amt) nounwind { %shift.upgrd.1 = zext i8 %Amt to i32 ; [#uses=1] Modified: llvm/trunk/test/CodeGen/X86/2006-03-02-InstrSchedBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2006-03-02-InstrSchedBug.ll?rev=49364&r1=49363&r2=49364&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2006-03-02-InstrSchedBug.ll (original) +++ llvm/trunk/test/CodeGen/X86/2006-03-02-InstrSchedBug.ll Mon Apr 7 19:14:17 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=x86 -stats |& \ +; RUN: llvm-as < %s | llc -march=x86 -disable-required-unwind-tables -stats |& \ ; RUN: grep asm-printer | grep 7 define i32 @g(i32 %a, i32 %b) nounwind { Modified: llvm/trunk/test/CodeGen/X86/2006-05-02-InstrSched1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2006-05-02-InstrSched1.ll?rev=49364&r1=49363&r2=49364&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2006-05-02-InstrSched1.ll (original) +++ llvm/trunk/test/CodeGen/X86/2006-05-02-InstrSched1.ll Mon Apr 7 19:14:17 2008 @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | \ -; RUN: llc -march=x86 -relocation-model=static -stats |& \ +; RUN: llc -march=x86 -relocation-model=static -disable-required-unwind-tables -stats |& \ ; RUN: grep asm-printer | grep 14 ; @size20 = external global i32 ; [#uses=1] Modified: llvm/trunk/test/CodeGen/X86/2006-05-02-InstrSched2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2006-05-02-InstrSched2.ll?rev=49364&r1=49363&r2=49364&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2006-05-02-InstrSched2.ll (original) +++ llvm/trunk/test/CodeGen/X86/2006-05-02-InstrSched2.ll Mon Apr 7 19:14:17 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=x86 -stats |& \ +; RUN: llvm-as < %s | llc -march=x86 -stats -disable-required-unwind-tables |& \ ; RUN: grep asm-printer | grep 13 define void @_ZN9__gnu_cxx9hashtableISt4pairIKPKciES3_NS_4hashIS3_EESt10_Select1stIS5_E5eqstrSaIiEE14find_or_insertERKS5__cond_true456.i(i8* %tmp435.i, i32* %tmp449.i.out) nounwind { Modified: llvm/trunk/test/CodeGen/X86/2006-05-11-InstrSched.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2006-05-11-InstrSched.ll?rev=49364&r1=49363&r2=49364&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2006-05-11-InstrSched.ll (original) +++ llvm/trunk/test/CodeGen/X86/2006-05-11-InstrSched.ll Mon Apr 7 19:14:17 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -stats |&\ +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -stats -disable-required-unwind-tables |&\ ; RUN: grep {asm-printer} | grep 32 target datalayout = "e-p:32:32" Modified: llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll?rev=49364&r1=49363&r2=49364&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll (original) +++ llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll Mon Apr 7 19:14:17 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=x86 -mtriple=i686-apple-darwin -enable-eh | grep {isNullOrNil].eh"} | count 2 +; RUN: llvm-as < %s | llc -march=x86 -mtriple=i686-apple-darwin -enable-eh -disable-required-unwind-tables | grep {isNullOrNil].eh"} | count 2 %struct.NSString = type { } %struct._objc__method_prototype_list = type opaque Modified: llvm/trunk/test/CodeGen/X86/constant-pool-remat-0.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/constant-pool-remat-0.ll?rev=49364&r1=49363&r2=49364&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/constant-pool-remat-0.ll (original) +++ llvm/trunk/test/CodeGen/X86/constant-pool-remat-0.ll Mon Apr 7 19:14:17 2008 @@ -1,7 +1,7 @@ ; RUN: llvm-as < %s | llc -march=x86-64 | grep LCPI | count 3 -; RUN: llvm-as < %s | llc -march=x86-64 -stats -info-output-file - | grep asm-printer | grep 6 +; RUN: llvm-as < %s | llc -march=x86-64 -stats -disable-required-unwind-tables -info-output-file - | grep asm-printer | grep 6 ; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep LCPI | count 3 -; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -stats -info-output-file - | grep asm-printer | grep 8 +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -stats -disable-required-unwind-tables -info-output-file - | grep asm-printer | grep 8 declare fastcc float @qux(float %y) Modified: llvm/trunk/test/CodeGen/X86/dagcombine-cse.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/dagcombine-cse.ll?rev=49364&r1=49363&r2=49364&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/dagcombine-cse.ll (original) +++ llvm/trunk/test/CodeGen/X86/dagcombine-cse.ll Mon Apr 7 19:14:17 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -stats |& grep asm-printer | grep 14 +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -disable-required-unwind-tables -stats |& grep asm-printer | grep 14 define i32 @t(i8* %ref_frame_ptr, i32 %ref_frame_stride, i32 %idxX, i32 %idxY) nounwind { entry: Modified: llvm/trunk/test/CodeGen/X86/iabs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/iabs.ll?rev=49364&r1=49363&r2=49364&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/iabs.ll (original) +++ llvm/trunk/test/CodeGen/X86/iabs.ll Mon Apr 7 19:14:17 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=x86-64 -stats |& \ +; RUN: llvm-as < %s | llc -march=x86-64 -stats -disable-required-unwind-tables |& \ ; RUN: grep {6 .*Number of machine instrs printed} ;; Integer absolute value, should produce something at least as good as: Modified: llvm/trunk/test/CodeGen/X86/or-branch.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/or-branch.ll?rev=49364&r1=49363&r2=49364&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/or-branch.ll (original) +++ llvm/trunk/test/CodeGen/X86/or-branch.ll Mon Apr 7 19:14:17 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=x86 | not grep set +; RUN: llvm-as < %s | llc -march=x86 -disable-required-unwind-tables | not grep set define void @foo(i32 %X, i32 %Y, i32 %Z) nounwind { entry: Modified: llvm/trunk/test/CodeGen/X86/select.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/select.ll?rev=49364&r1=49363&r2=49364&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/select.ll (original) +++ llvm/trunk/test/CodeGen/X86/select.ll Mon Apr 7 19:14:17 2008 @@ -1,6 +1,6 @@ -; RUN: llvm-as < %s | llc -march=x86 -mcpu=pentium -; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah -; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah | not grep set +; RUN: llvm-as < %s | llc -march=x86 -mcpu=pentium -disable-required-unwind-tables +; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah -disable-required-unwind-tables +; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah -disable-required-unwind-tables | not grep set define i1 @boolSel(i1 %A, i1 %B, i1 %C) nounwind { %X = select i1 %A, i1 %B, i1 %C ; [#uses=1] Modified: llvm/trunk/test/CodeGen/X86/setuge.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/setuge.ll?rev=49364&r1=49363&r2=49364&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/setuge.ll (original) +++ llvm/trunk/test/CodeGen/X86/setuge.ll Mon Apr 7 19:14:17 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=x86 | not grep set +; RUN: llvm-as < %s | llc -march=x86 -disable-required-unwind-tables | not grep set declare i1 @llvm.isunordered.f32(float, float) Modified: llvm/trunk/test/CodeGen/X86/x86-64-mem.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/x86-64-mem.ll?rev=49364&r1=49363&r2=49364&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/x86-64-mem.ll (original) +++ llvm/trunk/test/CodeGen/X86/x86-64-mem.ll Mon Apr 7 19:14:17 2008 @@ -1,6 +1,6 @@ ; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin -o %t1 -f ; RUN: grep GOTPCREL %t1 | count 4 -; RUN: grep rip %t1 | count 6 +; RUN: grep %%rip %t1 | count 6 ; RUN: grep movq %t1 | count 6 ; RUN: grep leaq %t1 | count 1 ; RUN: llvm-as < %s | \ Modified: llvm/trunk/test/CodeGen/X86/zero-remat.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/zero-remat.ll?rev=49364&r1=49363&r2=49364&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/zero-remat.ll (original) +++ llvm/trunk/test/CodeGen/X86/zero-remat.ll Mon Apr 7 19:14:17 2008 @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | llc -march=x86-64 | grep xor | count 4 -; RUN: llvm-as < %s | llc -march=x86-64 -stats -info-output-file - | grep asm-printer | grep 12 +; RUN: llvm-as < %s | llc -march=x86-64 -stats -disable-required-unwind-tables -info-output-file - | grep asm-printer | grep 12 ; RUN: llvm-as < %s | llc -march=x86 | grep fldz ; RUN: llvm-as < %s | llc -march=x86 | not grep fldl From dalej at apple.com Mon Apr 7 19:14:59 2008 From: dalej at apple.com (Dale Johannesen) Date: Tue, 08 Apr 2008 00:14:59 -0000 Subject: [llvm-commits] [llvm] r49365 - /llvm/trunk/test/CodeGen/PowerPC/fold-li.ll Message-ID: <200804080014.m380Exe6012556@zion.cs.uiuc.edu> Author: johannes Date: Mon Apr 7 19:14:59 2008 New Revision: 49365 URL: http://llvm.org/viewvc/llvm-project?rev=49365&view=rev Log: Missed one. Modified: llvm/trunk/test/CodeGen/PowerPC/fold-li.ll Modified: llvm/trunk/test/CodeGen/PowerPC/fold-li.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/fold-li.ll?rev=49365&r1=49364&r2=49365&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/fold-li.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/fold-li.ll Mon Apr 7 19:14:59 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=ppc32 | \ +; RUN: llvm-as < %s | llc -march=ppc32 -disable-required-unwind-tables | \ ; RUN: grep -v align | not grep li ;; Test that immediates are folded into these instructions correctly. From dalej at apple.com Mon Apr 7 19:37:56 2008 From: dalej at apple.com (Dale Johannesen) Date: Tue, 08 Apr 2008 00:37:56 -0000 Subject: [llvm-commits] [llvm] r49366 - /llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp Message-ID: <200804080037.m380buNB013202@zion.cs.uiuc.edu> Author: johannes Date: Mon Apr 7 19:37:56 2008 New Revision: 49366 URL: http://llvm.org/viewvc/llvm-project?rev=49366&view=rev Log: Handle the situation in 2008-01-25-EmptyFunction.ll correctly when unwind info is being generated. Modified: llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp Modified: llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp?rev=49366&r1=49365&r2=49366&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp Mon Apr 7 19:37:56 2008 @@ -156,17 +156,8 @@ DW.BeginFunction(&MF); } - if (Subtarget->isTargetDarwin()) { - // If the function is empty, then we need to emit *something*. Otherwise, - // the function's label might be associated with something that it wasn't - // meant to be associated with. We emit a noop in this situation. - MachineFunction::iterator I = MF.begin(); - - if (++I == MF.end() && MF.front().empty()) - O << "\tnop\n"; - } - // Print out code for the function. + bool hasAnyRealCode = false; for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); I != E; ++I) { // Print a label for the basic block. @@ -177,10 +168,20 @@ for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end(); II != IE; ++II) { // Print the assembly for the instruction. + if (II->getOpcode() != X86::LABEL) + hasAnyRealCode = true; printMachineInstruction(II); } } + if (Subtarget->isTargetDarwin() && !hasAnyRealCode) { + // If the function is empty, then we need to emit *something*. Otherwise, + // the function's label might be associated with something that it wasn't + // meant to be associated with. We emit a noop in this situation. + // We are assuming inline asms are code. + O << "\tnop\n"; + } + if (TAI->hasDotTypeDotSizeDirective()) O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << "\n"; From dpatel at apple.com Mon Apr 7 21:24:09 2008 From: dpatel at apple.com (Devang Patel) Date: Tue, 08 Apr 2008 02:24:09 -0000 Subject: [llvm-commits] [llvm] r49367 - /llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp Message-ID: <200804080224.m382O9Gb016160@zion.cs.uiuc.edu> Author: dpatel Date: Mon Apr 7 21:24:08 2008 New Revision: 49367 URL: http://llvm.org/viewvc/llvm-project?rev=49367&view=rev Log: Fix insert point handling for multiple return values. Modified: llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp Modified: llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp?rev=49367&r1=49366&r2=49367&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp Mon Apr 7 21:24:08 2008 @@ -117,13 +117,21 @@ if (NumRetVals == 0) ReturnInst::Create(NULL, NewRetBlock); else if (const StructType *STy = dyn_cast(F.getReturnType())) { - Instruction *InsertPt = NewRetBlock->getFirstNonPHI(); + Instruction *InsertPt = NULL; + if (NumRetVals == 0) + InsertPt = NewRetBlock->getFirstNonPHI(); + PHINode *PN = NULL; for (unsigned i = 0; i < NumRetVals; ++i) { - PHINode *PN = PHINode::Create(STy->getElementType(i), "UnifiedRetVal." - + utostr(i), InsertPt); + if (InsertPt) + PN = PHINode::Create(STy->getElementType(i), "UnifiedRetVal." + + utostr(i), InsertPt); + else + PN = PHINode::Create(STy->getElementType(i), "UnifiedRetVal." + + utostr(i), NewRetBlock); Phis.push_back(PN); + InsertPt = PN; } - ReturnInst::Create(&Phis[0], NumRetVals); + ReturnInst::Create(&Phis[0], NumRetVals, NewRetBlock); } else { // If the function doesn't return void... add a PHI node to the block... From clattner at apple.com Mon Apr 7 23:02:11 2008 From: clattner at apple.com (Chris Lattner) Date: Mon, 7 Apr 2008 21:02:11 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r49253 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp In-Reply-To: <7964E68C-9495-4FCE-B978-2EBD1B517DD9@apple.com> References: <200804051841.m35IfRKR008765@zion.cs.uiuc.edu> <200804070928.56685.baldrick@free.fr> <7964E68C-9495-4FCE-B978-2EBD1B517DD9@apple.com> Message-ID: On Apr 7, 2008, at 11:37 AM, Dale Johannesen wrote: >> presumably needs -funwind-tables. In short: Ada doesn't seem to >> need anything >> particularly special here, it's basically the same as Darwin. > > Ok, good. > > It's certainly possible to compile some files with -funwind-tables and > others without. > Unlike exceptions, however, I can't think of a case where this happens > or is useful. > Perhaps an llc flag is good enough; the default should be not to prune > unwinding > info, however, which is conservatively correct. I'll look at that. I think this is a great solution guys, -Chris From sabre at nondot.org Tue Apr 8 00:49:09 2008 From: sabre at nondot.org (Chris Lattner) Date: Tue, 08 Apr 2008 05:49:09 -0000 Subject: [llvm-commits] [llvm] r49371 - /llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp Message-ID: <200804080549.m385n9nC021689@zion.cs.uiuc.edu> Author: lattner Date: Tue Apr 8 00:49:09 2008 New Revision: 49371 URL: http://llvm.org/viewvc/llvm-project?rev=49371&view=rev Log: silence warning when assertions are disabled. Modified: llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp Modified: llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp?rev=49371&r1=49370&r2=49371&view=diff ============================================================================== --- llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp (original) +++ llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp Tue Apr 8 00:49:09 2008 @@ -204,7 +204,7 @@ waitFor = 0; int result = pthread_cond_broadcast( &condition ); - assert( result == 0 ); + assert(result == 0); result=result; } size_t n; From baldrick at free.fr Tue Apr 8 02:16:00 2008 From: baldrick at free.fr (Duncan Sands) Date: Tue, 8 Apr 2008 09:16:00 +0200 Subject: [llvm-commits] [llvm] r49361 - in /llvm/trunk: include/llvm/Target/TargetOptions.h lib/CodeGen/DwarfWriter.cpp lib/Target/PowerPC/PPCRegisterInfo.cpp lib/Target/TargetMachine.cpp lib/Target/X86/X86RegisterInfo.cpp In-Reply-To: <200804080010.m380AOMa012356@zion.cs.uiuc.edu> References: <200804080010.m380AOMa012356@zion.cs.uiuc.edu> Message-ID: <200804080916.03997.baldrick@free.fr> Hi Dale, looks good to me except for the name. > + cl::opt > + DisableUnwindTables("disable-required-unwind-tables", > + cl::desc("Do not require unwinding info for all functions"), > + cl::location(UnwindTablesOptional), > + cl::init(false)); How about "discard-unwind-tables" with comment "Only generate unwind tables for functions that require them". Ciao, Duncan. From baldrick at free.fr Tue Apr 8 01:58:56 2008 From: baldrick at free.fr (Duncan Sands) Date: Tue, 8 Apr 2008 08:58:56 +0200 Subject: [llvm-commits] =?ansi_x3.4-1968?q?=5Bllvm-gcc-4=2E2=5D_r49171_-_i?= =?ansi_x3.4-1968?q?n=09/llvm-gcc-4=2E2/trunk/gcc=3A_llvm-convert=2Ecpp_ll?= =?ansi_x3.4-1968?q?vm-types=2Ecpp?= In-Reply-To: <5939073A-D1EF-43B1-B57B-AB43293BE324@apple.com> References: <200804031727.m33HRR6h004565@zion.cs.uiuc.edu> <200804072107.47358.baldrick@free.fr> <5939073A-D1EF-43B1-B57B-AB43293BE324@apple.com> Message-ID: <200804080858.56612.baldrick@free.fr> > >> I think a point I made earlier has gotten lost: it is not possible > >> to > >> handle this without changing the linker. > > > > I've created PR2205 for this. > > What about the case when system linker (e.g. gnu ld or darwin ld on > Mac OS X) ? Do you mean when doing LTO? Presumably it will use the same code as llvm-link, but in case it doesn't I've added a note to the PR. Ciao, Duncan. From baldrick at free.fr Tue Apr 8 02:23:58 2008 From: baldrick at free.fr (Duncan Sands) Date: Tue, 08 Apr 2008 07:23:58 -0000 Subject: [llvm-commits] [llvm] r49373 - in /llvm/trunk: include/llvm/Function.h lib/VMCore/Function.cpp Message-ID: <200804080723.m387NwaK026637@zion.cs.uiuc.edu> Author: baldrick Date: Tue Apr 8 02:23:58 2008 New Revision: 49373 URL: http://llvm.org/viewvc/llvm-project?rev=49373&view=rev Log: Convenience method for setting the nounwind attribute for a function. Modified: llvm/trunk/include/llvm/Function.h llvm/trunk/lib/VMCore/Function.cpp Modified: llvm/trunk/include/llvm/Function.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Function.h?rev=49373&r1=49372&r2=49373&view=diff ============================================================================== --- llvm/trunk/include/llvm/Function.h (original) +++ llvm/trunk/include/llvm/Function.h Tue Apr 8 02:23:58 2008 @@ -178,6 +178,7 @@ /// @brief Determine if the function cannot return. bool doesNotReturn() const { return paramHasAttr(0, ParamAttr::NoReturn); } + void setDoesNotThrow(bool doesNotThrow = true); /// @brief Determine if the function cannot unwind. bool doesNotThrow() const { Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=49373&r1=49372&r2=49373&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Tue Apr 8 02:23:58 2008 @@ -219,6 +219,15 @@ BasicBlocks.clear(); // Delete all basic blocks... } +void Function::setDoesNotThrow(bool doesNotThrow) { + PAListPtr PAL = getParamAttrs(); + if (doesNotThrow) + PAL = PAL.addAttr(0, ParamAttr::NoUnwind); + else + PAL = PAL.removeAttr(0, ParamAttr::NoUnwind); + setParamAttrs(PAL); +} + // Maintain the collector name for each function in an on-the-side table. This // saves allocating an additional word in Function for programs which do not use // GC (i.e., most programs) at the cost of increased overhead for clients which From dpatel at apple.com Tue Apr 8 02:30:13 2008 From: dpatel at apple.com (Devang Patel) Date: Tue, 08 Apr 2008 07:30:13 -0000 Subject: [llvm-commits] [llvm] r49374 - /llvm/trunk/include/llvm/Support/LLVMBuilder.h Message-ID: <200804080730.m387UEKe026878@zion.cs.uiuc.edu> Author: dpatel Date: Tue Apr 8 02:30:13 2008 New Revision: 49374 URL: http://llvm.org/viewvc/llvm-project?rev=49374&view=rev Log: Add multiple value return instruction constructor. Modified: llvm/trunk/include/llvm/Support/LLVMBuilder.h Modified: llvm/trunk/include/llvm/Support/LLVMBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/LLVMBuilder.h?rev=49374&r1=49373&r2=49374&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/LLVMBuilder.h (original) +++ llvm/trunk/include/llvm/Support/LLVMBuilder.h Tue Apr 8 02:30:13 2008 @@ -96,6 +96,10 @@ ReturnInst *CreateRet(Value *V) { return Insert(ReturnInst::Create(V)); } + + ReturnInst *CreateRet(Value * const* retVals, unsigned N) { + return Insert(ReturnInst::Create(retVals, N)); + } /// CreateBr - Create an unconditional 'br label X' instruction. BranchInst *CreateBr(BasicBlock *Dest) { From baldrick at free.fr Tue Apr 8 03:07:01 2008 From: baldrick at free.fr (Duncan Sands) Date: Tue, 08 Apr 2008 08:07:01 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49375 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp llvm-types.cpp Message-ID: <200804080807.m38871Hc003554@zion.cs.uiuc.edu> Author: baldrick Date: Tue Apr 8 03:07:01 2008 New Revision: 49375 URL: http://llvm.org/viewvc/llvm-project?rev=49375&view=rev Log: If compiling without -fexceptions, mark function bodies as nounwind but not function declarations. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=49375&r1=49374&r2=49375&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Apr 8 03:07:01 2008 @@ -642,6 +642,10 @@ if (DECL_ATTRIBUTES(FnDecl)) AddAnnotateAttrsToGlobal(Fn, FnDecl); + // Mark the function "nounwind" if not doing exception handling. + if (!flag_exceptions) + Fn->setDoesNotThrow(); + // Create a new basic block for the function. Builder.SetInsertPoint(BasicBlock::Create("entry", Fn)); Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=49375&r1=49374&r2=49375&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Tue Apr 8 03:07:01 2008 @@ -1054,9 +1054,6 @@ // Compute whether the result needs to be zext or sext'd. ParameterAttributes RAttributes = HandleArgumentExtension(ReturnType); - // Make sure all functions are marked nounwind if we aren't using exceptions. - if (!flag_exceptions && !flag_unwind_tables) - RAttributes |= ParamAttr::NoUnwind; if (RAttributes != ParamAttr::None) Attrs.push_back(ParamAttrsWithIndex::get(0, RAttributes)); @@ -1122,9 +1119,7 @@ RAttributes |= ParamAttr::NoReturn; // Check for 'nounwind' function attribute. - // When flag_exceptions is not set (it is set by default in C++/ObjC++), - // don't unwind anything. - if ((flags & ECF_NOTHROW) || (!flag_exceptions && !flag_unwind_tables)) + if (flags & ECF_NOTHROW) RAttributes |= ParamAttr::NoUnwind; // Check for 'readnone' function attribute. From baldrick at free.fr Tue Apr 8 04:39:38 2008 From: baldrick at free.fr (Duncan Sands) Date: Tue, 08 Apr 2008 09:39:38 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49376 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Message-ID: <200804080939.m389dcbT007091@zion.cs.uiuc.edu> Author: baldrick Date: Tue Apr 8 04:39:36 2008 New Revision: 49376 URL: http://llvm.org/viewvc/llvm-project?rev=49376&view=rev Log: Don't run the prune-eh pass if compiled without -fexceptions: there is nothing for it to do. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=49376&r1=49375&r2=49376&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Tue Apr 8 04:39:36 2008 @@ -353,7 +353,7 @@ // DISABLE PREDSIMPLIFY UNTIL PR967 is fixed. //PM->add(createPredicateSimplifierPass()); // Canonicalize registers PM->add(createCFGSimplificationPass()); // Clean up after IPCP & DAE - if (flag_unit_at_a_time) + if (flag_unit_at_a_time && flag_exceptions) PM->add(createPruneEHPass()); // Remove dead EH info if (optimize > 1) { From baldrick at free.fr Tue Apr 8 05:24:14 2008 From: baldrick at free.fr (Duncan Sands) Date: Tue, 08 Apr 2008 10:24:14 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49377 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <200804081024.m38AOE9q008443@zion.cs.uiuc.edu> Author: baldrick Date: Tue Apr 8 05:24:11 2008 New Revision: 49377 URL: http://llvm.org/viewvc/llvm-project?rev=49377&view=rev Log: Add TODO item. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=49377&r1=49376&r2=49377&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Apr 8 05:24:11 2008 @@ -1105,6 +1105,7 @@ if (Ty == Type::Int1Ty && CI->getOperand(0)->getType() == Type::Int1Ty) return CI->getOperand(0); // Do an end-run around the builder's folding logic. + // TODO: introduce a new builder class that does target specific folding. Value *Result = Builder.Insert(CastInst::create(Instruction::CastOps(opcode), V, Ty, V->getNameStart())); From ggreif at gmail.com Tue Apr 8 07:35:08 2008 From: ggreif at gmail.com (Gabor Greif) Date: Tue, 08 Apr 2008 12:35:08 -0000 Subject: [llvm-commits] [llvm] r49378 - /llvm/branches/ggreif/use-diet/ Message-ID: <200804081235.m38CZ8rc012146@zion.cs.uiuc.edu> Author: ggreif Date: Tue Apr 8 07:35:05 2008 New Revision: 49378 URL: http://llvm.org/viewvc/llvm-project?rev=49378&view=rev Log: remove branch to start anew Removed: llvm/branches/ggreif/use-diet/ From ggreif at gmail.com Tue Apr 8 07:41:38 2008 From: ggreif at gmail.com (Gabor Greif) Date: Tue, 08 Apr 2008 12:41:38 -0000 Subject: [llvm-commits] [llvm] r49379 - /llvm/branches/ggreif/use-diet/ Message-ID: <200804081241.m38CfcSs012339@zion.cs.uiuc.edu> Author: ggreif Date: Tue Apr 8 07:41:37 2008 New Revision: 49379 URL: http://llvm.org/viewvc/llvm-project?rev=49379&view=rev Log: start anew Added: llvm/branches/ggreif/use-diet/ - copied from r49378, llvm/trunk/ From ggreif at gmail.com Tue Apr 8 08:35:26 2008 From: ggreif at gmail.com (Gabor Greif) Date: Tue, 08 Apr 2008 13:35:26 -0000 Subject: [llvm-commits] [llvm] r49380 - in /llvm/branches/ggreif/use-diet: include/llvm/Use.h include/llvm/User.h lib/VMCore/Use.cpp Message-ID: <200804081335.m38DZQVF013815@zion.cs.uiuc.edu> Author: ggreif Date: Tue Apr 8 08:35:24 2008 New Revision: 49380 URL: http://llvm.org/viewvc/llvm-project?rev=49380&view=rev Log: re-merge using to pick up changes on the old branch Added: llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp - copied unchanged from r49377, llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h llvm/branches/ggreif/use-diet/include/llvm/User.h Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Use.h?rev=49380&r1=49379&r2=49380&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Use.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Use.h Tue Apr 8 08:35:24 2008 @@ -41,7 +41,7 @@ if (Val) removeFromList(); } - /// Default ctor - This leaves the Use completely unitialized. The only thing + /// Default ctor - This leaves the Use completely uninitialized. The only thing /// that is valid to do with this use is to call the "init" method. inline Use() : Val(0) {} @@ -49,6 +49,8 @@ operator Value*() const { return Val; } Value *get() const { return Val; } User *getUser() const { return U; } + const Use* getImpliedUser() const; + void initTags(Use *Start, Use *Stop, ptrdiff_t Done = 0); inline void set(Value *Val); Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49380&r1=49379&r2=49380&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/User.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/User.h Tue Apr 8 08:35:24 2008 @@ -23,6 +23,171 @@ namespace llvm { +/*============================================================================== + + + ----------------------------------------------------------------- + --- Interaction and relationship between User and Use objects --- + ----------------------------------------------------------------- + + +A subclass of User can choose between incorporating its Use objects +or refer to them out-of-line by means of a pointer. A mixed variant +(some Uses inline others hung off) is impractical and breaks the invariant +that the Use objects belonging to the same User form a contiguous array. + +We have 2 different layouts in the User (sub)classes: + +Layout a) +The Use object(s) are inside (resp. at fixed offset) of the User +object and there are a fixed number of them. + +Layout b) +The Use object(s) are referenced by a pointer to an +array from the User object and there may be a variable +number of them. + +Initially each layout will possess a direct pointer to the +start of the array of Uses. Though not mandatory for layout a), +we stick to this redundancy for the sake of simplicity. +The User object will also store the number of Use objects it +has. (Theoretically this information can also be calculated +given the scheme presented below.) + +Special forms of allocation operators (operator new) +will enforce the following memory layouts: + + +# Layout a) will be modelled by prepending the User object +# by the Use[] array. +# +# ...---.---.---.---.-------... +# | V | V | V | V | User +# '''---'---'---'---'-------''' + + +# Layout b) will be modelled by pointing at the Use[] array. +# +# .-------... +# | User +# '-------''' +# | +# v +# .---.---.---.---... +# | V | V | V | V | +# '---'---'---'---''' + + (In the above figures 'V' stands for the Value* that + is stored in each Use object) + + +Since the Use objects will be deprived of the direct pointer to +their User objects, there must be a fast and exact method to +recover it. This is accomplished by the following scheme: + +A bit-encoding in the 2 LSBits of the Use::Val will allow to find the +start of the User object: + +00 --> binary digit 0 +01 --> binary digit 1 +10 --> stop and calc (s) +11 --> full stop (S) + +Given a Use*, all we have to do is to walk till we get +a stop and we either have a User immediately behind or +we have to walk to the next stop picking up digits +and calculating the offset: + +.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---------------- +| 1 | s | 1 | 0 | 1 | 0 | s | 1 | 1 | 0 | s | 1 | 1 | s | 1 | S | User (or User*) +'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---------------- + |+15 |+10 |+6 |+3 |+1 + | | | | |__> + | | | |__________> + | | |______________________> + | |______________________________________> + |__________________________________________________________> + + +Only the significant number of bits need to be stored between the +stops, so that the worst case is 21 memory accesses when there are +1000 Use objects. + +The following literate Haskell fragment demonstrates the concept: + +> import Test.QuickCheck +> +> digits :: Int -> [Char] -> [Char] +> digits 0 acc = '0' : acc +> digits 1 acc = '1' : acc +> digits n acc = digits (n `div` 2) $ digits (n `mod` 2) acc +> +> dist :: Int -> [Char] -> [Char] +> dist 0 [] = ['S'] +> dist 0 acc = acc +> dist 1 acc = let r = dist 0 acc in 's' : digits (length r) r +> dist n acc = dist (n - 1) $ dist 1 acc +> +> takeLast n ss = reverse $ take n $ reverse ss +> +> test = takeLast 40 $ dist 20 [] +> + +Printing gives: "1s100000s11010s10100s1111s1010s110s11s1S" + +The reverse algorithm computes the +length of the string just by examining +a certain prefix: + +> pref :: [Char] -> Int +> pref "S" = 1 +> pref ('s':rest) = decode 1 0 rest +> pref (_:rest) = 1 + pref rest +> +> decode walk acc ('0':rest) = decode (walk + 1) (acc * 2) rest +> decode walk acc ('1':rest) = decode (walk + 1) (acc * 2 + 1) rest +> decode walk acc _ = walk + acc +> + +Now, as expected, printing gives 40. + +We can quickCheck this with following property: + +> testcase = dist 2000 [] +> testcaseLength = length testcase +> +> identityProp n = n > 0 && n <= testcaseLength ==> length arr == pref arr +> where arr = takeLast n testcase + +As expected gives: + +*Main> quickCheck identityProp +OK, passed 100 tests. + +Let's be a bit more exhaustive: + +> +> deepCheck p = check (defaultConfig { configMaxTest = 500 }) p +> + +And here is the result of : + +*Main> deepCheck identityProp +OK, passed 500 tests. + + +To maintain the invariant that the 2 LSBits of each Value* in Use +never change after being set up, setters of Use::Val must re-tag the +new Value* on every modification. Accordingly getters must strip the +tag bits. + +For layout b) instead of the User we will find a pointer (with LSBit set). +Following this pointer brings us to the User. A portable trick will ensure +that the first bytes of User (if interpreted as a pointer) will never have +the LSBit set. + +==============================================================================*/ + class User : public Value { User(const User &); // Do not implement void *operator new(size_t); // Do not implement From ggreif at gmail.com Tue Apr 8 09:51:33 2008 From: ggreif at gmail.com (Gabor Greif) Date: Tue, 08 Apr 2008 14:51:33 -0000 Subject: [llvm-commits] [llvm] r49381 - /llvm/branches/ggreif/use-diet/lib/Support/MemoryBuffer.cpp Message-ID: <200804081451.m38EpX76016568@zion.cs.uiuc.edu> Author: ggreif Date: Tue Apr 8 09:51:31 2008 New Revision: 49381 URL: http://llvm.org/viewvc/llvm-project?rev=49381&view=rev Log: unbreak solaris build: fcntl.h is standard Modified: llvm/branches/ggreif/use-diet/lib/Support/MemoryBuffer.cpp Modified: llvm/branches/ggreif/use-diet/lib/Support/MemoryBuffer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Support/MemoryBuffer.cpp?rev=49381&r1=49380&r2=49381&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Support/MemoryBuffer.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/Support/MemoryBuffer.cpp Tue Apr 8 09:51:31 2008 @@ -26,11 +26,10 @@ #if !defined(_MSC_VER) && !defined(__MINGW32__) #include #include -#include #else #include -#include #endif +#include using namespace llvm; //===----------------------------------------------------------------------===// From dalej at apple.com Tue Apr 8 10:11:07 2008 From: dalej at apple.com (Dale Johannesen) Date: Tue, 8 Apr 2008 08:11:07 -0700 Subject: [llvm-commits] [llvm] r49361 - in /llvm/trunk: include/llvm/Target/TargetOptions.h lib/CodeGen/DwarfWriter.cpp lib/Target/PowerPC/PPCRegisterInfo.cpp lib/Target/TargetMachine.cpp lib/Target/X86/X86RegisterInfo.cpp In-Reply-To: <200804080916.03997.baldrick@free.fr> References: <200804080010.m380AOMa012356@zion.cs.uiuc.edu> <200804080916.03997.baldrick@free.fr> Message-ID: <83BF0839-F328-48CE-87EE-9DEC1F72057D@apple.com> On Apr 8, 2008, at 12:16 AM, Duncan Sands wrote: > Hi Dale, looks good to me except for the name. > >> + cl::opt >> + DisableUnwindTables("disable-required-unwind-tables", >> + cl::desc("Do not require unwinding info for all >> functions"), >> + cl::location(UnwindTablesOptional), >> + cl::init(false)); > > How about "discard-unwind-tables" with comment > "Only generate unwind tables for functions that require them". "discard" implies discarding all of them which isn't necessarily what happens. Is your objection to the length, or the meaning, or what? From ggreif at gmail.com Tue Apr 8 10:22:45 2008 From: ggreif at gmail.com (Gabor Greif) Date: Tue, 08 Apr 2008 15:22:45 -0000 Subject: [llvm-commits] [llvm] r49382 - /llvm/trunk/test/Transforms/DecomposeMultiDimRefs/ Message-ID: <200804081522.m38FMkPk017702@zion.cs.uiuc.edu> Author: ggreif Date: Tue Apr 8 10:22:41 2008 New Revision: 49382 URL: http://llvm.org/viewvc/llvm-project?rev=49382&view=rev Log: merge r48768 from branches/ggreif/parallelized-test Removed: llvm/trunk/test/Transforms/DecomposeMultiDimRefs/ From dpatel at apple.com Tue Apr 8 11:15:02 2008 From: dpatel at apple.com (Devang Patel) Date: Tue, 8 Apr 2008 09:15:02 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r49171 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp llvm-types.cpp In-Reply-To: <200804080858.56612.baldrick@free.fr> References: <200804031727.m33HRR6h004565@zion.cs.uiuc.edu> <200804072107.47358.baldrick@free.fr> <5939073A-D1EF-43B1-B57B-AB43293BE324@apple.com> <200804080858.56612.baldrick@free.fr> Message-ID: On Apr 7, 2008, at 11:58 PM, Duncan Sands wrote: >>>> I think a point I made earlier has gotten lost: it is not possible >>>> to >>>> handle this without changing the linker. >>> >>> I've created PR2205 for this. >> >> What about the case when system linker (e.g. gnu ld or darwin ld on >> Mac OS X) ? > > Do you mean when doing LTO? No. I mean, when two separate source files with conflicting (or rather not matching) declarations are compiled into the native .o files and linked together using system linker. - Devang > Presumably it will use the same code as > llvm-link, but in case it doesn't I've added a note to the PR. From ggreif at gmail.com Tue Apr 8 11:16:08 2008 From: ggreif at gmail.com (Gabor Greif) Date: Tue, 08 Apr 2008 16:16:08 -0000 Subject: [llvm-commits] [llvm] r49383 - in /llvm/branches/ggreif/use-diet/include/llvm: Use.h User.h Message-ID: <200804081616.m38GG8pl005974@zion.cs.uiuc.edu> Author: ggreif Date: Tue Apr 8 11:16:07 2008 New Revision: 49383 URL: http://llvm.org/viewvc/llvm-project?rev=49383&view=rev Log: actually allocate storage for Uses Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h llvm/branches/ggreif/use-diet/include/llvm/User.h Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Use.h?rev=49383&r1=49382&r2=49383&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Use.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Use.h Tue Apr 8 11:16:07 2008 @@ -50,7 +50,7 @@ Value *get() const { return Val; } User *getUser() const { return U; } const Use* getImpliedUser() const; - void initTags(Use *Start, Use *Stop, ptrdiff_t Done = 0); + static void initTags(Use *Start, Use *Stop, ptrdiff_t Done = 0); inline void set(Value *Val); Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49383&r1=49382&r2=49383&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/User.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/User.h Tue Apr 8 11:16:07 2008 @@ -204,8 +204,12 @@ /// unsigned NumOperands; - void *operator new(size_t s, unsigned) { - return ::operator new(s); + void *operator new(size_t s, unsigned Us) { + void *Storage = ::operator new(s + sizeof(Use) * Us); + Use *Start = static_cast(Storage); + Use *End = Start + Us; + Use::initTags(Start, End); + return End; } User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps) : Value(Ty, vty), OperandList(OpList), NumOperands(NumOps) {} From ggreif at gmail.com Tue Apr 8 11:17:12 2008 From: ggreif at gmail.com (Gabor Greif) Date: Tue, 08 Apr 2008 16:17:12 -0000 Subject: [llvm-commits] [llvm] r49384 - /llvm/branches/ggreif/use-diet/test/Transforms/DecomposeMultiDimRefs/ Message-ID: <200804081617.m38GHCAE006018@zion.cs.uiuc.edu> Author: ggreif Date: Tue Apr 8 11:17:11 2008 New Revision: 49384 URL: http://llvm.org/viewvc/llvm-project?rev=49384&view=rev Log: merge r48768 from branches/ggreif/parallelized-test Removed: llvm/branches/ggreif/use-diet/test/Transforms/DecomposeMultiDimRefs/ From dpatel at apple.com Tue Apr 8 11:46:16 2008 From: dpatel at apple.com (Devang Patel) Date: Tue, 08 Apr 2008 16:46:16 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49385 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <200804081646.m38GkGhm007108@zion.cs.uiuc.edu> Author: dpatel Date: Tue Apr 8 11:46:16 2008 New Revision: 49385 URL: http://llvm.org/viewvc/llvm-project?rev=49385&view=rev Log: Construct multiple value return instruction. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=49385&r1=49384&r2=49385&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Apr 8 11:46:16 2008 @@ -743,30 +743,47 @@ // Insert the return block at the end of the function. EmitBlock(ReturnBB); - Value *RetVal = 0; + SmallVector RetVals; + // If the function returns a value, get it into a register and return it now. if (Fn->getReturnType() != Type::VoidTy) { if (!isAggregateTreeType(TREE_TYPE(DECL_RESULT(FnDecl)))) { // If the DECL_RESULT is a scalar type, just load out the return value // and return it. tree TreeRetVal = DECL_RESULT(FnDecl); - RetVal = Builder.CreateLoad(DECL_LLVM(TreeRetVal), "retval"); + Value *RetVal = Builder.CreateLoad(DECL_LLVM(TreeRetVal), "retval"); bool RetValSigned = !TYPE_UNSIGNED(TREE_TYPE(TreeRetVal)); Instruction::CastOps opcode = CastInst::getCastOpcode( RetVal, RetValSigned, Fn->getReturnType(), RetValSigned); RetVal = CastToType(opcode, RetVal, Fn->getReturnType()); + RetVals.push_back(RetVal); } else { - // Otherwise, this aggregate result must be something that is returned in - // a scalar register for this target. We must bit convert the aggregate - // to the specified scalar type, which we do by casting the pointer and - // loading. - RetVal = BitCastToType(DECL_LLVM(DECL_RESULT(FnDecl)), - PointerType::getUnqual(Fn->getReturnType())); - RetVal = Builder.CreateLoad(RetVal, "retval"); + Value *RetVal = DECL_LLVM(DECL_RESULT(FnDecl)); + if (const StructType *STy = dyn_cast(Fn->getReturnType())) { + // Handle multiple return values + unsigned NumElements = STy->getNumElements(); + for (unsigned i = 0; i < NumElements; i++) { + Value *GEP = Builder.CreateStructGEP(RetVal, i, "mrv_idx"); + Value *RetVal = Builder.CreateLoad(GEP, "mrv"); + RetVals.push_back(RetVal); + } + } else { + // Otherwise, this aggregate result must be something that is returned in + // a scalar register for this target. We must bit convert the aggregate + // to the specified scalar type, which we do by casting the pointer and + // loading. + RetVal = BitCastToType(DECL_LLVM(DECL_RESULT(FnDecl)), + PointerType::getUnqual(Fn->getReturnType())); + RetVal = Builder.CreateLoad(RetVal, "retval"); + RetVals.push_back(RetVal); + } } } if (TheDebugInfo) TheDebugInfo->EmitRegionEnd(Fn, Builder.GetInsertBlock()); - Builder.CreateRet(RetVal); + if (RetVals.empty()) + Builder.CreateRetVoid(); + else + Builder.CreateRet(&RetVals[0], RetVals.size()); // Emit pending exception handling code. EmitLandingPads(); From dpatel at apple.com Tue Apr 8 11:48:04 2008 From: dpatel at apple.com (Devang Patel) Date: Tue, 08 Apr 2008 16:48:04 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49386 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <200804081648.m38Gm4vW007166@zion.cs.uiuc.edu> Author: dpatel Date: Tue Apr 8 11:48:04 2008 New Revision: 49386 URL: http://llvm.org/viewvc/llvm-project?rev=49386&view=rev Log: Keep track of calls that return multiple values. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=49386&r1=49385&r2=49386&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Apr 8 11:48:04 2008 @@ -2311,6 +2311,7 @@ Value *TheValue; MemRef RetBuf; bool isShadowRet; + bool isAggrRet; FunctionCallArgumentConversion(SmallVector &ops, const FunctionType *FnTy, @@ -2318,7 +2319,8 @@ bool ReturnSlotOpt, LLVMFoldingBuilder &b) : CallOperands(ops), FTy(FnTy), DestLoc(destloc), - useReturnSlot(ReturnSlotOpt), Builder(b), isShadowRet(false) { } + useReturnSlot(ReturnSlotOpt), Builder(b), isShadowRet(false), + isAggrRet(false) { } // Push the address of an argument. void pushAddress(Value *Loc) { @@ -2367,6 +2369,7 @@ } bool isShadowReturn() { return isShadowRet; } + bool isAggrReturn() { return isAggrRet; } // EmitShadowResult - If the return result was redirected to a buffer, // emit it now. @@ -2406,6 +2409,7 @@ /// returns an aggregate value using multiple return values. void HandleAggregateResultAsAggregate(const Type *AggrTy) { // There is nothing to do here. + isAggrRet = true; } /// HandleAggregateShadowArgument - This callback is invoked if the function From criswell at uiuc.edu Tue Apr 8 11:49:42 2008 From: criswell at uiuc.edu (John Criswell) Date: Tue, 08 Apr 2008 16:49:42 -0000 Subject: [llvm-commits] [poolalloc] r49387 - in /poolalloc/trunk: include/poolalloc/PoolAllocate.h lib/PoolAllocate/PASimple.cpp lib/PoolAllocate/PoolAllocate.cpp Message-ID: <200804081649.m38Gng91007221@zion.cs.uiuc.edu> Author: criswell Date: Tue Apr 8 11:49:41 2008 New Revision: 49387 URL: http://llvm.org/viewvc/llvm-project?rev=49387&view=rev Log: Fixed linking errors with PoolAllocateGroup analysis group. This required defining all virtual methods in the PoolAllocateGroup class. Added some macros which should force linking of most PoolAllocate classes. Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h poolalloc/trunk/lib/PoolAllocate/PASimple.cpp poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/poolalloc/PoolAllocate.h?rev=49387&r1=49386&r2=49387&view=diff ============================================================================== --- poolalloc/trunk/include/poolalloc/PoolAllocate.h (original) +++ poolalloc/trunk/include/poolalloc/PoolAllocate.h Tue Apr 8 11:49:41 2008 @@ -109,26 +109,34 @@ } // end PA namespace -class PoolAllocateGroup : public ImmutablePass { +class PoolAllocateGroup { +private: + EquivClassGraphs *ECGraphs; + public: static char ID; - virtual PA::FuncInfo *getFuncInfo(Function &F); - virtual PA::FuncInfo *getFuncInfoOrClone(Function &F); - virtual DSGraph & getDSGraph (const Function & F) const; + virtual ~PoolAllocateGroup () {} + virtual PA::FuncInfo *getFuncInfo(Function &F) { return 0;} + virtual PA::FuncInfo *getFuncInfoOrClone(Function &F) {return 0;} + virtual DSGraph & getDSGraph (const Function & F) const { + return ECGraphs->getDSGraph (F); + } - virtual DSGraph & getGlobalsGraph () const; + virtual DSGraph & getGlobalsGraph () const { + return ECGraphs->getGlobalsGraph (); + } - virtual Value * getPool (const DSNode * N, Function & F); + virtual Value * getPool (const DSNode * N, Function & F) {return 0;} - virtual Value * getGlobalPool (const DSNode * Node); + virtual Value * getGlobalPool (const DSNode * Node) {return 0;} - virtual CompleteBUDataStructures::callee_iterator callee_begin (CallInst *CI); - virtual CompleteBUDataStructures::callee_iterator callee_end (CallInst *CI); + virtual CompleteBUDataStructures::callee_iterator callee_begin (CallInst *CI) { return ECGraphs->callee_begin(CI);} + virtual CompleteBUDataStructures::callee_iterator callee_end (CallInst *CI) { return ECGraphs->callee_end(CI);} }; /// PoolAllocate - The main pool allocation pass /// -class PoolAllocate : public ModulePass { +class PoolAllocate : public ModulePass , public PoolAllocateGroup { /// PassAllArguments - If set to true, we should pass pool descriptor /// arguments into any function that loads or stores to a pool, in addition to /// those functions that allocate or deallocate. See also the @@ -379,4 +387,8 @@ }; } +FORCE_DEFINING_FILE_TO_BE_LINKED(PoolAllocateGroup) +FORCE_DEFINING_FILE_TO_BE_LINKED(PoolAllocateSimple) +FORCE_DEFINING_FILE_TO_BE_LINKED(PoolAllocate) + #endif Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PASimple.cpp?rev=49387&r1=49386&r2=49387&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PASimple.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Tue Apr 8 11:49:41 2008 @@ -47,7 +47,7 @@ RegisterPass X("poolalloc-simple", "Pool allocate everything into a single global pool"); - RegisterAnalysisGroup PAGroup1(X); + RegisterAnalysisGroup PAGroup1(X); } static inline Value * @@ -276,3 +276,4 @@ return GV; } +DEFINING_FILE_FOR(PoolAllocateSimple) Modified: poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp?rev=49387&r1=49386&r2=49387&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Tue Apr 8 11:49:41 2008 @@ -986,3 +986,7 @@ InitializeAndDestroyPool(F, Node, PoolDescriptors, PoolUses, PoolFrees); } } + +DEFINING_FILE_FOR(PoolAllocateGroup) +DEFINING_FILE_FOR(PoolAllocate) + From nicolas.geoffray at lip6.fr Tue Apr 8 12:06:22 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 08 Apr 2008 17:06:22 -0000 Subject: [llvm-commits] [vmkit] r49388 - in /vmkit/trunk: include/mvm/ include/mvm/Threads/ lib/JnJVM/ lib/JnJVM/Classpath/ lib/JnJVM/VMCore/ lib/Mvm/ lib/Mvm/Allocator/ lib/Mvm/CommonThread/ lib/Mvm/GCMmap2/ lib/N3/ lib/N3/VMCore/ Message-ID: <200804081706.m38H6ONr007829@zion.cs.uiuc.edu> Author: geoffray Date: Tue Apr 8 12:06:22 2008 New Revision: 49388 URL: http://llvm.org/viewvc/llvm-project?rev=49388&view=rev Log: Many cleanups: - Use -DMULTIPLE_VM to run isolates - Fix LLVM include list in .h files - Code cleanup - 80-Col violation - Remove unused file VMLet.h Removed: vmkit/trunk/include/mvm/VMLet.h Modified: vmkit/trunk/include/mvm/JIT.h vmkit/trunk/include/mvm/Object.h vmkit/trunk/include/mvm/Threads/Thread.h vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClassLoader.cpp vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp vmkit/trunk/lib/JnJVM/Classpath/Makefile.am vmkit/trunk/lib/JnJVM/Main.cpp vmkit/trunk/lib/JnJVM/Makefile.am vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h vmkit/trunk/lib/JnJVM/VMCore/Makefile.am vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp vmkit/trunk/lib/Mvm/Allocator/Makefile.am vmkit/trunk/lib/Mvm/CommonThread/Makefile.am vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h vmkit/trunk/lib/Mvm/JIT.cpp vmkit/trunk/lib/Mvm/Main.cpp vmkit/trunk/lib/Mvm/Makefile.am vmkit/trunk/lib/Mvm/Object.cpp vmkit/trunk/lib/Mvm/Sigsegv.cpp vmkit/trunk/lib/N3/Main.cpp vmkit/trunk/lib/N3/Makefile.am vmkit/trunk/lib/N3/VMCore/Makefile.am vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp vmkit/trunk/lib/N3/VMCore/VMThread.cpp vmkit/trunk/lib/N3/VMCore/VMThread.h Modified: vmkit/trunk/include/mvm/JIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/include/mvm/JIT.h (original) +++ vmkit/trunk/include/mvm/JIT.h Tue Apr 8 12:06:22 2008 @@ -96,11 +96,10 @@ extern llvm::ExecutionEngine* executionEngine; extern uint64 getTypeSize(const llvm::Type* type); - extern void AddStandardCompilePasses(llvm::FunctionPassManager*); - extern void runPasses(llvm::Function* func, llvm::FunctionPassManager*); -extern void* runCompilation(llvm::Function*); +extern void initialise(); + //extern mvm::Lock* protectTypes; //extern mvm::Lock* protectConstants; Modified: vmkit/trunk/include/mvm/Object.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Object.h?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/include/mvm/Object.h (original) +++ vmkit/trunk/include/mvm/Object.h Tue Apr 8 12:06:22 2008 @@ -87,7 +87,7 @@ } static void markAndTraceRoots(void); - static void initialise(void *sp); + static void initialise(); }; Modified: vmkit/trunk/include/mvm/Threads/Thread.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/Thread.h?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/include/mvm/Threads/Thread.h (original) +++ vmkit/trunk/include/mvm/Threads/Thread.h Tue Apr 8 12:06:22 2008 @@ -10,10 +10,14 @@ #ifndef MVM_THREAD_H #define MVM_THREAD_H -#include "mvm/GC/GC.h" +#include "mvm/Object.h" +#include "mvm/Threads/Key.h" + +class Collector; namespace mvm { -class Thread { + +class Thread : public Object{ public: static void yield(void); static void yield(unsigned int *); @@ -22,6 +26,12 @@ static int kill(int tid, int signo); static void exit(int value); static int start(int *tid, int (*fct)(void *), void *arg); + + static mvm::Key* threadKey; +#ifdef MULTIPLE_VM + Collector* GC; +#endif + static Thread* get(); }; Removed: vmkit/trunk/include/mvm/VMLet.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/VMLet.h?rev=49387&view=auto ============================================================================== --- vmkit/trunk/include/mvm/VMLet.h (original) +++ vmkit/trunk/include/mvm/VMLet.h (removed) @@ -1,38 +0,0 @@ -//===--------------- VMLet.h - Definition of VMLets -----------------------===// -// -// The Micro Virtual Machine -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef MVM_VMLET_H -#define MVM_VMLET_H - -#include "mvm/Object.h" -#include "mvm/Threads/Key.h" - -namespace llvm { - class Module; - class ExistingModuleProvider; - class ExecutionEngine; - class FunctionPassManager; - class JITMemoryManager; -} - -namespace mvm { - -class VMLet : public Object { -public: - static VirtualTable *VT; - //GC_defass(String, name); - - static void register_sigsegv_handler(void (*fct)(int, void *)); - - static void initialise(); -}; - -} // end namespace mvm - -#endif // MVM_VMLET_H Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClassLoader.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClassLoader.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClassLoader.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClassLoader.cpp Tue Apr 8 12:06:22 2008 @@ -100,7 +100,7 @@ if (cl->status == hashed) { cl->bytes = (ArrayUInt8*)bytes; cl->status = loaded; -#ifdef SINGLE_VM +#ifndef MULTIPLE_VM cl->delegatee = (JavaObject*)pd; #else vm->delegatees->hash(cl, (JavaObject*)pd); Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp Tue Apr 8 12:06:22 2008 @@ -115,7 +115,7 @@ jclass clazz, #endif jint par1) { -#ifdef SINGLE_VM +#ifndef MULTIPLE_VM exit(par1); #else // TODO: do a longjmp Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp Tue Apr 8 12:06:22 2008 @@ -50,7 +50,7 @@ JavaObject* vmThread = arg->vmThread; JavaThread* intern = arg->intern; delete arg; - JavaThread::threadKey->set(intern); + mvm::Thread::threadKey->set(intern); CommonClass* vmthClass = vmThread->classOf; JavaObject* thread = (JavaObject*)((*ClasspathThread::assocThread)(vmThread).PointerVal); JavaIsolate* isolate = (JavaIsolate*)(intern->isolate); @@ -86,7 +86,8 @@ JavaObject* javaThread = (JavaObject*)(*ClasspathThread::assocThread)(vmThread).PointerVal; assert(javaThread); - JavaThread* th = JavaThread::allocate(javaThread, JavaThread::get()->isolate); + JavaThread* th = gc_new(JavaThread)(); + th->initialise(javaThread, JavaThread::get()->isolate); (*ClasspathThread::vmdata)(vmThread, (JavaObject*)th); int tid = 0; arg_thread_t* arg = (arg_thread_t*)malloc(sizeof(arg_thread_t)); Modified: vmkit/trunk/lib/JnJVM/Classpath/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/Makefile.am?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/Makefile.am (original) +++ vmkit/trunk/lib/JnJVM/Classpath/Makefile.am Tue Apr 8 12:06:22 2008 @@ -17,4 +17,4 @@ ClasspathVMThrowable.h ClasspathVMThrowable.cpp ClasspathMethod.h ClasspathMethod.cpp \ ClasspathVMField.h ClasspathVMField.cpp ClasspathVMStackWalker.cpp ClasspathVMStackWalker.h -libClasspath_la_CXXFLAGS =$(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -DSINGLE_VM -O2 -g -Werror +libClasspath_la_CXXFLAGS =$(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -O2 -g -Werror Modified: vmkit/trunk/lib/JnJVM/Main.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Main.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Main.cpp (original) +++ vmkit/trunk/lib/JnJVM/Main.cpp Tue Apr 8 12:06:22 2008 @@ -7,77 +7,27 @@ // //===----------------------------------------------------------------------===// +#include "mvm/JIT.h" +#include "mvm/Object.h" #include "mvm/GC/GC.h" -#include "mvm/PrintBuffer.h" -#include "mvm/VMLet.h" - - -#include -#include -#include -#include #include "llvm/Support/ManagedStatic.h" -#include "mvm/Threads/Thread.h" - using namespace mvm; -static void clearSignals(void) { - signal(SIGINT, SIG_DFL); - signal(SIGILL, SIG_DFL); -#if !defined(WIN32) - signal(SIGIOT, SIG_DFL); - signal(SIGBUS, SIG_DFL); -#endif - signal(SIGSEGV, SIG_DFL); -} - extern "C" int boot(); extern "C" int start_app(int, char**); -extern "C" int ClasspathBoot(int, char**, char**); - -#include "VMCore/JavaJIT.h" - -void handler2(int n, void *context) { - printf("[%d] crashed\n", (int)mvm::Thread::self()); - jnjvm::JavaJIT::printBacktrace(); - assert(0); -} - -void handler(int n, siginfo_t *_info, void *context) { - printf("[%d] crashed\n", (int)mvm::Thread::self()); - jnjvm::JavaJIT::printBacktrace(); - assert(0); -} int main(int argc, char **argv, char **envp) { llvm::llvm_shutdown_obj X; int base; - - struct sigaction sa; - - sigaction(SIGINT, 0, &sa); - sa.sa_sigaction = handler; - sa.sa_flags |= (SA_RESTART | SA_SIGINFO | SA_NODEFER); - sigaction(SIGINT, &sa, 0); - - sigaction(SIGILL, 0, &sa); - sa.sa_sigaction = handler; - sa.sa_flags |= (SA_RESTART | SA_SIGINFO | SA_NODEFER); - sigaction(SIGILL, &sa, 0); - - - VMLet::register_sigsegv_handler(handler2); - - Object::initialise(&base); - VMLet::initialise(); - ClasspathBoot(argc, argv, envp); + + jit::initialise(); + Object::initialise(); + Collector::initialise(Object::markAndTraceRoots, &base); boot(); start_app(argc, argv); - clearSignals(); - return 0; } Modified: vmkit/trunk/lib/JnJVM/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Makefile.am?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Makefile.am (original) +++ vmkit/trunk/lib/JnJVM/Makefile.am Tue Apr 8 12:06:22 2008 @@ -17,7 +17,7 @@ main_SOURCES = ../Mvm/Object.cpp ../Mvm/Sigsegv.cpp Main.cpp ../Mvm/MvmMemoryManager.cpp ../Mvm/JIT.cpp ../Mvm/EscapeAnalysis.cpp -main_CXXFLAGS = $(libJnJVM_la_CXXFLAGS) +main_CXXFLAGS = $(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -Werror -O2 main_LDADD = VMCore/.libs/libJnJVM.a Classpath/.libs/libClasspath.a $(LIBSUVM) @LLVMDYLIB@ main_LDFLAGS = @rdynamic@ Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp Tue Apr 8 12:06:22 2008 @@ -30,6 +30,17 @@ const unsigned int JavaArray::T_INT = 10; const unsigned int JavaArray::T_LONG = 11; +ClassArray* JavaArray::ofByte = 0; +ClassArray* JavaArray::ofChar = 0; +ClassArray* JavaArray::ofInt = 0; +ClassArray* JavaArray::ofShort = 0; +ClassArray* JavaArray::ofBool = 0; +ClassArray* JavaArray::ofLong = 0; +ClassArray* JavaArray::ofFloat = 0; +ClassArray* JavaArray::ofDouble = 0; +ClassArray* JavaArray::ofString = 0; +ClassArray* JavaArray::ofObject = 0; + #define ACONS(name, elmt, primSize) \ name *name::acons(sint32 n, ClassArray* atype) { \ if (n < 0) \ Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h Tue Apr 8 12:06:22 2008 @@ -125,7 +125,7 @@ const UTF8* extract(Jnjvm *vm, uint32 start, uint32 len) const; -#ifdef SINGLE_VM +#ifndef MULTIPLE_VM bool equals(const UTF8* other) const { return this == other; } Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Tue Apr 8 12:06:22 2008 @@ -35,6 +35,22 @@ const int CommonClass::MaxDisplay = 6; +const UTF8* Attribut::codeAttribut = 0; +const UTF8* Attribut::exceptionsAttribut = 0; +const UTF8* Attribut::constantAttribut = 0; +const UTF8* Attribut::lineNumberTableAttribut = 0; +const UTF8* Attribut::innerClassesAttribut = 0; +const UTF8* Attribut::sourceFileAttribut = 0; + +JavaObject* CommonClass::jnjvmClassLoader = 0; + +CommonClass* ClassArray::SuperArray = 0; +std::vector ClassArray::InterfacesArray; +std::vector ClassArray::VirtualMethodsArray; +std::vector ClassArray::StaticMethodsArray; +std::vector ClassArray::VirtualFieldsArray; +std::vector ClassArray::StaticFieldsArray; + void Attribut::print(mvm::PrintBuffer* buf) const { buf->write("Attribut<"); buf->writeObj(name); @@ -116,7 +132,7 @@ this->dim = -1; this->isArray = isArray; this->_llvmVar = 0; -#ifdef SINGLE_VM +#ifndef MULTIPLE_VM this->_llvmDelegatee = 0; this->delegatee = 0; #endif @@ -357,16 +373,6 @@ return res; } -#ifndef SINGLE_VM -JavaObject* Class::doNewIsolate() { - if (!isReady()) - initialiseClass(); - JavaObject* res = (JavaObject*)gc::operator new(virtualSize, virtualVT); - memcpy(res, virtualInstance, virtualSize); - return res; -} -#endif - bool CommonClass::inheritName(const UTF8* Tname) { if (name->equals(Tname)) { return true; @@ -515,21 +521,19 @@ VirtualTable* VT = JavaJIT::makeVT(cl, true); uint64 size = mvm::jit::getTypeSize(cl->staticType->getContainedType(0)); -#ifndef SINGLE_VM cl->staticSize = size; cl->staticVT = VT; - if (cl->isolate != Jnjvm::bootstrapVM) { -#endif - JavaObject* val = (JavaObject*)gc::operator new(size, VT); - cl->setStaticInstance(val); + +#ifndef MULTIPLE_VM + JavaObject* val = (JavaObject*)gc::operator new(cl->staticSize, cl->staticVT); val->initialise(cl); for (std::vector::iterator i = cl->staticFields.begin(), e = cl->staticFields.end(); i!= e; ++i) { (*i)->initField(val); } -#ifndef SINGLE_VM - } + + cl->_staticInstance = val; #endif } @@ -589,11 +593,7 @@ return isolate->initialiseClass(this); } -#ifndef SINGLE_VM -void Class::setStaticInstance(JavaObject* val) { - _staticInstance = val; -} - +#ifdef MULTIPLE_VM JavaObject* Class::staticInstance() { if (isolate == Jnjvm::bootstrapVM) { Class* cl = this; @@ -606,7 +606,7 @@ } } -JavaObject* Class::createStaticInstance() { +void Class::createStaticInstance() { JavaObject* val = (JavaObject*)gc::operator new(staticSize, staticVT); val->initialise(this); for (std::vector::iterator i = this->staticFields.begin(), @@ -614,7 +614,13 @@ (*i)->initField(val); } - return val; + if (isolate == Jnjvm::bootstrapVM) { + std::pair* v = + new std::pair(0, val); + JavaThread::get()->isolate->statics->hash(this, v); + } else { + _staticInstance = val; + } } bool CommonClass::isReady() { @@ -629,4 +635,14 @@ } } +void CommonClass::setReady() { + if (isolate == Jnjvm::bootstrapVM && !this->isArray && + !AssessorDesc::bogusClassToPrimitive(this)) { + std::pair* val = + JavaThread::get()->isolate->statics->lookup((Class*)this); + val->first = 1; + } else { + status = ready; + } +} #endif Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Tue Apr 8 12:06:22 2008 @@ -76,7 +76,7 @@ class CommonClass : public mvm::Object { private: llvm::GlobalVariable* _llvmVar; -#ifdef SINGLE_VM +#ifndef MULTIPLE_VM llvm::GlobalVariable* _llvmDelegatee; #endif public: @@ -95,7 +95,7 @@ std::vector virtualFields; std::vector staticFields; JavaObject* classLoader; -#ifdef SINGLE_VM +#ifndef MULTIPLE_VM JavaObject* delegatee; #endif std::vector display; @@ -111,9 +111,8 @@ static JavaObject* jnjvmClassLoader; llvm::GlobalVariable* llvmVar(llvm::Module* compilingModule); -#ifdef SINGLE_VM - llvm::GlobalVariable* llvmDelegatee(); -#endif + llvm::Value* llvmDelegatee(llvm::Module* M, llvm::BasicBlock* BB); + static void printClassName(const UTF8* name, mvm::PrintBuffer* buf); void initialise(Jnjvm* isolate, bool array); void aquire(); @@ -148,12 +147,16 @@ void initialiseClass(); void resolveClass(bool doClinit); -#ifdef SINGLE_VM +#ifndef MULTIPLE_VM bool isReady() { return status == ready; } + void setReady() { + status = ready; + } #else bool isReady(); + void setReady(); #endif }; @@ -181,15 +184,12 @@ bool innerOuterResolved; void resolveFields(); - llvm::GlobalVariable* staticVar(llvm::Module* compilingModule); + llvm::Value* staticVar(llvm::Module* compilingModule, llvm::BasicBlock* BB); uint64 virtualSize; VirtualTable* virtualVT; -#ifndef SINGLE_VM uint64 staticSize; VirtualTable* staticVT; - JavaObject* doNewIsolate(); -#endif JavaObject* doNew(); JavaObject* doNewUnknown(); JavaObject* initialiseObject(JavaObject* obj); @@ -198,17 +198,14 @@ JavaObject* operator()(); -#ifdef SINGLE_VM - void setStaticInstance(JavaObject* val) { - _staticInstance = val; - } +#ifndef MULTIPLE_VM JavaObject* staticInstance() { return _staticInstance; } + void createStaticInstance() { } #else - void setStaticInstance(JavaObject* val); JavaObject* staticInstance(); - JavaObject* createStaticInstance(); + void createStaticInstance(); #endif }; Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp Tue Apr 8 12:06:22 2008 @@ -7,10 +7,9 @@ // //===----------------------------------------------------------------------===// - +#include #include -#include "mvm/VMLet.h" #include "mvm/Threads/Locks.h" #include "JavaArray.h" @@ -31,143 +30,8 @@ #include "LockedMap.h" #include "Zip.h" - - - using namespace jnjvm; -ClassArray* JavaArray::ofByte = 0; -ClassArray* JavaArray::ofChar = 0; -ClassArray* JavaArray::ofInt = 0; -ClassArray* JavaArray::ofShort = 0; -ClassArray* JavaArray::ofBool = 0; -ClassArray* JavaArray::ofLong = 0; -ClassArray* JavaArray::ofFloat = 0; -ClassArray* JavaArray::ofDouble = 0; -ClassArray* JavaArray::ofString = 0; -ClassArray* JavaArray::ofObject = 0; - -const UTF8* Attribut::codeAttribut = 0; -const UTF8* Attribut::exceptionsAttribut = 0; -const UTF8* Attribut::constantAttribut = 0; -const UTF8* Attribut::lineNumberTableAttribut = 0; -const UTF8* Attribut::innerClassesAttribut = 0; -const UTF8* Attribut::sourceFileAttribut = 0; - -JavaObject* CommonClass::jnjvmClassLoader = 0; - -CommonClass* ClassArray::SuperArray = 0; -std::vector ClassArray::InterfacesArray; -std::vector ClassArray::VirtualMethodsArray; -std::vector ClassArray::StaticMethodsArray; -std::vector ClassArray::VirtualFieldsArray; -std::vector ClassArray::StaticFieldsArray; - - -llvm::Function* JavaJIT::getSJLJBufferLLVM = 0; -llvm::Function* JavaJIT::throwExceptionLLVM = 0; -llvm::Function* JavaJIT::getExceptionLLVM = 0; -llvm::Function* JavaJIT::getJavaExceptionLLVM = 0; -llvm::Function* JavaJIT::clearExceptionLLVM = 0; -llvm::Function* JavaJIT::compareExceptionLLVM = 0; -llvm::Function* JavaJIT::nullPointerExceptionLLVM = 0; -llvm::Function* JavaJIT::classCastExceptionLLVM = 0; -llvm::Function* JavaJIT::indexOutOfBoundsExceptionLLVM = 0; -llvm::Function* JavaJIT::markAndTraceLLVM = 0; -llvm::Function* JavaJIT::javaObjectTracerLLVM = 0; -llvm::Function* JavaJIT::virtualLookupLLVM = 0; -llvm::Function* JavaJIT::fieldLookupLLVM = 0; -llvm::Function* JavaJIT::UTF8AconsLLVM = 0; -llvm::Function* JavaJIT::Int8AconsLLVM = 0; -llvm::Function* JavaJIT::Int32AconsLLVM = 0; -llvm::Function* JavaJIT::Int16AconsLLVM = 0; -llvm::Function* JavaJIT::FloatAconsLLVM = 0; -llvm::Function* JavaJIT::DoubleAconsLLVM = 0; -llvm::Function* JavaJIT::LongAconsLLVM = 0; -llvm::Function* JavaJIT::ObjectAconsLLVM = 0; -llvm::Function* JavaJIT::printExecutionLLVM = 0; -llvm::Function* JavaJIT::printMethodStartLLVM = 0; -llvm::Function* JavaJIT::printMethodEndLLVM = 0; -llvm::Function* JavaJIT::jniProceedPendingExceptionLLVM = 0; -llvm::Function* JavaJIT::doNewLLVM = 0; -llvm::Function* JavaJIT::doNewUnknownLLVM = 0; -llvm::Function* JavaJIT::initialiseObjectLLVM = 0; -llvm::Function* JavaJIT::newLookupLLVM = 0; -llvm::Function* JavaJIT::instanceOfLLVM = 0; -llvm::Function* JavaJIT::aquireObjectLLVM = 0; -llvm::Function* JavaJIT::releaseObjectLLVM = 0; -llvm::Function* JavaJIT::multiCallNewLLVM = 0; -llvm::Function* JavaJIT::runtimeUTF8ToStrLLVM = 0; -llvm::Function* JavaJIT::getStaticInstanceLLVM = 0; -llvm::Function* JavaJIT::getClassDelegateeLLVM = 0; -llvm::Function* JavaJIT::arrayLengthLLVM = 0; -#ifndef SINGLE_VM -llvm::Function* JavaJIT::doNewIsolateLLVM = 0; -#endif - - -const llvm::FunctionType* JavaJIT::markAndTraceLLVMType = 0; - -mvm::Lock* JavaObject::globalLock = 0; -const llvm::Type* JavaObject::llvmType = 0; -const llvm::Type* JavaArray::llvmType = 0; -const llvm::Type* ArrayUInt8::llvmType = 0; -const llvm::Type* ArraySInt8::llvmType = 0; -const llvm::Type* ArrayUInt16::llvmType = 0; -const llvm::Type* ArraySInt16::llvmType = 0; -const llvm::Type* ArrayUInt32::llvmType = 0; -const llvm::Type* ArraySInt32::llvmType = 0; -const llvm::Type* ArrayFloat::llvmType = 0; -const llvm::Type* ArrayDouble::llvmType = 0; -const llvm::Type* ArrayLong::llvmType = 0; -const llvm::Type* ArrayObject::llvmType = 0; -const llvm::Type* UTF8::llvmType = 0; -const llvm::Type* CacheNode::llvmType = 0; -const llvm::Type* Enveloppe::llvmType = 0; - - -mvm::Key* JavaThread::threadKey = 0; - - -Jnjvm* Jnjvm::bootstrapVM = 0; -const UTF8* Jnjvm::initName = 0; -const UTF8* Jnjvm::clinitName = 0; -const UTF8* Jnjvm::clinitType = 0; -const UTF8* Jnjvm::runName = 0; -const UTF8* Jnjvm::prelib = 0; -const UTF8* Jnjvm::postlib = 0; -const UTF8* Jnjvm::mathName = 0; - -#define DEF_UTF8(var) \ - const UTF8* Jnjvm::var = 0; - - DEF_UTF8(abs); - DEF_UTF8(sqrt); - DEF_UTF8(sin); - DEF_UTF8(cos); - DEF_UTF8(tan); - DEF_UTF8(asin); - DEF_UTF8(acos); - DEF_UTF8(atan); - DEF_UTF8(atan2); - DEF_UTF8(exp); - DEF_UTF8(log); - DEF_UTF8(pow); - DEF_UTF8(ceil); - DEF_UTF8(floor); - DEF_UTF8(rint); - DEF_UTF8(cbrt); - DEF_UTF8(cosh); - DEF_UTF8(expm1); - DEF_UTF8(hypot); - DEF_UTF8(log10); - DEF_UTF8(log1p); - DEF_UTF8(sinh); - DEF_UTF8(tanh); - -#undef DEF_UTF8 - - static void initialiseVT() { # define INIT(X) { \ @@ -199,7 +63,6 @@ INIT(LockObj); INIT(JavaObject); INIT(JavaThread); - //mvm::Key::VT = mvm::ThreadKey::VT; INIT(AssessorDesc); INIT(Typedef); INIT(Signdef); @@ -227,10 +90,6 @@ JavaObject::globalLock = mvm::Lock::allocNormal(); //mvm::Object::pushRoot((mvm::Object*)JavaObject::globalLock); - JavaThread::threadKey = new mvm::Key(); - //JavaThread::threadKey = gc_new(mvm::Key); - //mvm::Object::pushRoot((mvm::Object*)JavaThread::threadKey); - Jnjvm* vm = JavaIsolate::bootstrapVM = JavaIsolate::allocateBootstrap(); mvm::Object::pushRoot((mvm::Object*)JavaIsolate::bootstrapVM); @@ -336,24 +195,43 @@ } -extern "C" void sigsegv_handler(int val, void* addr) { - printf("SIGSEGV in JnJVM at %p\n", addr); +extern "C" void ClasspathBoot(); + +void handler(int val, siginfo_t* info, void* addr) { + printf("Crash in JnJVM at %p\n", addr); JavaJIT::printBacktrace(); assert(0); } - extern "C" int boot() { + struct sigaction sa; + + sigaction(SIGINT, 0, &sa); + sa.sa_sigaction = handler; + sa.sa_flags |= (SA_RESTART | SA_SIGINFO | SA_NODEFER); + sigaction(SIGINT, &sa, 0); + + sigaction(SIGILL, 0, &sa); + sa.sa_sigaction = handler; + sa.sa_flags |= (SA_RESTART | SA_SIGINFO | SA_NODEFER); + sigaction(SIGILL, &sa, 0); + + sigaction(SIGSEGV, 0, &sa); + sa.sa_sigaction = handler; + sa.sa_flags |= (SA_RESTART | SA_SIGINFO | SA_NODEFER); + sigaction(SIGSEGV, &sa, 0); + JavaJIT::initialise(); initialiseVT(); initialiseStatics(); + + ClasspathBoot(); Classpath::initialiseClasspath(JavaIsolate::bootstrapVM); - //mvm::VMLet::register_sigsegv_handler(sigsegv_handler); return 0; } extern "C" int start_app(int argc, char** argv) { -#if defined(SINGLE_VM) || defined(SERVICE_VM) +#if defined(SERVICE_VM) || !defined(MULTIPLE_VM) JavaIsolate* vm = (JavaIsolate*)JavaIsolate::bootstrapVM; #else JavaIsolate* vm = JavaIsolate::allocateIsolate(JavaIsolate::bootstrapVM); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp Tue Apr 8 12:06:22 2008 @@ -433,7 +433,9 @@ isolate->functions); JavaJIT::initialiseJITIsolateVM(isolate); - isolate->bootstrapThread = JavaThread::allocate(0, isolate); + + isolate->bootstrapThread = gc_new(JavaThread)(); + isolate->bootstrapThread->initialise(0, isolate); JavaThread::threadKey->set(isolate->bootstrapThread); @@ -451,7 +453,7 @@ isolate->loadedFields = FieldMap::allocate(); isolate->javaTypes = jnjvm::TypeMap::allocate(); isolate->globalRefsLock = mvm::Lock::allocNormal(); -#ifndef SINGLE_VM +#ifdef MULTIPLE_VM isolate->statics = StaticInstanceMap::allocate(); isolate->delegatees = DelegateeMap::allocate(); #endif @@ -484,7 +486,8 @@ isolate->functions); JavaJIT::initialiseJITBootstrapVM(isolate); - isolate->bootstrapThread = JavaThread::allocate(0, isolate); + isolate->bootstrapThread = gc_new(JavaThread)(); + isolate->bootstrapThread->initialise(0, isolate); JavaThread::threadKey->set(isolate->bootstrapThread); isolate->name = "bootstrapVM"; @@ -498,11 +501,13 @@ isolate->javavmEnv = &JNI_JavaVMTable; isolate->globalRefsLock = mvm::Lock::allocNormal(); isolate->javaTypes = jnjvm::TypeMap::allocate(); -#ifndef SINGLE_VM + +#ifdef MULTIPLE_VM isolate->statics = StaticInstanceMap::allocate(); isolate->delegatees = DelegateeMap::allocate(); #endif -#if defined(SINGLE_VM) || defined(SERVICE_VM) + +#if defined(SERVICE_VM) || !defined(MULTIPLE_VM) isolate->threadSystem = ThreadSystem::allocateThreadSystem(); #endif Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Tue Apr 8 12:06:22 2008 @@ -170,15 +170,8 @@ uint32 index = 0; if (stat) { -#ifdef SINGLE_VM - nativeArgs.push_back(new LoadInst(compilingClass->llvmDelegatee(), "", - currentBlock)); -#else Module* M = compilingClass->isolate->module; - Value* ld = new LoadInst(compilingClass->llvmVar(M), "", currentBlock); - nativeArgs.push_back(llvm::CallInst::Create(getClassDelegateeLLVM, ld, "", - currentBlock)); -#endif + nativeArgs.push_back(compilingClass->llvmDelegatee(M, currentBlock)); index = 2; } else { index = 1; @@ -227,15 +220,11 @@ argsSync.push_back(llvmFunction->arg_begin()); } else { Module* M = compilingClass->isolate->module; - Value* arg = new LoadInst(compilingClass->staticVar(M), "", currentBlock); -#ifndef SINGLE_VM - if (compilingClass->isolate == Jnjvm::bootstrapVM) { - arg = llvm::CallInst::Create(getStaticInstanceLLVM, arg, "", currentBlock); - } -#endif + Value* arg = compilingClass->staticVar(M, currentBlock); argsSync.push_back(arg); } - llvm::CallInst::Create(aquireObjectLLVM, argsSync.begin(), argsSync.end(), "", currentBlock); + llvm::CallInst::Create(aquireObjectLLVM, argsSync.begin(), argsSync.end(), + "", currentBlock); } void JavaJIT::endSynchronize() { @@ -244,12 +233,7 @@ argsSync.push_back(llvmFunction->arg_begin()); } else { Module* M = compilingClass->isolate->module; - Value* arg = new LoadInst(compilingClass->staticVar(M), "", currentBlock); -#ifndef SINGLE_VM - if (compilingClass->isolate == Jnjvm::bootstrapVM) { - arg = llvm::CallInst::Create(getStaticInstanceLLVM, arg, "", currentBlock); - } -#endif + Value* arg = compilingClass->staticVar(M, currentBlock); argsSync.push_back(arg); } llvm::CallInst::Create(releaseObjectLLVM, argsSync.begin(), argsSync.end(), "", @@ -401,7 +385,8 @@ mvm::jit::protectConstants();//->lock(); args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod)); mvm::jit::unprotectConstants();//->unlock(); - llvm::CallInst::Create(printMethodStartLLVM, args.begin(), args.end(), "", currentBlock); + llvm::CallInst::Create(printMethodStartLLVM, args.begin(), args.end(), "", + currentBlock); } #endif @@ -472,7 +457,8 @@ mvm::jit::protectConstants();//->lock(); args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod)); mvm::jit::unprotectConstants();//->unlock(); - llvm::CallInst::Create(printMethodEndLLVM, args.begin(), args.end(), "", currentBlock); + llvm::CallInst::Create(printMethodEndLLVM, args.begin(), args.end(), "", + currentBlock); } #endif @@ -488,7 +474,8 @@ } else { CallInst* ptr_eh_ptr = llvm::CallInst::Create(getExceptionLLVM, "eh_ptr", endExceptionBlock); - llvm::CallInst::Create(mvm::jit::unwindResume, ptr_eh_ptr, "", endExceptionBlock); + llvm::CallInst::Create(mvm::jit::unwindResume, ptr_eh_ptr, "", + endExceptionBlock); new UnreachableInst(endExceptionBlock); } @@ -540,32 +527,41 @@ BasicBlock* realEndExceptionBlock = endExceptionBlock; if (sync) { - BasicBlock* synchronizeExceptionBlock = createBasicBlock("synchronizeExceptionBlock"); - BasicBlock* trySynchronizeExceptionBlock = createBasicBlock("trySynchronizeExceptionBlock"); + BasicBlock* synchronizeExceptionBlock = + createBasicBlock("synchronizeExceptionBlock"); + BasicBlock* trySynchronizeExceptionBlock = + createBasicBlock("trySynchronizeExceptionBlock"); realEndExceptionBlock = synchronizeExceptionBlock; std::vector argsSync; if (isVirtual(compilingMethod->access)) { argsSync.push_back(llvmFunction->arg_begin()); } else { - Value* arg = new LoadInst(compilingClass->staticVar(compilingClass->isolate->module), "", currentBlock); -#ifndef SINGLE_VM - if (compilingClass->isolate == Jnjvm::bootstrapVM) { - arg = llvm::CallInst::Create(getStaticInstanceLLVM, arg, "", currentBlock); - } -#endif + Value* arg = compilingClass->staticVar(compilingClass->isolate->module, + currentBlock); argsSync.push_back(arg); } - llvm::CallInst::Create(releaseObjectLLVM, argsSync.begin(), argsSync.end(), "", synchronizeExceptionBlock); + llvm::CallInst::Create(releaseObjectLLVM, argsSync.begin(), argsSync.end(), + "", synchronizeExceptionBlock); + llvm::BranchInst::Create(endExceptionBlock, synchronizeExceptionBlock); const PointerType* PointerTy_0 = mvm::jit::ptrType; std::vector int32_eh_select_params; - Instruction* ptr_eh_ptr = llvm::CallInst::Create(mvm::jit::llvmGetException, "eh_ptr", trySynchronizeExceptionBlock); + Instruction* ptr_eh_ptr = + llvm::CallInst::Create(mvm::jit::llvmGetException, "eh_ptr", + trySynchronizeExceptionBlock); int32_eh_select_params.push_back(ptr_eh_ptr); - int32_eh_select_params.push_back(ConstantExpr::getCast(Instruction::BitCast, mvm::jit::personality, PointerTy_0)); + Constant* C = ConstantExpr::getCast(Instruction::BitCast, + mvm::jit::personality, PointerTy_0); + int32_eh_select_params.push_back(C); int32_eh_select_params.push_back(mvm::jit::constantPtrNull); - llvm::CallInst::Create(mvm::jit::exceptionSelector, int32_eh_select_params.begin(), int32_eh_select_params.end(), "eh_select", trySynchronizeExceptionBlock); - llvm::BranchInst::Create(synchronizeExceptionBlock, trySynchronizeExceptionBlock); + llvm::CallInst::Create(mvm::jit::exceptionSelector, + int32_eh_select_params.begin(), + int32_eh_select_params.end(), + "eh_select", trySynchronizeExceptionBlock); + + llvm::BranchInst::Create(synchronizeExceptionBlock, + trySynchronizeExceptionBlock); for (uint16 i = 0; i < codeLen; ++i) { if (opcodeInfos[i].exceptionBlock == endExceptionBlock) { @@ -599,7 +595,8 @@ } if (!(opcodeInfos[ex->handlerpc].newBlock)) { - opcodeInfos[ex->handlerpc].newBlock = createBasicBlock("handlerException"); + opcodeInfos[ex->handlerpc].newBlock = + createBasicBlock("handlerException"); } ex->handler = opcodeInfos[ex->handlerpc].newBlock; @@ -624,7 +621,8 @@ cur->realTest = cur->test; } - cur->exceptionPHI = llvm::PHINode::Create(mvm::jit::ptrType, "", cur->realTest); + cur->exceptionPHI = llvm::PHINode::Create(mvm::jit::ptrType, "", + cur->realTest); if (next && cur->startpc == next->startpc && cur->endpc == next->endpc) first = false; @@ -655,29 +653,42 @@ if (cur->realTest != cur->test) { const PointerType* PointerTy_0 = mvm::jit::ptrType; std::vector int32_eh_select_params; - Instruction* ptr_eh_ptr = llvm::CallInst::Create(mvm::jit::llvmGetException, "eh_ptr", cur->test); + Instruction* ptr_eh_ptr = + llvm::CallInst::Create(mvm::jit::llvmGetException, "eh_ptr", cur->test); int32_eh_select_params.push_back(ptr_eh_ptr); - int32_eh_select_params.push_back(ConstantExpr::getCast(Instruction::BitCast, mvm::jit::personality, PointerTy_0)); + Constant* C = ConstantExpr::getCast(Instruction::BitCast, + mvm::jit::personality, PointerTy_0); + int32_eh_select_params.push_back(C); int32_eh_select_params.push_back(mvm::jit::constantPtrNull); - llvm::CallInst::Create(mvm::jit::exceptionSelector, int32_eh_select_params.begin(), int32_eh_select_params.end(), "eh_select", cur->test); + llvm::CallInst::Create(mvm::jit::exceptionSelector, + int32_eh_select_params.begin(), + int32_eh_select_params.end(), "eh_select", + cur->test); llvm::BranchInst::Create(cur->realTest, cur->test); cur->exceptionPHI->addIncoming(ptr_eh_ptr, cur->test); } - - Value* cl = new LoadInst(cur->catchClass->llvmVar(compilingClass->isolate->module), "", cur->realTest); - Value* cmp = llvm::CallInst::Create(compareExceptionLLVM, cl, "", cur->realTest); + + Module* M = compilingClass->isolate->module; + Value* cl = new LoadInst(cur->catchClass->llvmVar(M), "", cur->realTest); + Value* cmp = llvm::CallInst::Create(compareExceptionLLVM, cl, "", + cur->realTest); llvm::BranchInst::Create(cur->handler, bbNext, cmp, cur->realTest); if (nodeNext) nodeNext->addIncoming(cur->exceptionPHI, cur->realTest); if (cur->handler->empty()) { - cur->handlerPHI = llvm::PHINode::Create(mvm::jit::ptrType, "", cur->handler); + cur->handlerPHI = llvm::PHINode::Create(mvm::jit::ptrType, "", + cur->handler); cur->handlerPHI->addIncoming(cur->exceptionPHI, cur->realTest); - Value* exc = llvm::CallInst::Create(getJavaExceptionLLVM, "", cur->handler); + Value* exc = llvm::CallInst::Create(getJavaExceptionLLVM, "", + cur->handler); llvm::CallInst::Create(clearExceptionLLVM, "", cur->handler); - llvm::CallInst::Create(mvm::jit::exceptionBeginCatch, cur->handlerPHI, "tmp8", cur->handler); + llvm::CallInst::Create(mvm::jit::exceptionBeginCatch, cur->handlerPHI, + "tmp8", cur->handler); std::vector void_28_params; - llvm::CallInst::Create(mvm::jit::exceptionEndCatch, void_28_params.begin(), void_28_params.end(), "", cur->handler); + llvm::CallInst::Create(mvm::jit::exceptionEndCatch, + void_28_params.begin(), void_28_params.end(), "", + cur->handler); new StoreInst(exc, supplLocal, false, cur->handler); } else { Instruction* insn = cur->handler->begin(); @@ -718,7 +729,7 @@ const UTF8* utf8 = ctpInfo->UTF8At(ctpInfo->ctpDef[index]); void* val = 0; GlobalVariable* gv = 0; -#ifndef SINGLE_VM +#ifdef MULTIPLE_VM if (compilingClass->isolate != Jnjvm::bootstrapVM) { #endif val = compilingClass->isolate->UTF8ToStr(utf8); @@ -729,7 +740,7 @@ constantJavaObjectNull, "", compilingClass->isolate->module); compilingClass->isolate->protectModule->unlock(); -#ifndef SINGLE_VM +#ifdef MULTIPLE_VM } else { val = (void*)utf8; compilingClass->isolate->protectModule->lock(); @@ -746,38 +757,47 @@ void* ptr = mvm::jit::executionEngine->getPointerToGlobal(gv); GenericValue Val = GenericValue(val); llvm::GenericValue * Ptr = (llvm::GenericValue*)ptr; - mvm::jit::executionEngine->StoreValueToMemory(Val, Ptr, JavaObject::llvmType); + mvm::jit::executionEngine->StoreValueToMemory(Val, Ptr, + JavaObject::llvmType); toPush = new LoadInst(gv, "", currentBlock); ctpInfo->ctpRes[index] = gv; compilingClass->release(); } else { compilingClass->release(); - toPush = new LoadInst((GlobalVariable*)ctpInfo->ctpRes[index], "", currentBlock); + toPush = new LoadInst((GlobalVariable*)ctpInfo->ctpRes[index], "", + currentBlock); } } else { - toPush = new LoadInst((GlobalVariable*)ctpInfo->ctpRes[index], "", currentBlock); + toPush = new LoadInst((GlobalVariable*)ctpInfo->ctpRes[index], "", + currentBlock); } -#ifndef SINGLE_VM - if (compilingClass->isolate == Jnjvm::bootstrapVM) - push(llvm::CallInst::Create(runtimeUTF8ToStrLLVM, toPush, "", currentBlock), AssessorDesc::dRef); - else +#ifdef MULTIPLE_VM + if (compilingClass->isolate == Jnjvm::bootstrapVM) { + CallInst* C = llvm::CallInst::Create(runtimeUTF8ToStrLLVM, toPush, "", + currentBlock); + push(C, AssessorDesc::dRef); + } else #endif push(toPush, AssessorDesc::dRef); } else if (type == JavaCtpInfo::ConstantLong) { mvm::jit::protectConstants();//->lock(); - push(ConstantInt::get(Type::Int64Ty, ctpInfo->LongAt(index)), AssessorDesc::dLong); + push(ConstantInt::get(Type::Int64Ty, ctpInfo->LongAt(index)), + AssessorDesc::dLong); mvm::jit::unprotectConstants();//->unlock(); } else if (type == JavaCtpInfo::ConstantDouble) { mvm::jit::protectConstants();//->lock(); - push(ConstantFP::get(Type::DoubleTy, APFloat(ctpInfo->DoubleAt(index))), AssessorDesc::dDouble); + push(ConstantFP::get(Type::DoubleTy, APFloat(ctpInfo->DoubleAt(index))), + AssessorDesc::dDouble); mvm::jit::unprotectConstants();//->unlock(); } else if (type == JavaCtpInfo::ConstantInteger) { mvm::jit::protectConstants();//->lock(); - push(ConstantInt::get(Type::Int32Ty, ctpInfo->IntegerAt(index)), AssessorDesc::dInt); + push(ConstantInt::get(Type::Int32Ty, ctpInfo->IntegerAt(index)), + AssessorDesc::dInt); mvm::jit::unprotectConstants();//->unlock(); } else if (type == JavaCtpInfo::ConstantFloat) { mvm::jit::protectConstants();//->lock(); - push(ConstantFP::get(Type::FloatTy, APFloat(ctpInfo->FloatAt(index))), AssessorDesc::dFloat); + push(ConstantFP::get(Type::FloatTy, APFloat(ctpInfo->FloatAt(index))), + AssessorDesc::dFloat); mvm::jit::unprotectConstants();//->unlock(); } else if (type == JavaCtpInfo::ConstantClass) { assert(0 && "implement ConstantClass in ldc!"); @@ -799,9 +819,10 @@ llvm::BranchInst::Create(exit, cont, test, jit->currentBlock); std::vector args; if (currentExceptionBlock != endExceptionBlock) { - llvm::InvokeInst::Create(JavaJIT::nullPointerExceptionLLVM, unifiedUnreachable, - currentExceptionBlock, args.begin(), - args.end(), "", exit); + llvm::InvokeInst::Create(JavaJIT::nullPointerExceptionLLVM, + unifiedUnreachable, + currentExceptionBlock, args.begin(), + args.end(), "", exit); } else { llvm::CallInst::Create(JavaJIT::nullPointerExceptionLLVM, args.begin(), args.end(), "", exit); @@ -824,7 +845,8 @@ if (true) { Value* size = arraySize(obj); - Value* cmp = new ICmpInst(ICmpInst::ICMP_ULT, index, size, "", currentBlock); + Value* cmp = new ICmpInst(ICmpInst::ICMP_ULT, index, size, "", + currentBlock); BasicBlock* ifTrue = createBasicBlock("true verifyAndComputePtr"); BasicBlock* ifFalse = createBasicBlock("false verifyAndComputePtr"); @@ -835,12 +857,13 @@ args.push_back(obj); args.push_back(index); if (currentExceptionBlock != endExceptionBlock) { - llvm::InvokeInst::Create(JavaJIT::indexOutOfBoundsExceptionLLVM, unifiedUnreachable, - currentExceptionBlock, args.begin(), - args.end(), "", ifFalse); + llvm::InvokeInst::Create(JavaJIT::indexOutOfBoundsExceptionLLVM, + unifiedUnreachable, + currentExceptionBlock, args.begin(), + args.end(), "", ifFalse); } else { - llvm::CallInst::Create(JavaJIT::indexOutOfBoundsExceptionLLVM, args.begin(), - args.end(), "", ifFalse); + llvm::CallInst::Create(JavaJIT::indexOutOfBoundsExceptionLLVM, + args.begin(), args.end(), "", ifFalse); new UnreachableInst(ifFalse); } @@ -854,8 +877,9 @@ indexes.push_back(zero); indexes.push_back(JavaArray::elementsOffset()); indexes.push_back(index); - Value* ptr = llvm::GetElementPtrInst::Create(val, indexes.begin(), indexes.end(), - "", currentBlock); + Value* ptr = llvm::GetElementPtrInst::Create(val, indexes.begin(), + indexes.end(), + "", currentBlock); return ptr; @@ -887,7 +911,8 @@ static void testPHINodes(BasicBlock* dest, BasicBlock* insert, JavaJIT* jit) { if(dest->empty()) { - for (std::vector< std::pair >::iterator i = jit->stack.begin(), + for (std::vector< std::pair >::iterator i = + jit->stack.begin(), e = jit->stack.end(); i!= e; ++i) { Value* cur = i->first; const AssessorDesc* func = i->second; @@ -904,7 +929,8 @@ node->addIncoming(cur, insert); } } else { - std::vector< std::pair >::iterator stackit = jit->stack.begin(); + std::vector< std::pair >::iterator stackit = + jit->stack.begin(); for (BasicBlock::iterator i = dest->begin(), e = dest->end(); i != e; ++i) { if (!(isa(i))) { @@ -990,64 +1016,102 @@ if (Ty == Type::Int32Ty) { Constant* const_int32_9 = mvm::jit::constantZero; ConstantInt* const_int32_10 = mvm::jit::constantMinusOne; - BinaryOperator* int32_tmpneg = BinaryOperator::create(Instruction::Sub, const_int32_9, args[0], "tmpneg", currentBlock); - ICmpInst* int1_abscond = new ICmpInst(ICmpInst::ICMP_SGT, args[0], const_int32_10, "abscond", currentBlock); - return llvm::SelectInst::Create(int1_abscond, args[0], int32_tmpneg, "abs", currentBlock); + BinaryOperator* int32_tmpneg = + BinaryOperator::create(Instruction::Sub, const_int32_9, args[0], + "tmpneg", currentBlock); + ICmpInst* int1_abscond = + new ICmpInst(ICmpInst::ICMP_SGT, args[0], const_int32_10, "abscond", + currentBlock); + return llvm::SelectInst::Create(int1_abscond, args[0], int32_tmpneg, + "abs", currentBlock); } else if (Ty == Type::Int64Ty) { Constant* const_int64_9 = mvm::jit::constantLongZero; ConstantInt* const_int64_10 = mvm::jit::constantLongMinusOne; - BinaryOperator* int64_tmpneg = BinaryOperator::create(Instruction::Sub, const_int64_9, args[0], "tmpneg", currentBlock); - ICmpInst* int1_abscond = new ICmpInst(ICmpInst::ICMP_SGT, args[0], const_int64_10, "abscond", currentBlock); - return llvm::SelectInst::Create(int1_abscond, args[0], int64_tmpneg, "abs", currentBlock); + + BinaryOperator* int64_tmpneg = + BinaryOperator::create(Instruction::Sub, const_int64_9, args[0], + "tmpneg", currentBlock); + + ICmpInst* int1_abscond = new ICmpInst(ICmpInst::ICMP_SGT, args[0], + const_int64_10, "abscond", + currentBlock); + + return llvm::SelectInst::Create(int1_abscond, args[0], int64_tmpneg, + "abs", currentBlock); } else if (Ty == Type::FloatTy) { - return llvm::CallInst::Create(mvm::jit::func_llvm_fabs_f32, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_fabs_f32, args[0], + "tmp1", currentBlock); } else if (Ty == Type::DoubleTy) { - return llvm::CallInst::Create(mvm::jit::func_llvm_fabs_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_fabs_f64, args[0], + "tmp1", currentBlock); } } else if (name == Jnjvm::sqrt) { - return llvm::CallInst::Create(mvm::jit::func_llvm_sqrt_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_sqrt_f64, args[0], + "tmp1", currentBlock); } else if (name == Jnjvm::sin) { - return llvm::CallInst::Create(mvm::jit::func_llvm_sin_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_sin_f64, args[0], + "tmp1", currentBlock); } else if (name == Jnjvm::cos) { - return llvm::CallInst::Create(mvm::jit::func_llvm_cos_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_cos_f64, args[0], + "tmp1", currentBlock); } else if (name == Jnjvm::tan) { - return llvm::CallInst::Create(mvm::jit::func_llvm_tan_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_tan_f64, args[0], + "tmp1", currentBlock); } else if (name == Jnjvm::asin) { - return llvm::CallInst::Create(mvm::jit::func_llvm_asin_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_asin_f64, args[0], + "tmp1", currentBlock); } else if (name == Jnjvm::acos) { - return llvm::CallInst::Create(mvm::jit::func_llvm_acos_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_acos_f64, args[0], + "tmp1", currentBlock); } else if (name == Jnjvm::atan) { - return llvm::CallInst::Create(mvm::jit::func_llvm_atan_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_atan_f64, args[0], + "tmp1", currentBlock); } else if (name == Jnjvm::atan2) { - return llvm::CallInst::Create(mvm::jit::func_llvm_atan2_f64, args.begin(), args.end(), "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_atan2_f64, + args.begin(), args.end(), "tmp1", + currentBlock); } else if (name == Jnjvm::exp) { - return llvm::CallInst::Create(mvm::jit::func_llvm_exp_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_exp_f64, args[0], + "tmp1", currentBlock); } else if (name == Jnjvm::log) { - return llvm::CallInst::Create(mvm::jit::func_llvm_log_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_log_f64, args[0], + "tmp1", currentBlock); } else if (name == Jnjvm::pow) { - return llvm::CallInst::Create(mvm::jit::func_llvm_pow_f64, args.begin(), args.end(), "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_pow_f64, args.begin(), + args.end(), "tmp1", currentBlock); } else if (name == Jnjvm::ceil) { - return llvm::CallInst::Create(mvm::jit::func_llvm_ceil_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_ceil_f64, args[0], "tmp1", + currentBlock); } else if (name == Jnjvm::floor) { - return llvm::CallInst::Create(mvm::jit::func_llvm_floor_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_floor_f64, args[0], + "tmp1", currentBlock); } else if (name == Jnjvm::rint) { - return llvm::CallInst::Create(mvm::jit::func_llvm_rint_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_rint_f64, args[0], + "tmp1", currentBlock); } else if (name == Jnjvm::cbrt) { - return llvm::CallInst::Create(mvm::jit::func_llvm_cbrt_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_cbrt_f64, args[0], "tmp1", + currentBlock); } else if (name == Jnjvm::cosh) { - return llvm::CallInst::Create(mvm::jit::func_llvm_cosh_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_cosh_f64, args[0], "tmp1", + currentBlock); } else if (name == Jnjvm::expm1) { - return llvm::CallInst::Create(mvm::jit::func_llvm_expm1_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_expm1_f64, args[0], + "tmp1", currentBlock); } else if (name == Jnjvm::hypot) { - return llvm::CallInst::Create(mvm::jit::func_llvm_hypot_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_hypot_f64, args[0], + "tmp1", currentBlock); } else if (name == Jnjvm::log10) { - return llvm::CallInst::Create(mvm::jit::func_llvm_log10_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_log10_f64, args[0], + "tmp1", currentBlock); } else if (name == Jnjvm::log1p) { - return llvm::CallInst::Create(mvm::jit::func_llvm_log1p_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_log1p_f64, args[0], + "tmp1", currentBlock); } else if (name == Jnjvm::sinh) { - return llvm::CallInst::Create(mvm::jit::func_llvm_sinh_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_sinh_f64, args[0], + "tmp1", currentBlock); } else if (name == Jnjvm::tanh) { - return llvm::CallInst::Create(mvm::jit::func_llvm_tanh_f64, args[0], "tmp1", currentBlock); + return llvm::CallInst::Create(mvm::jit::func_llvm_tanh_f64, args[0], + "tmp1", currentBlock); } return 0; @@ -1200,7 +1264,8 @@ Value* node = getInitializedClass(index); val = invoke(doNewUnknownLLVM, node, "", currentBlock); } else { - Value* load = new LoadInst(cl->llvmVar(compilingClass->isolate->module), "", currentBlock); + Value* load = new LoadInst(cl->llvmVar(compilingClass->isolate->module), + "", currentBlock); val = invoke(doNewLLVM, load, "", currentBlock); // give the real type info, escape analysis uses it new BitCastInst(val, cl->virtualType, "", currentBlock); @@ -1231,8 +1296,10 @@ std::vector args; // size = 2 args.push_back(zero); args.push_back(offset); - llvm::Value* ptr = llvm::GetElementPtrInst::Create(objectConvert, args.begin(), - args.end(), "", jit->currentBlock); + llvm::Value* ptr = llvm::GetElementPtrInst::Create(objectConvert, + args.begin(), + args.end(), "", + jit->currentBlock); return ptr; } @@ -1242,16 +1309,11 @@ JavaField* field = info->lookupField(index, stat); if (field && field->classDef->isReady()) { - if (stat) object = new LoadInst(field->classDef->staticVar(compilingClass->isolate->module), "", - currentBlock); + Module* M = compilingClass->isolate->module; + if (stat) object = field->classDef->staticVar(M, currentBlock); const Type* type = stat ? field->classDef->staticType : field->classDef->virtualType; -#ifndef SINGLE_VM - if (stat && field->classDef->isolate == Jnjvm::bootstrapVM) { - object = llvm::CallInst::Create(getStaticInstanceLLVM, object, "", currentBlock); - } -#endif return fieldGetter(this, type, object, field->offset); } else { const Type* Pty = mvm::jit::arrayPtrType; @@ -1304,8 +1366,8 @@ } else { args.push_back(constantJavaObjectNull); } - args.push_back(new LoadInst(compilingClass->llvmVar(compilingClass->isolate->module), "", - currentBlock)); + Module* M = compilingClass->isolate->module; + args.push_back(new LoadInst(compilingClass->llvmVar(M), "", currentBlock)); mvm::jit::protectConstants();//->lock(); args.push_back(ConstantInt::get(Type::Int32Ty, index)); mvm::jit::unprotectConstants();//->unlock(); @@ -1321,7 +1383,8 @@ } } -extern void convertValue(Value*& val, const Type* t1, BasicBlock* currentBlock, bool usign); +extern void convertValue(Value*& val, const Type* t1, BasicBlock* currentBlock, + bool usign); void JavaJIT::setStaticField(uint16 index) { @@ -1398,8 +1461,9 @@ if (currentExceptionBlock != endExceptionBlock) { BasicBlock* ifNormal = createBasicBlock("no exception block"); currentBlock = ifNormal; - return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock, args.begin(), - args.end(), Name, InsertAtEnd); + return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock, + args.begin(), + args.end(), Name, InsertAtEnd); } else { return llvm::CallInst::Create(F, args.begin(), args.end(), Name, InsertAtEnd); } @@ -1414,8 +1478,8 @@ currentBlock = ifNormal; std::vector arg; arg.push_back(arg1); - return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock, arg.begin(), - arg.end(), Name, InsertAtEnd); + return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock, + arg.begin(), arg.end(), Name, InsertAtEnd); } else { return llvm::CallInst::Create(F, arg1, Name, InsertAtEnd); } @@ -1432,8 +1496,9 @@ if (currentExceptionBlock != endExceptionBlock) { BasicBlock* ifNormal = createBasicBlock("no exception block"); currentBlock = ifNormal; - return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock, args.begin(), - args.end(), Name, InsertAtEnd); + return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock, + args.begin(), args.end(), Name, + InsertAtEnd); } else { return llvm::CallInst::Create(F, args.begin(), args.end(), Name, InsertAtEnd); } @@ -1446,8 +1511,9 @@ BasicBlock* ifNormal = createBasicBlock("no exception block"); currentBlock = ifNormal; std::vector args; - return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock, args.begin(), - args.end(), Name, InsertAtEnd); + return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock, + args.begin(), args.end(), Name, + InsertAtEnd); } else { return llvm::CallInst::Create(F, Name, InsertAtEnd); } Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Tue Apr 8 12:06:22 2008 @@ -268,10 +268,6 @@ static llvm::Function* getStaticInstanceLLVM; static llvm::Function* getClassDelegateeLLVM; static llvm::Function* arrayLengthLLVM; -#ifndef SINGLE_VM - static llvm::Function* doNewIsolateLLVM; -#endif - static void runtimeInitialise(); static Class* getCallingClass(); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp Tue Apr 8 12:06:22 2008 @@ -7,62 +7,15 @@ // //===----------------------------------------------------------------------===// -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "llvm/Constants.h" -#include "llvm/DerivedTypes.h" +#include "llvm/Instructions.h" +#include "llvm/LinkAllPasses.h" #include "llvm/Module.h" -#include "llvm/ModuleProvider.h" -#include "llvm/ParameterAttributes.h" -#include "llvm/PassManager.h" -#include "llvm/ValueSymbolTable.h" -#include "llvm/Analysis/LoadValueNumbering.h" #include "llvm/Analysis/LoopPass.h" -#include "llvm/Analysis/Verifier.h" -#include "llvm/Assembly/Writer.h" -#include "llvm/Assembly/PrintModulePass.h" -#include "llvm/Bitcode/ReaderWriter.h" -#include "llvm/CodeGen/RegAllocRegistry.h" -#include "llvm/CodeGen/SchedulerRegistry.h" -#include "llvm/CodeGen/ScheduleDAG.h" -#include "llvm/Target/SubtargetFeature.h" -#include "llvm/Target/TargetData.h" -#include "llvm/Target/TargetLowering.h" -#include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetMachineRegistry.h" -#include "llvm/Transforms/Scalar.h" -#include "llvm/Transforms/IPO.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/StringMap.h" -#include "llvm/Support/Streams.h" -#include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/MutexGuard.h" -#include - -#include #include "mvm/JIT.h" #include "mvm/Method.h" -#include "mvm/VMLet.h" #include "JavaArray.h" #include "JavaCache.h" @@ -75,9 +28,23 @@ using namespace jnjvm; using namespace llvm; -void JavaJIT::initialise() { - runtimeInitialise(); -} +const llvm::FunctionType* JavaJIT::markAndTraceLLVMType = 0; + +const llvm::Type* JavaObject::llvmType = 0; +const llvm::Type* JavaArray::llvmType = 0; +const llvm::Type* ArrayUInt8::llvmType = 0; +const llvm::Type* ArraySInt8::llvmType = 0; +const llvm::Type* ArrayUInt16::llvmType = 0; +const llvm::Type* ArraySInt16::llvmType = 0; +const llvm::Type* ArrayUInt32::llvmType = 0; +const llvm::Type* ArraySInt32::llvmType = 0; +const llvm::Type* ArrayFloat::llvmType = 0; +const llvm::Type* ArrayDouble::llvmType = 0; +const llvm::Type* ArrayLong::llvmType = 0; +const llvm::Type* ArrayObject::llvmType = 0; +const llvm::Type* UTF8::llvmType = 0; +const llvm::Type* CacheNode::llvmType = 0; +const llvm::Type* Enveloppe::llvmType = 0; void JavaJIT::initialiseJITIsolateVM(Jnjvm* vm) { mvm::jit::protectEngine->lock(); @@ -274,20 +241,6 @@ module); } -#ifndef SINGLE_VM - // Create doNewIsolateLLVM - { - std::vector args; - args.push_back(mvm::jit::ptrType); - const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, - false); - - doNewIsolateLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5jnjvm5Class12doNewIsolateEv", - module); - } -#endif - // Create fieldLookupLLVM { std::vector args; Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Tue Apr 8 12:06:22 2008 @@ -13,27 +13,12 @@ #include -#include -#include #include -#include #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - +#include +#include #include "mvm/JIT.h" #include "mvm/Method.h" @@ -48,7 +33,6 @@ #include "JavaThread.h" #include "JavaTypes.h" #include "Jnjvm.h" -#include "Reader.h" #include "OpcodeNames.def" Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp Tue Apr 8 12:06:22 2008 @@ -7,145 +7,79 @@ // //===----------------------------------------------------------------------===// +#include #include -#include -#include +#include +#include +#include #include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "llvm/Constants.h" -#include "llvm/DerivedTypes.h" -#include "llvm/Module.h" -#include "llvm/ModuleProvider.h" -#include "llvm/PassManager.h" -#include "llvm/ValueSymbolTable.h" -#include "llvm/Analysis/LoadValueNumbering.h" -#include "llvm/Analysis/LoopPass.h" -#include "llvm/Analysis/Verifier.h" -#include "llvm/Assembly/Writer.h" -#include "llvm/Assembly/PrintModulePass.h" -#include "llvm/Bitcode/ReaderWriter.h" -#include "llvm/CodeGen/RegAllocRegistry.h" -#include "llvm/CodeGen/SchedulerRegistry.h" -#include "llvm/CodeGen/ScheduleDAG.h" -#include "llvm/Target/SubtargetFeature.h" -#include "llvm/Target/TargetData.h" -#include "llvm/Target/TargetLowering.h" -#include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetMachineRegistry.h" -#include "llvm/Transforms/Scalar.h" -#include "llvm/Transforms/IPO.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/StringMap.h" -#include "llvm/Support/Streams.h" -#include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/MemoryBuffer.h" - -#include - +#include "llvm/ExecutionEngine/GenericValue.h" #include "mvm/JIT.h" #include "mvm/Method.h" #include "debug.h" #include "JavaArray.h" -#include "JavaCache.h" #include "JavaClass.h" -#include "JavaConstantPool.h" -#include "JavaObject.h" #include "JavaJIT.h" -#include "JavaString.h" +#include "JavaObject.h" #include "JavaThread.h" #include "JavaTypes.h" -#include "JavaUpcalls.h" #include "Jnjvm.h" -#include "JnjvmModuleProvider.h" -#include "NativeUtil.h" -#include "Reader.h" -#include "Zip.h" - -#include - using namespace jnjvm; using namespace llvm; -#ifndef SINGLE_VM -GlobalVariable* Class::staticVar(llvm::Module* compilingModule) { +Value* Class::staticVar(Module* compilingModule, BasicBlock* currentBlock) { + if (!_staticVar) { aquire(); if (!_staticVar) { +#ifdef MULTIPLE_VM if (isolate == Jnjvm::bootstrapVM) { _staticVar = llvmVar(compilingModule); - release(); - return _staticVar; } else { - isolate->protectModule->lock(); - _staticVar = new GlobalVariable(JavaObject::llvmType, false, - GlobalValue::ExternalLinkage, - JavaJIT::constantJavaObjectNull, "", - isolate->module); - isolate->protectModule->unlock(); - - // TODO: put an initializer in here - void* ptr = mvm::jit::executionEngine->getPointerToGlobal(_staticVar); - GenericValue Val = GenericValue((void*)staticInstance()); - llvm::GenericValue * Ptr = (llvm::GenericValue*)ptr; - mvm::jit::executionEngine->StoreValueToMemory(Val, Ptr, staticType); - } - } - release(); - } - - return _staticVar; -} -#else -GlobalVariable* Class::staticVar(llvm::Module* compilingModule) { - if (!_staticVar) { - aquire(); - if (!_staticVar) { - - JavaObject* obj = staticInstance(); - mvm::jit::protectConstants();//->lock(); - Constant* cons = - ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (obj)), - JavaObject::llvmType); - mvm::jit::unprotectConstants();//->unlock(); +#endif + JavaObject* obj = staticInstance(); + mvm::jit::protectConstants();//->lock(); + Constant* cons = + ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, + uint64_t (obj)), JavaObject::llvmType); + mvm::jit::unprotectConstants();//->unlock(); - isolate->protectModule->lock(); - _staticVar = new GlobalVariable(JavaObject::llvmType, true, + isolate->protectModule->lock(); + _staticVar = new GlobalVariable(JavaObject::llvmType, true, GlobalValue::ExternalLinkage, cons, "", isolate->module); - isolate->protectModule->unlock(); - + isolate->protectModule->unlock(); + } +#ifdef MULTIPLE_VM } +#endif release(); } - return _staticVar; -} + +#ifdef MULTIPLE_VM + if (isolate == Jnjvm::bootstrapVM) { + Value* ld = new LoadInst(_staticVar, "", currentBlock); + return llvm::CallInst::Create(JavaJIT::getStaticInstanceLLVM, ld, "", + currentBlock); + } else { +#endif + return new LoadInst(_staticVar, "", currentBlock); +#ifdef MULTIPLE_VM + } #endif +} GlobalVariable* CommonClass::llvmVar(llvm::Module* compilingModule) { if (!_llvmVar) { aquire(); if (!_llvmVar) { -#ifndef SINGLE_VM +#ifdef MULTIPLE_VM if (compilingModule == Jnjvm::bootstrapVM->module && isArray && isolate != Jnjvm::bootstrapVM) { // We know the array class can belong to bootstrap _llvmVar = Jnjvm::bootstrapVM->constructArray(this->name, 0)->llvmVar(compilingModule); @@ -173,8 +107,8 @@ return _llvmVar; } -#ifdef SINGLE_VM -GlobalVariable* CommonClass::llvmDelegatee() { +Value* CommonClass::llvmDelegatee(llvm::Module* M, llvm::BasicBlock* BB) { +#ifndef MULTIPLE_VM if (!_llvmDelegatee) { aquire(); if (!_llvmDelegatee) { @@ -183,7 +117,7 @@ JavaObject* obj = getClassDelegatee(); mvm::jit::protectConstants();//->lock(); Constant* cons = - ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (obj)), + ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64(obj)), pty); mvm::jit::unprotectConstants();//->unlock(); @@ -196,9 +130,12 @@ } release(); } - return _llvmDelegatee; -} + return new LoadInst(_llvmDelegatee, "", BB); +#else + Value* ld = new LoadInst(llvmVar(M), "", BB); + return llvm::CallInst::Create(JavaJIT::getClassDelegateeLLVM, ld, "", BB); #endif +} ConstantInt* JavaObject::classOffset() { return mvm::jit::constantOne; Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp Tue Apr 8 12:06:22 2008 @@ -18,6 +18,8 @@ using namespace jnjvm; +mvm::Lock* JavaObject::globalLock = 0; + JavaCond* JavaCond::allocate() { return gc_new(JavaCond)(); } Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Tue Apr 8 12:06:22 2008 @@ -26,6 +26,44 @@ using namespace jnjvm; +llvm::Function* JavaJIT::getSJLJBufferLLVM = 0; +llvm::Function* JavaJIT::throwExceptionLLVM = 0; +llvm::Function* JavaJIT::getExceptionLLVM = 0; +llvm::Function* JavaJIT::getJavaExceptionLLVM = 0; +llvm::Function* JavaJIT::clearExceptionLLVM = 0; +llvm::Function* JavaJIT::compareExceptionLLVM = 0; +llvm::Function* JavaJIT::nullPointerExceptionLLVM = 0; +llvm::Function* JavaJIT::classCastExceptionLLVM = 0; +llvm::Function* JavaJIT::indexOutOfBoundsExceptionLLVM = 0; +llvm::Function* JavaJIT::markAndTraceLLVM = 0; +llvm::Function* JavaJIT::javaObjectTracerLLVM = 0; +llvm::Function* JavaJIT::virtualLookupLLVM = 0; +llvm::Function* JavaJIT::fieldLookupLLVM = 0; +llvm::Function* JavaJIT::UTF8AconsLLVM = 0; +llvm::Function* JavaJIT::Int8AconsLLVM = 0; +llvm::Function* JavaJIT::Int32AconsLLVM = 0; +llvm::Function* JavaJIT::Int16AconsLLVM = 0; +llvm::Function* JavaJIT::FloatAconsLLVM = 0; +llvm::Function* JavaJIT::DoubleAconsLLVM = 0; +llvm::Function* JavaJIT::LongAconsLLVM = 0; +llvm::Function* JavaJIT::ObjectAconsLLVM = 0; +llvm::Function* JavaJIT::printExecutionLLVM = 0; +llvm::Function* JavaJIT::printMethodStartLLVM = 0; +llvm::Function* JavaJIT::printMethodEndLLVM = 0; +llvm::Function* JavaJIT::jniProceedPendingExceptionLLVM = 0; +llvm::Function* JavaJIT::doNewLLVM = 0; +llvm::Function* JavaJIT::doNewUnknownLLVM = 0; +llvm::Function* JavaJIT::initialiseObjectLLVM = 0; +llvm::Function* JavaJIT::newLookupLLVM = 0; +llvm::Function* JavaJIT::instanceOfLLVM = 0; +llvm::Function* JavaJIT::aquireObjectLLVM = 0; +llvm::Function* JavaJIT::releaseObjectLLVM = 0; +llvm::Function* JavaJIT::multiCallNewLLVM = 0; +llvm::Function* JavaJIT::runtimeUTF8ToStrLLVM = 0; +llvm::Function* JavaJIT::getStaticInstanceLLVM = 0; +llvm::Function* JavaJIT::getClassDelegateeLLVM = 0; +llvm::Function* JavaJIT::arrayLengthLLVM = 0; + extern "C" JavaString* runtimeUTF8ToStr(const UTF8* val) { Jnjvm* vm = JavaThread::get()->isolate; return vm->UTF8ToStr(val); @@ -161,7 +199,7 @@ JavaThread::get()->isolate->indexOutOfBounds(obj, index); } -#ifndef SINGLE_VM +#ifdef MULTIPLE_VM extern "C" JavaObject* getStaticInstance(Class* cl) { if (cl->isolate == Jnjvm::bootstrapVM) { Jnjvm* vm = JavaThread::get()->isolate; @@ -182,20 +220,9 @@ } #endif -void JavaJIT::runtimeInitialise() { +void JavaJIT::initialise() { void* p; p = (void*)&runtimeUTF8ToStr; - p = (void*)&fieldLookup; - p = (void*)&virtualLookup; - p = (void*)&printExecution; - p = (void*)&jniProceedPendingException; - p = (void*)&nullPointerException; - p = (void*)&classCastException; - p = (void*)&indexOutOfBoundsException; -#ifndef SINGLE_VM - p = (void*)&getStaticInstance; - p = (void*)&getClassDelegatee; -#endif } extern "C" Class* newLookup(Class* caller, uint32 index, Class** toAlloc) { Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp Tue Apr 8 12:06:22 2008 @@ -40,25 +40,24 @@ } JavaThread* JavaThread::get() { - return threadKey->get(); + return (JavaThread*)Thread::threadKey->get(); } extern void AddStandardCompilePasses(llvm::FunctionPassManager*); -JavaThread* JavaThread::allocate(JavaObject* thread, Jnjvm* isolate) { - JavaThread* key = gc_new(JavaThread)(); - key->javaThread = thread; - key->isolate = isolate; - key->lock = mvm::Lock::allocNormal(); - key->varcond = mvm::Cond::allocCond(); - key->interruptFlag = 0; - key->state = StateRunning; - key->self = mvm::Thread::self(); - key->pendingException = 0; - key->perFunctionPasses = new llvm::FunctionPassManager(isolate->TheModuleProvider); - key->perFunctionPasses->add(new llvm::TargetData(isolate->module)); - AddStandardCompilePasses(key->perFunctionPasses); - return key; +void JavaThread::initialise(JavaObject* thread, Jnjvm* isolate) { + this->javaThread = thread; + this->isolate = isolate; + this->lock = mvm::Lock::allocNormal(); + this->varcond = mvm::Cond::allocCond(); + this->interruptFlag = 0; + this->state = StateRunning; + this->self = mvm::Thread::self(); + this->pendingException = 0; + ModuleProvider* MP = isolate->TheModuleProvider; + this->perFunctionPasses = new llvm::FunctionPassManager(MP); + this->perFunctionPasses->add(new llvm::TargetData(isolate->module)); + AddStandardCompilePasses(this->perFunctionPasses); } JavaObject* JavaThread::currentThread() { Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h Tue Apr 8 12:06:22 2008 @@ -18,6 +18,7 @@ #include "mvm/Threads/Cond.h" #include "mvm/Threads/Key.h" #include "mvm/Threads/Locks.h" +#include "mvm/Threads/Thread.h" namespace jnjvm { @@ -25,7 +26,7 @@ class JavaObject; class Jnjvm; -class JavaThread : public mvm::Object { +class JavaThread : public mvm::Thread { public: static VirtualTable *VT; JavaObject* javaThread; @@ -50,10 +51,8 @@ virtual void tracer(size_t sz); virtual void destroyer(size_t sz); - static mvm::Key* threadKey; - + void initialise(JavaObject* thread, Jnjvm* isolate); static JavaThread* get(); - static JavaThread* allocate(JavaObject* thread, Jnjvm* isolate); static JavaObject* currentThread(); static void* getException(); Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Tue Apr 8 12:06:22 2008 @@ -7,12 +7,8 @@ // //===----------------------------------------------------------------------===// -// realpath -#include -#include - #include - +#include #include #include #include @@ -41,6 +37,44 @@ using namespace jnjvm; +Jnjvm* Jnjvm::bootstrapVM = 0; + +#define DEF_UTF8(var) \ + const UTF8* Jnjvm::var = 0; + + DEF_UTF8(initName); + DEF_UTF8(clinitName); + DEF_UTF8(clinitType); + DEF_UTF8(runName); + DEF_UTF8(prelib); + DEF_UTF8(postlib); + DEF_UTF8(mathName); + DEF_UTF8(abs); + DEF_UTF8(sqrt); + DEF_UTF8(sin); + DEF_UTF8(cos); + DEF_UTF8(tan); + DEF_UTF8(asin); + DEF_UTF8(acos); + DEF_UTF8(atan); + DEF_UTF8(atan2); + DEF_UTF8(exp); + DEF_UTF8(log); + DEF_UTF8(pow); + DEF_UTF8(ceil); + DEF_UTF8(floor); + DEF_UTF8(rint); + DEF_UTF8(cbrt); + DEF_UTF8(cosh); + DEF_UTF8(expm1); + DEF_UTF8(hypot); + DEF_UTF8(log10); + DEF_UTF8(log1p); + DEF_UTF8(sinh); + DEF_UTF8(tanh); + +#undef DEF_UTF8 + const char* Jnjvm::dirSeparator = "/"; const char* Jnjvm::envSeparator = ":"; const unsigned int Jnjvm::Magic = 0xcafebabe; @@ -265,17 +299,15 @@ typedef void (*clinit_t)(void); void Jnjvm::initialiseClass(CommonClass* cl) { -start: - if (!((Class*)cl)->isReady()) { + if (cl->isArray || AssessorDesc::bogusClassToPrimitive(cl)) { + cl->status = ready; + } else if (!(cl->isReady())) { cl->aquire(); int status = cl->status; -#ifdef SINGLE_VM - if (status == ready) { -#else - if (((Class*)cl)->isReady()) { -#endif + if (cl->isReady()) { cl->release(); - } else if (status >= resolved && status != clinitParent && status != inClinit) { + } else if (status >= resolved && status != clinitParent && + status != inClinit) { cl->status = clinitParent; cl->release(); if (cl->super) { @@ -292,15 +324,9 @@ PRINT_DEBUG(JNJVM_LOAD, 0, LIGHT_GREEN, "clinit "); PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "%s::%s\n", printString(), cl->printString()); - -#ifndef SINGLE_VM - std::pair* val = 0; - if (this == bootstrapVM && !AssessorDesc::bogusClassToPrimitive(cl) && !cl->isArray) { - JavaObject* staticVar = ((Class*)cl)->createStaticInstance(); - val = new std::pair(0, staticVar); - JavaThread::get()->isolate->statics->hash((Class*)cl, val); - } -#endif + + ((Class*)cl)->createStaticInstance(); + if (meth) { JavaObject* exc = 0; try{ @@ -319,13 +345,8 @@ } } } - - cl->status = ready; -#ifndef SINGLE_VM - if (this == bootstrapVM && !AssessorDesc::bogusClassToPrimitive(cl) && !cl->isArray) { - val->first = 1; - } -#endif + + cl->setReady(); cl->broadcastClass(); } else if (status < resolved) { cl->release(); @@ -334,7 +355,7 @@ if (!cl->ownerClass()) { while (status < ready) cl->waitClass(); cl->release(); - goto start; + initialiseClass(cl); } cl->release(); } @@ -770,22 +791,10 @@ } const UTF8* Jnjvm::asciizConstructUTF8(const char* asciiz) { -#ifndef SINGLE_VM - if (this != bootstrapVM) { - const UTF8* existing = bootstrapVM->hashUTF8->lookupAsciiz(asciiz); - if (existing) return existing; - } -#endif return hashUTF8->lookupOrCreateAsciiz(asciiz); } const UTF8* Jnjvm::readerConstructUTF8(const uint16* buf, uint32 size) { -#ifndef SINGLE_VM - if (this != bootstrapVM) { - const UTF8* existing = bootstrapVM->hashUTF8->lookupReader(buf, size); - if (existing) return existing; - } -#endif return hashUTF8->lookupOrCreateReader(buf, size); } @@ -803,18 +812,13 @@ } CommonClass* Jnjvm::loadInClassLoader(const UTF8* name, JavaObject* loader) { + JavaString* str = this->UTF8ToStr(name); JavaObject* obj = (JavaObject*) - Classpath::loadInClassLoader->invokeJavaObjectVirtual(loader, this->UTF8ToStr(name)); + Classpath::loadInClassLoader->invokeJavaObjectVirtual(loader, str); return (CommonClass*)((*Classpath::vmdataClass)(obj).PointerVal); } JavaString* Jnjvm::UTF8ToStr(const UTF8* utf8) { -#ifndef SINGLE_VM - if (this != bootstrapVM) { - JavaString* existing = bootstrapVM->hashStr->lookup(utf8); - if (existing) return existing; - } -#endif JavaString* res = hashStr->lookupOrCreate(utf8, this, JavaString::stringDup); return res; } @@ -828,7 +832,7 @@ postProperties.push_back(std::make_pair(key, value)); } -#ifdef SINGLE_VM +#ifndef MULTIPLE_VM JavaObject* Jnjvm::getClassDelegatee(CommonClass* cl) { if (!(cl->delegatee)) { JavaObject* delegatee = (*Classpath::newClass)(); @@ -838,7 +842,8 @@ JavaObject* pd = cl->delegatee; JavaObject* delegatee = (*Classpath::newClass)(); cl->delegatee = delegatee;; - Classpath::initClassWithProtectionDomain->invokeIntSpecial(delegatee, cl, pd); + Classpath::initClassWithProtectionDomain->invokeIntSpecial(delegatee, cl, + pd); } return cl->delegatee; } Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h Tue Apr 8 12:06:22 2008 @@ -241,7 +241,7 @@ MethodMap* loadedMethods; FieldMap* loadedFields; TypeMap* javaTypes; -#ifndef SINGLE_VM +#ifdef MULTIPLE_VM StaticInstanceMap* statics; DelegateeMap* delegatees; #endif Modified: vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h Tue Apr 8 12:06:22 2008 @@ -33,7 +33,7 @@ struct ltutf8 { -#ifndef SINGLE_VM +#ifdef MULTIPLE_VM bool operator()(const UTF8* s1, const UTF8* s2) const { if (s1->size < s2->size) return true; @@ -327,8 +327,6 @@ //lock->markAndTrace(); for (iterator i = map.begin(), e = map.end(); i!= e; ++i) { i->first->markAndTrace(); - printf("i->second = %p\n", i->second); - printf("second again = %p\n", i->second->second); i->second->second->markAndTrace(); } } Modified: vmkit/trunk/lib/JnJVM/VMCore/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Makefile.am?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/Makefile.am (original) +++ vmkit/trunk/lib/JnJVM/VMCore/Makefile.am Tue Apr 8 12:06:22 2008 @@ -18,6 +18,6 @@ JavaBacktrace.cpp NativeUtil.h NativeUtil.cpp Jni.cpp \ JavaCache.h JavaCache.cpp JavaUpcalls.h JavaUpcalls.cpp \ JnjvmModuleProvider.h JnjvmModuleProvider.cpp JavaRuntimeJIT.cpp JavaMetaJIT.cpp JavaJITInitialise.cpp \ - LowerArrayLength.cpp + LowerArrayLength.cpp ServiceDomain.cpp -libJnJVM_la_CXXFLAGS =$(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -DSINGLE_VM -Werror -O2 +libJnJVM_la_CXXFLAGS =$(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -Werror -O2 Modified: vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp Tue Apr 8 12:06:22 2008 @@ -53,8 +53,10 @@ service->loadedFields = FieldMap::allocate(); service->javaTypes = jnjvm::TypeMap::allocate(); service->globalRefsLock = mvm::Lock::allocNormal(); +#ifdef MULTIPLE_VM service->statics = StaticInstanceMap::allocate(); service->delegatees = DelegateeMap::allocate(); +#endif // A service is related to a class loader // Here are the classes it loaded Modified: vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp Tue Apr 8 12:06:22 2008 @@ -138,7 +138,7 @@ TRACE_VECTOR(JavaField*, virtualFields); TRACE_VECTOR(JavaField*, staticFields); classLoader->markAndTrace(); -#ifdef SINGLE_VM +#ifndef MULTIPLE_VM delegatee->markAndTrace(); #endif TRACE_VECTOR(CommonClass*, display); @@ -263,7 +263,7 @@ TRACE_VECTOR(JavaObject*, globalRefs); //globalRefsLock->markAndTrace(); functions->markAndTrace(); -#ifndef SINGLE_VM +#ifdef MULTIPLE_VM statics->markAndTrace(); delegatees->markAndTrace(); #endif Modified: vmkit/trunk/lib/Mvm/Allocator/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Allocator/Makefile.am?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Allocator/Makefile.am (original) +++ vmkit/trunk/lib/Mvm/Allocator/Makefile.am Tue Apr 8 12:06:22 2008 @@ -2,7 +2,7 @@ noinst_PROGRAMS = mainuvm_alloc libuvm_alloc_a_SOURCES = gcalloc.cpp gcalloc.h gcchunk.cpp gcchunk.h gcerror.cpp gcerror.h gcmapper.cpp gcmapper.h osdep.h -libuvm_alloc_a_CXXFLAGS = -O2 -W -Wall -Werror -ansi -pedantic -Wno-variadic-macros -Wno-unused-parameter +libuvm_alloc_a_CXXFLAGS = -O2 -W -Wall -Werror -ansi -pedantic -Wno-variadic-macros -Wno-unused-parameter -DSERVICE_VM mainuvm_alloc_SOURCES = main.cpp mainuvm_alloc_CXXFLAGS = Modified: vmkit/trunk/lib/Mvm/CommonThread/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/Makefile.am?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/CommonThread/Makefile.am (original) +++ vmkit/trunk/lib/Mvm/CommonThread/Makefile.am Tue Apr 8 12:06:22 2008 @@ -6,6 +6,6 @@ ALLOCLIBS = $(ALLOCDIR)/libuvm_alloc.a libuvm_common_thread_a_SOURCES = cterror.h ctthread.cpp cterror.cpp ctlock.cpp -libuvm_common_thread_a_CXXFLAGS = -frepo -O2 -W -Wall -Werror -ansi -pedantic -Wno-unused-parameter +libuvm_common_thread_a_CXXFLAGS = -frepo -O2 -W -Wall -Werror -ansi -pedantic -Wno-unused-parameter -DSERVICE_VM CLEANFILES = *~ *.bak .*.sw? Modified: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h Tue Apr 8 12:06:22 2008 @@ -19,7 +19,7 @@ namespace mvm { -class GCCollector { +class GCCollector : public Collector { #ifdef HAVE_PTHREAD friend class GCThread; #endif Modified: vmkit/trunk/lib/Mvm/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/JIT.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/JIT.cpp (original) +++ vmkit/trunk/lib/Mvm/JIT.cpp Tue Apr 8 12:06:22 2008 @@ -7,60 +7,16 @@ // //===----------------------------------------------------------------------===// -#include -#include -#include #include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "llvm/Constants.h" -#include "llvm/DerivedTypes.h" -#include "llvm/Module.h" -#include "llvm/ModuleProvider.h" -#include "llvm/PassManager.h" -#include "llvm/ValueSymbolTable.h" -#include "llvm/Analysis/LoopPass.h" -#include "llvm/Analysis/Verifier.h" -#include "llvm/Assembly/Writer.h" -#include "llvm/Assembly/PrintModulePass.h" -#include "llvm/Bitcode/ReaderWriter.h" -#include "llvm/CodeGen/RegAllocRegistry.h" -#include "llvm/CodeGen/SchedulerRegistry.h" -#include "llvm/CodeGen/ScheduleDAG.h" -#include "llvm/Target/SubtargetFeature.h" -#include "llvm/Target/TargetData.h" -#include "llvm/Target/TargetLowering.h" -#include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetMachineRegistry.h" -#include "llvm/Transforms/Scalar.h" -#include "llvm/Transforms/IPO.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/StringMap.h" -#include "llvm/Support/Streams.h" -#include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/MemoryBuffer.h" +#include #include "llvm/Support/MutexGuard.h" - -#include +#include "llvm/Target/TargetOptions.h" #include #include "mvm/JIT.h" #include "mvm/Method.h" -#include "mvm/VMLet.h" #include "MvmMemoryManager.h" @@ -89,61 +45,6 @@ printf("%s\n", obj->printString()); } -static void addPass(FunctionPassManager *PM, Pass *P) { - // Add the pass to the pass manager... - PM->add(P); -} - -void jit::AddStandardCompilePasses(FunctionPassManager *PM) { - llvm::MutexGuard locked(mvm::jit::executionEngine->lock); - // LLVM does not allow calling functions from other modules in verifier - //PM->add(createVerifierPass()); // Verify that input is correct - - addPass(PM, createCFGSimplificationPass()); // Clean up disgusting code - addPass(PM, createScalarReplAggregatesPass());// Kill useless allocas - addPass(PM, createInstructionCombiningPass()); // Clean up after IPCP & DAE - addPass(PM, createCFGSimplificationPass()); // Clean up after IPCP & DAE - addPass(PM, createPromoteMemoryToRegisterPass());// Kill useless allocas - addPass(PM, createInstructionCombiningPass()); // Clean up after IPCP & DAE - addPass(PM, createCFGSimplificationPass()); // Clean up after IPCP & DAE - - addPass(PM, createTailDuplicationPass()); // Simplify cfg by copying code - addPass(PM, createInstructionCombiningPass()); // Cleanup for scalarrepl. - addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs - addPass(PM, createScalarReplAggregatesPass()); // Break up aggregate allocas - addPass(PM, createInstructionCombiningPass()); // Combine silly seq's - addPass(PM, createCondPropagationPass()); // Propagate conditionals - - - addPass(PM, createTailCallEliminationPass()); // Eliminate tail calls - addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs - addPass(PM, createReassociatePass()); // Reassociate expressions - addPass(PM, createLoopRotatePass()); - addPass(PM, createLICMPass()); // Hoist loop invariants - addPass(PM, createLoopUnswitchPass()); // Unswitch loops. - addPass(PM, createInstructionCombiningPass()); // Clean up after LICM/reassoc - addPass(PM, createIndVarSimplifyPass()); // Canonicalize indvars - addPass(PM, createLoopUnrollPass()); // Unroll small loops - addPass(PM, createInstructionCombiningPass()); // Clean up after the unroller - addPass(PM, createGVNPass()); // GVN for load instructions - addPass(PM, createGCSEPass()); // Remove common subexprs - addPass(PM, createSCCPPass()); // Constant prop with SCCP - - - // Run instcombine after redundancy elimination to exploit opportunities - // opened up by them. - addPass(PM, createInstructionCombiningPass()); - addPass(PM, createCondPropagationPass()); // Propagate conditionals - - addPass(PM, createDeadStoreEliminationPass()); // Delete dead stores - addPass(PM, createAggressiveDCEPass()); // SSA based 'Aggressive DCE' - addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs - -} - - - - static void initialiseTypes(llvm::Module* mod) { { // llvm::Type Definitions @@ -317,7 +218,7 @@ extern "C" void __register_frame(void*); -void VMLet::initialise() { +void mvm::jit::initialise() { llvm::SizedMemoryCode = true; llvm::NoFramePointerElim = true; llvm::ExceptionHandling = true; Modified: vmkit/trunk/lib/Mvm/Main.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Main.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Main.cpp (original) +++ vmkit/trunk/lib/Mvm/Main.cpp Tue Apr 8 12:06:22 2008 @@ -8,10 +8,9 @@ //===----------------------------------------------------------------------===// #include "mvm/GC/GC.h" +#include "mvm/JIT.h" #include "mvm/PrintBuffer.h" #include "mvm/Threads/Thread.h" -#include "mvm/Sigsegv.h" -#include "mvm/VMLet.h" #include @@ -44,14 +43,15 @@ int base; llvm::cl::ParseCommandLineOptions(argc, argv, " VMKit: a virtual machine launcher\n"); - Object::initialise(&base); - VMLet::initialise(); + jit::initialise(); + Object::initialise(); + Collector::initialise(Object::markAndTraceRoots, &base); CommandLine cl; cl.start(); clearSignals(); - Thread::exit(0); + Thread::exit(0); return 0; } Modified: vmkit/trunk/lib/Mvm/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Makefile.am?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Makefile.am (original) +++ vmkit/trunk/lib/Mvm/Makefile.am Tue Apr 8 12:06:22 2008 @@ -15,6 +15,6 @@ PREFIX=@prefix@ main_SOURCES = Main.cpp Object.cpp Sigsegv.cpp JIT.cpp CommandLine.cpp CommandLine.h MvmMemoryManager.h MvmMemoryManager.cpp EscapeAnalysis.cpp Disassembler.cpp -main_CXXFLAGS = $(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -pedantic -Wno-long-long -fno-omit-frame-pointer -O2 -g +main_CXXFLAGS = $(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -pedantic -Wno-long-long -fno-omit-frame-pointer -O2 -g -DSERVICE_VM main_LDFLAGS=@rdynamic@ main_LDADD = $(LIBSUVM) @LLVMDYLIB@ Modified: vmkit/trunk/lib/Mvm/Object.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Object.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Object.cpp (original) +++ vmkit/trunk/lib/Mvm/Object.cpp Tue Apr 8 12:06:22 2008 @@ -13,6 +13,8 @@ #include "mvm/Object.h" #include "mvm/PrintBuffer.h" #include "mvm/GC/GC.h" +#include "mvm/Threads/Key.h" +#include "mvm/Threads/Thread.h" using namespace mvm; @@ -23,10 +25,12 @@ VirtualTable *NativeString::VT = 0; VirtualTable *PrintBuffer::VT = 0; +mvm::Key* mvm::Thread::threadKey = 0; + Object **Object::rootTable= 0; -int Object::rootTableSize= 0; -int Object::rootTableLimit= 0; +int Object::rootTableSize= 0; +int Object::rootTableLimit= 0; void Object::growRootTable(void) { if (rootTableLimit != 0) { @@ -46,7 +50,7 @@ rootTable[i]->markAndTrace(); } -void Object::initialise(void *b_sp) { +void Object::initialise() { # define INIT(X) { \ X fake; \ X::VT = ((void**)(void*)(&fake))[0]; } @@ -59,16 +63,15 @@ INIT(ExceptionTable); #undef INIT - - Collector::initialise(Object::markAndTraceRoots, b_sp); + Thread::threadKey = new mvm::Key(); } void Code::tracer(size_t sz) { - ((Code *)this)->method(sz)->markAndTrace(); + this->method(sz)->markAndTrace(); } void Method::tracer(size_t sz) { - Method *const self= (Method *)this; + Method *const self= (Method *)this; self->definition()->markAndTrace(); self->literals()->markAndTrace(); self->name()->markAndTrace(); @@ -77,7 +80,7 @@ } void PrintBuffer::tracer(size_t sz) { - ((PrintBuffer *)this)->contents()->markAndTrace(); + ((PrintBuffer *)this)->contents()->markAndTrace(); } PrintBuffer *PrintBuffer::alloc(void) { @@ -86,24 +89,24 @@ PrintBuffer *PrintBuffer::writeObj(const Object *obj) { - Object *beg = (Object*)Collector::begOf(obj); - - if(beg) { - if(beg == obj) - obj->print((mvm::PrintBuffer*)this); - else { - write("print(this); - write("] -- offset "); - writeS4((intptr_t)obj - (intptr_t)beg); - write(">"); - } - } else { - write(""); - } - return this; + Object *beg = (Object*)Collector::begOf(obj); + + if(beg) { + if(beg == obj) { + obj->print((mvm::PrintBuffer*)this); + } else { + write("print(this); + write("] -- offset "); + writeS4((intptr_t)obj - (intptr_t)beg); + write(">"); + } + } else { + write(""); + } + return this; } extern "C" void write_ptr(PrintBuffer* buf, void* obj) { @@ -120,30 +123,30 @@ char *Object::printString(void) const { PrintBuffer *buf= PrintBuffer::alloc(); - buf->writeObj(this); + buf->writeObj(this); return buf->contents()->cString(); } void Object::print(PrintBuffer *buf) const { - buf->write("writePtr((void*)this); + buf->write("writePtr((void*)this); buf->write(">"); } void Code::print(PrintBuffer *buf) const { - buf->write("Code<"); - buf->write(">"); + buf->write("Code<"); + buf->write(">"); } void Method::print(PrintBuffer *buf) const { Method *const self= (Method *)this; - buf->write("Method<"); + buf->write("Method<"); if (self->name()) { - self->name()->print(buf); + self->name()->print(buf); } else { buf->write("lambda"); } - buf->write(">"); + buf->write(">"); } void NativeString::print(PrintBuffer *buf) const { @@ -152,23 +155,27 @@ for (size_t i= 0; i < strlen(self->cString()); ++i) { int c= self->cString()[i]; switch (c) { - case '\b': buf->write("\\b"); break; - case '\f': buf->write("\\f"); break; - case '\n': buf->write("\\n"); break; - case '\r': buf->write("\\r"); break; - case '\t': buf->write("\\t"); break; - case '"': buf->write("\\\""); break; - default: { - char esc[32]; - if (c < 32) - sprintf(esc, "\\x%02x", c); - else - sprintf(esc, "%c", c); - buf->write(esc); - } - } + case '\b': buf->write("\\b"); break; + case '\f': buf->write("\\f"); break; + case '\n': buf->write("\\n"); break; + case '\r': buf->write("\\r"); break; + case '\t': buf->write("\\t"); break; + case '"': buf->write("\\\""); break; + default: { + char esc[32]; + if (c < 32) + sprintf(esc, "\\x%02x", c); + else + sprintf(esc, "%c", c); + buf->write(esc); + } + } } buf->write("\""); } NativeString *PrintBuffer::getContents() { return contents(); } + +Thread* Thread::get() { + return (Thread*)Thread::threadKey->get(); +} Modified: vmkit/trunk/lib/Mvm/Sigsegv.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Sigsegv.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Sigsegv.cpp (original) +++ vmkit/trunk/lib/Mvm/Sigsegv.cpp Tue Apr 8 12:06:22 2008 @@ -10,7 +10,6 @@ #include "mvm/GC/GC.h" #include "mvm/Sigsegv.h" -#include "mvm/VMLet.h" #include #include @@ -24,49 +23,41 @@ #endif void sigsegv_handler(int n, siginfo_t *_info, void *context) { - void *addr = _info->si_addr; + void *addr = _info->si_addr; #if defined(__i386__) - struct frame { - struct frame *caller; - void *ip; - }; - - struct frame *fp; /* my frame */ - asm ("mov %%ebp, %0" : "=&r"(fp)); /* get it */ - struct frame *caller = fp->caller; /* my caller */ + struct frame { + struct frame *caller; + void *ip; + }; + + /* my frame */ + struct frame *fp; + /* get it */ + asm ("mov %%ebp, %0" : "=&r"(fp)); + /* my caller */ + struct frame *caller = fp->caller; /* preserve my caller if I return from the handler */ - void *caller_ip = caller->ip; + void *caller_ip = caller->ip; -# if defined(__MACH__) +#if defined(__MACH__) //.gregs[REG_EIP]; /* just like it's on the stack.. */ - caller->ip = (void *)((ucontext_t*)context)->uc_mcontext->__ss.__eip; -# else - /* comme si c'?tait lui qui ?tait sur la pile... */ - caller->ip = (void *)((ucontext_t*)context)->uc_mcontext.gregs[REG_EIP]; -# endif + caller->ip = (void *)((ucontext_t*)context)->uc_mcontext->__ss.__eip; +#else + /* just like it's on the stack... */ + caller->ip = (void *)((ucontext_t*)context)->uc_mcontext.gregs[REG_EIP]; +#endif #endif - /* Free the GC if it sisgegv'd. No other collection is possible */ - Collector::die_if_sigsegv_occured_during_collection(addr); + /* Free the GC if it sisgegv'd. No other collection is possible */ + Collector::die_if_sigsegv_occured_during_collection(addr); - // sys_exit(0); - if(client_sigsegv_handler) - client_sigsegv_handler(n, addr); - else - signal(SIGSEGV, SIG_DFL); + // sys_exit(0); + if(client_sigsegv_handler) + client_sigsegv_handler(n, addr); + else + signal(SIGSEGV, SIG_DFL); #if defined(__i386__) - caller->ip = caller_ip; /* restore the caller ip */ + caller->ip = caller_ip; /* restore the caller ip */ #endif } - -void VMLet::register_sigsegv_handler(void (*fct)(int, void *)) { - struct sigaction sa; - - sigaction(SIGSEGV, 0, &sa); - sa.sa_sigaction = sigsegv_handler; - sa.sa_flags |= (SA_RESTART | SA_SIGINFO | SA_NODEFER); - sigaction(SIGSEGV, &sa, 0); - client_sigsegv_handler = fct; -} - Modified: vmkit/trunk/lib/N3/Main.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/Main.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/N3/Main.cpp (original) +++ vmkit/trunk/lib/N3/Main.cpp Tue Apr 8 12:06:22 2008 @@ -7,76 +7,28 @@ // //===----------------------------------------------------------------------===// +#include "mvm/JIT.h" #include "mvm/GC/GC.h" #include "mvm/PrintBuffer.h" -#include "mvm/VMLet.h" -#include "mvm/Threads/Thread.h" - - -#include -#include -#include -#include #include "llvm/Support/ManagedStatic.h" using namespace mvm; -typedef int (*boot_t)(int, char**, char**); - -static void clearSignals(void) { - signal(SIGINT, SIG_DFL); - signal(SIGILL, SIG_DFL); -#if !defined(WIN32) - signal(SIGIOT, SIG_DFL); - signal(SIGBUS, SIG_DFL); -#endif - signal(SIGSEGV, SIG_DFL); -} - extern "C" int boot(); extern "C" int start_app(int, char**); -#include "VMCore/CLIJit.h" - -void handler2(int n, void *context) { - printf("[%d] crashed\n", (int)mvm::Thread::self()); - n3::CLIJit::printBacktrace(); - assert(0); -} - -void handler(int n, siginfo_t *_info, void *context) { - printf("[%d] crashed\n", (int)mvm::Thread::self()); - n3::CLIJit::printBacktrace(); - assert(0); -} int main(int argc, char **argv, char **envp) { llvm::llvm_shutdown_obj X; int base; - struct sigaction sa; - - sigaction(SIGINT, 0, &sa); - sa.sa_sigaction = handler; - sa.sa_flags |= (SA_RESTART | SA_SIGINFO | SA_NODEFER); - sigaction(SIGINT, &sa, 0); - - sigaction(SIGILL, 0, &sa); - sa.sa_sigaction = handler; - sa.sa_flags |= (SA_RESTART | SA_SIGINFO | SA_NODEFER); - sigaction(SIGILL, &sa, 0); - - - VMLet::register_sigsegv_handler(handler2); - - Object::initialise(&base); - VMLet::initialise(); + jit::initialise(); + Object::initialise(); + Collector::initialise(Object::markAndTraceRoots, &base); boot(); start_app(argc, argv); - clearSignals(); - return 0; } Modified: vmkit/trunk/lib/N3/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/Makefile.am?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/N3/Makefile.am (original) +++ vmkit/trunk/lib/N3/Makefile.am Tue Apr 8 12:06:22 2008 @@ -14,6 +14,6 @@ main_SOURCES = ../Mvm/Object.cpp ../Mvm/Sigsegv.cpp Main.cpp ../Mvm/MvmMemoryManager.cpp ../Mvm/JIT.cpp ../Mvm/EscapeAnalysis.cpp -main_CXXFLAGS = $(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -Werror -O2 +main_CXXFLAGS = $(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -Werror -O2 -DSINGLE_VM main_LDADD = VMCore/.libs/libN3.a $(LIBSUVM) @LLVMDYLIB@ main_LDFLAGS = @rdynamic@ Modified: vmkit/trunk/lib/N3/VMCore/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Makefile.am?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/Makefile.am (original) +++ vmkit/trunk/lib/N3/VMCore/Makefile.am Tue Apr 8 12:06:22 2008 @@ -16,4 +16,4 @@ Opcodes.cpp NativeUtil.h NativeUtil.cpp PNetLib.cpp N3ModuleProvider.cpp N3ModuleProvider.h \ PNetLib.h BackTrace.cpp LowerArrayLength.cpp -libN3_la_CXXFLAGS =$(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -O2 +libN3_la_CXXFLAGS =$(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -O2 -DSINGLE_VM Modified: vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp Tue Apr 8 12:06:22 2008 @@ -32,7 +32,6 @@ N3* N3::bootstrapVM = 0; mvm::Lock* VMObject::globalLock = 0; -mvm::Key* VMThread::threadKey = 0; VMCommonClass* VMClassArray::SuperArray = 0; std::vector VMClassArray::InterfacesArray; @@ -237,9 +236,6 @@ VMObject::globalLock = mvm::Lock::allocNormal(); //mvm::Object::pushRoot((mvm::Object*)VMObject::globalLock); - VMThread::threadKey = new mvm::Key(); - //mvm::Object::pushRoot((mvm::Object*)VMThread::threadKey); - N3* vm = N3::bootstrapVM = N3::allocateBootstrap(); mvm::Object::pushRoot((mvm::Object*)N3::bootstrapVM); Modified: vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp Tue Apr 8 12:06:22 2008 @@ -11,7 +11,6 @@ #include #include "mvm/JIT.h" -#include "mvm/VMLet.h" #include "Assembly.h" #include "CLIJit.h" Modified: vmkit/trunk/lib/N3/VMCore/VMThread.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMThread.cpp?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/VMThread.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/VMThread.cpp Tue Apr 8 12:06:22 2008 @@ -40,7 +40,7 @@ } VMThread* VMThread::get() { - return threadKey->get(); + return (VMThread*)threadKey->get(); } extern void AddStandardCompilePasses(llvm::FunctionPassManager*); Modified: vmkit/trunk/lib/N3/VMCore/VMThread.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMThread.h?rev=49388&r1=49387&r2=49388&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/VMThread.h (original) +++ vmkit/trunk/lib/N3/VMCore/VMThread.h Tue Apr 8 12:06:22 2008 @@ -18,6 +18,7 @@ #include "mvm/Threads/Cond.h" #include "mvm/Threads/Key.h" #include "mvm/Threads/Locks.h" +#include "mvm/Threads/Thread.h" namespace n3 { @@ -25,7 +26,7 @@ class VMClass; class VMObject; -class VMThread : public mvm::Object { +class VMThread : public mvm::Thread { public: static VirtualTable *VT; VMObject* vmThread; @@ -46,8 +47,6 @@ virtual void tracer(size_t sz); virtual void destroyer(size_t sz); - static mvm::Key* threadKey; - static VMThread* get(); static VMThread* allocate(VMObject* thread, VirtualMachine* vm); static VMObject* currentThread(); From baldrick at free.fr Tue Apr 8 12:42:00 2008 From: baldrick at free.fr (Duncan Sands) Date: Tue, 8 Apr 2008 19:42:00 +0200 Subject: [llvm-commits] [llvm] r49361 - in /llvm/trunk: include/llvm/Target/TargetOptions.h lib/CodeGen/DwarfWriter.cpp lib/Target/PowerPC/PPCRegisterInfo.cpp lib/Target/TargetMachine.cpp lib/Target/X86/X86RegisterInfo.cpp In-Reply-To: <83BF0839-F328-48CE-87EE-9DEC1F72057D@apple.com> References: <200804080010.m380AOMa012356@zion.cs.uiuc.edu> <200804080916.03997.baldrick@free.fr> <83BF0839-F328-48CE-87EE-9DEC1F72057D@apple.com> Message-ID: <200804081942.00982.baldrick@free.fr> On Tuesday 8 April 2008 17:11:07 Dale Johannesen wrote: > > On Apr 8, 2008, at 12:16 AM, Duncan Sands wrote: > > > Hi Dale, looks good to me except for the name. > > > >> + cl::opt > >> + DisableUnwindTables("disable-required-unwind-tables", > >> + cl::desc("Do not require unwinding info for all > >> functions"), > >> + cl::location(UnwindTablesOptional), > >> + cl::init(false)); > > > > How about "discard-unwind-tables" with comment > > "Only generate unwind tables for functions that require them". > > "discard" implies discarding all of them which isn't necessarily what > happens. Correct, but the comment explains more clearly. > Is your objection to the length, or the meaning, or what? When I read disable-required-unwind-tables, I had no idea what it meant. In fact I still don't see what it's supposed to mean. disable-require-unwind-tables makes more sense to me, but seems convoluted. How about unwind-tables-optional? Ciao, D. From dalej at apple.com Tue Apr 8 12:50:01 2008 From: dalej at apple.com (Dale Johannesen) Date: Tue, 8 Apr 2008 10:50:01 -0700 Subject: [llvm-commits] [llvm] r49361 - in /llvm/trunk: include/llvm/Target/TargetOptions.h lib/CodeGen/DwarfWriter.cpp lib/Target/PowerPC/PPCRegisterInfo.cpp lib/Target/TargetMachine.cpp lib/Target/X86/X86RegisterInfo.cpp In-Reply-To: <200804081942.00982.baldrick@free.fr> References: <200804080010.m380AOMa012356@zion.cs.uiuc.edu> <200804080916.03997.baldrick@free.fr> <83BF0839-F328-48CE-87EE-9DEC1F72057D@apple.com> <200804081942.00982.baldrick@free.fr> Message-ID: <2863BC34-A744-4DC5-A8AC-D5BC689FD583@apple.com> On Apr 8, 2008, at 10:42 AM, Duncan Sands wrote: > On Tuesday 8 April 2008 17:11:07 Dale Johannesen wrote: >> >> On Apr 8, 2008, at 12:16 AM, Duncan Sands wrote: >> >>> Hi Dale, looks good to me except for the name. >>> >>>> + cl::opt >>>> + DisableUnwindTables("disable-required-unwind-tables", >>>> + cl::desc("Do not require unwinding info for all >>>> functions"), >>>> + cl::location(UnwindTablesOptional), >>>> + cl::init(false)); >>> >>> How about "discard-unwind-tables" with comment >>> "Only generate unwind tables for functions that require them". >> >> "discard" implies discarding all of them which isn't necessarily what >> happens. > > Correct, but the comment explains more clearly. > >> Is your objection to the length, or the meaning, or what? > > When I read disable-required-unwind-tables, I had no idea what it > meant. > In fact I still don't see what it's supposed to mean. > disable-require-unwind-tables makes more sense to me, but seems > convoluted. How about unwind-tables-optional? I'm OK with that. From dalej at apple.com Tue Apr 8 13:07:50 2008 From: dalej at apple.com (Dale Johannesen) Date: Tue, 08 Apr 2008 18:07:50 -0000 Subject: [llvm-commits] [llvm] r49389 - /llvm/trunk/lib/Target/TargetMachine.cpp Message-ID: <200804081807.m38I7olB009538@zion.cs.uiuc.edu> Author: johannes Date: Tue Apr 8 13:07:49 2008 New Revision: 49389 URL: http://llvm.org/viewvc/llvm-project?rev=49389&view=rev Log: Rename -disable-required-unwind-tables to unwind-tables-optional. Modified: llvm/trunk/lib/Target/TargetMachine.cpp Modified: llvm/trunk/lib/Target/TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachine.cpp?rev=49389&r1=49388&r2=49389&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/TargetMachine.cpp Tue Apr 8 13:07:49 2008 @@ -85,8 +85,8 @@ cl::location(ExceptionHandling), cl::init(false)); cl::opt - DisableUnwindTables("disable-required-unwind-tables", - cl::desc("Do not require unwinding info for all functions"), + DisableUnwindTables("unwind-tables-optional", + cl::desc("Generate unwinding tables only for functions that require them"), cl::location(UnwindTablesOptional), cl::init(false)); From evan.cheng at apple.com Tue Apr 8 13:07:51 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 8 Apr 2008 11:07:51 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r49386 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <200804081648.m38Gm4vW007166@zion.cs.uiuc.edu> References: <200804081648.m38Gm4vW007166@zion.cs.uiuc.edu> Message-ID: <2C3A9B5E-4F8C-494F-98AA-E79A673A31E0@apple.com> Hi Devang, This is somewhat confusing to me. isShadowRet means returning an aggregate in a shadow argument, while isAggrRet means returning an aggregare using multiple scalar values? Thanks, Evan On Apr 8, 2008, at 9:48 AM, Devang Patel wrote: > Author: dpatel > Date: Tue Apr 8 11:48:04 2008 > New Revision: 49386 > > URL: http://llvm.org/viewvc/llvm-project?rev=49386&view=rev > Log: > Keep track of calls that return multiple values. > > Modified: > llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp > > Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=49386&r1=49385&r2=49386&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) > +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Apr 8 11:48:04 2008 > @@ -2311,6 +2311,7 @@ > Value *TheValue; > MemRef RetBuf; > bool isShadowRet; > + bool isAggrRet; > > FunctionCallArgumentConversion(SmallVector &ops, > const FunctionType *FnTy, > @@ -2318,7 +2319,8 @@ > bool ReturnSlotOpt, > LLVMFoldingBuilder &b) > : CallOperands(ops), FTy(FnTy), DestLoc(destloc), > - useReturnSlot(ReturnSlotOpt), Builder(b), > isShadowRet(false) { } > + useReturnSlot(ReturnSlotOpt), Builder(b), isShadowRet(false), > + isAggrRet(false) { } > > // Push the address of an argument. > void pushAddress(Value *Loc) { > @@ -2367,6 +2369,7 @@ > } > > bool isShadowReturn() { return isShadowRet; } > + bool isAggrReturn() { return isAggrRet; } > > // EmitShadowResult - If the return result was redirected to a > buffer, > // emit it now. > @@ -2406,6 +2409,7 @@ > /// returns an aggregate value using multiple return values. > void HandleAggregateResultAsAggregate(const Type *AggrTy) { > // There is nothing to do here. > + isAggrRet = true; > } > > /// HandleAggregateShadowArgument - This callback is invoked if > the function > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From dpatel at apple.com Tue Apr 8 13:08:24 2008 From: dpatel at apple.com (Devang Patel) Date: Tue, 08 Apr 2008 18:08:24 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49390 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <200804081808.m38I8OEF009561@zion.cs.uiuc.edu> Author: dpatel Date: Tue Apr 8 13:08:24 2008 New Revision: 49390 URL: http://llvm.org/viewvc/llvm-project?rev=49390&view=rev Log: Store multiple return values in destination aggregate value. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=49390&r1=49389&r2=49390&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Apr 8 13:08:24 2008 @@ -2644,6 +2644,18 @@ Call->setName("tmp"); + if (Client.isAggrReturn()) { + const StructType *STy = cast(Call->getType()); + unsigned NumElements = STy->getNumElements(); + for (unsigned i = 0; i < NumElements; i++) { + //DPATEL + Value *GEP = Builder.CreateStructGEP(DestLoc->Ptr, i, "mrv_gep"); + GetResultInst *GR = Builder.CreateGetResult(Call, i, "mrv_gr"); + Builder.CreateStore(GR, GEP, DestLoc->Volatile); + } + return 0; + } + // If the caller expects an aggregate, we have a situation where the ABI for // the current target specifies that the aggregate be returned in scalar // registers even though it is an aggregate. We must bitconvert the scalar From dalej at apple.com Tue Apr 8 13:10:08 2008 From: dalej at apple.com (Dale Johannesen) Date: Tue, 08 Apr 2008 18:10:08 -0000 Subject: [llvm-commits] [llvm] r49391 - in /llvm/trunk/test/CodeGen: PowerPC/compare-fcmp-ord.ll PowerPC/fold-li.ll PowerPC/reg-coalesce-simple.ll PowerPC/rotl-2.ll X86/2006-03-02-InstrSchedBug.ll X86/2006-05-02-InstrSched1.ll X86/2006-05-02-InstrSched2.ll X86/2006-05-11-InstrSched.ll X86/2007-09-17-ObjcFrameEH.ll X86/constant-pool-remat-0.ll X86/dagcombine-cse.ll X86/iabs.ll X86/or-branch.ll X86/select.ll X86/setuge.ll X86/zero-remat.ll Message-ID: <200804081810.m38IA9GB009629@zion.cs.uiuc.edu> Author: johannes Date: Tue Apr 8 13:10:08 2008 New Revision: 49391 URL: http://llvm.org/viewvc/llvm-project?rev=49391&view=rev Log: Rename -disable-required-unwind-tables to -unwind-tables-optional. Modified: llvm/trunk/test/CodeGen/PowerPC/compare-fcmp-ord.ll llvm/trunk/test/CodeGen/PowerPC/fold-li.ll llvm/trunk/test/CodeGen/PowerPC/reg-coalesce-simple.ll llvm/trunk/test/CodeGen/PowerPC/rotl-2.ll llvm/trunk/test/CodeGen/X86/2006-03-02-InstrSchedBug.ll llvm/trunk/test/CodeGen/X86/2006-05-02-InstrSched1.ll llvm/trunk/test/CodeGen/X86/2006-05-02-InstrSched2.ll llvm/trunk/test/CodeGen/X86/2006-05-11-InstrSched.ll llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll llvm/trunk/test/CodeGen/X86/constant-pool-remat-0.ll llvm/trunk/test/CodeGen/X86/dagcombine-cse.ll llvm/trunk/test/CodeGen/X86/iabs.ll llvm/trunk/test/CodeGen/X86/or-branch.ll llvm/trunk/test/CodeGen/X86/select.ll llvm/trunk/test/CodeGen/X86/setuge.ll llvm/trunk/test/CodeGen/X86/zero-remat.ll Modified: llvm/trunk/test/CodeGen/PowerPC/compare-fcmp-ord.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/compare-fcmp-ord.ll?rev=49391&r1=49390&r2=49391&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/compare-fcmp-ord.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/compare-fcmp-ord.ll Tue Apr 8 13:10:08 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=ppc32 -disable-required-unwind-tables | grep or | count 3 +; RUN: llvm-as < %s | llc -march=ppc32 -unwind-tables-optional | grep or | count 3 ; This should produce one 'or' or 'cror' instruction per function. define i32 @test(double %x, double %y) nounwind { Modified: llvm/trunk/test/CodeGen/PowerPC/fold-li.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/fold-li.ll?rev=49391&r1=49390&r2=49391&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/fold-li.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/fold-li.ll Tue Apr 8 13:10:08 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=ppc32 -disable-required-unwind-tables | \ +; RUN: llvm-as < %s | llc -march=ppc32 -unwind-tables-optional | \ ; RUN: grep -v align | not grep li ;; Test that immediates are folded into these instructions correctly. Modified: llvm/trunk/test/CodeGen/PowerPC/reg-coalesce-simple.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/reg-coalesce-simple.ll?rev=49391&r1=49390&r2=49391&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/reg-coalesce-simple.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/reg-coalesce-simple.ll Tue Apr 8 13:10:08 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=ppc32 -disable-required-unwind-tables | not grep or +; RUN: llvm-as < %s | llc -march=ppc32 -unwind-tables-optional | not grep or %struct.foo = type { i32, i32, [0 x i8] } Modified: llvm/trunk/test/CodeGen/PowerPC/rotl-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/rotl-2.ll?rev=49391&r1=49390&r2=49391&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/rotl-2.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/rotl-2.ll Tue Apr 8 13:10:08 2008 @@ -1,6 +1,6 @@ -; RUN: llvm-as < %s | llc -march=ppc32 -disable-required-unwind-tables | grep rlwinm | count 4 -; RUN: llvm-as < %s | llc -march=ppc32 -disable-required-unwind-tables | grep rlwnm | count 2 -; RUN: llvm-as < %s | llc -march=ppc32 -disable-required-unwind-tables | not grep or +; RUN: llvm-as < %s | llc -march=ppc32 -unwind-tables-optional | grep rlwinm | count 4 +; RUN: llvm-as < %s | llc -march=ppc32 -unwind-tables-optional | grep rlwnm | count 2 +; RUN: llvm-as < %s | llc -march=ppc32 -unwind-tables-optional | not grep or define i32 @rotl32(i32 %A, i8 %Amt) nounwind { %shift.upgrd.1 = zext i8 %Amt to i32 ; [#uses=1] Modified: llvm/trunk/test/CodeGen/X86/2006-03-02-InstrSchedBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2006-03-02-InstrSchedBug.ll?rev=49391&r1=49390&r2=49391&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2006-03-02-InstrSchedBug.ll (original) +++ llvm/trunk/test/CodeGen/X86/2006-03-02-InstrSchedBug.ll Tue Apr 8 13:10:08 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=x86 -disable-required-unwind-tables -stats |& \ +; RUN: llvm-as < %s | llc -march=x86 -unwind-tables-optional -stats |& \ ; RUN: grep asm-printer | grep 7 define i32 @g(i32 %a, i32 %b) nounwind { Modified: llvm/trunk/test/CodeGen/X86/2006-05-02-InstrSched1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2006-05-02-InstrSched1.ll?rev=49391&r1=49390&r2=49391&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2006-05-02-InstrSched1.ll (original) +++ llvm/trunk/test/CodeGen/X86/2006-05-02-InstrSched1.ll Tue Apr 8 13:10:08 2008 @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | \ -; RUN: llc -march=x86 -relocation-model=static -disable-required-unwind-tables -stats |& \ +; RUN: llc -march=x86 -relocation-model=static -unwind-tables-optional -stats |& \ ; RUN: grep asm-printer | grep 14 ; @size20 = external global i32 ; [#uses=1] Modified: llvm/trunk/test/CodeGen/X86/2006-05-02-InstrSched2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2006-05-02-InstrSched2.ll?rev=49391&r1=49390&r2=49391&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2006-05-02-InstrSched2.ll (original) +++ llvm/trunk/test/CodeGen/X86/2006-05-02-InstrSched2.ll Tue Apr 8 13:10:08 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=x86 -stats -disable-required-unwind-tables |& \ +; RUN: llvm-as < %s | llc -march=x86 -stats -unwind-tables-optional |& \ ; RUN: grep asm-printer | grep 13 define void @_ZN9__gnu_cxx9hashtableISt4pairIKPKciES3_NS_4hashIS3_EESt10_Select1stIS5_E5eqstrSaIiEE14find_or_insertERKS5__cond_true456.i(i8* %tmp435.i, i32* %tmp449.i.out) nounwind { Modified: llvm/trunk/test/CodeGen/X86/2006-05-11-InstrSched.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2006-05-11-InstrSched.ll?rev=49391&r1=49390&r2=49391&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2006-05-11-InstrSched.ll (original) +++ llvm/trunk/test/CodeGen/X86/2006-05-11-InstrSched.ll Tue Apr 8 13:10:08 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -stats -disable-required-unwind-tables |&\ +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -stats -unwind-tables-optional |&\ ; RUN: grep {asm-printer} | grep 32 target datalayout = "e-p:32:32" Modified: llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll?rev=49391&r1=49390&r2=49391&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll (original) +++ llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll Tue Apr 8 13:10:08 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=x86 -mtriple=i686-apple-darwin -enable-eh -disable-required-unwind-tables | grep {isNullOrNil].eh"} | count 2 +; RUN: llvm-as < %s | llc -march=x86 -mtriple=i686-apple-darwin -enable-eh -unwind-tables-optional | grep {isNullOrNil].eh"} | count 2 %struct.NSString = type { } %struct._objc__method_prototype_list = type opaque Modified: llvm/trunk/test/CodeGen/X86/constant-pool-remat-0.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/constant-pool-remat-0.ll?rev=49391&r1=49390&r2=49391&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/constant-pool-remat-0.ll (original) +++ llvm/trunk/test/CodeGen/X86/constant-pool-remat-0.ll Tue Apr 8 13:10:08 2008 @@ -1,7 +1,7 @@ ; RUN: llvm-as < %s | llc -march=x86-64 | grep LCPI | count 3 -; RUN: llvm-as < %s | llc -march=x86-64 -stats -disable-required-unwind-tables -info-output-file - | grep asm-printer | grep 6 +; RUN: llvm-as < %s | llc -march=x86-64 -stats -unwind-tables-optional -info-output-file - | grep asm-printer | grep 6 ; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep LCPI | count 3 -; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -stats -disable-required-unwind-tables -info-output-file - | grep asm-printer | grep 8 +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -stats -unwind-tables-optional -info-output-file - | grep asm-printer | grep 8 declare fastcc float @qux(float %y) Modified: llvm/trunk/test/CodeGen/X86/dagcombine-cse.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/dagcombine-cse.ll?rev=49391&r1=49390&r2=49391&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/dagcombine-cse.ll (original) +++ llvm/trunk/test/CodeGen/X86/dagcombine-cse.ll Tue Apr 8 13:10:08 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -disable-required-unwind-tables -stats |& grep asm-printer | grep 14 +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -unwind-tables-optional -stats |& grep asm-printer | grep 14 define i32 @t(i8* %ref_frame_ptr, i32 %ref_frame_stride, i32 %idxX, i32 %idxY) nounwind { entry: Modified: llvm/trunk/test/CodeGen/X86/iabs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/iabs.ll?rev=49391&r1=49390&r2=49391&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/iabs.ll (original) +++ llvm/trunk/test/CodeGen/X86/iabs.ll Tue Apr 8 13:10:08 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=x86-64 -stats -disable-required-unwind-tables |& \ +; RUN: llvm-as < %s | llc -march=x86-64 -stats -unwind-tables-optional |& \ ; RUN: grep {6 .*Number of machine instrs printed} ;; Integer absolute value, should produce something at least as good as: Modified: llvm/trunk/test/CodeGen/X86/or-branch.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/or-branch.ll?rev=49391&r1=49390&r2=49391&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/or-branch.ll (original) +++ llvm/trunk/test/CodeGen/X86/or-branch.ll Tue Apr 8 13:10:08 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=x86 -disable-required-unwind-tables | not grep set +; RUN: llvm-as < %s | llc -march=x86 -unwind-tables-optional | not grep set define void @foo(i32 %X, i32 %Y, i32 %Z) nounwind { entry: Modified: llvm/trunk/test/CodeGen/X86/select.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/select.ll?rev=49391&r1=49390&r2=49391&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/select.ll (original) +++ llvm/trunk/test/CodeGen/X86/select.ll Tue Apr 8 13:10:08 2008 @@ -1,6 +1,6 @@ -; RUN: llvm-as < %s | llc -march=x86 -mcpu=pentium -disable-required-unwind-tables -; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah -disable-required-unwind-tables -; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah -disable-required-unwind-tables | not grep set +; RUN: llvm-as < %s | llc -march=x86 -mcpu=pentium -unwind-tables-optional +; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah -unwind-tables-optional +; RUN: llvm-as < %s | llc -march=x86 -mcpu=yonah -unwind-tables-optional | not grep set define i1 @boolSel(i1 %A, i1 %B, i1 %C) nounwind { %X = select i1 %A, i1 %B, i1 %C ; [#uses=1] Modified: llvm/trunk/test/CodeGen/X86/setuge.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/setuge.ll?rev=49391&r1=49390&r2=49391&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/setuge.ll (original) +++ llvm/trunk/test/CodeGen/X86/setuge.ll Tue Apr 8 13:10:08 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=x86 -disable-required-unwind-tables | not grep set +; RUN: llvm-as < %s | llc -march=x86 -unwind-tables-optional | not grep set declare i1 @llvm.isunordered.f32(float, float) Modified: llvm/trunk/test/CodeGen/X86/zero-remat.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/zero-remat.ll?rev=49391&r1=49390&r2=49391&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/zero-remat.ll (original) +++ llvm/trunk/test/CodeGen/X86/zero-remat.ll Tue Apr 8 13:10:08 2008 @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | llc -march=x86-64 | grep xor | count 4 -; RUN: llvm-as < %s | llc -march=x86-64 -stats -disable-required-unwind-tables -info-output-file - | grep asm-printer | grep 12 +; RUN: llvm-as < %s | llc -march=x86-64 -stats -unwind-tables-optional -info-output-file - | grep asm-printer | grep 12 ; RUN: llvm-as < %s | llc -march=x86 | grep fldz ; RUN: llvm-as < %s | llc -march=x86 | not grep fldl From criswell at uiuc.edu Tue Apr 8 13:51:34 2008 From: criswell at uiuc.edu (John Criswell) Date: Tue, 08 Apr 2008 18:51:34 -0000 Subject: [llvm-commits] [poolalloc] r49392 - /poolalloc/trunk/include/poolalloc/PoolAllocate.h Message-ID: <200804081851.m38IpZgg010813@zion.cs.uiuc.edu> Author: criswell Date: Tue Apr 8 13:51:34 2008 New Revision: 49392 URL: http://llvm.org/viewvc/llvm-project?rev=49392&view=rev Log: Added a few more interfaces that are needed by the PoolAllocate analysis group. Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/poolalloc/PoolAllocate.h?rev=49392&r1=49391&r2=49392&view=diff ============================================================================== --- poolalloc/trunk/include/poolalloc/PoolAllocate.h (original) +++ poolalloc/trunk/include/poolalloc/PoolAllocate.h Tue Apr 8 13:51:34 2008 @@ -115,9 +115,15 @@ public: static char ID; + Constant *PoolRegister; + virtual ~PoolAllocateGroup () {} virtual PA::FuncInfo *getFuncInfo(Function &F) { return 0;} virtual PA::FuncInfo *getFuncInfoOrClone(Function &F) {return 0;} + virtual Function *getOrigFunctionFromClone(Function *F) const {return 0;} + + virtual const Type * getPoolType() {return 0;} + virtual DSGraph & getDSGraph (const Function & F) const { return ECGraphs->getDSGraph (F); } @@ -155,9 +161,6 @@ Constant *PoolInit, *PoolDestroy, *PoolAlloc, *PoolRealloc, *PoolMemAlign; Constant *PoolFree; Constant *PoolStrdup; -#if defined(SAFECODE) || defined(BOUNDS_CHECK) - Constant *PoolRegister; -#endif static const Type *PoolDescPtrTy; From baldrick at free.fr Tue Apr 8 14:31:52 2008 From: baldrick at free.fr (Duncan Sands) Date: Tue, 08 Apr 2008 19:31:52 -0000 Subject: [llvm-commits] [llvm] r49393 - /llvm/trunk/test/CFrontend/2008-04-08-NoExceptions.c Message-ID: <200804081931.m38JVrDn012405@zion.cs.uiuc.edu> Author: baldrick Date: Tue Apr 8 14:31:52 2008 New Revision: 49393 URL: http://llvm.org/viewvc/llvm-project?rev=49393&view=rev Log: Check that bodies and calls but not declarations are marked nounwind when compiling without -fexceptions. Added: llvm/trunk/test/CFrontend/2008-04-08-NoExceptions.c Added: llvm/trunk/test/CFrontend/2008-04-08-NoExceptions.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CFrontend/2008-04-08-NoExceptions.c?rev=49393&view=auto ============================================================================== --- llvm/trunk/test/CFrontend/2008-04-08-NoExceptions.c (added) +++ llvm/trunk/test/CFrontend/2008-04-08-NoExceptions.c Tue Apr 8 14:31:52 2008 @@ -0,0 +1,7 @@ +// RUN: %llvmgcc -S -o - %s | grep nounwind | count 2 +// RUN: %llvmgcc -S -o - %s | not grep {declare.*nounwind} + +void f(void); +void g(void) { + f(); +} From dalej at apple.com Tue Apr 8 14:49:53 2008 From: dalej at apple.com (Dale Johannesen) Date: Tue, 08 Apr 2008 19:49:53 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49394 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Message-ID: <200804081949.m38Jnrj6013138@zion.cs.uiuc.edu> Author: johannes Date: Tue Apr 8 14:49:53 2008 New Revision: 49394 URL: http://llvm.org/viewvc/llvm-project?rev=49394&view=rev Log: Rename -disable-required-unwind-tables to unwind-tables-optional. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=49394&r1=49393&r2=49394&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Tue Apr 8 14:49:53 2008 @@ -132,7 +132,7 @@ // Reduce inline limit. Default limit is 200. Args.push_back("--inline-threshold=100"); if (!flag_unwind_tables) - Args.push_back("--disable-required-unwind-tables"); + Args.push_back("--unwind-tables-optional"); // If there are options that should be passed through to the LLVM backend // directly from the command line, do so now. This is mainly for debugging From clattner at apple.com Tue Apr 8 14:51:13 2008 From: clattner at apple.com (Chris Lattner) Date: Tue, 8 Apr 2008 12:51:13 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r49390 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <200804081808.m38I8OEF009561@zion.cs.uiuc.edu> References: <200804081808.m38I8OEF009561@zion.cs.uiuc.edu> Message-ID: <3F957C5E-93E3-4086-ABDC-8F1AC7ADD662@apple.com> On Apr 8, 2008, at 11:08 AM, Devang Patel wrote: > Author: dpatel > Date: Tue Apr 8 13:08:24 2008 > New Revision: 49390 > + for (unsigned i = 0; i < NumElements; i++) { > + //DPATEL > + Value *GEP = Builder.CreateStructGEP(DestLoc->Ptr, i, > "mrv_gep"); Please remove the comment :) -Chris From gohman at apple.com Tue Apr 8 14:56:50 2008 From: gohman at apple.com (Dan Gohman) Date: Tue, 08 Apr 2008 19:56:50 -0000 Subject: [llvm-commits] [test-suite] r49395 - in /test-suite/trunk/MultiSource: Applications/ClamAV/ Applications/lemon/ Applications/sqlite3/ Benchmarks/Trimaran/enc-3des/ Benchmarks/Trimaran/enc-md5/ Benchmarks/Trimaran/enc-pc1/ Benchmarks/Trimaran/enc-rc4/ Benchmarks/Trimaran/netbench-crc/ Benchmarks/Trimaran/netbench-url/ Benchmarks/VersaBench/8b10b/ Benchmarks/VersaBench/beamformer/ Benchmarks/VersaBench/bmm/ Benchmarks/VersaBench/dbms/ Benchmarks/VersaBench/ecbdes/ Message-ID: <200804081956.m38JuoDK013427@zion.cs.uiuc.edu> Author: djg Date: Tue Apr 8 14:56:50 2008 New Revision: 49395 URL: http://llvm.org/viewvc/llvm-project?rev=49395&view=rev Log: Use svn:ignore to ignore Output directories. Modified: test-suite/trunk/MultiSource/Applications/ClamAV/ (props changed) test-suite/trunk/MultiSource/Applications/lemon/ (props changed) test-suite/trunk/MultiSource/Applications/sqlite3/ (props changed) test-suite/trunk/MultiSource/Benchmarks/Trimaran/enc-3des/ (props changed) test-suite/trunk/MultiSource/Benchmarks/Trimaran/enc-md5/ (props changed) test-suite/trunk/MultiSource/Benchmarks/Trimaran/enc-pc1/ (props changed) test-suite/trunk/MultiSource/Benchmarks/Trimaran/enc-rc4/ (props changed) test-suite/trunk/MultiSource/Benchmarks/Trimaran/netbench-crc/ (props changed) test-suite/trunk/MultiSource/Benchmarks/Trimaran/netbench-url/ (props changed) test-suite/trunk/MultiSource/Benchmarks/VersaBench/8b10b/ (props changed) test-suite/trunk/MultiSource/Benchmarks/VersaBench/beamformer/ (props changed) test-suite/trunk/MultiSource/Benchmarks/VersaBench/bmm/ (props changed) test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/ (props changed) test-suite/trunk/MultiSource/Benchmarks/VersaBench/ecbdes/ (props changed) Propchange: test-suite/trunk/MultiSource/Applications/ClamAV/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Apr 8 14:56:50 2008 @@ -0,0 +1 @@ +Output Propchange: test-suite/trunk/MultiSource/Applications/lemon/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Apr 8 14:56:50 2008 @@ -0,0 +1 @@ +Output Propchange: test-suite/trunk/MultiSource/Applications/sqlite3/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Apr 8 14:56:50 2008 @@ -0,0 +1 @@ +Output Propchange: test-suite/trunk/MultiSource/Benchmarks/Trimaran/enc-3des/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Apr 8 14:56:50 2008 @@ -0,0 +1 @@ +Output Propchange: test-suite/trunk/MultiSource/Benchmarks/Trimaran/enc-md5/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Apr 8 14:56:50 2008 @@ -0,0 +1 @@ +Output Propchange: test-suite/trunk/MultiSource/Benchmarks/Trimaran/enc-pc1/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Apr 8 14:56:50 2008 @@ -0,0 +1 @@ +Output Propchange: test-suite/trunk/MultiSource/Benchmarks/Trimaran/enc-rc4/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Apr 8 14:56:50 2008 @@ -0,0 +1 @@ +Output Propchange: test-suite/trunk/MultiSource/Benchmarks/Trimaran/netbench-crc/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Apr 8 14:56:50 2008 @@ -0,0 +1 @@ +Output Propchange: test-suite/trunk/MultiSource/Benchmarks/Trimaran/netbench-url/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Apr 8 14:56:50 2008 @@ -0,0 +1 @@ +Output Propchange: test-suite/trunk/MultiSource/Benchmarks/VersaBench/8b10b/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Apr 8 14:56:50 2008 @@ -0,0 +1 @@ +Output Propchange: test-suite/trunk/MultiSource/Benchmarks/VersaBench/beamformer/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Apr 8 14:56:50 2008 @@ -0,0 +1 @@ +Output Propchange: test-suite/trunk/MultiSource/Benchmarks/VersaBench/bmm/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Apr 8 14:56:50 2008 @@ -0,0 +1 @@ +Output Propchange: test-suite/trunk/MultiSource/Benchmarks/VersaBench/dbms/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Apr 8 14:56:50 2008 @@ -0,0 +1 @@ +Output Propchange: test-suite/trunk/MultiSource/Benchmarks/VersaBench/ecbdes/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Apr 8 14:56:50 2008 @@ -0,0 +1 @@ +Output From criswell at uiuc.edu Tue Apr 8 15:05:08 2008 From: criswell at uiuc.edu (John Criswell) Date: Tue, 08 Apr 2008 20:05:08 -0000 Subject: [llvm-commits] [poolalloc] r49396 - /poolalloc/trunk/lib/DSA/Local.cpp Message-ID: <200804082005.m38K58hp013752@zion.cs.uiuc.edu> Author: criswell Date: Tue Apr 8 15:05:08 2008 New Revision: 49396 URL: http://llvm.org/viewvc/llvm-project?rev=49396&view=rev Log: Print out offending intrinsic name before assertion. Modified: poolalloc/trunk/lib/DSA/Local.cpp Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=49396&r1=49395&r2=49396&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Tue Apr 8 15:05:08 2008 @@ -574,8 +574,8 @@ return true; } - assert(0 && "Unhandled intrinsic"); DOUT << "[dsa:local] Unhandled intrinsic: " << F->getName() << "\n"; + assert(0 && "Unhandled intrinsic"); return false; } } From dpatel at apple.com Tue Apr 8 15:41:23 2008 From: dpatel at apple.com (Devang Patel) Date: Tue, 08 Apr 2008 20:41:23 -0000 Subject: [llvm-commits] [llvm] r49398 - /llvm/trunk/include/llvm/Support/LLVMBuilder.h Message-ID: <200804082041.m38KfNg1015117@zion.cs.uiuc.edu> Author: dpatel Date: Tue Apr 8 15:41:22 2008 New Revision: 49398 URL: http://llvm.org/viewvc/llvm-project?rev=49398&view=rev Log: Add CreateGetResult() Modified: llvm/trunk/include/llvm/Support/LLVMBuilder.h Modified: llvm/trunk/include/llvm/Support/LLVMBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/LLVMBuilder.h?rev=49398&r1=49397&r2=49398&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/LLVMBuilder.h (original) +++ llvm/trunk/include/llvm/Support/LLVMBuilder.h Tue Apr 8 15:41:22 2008 @@ -100,7 +100,11 @@ ReturnInst *CreateRet(Value * const* retVals, unsigned N) { return Insert(ReturnInst::Create(retVals, N)); } - + + GetResultInst *CreateGetResult(Value *V, unsigned Index, const char *Name = "") { + return Insert(new GetResultInst(V, Index, Name)); + } + /// CreateBr - Create an unconditional 'br label X' instruction. BranchInst *CreateBr(BasicBlock *Dest) { return Insert(BranchInst::Create(Dest)); From gohman at apple.com Tue Apr 8 15:56:08 2008 From: gohman at apple.com (Dan Gohman) Date: Tue, 8 Apr 2008 13:56:08 -0700 Subject: [llvm-commits] Speeding up instruction selection In-Reply-To: References: <00FB5805-1FA5-4534-BBD0-E6E34EC17BF1@apple.com> <1C1F9E6C-5B8E-4667-A119-4590F340FDE7@apple.com> <83CD954F-CD49-4D4B-950D-B6CB6CD1B32D@apple.com> <417E9823-6AF6-44B0-83FD-89F0CC079B6A@apple.com> Message-ID: <3F534552-8033-40A3-8E0A-733516299939@apple.com> On Mar 31, 2008, at 5:09 AM, Roman Levenstein wrote: > Hi Dan, Hi Evan, > > Here is the updated patch. > > 1) I introduced the SDOperandPtr class, as I suggested in my last > email. This class is a sort of an "intelligent" pointer. With this > class, there is no need to copy the SDOperand arrays into the > temporary SmallVectors. Therefore there is no additional overhead. I don't know about *no* additional overhead :-), but I don't expect it'll be a big deal. I didn't expect the previous copying solution to be a big deal either, but I think this new approach is fine. Please add a doxygen comment for the SDOperandPtr class to document it. In changes like this in SelectionDAG.h: - const SDOperand *Ops, unsigned NumOps); + const SDOperandPtr Ops, unsigned NumOps); the const is now superfluous. In the SDOperandPtr class, + SDOperandPtr(SDOperand * op_ptr) { + ptr = op_ptr; + object_size = sizeof(SDOperand); + } + + SDOperandPtr(const SDOperand * op_ptr) { + ptr = op_ptr; + object_size = sizeof(SDOperand); + } The first of these two constructors is unnecessary because the second can be used in both cases. > > 2) Additionally, I also finally made SDOperand a member of the SDUse, > instead of using it as a base class. Now we can be sure that no > unintentional conversion of SDUse into SDOperand happens. Ok. > > > 3) I also changed the return types of some methods from SDUse to > SDOperand, as it was suggested during the review. Ok. Remember that Chris also suggested that many of these methods can be changed to return an SDOperand by value instead of by reference. If you decide to do that, please do it with a separate commit. With the issues mentioned above addressed, this patch looks good to me. Thanks, Dan From dpatel at apple.com Tue Apr 8 15:58:13 2008 From: dpatel at apple.com (Devang Patel) Date: Tue, 08 Apr 2008 20:58:13 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49400 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <200804082058.m38KwDsq015704@zion.cs.uiuc.edu> Author: dpatel Date: Tue Apr 8 15:58:12 2008 New Revision: 49400 URL: http://llvm.org/viewvc/llvm-project?rev=49400&view=rev Log: oops Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=49400&r1=49399&r2=49400&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Apr 8 15:58:12 2008 @@ -2648,7 +2648,6 @@ const StructType *STy = cast(Call->getType()); unsigned NumElements = STy->getNumElements(); for (unsigned i = 0; i < NumElements; i++) { - //DPATEL Value *GEP = Builder.CreateStructGEP(DestLoc->Ptr, i, "mrv_gep"); GetResultInst *GR = Builder.CreateGetResult(Call, i, "mrv_gr"); Builder.CreateStore(GR, GEP, DestLoc->Volatile); From dpatel at apple.com Tue Apr 8 16:01:27 2008 From: dpatel at apple.com (Devang Patel) Date: Tue, 8 Apr 2008 14:01:27 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r49386 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <2C3A9B5E-4F8C-494F-98AA-E79A673A31E0@apple.com> References: <200804081648.m38Gm4vW007166@zion.cs.uiuc.edu> <2C3A9B5E-4F8C-494F-98AA-E79A673A31E0@apple.com> Message-ID: <17B28120-121A-414A-A8D5-17F6D569F733@apple.com> On Apr 8, 2008, at 11:07 AM, Evan Cheng wrote: > Hi Devang, > > This is somewhat confusing to me. isShadowRet means returning an > aggregate in a shadow argument, while isAggrRet means returning an > aggregare using multiple scalar values? yes. - Devang From ggreif at gmail.com Tue Apr 8 16:22:37 2008 From: ggreif at gmail.com (Gabor Greif) Date: Tue, 08 Apr 2008 21:22:37 -0000 Subject: [llvm-commits] [llvm] r49401 - in /llvm/branches/ggreif/use-diet: include/llvm/User.h lib/VMCore/Use.cpp Message-ID: <200804082122.m38LMhFw016761@zion.cs.uiuc.edu> Author: ggreif Date: Tue Apr 8 16:22:23 2008 New Revision: 49401 URL: http://llvm.org/viewvc/llvm-project?rev=49401&view=rev Log: use the fact that 's' is always followed by '1' to peel off one memory access when decoding Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49401&r1=49400&r2=49401&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/User.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/User.h Tue Apr 8 16:22:23 2008 @@ -110,7 +110,7 @@ Only the significant number of bits need to be stored between the -stops, so that the worst case is 21 memory accesses when there are +stops, so that the worst case is 20 memory accesses when there are 1000 Use objects. The following literate Haskell fragment demonstrates the concept: @@ -141,7 +141,7 @@ > pref :: [Char] -> Int > pref "S" = 1 -> pref ('s':rest) = decode 1 0 rest +> pref ('s':'1':rest) = decode 2 1 rest > pref (_:rest) = 1 + pref rest > > decode walk acc ('0':rest) = decode (walk + 1) (acc * 2) rest Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp?rev=49401&r1=49400&r2=49401&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Tue Apr 8 16:22:23 2008 @@ -23,7 +23,7 @@ const Use *Use::getImpliedUser() const { bool StopEncountered = false; - ptrdiff_t Offset = 0; + ptrdiff_t Offset = 1; const Use *Current = this; while (true) { @@ -39,7 +39,8 @@ if (StopEncountered) return Current + Offset; StopEncountered = true; - break; + Current += 2; + continue; case fullStopTag: return Current + 1; } From evan.cheng at apple.com Tue Apr 8 16:32:31 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 8 Apr 2008 14:32:31 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r49386 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <17B28120-121A-414A-A8D5-17F6D569F733@apple.com> References: <200804081648.m38Gm4vW007166@zion.cs.uiuc.edu> <2C3A9B5E-4F8C-494F-98AA-E79A673A31E0@apple.com> <17B28120-121A-414A-A8D5-17F6D569F733@apple.com> Message-ID: Can you give the later a better name? isMultiValueRet? Thanks, Evan On Apr 8, 2008, at 2:01 PM, Devang Patel wrote: > > On Apr 8, 2008, at 11:07 AM, Evan Cheng wrote: > >> Hi Devang, >> >> This is somewhat confusing to me. isShadowRet means returning an >> aggregate in a shadow argument, while isAggrRet means returning an >> aggregare using multiple scalar values? > > yes. > > - > Devang > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Tue Apr 8 16:38:18 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 8 Apr 2008 14:38:18 -0700 Subject: [llvm-commits] PATCH: Tailcallopt x86 byval argument handling In-Reply-To: References: Message-ID: Hi Arnold, Nitpicks: I prefer function names which do not require decoding. :-) How about EmitTailCallLoadRetAddress instead of EmitTCRetAddrLoad? Same for EmitTCRetAddrStore. + MVT::ValueType VT = Is64Bit ? MVT::i64 : MVT::i32; + SDOperand NewRetAddrFrIdx = DAG.getFrameIndex(NewReturnAddrFI, VT); Please use getPointerTy() instead. +bool +X86TargetLowering::CopyByValClobberedRegToVirtReg(bool containsByValArg, + int CntUsedVRegsByVal, + unsigned VRegsByVal [3], + unsigned VRegsByValDest [3], + MVT::ValueType VRegsByValVTs [3], + std::pair &RegToPass, + SDOperand &OutChain, + SDOperand &OutFlag, + MachineFunction &MF, + SelectionDAG & DAG) { + if (!containsByValArg || !(RegToPass.first == X86::RSI || + RegToPass.first == X86::RDI || + RegToPass.first == X86::ESI || + RegToPass.first == X86::EDI || + RegToPass.first == X86::ECX || + RegToPass.first == X86::RCX)) return false; I am not very comfortable with this. Is the registers that can be impacted somehow specified in X86CallingConv.td? I don't want to get into a situation where someone updates the .td file but forgot to update this code. Will this work for all the CC that might want tail call support? /// RestoreByValClobberedReg - Restore registers which were overwritten by byval +/// tail call lowering from virtual registers. +static SDOperand RestoreByValClobberedReg(SelectionDAG & DAG, SDOperand Chain, + int CntUsedVRegsByVal, + unsigned VRegsByVal [3], + unsigned VRegsByValDest [3], + MVT::ValueType VRegsByValVTs [3]) { + if (!CntUsedVRegsByVal) return Chain; + SDOperand InFlag; + while (CntUsedVRegsByVal) { + CntUsedVRegsByVal--; + SDOperand Tmp = DAG.getCopyFromReg(Chain, VRegsByVal[CntUsedVRegsByVal], + VRegsByValVTs[CntUsedVRegsByVal], + InFlag); + Chain = DAG.getCopyToReg(Chain, VRegsByValDest[CntUsedVRegsByVal], + Tmp, InFlag); + InFlag = Chain.getValue(1); + } + return Chain; +} Is it necessary for all the copyfromreg and copytoreg to be chained and flagged together? Perhaps each pair need to be flagged together and chains from all pairs ended up feeding into a TokenFactor? + unsigned VRegsByVal [3]; Why the space between VRegsByVal and '['? :-) + // Remember fact that this call contains byval arguments. + if (!containsByValArg && IsTailCall && isByVal) containsByValArg=true; => containsByValArg |= isTailCall && isByVal; ? + MVT::ValueType VT = Is64Bit ? MVT::i64 : MVT::i32; FI = MF.getFrameInfo()->CreateFixedObject(OpSize, Offset); - FIN = DAG.getFrameIndex(FI, MVT::i32); + FIN = DAG.getFrameIndex(FI, VT); getPointerTy(). Thanks, Evan On Apr 7, 2008, at 3:17 PM, Arnold Schwaighofer wrote: > Hi Evan (and everyone else who wants to bash this patch :), > > this patch corrects handling of byval arguments for tailcall optimized > x86-64 (and x86) calls so that they work (... at least for my test > cases). > > Should fix the following problems: > > Problem 1: when i introduced the optimized handling of arguments for > tail called functions (not always moving them to a spill slot - > actually moving to the destination of the arg if the call were to be a > normal function call - before storing them at their 'tailcall' > position but using virtual registers) i did not handle byval arguments > correctly. > > Problem 2: on x86-64 after the arguments of the tail called function > are moved to their registers (which include ESI/RSI etc), tail call > optimization performs byval lowering which causes xSI,xDI, xCX > registers to be overwritten. this is handled in this patch by moving > the arguments to virtual registers first and after the byval lowering > the arguments are moved from those virtual registers back to > RSI/RDI/RCX. > > Okay to commit? > > regards arnold > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From arnold.schwaighofer at gmail.com Tue Apr 8 16:54:54 2008 From: arnold.schwaighofer at gmail.com (Arnold Schwaighofer) Date: Tue, 8 Apr 2008 23:54:54 +0200 Subject: [llvm-commits] PATCH: Tailcallopt x86 byval argument handling In-Reply-To: References: Message-ID: On Tue, Apr 8, 2008 at 11:38 PM, Evan Cheng wrote: > Hi Arnold, > > Nitpicks: > > I prefer function names which do not require decoding. :-) > How about EmitTailCallLoadRetAddress instead of EmitTCRetAddrLoad? > Same for EmitTCRetAddrStore. Hmm agreed. Somehow i got tempted :). > + MVT::ValueType VT = Is64Bit ? MVT::i64 : MVT::i32; > + SDOperand NewRetAddrFrIdx = DAG.getFrameIndex(NewReturnAddrFI, VT); > Please use getPointerTy() instead. > > +bool > +X86TargetLowering::CopyByValClobberedRegToVirtReg(bool > containsByValArg, > + int CntUsedVRegsByVal, > + unsigned VRegsByVal [3], > + unsigned VRegsByValDest [3], > + MVT::ValueType VRegsByValVTs [3], > + std::pair > &RegToPass, > + SDOperand &OutChain, > + SDOperand &OutFlag, > + MachineFunction &MF, > + SelectionDAG & DAG) { > + if (!containsByValArg || !(RegToPass.first == X86::RSI || > + RegToPass.first == X86::RDI || > + RegToPass.first == X86::ESI || > + RegToPass.first == X86::EDI || > + RegToPass.first == X86::ECX || > + RegToPass.first == X86::RCX)) return false; > > I am not very comfortable with this. Is the registers that can be > impacted somehow specified in X86CallingConv.td? I don't want to get > into a situation where someone updates the .td file but forgot to > update this code. I am not sure i understand. The impacted Registers RSI,RDI,RCX (or their 32bit respectives) always stay the same. They have nothing to do with the callingconvetion. A change in callling convention - which registers are used for passing does not influence above set. Above set is cause by the fact that the following sequence is neccesary for tail calls. forall actParams as ArgI move ArgI to > Will this work for all the CC that might want tail > call support? > > /// RestoreByValClobberedReg - Restore registers which were > overwritten by byval > +/// tail call lowering from virtual registers. > +static SDOperand RestoreByValClobberedReg(SelectionDAG & DAG, > SDOperand Chain, > + int CntUsedVRegsByVal, > + unsigned VRegsByVal [3], > + unsigned VRegsByValDest [3], > + MVT::ValueType > VRegsByValVTs [3]) { > + if (!CntUsedVRegsByVal) return Chain; > + SDOperand InFlag; > + while (CntUsedVRegsByVal) { > + CntUsedVRegsByVal--; > + SDOperand Tmp = DAG.getCopyFromReg(Chain, > VRegsByVal[CntUsedVRegsByVal], > + > VRegsByValVTs[CntUsedVRegsByVal], > + InFlag); > + Chain = DAG.getCopyToReg(Chain, VRegsByValDest[CntUsedVRegsByVal], > + Tmp, InFlag); > + InFlag = Chain.getValue(1); > + } > + return Chain; > +} > > Is it necessary for all the copyfromreg and copytoreg to be chained > and flagged together? Perhaps each pair need to be flagged together > and chains from all pairs ended up feeding into a TokenFactor? > > + unsigned VRegsByVal [3]; > > Why the space between VRegsByVal and '['? :-) > > + // Remember fact that this call contains byval arguments. > + if (!containsByValArg && IsTailCall && isByVal) > containsByValArg=true; > => > containsByValArg |= isTailCall && isByVal; > ? > > + MVT::ValueType VT = Is64Bit ? MVT::i64 : MVT::i32; > FI = MF.getFrameInfo()->CreateFixedObject(OpSize, Offset); > - FIN = DAG.getFrameIndex(FI, MVT::i32); > + FIN = DAG.getFrameIndex(FI, VT); > > getPointerTy(). > > Thanks, > > Evan > > > > > > On Apr 7, 2008, at 3:17 PM, Arnold Schwaighofer wrote: > > > Hi Evan (and everyone else who wants to bash this patch :), > > > > this patch corrects handling of byval arguments for tailcall optimized > > x86-64 (and x86) calls so that they work (... at least for my test > > cases). > > > > Should fix the following problems: > > > > Problem 1: when i introduced the optimized handling of arguments for > > tail called functions (not always moving them to a spill slot - > > actually moving to the destination of the arg if the call were to be a > > normal function call - before storing them at their 'tailcall' > > position but using virtual registers) i did not handle byval arguments > > correctly. > > > > Problem 2: on x86-64 after the arguments of the tail called function > > are moved to their registers (which include ESI/RSI etc), tail call > > optimization performs byval lowering which causes xSI,xDI, xCX > > registers to be overwritten. this is handled in this patch by moving > > the arguments to virtual registers first and after the byval lowering > > the arguments are moved from those virtual registers back to > > RSI/RDI/RCX. > > > > Okay to commit? > > > > regards arnold > > _______________________________________________ > > llvm-commits mailing list > > llvm-commits at cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From arnold.schwaighofer at gmail.com Tue Apr 8 17:19:47 2008 From: arnold.schwaighofer at gmail.com (Arnold Schwaighofer) Date: Wed, 9 Apr 2008 00:19:47 +0200 Subject: [llvm-commits] PATCH: Tailcallopt x86 byval argument handling In-Reply-To: References: Message-ID: Sorry i don't seem to be able to handle gmail that well this time of day :) > > I am not very comfortable with this. Is the registers that can be > > impacted somehow specified in X86CallingConv.td? I don't want to get > > into a situation where someone updates the .td file but forgot to > > update this code. I am not sure i understand. The impacted Registers RSI,RDI,RCX (or their 32bit respectives) always stays the same. They have nothing to do with the calling convention. A change in callling convention - which registers are used for passing does not influence above set (in the sence that above set is conservative, knowing the calling convention some of the above registers could be removed). It is caused by the fact that there has to be a byval lowering between moving actual parameters to registers and the tail call. the byval lowering creates new values in the RSI,RDI,RCX (ESI,EDI,ECX) registers invalidating the ones from the argument lowering - so arguments targeting those registers have to be temporarily stored to virtual registers before the byval lowering to be restored to the actual target registers aftwards. >Will this work for all the CC that might want tail >call support? probably i can not see why not. but there are other issues to support them there. (like the callee vs. caller pops issue and the PIC/GOT problem, which of course can be resolved by restricting tail call optimization to certain cases there). >Is it necessary for all the copyfromreg and copytoreg to be chained >and flagged together? Perhaps each pair need to be flagged together >and chains from all pairs ended up feeding into a TokenFactor? I will look at that. Probably not. ;) From arnold.schwaighofer at gmail.com Tue Apr 8 17:28:16 2008 From: arnold.schwaighofer at gmail.com (Arnold Schwaighofer) Date: Wed, 9 Apr 2008 00:28:16 +0200 Subject: [llvm-commits] PATCH: Tailcallopt x86 byval argument handling In-Reply-To: References: Message-ID: Maybe i should add that byval lowering generates code similar to following make the statements below clearer. leaq 32(%rsp), %rsi #source of copy movq 6, %rcx #number of bytes movq %rsp, %rdi #destination of copy rep;movsl > I am not sure i understand. The impacted Registers RSI,RDI,RCX (or > their 32bit respectives) always stays the same. They have nothing to do > with the calling convention. A change in callling convention - which > registers are used for passing does not influence above set (in the > sence that above set is conservative, knowing the calling convention > some of the above registers could be removed). It is caused by the > fact that there has to be a byval lowering between moving actual > parameters to registers and the tail call. the byval lowering creates > new values in the RSI,RDI,RCX (ESI,EDI,ECX) registers invalidating the > ones from the argument lowering - so arguments targeting those > registers have to be temporarily stored to virtual registers before > the byval lowering to be restored to the actual target registers > aftwards. From ggreif at gmail.com Tue Apr 8 17:54:01 2008 From: ggreif at gmail.com (Gabor Greif) Date: Tue, 08 Apr 2008 22:54:01 -0000 Subject: [llvm-commits] [llvm] r49407 - /llvm/branches/ggreif/use-diet/include/llvm/User.h Message-ID: <200804082254.m38Ms1aX019874@zion.cs.uiuc.edu> Author: ggreif Date: Tue Apr 8 17:54:00 2008 New Revision: 49407 URL: http://llvm.org/viewvc/llvm-project?rev=49407&view=rev Log: hackish attempt to implement a corresponding operator delete Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49407&r1=49406&r2=49407&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/User.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/User.h Tue Apr 8 17:54:00 2008 @@ -195,8 +195,8 @@ /// OperandList - This is a pointer to the array of Users for this operand. /// For nodes of fixed arity (e.g. a binary operator) this array will live /// embedded into the derived class. For nodes of variable arity - /// (e.g. ConstantArrays, CallInst, PHINodes, ReturnInst etc), this memory - /// will be dynamically allocated and should be destroyed by the classes + /// (e.g. ConstantArrays, CallInst, PHINodes, ReturnInst etc.), this memory + /// will be dynamically allocated and should be destroyed by the classes' /// virtual dtor. Use *OperandList; @@ -213,7 +213,14 @@ } User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps) : Value(Ty, vty), OperandList(OpList), NumOperands(NumOps) {} - +public: + void operator delete(void *Usr) { + User *Start = static_cast(Usr); + Use *Storage = static_cast(Usr) - Start->NumOperands; + if (Storage == Start->OperandList) + ::operator delete(Storage); // FIXME: destructors of Uses? + else ::operator delete(Usr); + } public: Value *getOperand(unsigned i) const { assert(i < NumOperands && "getOperand() out of range!"); From ggreif at gmail.com Tue Apr 8 18:22:52 2008 From: ggreif at gmail.com (Gabor Greif) Date: Tue, 08 Apr 2008 23:22:52 -0000 Subject: [llvm-commits] [llvm] r49408 - /llvm/branches/ggreif/use-diet/include/llvm/Use.h Message-ID: <200804082322.m38NMqnX021070@zion.cs.uiuc.edu> Author: ggreif Date: Tue Apr 8 18:22:52 2008 New Revision: 49408 URL: http://llvm.org/viewvc/llvm-project?rev=49408&view=rev Log: preliminary tag stripping Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Use.h?rev=49408&r1=49407&r2=49408&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Use.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Use.h Tue Apr 8 18:22:52 2008 @@ -36,18 +36,18 @@ inline void init(Value *V, User *U); Use(Value *V, User *U) { init(V, U); } - Use(const Use &U) { init(U.Val, U.U); } + Use(const Use &U) { init(U.get(), U.U); } inline ~Use() { - if (Val) removeFromList(); + if (get()) removeFromList(); } /// Default ctor - This leaves the Use completely uninitialized. The only thing /// that is valid to do with this use is to call the "init" method. - inline Use() : Val(0) {} + inline Use() {} - operator Value*() const { return Val; } - Value *get() const { return Val; } + operator Value*() const { return stripTag(Val); } + Value *get() const { return stripTag(Val); } User *getUser() const { return U; } const Use* getImpliedUser() const; static void initTags(Use *Start, Use *Stop, ptrdiff_t Done = 0); @@ -59,12 +59,12 @@ return RHS; } const Use &operator=(const Use &RHS) { - set(RHS.Val); + set(RHS.get()); return *this; } - Value *operator->() { return Val; } - const Value *operator->() const { return Val; } + Value *operator->() { return stripTag(Val); } + const Value *operator->() const { return stripTag(Val); } Use *getNext() const { return Next; } private: @@ -72,6 +72,9 @@ Value *Val; User *U; + static Value *stripTag(Value *V) { + return reinterpret_cast(reinterpret_cast(V) & ~3UL); + } void addToList(Use **List) { Next = *List; if (Next) Next->Prev = &Next; From sabre at nondot.org Tue Apr 8 19:03:58 2008 From: sabre at nondot.org (Chris Lattner) Date: Wed, 09 Apr 2008 00:03:58 -0000 Subject: [llvm-commits] [llvm] r49410 - /llvm/trunk/include/llvm/Constants.h Message-ID: <200804090003.m3903whQ022353@zion.cs.uiuc.edu> Author: lattner Date: Tue Apr 8 19:03:58 2008 New Revision: 49410 URL: http://llvm.org/viewvc/llvm-project?rev=49410&view=rev Log: make ConstantFP::isExactlyValue work for long double as well. Modified: llvm/trunk/include/llvm/Constants.h Modified: llvm/trunk/include/llvm/Constants.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=49410&r1=49409&r2=49410&view=diff ============================================================================== --- llvm/trunk/include/llvm/Constants.h (original) +++ llvm/trunk/include/llvm/Constants.h Tue Apr 8 19:03:58 2008 @@ -251,16 +251,13 @@ /// As such, this method can be used to do an exact bit-for-bit comparison of /// two floating point values. The version with a double operand is retained /// because it's so convenient to write isExactlyValue(2.0), but please use - /// it only for constants. + /// it only for simple constants. bool isExactlyValue(const APFloat& V) const; bool isExactlyValue(double V) const { - if (&Val.getSemantics() == &APFloat::IEEEdouble) - return isExactlyValue(APFloat(V)); - else if (&Val.getSemantics() == &APFloat::IEEEsingle) - return isExactlyValue(APFloat((float)V)); - assert(0); - return false; + APFloat FV(V); + FV.convert(Val.getSemantics(), APFloat::rmNearestTiesToEven); + return isExactlyValue(FV); } /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const ConstantFP *) { return true; } From sabre at nondot.org Tue Apr 8 19:07:45 2008 From: sabre at nondot.org (Chris Lattner) Date: Wed, 09 Apr 2008 00:07:45 -0000 Subject: [llvm-commits] [llvm] r49411 - in /llvm/trunk: lib/Transforms/IPO/SimplifyLibCalls.cpp test/Transforms/SimplifyLibCalls/Pow.ll Message-ID: <200804090007.m3907kZY022574@zion.cs.uiuc.edu> Author: lattner Date: Tue Apr 8 19:07:45 2008 New Revision: 49411 URL: http://llvm.org/viewvc/llvm-project?rev=49411&view=rev Log: many cleanups to the pow optimizer. Allow it to handle powf, add support for pow(x, 2.0) -> x*x. Modified: llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp llvm/trunk/test/Transforms/SimplifyLibCalls/Pow.ll Modified: llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp?rev=49411&r1=49410&r2=49411&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp Tue Apr 8 19:07:45 2008 @@ -1133,52 +1133,68 @@ struct VISIBILITY_HIDDEN PowOptimization : public LibCallOptimization { public: /// @brief Default Constructor - PowOptimization() : LibCallOptimization("pow", + PowOptimization(const char *Name) : LibCallOptimization(Name, "Number of 'pow' calls simplified") {} /// @brief Make sure that the "pow" function has the right prototype - virtual bool ValidateCalledFunction(const Function* f, SimplifyLibCalls& SLC){ - // Just make sure this has 2 arguments - return (f->arg_size() == 2); + virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){ + // Just make sure this has 2 arguments of the same FP type, which match the + // result type. + const FunctionType *FT = F->getFunctionType(); + return FT->getNumParams() == 2 && + FT->getParamType(0) == FT->getParamType(1) && + FT->getParamType(0) == FT->getReturnType() && + FT->getParamType(0)->isFloatingPoint(); } /// @brief Perform the pow optimization. - virtual bool OptimizeCall(CallInst *ci, SimplifyLibCalls &SLC) { - const Type *Ty = cast(ci->getOperand(0))->getReturnType(); - if (Ty!=Type::FloatTy && Ty!=Type::DoubleTy) + virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { + const Type *Ty = CI->getType(); + if (Ty != Type::FloatTy && Ty != Type::DoubleTy) return false; // FIXME long double not yet supported - Value* base = ci->getOperand(1); - Value* expn = ci->getOperand(2); - if (ConstantFP *Op1 = dyn_cast(base)) { - if (Op1->isExactlyValue(1.0)) // pow(1.0,x) -> 1.0 - return ReplaceCallWith(ci, ConstantFP::get(Ty, + + Value *Op1 = CI->getOperand(1); + Value *Op2 = CI->getOperand(2); + if (ConstantFP *Op1C = dyn_cast(Op1)) { + if (Op1C->isExactlyValue(1.0)) // pow(1.0, x) -> 1.0 + return ReplaceCallWith(CI, Op1C); + } + + ConstantFP *Op2C = dyn_cast(Op2); + if (Op2C == 0) return false; + + if (Op2C->getValueAPF().isZero()) { + // pow(x, 0.0) -> 1.0 + return ReplaceCallWith(CI, ConstantFP::get(Ty, Ty==Type::FloatTy ? APFloat(1.0f) : APFloat(1.0))); - } else if (ConstantFP* Op2 = dyn_cast(expn)) { - if (Op2->getValueAPF().isZero()) { - // pow(x,0.0) -> 1.0 - return ReplaceCallWith(ci, ConstantFP::get(Ty, - Ty==Type::FloatTy ? APFloat(1.0f) : APFloat(1.0))); - } else if (Op2->isExactlyValue(0.5)) { - // pow(x,0.5) -> sqrt(x) - CallInst* sqrt_inst = CallInst::Create(SLC.get_sqrt(), base, - ci->getName()+".pow",ci); - return ReplaceCallWith(ci, sqrt_inst); - } else if (Op2->isExactlyValue(1.0)) { - // pow(x,1.0) -> x - return ReplaceCallWith(ci, base); - } else if (Op2->isExactlyValue(-1.0)) { - // pow(x,-1.0) -> 1.0/x - Value *div_inst = - BinaryOperator::createFDiv(ConstantFP::get(Ty, - Ty==Type::FloatTy ? APFloat(1.0f) : APFloat(1.0)), - base, ci->getName()+".pow", ci); - return ReplaceCallWith(ci, div_inst); - } + } else if (Op2C->isExactlyValue(0.5)) { + // pow(x, 0.5) -> sqrt(x) + Value *Sqrt = CallInst::Create(SLC.get_sqrt(), Op1, "sqrt", CI); + return ReplaceCallWith(CI, Sqrt); + } else if (Op2C->isExactlyValue(1.0)) { + // pow(x, 1.0) -> x + return ReplaceCallWith(CI, Op1); + } else if (Op2C->isExactlyValue(2.0)) { + // pow(x, 2.0) -> x*x + Value *Sq = BinaryOperator::createMul(Op1, Op1, "pow2", CI); + return ReplaceCallWith(CI, Sq); + } else if (Op2C->isExactlyValue(-1.0)) { + // pow(x, -1.0) -> 1.0/x + Value *div_inst = + BinaryOperator::createFDiv(ConstantFP::get(Ty, + Ty==Type::FloatTy ? APFloat(1.0f) : APFloat(1.0)), + Op1, CI->getName()+".pow", CI); + return ReplaceCallWith(CI, div_inst); } return false; // opt failed } -} PowOptimizer; +}; +PowOptimization PowFOptimizer("powf"); +PowOptimization PowOptimizer("pow"); +PowOptimization PowLOptimizer("powl"); + + /// This LibCallOptimization will simplify calls to the "printf" library /// function. It looks for cases where the result of printf is not used and the /// operation can be reduced to something simpler. Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/Pow.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/Pow.ll?rev=49411&r1=49410&r2=49411&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/Pow.ll (original) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/Pow.ll Tue Apr 8 19:07:45 2008 @@ -1,11 +1,10 @@ ; Testcase for calls to the standard C "pow" function ; -; Equivalent to: http://gcc.gnu.org/ml/gcc-patches/2003-02/msg01786.html -; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \ -; RUN: not grep {call double .pow} -; END. +; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | not grep {call .pow} + declare double @pow(double, double) +declare float @powf(float, float) define double @test1(double %X) { %Y = call double @pow( double %X, double 0.000000e+00 ) ; [#uses=1] @@ -22,3 +21,12 @@ ret double %Y } +define double @test4(double %X) { + %Y = call double @pow( double %X, double 2.0) + ret double %Y +} + +define float @test4f(float %X) { + %Y = call float @powf( float %X, float 2.0) + ret float %Y +} From sabre at nondot.org Tue Apr 8 19:45:01 2008 From: sabre at nondot.org (Chris Lattner) Date: Wed, 09 Apr 2008 00:45:01 -0000 Subject: [llvm-commits] [llvm] r49413 - in /llvm/trunk: include/llvm/Constants.h lib/VMCore/Constants.cpp Message-ID: <200804090045.m390j12m024034@zion.cs.uiuc.edu> Author: lattner Date: Tue Apr 8 19:45:01 2008 New Revision: 49413 URL: http://llvm.org/viewvc/llvm-project?rev=49413&view=rev Log: add a version of ConstantFP::get that doesn't take a redundant Type* value, start migrating code over to use it. Modified: llvm/trunk/include/llvm/Constants.h llvm/trunk/lib/VMCore/Constants.cpp Modified: llvm/trunk/include/llvm/Constants.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=49413&r1=49412&r2=49413&view=diff ============================================================================== --- llvm/trunk/include/llvm/Constants.h (original) +++ llvm/trunk/include/llvm/Constants.h Tue Apr 8 19:45:01 2008 @@ -232,7 +232,10 @@ } public: /// get() - Static factory methods - Return objects of the specified value - static ConstantFP *get(const Type *Ty, const APFloat& V); + static ConstantFP *get(const APFloat &V); + static ConstantFP *get(const Type *Ty, const APFloat &V) { + return get(V); + } /// isValueValidForType - return true if Ty is big enough to represent V. static bool isValueValidForType(const Type *Ty, const APFloat& V); Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=49413&r1=49412&r2=49413&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Tue Apr 8 19:45:01 2008 @@ -108,15 +108,15 @@ case Type::IntegerTyID: return ConstantInt::get(Ty, 0); case Type::FloatTyID: - return ConstantFP::get(Ty, APFloat(APInt(32, 0))); + return ConstantFP::get(APFloat(APInt(32, 0))); case Type::DoubleTyID: - return ConstantFP::get(Ty, APFloat(APInt(64, 0))); + return ConstantFP::get(APFloat(APInt(64, 0))); case Type::X86_FP80TyID: - return ConstantFP::get(Ty, APFloat(APInt(80, 2, zero))); + return ConstantFP::get(APFloat(APInt(80, 2, zero))); case Type::FP128TyID: - return ConstantFP::get(Ty, APFloat(APInt(128, 2, zero), true)); + return ConstantFP::get(APFloat(APInt(128, 2, zero), true)); case Type::PPC_FP128TyID: - return ConstantFP::get(Ty, APFloat(APInt(128, 2, zero))); + return ConstantFP::get(APFloat(APInt(128, 2, zero))); case Type::PointerTyID: return ConstantPointerNull::get(cast(Ty)); case Type::StructTyID: @@ -270,7 +270,7 @@ ConstantFP *ConstantFP::getNegativeZero(const Type *Ty) { APFloat apf = cast (Constant::getNullValue(Ty))->getValueAPF(); apf.changeSign(); - return ConstantFP::get(Ty, apf); + return ConstantFP::get(apf); } bool ConstantFP::isExactlyValue(const APFloat& V) const { @@ -313,24 +313,25 @@ static ManagedStatic FPConstants; -ConstantFP *ConstantFP::get(const Type *Ty, const APFloat& V) { - // temporary - if (Ty==Type::FloatTy) - assert(&V.getSemantics()==&APFloat::IEEEsingle); - else if (Ty==Type::DoubleTy) - assert(&V.getSemantics()==&APFloat::IEEEdouble); - else if (Ty==Type::X86_FP80Ty) - assert(&V.getSemantics()==&APFloat::x87DoubleExtended); - else if (Ty==Type::FP128Ty) - assert(&V.getSemantics()==&APFloat::IEEEquad); - else if (Ty==Type::PPC_FP128Ty) - assert(&V.getSemantics()==&APFloat::PPCDoubleDouble); - else - assert(0); - +ConstantFP *ConstantFP::get(const APFloat &V) { DenseMapAPFloatKeyInfo::KeyTy Key(V); ConstantFP *&Slot = (*FPConstants)[Key]; if (Slot) return Slot; + + const Type *Ty; + if (&V.getSemantics() == &APFloat::IEEEsingle) + Ty = Type::FloatTy; + else if (&V.getSemantics() == &APFloat::IEEEdouble) + Ty = Type::DoubleTy; + else if (&V.getSemantics() == &APFloat::x87DoubleExtended) + Ty = Type::X86_FP80Ty; + else if (&V.getSemantics() == &APFloat::IEEEquad) + Ty = Type::FP128Ty; + else { + assert(&V.getSemantics() == &APFloat::PPCDoubleDouble&&"Unknown FP format"); + Ty = Type::PPC_FP128Ty; + } + return Slot = new ConstantFP(Ty, V); } From evan.cheng at apple.com Tue Apr 8 20:30:15 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 09 Apr 2008 01:30:15 -0000 Subject: [llvm-commits] [llvm] r49415 - in /llvm/trunk: lib/CodeGen/SimpleRegisterCoalescing.cpp test/CodeGen/X86/2008-04-08-CoalescerCrash.ll Message-ID: <200804090130.m391UFU5025459@zion.cs.uiuc.edu> Author: evancheng Date: Tue Apr 8 20:30:15 2008 New Revision: 49415 URL: http://llvm.org/viewvc/llvm-project?rev=49415&view=rev Log: Missed a hasInterval check. Added: llvm/trunk/test/CodeGen/X86/2008-04-08-CoalescerCrash.ll Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=49415&r1=49414&r2=49415&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Tue Apr 8 20:30:15 2008 @@ -1655,6 +1655,8 @@ LiveInterval &SrcInt = li_->getInterval(SrcReg); if (!SrcInt.empty()) return false; + if (!li_->hasInterval(DstReg)) + return false; LiveInterval &DstInt = li_->getInterval(DstReg); LiveInterval::iterator DstLR = DstInt.FindLiveRangeContaining(CopyIdx); DstInt.removeValNo(DstLR->valno); Added: llvm/trunk/test/CodeGen/X86/2008-04-08-CoalescerCrash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-04-08-CoalescerCrash.ll?rev=49415&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-04-08-CoalescerCrash.ll (added) +++ llvm/trunk/test/CodeGen/X86/2008-04-08-CoalescerCrash.ll Tue Apr 8 20:30:15 2008 @@ -0,0 +1,19 @@ +; RUN: llvm-as < %s | llc -march=x86 -mattr=+mmx + +define i32 @t2() nounwind { +entry: + tail call void asm sideeffect "# top of block", "~{dirflag},~{fpsr},~{flags},~{di},~{si},~{dx},~{cx},~{ax}"( ) nounwind + tail call void asm sideeffect ".file \224443946.c\22", "~{dirflag},~{fpsr},~{flags}"( ) nounwind + tail call void asm sideeffect ".line 8", "~{dirflag},~{fpsr},~{flags}"( ) nounwind + %tmp1 = tail call <2 x i32> asm sideeffect "movd $1, $0", "=={mm4},{bp},~{dirflag},~{fpsr},~{flags},~{memory}"( i32 undef ) nounwind ; <<2 x i32>> [#uses=1] + tail call void asm sideeffect ".file \224443946.c\22", "~{dirflag},~{fpsr},~{flags}"( ) nounwind + tail call void asm sideeffect ".line 9", "~{dirflag},~{fpsr},~{flags}"( ) nounwind + %tmp3 = tail call i32 asm sideeffect "movd $1, $0", "=={bp},{mm3},~{dirflag},~{fpsr},~{flags},~{memory}"( <2 x i32> undef ) nounwind ; [#uses=1] + tail call void asm sideeffect ".file \224443946.c\22", "~{dirflag},~{fpsr},~{flags}"( ) nounwind + tail call void asm sideeffect ".line 10", "~{dirflag},~{fpsr},~{flags}"( ) nounwind + tail call void asm sideeffect "movntq $0, 0($1,$2)", "{mm0},{di},{bp},~{dirflag},~{fpsr},~{flags},~{memory}"( <2 x i32> undef, i32 undef, i32 %tmp3 ) nounwind + tail call void asm sideeffect ".file \224443946.c\22", "~{dirflag},~{fpsr},~{flags}"( ) nounwind + tail call void asm sideeffect ".line 11", "~{dirflag},~{fpsr},~{flags}"( ) nounwind + %tmp8 = tail call i32 asm sideeffect "movd $1, $0", "=={bp},{mm4},~{dirflag},~{fpsr},~{flags},~{memory}"( <2 x i32> %tmp1 ) nounwind ; [#uses=0] + ret i32 undef +} From sabre at nondot.org Wed Apr 9 01:38:31 2008 From: sabre at nondot.org (Chris Lattner) Date: Wed, 09 Apr 2008 06:38:31 -0000 Subject: [llvm-commits] [llvm] r49416 - /llvm/trunk/lib/VMCore/Constants.cpp Message-ID: <200804090638.m396cVFK002452@zion.cs.uiuc.edu> Author: lattner Date: Wed Apr 9 01:38:30 2008 New Revision: 49416 URL: http://llvm.org/viewvc/llvm-project?rev=49416&view=rev Log: add a simplified accessor for creating an fp constant of a particular value but variable type. Modified: llvm/trunk/lib/VMCore/Constants.cpp Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=49416&r1=49415&r2=49416&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Wed Apr 9 01:38:30 2008 @@ -246,21 +246,24 @@ // ConstantFP //===----------------------------------------------------------------------===// +static const fltSemantics *TypeToFloatSemantics(const Type *Ty) { + if (Ty == Type::FloatTy) + return &APFloat::IEEEsingle; + if (Ty == Type::DoubleTy) + return &APFloat::IEEEdouble; + if (Ty == Type::X86_FP80Ty) + return &APFloat::x87DoubleExtended; + else if (Ty == Type::FP128Ty) + return &APFloat::IEEEquad; + + assert(Ty == Type::PPC_FP128Ty && "Unknown FP format"); + return &APFloat::PPCDoubleDouble; +} + ConstantFP::ConstantFP(const Type *Ty, const APFloat& V) : Constant(Ty, ConstantFPVal, 0, 0), Val(V) { - // temporary - if (Ty==Type::FloatTy) - assert(&V.getSemantics()==&APFloat::IEEEsingle); - else if (Ty==Type::DoubleTy) - assert(&V.getSemantics()==&APFloat::IEEEdouble); - else if (Ty==Type::X86_FP80Ty) - assert(&V.getSemantics()==&APFloat::x87DoubleExtended); - else if (Ty==Type::FP128Ty) - assert(&V.getSemantics()==&APFloat::IEEEquad); - else if (Ty==Type::PPC_FP128Ty) - assert(&V.getSemantics()==&APFloat::PPCDoubleDouble); - else - assert(0); + assert(&V.getSemantics() == TypeToFloatSemantics(Ty) && + "FP type Mismatch"); } bool ConstantFP::isNullValue() const { @@ -335,6 +338,15 @@ return Slot = new ConstantFP(Ty, V); } +/// get() - This returns a constant fp for the specified value in the +/// specified type. This should only be used for simple constant values like +/// 2.0/1.0 etc, that are known-valid both as double and as the target format. +ConstantFP *ConstantFP::get(const Type *Ty, double V) { + APFloat FV(V); + FV.convert(*TypeToFloatSemantics(Ty), APFloat::rmNearestTiesToEven); + return get(FV); +} + //===----------------------------------------------------------------------===// // ConstantXXX Classes //===----------------------------------------------------------------------===// From evan.cheng at apple.com Wed Apr 9 02:05:10 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 9 Apr 2008 00:05:10 -0700 Subject: [llvm-commits] PATCH: Tailcallopt x86 byval argument handling In-Reply-To: References: Message-ID: On Apr 8, 2008, at 3:19 PM, Arnold Schwaighofer wrote: > Sorry i don't seem to be able to handle gmail that well this time of > day :) > >>> I am not very comfortable with this. Is the registers that can be >>> impacted somehow specified in X86CallingConv.td? I don't want to get >>> into a situation where someone updates the .td file but forgot to >>> update this code. > I am not sure i understand. The impacted Registers RSI,RDI,RCX (or > their 32bit respectives) always stays the same. They have nothing to > do > with the calling convention. A change in callling convention - which > registers are used for passing does not influence above set (in the > sence that above set is conservative, knowing the calling convention > some of the above registers could be removed). It is caused by the > fact that there has to be a byval lowering between moving actual > parameters to registers and the tail call. the byval lowering creates > new values in the RSI,RDI,RCX (ESI,EDI,ECX) registers invalidating the > ones from the argument lowering - so arguments targeting those > registers have to be temporarily stored to virtual registers before > the byval lowering to be restored to the actual target registers > aftwards. Ok, I misread it. These are the registers that are used in the lowered memcpy code sequence for byval? The trouble is this is assuming memcpy's are always lowered a certain way which doesn't seem safe to me. There seems to be a phase ordering problem here. We need for the byval memcpy to be lowered first before we issue the copies to save these registers in virtual registers. Do you think that's possible? > > > >> Will this work for all the CC that might want tail >> call support? > probably i can not see why not. > but there are other issues to support them there. (like the callee vs. > caller pops issue and the PIC/GOT problem, which of course can be > resolved by restricting tail call optimization to certain cases > there). Ok. > >> Is it necessary for all the copyfromreg and copytoreg to be chained >> and flagged together? Perhaps each pair need to be flagged together >> and chains from all pairs ended up feeding into a TokenFactor? > I will look at that. Probably not. ;) Thanks. Evan > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Wed Apr 9 02:06:02 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 09 Apr 2008 07:06:02 -0000 Subject: [llvm-commits] [llvm] r49417 - /llvm/trunk/include/llvm/Constants.h Message-ID: <200804090706.m39762SZ003278@zion.cs.uiuc.edu> Author: evancheng Date: Wed Apr 9 02:06:01 2008 New Revision: 49417 URL: http://llvm.org/viewvc/llvm-project?rev=49417&view=rev Log: Unbreak teh build. Modified: llvm/trunk/include/llvm/Constants.h Modified: llvm/trunk/include/llvm/Constants.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=49417&r1=49416&r2=49417&view=diff ============================================================================== --- llvm/trunk/include/llvm/Constants.h (original) +++ llvm/trunk/include/llvm/Constants.h Wed Apr 9 02:06:01 2008 @@ -237,6 +237,11 @@ return get(V); } + /// get() - This returns a constant fp for the specified value in the + /// specified type. This should only be used for simple constant values like + /// 2.0/1.0 etc, that are known-valid both as double and as the target format. + ConstantFP *get(const Type *Ty, double V); + /// isValueValidForType - return true if Ty is big enough to represent V. static bool isValueValidForType(const Type *Ty, const APFloat& V); inline const APFloat& getValueAPF() const { return Val; } From baldrick at free.fr Wed Apr 9 02:47:19 2008 From: baldrick at free.fr (Duncan Sands) Date: Wed, 9 Apr 2008 09:47:19 +0200 Subject: [llvm-commits] [llvm-gcc-4.2] r49385 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <200804081646.m38GkGhm007108@zion.cs.uiuc.edu> References: <200804081646.m38GkGhm007108@zion.cs.uiuc.edu> Message-ID: <200804090947.34146.baldrick@free.fr> Hi Devang, > + Value *RetVal = DECL_LLVM(DECL_RESULT(FnDecl)); ... > + RetVal = BitCastToType(DECL_LLVM(DECL_RESULT(FnDecl)), > + PointerType::getUnqual(Fn->getReturnType())); Since RetVal was set to DECL_LLVM(DECL_RESULT(FnDecl)) above, you could use it here on the RHS. Ciao, Duncan. From baldrick at free.fr Wed Apr 9 02:51:19 2008 From: baldrick at free.fr (Duncan Sands) Date: Wed, 9 Apr 2008 09:51:19 +0200 Subject: [llvm-commits] [llvm-gcc-4.2] r49390 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <200804081808.m38I8OEF009561@zion.cs.uiuc.edu> References: <200804081808.m38I8OEF009561@zion.cs.uiuc.edu> Message-ID: <200804090951.23022.baldrick@free.fr> Hi Devang, > + if (Client.isAggrReturn()) { > + const StructType *STy = cast(Call->getType()); > + unsigned NumElements = STy->getNumElements(); > + for (unsigned i = 0; i < NumElements; i++) { > + //DPATEL > + Value *GEP = Builder.CreateStructGEP(DestLoc->Ptr, i, "mrv_gep"); is it clear that DestLoc->Ptr has the right type here? Ciao, Duncan. From resistor at mac.com Wed Apr 9 02:55:02 2008 From: resistor at mac.com (Owen Anderson) Date: Wed, 09 Apr 2008 07:55:02 -0000 Subject: [llvm-commits] [llvm] r49418 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp Message-ID: <200804090755.m397t2Y1012856@zion.cs.uiuc.edu> Author: resistor Date: Wed Apr 9 02:55:01 2008 New Revision: 49418 URL: http://llvm.org/viewvc/llvm-project?rev=49418&view=rev Log: Remove accidentally duplicated code. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=49418&r1=49417&r2=49418&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Wed Apr 9 02:55:01 2008 @@ -1586,10 +1586,6 @@ if (isa(I)) return false; - // Allocations are always unique, so don't bother value numbering them. - if (isa(I)) - return false; - if (MemCpyInst* M = dyn_cast(I)) { MemoryDependenceAnalysis& MD = getAnalysis(); From resistor at mac.com Wed Apr 9 03:23:16 2008 From: resistor at mac.com (Owen Anderson) Date: Wed, 09 Apr 2008 08:23:16 -0000 Subject: [llvm-commits] [llvm] r49419 - in /llvm/trunk: include/llvm/ include/llvm/Transforms/ lib/Transforms/Scalar/ test/Transforms/GVN/ test/Transforms/MemCpyOpt/ tools/llvm-ld/ tools/opt/ Message-ID: <200804090823.m398NHoo013835@zion.cs.uiuc.edu> Author: resistor Date: Wed Apr 9 03:23:16 2008 New Revision: 49419 URL: http://llvm.org/viewvc/llvm-project?rev=49419&view=rev Log: Factor a bunch of functionality related to memcpy and memset transforms out of GVN and into its own pass. Added: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp llvm/trunk/test/Transforms/MemCpyOpt/ llvm/trunk/test/Transforms/MemCpyOpt/2008-02-24-MultipleUseofSRet.ll - copied, changed from r49415, llvm/trunk/test/Transforms/GVN/2008-02-24-MultipleUseofSRet.ll llvm/trunk/test/Transforms/MemCpyOpt/2008-03-13-ReturnSlotBitcast.ll - copied, changed from r49415, llvm/trunk/test/Transforms/GVN/2008-03-13-ReturnSlotBitcast.ll llvm/trunk/test/Transforms/MemCpyOpt/dg.exp llvm/trunk/test/Transforms/MemCpyOpt/form-memset.ll - copied, changed from r49415, llvm/trunk/test/Transforms/GVN/form-memset.ll llvm/trunk/test/Transforms/MemCpyOpt/form-memset2.ll - copied, changed from r49415, llvm/trunk/test/Transforms/GVN/form-memset2.ll llvm/trunk/test/Transforms/MemCpyOpt/memcpy.ll - copied, changed from r49415, llvm/trunk/test/Transforms/GVN/memcpy.ll llvm/trunk/test/Transforms/MemCpyOpt/sret.ll - copied, changed from r49415, llvm/trunk/test/Transforms/GVN/sret.ll Removed: llvm/trunk/test/Transforms/GVN/2008-02-24-MultipleUseofSRet.ll llvm/trunk/test/Transforms/GVN/2008-03-13-ReturnSlotBitcast.ll llvm/trunk/test/Transforms/GVN/form-memset.ll llvm/trunk/test/Transforms/GVN/form-memset2.ll llvm/trunk/test/Transforms/GVN/memcpy.ll llvm/trunk/test/Transforms/GVN/sret.ll Modified: llvm/trunk/include/llvm/LinkAllPasses.h llvm/trunk/include/llvm/Transforms/Scalar.h llvm/trunk/lib/Transforms/Scalar/GVN.cpp llvm/trunk/tools/llvm-ld/Optimize.cpp llvm/trunk/tools/opt/opt.cpp Modified: llvm/trunk/include/llvm/LinkAllPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LinkAllPasses.h?rev=49419&r1=49418&r2=49419&view=diff ============================================================================== --- llvm/trunk/include/llvm/LinkAllPasses.h (original) +++ llvm/trunk/include/llvm/LinkAllPasses.h Wed Apr 9 03:23:16 2008 @@ -112,6 +112,7 @@ (void) llvm::createPredicateSimplifierPass(); (void) llvm::createCodeGenPreparePass(); (void) llvm::createGVNPass(); + (void) llvm::createMemCpyOptPass(); (void)new llvm::IntervalPartition(); (void)new llvm::FindUsedTypes(); Modified: llvm/trunk/include/llvm/Transforms/Scalar.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar.h?rev=49419&r1=49418&r2=49419&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Scalar.h (original) +++ llvm/trunk/include/llvm/Transforms/Scalar.h Wed Apr 9 03:23:16 2008 @@ -305,6 +305,13 @@ //===----------------------------------------------------------------------===// // +// MemCpyOpt - This pass performs optimizations related to eliminating memcpy +// calls and/or combining multiple stores into memset's. +// +FunctionPass *createMemCpyOptPass(); + +//===----------------------------------------------------------------------===// +// // CodeGenPrepare - This pass prepares a function for instruction selection. // FunctionPass *createCodeGenPreparePass(const TargetLowering *TLI = 0); Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=49419&r1=49418&r2=49419&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Wed Apr 9 03:23:16 2008 @@ -42,14 +42,6 @@ STATISTIC(NumGVNInstr, "Number of instructions deleted"); STATISTIC(NumGVNLoad, "Number of loads deleted"); -STATISTIC(NumMemSetInfer, "Number of memsets inferred"); - -namespace { - cl::opt - FormMemSet("form-memset-from-stores", - cl::desc("Transform straight-line stores to memsets"), - cl::init(true), cl::Hidden); -} //===----------------------------------------------------------------------===// // ValueTable Class @@ -668,17 +660,12 @@ bool processLoad(LoadInst* L, DenseMap &lastLoad, SmallVectorImpl &toErase); - bool processStore(StoreInst *SI, SmallVectorImpl &toErase); bool processInstruction(Instruction* I, ValueNumberedSet& currAvail, DenseMap& lastSeenLoad, SmallVectorImpl &toErase); bool processNonLocalLoad(LoadInst* L, SmallVectorImpl &toErase); - bool processMemCpy(MemCpyInst* M, MemCpyInst* MDep, - SmallVectorImpl &toErase); - bool performCallSlotOptzn(MemCpyInst* cpy, CallInst* C, - SmallVectorImpl &toErase); Value *GetValueForBlock(BasicBlock *BB, LoadInst* orig, DenseMap &Phis, bool top_level = false); @@ -983,593 +970,6 @@ return deletedLoad; } -/// isBytewiseValue - If the specified value can be set by repeating the same -/// byte in memory, return the i8 value that it is represented with. This is -/// true for all i8 values obviously, but is also true for i32 0, i32 -1, -/// i16 0xF0F0, double 0.0 etc. If the value can't be handled with a repeated -/// byte store (e.g. i16 0x1234), return null. -static Value *isBytewiseValue(Value *V) { - // All byte-wide stores are splatable, even of arbitrary variables. - if (V->getType() == Type::Int8Ty) return V; - - // Constant float and double values can be handled as integer values if the - // corresponding integer value is "byteable". An important case is 0.0. - if (ConstantFP *CFP = dyn_cast(V)) { - if (CFP->getType() == Type::FloatTy) - V = ConstantExpr::getBitCast(CFP, Type::Int32Ty); - if (CFP->getType() == Type::DoubleTy) - V = ConstantExpr::getBitCast(CFP, Type::Int64Ty); - // Don't handle long double formats, which have strange constraints. - } - - // We can handle constant integers that are power of two in size and a - // multiple of 8 bits. - if (ConstantInt *CI = dyn_cast(V)) { - unsigned Width = CI->getBitWidth(); - if (isPowerOf2_32(Width) && Width > 8) { - // We can handle this value if the recursive binary decomposition is the - // same at all levels. - APInt Val = CI->getValue(); - APInt Val2; - while (Val.getBitWidth() != 8) { - unsigned NextWidth = Val.getBitWidth()/2; - Val2 = Val.lshr(NextWidth); - Val2.trunc(Val.getBitWidth()/2); - Val.trunc(Val.getBitWidth()/2); - - // If the top/bottom halves aren't the same, reject it. - if (Val != Val2) - return 0; - } - return ConstantInt::get(Val); - } - } - - // Conceptually, we could handle things like: - // %a = zext i8 %X to i16 - // %b = shl i16 %a, 8 - // %c = or i16 %a, %b - // but until there is an example that actually needs this, it doesn't seem - // worth worrying about. - return 0; -} - -static int64_t GetOffsetFromIndex(const GetElementPtrInst *GEP, unsigned Idx, - bool &VariableIdxFound, TargetData &TD) { - // Skip over the first indices. - gep_type_iterator GTI = gep_type_begin(GEP); - for (unsigned i = 1; i != Idx; ++i, ++GTI) - /*skip along*/; - - // Compute the offset implied by the rest of the indices. - int64_t Offset = 0; - for (unsigned i = Idx, e = GEP->getNumOperands(); i != e; ++i, ++GTI) { - ConstantInt *OpC = dyn_cast(GEP->getOperand(i)); - if (OpC == 0) - return VariableIdxFound = true; - if (OpC->isZero()) continue; // No offset. - - // Handle struct indices, which add their field offset to the pointer. - if (const StructType *STy = dyn_cast(*GTI)) { - Offset += TD.getStructLayout(STy)->getElementOffset(OpC->getZExtValue()); - continue; - } - - // Otherwise, we have a sequential type like an array or vector. Multiply - // the index by the ElementSize. - uint64_t Size = TD.getABITypeSize(GTI.getIndexedType()); - Offset += Size*OpC->getSExtValue(); - } - - return Offset; -} - -/// IsPointerOffset - Return true if Ptr1 is provably equal to Ptr2 plus a -/// constant offset, and return that constant offset. For example, Ptr1 might -/// be &A[42], and Ptr2 might be &A[40]. In this case offset would be -8. -static bool IsPointerOffset(Value *Ptr1, Value *Ptr2, int64_t &Offset, - TargetData &TD) { - // Right now we handle the case when Ptr1/Ptr2 are both GEPs with an identical - // base. After that base, they may have some number of common (and - // potentially variable) indices. After that they handle some constant - // offset, which determines their offset from each other. At this point, we - // handle no other case. - GetElementPtrInst *GEP1 = dyn_cast(Ptr1); - GetElementPtrInst *GEP2 = dyn_cast(Ptr2); - if (!GEP1 || !GEP2 || GEP1->getOperand(0) != GEP2->getOperand(0)) - return false; - - // Skip any common indices and track the GEP types. - unsigned Idx = 1; - for (; Idx != GEP1->getNumOperands() && Idx != GEP2->getNumOperands(); ++Idx) - if (GEP1->getOperand(Idx) != GEP2->getOperand(Idx)) - break; - - bool VariableIdxFound = false; - int64_t Offset1 = GetOffsetFromIndex(GEP1, Idx, VariableIdxFound, TD); - int64_t Offset2 = GetOffsetFromIndex(GEP2, Idx, VariableIdxFound, TD); - if (VariableIdxFound) return false; - - Offset = Offset2-Offset1; - return true; -} - - -/// MemsetRange - Represents a range of memset'd bytes with the ByteVal value. -/// This allows us to analyze stores like: -/// store 0 -> P+1 -/// store 0 -> P+0 -/// store 0 -> P+3 -/// store 0 -> P+2 -/// which sometimes happens with stores to arrays of structs etc. When we see -/// the first store, we make a range [1, 2). The second store extends the range -/// to [0, 2). The third makes a new range [2, 3). The fourth store joins the -/// two ranges into [0, 3) which is memset'able. -namespace { -struct MemsetRange { - // Start/End - A semi range that describes the span that this range covers. - // The range is closed at the start and open at the end: [Start, End). - int64_t Start, End; - - /// StartPtr - The getelementptr instruction that points to the start of the - /// range. - Value *StartPtr; - - /// Alignment - The known alignment of the first store. - unsigned Alignment; - - /// TheStores - The actual stores that make up this range. - SmallVector TheStores; - - bool isProfitableToUseMemset(const TargetData &TD) const; - -}; -} // end anon namespace - -bool MemsetRange::isProfitableToUseMemset(const TargetData &TD) const { - // If we found more than 8 stores to merge or 64 bytes, use memset. - if (TheStores.size() >= 8 || End-Start >= 64) return true; - - // Assume that the code generator is capable of merging pairs of stores - // together if it wants to. - if (TheStores.size() <= 2) return false; - - // If we have fewer than 8 stores, it can still be worthwhile to do this. - // For example, merging 4 i8 stores into an i32 store is useful almost always. - // However, merging 2 32-bit stores isn't useful on a 32-bit architecture (the - // memset will be split into 2 32-bit stores anyway) and doing so can - // pessimize the llvm optimizer. - // - // Since we don't have perfect knowledge here, make some assumptions: assume - // the maximum GPR width is the same size as the pointer size and assume that - // this width can be stored. If so, check to see whether we will end up - // actually reducing the number of stores used. - unsigned Bytes = unsigned(End-Start); - unsigned NumPointerStores = Bytes/TD.getPointerSize(); - - // Assume the remaining bytes if any are done a byte at a time. - unsigned NumByteStores = Bytes - NumPointerStores*TD.getPointerSize(); - - // If we will reduce the # stores (according to this heuristic), do the - // transformation. This encourages merging 4 x i8 -> i32 and 2 x i16 -> i32 - // etc. - return TheStores.size() > NumPointerStores+NumByteStores; -} - - -namespace { -class MemsetRanges { - /// Ranges - A sorted list of the memset ranges. We use std::list here - /// because each element is relatively large and expensive to copy. - std::list Ranges; - typedef std::list::iterator range_iterator; - TargetData &TD; -public: - MemsetRanges(TargetData &td) : TD(td) {} - - typedef std::list::const_iterator const_iterator; - const_iterator begin() const { return Ranges.begin(); } - const_iterator end() const { return Ranges.end(); } - bool empty() const { return Ranges.empty(); } - - void addStore(int64_t OffsetFromFirst, StoreInst *SI); -}; - -} // end anon namespace - - -/// addStore - Add a new store to the MemsetRanges data structure. This adds a -/// new range for the specified store at the specified offset, merging into -/// existing ranges as appropriate. -void MemsetRanges::addStore(int64_t Start, StoreInst *SI) { - int64_t End = Start+TD.getTypeStoreSize(SI->getOperand(0)->getType()); - - // Do a linear search of the ranges to see if this can be joined and/or to - // find the insertion point in the list. We keep the ranges sorted for - // simplicity here. This is a linear search of a linked list, which is ugly, - // however the number of ranges is limited, so this won't get crazy slow. - range_iterator I = Ranges.begin(), E = Ranges.end(); - - while (I != E && Start > I->End) - ++I; - - // We now know that I == E, in which case we didn't find anything to merge - // with, or that Start <= I->End. If End < I->Start or I == E, then we need - // to insert a new range. Handle this now. - if (I == E || End < I->Start) { - MemsetRange &R = *Ranges.insert(I, MemsetRange()); - R.Start = Start; - R.End = End; - R.StartPtr = SI->getPointerOperand(); - R.Alignment = SI->getAlignment(); - R.TheStores.push_back(SI); - return; - } - - // This store overlaps with I, add it. - I->TheStores.push_back(SI); - - // At this point, we may have an interval that completely contains our store. - // If so, just add it to the interval and return. - if (I->Start <= Start && I->End >= End) - return; - - // Now we know that Start <= I->End and End >= I->Start so the range overlaps - // but is not entirely contained within the range. - - // See if the range extends the start of the range. In this case, it couldn't - // possibly cause it to join the prior range, because otherwise we would have - // stopped on *it*. - if (Start < I->Start) { - I->Start = Start; - I->StartPtr = SI->getPointerOperand(); - } - - // Now we know that Start <= I->End and Start >= I->Start (so the startpoint - // is in or right at the end of I), and that End >= I->Start. Extend I out to - // End. - if (End > I->End) { - I->End = End; - range_iterator NextI = I;; - while (++NextI != E && End >= NextI->Start) { - // Merge the range in. - I->TheStores.append(NextI->TheStores.begin(), NextI->TheStores.end()); - if (NextI->End > I->End) - I->End = NextI->End; - Ranges.erase(NextI); - NextI = I; - } - } -} - - - -/// processStore - When GVN is scanning forward over instructions, we look for -/// some other patterns to fold away. In particular, this looks for stores to -/// neighboring locations of memory. If it sees enough consequtive ones -/// (currently 4) it attempts to merge them together into a memcpy/memset. -bool GVN::processStore(StoreInst *SI, SmallVectorImpl &toErase) { - if (!FormMemSet) return false; - if (SI->isVolatile()) return false; - - // There are two cases that are interesting for this code to handle: memcpy - // and memset. Right now we only handle memset. - - // Ensure that the value being stored is something that can be memset'able a - // byte at a time like "0" or "-1" or any width, as well as things like - // 0xA0A0A0A0 and 0.0. - Value *ByteVal = isBytewiseValue(SI->getOperand(0)); - if (!ByteVal) - return false; - - TargetData &TD = getAnalysis(); - AliasAnalysis &AA = getAnalysis(); - - // Okay, so we now have a single store that can be splatable. Scan to find - // all subsequent stores of the same value to offset from the same pointer. - // Join these together into ranges, so we can decide whether contiguous blocks - // are stored. - MemsetRanges Ranges(TD); - - Value *StartPtr = SI->getPointerOperand(); - - BasicBlock::iterator BI = SI; - for (++BI; !isa(BI); ++BI) { - if (isa(BI) || isa(BI)) { - // If the call is readnone, ignore it, otherwise bail out. We don't even - // allow readonly here because we don't want something like: - // A[1] = 2; strlen(A); A[2] = 2; -> memcpy(A, ...); strlen(A). - if (AA.getModRefBehavior(CallSite::get(BI)) == - AliasAnalysis::DoesNotAccessMemory) - continue; - - // TODO: If this is a memset, try to join it in. - - break; - } else if (isa(BI) || isa(BI)) - break; - - // If this is a non-store instruction it is fine, ignore it. - StoreInst *NextStore = dyn_cast(BI); - if (NextStore == 0) continue; - - // If this is a store, see if we can merge it in. - if (NextStore->isVolatile()) break; - - // Check to see if this stored value is of the same byte-splattable value. - if (ByteVal != isBytewiseValue(NextStore->getOperand(0))) - break; - - // Check to see if this store is to a constant offset from the start ptr. - int64_t Offset; - if (!IsPointerOffset(StartPtr, NextStore->getPointerOperand(), Offset, TD)) - break; - - Ranges.addStore(Offset, NextStore); - } - - // If we have no ranges, then we just had a single store with nothing that - // could be merged in. This is a very common case of course. - if (Ranges.empty()) - return false; - - // If we had at least one store that could be merged in, add the starting - // store as well. We try to avoid this unless there is at least something - // interesting as a small compile-time optimization. - Ranges.addStore(0, SI); - - - Function *MemSetF = 0; - - // Now that we have full information about ranges, loop over the ranges and - // emit memset's for anything big enough to be worthwhile. - bool MadeChange = false; - for (MemsetRanges::const_iterator I = Ranges.begin(), E = Ranges.end(); - I != E; ++I) { - const MemsetRange &Range = *I; - - if (Range.TheStores.size() == 1) continue; - - // If it is profitable to lower this range to memset, do so now. - if (!Range.isProfitableToUseMemset(TD)) - continue; - - // Otherwise, we do want to transform this! Create a new memset. We put - // the memset right before the first instruction that isn't part of this - // memset block. This ensure that the memset is dominated by any addressing - // instruction needed by the start of the block. - BasicBlock::iterator InsertPt = BI; - - if (MemSetF == 0) - MemSetF = Intrinsic::getDeclaration(SI->getParent()->getParent() - ->getParent(), Intrinsic::memset_i64); - - // Get the starting pointer of the block. - StartPtr = Range.StartPtr; - - // Cast the start ptr to be i8* as memset requires. - const Type *i8Ptr = PointerType::getUnqual(Type::Int8Ty); - if (StartPtr->getType() != i8Ptr) - StartPtr = new BitCastInst(StartPtr, i8Ptr, StartPtr->getNameStart(), - InsertPt); - - Value *Ops[] = { - StartPtr, ByteVal, // Start, value - ConstantInt::get(Type::Int64Ty, Range.End-Range.Start), // size - ConstantInt::get(Type::Int32Ty, Range.Alignment) // align - }; - Value *C = CallInst::Create(MemSetF, Ops, Ops+4, "", InsertPt); - DEBUG(cerr << "Replace stores:\n"; - for (unsigned i = 0, e = Range.TheStores.size(); i != e; ++i) - cerr << *Range.TheStores[i]; - cerr << "With: " << *C); C=C; - - // Zap all the stores. - toErase.append(Range.TheStores.begin(), Range.TheStores.end()); - ++NumMemSetInfer; - MadeChange = true; - } - - return MadeChange; -} - - -/// performCallSlotOptzn - takes a memcpy and a call that it depends on, -/// and checks for the possibility of a call slot optimization by having -/// the call write its result directly into the destination of the memcpy. -bool GVN::performCallSlotOptzn(MemCpyInst *cpy, CallInst *C, - SmallVectorImpl &toErase) { - // The general transformation to keep in mind is - // - // call @func(..., src, ...) - // memcpy(dest, src, ...) - // - // -> - // - // memcpy(dest, src, ...) - // call @func(..., dest, ...) - // - // Since moving the memcpy is technically awkward, we additionally check that - // src only holds uninitialized values at the moment of the call, meaning that - // the memcpy can be discarded rather than moved. - - // Deliberately get the source and destination with bitcasts stripped away, - // because we'll need to do type comparisons based on the underlying type. - Value* cpyDest = cpy->getDest(); - Value* cpySrc = cpy->getSource(); - CallSite CS = CallSite::get(C); - - // We need to be able to reason about the size of the memcpy, so we require - // that it be a constant. - ConstantInt* cpyLength = dyn_cast(cpy->getLength()); - if (!cpyLength) - return false; - - // Require that src be an alloca. This simplifies the reasoning considerably. - AllocaInst* srcAlloca = dyn_cast(cpySrc); - if (!srcAlloca) - return false; - - // Check that all of src is copied to dest. - TargetData& TD = getAnalysis(); - - ConstantInt* srcArraySize = dyn_cast(srcAlloca->getArraySize()); - if (!srcArraySize) - return false; - - uint64_t srcSize = TD.getABITypeSize(srcAlloca->getAllocatedType()) * - srcArraySize->getZExtValue(); - - if (cpyLength->getZExtValue() < srcSize) - return false; - - // Check that accessing the first srcSize bytes of dest will not cause a - // trap. Otherwise the transform is invalid since it might cause a trap - // to occur earlier than it otherwise would. - if (AllocaInst* A = dyn_cast(cpyDest)) { - // The destination is an alloca. Check it is larger than srcSize. - ConstantInt* destArraySize = dyn_cast(A->getArraySize()); - if (!destArraySize) - return false; - - uint64_t destSize = TD.getABITypeSize(A->getAllocatedType()) * - destArraySize->getZExtValue(); - - if (destSize < srcSize) - return false; - } else if (Argument* A = dyn_cast(cpyDest)) { - // If the destination is an sret parameter then only accesses that are - // outside of the returned struct type can trap. - if (!A->hasStructRetAttr()) - return false; - - const Type* StructTy = cast(A->getType())->getElementType(); - uint64_t destSize = TD.getABITypeSize(StructTy); - - if (destSize < srcSize) - return false; - } else { - return false; - } - - // Check that src is not accessed except via the call and the memcpy. This - // guarantees that it holds only undefined values when passed in (so the final - // memcpy can be dropped), that it is not read or written between the call and - // the memcpy, and that writing beyond the end of it is undefined. - SmallVector srcUseList(srcAlloca->use_begin(), - srcAlloca->use_end()); - while (!srcUseList.empty()) { - User* UI = srcUseList.back(); - srcUseList.pop_back(); - - if (isa(UI) || isa(UI)) { - for (User::use_iterator I = UI->use_begin(), E = UI->use_end(); - I != E; ++I) - srcUseList.push_back(*I); - } else if (UI != C && UI != cpy) { - return false; - } - } - - // Since we're changing the parameter to the callsite, we need to make sure - // that what would be the new parameter dominates the callsite. - DominatorTree& DT = getAnalysis(); - if (Instruction* cpyDestInst = dyn_cast(cpyDest)) - if (!DT.dominates(cpyDestInst, C)) - return false; - - // In addition to knowing that the call does not access src in some - // unexpected manner, for example via a global, which we deduce from - // the use analysis, we also need to know that it does not sneakily - // access dest. We rely on AA to figure this out for us. - AliasAnalysis& AA = getAnalysis(); - if (AA.getModRefInfo(C, cpy->getRawDest(), srcSize) != - AliasAnalysis::NoModRef) - return false; - - // All the checks have passed, so do the transformation. - for (unsigned i = 0; i < CS.arg_size(); ++i) - if (CS.getArgument(i) == cpySrc) { - if (cpySrc->getType() != cpyDest->getType()) - cpyDest = CastInst::createPointerCast(cpyDest, cpySrc->getType(), - cpyDest->getName(), C); - CS.setArgument(i, cpyDest); - } - - // Drop any cached information about the call, because we may have changed - // its dependence information by changing its parameter. - MemoryDependenceAnalysis& MD = getAnalysis(); - MD.dropInstruction(C); - - // Remove the memcpy - MD.removeInstruction(cpy); - toErase.push_back(cpy); - - return true; -} - -/// processMemCpy - perform simplication of memcpy's. If we have memcpy A which -/// copies X to Y, and memcpy B which copies Y to Z, then we can rewrite B to be -/// a memcpy from X to Z (or potentially a memmove, depending on circumstances). -/// This allows later passes to remove the first memcpy altogether. -bool GVN::processMemCpy(MemCpyInst* M, MemCpyInst* MDep, - SmallVectorImpl &toErase) { - // We can only transforms memcpy's where the dest of one is the source of the - // other - if (M->getSource() != MDep->getDest()) - return false; - - // Second, the length of the memcpy's must be the same, or the preceeding one - // must be larger than the following one. - ConstantInt* C1 = dyn_cast(MDep->getLength()); - ConstantInt* C2 = dyn_cast(M->getLength()); - if (!C1 || !C2) - return false; - - uint64_t DepSize = C1->getValue().getZExtValue(); - uint64_t CpySize = C2->getValue().getZExtValue(); - - if (DepSize < CpySize) - return false; - - // Finally, we have to make sure that the dest of the second does not - // alias the source of the first - AliasAnalysis& AA = getAnalysis(); - if (AA.alias(M->getRawDest(), CpySize, MDep->getRawSource(), DepSize) != - AliasAnalysis::NoAlias) - return false; - else if (AA.alias(M->getRawDest(), CpySize, M->getRawSource(), CpySize) != - AliasAnalysis::NoAlias) - return false; - else if (AA.alias(MDep->getRawDest(), DepSize, MDep->getRawSource(), DepSize) - != AliasAnalysis::NoAlias) - return false; - - // If all checks passed, then we can transform these memcpy's - Function* MemCpyFun = Intrinsic::getDeclaration( - M->getParent()->getParent()->getParent(), - M->getIntrinsicID()); - - std::vector args; - args.push_back(M->getRawDest()); - args.push_back(MDep->getRawSource()); - args.push_back(M->getLength()); - args.push_back(M->getAlignment()); - - CallInst* C = CallInst::Create(MemCpyFun, args.begin(), args.end(), "", M); - - MemoryDependenceAnalysis& MD = getAnalysis(); - if (MD.getDependency(C) == MDep) { - MD.dropInstruction(M); - toErase.push_back(M); - return true; - } - - MD.removeInstruction(C); - toErase.push_back(C); - return false; -} - /// processInstruction - When calculating availability, handle an instruction /// by inserting it into the appropriate sets bool GVN::processInstruction(Instruction *I, ValueNumberedSet &currAvail, @@ -1578,31 +978,11 @@ if (LoadInst* L = dyn_cast(I)) return processLoad(L, lastSeenLoad, toErase); - if (StoreInst *SI = dyn_cast(I)) - return processStore(SI, toErase); - // Allocations are always uniquely numbered, so we can save time and memory // by fast failing them. if (isa(I)) return false; - if (MemCpyInst* M = dyn_cast(I)) { - MemoryDependenceAnalysis& MD = getAnalysis(); - - // The are two possible optimizations we can do for memcpy: - // a) memcpy-memcpy xform which exposes redundance for DSE - // b) call-memcpy xform for return slot optimization - Instruction* dep = MD.getDependency(M); - if (dep == MemoryDependenceAnalysis::None || - dep == MemoryDependenceAnalysis::NonLocal) - return false; - if (MemCpyInst *MemCpy = dyn_cast(dep)) - return processMemCpy(M, MemCpy, toErase); - if (CallInst* C = dyn_cast(dep)) - return performCallSlotOptzn(M, C, toErase); - return false; - } - unsigned num = VN.lookup_or_add(I); // Collapse PHI nodes Added: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=49419&view=auto ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (added) +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Wed Apr 9 03:23:16 2008 @@ -0,0 +1,769 @@ +//===- MemCpyOptimizer.cpp - Optimize use of memcpy and friends -----------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This pass performs various transformations related to eliminating memcpy +// calls, or transforming sets of stores into memset's. +// +//===----------------------------------------------------------------------===// + +#define DEBUG_TYPE "memcpyopt" +#include "llvm/Transforms/Scalar.h" +#include "llvm/BasicBlock.h" +#include "llvm/Constants.h" +#include "llvm/DerivedTypes.h" +#include "llvm/Function.h" +#include "llvm/IntrinsicInst.h" +#include "llvm/Instructions.h" +#include "llvm/ParameterAttributes.h" +#include "llvm/Value.h" +#include "llvm/ADT/DepthFirstIterator.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/Analysis/Dominators.h" +#include "llvm/Analysis/AliasAnalysis.h" +#include "llvm/Analysis/MemoryDependenceAnalysis.h" +#include "llvm/Support/CFG.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Compiler.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/GetElementPtrTypeIterator.h" +#include "llvm/Target/TargetData.h" +#include +using namespace llvm; + +STATISTIC(NumMemCpyInstr, "Number of memcpy instructions deleted"); +STATISTIC(NumMemSetInfer, "Number of memsets inferred"); + +namespace { + cl::opt + FormMemSet("form-memset-from-stores", + cl::desc("Transform straight-line stores to memsets"), + cl::init(true), cl::Hidden); +} + +/// isBytewiseValue - If the specified value can be set by repeating the same +/// byte in memory, return the i8 value that it is represented with. This is +/// true for all i8 values obviously, but is also true for i32 0, i32 -1, +/// i16 0xF0F0, double 0.0 etc. If the value can't be handled with a repeated +/// byte store (e.g. i16 0x1234), return null. +static Value *isBytewiseValue(Value *V) { + // All byte-wide stores are splatable, even of arbitrary variables. + if (V->getType() == Type::Int8Ty) return V; + + // Constant float and double values can be handled as integer values if the + // corresponding integer value is "byteable". An important case is 0.0. + if (ConstantFP *CFP = dyn_cast(V)) { + if (CFP->getType() == Type::FloatTy) + V = ConstantExpr::getBitCast(CFP, Type::Int32Ty); + if (CFP->getType() == Type::DoubleTy) + V = ConstantExpr::getBitCast(CFP, Type::Int64Ty); + // Don't handle long double formats, which have strange constraints. + } + + // We can handle constant integers that are power of two in size and a + // multiple of 8 bits. + if (ConstantInt *CI = dyn_cast(V)) { + unsigned Width = CI->getBitWidth(); + if (isPowerOf2_32(Width) && Width > 8) { + // We can handle this value if the recursive binary decomposition is the + // same at all levels. + APInt Val = CI->getValue(); + APInt Val2; + while (Val.getBitWidth() != 8) { + unsigned NextWidth = Val.getBitWidth()/2; + Val2 = Val.lshr(NextWidth); + Val2.trunc(Val.getBitWidth()/2); + Val.trunc(Val.getBitWidth()/2); + + // If the top/bottom halves aren't the same, reject it. + if (Val != Val2) + return 0; + } + return ConstantInt::get(Val); + } + } + + // Conceptually, we could handle things like: + // %a = zext i8 %X to i16 + // %b = shl i16 %a, 8 + // %c = or i16 %a, %b + // but until there is an example that actually needs this, it doesn't seem + // worth worrying about. + return 0; +} + +static int64_t GetOffsetFromIndex(const GetElementPtrInst *GEP, unsigned Idx, + bool &VariableIdxFound, TargetData &TD) { + // Skip over the first indices. + gep_type_iterator GTI = gep_type_begin(GEP); + for (unsigned i = 1; i != Idx; ++i, ++GTI) + /*skip along*/; + + // Compute the offset implied by the rest of the indices. + int64_t Offset = 0; + for (unsigned i = Idx, e = GEP->getNumOperands(); i != e; ++i, ++GTI) { + ConstantInt *OpC = dyn_cast(GEP->getOperand(i)); + if (OpC == 0) + return VariableIdxFound = true; + if (OpC->isZero()) continue; // No offset. + + // Handle struct indices, which add their field offset to the pointer. + if (const StructType *STy = dyn_cast(*GTI)) { + Offset += TD.getStructLayout(STy)->getElementOffset(OpC->getZExtValue()); + continue; + } + + // Otherwise, we have a sequential type like an array or vector. Multiply + // the index by the ElementSize. + uint64_t Size = TD.getABITypeSize(GTI.getIndexedType()); + Offset += Size*OpC->getSExtValue(); + } + + return Offset; +} + +/// IsPointerOffset - Return true if Ptr1 is provably equal to Ptr2 plus a +/// constant offset, and return that constant offset. For example, Ptr1 might +/// be &A[42], and Ptr2 might be &A[40]. In this case offset would be -8. +static bool IsPointerOffset(Value *Ptr1, Value *Ptr2, int64_t &Offset, + TargetData &TD) { + // Right now we handle the case when Ptr1/Ptr2 are both GEPs with an identical + // base. After that base, they may have some number of common (and + // potentially variable) indices. After that they handle some constant + // offset, which determines their offset from each other. At this point, we + // handle no other case. + GetElementPtrInst *GEP1 = dyn_cast(Ptr1); + GetElementPtrInst *GEP2 = dyn_cast(Ptr2); + if (!GEP1 || !GEP2 || GEP1->getOperand(0) != GEP2->getOperand(0)) + return false; + + // Skip any common indices and track the GEP types. + unsigned Idx = 1; + for (; Idx != GEP1->getNumOperands() && Idx != GEP2->getNumOperands(); ++Idx) + if (GEP1->getOperand(Idx) != GEP2->getOperand(Idx)) + break; + + bool VariableIdxFound = false; + int64_t Offset1 = GetOffsetFromIndex(GEP1, Idx, VariableIdxFound, TD); + int64_t Offset2 = GetOffsetFromIndex(GEP2, Idx, VariableIdxFound, TD); + if (VariableIdxFound) return false; + + Offset = Offset2-Offset1; + return true; +} + + +/// MemsetRange - Represents a range of memset'd bytes with the ByteVal value. +/// This allows us to analyze stores like: +/// store 0 -> P+1 +/// store 0 -> P+0 +/// store 0 -> P+3 +/// store 0 -> P+2 +/// which sometimes happens with stores to arrays of structs etc. When we see +/// the first store, we make a range [1, 2). The second store extends the range +/// to [0, 2). The third makes a new range [2, 3). The fourth store joins the +/// two ranges into [0, 3) which is memset'able. +namespace { +struct MemsetRange { + // Start/End - A semi range that describes the span that this range covers. + // The range is closed at the start and open at the end: [Start, End). + int64_t Start, End; + + /// StartPtr - The getelementptr instruction that points to the start of the + /// range. + Value *StartPtr; + + /// Alignment - The known alignment of the first store. + unsigned Alignment; + + /// TheStores - The actual stores that make up this range. + SmallVector TheStores; + + bool isProfitableToUseMemset(const TargetData &TD) const; + +}; +} // end anon namespace + +bool MemsetRange::isProfitableToUseMemset(const TargetData &TD) const { + // If we found more than 8 stores to merge or 64 bytes, use memset. + if (TheStores.size() >= 8 || End-Start >= 64) return true; + + // Assume that the code generator is capable of merging pairs of stores + // together if it wants to. + if (TheStores.size() <= 2) return false; + + // If we have fewer than 8 stores, it can still be worthwhile to do this. + // For example, merging 4 i8 stores into an i32 store is useful almost always. + // However, merging 2 32-bit stores isn't useful on a 32-bit architecture (the + // memset will be split into 2 32-bit stores anyway) and doing so can + // pessimize the llvm optimizer. + // + // Since we don't have perfect knowledge here, make some assumptions: assume + // the maximum GPR width is the same size as the pointer size and assume that + // this width can be stored. If so, check to see whether we will end up + // actually reducing the number of stores used. + unsigned Bytes = unsigned(End-Start); + unsigned NumPointerStores = Bytes/TD.getPointerSize(); + + // Assume the remaining bytes if any are done a byte at a time. + unsigned NumByteStores = Bytes - NumPointerStores*TD.getPointerSize(); + + // If we will reduce the # stores (according to this heuristic), do the + // transformation. This encourages merging 4 x i8 -> i32 and 2 x i16 -> i32 + // etc. + return TheStores.size() > NumPointerStores+NumByteStores; +} + + +namespace { +class MemsetRanges { + /// Ranges - A sorted list of the memset ranges. We use std::list here + /// because each element is relatively large and expensive to copy. + std::list Ranges; + typedef std::list::iterator range_iterator; + TargetData &TD; +public: + MemsetRanges(TargetData &td) : TD(td) {} + + typedef std::list::const_iterator const_iterator; + const_iterator begin() const { return Ranges.begin(); } + const_iterator end() const { return Ranges.end(); } + bool empty() const { return Ranges.empty(); } + + void addStore(int64_t OffsetFromFirst, StoreInst *SI); +}; + +} // end anon namespace + + +/// addStore - Add a new store to the MemsetRanges data structure. This adds a +/// new range for the specified store at the specified offset, merging into +/// existing ranges as appropriate. +void MemsetRanges::addStore(int64_t Start, StoreInst *SI) { + int64_t End = Start+TD.getTypeStoreSize(SI->getOperand(0)->getType()); + + // Do a linear search of the ranges to see if this can be joined and/or to + // find the insertion point in the list. We keep the ranges sorted for + // simplicity here. This is a linear search of a linked list, which is ugly, + // however the number of ranges is limited, so this won't get crazy slow. + range_iterator I = Ranges.begin(), E = Ranges.end(); + + while (I != E && Start > I->End) + ++I; + + // We now know that I == E, in which case we didn't find anything to merge + // with, or that Start <= I->End. If End < I->Start or I == E, then we need + // to insert a new range. Handle this now. + if (I == E || End < I->Start) { + MemsetRange &R = *Ranges.insert(I, MemsetRange()); + R.Start = Start; + R.End = End; + R.StartPtr = SI->getPointerOperand(); + R.Alignment = SI->getAlignment(); + R.TheStores.push_back(SI); + return; + } + + // This store overlaps with I, add it. + I->TheStores.push_back(SI); + + // At this point, we may have an interval that completely contains our store. + // If so, just add it to the interval and return. + if (I->Start <= Start && I->End >= End) + return; + + // Now we know that Start <= I->End and End >= I->Start so the range overlaps + // but is not entirely contained within the range. + + // See if the range extends the start of the range. In this case, it couldn't + // possibly cause it to join the prior range, because otherwise we would have + // stopped on *it*. + if (Start < I->Start) { + I->Start = Start; + I->StartPtr = SI->getPointerOperand(); + } + + // Now we know that Start <= I->End and Start >= I->Start (so the startpoint + // is in or right at the end of I), and that End >= I->Start. Extend I out to + // End. + if (End > I->End) { + I->End = End; + range_iterator NextI = I;; + while (++NextI != E && End >= NextI->Start) { + // Merge the range in. + I->TheStores.append(NextI->TheStores.begin(), NextI->TheStores.end()); + if (NextI->End > I->End) + I->End = NextI->End; + Ranges.erase(NextI); + NextI = I; + } + } +} + +//===----------------------------------------------------------------------===// +// MemCpyOpt Pass +//===----------------------------------------------------------------------===// + +namespace { + + class VISIBILITY_HIDDEN MemCpyOpt : public FunctionPass { + bool runOnFunction(Function &F); + public: + static char ID; // Pass identification, replacement for typeid + MemCpyOpt() : FunctionPass((intptr_t)&ID) { } + + private: + // This transformation requires dominator postdominator info + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesCFG(); + AU.addRequired(); + AU.addRequired(); + AU.addRequired(); + AU.addRequired(); + AU.addPreserved(); + AU.addPreserved(); + AU.addPreserved(); + } + + // Helper fuctions + bool processInstruction(Instruction* I, + SmallVectorImpl &toErase); + bool processStore(StoreInst *SI, SmallVectorImpl &toErase); + bool processMemCpy(MemCpyInst* M, MemCpyInst* MDep, + SmallVectorImpl &toErase); + bool performCallSlotOptzn(MemCpyInst* cpy, CallInst* C, + SmallVectorImpl &toErase); + bool iterateOnFunction(Function &F); + }; + + char MemCpyOpt::ID = 0; +} + +// createMemCpyOptPass - The public interface to this file... +FunctionPass *llvm::createMemCpyOptPass() { return new MemCpyOpt(); } + +static RegisterPass X("memcpyopt", + "MemCpy Optimization"); + + + +/// processStore - When GVN is scanning forward over instructions, we look for +/// some other patterns to fold away. In particular, this looks for stores to +/// neighboring locations of memory. If it sees enough consequtive ones +/// (currently 4) it attempts to merge them together into a memcpy/memset. +bool MemCpyOpt::processStore(StoreInst *SI, SmallVectorImpl &toErase) { + if (!FormMemSet) return false; + if (SI->isVolatile()) return false; + + // There are two cases that are interesting for this code to handle: memcpy + // and memset. Right now we only handle memset. + + // Ensure that the value being stored is something that can be memset'able a + // byte at a time like "0" or "-1" or any width, as well as things like + // 0xA0A0A0A0 and 0.0. + Value *ByteVal = isBytewiseValue(SI->getOperand(0)); + if (!ByteVal) + return false; + + TargetData &TD = getAnalysis(); + AliasAnalysis &AA = getAnalysis(); + + // Okay, so we now have a single store that can be splatable. Scan to find + // all subsequent stores of the same value to offset from the same pointer. + // Join these together into ranges, so we can decide whether contiguous blocks + // are stored. + MemsetRanges Ranges(TD); + + Value *StartPtr = SI->getPointerOperand(); + + BasicBlock::iterator BI = SI; + for (++BI; !isa(BI); ++BI) { + if (isa(BI) || isa(BI)) { + // If the call is readnone, ignore it, otherwise bail out. We don't even + // allow readonly here because we don't want something like: + // A[1] = 2; strlen(A); A[2] = 2; -> memcpy(A, ...); strlen(A). + if (AA.getModRefBehavior(CallSite::get(BI)) == + AliasAnalysis::DoesNotAccessMemory) + continue; + + // TODO: If this is a memset, try to join it in. + + break; + } else if (isa(BI) || isa(BI)) + break; + + // If this is a non-store instruction it is fine, ignore it. + StoreInst *NextStore = dyn_cast(BI); + if (NextStore == 0) continue; + + // If this is a store, see if we can merge it in. + if (NextStore->isVolatile()) break; + + // Check to see if this stored value is of the same byte-splattable value. + if (ByteVal != isBytewiseValue(NextStore->getOperand(0))) + break; + + // Check to see if this store is to a constant offset from the start ptr. + int64_t Offset; + if (!IsPointerOffset(StartPtr, NextStore->getPointerOperand(), Offset, TD)) + break; + + Ranges.addStore(Offset, NextStore); + } + + // If we have no ranges, then we just had a single store with nothing that + // could be merged in. This is a very common case of course. + if (Ranges.empty()) + return false; + + // If we had at least one store that could be merged in, add the starting + // store as well. We try to avoid this unless there is at least something + // interesting as a small compile-time optimization. + Ranges.addStore(0, SI); + + + Function *MemSetF = 0; + + // Now that we have full information about ranges, loop over the ranges and + // emit memset's for anything big enough to be worthwhile. + bool MadeChange = false; + for (MemsetRanges::const_iterator I = Ranges.begin(), E = Ranges.end(); + I != E; ++I) { + const MemsetRange &Range = *I; + + if (Range.TheStores.size() == 1) continue; + + // If it is profitable to lower this range to memset, do so now. + if (!Range.isProfitableToUseMemset(TD)) + continue; + + // Otherwise, we do want to transform this! Create a new memset. We put + // the memset right before the first instruction that isn't part of this + // memset block. This ensure that the memset is dominated by any addressing + // instruction needed by the start of the block. + BasicBlock::iterator InsertPt = BI; + + if (MemSetF == 0) + MemSetF = Intrinsic::getDeclaration(SI->getParent()->getParent() + ->getParent(), Intrinsic::memset_i64); + + // Get the starting pointer of the block. + StartPtr = Range.StartPtr; + + // Cast the start ptr to be i8* as memset requires. + const Type *i8Ptr = PointerType::getUnqual(Type::Int8Ty); + if (StartPtr->getType() != i8Ptr) + StartPtr = new BitCastInst(StartPtr, i8Ptr, StartPtr->getNameStart(), + InsertPt); + + Value *Ops[] = { + StartPtr, ByteVal, // Start, value + ConstantInt::get(Type::Int64Ty, Range.End-Range.Start), // size + ConstantInt::get(Type::Int32Ty, Range.Alignment) // align + }; + Value *C = CallInst::Create(MemSetF, Ops, Ops+4, "", InsertPt); + DEBUG(cerr << "Replace stores:\n"; + for (unsigned i = 0, e = Range.TheStores.size(); i != e; ++i) + cerr << *Range.TheStores[i]; + cerr << "With: " << *C); C=C; + + // Zap all the stores. + toErase.append(Range.TheStores.begin(), Range.TheStores.end()); + ++NumMemSetInfer; + MadeChange = true; + } + + return MadeChange; +} + + +/// performCallSlotOptzn - takes a memcpy and a call that it depends on, +/// and checks for the possibility of a call slot optimization by having +/// the call write its result directly into the destination of the memcpy. +bool MemCpyOpt::performCallSlotOptzn(MemCpyInst *cpy, CallInst *C, + SmallVectorImpl &toErase) { + // The general transformation to keep in mind is + // + // call @func(..., src, ...) + // memcpy(dest, src, ...) + // + // -> + // + // memcpy(dest, src, ...) + // call @func(..., dest, ...) + // + // Since moving the memcpy is technically awkward, we additionally check that + // src only holds uninitialized values at the moment of the call, meaning that + // the memcpy can be discarded rather than moved. + + // Deliberately get the source and destination with bitcasts stripped away, + // because we'll need to do type comparisons based on the underlying type. + Value* cpyDest = cpy->getDest(); + Value* cpySrc = cpy->getSource(); + CallSite CS = CallSite::get(C); + + // We need to be able to reason about the size of the memcpy, so we require + // that it be a constant. + ConstantInt* cpyLength = dyn_cast(cpy->getLength()); + if (!cpyLength) + return false; + + // Require that src be an alloca. This simplifies the reasoning considerably. + AllocaInst* srcAlloca = dyn_cast(cpySrc); + if (!srcAlloca) + return false; + + // Check that all of src is copied to dest. + TargetData& TD = getAnalysis(); + + ConstantInt* srcArraySize = dyn_cast(srcAlloca->getArraySize()); + if (!srcArraySize) + return false; + + uint64_t srcSize = TD.getABITypeSize(srcAlloca->getAllocatedType()) * + srcArraySize->getZExtValue(); + + if (cpyLength->getZExtValue() < srcSize) + return false; + + // Check that accessing the first srcSize bytes of dest will not cause a + // trap. Otherwise the transform is invalid since it might cause a trap + // to occur earlier than it otherwise would. + if (AllocaInst* A = dyn_cast(cpyDest)) { + // The destination is an alloca. Check it is larger than srcSize. + ConstantInt* destArraySize = dyn_cast(A->getArraySize()); + if (!destArraySize) + return false; + + uint64_t destSize = TD.getABITypeSize(A->getAllocatedType()) * + destArraySize->getZExtValue(); + + if (destSize < srcSize) + return false; + } else if (Argument* A = dyn_cast(cpyDest)) { + // If the destination is an sret parameter then only accesses that are + // outside of the returned struct type can trap. + if (!A->hasStructRetAttr()) + return false; + + const Type* StructTy = cast(A->getType())->getElementType(); + uint64_t destSize = TD.getABITypeSize(StructTy); + + if (destSize < srcSize) + return false; + } else { + return false; + } + + // Check that src is not accessed except via the call and the memcpy. This + // guarantees that it holds only undefined values when passed in (so the final + // memcpy can be dropped), that it is not read or written between the call and + // the memcpy, and that writing beyond the end of it is undefined. + SmallVector srcUseList(srcAlloca->use_begin(), + srcAlloca->use_end()); + while (!srcUseList.empty()) { + User* UI = srcUseList.back(); + srcUseList.pop_back(); + + if (isa(UI) || isa(UI)) { + for (User::use_iterator I = UI->use_begin(), E = UI->use_end(); + I != E; ++I) + srcUseList.push_back(*I); + } else if (UI != C && UI != cpy) { + return false; + } + } + + // Since we're changing the parameter to the callsite, we need to make sure + // that what would be the new parameter dominates the callsite. + DominatorTree& DT = getAnalysis(); + if (Instruction* cpyDestInst = dyn_cast(cpyDest)) + if (!DT.dominates(cpyDestInst, C)) + return false; + + // In addition to knowing that the call does not access src in some + // unexpected manner, for example via a global, which we deduce from + // the use analysis, we also need to know that it does not sneakily + // access dest. We rely on AA to figure this out for us. + AliasAnalysis& AA = getAnalysis(); + if (AA.getModRefInfo(C, cpy->getRawDest(), srcSize) != + AliasAnalysis::NoModRef) + return false; + + // All the checks have passed, so do the transformation. + for (unsigned i = 0; i < CS.arg_size(); ++i) + if (CS.getArgument(i) == cpySrc) { + if (cpySrc->getType() != cpyDest->getType()) + cpyDest = CastInst::createPointerCast(cpyDest, cpySrc->getType(), + cpyDest->getName(), C); + CS.setArgument(i, cpyDest); + } + + // Drop any cached information about the call, because we may have changed + // its dependence information by changing its parameter. + MemoryDependenceAnalysis& MD = getAnalysis(); + MD.dropInstruction(C); + + // Remove the memcpy + MD.removeInstruction(cpy); + toErase.push_back(cpy); + + return true; +} + +/// processMemCpy - perform simplication of memcpy's. If we have memcpy A which +/// copies X to Y, and memcpy B which copies Y to Z, then we can rewrite B to be +/// a memcpy from X to Z (or potentially a memmove, depending on circumstances). +/// This allows later passes to remove the first memcpy altogether. +bool MemCpyOpt::processMemCpy(MemCpyInst* M, MemCpyInst* MDep, + SmallVectorImpl &toErase) { + // We can only transforms memcpy's where the dest of one is the source of the + // other + if (M->getSource() != MDep->getDest()) + return false; + + // Second, the length of the memcpy's must be the same, or the preceeding one + // must be larger than the following one. + ConstantInt* C1 = dyn_cast(MDep->getLength()); + ConstantInt* C2 = dyn_cast(M->getLength()); + if (!C1 || !C2) + return false; + + uint64_t DepSize = C1->getValue().getZExtValue(); + uint64_t CpySize = C2->getValue().getZExtValue(); + + if (DepSize < CpySize) + return false; + + // Finally, we have to make sure that the dest of the second does not + // alias the source of the first + AliasAnalysis& AA = getAnalysis(); + if (AA.alias(M->getRawDest(), CpySize, MDep->getRawSource(), DepSize) != + AliasAnalysis::NoAlias) + return false; + else if (AA.alias(M->getRawDest(), CpySize, M->getRawSource(), CpySize) != + AliasAnalysis::NoAlias) + return false; + else if (AA.alias(MDep->getRawDest(), DepSize, MDep->getRawSource(), DepSize) + != AliasAnalysis::NoAlias) + return false; + + // If all checks passed, then we can transform these memcpy's + Function* MemCpyFun = Intrinsic::getDeclaration( + M->getParent()->getParent()->getParent(), + M->getIntrinsicID()); + + std::vector args; + args.push_back(M->getRawDest()); + args.push_back(MDep->getRawSource()); + args.push_back(M->getLength()); + args.push_back(M->getAlignment()); + + CallInst* C = CallInst::Create(MemCpyFun, args.begin(), args.end(), "", M); + + MemoryDependenceAnalysis& MD = getAnalysis(); + if (MD.getDependency(C) == MDep) { + MD.dropInstruction(M); + toErase.push_back(M); + return true; + } + + MD.removeInstruction(C); + toErase.push_back(C); + return false; +} + +/// processInstruction - When calculating availability, handle an instruction +/// by inserting it into the appropriate sets +bool MemCpyOpt::processInstruction(Instruction *I, + SmallVectorImpl &toErase) { + if (StoreInst *SI = dyn_cast(I)) + return processStore(SI, toErase); + + if (MemCpyInst* M = dyn_cast(I)) { + MemoryDependenceAnalysis& MD = getAnalysis(); + + // The are two possible optimizations we can do for memcpy: + // a) memcpy-memcpy xform which exposes redundance for DSE + // b) call-memcpy xform for return slot optimization + Instruction* dep = MD.getDependency(M); + if (dep == MemoryDependenceAnalysis::None || + dep == MemoryDependenceAnalysis::NonLocal) + return false; + if (MemCpyInst *MemCpy = dyn_cast(dep)) + return processMemCpy(M, MemCpy, toErase); + if (CallInst* C = dyn_cast(dep)) + return performCallSlotOptzn(M, C, toErase); + return false; + } + + return false; +} + +// MemCpyOpt::runOnFunction - This is the main transformation entry point for a +// function. +// +bool MemCpyOpt::runOnFunction(Function& F) { + + bool changed = false; + bool shouldContinue = true; + + while (shouldContinue) { + shouldContinue = iterateOnFunction(F); + changed |= shouldContinue; + } + + return changed; +} + + +// MemCpyOpt::iterateOnFunction - Executes one iteration of GVN +bool MemCpyOpt::iterateOnFunction(Function &F) { + bool changed_function = false; + + DominatorTree &DT = getAnalysis(); + + SmallVector toErase; + + // Top-down walk of the dominator tree + for (df_iterator DI = df_begin(DT.getRootNode()), + E = df_end(DT.getRootNode()); DI != E; ++DI) { + + BasicBlock* BB = DI->getBlock(); + for (BasicBlock::iterator BI = BB->begin(), BE = BB->end(); + BI != BE;) { + changed_function |= processInstruction(BI, toErase); + if (toErase.empty()) { + ++BI; + continue; + } + + // If we need some instructions deleted, do it now. + NumMemCpyInstr += toErase.size(); + + // Avoid iterator invalidation. + bool AtStart = BI == BB->begin(); + if (!AtStart) + --BI; + + for (SmallVector::iterator I = toErase.begin(), + E = toErase.end(); I != E; ++I) + (*I)->eraseFromParent(); + + if (AtStart) + BI = BB->begin(); + else + ++BI; + + toErase.clear(); + } + } + + return changed_function; +} Removed: llvm/trunk/test/Transforms/GVN/2008-02-24-MultipleUseofSRet.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/2008-02-24-MultipleUseofSRet.ll?rev=49418&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GVN/2008-02-24-MultipleUseofSRet.ll (original) +++ llvm/trunk/test/Transforms/GVN/2008-02-24-MultipleUseofSRet.ll (removed) @@ -1,34 +0,0 @@ -; RUN: llvm-as < %s | opt -gvn -dse | llvm-dis | grep {call.*initialize} | not grep memtmp -; PR2077 - -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32" -target triple = "i386-pc-linux-gnu" - -define internal fastcc void @initialize({ x86_fp80, x86_fp80 }* noalias sret %agg.result) nounwind { -entry: - %agg.result.03 = getelementptr { x86_fp80, x86_fp80 }* %agg.result, i32 0, i32 0 ; [#uses=1] - store x86_fp80 0xK00000000000000000000, x86_fp80* %agg.result.03 - %agg.result.15 = getelementptr { x86_fp80, x86_fp80 }* %agg.result, i32 0, i32 1 ; [#uses=1] - store x86_fp80 0xK00000000000000000000, x86_fp80* %agg.result.15 - ret void -} - -declare fastcc x86_fp80 @passed_uninitialized({ x86_fp80, x86_fp80 }* %x) nounwind - -define fastcc void @badly_optimized() nounwind { -entry: - %z = alloca { x86_fp80, x86_fp80 } ; <{ x86_fp80, x86_fp80 }*> [#uses=2] - %tmp = alloca { x86_fp80, x86_fp80 } ; <{ x86_fp80, x86_fp80 }*> [#uses=2] - %memtmp = alloca { x86_fp80, x86_fp80 }, align 8 ; <{ x86_fp80, x86_fp80 }*> [#uses=2] - call fastcc void @initialize( { x86_fp80, x86_fp80 }* noalias sret %memtmp ) - %tmp1 = bitcast { x86_fp80, x86_fp80 }* %tmp to i8* ; [#uses=1] - %memtmp2 = bitcast { x86_fp80, x86_fp80 }* %memtmp to i8* ; [#uses=1] - call void @llvm.memcpy.i32( i8* %tmp1, i8* %memtmp2, i32 24, i32 8 ) - %z3 = bitcast { x86_fp80, x86_fp80 }* %z to i8* ; [#uses=1] - %tmp4 = bitcast { x86_fp80, x86_fp80 }* %tmp to i8* ; [#uses=1] - call void @llvm.memcpy.i32( i8* %z3, i8* %tmp4, i32 24, i32 8 ) - %tmp5 = call fastcc x86_fp80 @passed_uninitialized( { x86_fp80, x86_fp80 }* %z ) ; [#uses=0] - ret void -} - -declare void @llvm.memcpy.i32(i8*, i8*, i32, i32) nounwind Removed: llvm/trunk/test/Transforms/GVN/2008-03-13-ReturnSlotBitcast.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/2008-03-13-ReturnSlotBitcast.ll?rev=49418&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GVN/2008-03-13-ReturnSlotBitcast.ll (original) +++ llvm/trunk/test/Transforms/GVN/2008-03-13-ReturnSlotBitcast.ll (removed) @@ -1,19 +0,0 @@ -; RUN: llvm-as < %s | opt -gvn | llvm-dis | not grep {call.*memcpy.} - %a = type { i32 } - %b = type { float } - -declare void @llvm.memcpy.i32(i8*, i8*, i32, i32) nounwind -declare void @g(%a*) - -define float @f() { -entry: - %a_var = alloca %a - %b_var = alloca %b - call void @g(%a *%a_var) - %a_i8 = bitcast %a* %a_var to i8* - %b_i8 = bitcast %b* %b_var to i8* - call void @llvm.memcpy.i32(i8* %b_i8, i8* %a_i8, i32 4, i32 4) - %tmp1 = getelementptr %b* %b_var, i32 0, i32 0 - %tmp2 = load float* %tmp1 - ret float %tmp2 -} Removed: llvm/trunk/test/Transforms/GVN/form-memset.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/form-memset.ll?rev=49418&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GVN/form-memset.ll (original) +++ llvm/trunk/test/Transforms/GVN/form-memset.ll (removed) @@ -1,55 +0,0 @@ -; RUN: llvm-as < %s | opt -gvn -form-memset-from-stores | llvm-dis | not grep store -; RUN: llvm-as < %s | opt -gvn -form-memset-from-stores | llvm-dis | grep {call.*llvm.memset} - -; All the stores in this example should be merged into a single memset. - -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin8" - -define void @foo(i8 signext %c) nounwind { -entry: - %x = alloca [19 x i8] ; <[19 x i8]*> [#uses=20] - %tmp = getelementptr [19 x i8]* %x, i32 0, i32 0 ; [#uses=1] - store i8 %c, i8* %tmp, align 1 - %tmp5 = getelementptr [19 x i8]* %x, i32 0, i32 1 ; [#uses=1] - store i8 %c, i8* %tmp5, align 1 - %tmp9 = getelementptr [19 x i8]* %x, i32 0, i32 2 ; [#uses=1] - store i8 %c, i8* %tmp9, align 1 - %tmp13 = getelementptr [19 x i8]* %x, i32 0, i32 3 ; [#uses=1] - store i8 %c, i8* %tmp13, align 1 - %tmp17 = getelementptr [19 x i8]* %x, i32 0, i32 4 ; [#uses=1] - store i8 %c, i8* %tmp17, align 1 - %tmp21 = getelementptr [19 x i8]* %x, i32 0, i32 5 ; [#uses=1] - store i8 %c, i8* %tmp21, align 1 - %tmp25 = getelementptr [19 x i8]* %x, i32 0, i32 6 ; [#uses=1] - store i8 %c, i8* %tmp25, align 1 - %tmp29 = getelementptr [19 x i8]* %x, i32 0, i32 7 ; [#uses=1] - store i8 %c, i8* %tmp29, align 1 - %tmp33 = getelementptr [19 x i8]* %x, i32 0, i32 8 ; [#uses=1] - store i8 %c, i8* %tmp33, align 1 - %tmp37 = getelementptr [19 x i8]* %x, i32 0, i32 9 ; [#uses=1] - store i8 %c, i8* %tmp37, align 1 - %tmp41 = getelementptr [19 x i8]* %x, i32 0, i32 10 ; [#uses=1] - store i8 %c, i8* %tmp41, align 1 - %tmp45 = getelementptr [19 x i8]* %x, i32 0, i32 11 ; [#uses=1] - store i8 %c, i8* %tmp45, align 1 - %tmp49 = getelementptr [19 x i8]* %x, i32 0, i32 12 ; [#uses=1] - store i8 %c, i8* %tmp49, align 1 - %tmp53 = getelementptr [19 x i8]* %x, i32 0, i32 13 ; [#uses=1] - store i8 %c, i8* %tmp53, align 1 - %tmp57 = getelementptr [19 x i8]* %x, i32 0, i32 14 ; [#uses=1] - store i8 %c, i8* %tmp57, align 1 - %tmp61 = getelementptr [19 x i8]* %x, i32 0, i32 15 ; [#uses=1] - store i8 %c, i8* %tmp61, align 1 - %tmp65 = getelementptr [19 x i8]* %x, i32 0, i32 16 ; [#uses=1] - store i8 %c, i8* %tmp65, align 1 - %tmp69 = getelementptr [19 x i8]* %x, i32 0, i32 17 ; [#uses=1] - store i8 %c, i8* %tmp69, align 1 - %tmp73 = getelementptr [19 x i8]* %x, i32 0, i32 18 ; [#uses=1] - store i8 %c, i8* %tmp73, align 1 - %tmp76 = call i32 (...)* @bar( [19 x i8]* %x ) nounwind ; [#uses=0] - ret void -} - -declare i32 @bar(...) - Removed: llvm/trunk/test/Transforms/GVN/form-memset2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/form-memset2.ll?rev=49418&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GVN/form-memset2.ll (original) +++ llvm/trunk/test/Transforms/GVN/form-memset2.ll (removed) @@ -1,99 +0,0 @@ -; RUN: llvm-as < %s | opt -gvn -form-memset-from-stores | llvm-dis | not grep store -; RUN: llvm-as < %s | opt -gvn -form-memset-from-stores | llvm-dis | grep {call.*llvm.memset} | count 3 - -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin8" - %struct.MV = type { i16, i16 } - -define i32 @t() nounwind { -entry: - %ref_idx = alloca [8 x i8] ; <[8 x i8]*> [#uses=8] - %left_mvd = alloca [8 x %struct.MV] ; <[8 x %struct.MV]*> [#uses=17] - %up_mvd = alloca [8 x %struct.MV] ; <[8 x %struct.MV]*> [#uses=17] - %tmp20 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 7 ; [#uses=1] - store i8 -1, i8* %tmp20, align 1 - %tmp23 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 6 ; [#uses=1] - store i8 -1, i8* %tmp23, align 1 - %tmp26 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 5 ; [#uses=1] - store i8 -1, i8* %tmp26, align 1 - %tmp29 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 4 ; [#uses=1] - store i8 -1, i8* %tmp29, align 1 - %tmp32 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 3 ; [#uses=1] - store i8 -1, i8* %tmp32, align 1 - %tmp35 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 2 ; [#uses=1] - store i8 -1, i8* %tmp35, align 1 - %tmp38 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 1 ; [#uses=1] - store i8 -1, i8* %tmp38, align 1 - %tmp41 = getelementptr [8 x i8]* %ref_idx, i32 0, i32 0 ; [#uses=2] - store i8 -1, i8* %tmp41, align 1 - %tmp43 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 7, i32 0 ; [#uses=1] - store i16 0, i16* %tmp43, align 2 - %tmp46 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 7, i32 1 ; [#uses=1] - store i16 0, i16* %tmp46, align 2 - %tmp57 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 6, i32 0 ; [#uses=1] - store i16 0, i16* %tmp57, align 2 - %tmp60 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 6, i32 1 ; [#uses=1] - store i16 0, i16* %tmp60, align 2 - %tmp71 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 5, i32 0 ; [#uses=1] - store i16 0, i16* %tmp71, align 2 - %tmp74 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 5, i32 1 ; [#uses=1] - store i16 0, i16* %tmp74, align 2 - %tmp85 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 4, i32 0 ; [#uses=1] - store i16 0, i16* %tmp85, align 2 - %tmp88 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 4, i32 1 ; [#uses=1] - store i16 0, i16* %tmp88, align 2 - %tmp99 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 3, i32 0 ; [#uses=1] - store i16 0, i16* %tmp99, align 2 - %tmp102 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 3, i32 1 ; [#uses=1] - store i16 0, i16* %tmp102, align 2 - %tmp113 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 2, i32 0 ; [#uses=1] - store i16 0, i16* %tmp113, align 2 - %tmp116 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 2, i32 1 ; [#uses=1] - store i16 0, i16* %tmp116, align 2 - %tmp127 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 1, i32 0 ; [#uses=1] - store i16 0, i16* %tmp127, align 2 - %tmp130 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 1, i32 1 ; [#uses=1] - store i16 0, i16* %tmp130, align 2 - %tmp141 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 0, i32 0 ; [#uses=1] - store i16 0, i16* %tmp141, align 8 - %tmp144 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 0, i32 1 ; [#uses=1] - store i16 0, i16* %tmp144, align 2 - %tmp148 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 7, i32 0 ; [#uses=1] - store i16 0, i16* %tmp148, align 2 - %tmp151 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 7, i32 1 ; [#uses=1] - store i16 0, i16* %tmp151, align 2 - %tmp162 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 6, i32 0 ; [#uses=1] - store i16 0, i16* %tmp162, align 2 - %tmp165 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 6, i32 1 ; [#uses=1] - store i16 0, i16* %tmp165, align 2 - %tmp176 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 5, i32 0 ; [#uses=1] - store i16 0, i16* %tmp176, align 2 - %tmp179 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 5, i32 1 ; [#uses=1] - store i16 0, i16* %tmp179, align 2 - %tmp190 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 4, i32 0 ; [#uses=1] - store i16 0, i16* %tmp190, align 2 - %tmp193 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 4, i32 1 ; [#uses=1] - store i16 0, i16* %tmp193, align 2 - %tmp204 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 3, i32 0 ; [#uses=1] - store i16 0, i16* %tmp204, align 2 - %tmp207 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 3, i32 1 ; [#uses=1] - store i16 0, i16* %tmp207, align 2 - %tmp218 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 2, i32 0 ; [#uses=1] - store i16 0, i16* %tmp218, align 2 - %tmp221 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 2, i32 1 ; [#uses=1] - store i16 0, i16* %tmp221, align 2 - %tmp232 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 1, i32 0 ; [#uses=1] - store i16 0, i16* %tmp232, align 2 - %tmp235 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 1, i32 1 ; [#uses=1] - store i16 0, i16* %tmp235, align 2 - %tmp246 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 0, i32 0 ; [#uses=1] - store i16 0, i16* %tmp246, align 8 - %tmp249 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 0, i32 1 ; [#uses=1] - store i16 0, i16* %tmp249, align 2 - %up_mvd252 = getelementptr [8 x %struct.MV]* %up_mvd, i32 0, i32 0 ; <%struct.MV*> [#uses=1] - %left_mvd253 = getelementptr [8 x %struct.MV]* %left_mvd, i32 0, i32 0 ; <%struct.MV*> [#uses=1] - call void @foo( %struct.MV* %up_mvd252, %struct.MV* %left_mvd253, i8* %tmp41 ) nounwind - ret i32 undef -} - -declare void @foo(%struct.MV*, %struct.MV*, i8*) Removed: llvm/trunk/test/Transforms/GVN/memcpy.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/memcpy.ll?rev=49418&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GVN/memcpy.ll (original) +++ llvm/trunk/test/Transforms/GVN/memcpy.ll (removed) @@ -1,22 +0,0 @@ -; RUN: llvm-as < %s | opt -gvn -dse | llvm-dis | grep {call.*memcpy} | count 1 - -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i686-apple-darwin9" - -define void @ccosl({ x86_fp80, x86_fp80 }* sret %agg.result, x86_fp80 %z.0, x86_fp80 %z.1) nounwind { -entry: - %tmp2 = alloca { x86_fp80, x86_fp80 } ; <{ x86_fp80, x86_fp80 }*> [#uses=1] - %memtmp = alloca { x86_fp80, x86_fp80 }, align 16 ; <{ x86_fp80, x86_fp80 }*> [#uses=2] - %tmp5 = sub x86_fp80 0xK80000000000000000000, %z.1 ; [#uses=1] - call void @ccoshl( { x86_fp80, x86_fp80 }* sret %memtmp, x86_fp80 %tmp5, x86_fp80 %z.0 ) nounwind - %tmp219 = bitcast { x86_fp80, x86_fp80 }* %tmp2 to i8* ; [#uses=2] - %memtmp20 = bitcast { x86_fp80, x86_fp80 }* %memtmp to i8* ; [#uses=1] - call void @llvm.memcpy.i32( i8* %tmp219, i8* %memtmp20, i32 32, i32 16 ) - %agg.result21 = bitcast { x86_fp80, x86_fp80 }* %agg.result to i8* ; [#uses=1] - call void @llvm.memcpy.i32( i8* %agg.result21, i8* %tmp219, i32 32, i32 16 ) - ret void -} - -declare void @ccoshl({ x86_fp80, x86_fp80 }* sret , x86_fp80, x86_fp80) nounwind - -declare void @llvm.memcpy.i32(i8*, i8*, i32, i32) nounwind Removed: llvm/trunk/test/Transforms/GVN/sret.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/sret.ll?rev=49418&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GVN/sret.ll (original) +++ llvm/trunk/test/Transforms/GVN/sret.ll (removed) @@ -1,28 +0,0 @@ -; RUN: llvm-as < %s | opt -gvn | llvm-dis | not grep {call.*memcpy} - -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i686-apple-darwin9" - -define void @ccosl({ x86_fp80, x86_fp80 }* noalias sret %agg.result, { x86_fp80, x86_fp80 }* byval %z) nounwind { -entry: - %iz = alloca { x86_fp80, x86_fp80 } ; <{ x86_fp80, x86_fp80 }*> [#uses=3] - %memtmp = alloca { x86_fp80, x86_fp80 }, align 16 ; <{ x86_fp80, x86_fp80 }*> [#uses=2] - %tmp1 = getelementptr { x86_fp80, x86_fp80 }* %z, i32 0, i32 1 ; [#uses=1] - %tmp2 = load x86_fp80* %tmp1, align 16 ; [#uses=1] - %tmp3 = sub x86_fp80 0xK80000000000000000000, %tmp2 ; [#uses=1] - %tmp4 = getelementptr { x86_fp80, x86_fp80 }* %iz, i32 0, i32 1 ; [#uses=1] - %real = getelementptr { x86_fp80, x86_fp80 }* %iz, i32 0, i32 0 ; [#uses=1] - %tmp7 = getelementptr { x86_fp80, x86_fp80 }* %z, i32 0, i32 0 ; [#uses=1] - %tmp8 = load x86_fp80* %tmp7, align 16 ; [#uses=1] - store x86_fp80 %tmp3, x86_fp80* %real, align 16 - store x86_fp80 %tmp8, x86_fp80* %tmp4, align 16 - call void @ccoshl( { x86_fp80, x86_fp80 }* noalias sret %memtmp, { x86_fp80, x86_fp80 }* byval %iz ) nounwind - %memtmp14 = bitcast { x86_fp80, x86_fp80 }* %memtmp to i8* ; [#uses=1] - %agg.result15 = bitcast { x86_fp80, x86_fp80 }* %agg.result to i8* ; [#uses=1] - call void @llvm.memcpy.i32( i8* %agg.result15, i8* %memtmp14, i32 32, i32 16 ) - ret void -} - -declare void @ccoshl({ x86_fp80, x86_fp80 }* noalias sret , { x86_fp80, x86_fp80 }* byval ) nounwind - -declare void @llvm.memcpy.i32(i8*, i8*, i32, i32) nounwind Copied: llvm/trunk/test/Transforms/MemCpyOpt/2008-02-24-MultipleUseofSRet.ll (from r49415, llvm/trunk/test/Transforms/GVN/2008-02-24-MultipleUseofSRet.ll) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MemCpyOpt/2008-02-24-MultipleUseofSRet.ll?p2=llvm/trunk/test/Transforms/MemCpyOpt/2008-02-24-MultipleUseofSRet.ll&p1=llvm/trunk/test/Transforms/GVN/2008-02-24-MultipleUseofSRet.ll&r1=49415&r2=49419&rev=49419&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/2008-02-24-MultipleUseofSRet.ll (original) +++ llvm/trunk/test/Transforms/MemCpyOpt/2008-02-24-MultipleUseofSRet.ll Wed Apr 9 03:23:16 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -gvn -dse | llvm-dis | grep {call.*initialize} | not grep memtmp +; RUN: llvm-as < %s | opt -memcpyopt -dse | llvm-dis | grep {call.*initialize} | not grep memtmp ; PR2077 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32" Copied: llvm/trunk/test/Transforms/MemCpyOpt/2008-03-13-ReturnSlotBitcast.ll (from r49415, llvm/trunk/test/Transforms/GVN/2008-03-13-ReturnSlotBitcast.ll) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MemCpyOpt/2008-03-13-ReturnSlotBitcast.ll?p2=llvm/trunk/test/Transforms/MemCpyOpt/2008-03-13-ReturnSlotBitcast.ll&p1=llvm/trunk/test/Transforms/GVN/2008-03-13-ReturnSlotBitcast.ll&r1=49415&r2=49419&rev=49419&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/2008-03-13-ReturnSlotBitcast.ll (original) +++ llvm/trunk/test/Transforms/MemCpyOpt/2008-03-13-ReturnSlotBitcast.ll Wed Apr 9 03:23:16 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -gvn | llvm-dis | not grep {call.*memcpy.} +; RUN: llvm-as < %s | opt -memcpyopt | llvm-dis | not grep {call.*memcpy.} %a = type { i32 } %b = type { float } Added: llvm/trunk/test/Transforms/MemCpyOpt/dg.exp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MemCpyOpt/dg.exp?rev=49419&view=auto ============================================================================== --- llvm/trunk/test/Transforms/MemCpyOpt/dg.exp (added) +++ llvm/trunk/test/Transforms/MemCpyOpt/dg.exp Wed Apr 9 03:23:16 2008 @@ -0,0 +1,3 @@ +load_lib llvm.exp + +RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,llx,c,cpp,tr}]] Copied: llvm/trunk/test/Transforms/MemCpyOpt/form-memset.ll (from r49415, llvm/trunk/test/Transforms/GVN/form-memset.ll) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MemCpyOpt/form-memset.ll?p2=llvm/trunk/test/Transforms/MemCpyOpt/form-memset.ll&p1=llvm/trunk/test/Transforms/GVN/form-memset.ll&r1=49415&r2=49419&rev=49419&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/form-memset.ll (original) +++ llvm/trunk/test/Transforms/MemCpyOpt/form-memset.ll Wed Apr 9 03:23:16 2008 @@ -1,5 +1,5 @@ -; RUN: llvm-as < %s | opt -gvn -form-memset-from-stores | llvm-dis | not grep store -; RUN: llvm-as < %s | opt -gvn -form-memset-from-stores | llvm-dis | grep {call.*llvm.memset} +; RUN: llvm-as < %s | opt -memcpyopt -form-memset-from-stores | llvm-dis | not grep store +; RUN: llvm-as < %s | opt -memcpyopt -form-memset-from-stores | llvm-dis | grep {call.*llvm.memset} ; All the stores in this example should be merged into a single memset. Copied: llvm/trunk/test/Transforms/MemCpyOpt/form-memset2.ll (from r49415, llvm/trunk/test/Transforms/GVN/form-memset2.ll) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MemCpyOpt/form-memset2.ll?p2=llvm/trunk/test/Transforms/MemCpyOpt/form-memset2.ll&p1=llvm/trunk/test/Transforms/GVN/form-memset2.ll&r1=49415&r2=49419&rev=49419&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/form-memset2.ll (original) +++ llvm/trunk/test/Transforms/MemCpyOpt/form-memset2.ll Wed Apr 9 03:23:16 2008 @@ -1,5 +1,5 @@ -; RUN: llvm-as < %s | opt -gvn -form-memset-from-stores | llvm-dis | not grep store -; RUN: llvm-as < %s | opt -gvn -form-memset-from-stores | llvm-dis | grep {call.*llvm.memset} | count 3 +; RUN: llvm-as < %s | opt -memcpyopt -form-memset-from-stores | llvm-dis | not grep store +; RUN: llvm-as < %s | opt -memcpyopt -form-memset-from-stores | llvm-dis | grep {call.*llvm.memset} | count 3 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" target triple = "i386-apple-darwin8" Copied: llvm/trunk/test/Transforms/MemCpyOpt/memcpy.ll (from r49415, llvm/trunk/test/Transforms/GVN/memcpy.ll) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MemCpyOpt/memcpy.ll?p2=llvm/trunk/test/Transforms/MemCpyOpt/memcpy.ll&p1=llvm/trunk/test/Transforms/GVN/memcpy.ll&r1=49415&r2=49419&rev=49419&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/memcpy.ll (original) +++ llvm/trunk/test/Transforms/MemCpyOpt/memcpy.ll Wed Apr 9 03:23:16 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -gvn -dse | llvm-dis | grep {call.*memcpy} | count 1 +; RUN: llvm-as < %s | opt -memcpyopt -dse | llvm-dis | grep {call.*memcpy} | count 1 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" target triple = "i686-apple-darwin9" Copied: llvm/trunk/test/Transforms/MemCpyOpt/sret.ll (from r49415, llvm/trunk/test/Transforms/GVN/sret.ll) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MemCpyOpt/sret.ll?p2=llvm/trunk/test/Transforms/MemCpyOpt/sret.ll&p1=llvm/trunk/test/Transforms/GVN/sret.ll&r1=49415&r2=49419&rev=49419&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/sret.ll (original) +++ llvm/trunk/test/Transforms/MemCpyOpt/sret.ll Wed Apr 9 03:23:16 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -gvn | llvm-dis | not grep {call.*memcpy} +; RUN: llvm-as < %s | opt -memcpyopt | llvm-dis | not grep {call.*memcpy} target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" target triple = "i686-apple-darwin9" Modified: llvm/trunk/tools/llvm-ld/Optimize.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ld/Optimize.cpp?rev=49419&r1=49418&r2=49419&view=diff ============================================================================== --- llvm/trunk/tools/llvm-ld/Optimize.cpp (original) +++ llvm/trunk/tools/llvm-ld/Optimize.cpp Wed Apr 9 03:23:16 2008 @@ -169,6 +169,7 @@ addPass(Passes, createGlobalsModRefPass()); // IP alias analysis addPass(Passes, createLICMPass()); // Hoist loop invariants + addPass(Passes, createMemCpyOptPass()); // Remove dead memcpy's addPass(Passes, createGVNPass()); // Remove redundancies addPass(Passes, createDeadStoreEliminationPass()); // Nuke dead stores Modified: llvm/trunk/tools/opt/opt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=49419&r1=49418&r2=49419&view=diff ============================================================================== --- llvm/trunk/tools/opt/opt.cpp (original) +++ llvm/trunk/tools/opt/opt.cpp Wed Apr 9 03:23:16 2008 @@ -282,6 +282,7 @@ addPass(PM, createIndVarSimplifyPass()); // Canonicalize indvars addPass(PM, createLoopUnrollPass()); // Unroll small loops addPass(PM, createInstructionCombiningPass()); // Clean up after the unroller + addPass(PM, createMemCpyOptPass()); // Remove unneeded memcpy's addPass(PM, createGVNPass()); // Remove redundancies addPass(PM, createSCCPPass()); // Constant prop with SCCP From resistor at mac.com Wed Apr 9 03:24:51 2008 From: resistor at mac.com (Owen Anderson) Date: Wed, 09 Apr 2008 08:24:51 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49420 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Message-ID: <200804090824.m398OpQT013898@zion.cs.uiuc.edu> Author: resistor Date: Wed Apr 9 03:24:51 2008 New Revision: 49420 URL: http://llvm.org/viewvc/llvm-project?rev=49420&view=rev Log: Add the new MemCpyOpt pass to the standard set. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=49420&r1=49419&r2=49420&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Wed Apr 9 03:24:51 2008 @@ -384,6 +384,7 @@ if (flag_unroll_loops) PM->add(createLoopUnrollPass()); // Unroll small loops PM->add(createInstructionCombiningPass()); // Clean up after the unroller + PM->add(createMemCpyOptPass()) // Remove dead memcpy's PM->add(createGVNPass()); // Remove redundancies PM->add(createSCCPPass()); // Constant prop with SCCP From baldrick at free.fr Wed Apr 9 04:39:30 2008 From: baldrick at free.fr (Duncan Sands) Date: Wed, 09 Apr 2008 09:39:30 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49422 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Message-ID: <200804090939.m399dUtg016956@zion.cs.uiuc.edu> Author: baldrick Date: Wed Apr 9 04:39:29 2008 New Revision: 49422 URL: http://llvm.org/viewvc/llvm-project?rev=49422&view=rev Log: Hack to fix PR1971. Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=49422&r1=49421&r2=49422&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Wed Apr 9 04:39:29 2008 @@ -1701,7 +1701,8 @@ // node for it, but not when A is a nonvirtual base class. So we can't // use that.) static void FixBaseClassFields(tree type) { - assert(TREE_CODE(type)==RECORD_TYPE); + if (TREE_CODE(type)!=RECORD_TYPE) + return; for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) { if (TREE_CODE(Field)==FIELD_DECL && !DECL_BIT_FIELD_TYPE(Field) && @@ -1749,7 +1750,8 @@ // code continues to work (there are pointers stashed away in there). static void RestoreBaseClassFields(tree type) { - assert(TREE_CODE(type)==RECORD_TYPE); + if (TREE_CODE(type)!=RECORD_TYPE) + return; for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) { if (TREE_CODE(Field) == FIELD_DECL && DECL_FIELD_REPLACED(Field)) { tree &oldTy = BaseTypesMap[TREE_TYPE(Field)]; @@ -2174,7 +2176,13 @@ unsigned MaxSize = 0, MaxAlign = 0; for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) { if (TREE_CODE(Field) != FIELD_DECL) continue; - assert(getFieldOffsetInBits(Field) == 0 && "Union with non-zero offset?"); +// assert(getFieldOffsetInBits(Field) == 0 && "Union with non-zero offset?"); + // Hack to get Fortran EQUIVALENCE working. + // TODO: Unify record and union logic and handle this optimally. + if (getFieldOffsetInBits(Field) != 0) { + ConvertingStruct = OldConvertingStruct; + return ConvertRECORD(type, orig_type); + } // Set the field idx to zero for all fields. SetFieldIndex(Field, 0); From baldrick at free.fr Wed Apr 9 04:30:28 2008 From: baldrick at free.fr (Duncan Sands) Date: Wed, 09 Apr 2008 09:30:28 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49421 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp llvm-types.cpp Message-ID: <200804090930.m399USPh016709@zion.cs.uiuc.edu> Author: baldrick Date: Wed Apr 9 04:30:27 2008 New Revision: 49421 URL: http://llvm.org/viewvc/llvm-project?rev=49421&view=rev Log: Silence gcc-4.4 warnings. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=49421&r1=49420&r2=49421&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Wed Apr 9 04:30:27 2008 @@ -1828,7 +1828,7 @@ } } - if (DefaultDest) + if (DefaultDest) { if (SI->getSuccessor(0) == Builder.GetInsertBlock()) SI->setSuccessor(0, DefaultDest); else { @@ -1836,6 +1836,7 @@ // Emit a "fallthrough" block, which is almost certainly dead. EmitBlock(BasicBlock::Create("")); } + } return 0; } @@ -6107,7 +6108,7 @@ } else { // If this is little-endian bit-field, take the bottom NumBitsToInsert // bits from the bitfield value. - EltValToInsert = ValToInsert & (1ULL << NumEltBitsToInsert)-1; + EltValToInsert = ValToInsert & ((1ULL << NumEltBitsToInsert)-1); ValToInsert >>= NumEltBitsToInsert; } @@ -6205,7 +6206,7 @@ } else { // If this is little-endian bit-field, take the bottom NumBitsToInsert // bits from the bitfield value. - ValToInsert = BitfieldVal & (1ULL << NumBitsToInsert)-1; + ValToInsert = BitfieldVal & ((1ULL << NumBitsToInsert)-1); BitfieldVal >>= NumBitsToInsert; } @@ -6297,9 +6298,9 @@ assert(FieldNo < ResultElts.size() && "Invalid struct field number!"); // Example: struct X { int A; char C[]; } x = { 4, "foo" }; - assert(TYPE_SIZE(getDeclaredType(Field)) || + assert((TYPE_SIZE(getDeclaredType(Field)) || (FieldNo == ResultElts.size()-1 && - isStructWithVarSizeArrayAtEnd(STy)) + isStructWithVarSizeArrayAtEnd(STy))) && "field with no size is not array at end of struct!"); // If this is an initialization of a global that ends with a variable @@ -6498,7 +6499,7 @@ // Check for variable sized reference. // FIXME: add support for array types where the size doesn't fit into 64 bits - assert(isArrayCompatible(ArrayType) || isSequentialCompatible(ArrayType) + assert((isArrayCompatible(ArrayType) || isSequentialCompatible(ArrayType)) && "Cannot have globals with variable size!"); // As an LLVM extension, we allow ARRAY_REF with a pointer as the first Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=49421&r1=49420&r2=49421&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Wed Apr 9 04:30:27 2008 @@ -245,11 +245,12 @@ /// the specified type. static std::string GetTypeName(const char *Prefix, tree type) { const char *Name = "anon"; - if (TYPE_NAME(type)) + if (TYPE_NAME(type)) { if (TREE_CODE(TYPE_NAME(type)) == IDENTIFIER_NODE) Name = IDENTIFIER_POINTER(TYPE_NAME(type)); else if (DECL_NAME(TYPE_NAME(type))) Name = IDENTIFIER_POINTER(DECL_NAME(TYPE_NAME(type))); + } std::string ContextStr; tree Context = TYPE_CONTEXT(type); From resistor at mac.com Wed Apr 9 04:55:59 2008 From: resistor at mac.com (Owen Anderson) Date: Wed, 09 Apr 2008 09:55:59 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49423 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Message-ID: <200804090955.m399txl2017433@zion.cs.uiuc.edu> Author: resistor Date: Wed Apr 9 04:55:58 2008 New Revision: 49423 URL: http://llvm.org/viewvc/llvm-project?rev=49423&view=rev Log: Unbreak the build. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=49423&r1=49422&r2=49423&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Wed Apr 9 04:55:58 2008 @@ -384,7 +384,7 @@ if (flag_unroll_loops) PM->add(createLoopUnrollPass()); // Unroll small loops PM->add(createInstructionCombiningPass()); // Clean up after the unroller - PM->add(createMemCpyOptPass()) // Remove dead memcpy's + PM->add(createMemCpyOptPass()); // Remove dead memcpy's PM->add(createGVNPass()); // Remove redundancies PM->add(createSCCPPass()); // Constant prop with SCCP From arnold.schwaighofer at gmail.com Wed Apr 9 06:32:33 2008 From: arnold.schwaighofer at gmail.com (Arnold Schwaighofer) Date: Wed, 9 Apr 2008 13:32:33 +0200 Subject: [llvm-commits] PATCH: Tailcallopt x86 byval argument handling In-Reply-To: References: Message-ID: On Wed, Apr 9, 2008 at 9:05 AM, Evan Cheng wrote: > Ok, I misread it. These are the registers that are used in the lowered > memcpy code sequence for byval? yes > The trouble is this is assuming > memcpy's are always lowered a certain way which doesn't seem safe to > me. > There seems to be a phase ordering problem here. We need for the > byval memcpy to be lowered first before we issue the copies to save > these registers in virtual registers. Do you think that's possible? No i believe not. The problem with reordering is that when performing tail call optimization we always have to keep in mind that we might end up copying arguments (caller function's) onto arguments (tailcall function's) overwriting each other. So a special ordering has to be obeyed. copy byval arguments to the top of the stack [1] move arguments to registers emit a series of copytovirtreg copyfromvirtreg for the tailcallclobbered arguments store the copyfromreg values to the tailcall stack slots copy byval arguments form the top of the stack to their tailcall stack slot [<- this line would have to be moved to 1] We can't move the last line after the first line because we might overwrite arguments that are source for the registers. confusing. definitately ;) consider this example: int (struct{int,int} a byval, int b) { tailcall callee(int b,struct{int,int} a byval)) } say we generate the following code sequence copy byval args to top of stack copy byval args to tail call position [ups we are overwriting b] mov b to a argument register [wrong b] BUT: I think it is possible to eliminate the check for esi, edi, ecx. Instead of only copying the 'byval clobbered' registers to virtual registers and back this will be done for all argument registers (if byval args occur). The register allocator will than hopefully do the rest (eliminating the unneccessary ones). D'oh - there is always a simpler solution waiting to be beaten out of me by evan. ;-) ill try this and correct the other stuff and hopefully return with a new shiny patch i'll be back regards arnold From nicolas.geoffray at lip6.fr Wed Apr 9 08:33:24 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Wed, 09 Apr 2008 13:33:24 -0000 Subject: [llvm-commits] [vmkit] r49424 - in /vmkit/trunk: configure.ac lib/JnJVM/Makefile.am lib/JnJVM/VMCore/JavaIsolate.cpp lib/JnJVM/VMCore/JavaThread.cpp lib/Mvm/JIT.cpp lib/N3/VMCore/PNetLib.cpp Message-ID: <200804091333.m39DXO3n023871@zion.cs.uiuc.edu> Author: geoffray Date: Wed Apr 9 08:33:23 2008 New Revision: 49424 URL: http://llvm.org/viewvc/llvm-project?rev=49424&view=rev Log: Compilation fixes for Darwin Modified: vmkit/trunk/configure.ac vmkit/trunk/lib/JnJVM/Makefile.am vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp vmkit/trunk/lib/Mvm/JIT.cpp vmkit/trunk/lib/N3/VMCore/PNetLib.cpp Modified: vmkit/trunk/configure.ac URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/configure.ac?rev=49424&r1=49423&r2=49424&view=diff ============================================================================== --- vmkit/trunk/configure.ac (original) +++ vmkit/trunk/configure.ac Wed Apr 9 08:33:23 2008 @@ -113,6 +113,7 @@ dnl ************************************************************************** case $target_os in *darwin*) + DYLIB_EXTENSION="dylib" rdynamic="" ;; *linux*) @@ -129,6 +130,7 @@ ) rdynamic="-rdynamic" + DYLIB_EXTENSION="so" AC_DEFINE([HAVE_DISASSEMBLER], [1], [Using libopcodes]) ;; @@ -141,6 +143,7 @@ AC_SUBST([rdynamic]) AC_SUBST([LLVMDYLIB]) +AC_SUBST([DYLIB_EXTENSION]) dnl ************************************************************************** dnl VVM thread type @@ -245,10 +248,14 @@ echo Using ${gnuclasspathinstallationprefix} as GNU CLASSPATH installation prefix; classpathglibj=${gnuclasspathinstallationprefix}/share/classpath/glibj.zip; classpathlibs=${gnuclasspathinstallationprefix}/lib/classpath/; + CFLAGS=$CFLAGS -I$gnuclasspathinstallationprefix/include + CXXFLAGS=$CXXFLAGS -I$gnuclasspathinstallationprefix/include else echo Using ${gnuclasspathlocalprefix} as GNU CLASSPATH local prefix; classpathglibj=${gnuclasspathlocalprefix}/lib/; classpathlibs=${gnuclasspathlocalprefix}/lib/; + CFLAGS="$CFLAGS -I$gnuclasspathlocalprefix/include" + CXXFLAGS="$CXXFLAGS -I$gnuclasspathlocalprefix/include" fi Modified: vmkit/trunk/lib/JnJVM/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Makefile.am?rev=49424&r1=49423&r2=49424&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Makefile.am (original) +++ vmkit/trunk/lib/JnJVM/Makefile.am Wed Apr 9 08:33:23 2008 @@ -2,7 +2,7 @@ SUBDIRS = VMCore Classpath EXTRA_DIST = OpcodeNames.def bin_PROGRAMS = main -lib_LTLIBRARIES = libjnjvm.la +#lib_LTLIBRARIES = libjnjvm.la THREADDIR=../Mvm/CommonThread ALLOCDIR=../Mvm/Allocator @@ -21,5 +21,5 @@ main_LDADD = VMCore/.libs/libJnJVM.a Classpath/.libs/libClasspath.a $(LIBSUVM) @LLVMDYLIB@ main_LDFLAGS = @rdynamic@ -libjnjvm.la: - gcc -shared VMCore/.libs/libJnJVM.so Classpath/.libs/libClasspath.so -o libjnjvm.so +#libjnjvm.la: +# gcc -shared VMCore/.libs/libJnJVM.$(DYLIB_EXTENSION) Classpath/.libs/libClasspath.$(DYLIB_EXTENSION) -o libjnjvm.$(DYLIB_EXTENSION) Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp?rev=49424&r1=49423&r2=49424&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp Wed Apr 9 08:33:23 2008 @@ -63,7 +63,7 @@ assert(0 && "implement me"); } -extern "C" int strnstr(const char *haystack, const char *needle) { +extern "C" int sys_strnstr(const char *haystack, const char *needle) { char * res = strstr(haystack, needle); if (res) return res - haystack; else return -1; @@ -72,10 +72,10 @@ static char* findInformation(ArrayUInt8* manifest, const char* entry, uint32 len) { uint8* ptr = manifest->elements; - sint32 index = strnstr((char*)ptr, entry); + sint32 index = sys_strnstr((char*)ptr, entry); if (index != -1) { index += len; - sint32 end = strnstr((char*)&(ptr[index]), "\n"); + sint32 end = sys_strnstr((char*)&(ptr[index]), "\n"); if (end == -1) end = manifest->size; else end += index; Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp?rev=49424&r1=49423&r2=49424&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp Wed Apr 9 08:33:23 2008 @@ -112,5 +112,9 @@ void JavaThread::returnFromNative() { assert(sjlj_buffers.size()); +#if defined(__MACH__) + longjmp((int*)sjlj_buffers.back(), 1); +#else longjmp((__jmp_buf_tag*)sjlj_buffers.back(), 1); +#endif } Modified: vmkit/trunk/lib/Mvm/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/JIT.cpp?rev=49424&r1=49423&r2=49424&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/JIT.cpp (original) +++ vmkit/trunk/lib/Mvm/JIT.cpp Wed Apr 9 08:33:23 2008 @@ -513,7 +513,7 @@ // Constant declaration - constantLongMinusOne = ConstantInt::get(Type::Int64Ty, -1); + constantLongMinusOne = ConstantInt::get(Type::Int64Ty, (uint64_t)-1); constantLongZero = ConstantInt::get(Type::Int64Ty, 0); constantLongOne = ConstantInt::get(Type::Int64Ty, 1); constantZero = ConstantInt::get(Type::Int32Ty, 0); @@ -526,7 +526,7 @@ constantSix = ConstantInt::get(Type::Int32Ty, 6); constantSeven = ConstantInt::get(Type::Int32Ty, 7); constantEight = ConstantInt::get(Type::Int32Ty, 8); - constantMinusOne = ConstantInt::get(Type::Int32Ty, -1); + constantMinusOne = ConstantInt::get(Type::Int32Ty, (uint64_t)-1); constantMinInt = ConstantInt::get(Type::Int32Ty, MinInt); constantMaxInt = ConstantInt::get(Type::Int32Ty, MaxInt); constantMinLong = ConstantInt::get(Type::Int64Ty, MinLong); Modified: vmkit/trunk/lib/N3/VMCore/PNetLib.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/PNetLib.cpp?rev=49424&r1=49423&r2=49424&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/PNetLib.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/PNetLib.cpp Wed Apr 9 08:33:23 2008 @@ -678,6 +678,16 @@ #define ASSEMBLY_VALUE(obj) ((Assembly**)obj)[3] +#if !defined(__GNU__) +void* memrchr(const void* s, int c, size_t n) { + unsigned char* m = (unsigned char*) s; + for (;;) { + if (!(n--)) return NULL; + else if (*m-- == (unsigned char)c) return (void*)(m+1); + } +} +#endif + extern "C" VMObject* System_Reflection_Assembly_GetType(VMObject* obj, CLIString* str, bool onError, bool ignoreCase) { Assembly* ass = ASSEMBLY_VALUE(obj); const UTF8* utf8 = str->value; From ggreif at gmail.com Wed Apr 9 09:39:56 2008 From: ggreif at gmail.com (Gabor Greif) Date: Wed, 09 Apr 2008 14:39:56 -0000 Subject: [llvm-commits] [llvm] r49425 - in /llvm/branches/ggreif/use-diet: include/llvm/BasicBlock.h include/llvm/GlobalAlias.h include/llvm/GlobalVariable.h include/llvm/InstrTypes.h include/llvm/Instructions.h include/llvm/Use.h include/llvm/User.h lib/VMCore/BasicBlock.cpp lib/VMCore/Constants.cpp lib/VMCore/Globals.cpp lib/VMCore/Instructions.cpp lib/VMCore/Use.cpp Message-ID: <200804091439.m39EduCW025807@zion.cs.uiuc.edu> Author: ggreif Date: Wed Apr 9 09:39:56 2008 New Revision: 49425 URL: http://llvm.org/viewvc/llvm-project?rev=49425&view=rev Log: major surgery to get rid of embedded Uses. BitcodeReader does not compile yet. Modified: llvm/branches/ggreif/use-diet/include/llvm/BasicBlock.h llvm/branches/ggreif/use-diet/include/llvm/GlobalAlias.h llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h llvm/branches/ggreif/use-diet/include/llvm/Instructions.h llvm/branches/ggreif/use-diet/include/llvm/Use.h llvm/branches/ggreif/use-diet/include/llvm/User.h llvm/branches/ggreif/use-diet/lib/VMCore/BasicBlock.cpp llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp llvm/branches/ggreif/use-diet/lib/VMCore/Globals.cpp llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Modified: llvm/branches/ggreif/use-diet/include/llvm/BasicBlock.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/BasicBlock.h?rev=49425&r1=49424&r2=49425&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/BasicBlock.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/BasicBlock.h Wed Apr 9 09:39:56 2008 @@ -52,11 +52,11 @@ class BasicBlock : public User { // Basic blocks are data objects also public: typedef iplist InstListType; -private : +private: InstListType InstList; BasicBlock *Prev, *Next; // Next and Prev links for our intrusive linked list Function *Parent; - Use unwindDest; +/* Use unwindDest;*/ void setParent(Function *parent); void setNext(BasicBlock *N) { Next = N; } Modified: llvm/branches/ggreif/use-diet/include/llvm/GlobalAlias.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/GlobalAlias.h?rev=49425&r1=49424&r2=49425&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/GlobalAlias.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/GlobalAlias.h Wed Apr 9 09:39:56 2008 @@ -42,11 +42,10 @@ GlobalAlias *getPrev() { return Prev; } const GlobalAlias *getPrev() const { return Prev; } - Use Aliasee; public: - // allocate space for exactly zero operands + // allocate space for exactly one operand void *operator new(size_t s) { - return User::operator new(s, 0); + return User::operator new(s, 1); } /// GlobalAlias ctor - If a parent module is specified, the alias is /// automatically inserted into the end of the specified module's alias list. Modified: llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h?rev=49425&r1=49424&r2=49425&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h Wed Apr 9 09:39:56 2008 @@ -44,12 +44,11 @@ bool isConstantGlobal : 1; // Is this a global constant? bool isThreadLocalSymbol : 1; // Is this symbol "Thread Local"? - Use Initializer; public: - // allocate space for exactly zero operands + // allocate space for exactly one operand void *operator new(size_t s) { - return User::operator new(s, 0); + return User::operator new(s, 1); // FIXME: if no initializer, then 0 } /// GlobalVariable ctor - If a parent module is specified, the global is /// automatically inserted into the end of the specified modules global list. @@ -81,22 +80,22 @@ /// inline Constant *getInitializer() const { assert(hasInitializer() && "GV doesn't have initializer!"); - return reinterpret_cast(Initializer.get()); + return static_cast(Op<0>().get()); } inline Constant *getInitializer() { assert(hasInitializer() && "GV doesn't have initializer!"); - return reinterpret_cast(Initializer.get()); + return static_cast(Op<0>().get()); } inline void setInitializer(Constant *CPV) { if (CPV == 0) { if (hasInitializer()) { - Initializer.set(0); + Op<0>().set(0); NumOperands = 0; } } else { if (!hasInitializer()) NumOperands = 1; - Initializer.set(CPV); + Op<0>().set(CPV); } } Modified: llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h?rev=49425&r1=49424&r2=49425&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h Wed Apr 9 09:39:56 2008 @@ -84,16 +84,15 @@ class UnaryInstruction : public Instruction { void *operator new(size_t, unsigned); // Do not implement - Use Op; - // avoiding warning: 'this' : used in base member initializer list - UnaryInstruction* this_() { return this; } protected: - UnaryInstruction(const Type *Ty, unsigned iType, Value *V, Instruction *IB =0) - : Instruction(Ty, iType, &Op, 1, IB), Op(V, this_()) { + UnaryInstruction(const Type *Ty, unsigned iType, Value *V, Instruction *IB = 0) + : Instruction(Ty, iType, &Op<0>(), 1, IB) { + Op<0>() = V; } UnaryInstruction(const Type *Ty, unsigned iType, Value *V, BasicBlock *IAE) - : Instruction(Ty, iType, &Op, 1, IAE), Op(V, this_()) { + : Instruction(Ty, iType, &Op<0>(), 1, IAE) { + Op<0>() = V; } public: // allocate space for exactly one operand @@ -107,11 +106,11 @@ // Transparently provide more efficient getOperand methods. Value *getOperand(unsigned i) const { assert(i == 0 && "getOperand() out of range!"); - return Op; + return Op<0>(); } void setOperand(unsigned i, Value *Val) { assert(i == 0 && "setOperand() out of range!"); - Op = Val; + Op<0>() = Val; } unsigned getNumOperands() const { return 1; } @@ -136,7 +135,6 @@ class BinaryOperator : public Instruction { void *operator new(size_t, unsigned); // Do not implement - Use Ops[2]; protected: void init(BinaryOps iType); BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty, @@ -152,11 +150,11 @@ /// Transparently provide more efficient getOperand methods. Value *getOperand(unsigned i) const { assert(i < 2 && "getOperand() out of range!"); - return Ops[i]; + return OperandList[i]; } void setOperand(unsigned i, Value *Val) { assert(i < 2 && "setOperand() out of range!"); - Ops[i] = Val; + OperandList[i] = Val; } unsigned getNumOperands() const { return 2; } @@ -509,8 +507,6 @@ CmpInst(Instruction::OtherOps op, unsigned short pred, Value *LHS, Value *RHS, const std::string &Name, BasicBlock *InsertAtEnd); - Use Ops[2]; // CmpInst instructions always have 2 operands, optimize - public: // allocate space for exactly two operands void *operator new(size_t s) { @@ -552,11 +548,11 @@ /// @brief Provide more efficient getOperand methods. Value *getOperand(unsigned i) const { assert(i < 2 && "getOperand() out of range!"); - return Ops[i]; + return OperandList[i]; } void setOperand(unsigned i, Value *Val) { assert(i < 2 && "setOperand() out of range!"); - Ops[i] = Val; + OperandList[i] = Val; } /// @brief CmpInst instructions always have 2 operands. Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=49425&r1=49424&r2=49425&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Wed Apr 9 09:39:56 2008 @@ -288,11 +288,10 @@ /// class StoreInst : public Instruction { void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - Use Ops[2]; - StoreInst(const StoreInst &SI) : Instruction(SI.getType(), Store, Ops, 2) { - Ops[0].init(SI.Ops[0], this); - Ops[1].init(SI.Ops[1], this); + StoreInst(const StoreInst &SI) : Instruction(SI.getType(), Store, &Op<0>(), 2) { + Op<0>().init(SI.Op<0>(), this); + Op<1>().init(SI.Op<1>(), this); setVolatile(SI.isVolatile()); setAlignment(SI.getAlignment()); @@ -331,11 +330,11 @@ /// Transparently provide more efficient getOperand methods. Value *getOperand(unsigned i) const { assert(i < 2 && "getOperand() out of range!"); - return Ops[i]; + return OperandList[i]; } void setOperand(unsigned i, Value *Val) { assert(i < 2 && "setOperand() out of range!"); - Ops[i] = Val; + OperandList[i] = Val; } unsigned getNumOperands() const { return 2; } @@ -383,7 +382,7 @@ GetElementPtrInst(const GetElementPtrInst &GEPI) : Instruction(reinterpret_cast(GEPI.getType()), GetElementPtr, 0, GEPI.getNumOperands()) { - Use *OL = OperandList = new Use[NumOperands]; + Use *OL = OperandList = 0; // FIXME: GEPI.dupHangoffUses(this, NumOperands, GEPI.OperandList) new Use[NumOperands]; Use *GEPIOL = GEPI.OperandList; for (unsigned i = 0, E = NumOperands; i != E; ++i) OL[i].init(GEPIOL[i], this); @@ -401,7 +400,7 @@ std::distance(IdxBegin, IdxEnd); if (NumIdx > 0) { - // This requires that the itoerator points to contiguous memory. + // This requires that the iterator points to contiguous memory. init(Ptr, &*IdxBegin, NumIdx); } else { @@ -725,7 +724,7 @@ /// @brief Swap operands and adjust predicate. void swapOperands() { SubclassData = getSwappedPredicate(); - std::swap(Ops[0], Ops[1]); + std::swap(Op<0>(), Op<1>()); } virtual ICmpInst *clone() const; @@ -849,7 +848,7 @@ /// @brief Swap operands and adjust predicate. void swapOperands() { SubclassData = getSwappedPredicate(); - std::swap(Ops[0], Ops[1]); + std::swap(Op<0>(), Op<1>()); } virtual FCmpInst *clone() const; @@ -1053,27 +1052,25 @@ /// SelectInst - This class represents the LLVM 'select' instruction. /// class SelectInst : public Instruction { - Use Ops[3]; - void init(Value *C, Value *S1, Value *S2) { - Ops[0].init(C, this); - Ops[1].init(S1, this); - Ops[2].init(S2, this); + Op<0>() = C; + Op<1>() = S1; + Op<2>() = S2; } SelectInst(const SelectInst &SI) - : Instruction(SI.getType(), SI.getOpcode(), Ops, 3) { - init(SI.Ops[0], SI.Ops[1], SI.Ops[2]); + : Instruction(SI.getType(), SI.getOpcode(), &Op<0>(), 3) { + init(SI.Op<0>(), SI.Op<1>(), SI.Op<2>()); } SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name = "", Instruction *InsertBefore = 0) - : Instruction(S1->getType(), Instruction::Select, Ops, 3, InsertBefore) { + : Instruction(S1->getType(), Instruction::Select, &Op<0>(), 3, InsertBefore) { init(C, S1, S2); setName(Name); } SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(S1->getType(), Instruction::Select, Ops, 3, InsertAtEnd) { + : Instruction(S1->getType(), Instruction::Select, &Op<0>(), 3, InsertAtEnd) { init(C, S1, S2); setName(Name); } @@ -1087,18 +1084,18 @@ return new(3) SelectInst(C, S1, S2, Name, InsertAtEnd); } - Value *getCondition() const { return Ops[0]; } - Value *getTrueValue() const { return Ops[1]; } - Value *getFalseValue() const { return Ops[2]; } + Value *getCondition() const { return Op<0>(); } + Value *getTrueValue() const { return Op<1>(); } + Value *getFalseValue() const { return Op<2>(); } /// Transparently provide more efficient getOperand methods. Value *getOperand(unsigned i) const { assert(i < 3 && "getOperand() out of range!"); - return Ops[i]; + return OperandList[i]; } void setOperand(unsigned i, Value *Val) { assert(i < 3 && "setOperand() out of range!"); - Ops[i] = Val; + OperandList[i] = Val; } unsigned getNumOperands() const { return 3; } @@ -1160,11 +1157,10 @@ /// element from a VectorType value /// class ExtractElementInst : public Instruction { - Use Ops[2]; ExtractElementInst(const ExtractElementInst &EE) : - Instruction(EE.getType(), ExtractElement, Ops, 2) { - Ops[0].init(EE.Ops[0], this); - Ops[1].init(EE.Ops[1], this); + Instruction(EE.getType(), ExtractElement, &Op<0>(), 2) { + Op<0>().init(EE.Op<0>(), this); + Op<1>().init(EE.Op<1>(), this); } public: @@ -1190,11 +1186,11 @@ /// Transparently provide more efficient getOperand methods. Value *getOperand(unsigned i) const { assert(i < 2 && "getOperand() out of range!"); - return Ops[i]; + return OperandList[i]; } void setOperand(unsigned i, Value *Val) { assert(i < 2 && "setOperand() out of range!"); - Ops[i] = Val; + OperandList[i] = Val; } unsigned getNumOperands() const { return 2; } @@ -1216,7 +1212,6 @@ /// element into a VectorType value /// class InsertElementInst : public Instruction { - Use Ops[3]; InsertElementInst(const InsertElementInst &IE); InsertElementInst(Value *Vec, Value *NewElt, Value *Idx, const std::string &Name = "",Instruction *InsertBefore = 0); @@ -1263,11 +1258,11 @@ /// Transparently provide more efficient getOperand methods. Value *getOperand(unsigned i) const { assert(i < 3 && "getOperand() out of range!"); - return Ops[i]; + return OperandList[i]; } void setOperand(unsigned i, Value *Val) { assert(i < 3 && "setOperand() out of range!"); - Ops[i] = Val; + OperandList[i] = Val; } unsigned getNumOperands() const { return 3; } @@ -1289,7 +1284,6 @@ /// input vectors. /// class ShuffleVectorInst : public Instruction { - Use Ops[3]; ShuffleVectorInst(const ShuffleVectorInst &IE); public: // allocate space for exactly three operands @@ -1317,15 +1311,15 @@ /// Transparently provide more efficient getOperand methods. const Value *getOperand(unsigned i) const { assert(i < 3 && "getOperand() out of range!"); - return Ops[i]; + return OperandList[i]; } Value *getOperand(unsigned i) { assert(i < 3 && "getOperand() out of range!"); - return Ops[i]; + return OperandList[i]; } void setOperand(unsigned i, Value *Val) { assert(i < 3 && "setOperand() out of range!"); - Ops[i] = Val; + OperandList[i] = Val; } unsigned getNumOperands() const { return 3; } @@ -1497,7 +1491,6 @@ /// does not continue in this function any longer. /// class ReturnInst : public TerminatorInst { - Use RetVal; ReturnInst(const ReturnInst &RI); void init(Value * const* retVals, unsigned N); @@ -1549,7 +1542,7 @@ if (getNumOperands() > 1) return TerminatorInst::getOperand(n); else - return RetVal; + return Op<0>(); } Value *getReturnValue(unsigned n = 0) const { @@ -1583,7 +1576,6 @@ /// Ops list - Branches are strange. The operands are ordered: /// TrueDest, FalseDest, Cond. This makes some accessors faster because /// they don't have to check for cond/uncond branchness. - Use Ops[3]; BranchInst(const BranchInst &BI); void AssertOK(); // BranchInst constructors (where {B, T, F} are blocks, and C is a condition): @@ -1618,11 +1610,11 @@ /// Transparently provide more efficient getOperand methods. Value *getOperand(unsigned i) const { assert(i < getNumOperands() && "getOperand() out of range!"); - return Ops[i]; + return OperandList[i]; } void setOperand(unsigned i, Value *Val) { assert(i < getNumOperands() && "setOperand() out of range!"); - Ops[i] = Val; + OperandList[i] = Val; } virtual BranchInst *clone() const; @@ -1646,8 +1638,8 @@ void setUnconditionalDest(BasicBlock *Dest) { if (isConditional()) { // Convert this to an uncond branch. NumOperands = 1; - Ops[1].set(0); - Ops[2].set(0); + Op<1>().set(0); + Op<2>().set(0); } setOperand(0, reinterpret_cast(Dest)); } @@ -2552,11 +2544,10 @@ /// class GetResultInst : public /*FIXME: Unary*/Instruction { void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - Use Aggr; unsigned Idx; GetResultInst(const GetResultInst &GRI) : - Instruction(GRI.getType(), Instruction::GetResult, &Aggr, 1) { - Aggr.init(GRI.Aggr, this); + Instruction(GRI.getType(), Instruction::GetResult, &Op<0>(), 1) { + Op<0>().init(GRI.Op<0>(), this); Idx = GRI.Idx; } Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Use.h?rev=49425&r1=49424&r2=49425&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Use.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Use.h Wed Apr 9 09:39:56 2008 @@ -35,15 +35,19 @@ public: inline void init(Value *V, User *U); - Use(Value *V, User *U) { init(V, U); } +/* Use(Value *V, User *U) { init(V, U); } Use(const Use &U) { init(U.get(), U.U); } +*/ inline ~Use() { if (get()) removeFromList(); } /// Default ctor - This leaves the Use completely uninitialized. The only thing /// that is valid to do with this use is to call the "init" method. + +private: inline Use() {} +public: operator Value*() const { return stripTag(Val); } @@ -68,9 +72,9 @@ Use *getNext() const { return Next; } private: + User *U; Use *Next, **Prev; Value *Val; - User *U; static Value *stripTag(Value *V) { return reinterpret_cast(reinterpret_cast(V) & ~3UL); Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49425&r1=49424&r2=49425&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/User.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/User.h Wed Apr 9 09:39:56 2008 @@ -208,11 +208,14 @@ void *Storage = ::operator new(s + sizeof(Use) * Us); Use *Start = static_cast(Storage); Use *End = Start + Us; + User *Obj = reinterpret_cast(End); + Obj->OperandList = Start; + Obj->NumOperands = Us; Use::initTags(Start, End); - return End; + return Obj; } User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps) - : Value(Ty, vty), OperandList(OpList), NumOperands(NumOps) {} + : Value(Ty, vty)/*, OperandList(OpList), NumOperands(NumOps)*/ {} public: void operator delete(void *Usr) { User *Start = static_cast(Usr); @@ -222,6 +225,10 @@ else ::operator delete(Usr); } public: + template Use &Op(); + template const Use &Op() const; + Use *allocHangoffUses(unsigned) const; + Value *getOperand(unsigned i) const { assert(i < NumOperands && "getOperand() out of range!"); return OperandList[i]; Modified: llvm/branches/ggreif/use-diet/lib/VMCore/BasicBlock.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/BasicBlock.cpp?rev=49425&r1=49424&r2=49425&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/BasicBlock.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/BasicBlock.cpp Wed Apr 9 09:39:56 2008 @@ -75,7 +75,7 @@ BasicBlock::BasicBlock(const std::string &Name, Function *NewParent, BasicBlock *InsertBefore, BasicBlock *Dest) - : User(Type::LabelTy, Value::BasicBlockVal, &unwindDest, 0/*FIXME*/), Parent(0) { + : User(Type::LabelTy, Value::BasicBlockVal, &Op<0>()/*unwindDest*/, 0/*FIXME*/), Parent(0) { // Make sure that we get added to a function LeakDetector::addGarbageObject(this); @@ -89,8 +89,9 @@ } setName(Name); - unwindDest.init(NULL, this); - setUnwindDest(Dest); + // Op<0>()./*unwindDest.*/init(NULL, this); /*FIXME*/ + if (Dest) + setUnwindDest(Dest); } @@ -120,16 +121,17 @@ } const BasicBlock *BasicBlock::getUnwindDest() const { - return cast_or_null(unwindDest.get()); + return cast_or_null(Op<0>().get()); } BasicBlock *BasicBlock::getUnwindDest() { - return cast_or_null(unwindDest.get()); + return cast_or_null(Op<0>().get()); } void BasicBlock::setUnwindDest(BasicBlock *dest) { - NumOperands = unwindDest ? 1 : 0; - unwindDest.set(dest); +// NumOperands = unwindDest ? 1 : 0; + if (dest) // FIXME + Op<0>().set(dest); } /// moveBefore - Unlink this basic block from its current function and Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp?rev=49425&r1=49424&r2=49425&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp Wed Apr 9 09:39:56 2008 @@ -341,7 +341,7 @@ ConstantArray::ConstantArray(const ArrayType *T, const std::vector &V) - : Constant(T, ConstantArrayVal, new Use[V.size()], V.size()) { + : Constant(T, ConstantArrayVal, allocHangoffUses(V.size()), V.size()) { assert(V.size() == T->getNumElements() && "Invalid initializer vector for constant array"); Use *OL = OperandList; @@ -357,12 +357,12 @@ } ConstantArray::~ConstantArray() { - delete [] OperandList; +// delete [] OperandList; } ConstantStruct::ConstantStruct(const StructType *T, const std::vector &V) - : Constant(T, ConstantStructVal, new Use[V.size()], V.size()) { + : Constant(T, ConstantStructVal, allocHangoffUses(V.size()), V.size()) { assert(V.size() == T->getNumElements() && "Invalid initializer vector for constant structure"); Use *OL = OperandList; @@ -386,7 +386,7 @@ ConstantVector::ConstantVector(const VectorType *T, const std::vector &V) - : Constant(T, ConstantVectorVal, new Use[V.size()], V.size()) { + : Constant(T, ConstantVectorVal, allocHangoffUses(V.size()), V.size()) { Use *OL = OperandList; for (std::vector::const_iterator I = V.begin(), E = V.end(); I != E; ++I, ++OL) { @@ -400,7 +400,7 @@ } ConstantVector::~ConstantVector() { - delete [] OperandList; +// delete [] OperandList; } // We declare several classes private to this file, so use an anonymous @@ -411,30 +411,30 @@ /// behind the scenes to implement unary constant exprs. class VISIBILITY_HIDDEN UnaryConstantExpr : public ConstantExpr { void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - Use Op; public: // allocate space for exactly one operand void *operator new(size_t s) { return User::operator new(s, 1); } UnaryConstantExpr(unsigned Opcode, Constant *C, const Type *Ty) - : ConstantExpr(Ty, Opcode, &Op, 1), Op(C, this) {} + : ConstantExpr(Ty, Opcode, &Op<0>(), 1) { + Op<0>() = C; + } }; /// BinaryConstantExpr - This class is private to Constants.cpp, and is used /// behind the scenes to implement binary constant exprs. class VISIBILITY_HIDDEN BinaryConstantExpr : public ConstantExpr { void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - Use Ops[2]; public: // allocate space for exactly two operands void *operator new(size_t s) { return User::operator new(s, 2); } BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2) - : ConstantExpr(C1->getType(), Opcode, Ops, 2) { - Ops[0].init(C1, this); - Ops[1].init(C2, this); + : ConstantExpr(C1->getType(), Opcode, &Op<0>(), 2) { + Op<0>().init(C1, this); + Op<1>().init(C2, this); } }; @@ -442,17 +442,16 @@ /// behind the scenes to implement select constant exprs. class VISIBILITY_HIDDEN SelectConstantExpr : public ConstantExpr { void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - Use Ops[3]; public: // allocate space for exactly three operands void *operator new(size_t s) { return User::operator new(s, 3); } SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3) - : ConstantExpr(C2->getType(), Instruction::Select, Ops, 3) { - Ops[0].init(C1, this); - Ops[1].init(C2, this); - Ops[2].init(C3, this); + : ConstantExpr(C2->getType(), Instruction::Select, &Op<0>(), 3) { + Op<0>().init(C1, this); + Op<1>().init(C2, this); + Op<2>().init(C3, this); } }; @@ -461,7 +460,6 @@ /// extractelement constant exprs. class VISIBILITY_HIDDEN ExtractElementConstantExpr : public ConstantExpr { void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - Use Ops[2]; public: // allocate space for exactly two operands void *operator new(size_t s) { @@ -469,9 +467,9 @@ } ExtractElementConstantExpr(Constant *C1, Constant *C2) : ConstantExpr(cast(C1->getType())->getElementType(), - Instruction::ExtractElement, Ops, 2) { - Ops[0].init(C1, this); - Ops[1].init(C2, this); + Instruction::ExtractElement, &Op<0>(), 2) { + Op<0>().init(C1, this); + Op<1>().init(C2, this); } }; @@ -480,7 +478,6 @@ /// insertelement constant exprs. class VISIBILITY_HIDDEN InsertElementConstantExpr : public ConstantExpr { void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - Use Ops[3]; public: // allocate space for exactly three operands void *operator new(size_t s) { @@ -488,10 +485,10 @@ } InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3) : ConstantExpr(C1->getType(), Instruction::InsertElement, - Ops, 3) { - Ops[0].init(C1, this); - Ops[1].init(C2, this); - Ops[2].init(C3, this); + &Op<0>(), 3) { + Op<0>().init(C1, this); + Op<1>().init(C2, this); + Op<2>().init(C3, this); } }; @@ -500,7 +497,6 @@ /// shufflevector constant exprs. class VISIBILITY_HIDDEN ShuffleVectorConstantExpr : public ConstantExpr { void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - Use Ops[3]; public: // allocate space for exactly three operands void *operator new(size_t s) { @@ -508,10 +504,10 @@ } ShuffleVectorConstantExpr(Constant *C1, Constant *C2, Constant *C3) : ConstantExpr(C1->getType(), Instruction::ShuffleVector, - Ops, 3) { - Ops[0].init(C1, this); - Ops[1].init(C2, this); - Ops[2].init(C3, this); + &Op<0>(), 3) { + Op<0>().init(C1, this); + Op<1>().init(C2, this); + Op<2>().init(C3, this); } }; @@ -521,7 +517,7 @@ GetElementPtrConstantExpr(Constant *C, const std::vector &IdxList, const Type *DestTy) : ConstantExpr(DestTy, Instruction::GetElementPtr, - new Use[IdxList.size()+1], IdxList.size()+1) { + allocHangoffUses(IdxList.size()+1), IdxList.size()+1) { OperandList[0].init(C, this); for (unsigned i = 0, E = IdxList.size(); i != E; ++i) OperandList[i+1].init(IdxList[i], this); @@ -546,10 +542,9 @@ return User::operator new(s, 2); } unsigned short predicate; - Use Ops[2]; CompareConstantExpr(Instruction::OtherOps opc, unsigned short pred, Constant* LHS, Constant* RHS) - : ConstantExpr(Type::Int1Ty, opc, Ops, 2), predicate(pred) { + : ConstantExpr(Type::Int1Ty, opc, &Op<0>(), 2), predicate(pred) { OperandList[0].init(LHS, this); OperandList[1].init(RHS, this); } Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Globals.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Globals.cpp?rev=49425&r1=49424&r2=49425&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Globals.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Globals.cpp Wed Apr 9 09:39:56 2008 @@ -89,14 +89,14 @@ Module *ParentModule, bool ThreadLocal, unsigned AddressSpace) : GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalVariableVal, - &Initializer, InitVal != 0, Link, Name), + &Op<0>(), InitVal != 0, Link, Name), isConstantGlobal(constant), isThreadLocalSymbol(ThreadLocal) { if (InitVal) { assert(InitVal->getType() == Ty && "Initializer should be the same type as the GlobalVariable!"); - Initializer.init(InitVal, this); + Op<0>().init(InitVal, this); } else { - Initializer.init(0, this); + Op<0>().init(0, this); // FIXME: if no InitVal, then none! } LeakDetector::addGarbageObject(this); @@ -110,14 +110,14 @@ GlobalVariable *Before, bool ThreadLocal, unsigned AddressSpace) : GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalVariableVal, - &Initializer, InitVal != 0, Link, Name), + &Op<0>(), InitVal != 0, Link, Name), isConstantGlobal(constant), isThreadLocalSymbol(ThreadLocal) { if (InitVal) { assert(InitVal->getType() == Ty && "Initializer should be the same type as the GlobalVariable!"); - Initializer.init(InitVal, this); + Op<0>().init(InitVal, this); } else { - Initializer.init(0, this); + Op<0>().init(0, this); // FIXME: if no InitVal, then none! } LeakDetector::addGarbageObject(this); @@ -169,12 +169,12 @@ GlobalAlias::GlobalAlias(const Type *Ty, LinkageTypes Link, const std::string &Name, Constant* aliasee, Module *ParentModule) - : GlobalValue(Ty, Value::GlobalAliasVal, &Aliasee, 1, Link, Name) { + : GlobalValue(Ty, Value::GlobalAliasVal, &Op<0>(), 1, Link, Name) { LeakDetector::addGarbageObject(this); if (aliasee) assert(aliasee->getType() == Ty && "Alias and aliasee types should match!"); - Aliasee.init(aliasee, this); + Op<0>().init(aliasee, this); if (ParentModule) ParentModule->getAliasList().push_back(this); Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp?rev=49425&r1=49424&r2=49425&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Wed Apr 9 09:39:56 2008 @@ -111,7 +111,7 @@ PHINode::PHINode(const PHINode &PN) : Instruction(PN.getType(), Instruction::PHI, - new Use[PN.getNumOperands()], PN.getNumOperands()), + allocHangoffUses(PN.getNumOperands()), PN.getNumOperands()), ReservedSpace(PN.getNumOperands()) { Use *OL = OperandList; for (unsigned i = 0, e = PN.getNumOperands(); i != e; i+=2) { @@ -121,7 +121,7 @@ } PHINode::~PHINode() { - delete [] OperandList; +// delete [] OperandList; } // removeIncomingValue - Remove an incoming value. This is useful if a @@ -177,13 +177,13 @@ } ReservedSpace = NumOps; - Use *NewOps = new Use[NumOps]; Use *OldOps = OperandList; + Use *NewOps = allocHangoffUses(NumOps); for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { NewOps[i].init(OldOps[i], this); OldOps[i].set(0); } - delete [] OldOps; +// delete [] OldOps; OperandList = NewOps; } @@ -241,12 +241,12 @@ //===----------------------------------------------------------------------===// CallInst::~CallInst() { - delete [] OperandList; +// delete [] OperandList; } void CallInst::init(Value *Func, Value* const *Params, unsigned NumParams) { NumOperands = NumParams+1; - Use *OL = OperandList = new Use[NumParams+1]; + Use *OL = OperandList = allocHangoffUses(NumParams+1); OL[0].init(Func, this); const FunctionType *FTy = @@ -266,7 +266,7 @@ void CallInst::init(Value *Func, Value *Actual1, Value *Actual2) { NumOperands = 3; - Use *OL = OperandList = new Use[3]; + Use *OL = OperandList = allocHangoffUses(3); OL[0].init(Func, this); OL[1].init(Actual1, this); OL[2].init(Actual2, this); @@ -288,7 +288,7 @@ void CallInst::init(Value *Func, Value *Actual) { NumOperands = 2; - Use *OL = OperandList = new Use[2]; + Use *OL = OperandList = allocHangoffUses(2); OL[0].init(Func, this); OL[1].init(Actual, this); @@ -306,7 +306,7 @@ void CallInst::init(Value *Func) { NumOperands = 1; - Use *OL = OperandList = new Use[1]; + Use *OL = OperandList = allocHangoffUses(1); OL[0].init(Func, this); const FunctionType *FTy = @@ -352,7 +352,7 @@ } CallInst::CallInst(const CallInst &CI) - : Instruction(CI.getType(), Instruction::Call, new Use[CI.getNumOperands()], + : Instruction(CI.getType(), Instruction::Call, allocHangoffUses(CI.getNumOperands()), CI.getNumOperands()) { setParamAttrs(CI.getParamAttrs()); SubclassData = CI.SubclassData; @@ -385,13 +385,13 @@ //===----------------------------------------------------------------------===// InvokeInst::~InvokeInst() { - delete [] OperandList; +// delete [] OperandList; } void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException, Value* const *Args, unsigned NumArgs) { NumOperands = 3+NumArgs; - Use *OL = OperandList = new Use[3+NumArgs]; + Use *OL = OperandList = allocHangoffUses(3+NumArgs); OL[0].init(Fn, this); OL[1].init(IfNormal, this); OL[2].init(IfException, this); @@ -414,7 +414,7 @@ InvokeInst::InvokeInst(const InvokeInst &II) : TerminatorInst(II.getType(), Instruction::Invoke, - new Use[II.getNumOperands()], II.getNumOperands()) { + allocHangoffUses(II.getNumOperands()), II.getNumOperands()) { setParamAttrs(II.getParamAttrs()); SubclassData = II.SubclassData; Use *OL = OperandList, *InOL = II.OperandList; @@ -456,45 +456,45 @@ ReturnInst::ReturnInst(const ReturnInst &RI) : TerminatorInst(Type::VoidTy, Instruction::Ret, - &RetVal, RI.getNumOperands()) { + /*&RetVal*/NULL, RI.getNumOperands()) { unsigned N = RI.getNumOperands(); if (N == 1) - RetVal.init(RI.RetVal, this); + Op<0>().init(RI.Op<0>(), this); else if (N) { - Use *OL = OperandList = new Use[N]; + Use *OL = OperandList = allocHangoffUses(N); for (unsigned i = 0; i < N; ++i) OL[i].init(RI.getOperand(i), this); } } ReturnInst::ReturnInst(Value *retVal, Instruction *InsertBefore) - : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertBefore) { + : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, 0, InsertBefore) { if (retVal) init(&retVal, 1); } ReturnInst::ReturnInst(Value *retVal, BasicBlock *InsertAtEnd) - : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertAtEnd) { + : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, 0, InsertAtEnd) { if (retVal) init(&retVal, 1); } ReturnInst::ReturnInst(BasicBlock *InsertAtEnd) - : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertAtEnd) { + : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, 0, InsertAtEnd) { } ReturnInst::ReturnInst(Value * const* retVals, unsigned N, Instruction *InsertBefore) - : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, N, InsertBefore) { + : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, N, InsertBefore) { if (N != 0) init(retVals, N); } ReturnInst::ReturnInst(Value * const* retVals, unsigned N, BasicBlock *InsertAtEnd) - : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, N, InsertAtEnd) { + : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, N, InsertAtEnd) { if (N != 0) init(retVals, N); } ReturnInst::ReturnInst(Value * const* retVals, unsigned N) - : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, N) { + : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, N) { if (N != 0) init(retVals, N); } @@ -507,11 +507,10 @@ Value *V = *retVals; if (V->getType() == Type::VoidTy) return; - RetVal.init(V, this); - return; + Op<0>().init(V, this); } - Use *OL = OperandList = new Use[NumOperands]; + Use *OL = OperandList = allocHangoffUses(NumOperands); for (unsigned i = 0; i < NumOperands; ++i) { Value *V = *retVals++; assert(!isa(V) && @@ -537,8 +536,8 @@ } ReturnInst::~ReturnInst() { - if (NumOperands > 1) - delete [] OperandList; +// if (NumOperands > 1) +// delete [] OperandList; } //===----------------------------------------------------------------------===// @@ -603,33 +602,33 @@ } BranchInst::BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore) - : TerminatorInst(Type::VoidTy, Instruction::Br, Ops, 1, InsertBefore) { + : TerminatorInst(Type::VoidTy, Instruction::Br, /*Ops*/NULL, 1, InsertBefore) { assert(IfTrue != 0 && "Branch destination may not be null!"); - Ops[0].init(reinterpret_cast(IfTrue), this); + Op<0>().init(reinterpret_cast(IfTrue), this); } BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, Instruction *InsertBefore) -: TerminatorInst(Type::VoidTy, Instruction::Br, Ops, 3, InsertBefore) { - Ops[0].init(reinterpret_cast(IfTrue), this); - Ops[1].init(reinterpret_cast(IfFalse), this); - Ops[2].init(Cond, this); +: TerminatorInst(Type::VoidTy, Instruction::Br, /*Ops*/NULL, 3, InsertBefore) { + Op<0>().init(reinterpret_cast(IfTrue), this); + Op<1>().init(reinterpret_cast(IfFalse), this); + Op<2>().init(Cond, this); #ifndef NDEBUG AssertOK(); #endif } BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd) - : TerminatorInst(Type::VoidTy, Instruction::Br, Ops, 1, InsertAtEnd) { + : TerminatorInst(Type::VoidTy, Instruction::Br, /*Ops*/NULL, 1, InsertAtEnd) { assert(IfTrue != 0 && "Branch destination may not be null!"); - Ops[0].init(reinterpret_cast(IfTrue), this); + Op<0>().init(reinterpret_cast(IfTrue), this); } BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, BasicBlock *InsertAtEnd) - : TerminatorInst(Type::VoidTy, Instruction::Br, Ops, 3, InsertAtEnd) { - Ops[0].init(reinterpret_cast(IfTrue), this); - Ops[1].init(reinterpret_cast(IfFalse), this); - Ops[2].init(Cond, this); + : TerminatorInst(Type::VoidTy, Instruction::Br, /*Ops*/NULL, 3, InsertAtEnd) { + Op<0>().init(reinterpret_cast(IfTrue), this); + Op<1>().init(reinterpret_cast(IfFalse), this); + Op<2>().init(Cond, this); #ifndef NDEBUG AssertOK(); #endif @@ -637,7 +636,7 @@ BranchInst::BranchInst(const BranchInst &BI) : - TerminatorInst(Type::VoidTy, Instruction::Br, Ops, BI.getNumOperands()) { + TerminatorInst(Type::VoidTy, Instruction::Br, /*Ops*/NULL, BI.getNumOperands()) { OperandList[0].init(BI.getOperand(0), this); if (BI.getNumOperands() != 1) { assert(BI.getNumOperands() == 3 && "BR can have 1 or 3 operands!"); @@ -869,18 +868,18 @@ StoreInst::StoreInst(Value *val, Value *addr, Instruction *InsertBefore) - : Instruction(Type::VoidTy, Store, Ops, 2, InsertBefore) { - Ops[0].init(val, this); - Ops[1].init(addr, this); + : Instruction(Type::VoidTy, Store, /*Ops*/NULL, 2, InsertBefore) { + Op<0>().init(val, this); + Op<1>().init(addr, this); setVolatile(false); setAlignment(0); AssertOK(); } StoreInst::StoreInst(Value *val, Value *addr, BasicBlock *InsertAtEnd) - : Instruction(Type::VoidTy, Store, Ops, 2, InsertAtEnd) { - Ops[0].init(val, this); - Ops[1].init(addr, this); + : Instruction(Type::VoidTy, Store, /*Ops*/NULL, 2, InsertAtEnd) { + Op<0>().init(val, this); + Op<1>().init(addr, this); setVolatile(false); setAlignment(0); AssertOK(); @@ -888,9 +887,9 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, Instruction *InsertBefore) - : Instruction(Type::VoidTy, Store, Ops, 2, InsertBefore) { - Ops[0].init(val, this); - Ops[1].init(addr, this); + : Instruction(Type::VoidTy, Store, /*Ops*/NULL, 2, InsertBefore) { + Op<0>().init(val, this); + Op<1>().init(addr, this); setVolatile(isVolatile); setAlignment(0); AssertOK(); @@ -898,9 +897,9 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, unsigned Align, Instruction *InsertBefore) - : Instruction(Type::VoidTy, Store, Ops, 2, InsertBefore) { - Ops[0].init(val, this); - Ops[1].init(addr, this); + : Instruction(Type::VoidTy, Store, /*Ops*/NULL, 2, InsertBefore) { + Op<0>().init(val, this); + Op<1>().init(addr, this); setVolatile(isVolatile); setAlignment(Align); AssertOK(); @@ -908,9 +907,9 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, unsigned Align, BasicBlock *InsertAtEnd) - : Instruction(Type::VoidTy, Store, Ops, 2, InsertAtEnd) { - Ops[0].init(val, this); - Ops[1].init(addr, this); + : Instruction(Type::VoidTy, Store, /*Ops*/NULL, 2, InsertAtEnd) { + Op<0>().init(val, this); + Op<1>().init(addr, this); setVolatile(isVolatile); setAlignment(Align); AssertOK(); @@ -918,9 +917,9 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, BasicBlock *InsertAtEnd) - : Instruction(Type::VoidTy, Store, Ops, 2, InsertAtEnd) { - Ops[0].init(val, this); - Ops[1].init(addr, this); + : Instruction(Type::VoidTy, Store, /*Ops*/NULL, 2, InsertAtEnd) { + Op<0>().init(val, this); + Op<1>().init(addr, this); setVolatile(isVolatile); setAlignment(0); AssertOK(); @@ -941,7 +940,7 @@ void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx) { NumOperands = 1+NumIdx; - Use *OL = OperandList = new Use[NumOperands]; + Use *OL = OperandList = allocHangoffUses(NumOperands); OL[0].init(Ptr, this); for (unsigned i = 0; i != NumIdx; ++i) @@ -950,7 +949,7 @@ void GetElementPtrInst::init(Value *Ptr, Value *Idx) { NumOperands = 2; - Use *OL = OperandList = new Use[2]; + Use *OL = OperandList = allocHangoffUses(2); OL[0].init(Ptr, this); OL[1].init(Idx, this); } @@ -1067,11 +1066,11 @@ const std::string &Name, Instruction *InsertBef) : Instruction(cast(Val->getType())->getElementType(), - ExtractElement, Ops, 2, InsertBef) { + ExtractElement, /*Ops*/NULL, 2, InsertBef) { assert(isValidOperands(Val, Index) && "Invalid extractelement instruction operands!"); - Ops[0].init(Val, this); - Ops[1].init(Index, this); + Op<0>().init(Val, this); + Op<1>().init(Index, this); setName(Name); } @@ -1079,12 +1078,12 @@ const std::string &Name, Instruction *InsertBef) : Instruction(cast(Val->getType())->getElementType(), - ExtractElement, Ops, 2, InsertBef) { + ExtractElement, /*Ops*/NULL, 2, InsertBef) { Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV); assert(isValidOperands(Val, Index) && "Invalid extractelement instruction operands!"); - Ops[0].init(Val, this); - Ops[1].init(Index, this); + Op<0>().init(Val, this); + Op<1>().init(Index, this); setName(Name); } @@ -1093,12 +1092,12 @@ const std::string &Name, BasicBlock *InsertAE) : Instruction(cast(Val->getType())->getElementType(), - ExtractElement, Ops, 2, InsertAE) { + ExtractElement, /*Ops*/NULL, 2, InsertAE) { assert(isValidOperands(Val, Index) && "Invalid extractelement instruction operands!"); - Ops[0].init(Val, this); - Ops[1].init(Index, this); + Op<0>().init(Val, this); + Op<1>().init(Index, this); setName(Name); } @@ -1106,13 +1105,13 @@ const std::string &Name, BasicBlock *InsertAE) : Instruction(cast(Val->getType())->getElementType(), - ExtractElement, Ops, 2, InsertAE) { + ExtractElement, /*Ops*/NULL, 2, InsertAE) { Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV); assert(isValidOperands(Val, Index) && "Invalid extractelement instruction operands!"); - Ops[0].init(Val, this); - Ops[1].init(Index, this); + Op<0>().init(Val, this); + Op<1>().init(Index, this); setName(Name); } @@ -1129,33 +1128,33 @@ //===----------------------------------------------------------------------===// InsertElementInst::InsertElementInst(const InsertElementInst &IE) - : Instruction(IE.getType(), InsertElement, Ops, 3) { - Ops[0].init(IE.Ops[0], this); - Ops[1].init(IE.Ops[1], this); - Ops[2].init(IE.Ops[2], this); + : Instruction(IE.getType(), InsertElement, /*Ops*/NULL, 3) { + Op<0>().init(IE.Op<0>(), this); + Op<1>().init(IE.Op<1>(), this); + Op<2>().init(IE.Op<2>(), this); } InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index, const std::string &Name, Instruction *InsertBef) - : Instruction(Vec->getType(), InsertElement, Ops, 3, InsertBef) { + : Instruction(Vec->getType(), InsertElement, /*Ops*/NULL, 3, InsertBef) { assert(isValidOperands(Vec, Elt, Index) && "Invalid insertelement instruction operands!"); - Ops[0].init(Vec, this); - Ops[1].init(Elt, this); - Ops[2].init(Index, this); + Op<0>().init(Vec, this); + Op<1>().init(Elt, this); + Op<2>().init(Index, this); setName(Name); } InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV, const std::string &Name, Instruction *InsertBef) - : Instruction(Vec->getType(), InsertElement, Ops, 3, InsertBef) { + : Instruction(Vec->getType(), InsertElement, /*Ops*/NULL, 3, InsertBef) { Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV); assert(isValidOperands(Vec, Elt, Index) && "Invalid insertelement instruction operands!"); - Ops[0].init(Vec, this); - Ops[1].init(Elt, this); - Ops[2].init(Index, this); + Op<0>().init(Vec, this); + Op<1>().init(Elt, this); + Op<2>().init(Index, this); setName(Name); } @@ -1163,27 +1162,27 @@ InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index, const std::string &Name, BasicBlock *InsertAE) - : Instruction(Vec->getType(), InsertElement, Ops, 3, InsertAE) { + : Instruction(Vec->getType(), InsertElement, /*Ops*/NULL, 3, InsertAE) { assert(isValidOperands(Vec, Elt, Index) && "Invalid insertelement instruction operands!"); - Ops[0].init(Vec, this); - Ops[1].init(Elt, this); - Ops[2].init(Index, this); + Op<0>().init(Vec, this); + Op<1>().init(Elt, this); + Op<2>().init(Index, this); setName(Name); } InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV, const std::string &Name, BasicBlock *InsertAE) -: Instruction(Vec->getType(), InsertElement, Ops, 3, InsertAE) { +: Instruction(Vec->getType(), InsertElement, /*Ops*/NULL, 3, InsertAE) { Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV); assert(isValidOperands(Vec, Elt, Index) && "Invalid insertelement instruction operands!"); - Ops[0].init(Vec, this); - Ops[1].init(Elt, this); - Ops[2].init(Index, this); + Op<0>().init(Vec, this); + Op<1>().init(Elt, this); + Op<2>().init(Index, this); setName(Name); } @@ -1206,34 +1205,34 @@ //===----------------------------------------------------------------------===// ShuffleVectorInst::ShuffleVectorInst(const ShuffleVectorInst &SV) - : Instruction(SV.getType(), ShuffleVector, Ops, 3) { - Ops[0].init(SV.Ops[0], this); - Ops[1].init(SV.Ops[1], this); - Ops[2].init(SV.Ops[2], this); + : Instruction(SV.getType(), ShuffleVector, /*Ops*/NULL, 3) { + Op<0>().init(SV.Op<0>(), this); + Op<1>().init(SV.Op<1>(), this); + Op<2>().init(SV.Op<2>(), this); } ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask, const std::string &Name, Instruction *InsertBefore) - : Instruction(V1->getType(), ShuffleVector, Ops, 3, InsertBefore) { + : Instruction(V1->getType(), ShuffleVector, /*Ops*/NULL, 3, InsertBefore) { assert(isValidOperands(V1, V2, Mask) && "Invalid shuffle vector instruction operands!"); - Ops[0].init(V1, this); - Ops[1].init(V2, this); - Ops[2].init(Mask, this); + Op<0>().init(V1, this); + Op<1>().init(V2, this); + Op<2>().init(Mask, this); setName(Name); } ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(V1->getType(), ShuffleVector, Ops, 3, InsertAtEnd) { + : Instruction(V1->getType(), ShuffleVector, /*Ops*/NULL, 3, InsertAtEnd) { assert(isValidOperands(V1, V2, Mask) && "Invalid shuffle vector instruction operands!"); - Ops[0].init(V1, this); - Ops[1].init(V2, this); - Ops[2].init(Mask, this); + Op<0>().init(V1, this); + Op<1>().init(V2, this); + Op<2>().init(Mask, this); setName(Name); } @@ -1275,9 +1274,9 @@ BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty, const std::string &Name, Instruction *InsertBefore) - : Instruction(Ty, iType, Ops, 2, InsertBefore) { - Ops[0].init(S1, this); - Ops[1].init(S2, this); + : Instruction(Ty, iType, /*Ops*/NULL, 2, InsertBefore) { + Op<0>().init(S1, this); + Op<1>().init(S2, this); init(iType); setName(Name); } @@ -1285,9 +1284,9 @@ BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(Ty, iType, Ops, 2, InsertAtEnd) { - Ops[0].init(S1, this); - Ops[1].init(S2, this); + : Instruction(Ty, iType, /*Ops*/NULL, 2, InsertAtEnd) { + Op<0>().init(S1, this); + Op<1>().init(S2, this); init(iType); setName(Name); } @@ -1482,7 +1481,7 @@ bool BinaryOperator::swapOperands() { if (!isCommutative()) return true; // Can't commute operands - std::swap(Ops[0], Ops[1]); + std::swap(Op<0>(), Op<1>()); return false; } @@ -2254,9 +2253,9 @@ CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS, const std::string &Name, Instruction *InsertBefore) - : Instruction(Type::Int1Ty, op, Ops, 2, InsertBefore) { - Ops[0].init(LHS, this); - Ops[1].init(RHS, this); + : Instruction(Type::Int1Ty, op, /*Ops*/NULL, 2, InsertBefore) { + Op<0>().init(LHS, this); + Op<1>().init(RHS, this); SubclassData = predicate; setName(Name); if (op == Instruction::ICmp) { @@ -2286,9 +2285,9 @@ CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(Type::Int1Ty, op, Ops, 2, InsertAtEnd) { - Ops[0].init(LHS, this); - Ops[1].init(RHS, this); + : Instruction(Type::Int1Ty, op, /*Ops*/NULL, 2, InsertAtEnd) { + Op<0>().init(LHS, this); + Op<1>().init(RHS, this); SubclassData = predicate; setName(Name); if (op == Instruction::ICmp) { @@ -2548,7 +2547,7 @@ assert(Value && Default); ReservedSpace = 2+NumCases*2; NumOperands = 2; - OperandList = new Use[ReservedSpace]; + OperandList = allocHangoffUses(ReservedSpace); OperandList[0].init(Value, this); OperandList[1].init(Default, this); @@ -2576,7 +2575,7 @@ SwitchInst::SwitchInst(const SwitchInst &SI) : TerminatorInst(Type::VoidTy, Instruction::Switch, - new Use[SI.getNumOperands()], SI.getNumOperands()) { + allocHangoffUses(SI.getNumOperands()), SI.getNumOperands()) { Use *OL = OperandList, *InOL = SI.OperandList; for (unsigned i = 0, E = SI.getNumOperands(); i != E; i+=2) { OL[i].init(InOL[i], this); @@ -2585,7 +2584,7 @@ } SwitchInst::~SwitchInst() { - delete [] OperandList; +// delete [] OperandList; } @@ -2649,13 +2648,13 @@ } ReservedSpace = NumOps; - Use *NewOps = new Use[NumOps]; + Use *NewOps = allocHangoffUses(NumOps); Use *OldOps = OperandList; for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { NewOps[i].init(OldOps[i], this); OldOps[i].set(0); } - delete [] OldOps; +// delete [] OldOps; OperandList = NewOps; } @@ -2678,9 +2677,9 @@ const std::string &Name, Instruction *InsertBef) : Instruction(cast(Aggregate->getType())->getElementType(Index), - GetResult, &Aggr, 1, InsertBef) { + GetResult, /*&Aggr*/NULL, 1, InsertBef) { assert(isValidOperands(Aggregate, Index) && "Invalid GetResultInst operands!"); - Aggr.init(Aggregate, this); + Op<0>().init(Aggregate, this); Idx = Index; setName(Name); } @@ -2714,14 +2713,14 @@ } BinaryOperator *BinaryOperator::clone() const { - return create(getOpcode(), Ops[0], Ops[1]); + return create(getOpcode(), Op<0>(), Op<1>()); } FCmpInst* FCmpInst::clone() const { - return new FCmpInst(getPredicate(), Ops[0], Ops[1]); + return new FCmpInst(getPredicate(), Op<0>(), Op<1>()); } ICmpInst* ICmpInst::clone() const { - return new ICmpInst(getPredicate(), Ops[0], Ops[1]); + return new ICmpInst(getPredicate(), Op<0>(), Op<1>()); } MallocInst *MallocInst::clone() const { return new MallocInst(*this); } Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp?rev=49425&r1=49424&r2=49425&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Wed Apr 9 09:39:56 2008 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file implements the algoritm for finding the User of a Use. +// This file implements the algorithm for finding the User of a Use. // //===----------------------------------------------------------------------===// From ggreif at gmail.com Wed Apr 9 10:17:50 2008 From: ggreif at gmail.com (Gabor Greif) Date: Wed, 09 Apr 2008 15:17:50 -0000 Subject: [llvm-commits] [llvm] r49426 - in /llvm/branches/ggreif/use-diet/lib/Bitcode/Reader: BitcodeReader.cpp BitcodeReader.h Message-ID: <200804091517.m39FHoWI027071@zion.cs.uiuc.edu> Author: ggreif Date: Wed Apr 9 10:17:50 2008 New Revision: 49426 URL: http://llvm.org/viewvc/llvm-project?rev=49426&view=rev Log: get BitcodeReader compiling by commenting out stuff :-). Next: resolve linker references Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp?rev=49426&r1=49425&r2=49426&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp Wed Apr 9 10:17:50 2008 @@ -122,15 +122,14 @@ class ConstantPlaceHolder : public ConstantExpr { ConstantPlaceHolder(); // DO NOT IMPLEMENT void operator=(const ConstantPlaceHolder &); // DO NOT IMPLEMENT - Use Op; public: // allocate space for exactly one operand void *operator new(size_t s) { return User::operator new(s, 1); } explicit ConstantPlaceHolder(const Type *Ty) - : ConstantExpr(Ty, Instruction::UserOp1, &Op, 1), - Op(UndefValue::get(Type::Int32Ty), this) { + : ConstantExpr(Ty, Instruction::UserOp1, /*&Op*/NULL, 1) { + Op<0>() = UndefValue::get(Type::Int32Ty); } }; } @@ -139,41 +138,41 @@ const Type *Ty) { if (Idx >= size()) { // Insert a bunch of null values. - Uses.resize(Idx+1); - OperandList = &Uses[0]; +// Uses.resize(Idx+1); +// OperandList = &Uses[0]; NumOperands = Idx+1; } - if (Value *V = Uses[Idx]) { - assert(Ty == V->getType() && "Type mismatch in constant table!"); - return cast(V); - } +// if (Value *V = Uses[Idx]) { +// assert(Ty == V->getType() && "Type mismatch in constant table!"); +// return cast(V); +// } // Create and return a placeholder, which will later be RAUW'd. Constant *C = new ConstantPlaceHolder(Ty); - Uses[Idx].init(C, this); +// Uses[Idx].init(C, this); return C; } Value *BitcodeReaderValueList::getValueFwdRef(unsigned Idx, const Type *Ty) { if (Idx >= size()) { // Insert a bunch of null values. - Uses.resize(Idx+1); - OperandList = &Uses[0]; +// Uses.resize(Idx+1); +// OperandList = &Uses[0]; NumOperands = Idx+1; } - if (Value *V = Uses[Idx]) { +/* if (Value *V = Uses[Idx]) { assert((Ty == 0 || Ty == V->getType()) && "Type mismatch in value table!"); return V; - } + }*/ // No type specified, must be invalid reference. if (Ty == 0) return 0; // Create and return a placeholder, which will later be RAUW'd. Value *V = new Argument(Ty); - Uses[Idx].init(V, this); +// Uses[Idx].init(V, this); return V; } Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h?rev=49426&r1=49425&r2=49426&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h (original) +++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h Wed Apr 9 10:17:50 2008 @@ -27,30 +27,29 @@ class MemoryBuffer; class BitcodeReaderValueList : public User { - std::vector Uses; public: BitcodeReaderValueList() : User(Type::VoidTy, Value::ArgumentVal, 0, 0) {} // vector compatibility methods unsigned size() const { return getNumOperands(); } void push_back(Value *V) { - Uses.push_back(Use(V, this)); - OperandList = &Uses[0]; +// Uses.push_back(Use(V, this)); +// OperandList = &Uses[0]; ++NumOperands; } void clear() { - std::vector().swap(Uses); +// std::vector().swap(Uses); } Value *operator[](unsigned i) const { return getOperand(i); } - Value *back() const { return Uses.back(); } - void pop_back() { Uses.pop_back(); --NumOperands; } + Value *back() const { /*return Uses.back();*/ } + void pop_back() { /*Uses.pop_back(); --NumOperands;*/ } bool empty() const { return NumOperands == 0; } void shrinkTo(unsigned N) { assert(N <= NumOperands && "Invalid shrinkTo request!"); - Uses.resize(N); +// Uses.resize(N); NumOperands = N; } virtual void print(std::ostream&) const {} @@ -73,8 +72,8 @@ private: void initVal(unsigned Idx, Value *V) { - assert(Uses[Idx] == 0 && "Cannot init an already init'd Use!"); - Uses[Idx].init(V, this); +// assert(Uses[Idx] == 0 && "Cannot init an already init'd Use!"); +// Uses[Idx].init(V, this); } }; From dpatel at apple.com Wed Apr 9 11:03:33 2008 From: dpatel at apple.com (Devang Patel) Date: Wed, 9 Apr 2008 09:03:33 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r49385 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <200804090947.34146.baldrick@free.fr> References: <200804081646.m38GkGhm007108@zion.cs.uiuc.edu> <200804090947.34146.baldrick@free.fr> Message-ID: <44650634-9CDB-4988-AAAF-19FD4FAD3041@apple.com> On Apr 9, 2008, at 12:47 AM, Duncan Sands wrote: > Hi Devang, > >> + Value *RetVal = DECL_LLVM(DECL_RESULT(FnDecl)); > ... >> + RetVal = BitCastToType(DECL_LLVM(DECL_RESULT(FnDecl)), >> + PointerType::getUnqual(Fn- >> >getReturnType())); > > Since RetVal was set to DECL_LLVM(DECL_RESULT(FnDecl)) above, you > could use it > here on the RHS. Yup. The part of patch is original content, which I did not modify. I'll fix this later if nobody fixes it sooner. Please feel free to fix such small items as you notice because I'm testing much larger patch in my tree and it may take a while. - Devang From dpatel at apple.com Wed Apr 9 11:05:49 2008 From: dpatel at apple.com (Devang Patel) Date: Wed, 9 Apr 2008 09:05:49 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r49390 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <200804090951.23022.baldrick@free.fr> References: <200804081808.m38I8OEF009561@zion.cs.uiuc.edu> <200804090951.23022.baldrick@free.fr> Message-ID: <1B34598C-B705-4177-AFDA-E7C4427D48F5@apple.com> On Apr 9, 2008, at 12:51 AM, Duncan Sands wrote: > Hi Devang, > >> + if (Client.isAggrReturn()) { >> + const StructType *STy = cast(Call->getType()); >> + unsigned NumElements = STy->getNumElements(); >> + for (unsigned i = 0; i < NumElements; i++) { >> + //DPATEL >> + Value *GEP = Builder.CreateStructGEP(DestLoc->Ptr, i, >> "mrv_gep"); > > is it clear that DestLoc->Ptr has the right type here? Yes, there are assertions to check this earlier. > > > Ciao, > > Duncan. - Devang From dpatel at apple.com Wed Apr 9 11:07:49 2008 From: dpatel at apple.com (Devang Patel) Date: Wed, 9 Apr 2008 09:07:49 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r49422 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp In-Reply-To: <200804090939.m399dUtg016956@zion.cs.uiuc.edu> References: <200804090939.m399dUtg016956@zion.cs.uiuc.edu> Message-ID: <8587B44A-52E6-4282-81C4-6045E190C44C@apple.com> Pl. avoid the word "Hack" in the comments. - Devang On Apr 9, 2008, at 2:39 AM, Duncan Sands wrote: > Author: baldrick > Date: Wed Apr 9 04:39:29 2008 > New Revision: 49422 > > URL: http://llvm.org/viewvc/llvm-project?rev=49422&view=rev > Log: > Hack to fix PR1971. > > Modified: > llvm-gcc-4.2/trunk/gcc/llvm-types.cpp > > Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=49422&r1=49421&r2=49422&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) > +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Wed Apr 9 04:39:29 2008 > @@ -1701,7 +1701,8 @@ > // node for it, but not when A is a nonvirtual base class. So we > can't > // use that.) > static void FixBaseClassFields(tree type) { > - assert(TREE_CODE(type)==RECORD_TYPE); > + if (TREE_CODE(type)!=RECORD_TYPE) > + return; > for (tree Field = TYPE_FIELDS(type); Field; Field = > TREE_CHAIN(Field)) { > if (TREE_CODE(Field)==FIELD_DECL && > !DECL_BIT_FIELD_TYPE(Field) && > @@ -1749,7 +1750,8 @@ > // code continues to work (there are pointers stashed away in there). > > static void RestoreBaseClassFields(tree type) { > - assert(TREE_CODE(type)==RECORD_TYPE); > + if (TREE_CODE(type)!=RECORD_TYPE) > + return; > for (tree Field = TYPE_FIELDS(type); Field; Field = > TREE_CHAIN(Field)) { > if (TREE_CODE(Field) == FIELD_DECL && > DECL_FIELD_REPLACED(Field)) { > tree &oldTy = BaseTypesMap[TREE_TYPE(Field)]; > @@ -2174,7 +2176,13 @@ > unsigned MaxSize = 0, MaxAlign = 0; > for (tree Field = TYPE_FIELDS(type); Field; Field = > TREE_CHAIN(Field)) { > if (TREE_CODE(Field) != FIELD_DECL) continue; > - assert(getFieldOffsetInBits(Field) == 0 && "Union with non-zero > offset?"); > +// assert(getFieldOffsetInBits(Field) == 0 && "Union with non- > zero offset?"); > + // Hack to get Fortran EQUIVALENCE working. > + // TODO: Unify record and union logic and handle this optimally. > + if (getFieldOffsetInBits(Field) != 0) { > + ConvertingStruct = OldConvertingStruct; > + return ConvertRECORD(type, orig_type); > + } > > // Set the field idx to zero for all fields. > SetFieldIndex(Field, 0); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From baldrick at free.fr Wed Apr 9 11:17:04 2008 From: baldrick at free.fr (Duncan Sands) Date: Wed, 09 Apr 2008 16:17:04 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49431 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Message-ID: <200804091617.m39GH4BP028872@zion.cs.uiuc.edu> Author: baldrick Date: Wed Apr 9 11:17:04 2008 New Revision: 49431 URL: http://llvm.org/viewvc/llvm-project?rev=49431&view=rev Log: Devang doesn't like the term "hack". Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=49431&r1=49430&r2=49431&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Wed Apr 9 11:17:04 2008 @@ -2177,7 +2177,7 @@ for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) { if (TREE_CODE(Field) != FIELD_DECL) continue; // assert(getFieldOffsetInBits(Field) == 0 && "Union with non-zero offset?"); - // Hack to get Fortran EQUIVALENCE working. + // Workaround to get Fortran EQUIVALENCE working. // TODO: Unify record and union logic and handle this optimally. if (getFieldOffsetInBits(Field) != 0) { ConvertingStruct = OldConvertingStruct; From baldrick at free.fr Wed Apr 9 11:18:18 2008 From: baldrick at free.fr (Duncan Sands) Date: Wed, 09 Apr 2008 16:18:18 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49432 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <200804091618.m39GIIjQ028926@zion.cs.uiuc.edu> Author: baldrick Date: Wed Apr 9 11:18:18 2008 New Revision: 49432 URL: http://llvm.org/viewvc/llvm-project?rev=49432&view=rev Log: RetVal already has this value. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=49432&r1=49431&r2=49432&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Wed Apr 9 11:18:18 2008 @@ -772,7 +772,7 @@ // a scalar register for this target. We must bit convert the aggregate // to the specified scalar type, which we do by casting the pointer and // loading. - RetVal = BitCastToType(DECL_LLVM(DECL_RESULT(FnDecl)), + RetVal = BitCastToType(RetVal, PointerType::getUnqual(Fn->getReturnType())); RetVal = Builder.CreateLoad(RetVal, "retval"); RetVals.push_back(RetVal); From natebegeman at mac.com Wed Apr 9 11:24:11 2008 From: natebegeman at mac.com (Nate Begeman) Date: Wed, 09 Apr 2008 16:24:11 -0000 Subject: [llvm-commits] [llvm] r49433 - /llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Message-ID: <200804091624.m39GOBFY029167@zion.cs.uiuc.edu> Author: sampo Date: Wed Apr 9 11:24:11 2008 New Revision: 49433 URL: http://llvm.org/viewvc/llvm-project?rev=49433&view=rev Log: Fix a bug where an incorrect bit mask would be generated if a target's last asm string began at a power of 2 in the string index. For example, if "ret" started at position 16, the ret instruction would be assigned code 16, but the mask would be AsmChars[] + Code & 15, not Code & 31. Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp?rev=49433&r1=49432&r2=49433&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Wed Apr 9 11:24:11 2008 @@ -536,7 +536,7 @@ } // Figure out how many bits we used for the string index. - unsigned AsmStrBits = Log2_32_Ceil(MaxStringIdx); + unsigned AsmStrBits = Log2_32_Ceil(MaxStringIdx+1); // To reduce code size, we compactify common instructions into a few bits // in the opcode-indexed table. From dpatel at apple.com Wed Apr 9 10:58:24 2008 From: dpatel at apple.com (Devang Patel) Date: Wed, 09 Apr 2008 15:58:24 -0000 Subject: [llvm-commits] [llvm] r49430 - /llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Message-ID: <200804091558.m39FwOLp028288@zion.cs.uiuc.edu> Author: dpatel Date: Wed Apr 9 10:58:24 2008 New Revision: 49430 URL: http://llvm.org/viewvc/llvm-project?rev=49430&view=rev Log: Be conservative if getresult operand is neither call nor invoke. Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=49430&r1=49429&r2=49430&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Wed Apr 9 10:58:24 2008 @@ -690,12 +690,13 @@ unsigned Idx = GRI.getIndex(); Value *Aggr = GRI.getOperand(0); Function *F = NULL; - if (CallInst *CI = dyn_cast(Aggr)) + if (CallInst *CI = dyn_cast(Aggr)) F = CI->getCalledFunction(); else if (InvokeInst *II = dyn_cast(Aggr)) F = II->getCalledFunction(); - assert (F && "Invalid GetResultInst operands!"); + if (!F) + return; std::multimap::iterator It, E; tie(It, E) = TrackedMultipleRetVals.equal_range(F); From clattner at apple.com Wed Apr 9 11:51:57 2008 From: clattner at apple.com (Chris Lattner) Date: Wed, 9 Apr 2008 09:51:57 -0700 Subject: [llvm-commits] [llvm] r49417 - /llvm/trunk/include/llvm/Constants.h In-Reply-To: <200804090706.m39762SZ003278@zion.cs.uiuc.edu> References: <200804090706.m39762SZ003278@zion.cs.uiuc.edu> Message-ID: <503C1246-4B36-487F-9401-10C0DBB85983@apple.com> On Apr 9, 2008, at 12:06 AM, Evan Cheng wrote: > Author: evancheng > Date: Wed Apr 9 02:06:01 2008 > New Revision: 49417 > > URL: http://llvm.org/viewvc/llvm-project?rev=49417&view=rev > Log: > Unbreak teh build. Doh, thanks Evan. -Chris > > > Modified: > llvm/trunk/include/llvm/Constants.h > > Modified: llvm/trunk/include/llvm/Constants.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=49417&r1=49416&r2=49417&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/include/llvm/Constants.h (original) > +++ llvm/trunk/include/llvm/Constants.h Wed Apr 9 02:06:01 2008 > @@ -237,6 +237,11 @@ > return get(V); > } > > + /// get() - This returns a constant fp for the specified value in > the > + /// specified type. This should only be used for simple constant > values like > + /// 2.0/1.0 etc, that are known-valid both as double and as the > target format. > + ConstantFP *get(const Type *Ty, double V); > + > /// isValueValidForType - return true if Ty is big enough to > represent V. > static bool isValueValidForType(const Type *Ty, const APFloat& V); > inline const APFloat& getValueAPF() const { return Val; } > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Wed Apr 9 11:54:22 2008 From: clattner at apple.com (Chris Lattner) Date: Wed, 9 Apr 2008 09:54:22 -0700 Subject: [llvm-commits] [llvm] r49430 - /llvm/trunk/lib/Transforms/Scalar/SCCP.cpp In-Reply-To: <200804091558.m39FwOLp028288@zion.cs.uiuc.edu> References: <200804091558.m39FwOLp028288@zion.cs.uiuc.edu> Message-ID: On Apr 9, 2008, at 8:58 AM, Devang Patel wrote: > Author: dpatel > Date: Wed Apr 9 10:58:24 2008 > New Revision: 49430 > > URL: http://llvm.org/viewvc/llvm-project?rev=49430&view=rev > Log: > Be conservative if getresult operand is neither call nor invoke. What else could it be? undef? -Chris > > > Modified: > llvm/trunk/lib/Transforms/Scalar/SCCP.cpp > > Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=49430&r1=49429&r2=49430&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Wed Apr 9 10:58:24 2008 > @@ -690,12 +690,13 @@ > unsigned Idx = GRI.getIndex(); > Value *Aggr = GRI.getOperand(0); > Function *F = NULL; > - if (CallInst *CI = dyn_cast(Aggr)) > + if (CallInst *CI = dyn_cast(Aggr)) > F = CI->getCalledFunction(); > else if (InvokeInst *II = dyn_cast(Aggr)) > F = II->getCalledFunction(); > > - assert (F && "Invalid GetResultInst operands!"); > + if (!F) > + return; > > std::multimap::iterator It, E; > tie(It, E) = TrackedMultipleRetVals.equal_range(F); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Wed Apr 9 12:16:28 2008 From: sabre at nondot.org (Chris Lattner) Date: Wed, 09 Apr 2008 17:16:28 -0000 Subject: [llvm-commits] [llvm] r49434 - /llvm/trunk/include/llvm/Constants.h Message-ID: <200804091716.m39HGTs4030829@zion.cs.uiuc.edu> Author: lattner Date: Wed Apr 9 12:16:28 2008 New Revision: 49434 URL: http://llvm.org/viewvc/llvm-project?rev=49434&view=rev Log: ConstantFP::get should be static. Modified: llvm/trunk/include/llvm/Constants.h Modified: llvm/trunk/include/llvm/Constants.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=49434&r1=49433&r2=49434&view=diff ============================================================================== --- llvm/trunk/include/llvm/Constants.h (original) +++ llvm/trunk/include/llvm/Constants.h Wed Apr 9 12:16:28 2008 @@ -240,7 +240,7 @@ /// get() - This returns a constant fp for the specified value in the /// specified type. This should only be used for simple constant values like /// 2.0/1.0 etc, that are known-valid both as double and as the target format. - ConstantFP *get(const Type *Ty, double V); + static ConstantFP *get(const Type *Ty, double V); /// isValueValidForType - return true if Ty is big enough to represent V. static bool isValueValidForType(const Type *Ty, const APFloat& V); From sabre at nondot.org Wed Apr 9 12:17:35 2008 From: sabre at nondot.org (Chris Lattner) Date: Wed, 09 Apr 2008 17:17:35 -0000 Subject: [llvm-commits] [llvm] r49435 - /llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp Message-ID: <200804091717.m39HHZPI030869@zion.cs.uiuc.edu> Author: lattner Date: Wed Apr 9 12:17:35 2008 New Revision: 49435 URL: http://llvm.org/viewvc/llvm-project?rev=49435&view=rev Log: use the new ConstantFP::get method to make this work with long double and simplify the code. Modified: llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp Modified: llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp?rev=49435&r1=49434&r2=49435&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp Wed Apr 9 12:17:35 2008 @@ -1149,10 +1149,6 @@ /// @brief Perform the pow optimization. virtual bool OptimizeCall(CallInst *CI, SimplifyLibCalls &SLC) { - const Type *Ty = CI->getType(); - if (Ty != Type::FloatTy && Ty != Type::DoubleTy) - return false; // FIXME long double not yet supported - Value *Op1 = CI->getOperand(1); Value *Op2 = CI->getOperand(2); if (ConstantFP *Op1C = dyn_cast(Op1)) { @@ -1165,8 +1161,7 @@ if (Op2C->getValueAPF().isZero()) { // pow(x, 0.0) -> 1.0 - return ReplaceCallWith(CI, ConstantFP::get(Ty, - Ty==Type::FloatTy ? APFloat(1.0f) : APFloat(1.0))); + return ReplaceCallWith(CI, ConstantFP::get(CI->getType(), 1.0)); } else if (Op2C->isExactlyValue(0.5)) { // pow(x, 0.5) -> sqrt(x) Value *Sqrt = CallInst::Create(SLC.get_sqrt(), Op1, "sqrt", CI); @@ -1180,11 +1175,9 @@ return ReplaceCallWith(CI, Sq); } else if (Op2C->isExactlyValue(-1.0)) { // pow(x, -1.0) -> 1.0/x - Value *div_inst = - BinaryOperator::createFDiv(ConstantFP::get(Ty, - Ty==Type::FloatTy ? APFloat(1.0f) : APFloat(1.0)), - Op1, CI->getName()+".pow", CI); - return ReplaceCallWith(CI, div_inst); + Value *R = BinaryOperator::createFDiv(ConstantFP::get(CI->getType(), 1.0), + Op1, CI->getName()+".pow", CI); + return ReplaceCallWith(CI, R); } return false; // opt failed } From sabre at nondot.org Wed Apr 9 12:46:36 2008 From: sabre at nondot.org (Chris Lattner) Date: Wed, 09 Apr 2008 17:46:36 -0000 Subject: [llvm-commits] [llvm] r49436 - in /llvm/trunk/test/Transforms/SimplifyLibCalls: Pow.ll pow2.ll Message-ID: <200804091746.m39Hka7g031896@zion.cs.uiuc.edu> Author: lattner Date: Wed Apr 9 12:46:36 2008 New Revision: 49436 URL: http://llvm.org/viewvc/llvm-project?rev=49436&view=rev Log: remove capital letter from test name. Added: llvm/trunk/test/Transforms/SimplifyLibCalls/pow2.ll - copied unchanged from r49433, llvm/trunk/test/Transforms/SimplifyLibCalls/Pow.ll Removed: llvm/trunk/test/Transforms/SimplifyLibCalls/Pow.ll Removed: llvm/trunk/test/Transforms/SimplifyLibCalls/Pow.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/Pow.ll?rev=49435&view=auto ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/Pow.ll (original) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/Pow.ll (removed) @@ -1,32 +0,0 @@ -; Testcase for calls to the standard C "pow" function -; -; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | not grep {call .pow} - - -declare double @pow(double, double) -declare float @powf(float, float) - -define double @test1(double %X) { - %Y = call double @pow( double %X, double 0.000000e+00 ) ; [#uses=1] - ret double %Y -} - -define double @test2(double %X) { - %Y = call double @pow( double %X, double -0.000000e+00 ) ; [#uses=1] - ret double %Y -} - -define double @test3(double %X) { - %Y = call double @pow( double 1.000000e+00, double %X ) ; [#uses=1] - ret double %Y -} - -define double @test4(double %X) { - %Y = call double @pow( double %X, double 2.0) - ret double %Y -} - -define float @test4f(float %X) { - %Y = call float @powf( float %X, float 2.0) - ret float %Y -} From sabre at nondot.org Wed Apr 9 12:48:11 2008 From: sabre at nondot.org (Chris Lattner) Date: Wed, 09 Apr 2008 17:48:11 -0000 Subject: [llvm-commits] [llvm] r49437 - in /llvm/trunk: lib/Transforms/IPO/SimplifyLibCalls.cpp test/Transforms/SimplifyLibCalls/pow2.ll Message-ID: <200804091748.m39HmBYD031951@zion.cs.uiuc.edu> Author: lattner Date: Wed Apr 9 12:48:11 2008 New Revision: 49437 URL: http://llvm.org/viewvc/llvm-project?rev=49437&view=rev Log: Generalize getUnaryFloatFunction to handle any FP unary function, automatically figuring out the suffix to use. implement pow(2,x) -> exp2(x). Modified: llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp llvm/trunk/test/Transforms/SimplifyLibCalls/pow2.ll Modified: llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp?rev=49437&r1=49436&r2=49437&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp Wed Apr 9 12:48:11 2008 @@ -328,18 +328,36 @@ return memcpy_func; } - Constant *getUnaryFloatFunction(const char *Name, Constant *&Cache) { - if (!Cache) - Cache = M->getOrInsertFunction(Name, Type::FloatTy, Type::FloatTy, NULL); - return Cache; + Constant *getUnaryFloatFunction(const char *BaseName, const Type *T = 0) { + if (T == 0) T = Type::FloatTy; + + char NameBuffer[20]; + const char *Name; + if (T == Type::DoubleTy) + Name = BaseName; // floor + else { + Name = NameBuffer; + unsigned NameLen = strlen(BaseName); + assert(NameLen < sizeof(NameBuffer)-2 && "Buffer too small"); + memcpy(NameBuffer, BaseName, NameLen); + if (T == Type::FloatTy) + NameBuffer[NameLen] = 'f'; // floorf + else + NameBuffer[NameLen] = 'l'; // floorl + NameBuffer[NameLen+1] = 0; + } + + return M->getOrInsertFunction(Name, T, T, NULL); } - Constant *get_floorf() { return getUnaryFloatFunction("floorf", floorf_func);} - Constant *get_ceilf() { return getUnaryFloatFunction( "ceilf", ceilf_func);} - Constant *get_roundf() { return getUnaryFloatFunction("roundf", roundf_func);} - Constant *get_rintf() { return getUnaryFloatFunction( "rintf", rintf_func);} - Constant *get_nearbyintf() { return getUnaryFloatFunction("nearbyintf", - nearbyintf_func); } + Constant *get_floorf() { return getUnaryFloatFunction("floor"); } + Constant *get_ceilf() { return getUnaryFloatFunction( "ceil"); } + Constant *get_roundf() { return getUnaryFloatFunction("round"); } + Constant *get_rintf() { return getUnaryFloatFunction( "rint"); } + Constant *get_nearbyintf() { return getUnaryFloatFunction("nearbyint"); } + + + private: /// @brief Reset our cached data for a new Module void reset(Module& mod) { @@ -355,11 +373,6 @@ sqrt_func = 0; strcpy_func = 0; strlen_func = 0; - floorf_func = 0; - ceilf_func = 0; - roundf_func = 0; - rintf_func = 0; - nearbyintf_func = 0; } private: @@ -369,8 +382,6 @@ Constant *memcpy_func, *memchr_func; Constant *sqrt_func; Constant *strcpy_func, *strlen_func; - Constant *floorf_func, *ceilf_func, *roundf_func; - Constant *rintf_func, *nearbyintf_func; Module *M; ///< Cached Module TargetData *TD; ///< Cached TargetData }; @@ -1154,6 +1165,11 @@ if (ConstantFP *Op1C = dyn_cast(Op1)) { if (Op1C->isExactlyValue(1.0)) // pow(1.0, x) -> 1.0 return ReplaceCallWith(CI, Op1C); + if (Op1C->isExactlyValue(2.0)) {// pow(2.0, x) -> exp2(x) + Value *Exp2 = SLC.getUnaryFloatFunction("exp2", CI->getType()); + Value *Res = CallInst::Create(Exp2, Op2, CI->getName()+"exp2", CI); + return ReplaceCallWith(CI, Res); + } } ConstantFP *Op2C = dyn_cast(Op2); Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/pow2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/pow2.ll?rev=49437&r1=49436&r2=49437&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/pow2.ll (original) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/pow2.ll Wed Apr 9 12:48:11 2008 @@ -30,3 +30,8 @@ %Y = call float @powf( float %X, float 2.0) ret float %Y } + +define float @test5f(float %X) { + %Y = call float @powf(float 2.0, float %X) ;; exp2 + ret float %Y +} From isanbard at gmail.com Wed Apr 9 12:50:45 2008 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 09 Apr 2008 17:50:45 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49438 - /llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c Message-ID: <200804091750.m39HojG4032086@zion.cs.uiuc.edu> Author: void Date: Wed Apr 9 12:50:44 2008 New Revision: 49438 URL: http://llvm.org/viewvc/llvm-project?rev=49438&view=rev Log: Temporary fix to get the build working again. Devang, please review. Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c?rev=49438&r1=49437&r2=49438&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c (original) +++ llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c Wed Apr 9 12:50:44 2008 @@ -4906,7 +4906,8 @@ means aggregate_value_p is not useful on this target for this purpose. This is a big nasty longterm problem. For now put things back the way they used to be (wrong, but fewer crashes). */ - if (TARGET_64BIT && TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type)) > 8) + if (TARGET_64BIT && TREE_CODE(TYPE_SIZE_UNIT(type)) == INTEGER_CST && + TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type)) > 8) return true; /* LLVM LOCAL end strcut return check */ From gohman at apple.com Wed Apr 9 12:53:38 2008 From: gohman at apple.com (Dan Gohman) Date: Wed, 09 Apr 2008 17:53:38 -0000 Subject: [llvm-commits] [llvm] r49440 - /llvm/trunk/lib/Target/X86/X86CallingConv.td Message-ID: <200804091753.m39HrctW032396@zion.cs.uiuc.edu> Author: djg Date: Wed Apr 9 12:53:38 2008 New Revision: 49440 URL: http://llvm.org/viewvc/llvm-project?rev=49440&view=rev Log: Add DX as a second return value register for i16 on x86. Modified: llvm/trunk/lib/Target/X86/X86CallingConv.td Modified: llvm/trunk/lib/Target/X86/X86CallingConv.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CallingConv.td?rev=49440&r1=49439&r2=49440&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86CallingConv.td (original) +++ llvm/trunk/lib/Target/X86/X86CallingConv.td Wed Apr 9 12:53:38 2008 @@ -24,7 +24,7 @@ def RetCC_X86Common : CallingConv<[ // Scalar values are returned in AX first, then DX. CCIfType<[i8] , CCAssignToReg<[AL]>>, - CCIfType<[i16], CCAssignToReg<[AX]>>, + CCIfType<[i16], CCAssignToReg<[AX, DX]>>, CCIfType<[i32], CCAssignToReg<[EAX, EDX]>>, CCIfType<[i64], CCAssignToReg<[RAX, RDX]>>, From tonic at nondot.org Wed Apr 9 12:53:38 2008 From: tonic at nondot.org (Tanya Lattner) Date: Wed, 09 Apr 2008 17:53:38 -0000 Subject: [llvm-commits] [test-suite] r49439 - /test-suite/trunk/configure Message-ID: <200804091753.m39HrcQw032401@zion.cs.uiuc.edu> Author: tbrethou Date: Wed Apr 9 12:53:38 2008 New Revision: 49439 URL: http://llvm.org/viewvc/llvm-project?rev=49439&view=rev Log: Regenerate configure. Modified: test-suite/trunk/configure Modified: test-suite/trunk/configure URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/configure?rev=49439&r1=49438&r2=49439&view=diff ============================================================================== --- test-suite/trunk/configure (original) +++ test-suite/trunk/configure Wed Apr 9 12:53:38 2008 @@ -2045,6 +2045,9 @@ ac_config_commands="$ac_config_commands External/SPEC/Makefile.spec" +ac_config_commands="$ac_config_commands External/SPEC/Makefile.spec.config" + + ac_config_commands="$ac_config_commands External/SPEC/Makefile.spec2006" @@ -5239,7 +5242,7 @@ ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 5242 "configure"' > conftest.$ac_ext + echo '#line 5245 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -7404,11 +7407,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7407: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7410: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7411: \$? = $ac_status" >&5 + echo "$as_me:7414: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7672,11 +7675,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7675: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7678: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7679: \$? = $ac_status" >&5 + echo "$as_me:7682: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7776,11 +7779,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7779: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7782: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7783: \$? = $ac_status" >&5 + echo "$as_me:7786: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -10228,7 +10231,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:12702: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:12703: \$? = $ac_status" >&5 + echo "$as_me:12706: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -12800,11 +12803,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12803: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12806: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:12807: \$? = $ac_status" >&5 + echo "$as_me:12810: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -14370,11 +14373,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14373: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14376: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14377: \$? = $ac_status" >&5 + echo "$as_me:14380: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -14474,11 +14477,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14477: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14480: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14481: \$? = $ac_status" >&5 + echo "$as_me:14484: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -16709,11 +16712,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16712: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16715: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:16716: \$? = $ac_status" >&5 + echo "$as_me:16719: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -16977,11 +16980,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16980: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16983: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:16984: \$? = $ac_status" >&5 + echo "$as_me:16987: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -17081,11 +17084,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:17084: $lt_compile\"" >&5) + (eval echo "\"\$as_me:17087: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:17088: \$? = $ac_status" >&5 + echo "$as_me:17091: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -21427,6 +21430,7 @@ "External/Povray/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS External/Povray/Makefile" ;; "External/SPEC/Makefile") CONFIG_COMMANDS="$CONFIG_COMMANDS External/SPEC/Makefile" ;; "External/SPEC/Makefile.spec") CONFIG_COMMANDS="$CONFIG_COMMANDS External/SPEC/Makefile.spec" ;; + "External/SPEC/Makefile.spec.config") CONFIG_COMMANDS="$CONFIG_COMMANDS External/SPEC/Makefile.spec.config" ;; "External/SPEC/Makefile.spec2006") CONFIG_COMMANDS="$CONFIG_COMMANDS External/SPEC/Makefile.spec2006" ;; "External/SPEC/Makefile.spec2000") CONFIG_COMMANDS="$CONFIG_COMMANDS External/SPEC/Makefile.spec2000" ;; "External/SPEC/Makefile.spec95") CONFIG_COMMANDS="$CONFIG_COMMANDS External/SPEC/Makefile.spec95" ;; @@ -22003,6 +22007,8 @@ ${SHELL} ${llvm_src}/autoconf/install-sh -c ${srcdir}/External/SPEC/Makefile External/SPEC/Makefile ;; "External/SPEC/Makefile.spec":C) ${llvm_src}/autoconf/mkinstalldirs `dirname External/SPEC/Makefile.spec` ${SHELL} ${llvm_src}/autoconf/install-sh -c ${srcdir}/External/SPEC/Makefile.spec External/SPEC/Makefile.spec ;; + "External/SPEC/Makefile.spec.config":C) ${llvm_src}/autoconf/mkinstalldirs `dirname External/SPEC/Makefile.spec.config` + ${SHELL} ${llvm_src}/autoconf/install-sh -c ${srcdir}/External/SPEC/Makefile.spec.config External/SPEC/Makefile.spec.config ;; "External/SPEC/Makefile.spec2006":C) ${llvm_src}/autoconf/mkinstalldirs `dirname External/SPEC/Makefile.spec2006` ${SHELL} ${llvm_src}/autoconf/install-sh -c ${srcdir}/External/SPEC/Makefile.spec2006 External/SPEC/Makefile.spec2006 ;; "External/SPEC/Makefile.spec2000":C) ${llvm_src}/autoconf/mkinstalldirs `dirname External/SPEC/Makefile.spec2000` From gohman at apple.com Wed Apr 9 12:54:37 2008 From: gohman at apple.com (Dan Gohman) Date: Wed, 09 Apr 2008 17:54:37 -0000 Subject: [llvm-commits] [llvm] r49441 - /llvm/trunk/lib/Target/X86/X86CallingConv.td Message-ID: <200804091754.m39HsbIk032442@zion.cs.uiuc.edu> Author: djg Date: Wed Apr 9 12:54:37 2008 New Revision: 49441 URL: http://llvm.org/viewvc/llvm-project?rev=49441&view=rev Log: Add XMM1 as a second return value register for f32 and f64 on x86-64. This is needed for the x86-64-ABI handling of structs that contain floating-point members that are returned by value. Modified: llvm/trunk/lib/Target/X86/X86CallingConv.td Modified: llvm/trunk/lib/Target/X86/X86CallingConv.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CallingConv.td?rev=49441&r1=49440&r2=49441&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86CallingConv.td (original) +++ llvm/trunk/lib/Target/X86/X86CallingConv.td Wed Apr 9 12:54:37 2008 @@ -65,16 +65,16 @@ def RetCC_X86_32_SSE : CallingConv<[ // The X86-32 sseregparm calling convention returns FP values in XMM0 if the // target has SSE2, otherwise it is the C calling convention. - CCIfType<[f32], CCIfSubtarget<"hasSSE2()", CCAssignToReg<[XMM0]>>>, - CCIfType<[f64], CCIfSubtarget<"hasSSE2()", CCAssignToReg<[XMM0]>>>, + CCIfType<[f32], CCIfSubtarget<"hasSSE2()", CCAssignToReg<[XMM0, XMM1]>>>, + CCIfType<[f64], CCIfSubtarget<"hasSSE2()", CCAssignToReg<[XMM0, XMM1]>>>, CCDelegateTo ]>; // X86-64 C return-value convention. def RetCC_X86_64_C : CallingConv<[ // The X86-64 calling convention always returns FP values in XMM0. - CCIfType<[f32], CCAssignToReg<[XMM0]>>, - CCIfType<[f64], CCAssignToReg<[XMM0]>>, + CCIfType<[f32], CCAssignToReg<[XMM0, XMM1]>>, + CCIfType<[f64], CCAssignToReg<[XMM0, XMM1]>>, CCDelegateTo ]>; From dalej at apple.com Wed Apr 9 12:58:16 2008 From: dalej at apple.com (Dale Johannesen) Date: Wed, 9 Apr 2008 10:58:16 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r49438 - /llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c In-Reply-To: <200804091750.m39HojG4032086@zion.cs.uiuc.edu> References: <200804091750.m39HojG4032086@zion.cs.uiuc.edu> Message-ID: <4FB951AA-FF91-41DA-850C-1E7532B1D180@apple.com> This is my doing, not devang's. I'm not sure what structs with nonconstant size ought to do, but ppc64 doesn't work anyway, so let's worry about it later; this patch is fine. On Apr 9, 2008, at 10:50 AM, Bill Wendling wrote: > Author: void > Date: Wed Apr 9 12:50:44 2008 > New Revision: 49438 > > URL: http://llvm.org/viewvc/llvm-project?rev=49438&view=rev > Log: > Temporary fix to get the build working again. Devang, please review. > > > Modified: > llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c > > Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c?rev=49438&r1=49437&r2=49438&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c (original) > +++ llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c Wed Apr 9 > 12:50:44 2008 > @@ -4906,7 +4906,8 @@ > means aggregate_value_p is not useful on this target for this > purpose. > This is a big nasty longterm problem. For now put things back > the > way they used to be (wrong, but fewer crashes). */ > - if (TARGET_64BIT && TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type)) > 8) > + if (TARGET_64BIT && TREE_CODE(TYPE_SIZE_UNIT(type)) == > INTEGER_CST && > + TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type)) > 8) > return true; > /* LLVM LOCAL end strcut return check */ > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From isanbard at gmail.com Wed Apr 9 13:04:12 2008 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 9 Apr 2008 11:04:12 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r49438 - /llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c In-Reply-To: <4FB951AA-FF91-41DA-850C-1E7532B1D180@apple.com> References: <200804091750.m39HojG4032086@zion.cs.uiuc.edu> <4FB951AA-FF91-41DA-850C-1E7532B1D180@apple.com> Message-ID: <16e5fdf90804091104g6ba8620dh766818d522485ac6@mail.gmail.com> My mistake. Thanks for reviewing it. -bw On Wed, Apr 9, 2008 at 10:58 AM, Dale Johannesen wrote: > This is my doing, not devang's. I'm not sure what structs with > nonconstant size ought > to do, but ppc64 doesn't work anyway, so let's worry about it later; > this patch is fine. > > > > On Apr 9, 2008, at 10:50 AM, Bill Wendling wrote: > > > Author: void > > Date: Wed Apr 9 12:50:44 2008 > > New Revision: 49438 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=49438&view=rev > > Log: > > Temporary fix to get the build working again. Devang, please review. > > > > > > Modified: > > llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c > > > > Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c > > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c?rev=49438&r1=49437&r2=49438&view=diff > > > > = > > = > > = > > = > > = > > = > > = > > = > > ====================================================================== > > --- llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c (original) > > +++ llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c Wed Apr 9 > > 12:50:44 2008 > > @@ -4906,7 +4906,8 @@ > > means aggregate_value_p is not useful on this target for this > > purpose. > > This is a big nasty longterm problem. For now put things back > > the > > way they used to be (wrong, but fewer crashes). */ > > - if (TARGET_64BIT && TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type)) > 8) > > + if (TARGET_64BIT && TREE_CODE(TYPE_SIZE_UNIT(type)) == > > INTEGER_CST && > > + TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type)) > 8) > > return true; > > /* LLVM LOCAL end strcut return check */ > > > > > > > > _______________________________________________ > > llvm-commits mailing list > > llvm-commits at cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From gohman at apple.com Wed Apr 9 13:24:25 2008 From: gohman at apple.com (Dan Gohman) Date: Wed, 09 Apr 2008 18:24:25 -0000 Subject: [llvm-commits] [llvm] r49442 - in /llvm/trunk/include/llvm: CodeGen/MachineModuleInfo.h DerivedTypes.h Message-ID: <200804091824.m39IOP7Y000860@zion.cs.uiuc.edu> Author: djg Date: Wed Apr 9 13:24:25 2008 New Revision: 49442 URL: http://llvm.org/viewvc/llvm-project?rev=49442&view=rev Log: Update comments to use 2.0 syntax type names. Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h llvm/trunk/include/llvm/DerivedTypes.h Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h?rev=49442&r1=49441&r2=49442&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Wed Apr 9 13:24:25 2008 @@ -772,7 +772,7 @@ class DISerializer { private: Module *M; // Definition space module. - PointerType *StrPtrTy; // A "sbyte *" type. Created lazily. + PointerType *StrPtrTy; // A "i8*" type. Created lazily. PointerType *EmptyStructPtrTy; // A "{ }*" type. Created lazily. std::map TagTypes; // Types per Tag. Created lazily. @@ -796,7 +796,7 @@ Module *getModule() const { return M; }; void setModule(Module *module) { M = module; } - /// getStrPtrType - Return a "sbyte *" type. + /// getStrPtrType - Return a "i8*" type. /// const PointerType *getStrPtrType(); Modified: llvm/trunk/include/llvm/DerivedTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DerivedTypes.h?rev=49442&r1=49441&r2=49442&view=diff ============================================================================== --- llvm/trunk/include/llvm/DerivedTypes.h (original) +++ llvm/trunk/include/llvm/DerivedTypes.h Wed Apr 9 13:24:25 2008 @@ -104,7 +104,7 @@ /// getBitMask - Return a bitmask with ones set for all of the bits /// that can be set by an unsigned version of this type. This is 0xFF for - /// sbyte/ubyte, 0xFFFF for shorts, etc. + /// i8, 0xFFFF for i16, etc. uint64_t getBitMask() const { return ~uint64_t(0UL) >> (64-getBitWidth()); } From gohman at apple.com Wed Apr 9 13:31:41 2008 From: gohman at apple.com (Dan Gohman) Date: Wed, 09 Apr 2008 18:31:41 -0000 Subject: [llvm-commits] [llvm] r49443 - /llvm/trunk/include/llvm/Instruction.h Message-ID: <200804091831.m39IVfTV001069@zion.cs.uiuc.edu> Author: djg Date: Wed Apr 9 13:31:41 2008 New Revision: 49443 URL: http://llvm.org/viewvc/llvm-project?rev=49443&view=rev Log: Add const qualifiers. Modified: llvm/trunk/include/llvm/Instruction.h Modified: llvm/trunk/include/llvm/Instruction.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instruction.h?rev=49443&r1=49442&r2=49443&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instruction.h (original) +++ llvm/trunk/include/llvm/Instruction.h Wed Apr 9 13:31:41 2008 @@ -127,13 +127,13 @@ /// isLogicalShift - Return true if this is a logical shift left or a logical /// shift right. - inline bool isLogicalShift() { + inline bool isLogicalShift() const { return getOpcode() == Shl || getOpcode() == LShr; } /// isLogicalShift - Return true if this is a logical shift left or a logical /// shift right. - inline bool isArithmeticShift() { + inline bool isArithmeticShift() const { return getOpcode() == AShr; } From baldrick at free.fr Wed Apr 9 14:32:06 2008 From: baldrick at free.fr (Duncan Sands) Date: Wed, 09 Apr 2008 19:32:06 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49444 - in /llvm-gcc-4.2/trunk/gcc/ada: atree.adb comperr.adb einfo.adb exp_ch5.adb exp_ch6.adb exp_disp.adb exp_dist.adb exp_util.adb freeze.adb get_targ.adb gnatbind.adb init.c krunch.adb lib-util.adb namet.adb nlists.adb osint.adb par-ch3.adb par-util.adb rtsfind.adb scng.adb sem_cat.adb sem_ch3.adb sem_ch6.adb sem_elab.adb sem_maps.adb sem_maps.ads sem_res.adb sem_type.adb sem_util.adb sprint.adb uintp.adb Message-ID: <200804091932.m39JW7BR003118@zion.cs.uiuc.edu> Author: baldrick Date: Wed Apr 9 14:32:05 2008 New Revision: 49444 URL: http://llvm.org/viewvc/llvm-project?rev=49444&view=rev Log: Make the Ada front-end buildable by GNAT GPL 2006 and GNAT GPL 2007. Modified: llvm-gcc-4.2/trunk/gcc/ada/atree.adb llvm-gcc-4.2/trunk/gcc/ada/comperr.adb llvm-gcc-4.2/trunk/gcc/ada/einfo.adb llvm-gcc-4.2/trunk/gcc/ada/exp_ch5.adb llvm-gcc-4.2/trunk/gcc/ada/exp_ch6.adb llvm-gcc-4.2/trunk/gcc/ada/exp_disp.adb llvm-gcc-4.2/trunk/gcc/ada/exp_dist.adb llvm-gcc-4.2/trunk/gcc/ada/exp_util.adb llvm-gcc-4.2/trunk/gcc/ada/freeze.adb llvm-gcc-4.2/trunk/gcc/ada/get_targ.adb llvm-gcc-4.2/trunk/gcc/ada/gnatbind.adb llvm-gcc-4.2/trunk/gcc/ada/init.c llvm-gcc-4.2/trunk/gcc/ada/krunch.adb llvm-gcc-4.2/trunk/gcc/ada/lib-util.adb llvm-gcc-4.2/trunk/gcc/ada/namet.adb llvm-gcc-4.2/trunk/gcc/ada/nlists.adb llvm-gcc-4.2/trunk/gcc/ada/osint.adb llvm-gcc-4.2/trunk/gcc/ada/par-ch3.adb llvm-gcc-4.2/trunk/gcc/ada/par-util.adb llvm-gcc-4.2/trunk/gcc/ada/rtsfind.adb llvm-gcc-4.2/trunk/gcc/ada/scng.adb llvm-gcc-4.2/trunk/gcc/ada/sem_cat.adb llvm-gcc-4.2/trunk/gcc/ada/sem_ch3.adb llvm-gcc-4.2/trunk/gcc/ada/sem_ch6.adb llvm-gcc-4.2/trunk/gcc/ada/sem_elab.adb llvm-gcc-4.2/trunk/gcc/ada/sem_maps.adb llvm-gcc-4.2/trunk/gcc/ada/sem_maps.ads llvm-gcc-4.2/trunk/gcc/ada/sem_res.adb llvm-gcc-4.2/trunk/gcc/ada/sem_type.adb llvm-gcc-4.2/trunk/gcc/ada/sem_util.adb llvm-gcc-4.2/trunk/gcc/ada/sprint.adb llvm-gcc-4.2/trunk/gcc/ada/uintp.adb Modified: llvm-gcc-4.2/trunk/gcc/ada/atree.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/atree.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/atree.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/atree.adb Wed Apr 9 14:32:05 2008 @@ -504,7 +504,8 @@ function Analyzed (N : Node_Id) return Boolean is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Analyzed; end Analyzed; @@ -544,7 +545,8 @@ function Comes_From_Source (N : Node_Id) return Boolean is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Comes_From_Source; end Comes_From_Source; @@ -819,7 +821,8 @@ function Error_Posted (N : Node_Id) return Boolean is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Error_Posted; end Error_Posted; @@ -2082,7 +2085,8 @@ C : Paren_Count_Type := 0; begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); if Nodes.Table (N).Pflag1 then C := C + 1; @@ -2270,7 +2274,8 @@ procedure Set_Comes_From_Source (N : Node_Id; Val : Boolean) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Comes_From_Source := Val; end Set_Comes_From_Source; @@ -2521,31 +2526,36 @@ function Field1 (N : Node_Id) return Union_Id is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Field1; end Field1; function Field2 (N : Node_Id) return Union_Id is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Field2; end Field2; function Field3 (N : Node_Id) return Union_Id is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Field3; end Field3; function Field4 (N : Node_Id) return Union_Id is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Field4; end Field4; function Field5 (N : Node_Id) return Union_Id is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Field5; end Field5; @@ -2683,31 +2693,36 @@ function Node1 (N : Node_Id) return Node_Id is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Node_Id (Nodes.Table (N).Field1); end Node1; function Node2 (N : Node_Id) return Node_Id is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Node_Id (Nodes.Table (N).Field2); end Node2; function Node3 (N : Node_Id) return Node_Id is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Node_Id (Nodes.Table (N).Field3); end Node3; function Node4 (N : Node_Id) return Node_Id is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Node_Id (Nodes.Table (N).Field4); end Node4; function Node5 (N : Node_Id) return Node_Id is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Node_Id (Nodes.Table (N).Field5); end Node5; @@ -2845,31 +2860,36 @@ function List1 (N : Node_Id) return List_Id is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return List_Id (Nodes.Table (N).Field1); end List1; function List2 (N : Node_Id) return List_Id is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return List_Id (Nodes.Table (N).Field2); end List2; function List3 (N : Node_Id) return List_Id is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return List_Id (Nodes.Table (N).Field3); end List3; function List4 (N : Node_Id) return List_Id is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return List_Id (Nodes.Table (N).Field4); end List4; function List5 (N : Node_Id) return List_Id is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return List_Id (Nodes.Table (N).Field5); end List5; @@ -2886,7 +2906,8 @@ end List14; function Elist2 (N : Node_Id) return Elist_Id is - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Value : constant Union_Id := Nodes.Table (N).Field2; begin if Value = 0 then @@ -2897,7 +2918,8 @@ end Elist2; function Elist3 (N : Node_Id) return Elist_Id is - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Value : constant Union_Id := Nodes.Table (N).Field3; begin if Value = 0 then @@ -2908,7 +2930,8 @@ end Elist3; function Elist4 (N : Node_Id) return Elist_Id is - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Value : constant Union_Id := Nodes.Table (N).Field4; begin if Value = 0 then @@ -3008,24 +3031,28 @@ function Name1 (N : Node_Id) return Name_Id is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Name_Id (Nodes.Table (N).Field1); end Name1; function Name2 (N : Node_Id) return Name_Id is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Name_Id (Nodes.Table (N).Field2); end Name2; function Str3 (N : Node_Id) return String_Id is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return String_Id (Nodes.Table (N).Field3); end Str3; function Uint2 (N : Node_Id) return Uint is - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); U : constant Union_Id := Nodes.Table (N).Field2; begin if U = 0 then @@ -3036,7 +3063,8 @@ end Uint2; function Uint3 (N : Node_Id) return Uint is - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); U : constant Union_Id := Nodes.Table (N).Field3; begin if U = 0 then @@ -3047,7 +3075,8 @@ end Uint3; function Uint4 (N : Node_Id) return Uint is - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); U : constant Union_Id := Nodes.Table (N).Field4; begin if U = 0 then @@ -3058,7 +3087,8 @@ end Uint4; function Uint5 (N : Node_Id) return Uint is - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); U : constant Union_Id := Nodes.Table (N).Field5; begin if U = 0 then @@ -3191,7 +3221,8 @@ function Ureal3 (N : Node_Id) return Ureal is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return From_Union (Nodes.Table (N).Field3); end Ureal3; @@ -3209,91 +3240,106 @@ function Flag4 (N : Node_Id) return Boolean is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Flag4; end Flag4; function Flag5 (N : Node_Id) return Boolean is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Flag5; end Flag5; function Flag6 (N : Node_Id) return Boolean is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Flag6; end Flag6; function Flag7 (N : Node_Id) return Boolean is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Flag7; end Flag7; function Flag8 (N : Node_Id) return Boolean is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Flag8; end Flag8; function Flag9 (N : Node_Id) return Boolean is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Flag9; end Flag9; function Flag10 (N : Node_Id) return Boolean is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Flag10; end Flag10; function Flag11 (N : Node_Id) return Boolean is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Flag11; end Flag11; function Flag12 (N : Node_Id) return Boolean is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Flag12; end Flag12; function Flag13 (N : Node_Id) return Boolean is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Flag13; end Flag13; function Flag14 (N : Node_Id) return Boolean is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Flag14; end Flag14; function Flag15 (N : Node_Id) return Boolean is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Flag15; end Flag15; function Flag16 (N : Node_Id) return Boolean is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Flag16; end Flag16; function Flag17 (N : Node_Id) return Boolean is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Flag17; end Flag17; function Flag18 (N : Node_Id) return Boolean is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); return Nodes.Table (N).Flag18; end Flag18; @@ -4481,37 +4527,43 @@ procedure Set_Nkind (N : Node_Id; Val : Node_Kind) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Nkind := Val; end Set_Nkind; procedure Set_Field1 (N : Node_Id; Val : Union_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field1 := Val; end Set_Field1; procedure Set_Field2 (N : Node_Id; Val : Union_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field2 := Val; end Set_Field2; procedure Set_Field3 (N : Node_Id; Val : Union_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field3 := Val; end Set_Field3; procedure Set_Field4 (N : Node_Id; Val : Union_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field4 := Val; end Set_Field4; procedure Set_Field5 (N : Node_Id; Val : Union_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field5 := Val; end Set_Field5; @@ -4649,31 +4701,36 @@ procedure Set_Node1 (N : Node_Id; Val : Node_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field1 := Union_Id (Val); end Set_Node1; procedure Set_Node2 (N : Node_Id; Val : Node_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field2 := Union_Id (Val); end Set_Node2; procedure Set_Node3 (N : Node_Id; Val : Node_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field3 := Union_Id (Val); end Set_Node3; procedure Set_Node4 (N : Node_Id; Val : Node_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field4 := Union_Id (Val); end Set_Node4; procedure Set_Node5 (N : Node_Id; Val : Node_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field5 := Union_Id (Val); end Set_Node5; @@ -4811,31 +4868,36 @@ procedure Set_List1 (N : Node_Id; Val : List_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field1 := Union_Id (Val); end Set_List1; procedure Set_List2 (N : Node_Id; Val : List_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field2 := Union_Id (Val); end Set_List2; procedure Set_List3 (N : Node_Id; Val : List_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field3 := Union_Id (Val); end Set_List3; procedure Set_List4 (N : Node_Id; Val : List_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field4 := Union_Id (Val); end Set_List4; procedure Set_List5 (N : Node_Id; Val : List_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field5 := Union_Id (Val); end Set_List5; @@ -4916,43 +4978,50 @@ procedure Set_Name1 (N : Node_Id; Val : Name_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field1 := Union_Id (Val); end Set_Name1; procedure Set_Name2 (N : Node_Id; Val : Name_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field2 := Union_Id (Val); end Set_Name2; procedure Set_Str3 (N : Node_Id; Val : String_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field3 := Union_Id (Val); end Set_Str3; procedure Set_Uint2 (N : Node_Id; Val : Uint) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field2 := To_Union (Val); end Set_Uint2; procedure Set_Uint3 (N : Node_Id; Val : Uint) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field3 := To_Union (Val); end Set_Uint3; procedure Set_Uint4 (N : Node_Id; Val : Uint) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field4 := To_Union (Val); end Set_Uint4; procedure Set_Uint5 (N : Node_Id; Val : Uint) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field5 := To_Union (Val); end Set_Uint5; @@ -5024,7 +5093,8 @@ procedure Set_Ureal3 (N : Node_Id; Val : Ureal) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Field3 := To_Union (Val); end Set_Ureal3; @@ -5042,91 +5112,106 @@ procedure Set_Flag4 (N : Node_Id; Val : Boolean) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Flag4 := Val; end Set_Flag4; procedure Set_Flag5 (N : Node_Id; Val : Boolean) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Flag5 := Val; end Set_Flag5; procedure Set_Flag6 (N : Node_Id; Val : Boolean) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Flag6 := Val; end Set_Flag6; procedure Set_Flag7 (N : Node_Id; Val : Boolean) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Flag7 := Val; end Set_Flag7; procedure Set_Flag8 (N : Node_Id; Val : Boolean) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Flag8 := Val; end Set_Flag8; procedure Set_Flag9 (N : Node_Id; Val : Boolean) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Flag9 := Val; end Set_Flag9; procedure Set_Flag10 (N : Node_Id; Val : Boolean) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Flag10 := Val; end Set_Flag10; procedure Set_Flag11 (N : Node_Id; Val : Boolean) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Flag11 := Val; end Set_Flag11; procedure Set_Flag12 (N : Node_Id; Val : Boolean) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Flag12 := Val; end Set_Flag12; procedure Set_Flag13 (N : Node_Id; Val : Boolean) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Flag13 := Val; end Set_Flag13; procedure Set_Flag14 (N : Node_Id; Val : Boolean) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Flag14 := Val; end Set_Flag14; procedure Set_Flag15 (N : Node_Id; Val : Boolean) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Flag15 := Val; end Set_Flag15; procedure Set_Flag16 (N : Node_Id; Val : Boolean) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Flag16 := Val; end Set_Flag16; procedure Set_Flag17 (N : Node_Id; Val : Boolean) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Flag17 := Val; end Set_Flag17; procedure Set_Flag18 (N : Node_Id; Val : Boolean) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); Nodes.Table (N).Flag18 := Val; end Set_Flag18; @@ -6570,42 +6655,48 @@ procedure Set_Node1_With_Parent (N : Node_Id; Val : Node_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); if Val > Error then Set_Parent (Val, N); end if; Set_Node1 (N, Val); end Set_Node1_With_Parent; procedure Set_Node2_With_Parent (N : Node_Id; Val : Node_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); if Val > Error then Set_Parent (Val, N); end if; Set_Node2 (N, Val); end Set_Node2_With_Parent; procedure Set_Node3_With_Parent (N : Node_Id; Val : Node_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); if Val > Error then Set_Parent (Val, N); end if; Set_Node3 (N, Val); end Set_Node3_With_Parent; procedure Set_Node4_With_Parent (N : Node_Id; Val : Node_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); if Val > Error then Set_Parent (Val, N); end if; Set_Node4 (N, Val); end Set_Node4_With_Parent; procedure Set_Node5_With_Parent (N : Node_Id; Val : Node_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); if Val > Error then Set_Parent (Val, N); end if; Set_Node5 (N, Val); end Set_Node5_With_Parent; procedure Set_List1_With_Parent (N : Node_Id; Val : List_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); if Val /= No_List and then Val /= Error_List then Set_Parent (Val, N); end if; @@ -6614,7 +6705,8 @@ procedure Set_List2_With_Parent (N : Node_Id; Val : List_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); if Val /= No_List and then Val /= Error_List then Set_Parent (Val, N); end if; @@ -6623,7 +6715,8 @@ procedure Set_List3_With_Parent (N : Node_Id; Val : List_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); if Val /= No_List and then Val /= Error_List then Set_Parent (Val, N); end if; @@ -6632,7 +6725,8 @@ procedure Set_List4_With_Parent (N : Node_Id; Val : List_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); if Val /= No_List and then Val /= Error_List then Set_Parent (Val, N); end if; @@ -6641,7 +6735,8 @@ procedure Set_List5_With_Parent (N : Node_Id; Val : List_Id) is begin - pragma Assert (N in Nodes.First .. Nodes.Last); + -- LLVM local + pragma Assert (N <= Nodes.Last); if Val /= No_List and then Val /= Error_List then Set_Parent (Val, N); end if; Modified: llvm-gcc-4.2/trunk/gcc/ada/comperr.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/comperr.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/comperr.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/comperr.adb Wed Apr 9 14:32:05 2008 @@ -174,15 +174,18 @@ begin for P in 40 .. 69 loop - if X (P) = ' ' then + -- LLVM local + if X (X'First + P - 1) = ' ' then Last_Blank := P; end if; end loop; - Write_Str (X (1 .. Last_Blank)); + -- LLVM local + Write_Str (X (X'First .. X'First + Last_Blank - 1)); End_Line; Write_Str ("| "); - Write_Str (X (Last_Blank + 1 .. X'Length)); + -- LLVM local + Write_Str (X (X'First + Last_Blank .. X'Last)); end; else Write_Str (X); Modified: llvm-gcc-4.2/trunk/gcc/ada/einfo.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/einfo.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/einfo.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/einfo.adb Wed Apr 9 14:32:05 2008 @@ -6243,7 +6243,7 @@ end loop; end if; - raise Program_Error; + -- LLVM local deleted unreachable line end Root_Type; ----------------- Modified: llvm-gcc-4.2/trunk/gcc/ada/exp_ch5.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/exp_ch5.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/exp_ch5.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/exp_ch5.adb Wed Apr 9 14:32:05 2008 @@ -165,7 +165,8 @@ -- This switch is set to True if the array move must be done using -- an explicit front end generated loop. - procedure Apply_Dereference (Arg : in out Node_Id); + -- LLVM local + procedure Apply_Dereference (Arg : Node_Id); -- If the argument is an access to an array, and the assignment is -- converted into a procedure call, apply explicit dereference. @@ -188,7 +189,8 @@ -- Apply_Dereference -- ----------------------- - procedure Apply_Dereference (Arg : in out Node_Id) is + -- LLVM local + procedure Apply_Dereference (Arg : Node_Id) is Typ : constant Entity_Id := Etype (Arg); begin if Is_Access_Type (Typ) then Modified: llvm-gcc-4.2/trunk/gcc/ada/exp_ch6.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/exp_ch6.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/exp_ch6.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/exp_ch6.adb Wed Apr 9 14:32:05 2008 @@ -623,7 +623,8 @@ Low_Bound => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Var, Loc), - Attribute_name => Name_First), + -- LLVM local + Attribute_Name => Name_First), High_Bound => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Var, Loc), @@ -2478,7 +2479,8 @@ end loop; while Present (Next (Temp)) loop - Discard := Remove_Next (Temp); + -- LLVM local + Remove (Next (Temp)); end loop; end if; Modified: llvm-gcc-4.2/trunk/gcc/ada/exp_disp.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/exp_disp.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/exp_disp.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/exp_disp.adb Wed Apr 9 14:32:05 2008 @@ -4762,7 +4762,8 @@ -- Protect this procedure against wrong usage. Required because it will -- be used directly from GDB - if not (Typ in First_Node_Id .. Last_Node_Id) + -- LLVM local + if not (Typ <= Last_Node_Id) or else not Is_Tagged_Type (Typ) then Write_Str ("wrong usage: Write_DT must be used with tagged types"); Modified: llvm-gcc-4.2/trunk/gcc/ada/exp_dist.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/exp_dist.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/exp_dist.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/exp_dist.adb Wed Apr 9 14:32:05 2008 @@ -8342,7 +8342,8 @@ Build_From_Any_Call (Etype (Field), Build_Get_Aggregate_Element (Loc, Any => Any, - Tc => Build_TypeCode_Call (Loc, + -- LLVM local + TC => Build_TypeCode_Call (Loc, Etype (Field), Decls), Idx => Make_Integer_Literal (Loc, Counter)), @@ -8382,7 +8383,8 @@ Parameter_Associations => New_List ( Build_Get_Aggregate_Element (Loc, Any => Any, - Tc => Make_Function_Call (Loc, + -- LLVM local + TC => Make_Function_Call (Loc, Name => New_Occurrence_Of ( RTE (RE_Any_Member_Type), Loc), Parameter_Associations => @@ -8461,7 +8463,8 @@ Build_From_Any_Call (Etype (Disc), Build_Get_Aggregate_Element (Loc, Any => Any_Parameter, - Tc => Build_TypeCode_Call + -- LLVM local + TC => Build_TypeCode_Call (Loc, Etype (Disc), Decls), Idx => Make_Integer_Literal (Loc, Component_Counter)), @@ -8544,7 +8547,8 @@ Element_Any : constant Node_Id := Build_Get_Aggregate_Element (Loc, Any => Any, - Tc => Build_TypeCode_Call (Loc, + -- LLVM local + TC => Build_TypeCode_Call (Loc, Etype (Datum), Decls), Idx => New_Occurrence_Of (Counter, Loc)); @@ -8633,7 +8637,8 @@ Indt, Build_Get_Aggregate_Element (Loc, Any => Any_Parameter, - Tc => Build_TypeCode_Call (Loc, + -- LLVM local + TC => Build_TypeCode_Call (Loc, Indt, Decls), Idx => Make_Integer_Literal (Loc, J - 1)), Decls))); Modified: llvm-gcc-4.2/trunk/gcc/ada/exp_util.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/exp_util.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/exp_util.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/exp_util.adb Wed Apr 9 14:32:05 2008 @@ -91,8 +91,10 @@ Pos : out Entity_Id; Prefix : Entity_Id; Sum : Node_Id; - Decls : in out List_Id; - Stats : in out List_Id); + -- LLVM local begin + Decls : List_Id; + Stats : List_Id); + -- LLVM local end -- Common processing for Task_Array_Image and Task_Record_Image. -- Create local variables and assign prefix of name to result string. @@ -402,8 +404,10 @@ T : Entity_Id; -- Entity for name at one index position - Decls : List_Id := New_List; - Stats : List_Id := New_List; + -- LLVM local begin + Decls : constant List_Id := New_List; + Stats : constant List_Id := New_List; + -- LLVM local end begin Pref := Make_Defining_Identifier (Loc, New_Internal_Name ('P')); @@ -708,8 +712,10 @@ Pos : out Entity_Id; Prefix : Entity_Id; Sum : Node_Id; - Decls : in out List_Id; - Stats : in out List_Id) + -- LLVM local begin + Decls : List_Id; + Stats : List_Id) + -- LLVM local end is begin Len := Make_Defining_Identifier (Loc, New_Internal_Name ('L')); @@ -804,8 +810,10 @@ Sel : Entity_Id; -- Entity for selector name - Decls : List_Id := New_List; - Stats : List_Id := New_List; + -- LLVM local begin + Decls : constant List_Id := New_List; + Stats : constant List_Id := New_List; + -- LLVM local end begin Pref := Make_Defining_Identifier (Loc, New_Internal_Name ('P')); Modified: llvm-gcc-4.2/trunk/gcc/ada/freeze.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/freeze.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/freeze.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/freeze.adb Wed Apr 9 14:32:05 2008 @@ -1086,7 +1086,8 @@ New_N := Make_Object_Declaration (Loc, Defining_Identifier => Temp, - Object_definition => New_Occurrence_Of (Typ, Loc), + -- LLVM local + Object_Definition => New_Occurrence_Of (Typ, Loc), Expression => Relocate_Node (E)); Insert_Before (Parent (E), New_N); Analyze (New_N); @@ -4707,8 +4708,11 @@ return True; end; - else return not Is_Private_Type (T) - or else Present (Full_View (Base_Type (T))); + -- LLVM local begin + else + return not Is_Private_Type (T) + or else Present (Full_View (Base_Type (T))); + -- LLVM local end end if; end Is_Fully_Defined; Modified: llvm-gcc-4.2/trunk/gcc/ada/get_targ.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/get_targ.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/get_targ.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/get_targ.adb Wed Apr 9 14:32:05 2008 @@ -32,11 +32,18 @@ function Digits_From_Size (Size : Pos) return Pos is begin - if Size = 32 then return 6; - elsif Size = 48 then return 9; - elsif Size = 64 then return 15; - elsif Size = 96 then return 18; - elsif Size = 128 then return 18; + -- LLVM local begin + if Size = 32 then + return 6; + elsif Size = 48 then + return 9; + elsif Size = 64 then + return 15; + elsif Size = 96 then + return 18; + elsif Size = 128 then + return 18; + -- LLVM local end else raise Program_Error; end if; @@ -48,10 +55,16 @@ function Width_From_Size (Size : Pos) return Pos is begin - if Size = 8 then return 4; - elsif Size = 16 then return 6; - elsif Size = 32 then return 11; - elsif Size = 64 then return 21; + -- LLVM local begin + if Size = 8 then + return 4; + elsif Size = 16 then + return 6; + elsif Size = 32 then + return 11; + elsif Size = 64 then + return 21; + -- LLVM local end else raise Program_Error; end if; Modified: llvm-gcc-4.2/trunk/gcc/ada/gnatbind.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/gnatbind.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/gnatbind.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/gnatbind.adb Wed Apr 9 14:32:05 2008 @@ -206,6 +206,8 @@ ------------------- procedure Scan_Bind_Arg (Argv : String) is + -- LLVM local + pragma Assert (Argv'First = 1); begin -- Now scan arguments that are specific to the binder and are not -- handled by the common circuitry in Switch. Modified: llvm-gcc-4.2/trunk/gcc/ada/init.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/init.c?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/init.c (original) +++ llvm-gcc-4.2/trunk/gcc/ada/init.c Wed Apr 9 14:32:05 2008 @@ -95,6 +95,11 @@ char __gl_locking_policy = ' '; char __gl_queuing_policy = ' '; char __gl_task_dispatching_policy = ' '; +/* LLVM local begin */ +char *__gl_priority_specific_dispatching __attribute__ ((__weak__)) = 0; +int __gl_num_specific_dispatching __attribute__ ((__weak__)) = 0; +int system__restrictions__run_time_restrictions __attribute__ ((__weak__)) = 0; +/* LLVM local end */ char *__gl_restrictions = 0; char *__gl_interrupt_states = 0; int __gl_num_interrupt_states = 0; Modified: llvm-gcc-4.2/trunk/gcc/ada/krunch.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/krunch.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/krunch.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/krunch.adb Wed Apr 9 14:32:05 2008 @@ -40,6 +40,9 @@ No_Predef : Boolean) is + -- LLVM local + pragma Assert (Buffer'First = 1); + B1 : Character renames Buffer (1); Curlen : Natural; Krlen : Natural; Modified: llvm-gcc-4.2/trunk/gcc/ada/lib-util.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/lib-util.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/lib-util.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/lib-util.adb Wed Apr 9 14:32:05 2008 @@ -75,10 +75,12 @@ -- Start of processing for Write_Info_Char_Code begin - if Code in 16#00# .. 16#7F# then + -- LLVM local + if Code <= 16#7F# then Write_Info_Char (Character'Val (Code)); - elsif Code in 16#80# .. 16#FF# then + -- LLVM local + elsif Code <= 16#FF# then Write_Info_Char ('U'); Write_Info_Hex_Byte (Natural (Code)); Modified: llvm-gcc-4.2/trunk/gcc/ada/namet.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/namet.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/namet.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/namet.adb Wed Apr 9 14:32:05 2008 @@ -149,7 +149,8 @@ else Write_Str ("Hash_Table ("); - Write_Int (Int (J)); + -- LLVM local + Write_Int (J); Write_Str (") has "); declare Modified: llvm-gcc-4.2/trunk/gcc/ada/nlists.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/nlists.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/nlists.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/nlists.adb Wed Apr 9 14:32:05 2008 @@ -293,7 +293,8 @@ if List = No_List then return Empty; else - pragma Assert (List in First_List_Id .. Lists.Last); + -- LLVM local + pragma Assert (List <= Lists.Last); return Lists.Table (List).First; end if; end First; @@ -619,7 +620,8 @@ function Last (List : List_Id) return Node_Id is begin - pragma Assert (List in First_List_Id .. Lists.Last); + -- LLVM local + pragma Assert (List <= Lists.Last); return Lists.Table (List).Last; end Last; @@ -1017,7 +1019,8 @@ function Parent (List : List_Id) return Node_Id is begin - pragma Assert (List in First_List_Id .. Lists.Last); + -- LLVM local + pragma Assert (List <= Lists.Last); return Lists.Table (List).Parent; end Parent; @@ -1344,7 +1347,8 @@ procedure Set_Parent (List : List_Id; Node : Node_Id) is begin - pragma Assert (List in First_List_Id .. Lists.Last); + -- LLVM local + pragma Assert (List <= Lists.Last); Lists.Table (List).Parent := Node; end Set_Parent; Modified: llvm-gcc-4.2/trunk/gcc/ada/osint.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/osint.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/osint.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/osint.adb Wed Apr 9 14:32:05 2008 @@ -2124,6 +2124,8 @@ Status : Boolean; -- For the call to Close + -- LLVM local + pragma Warnings (Off, Status); begin Current_Full_Source_Name := Find_File (N, T); Modified: llvm-gcc-4.2/trunk/gcc/ada/par-ch3.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/par-ch3.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/par-ch3.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/par-ch3.adb Wed Apr 9 14:32:05 2008 @@ -4334,6 +4334,8 @@ procedure Skip_Declaration (S : List_Id) is Dummy_Done : Boolean; + -- LLVM local + pragma Warnings (Off, Dummy_Done); begin P_Declarative_Items (S, Dummy_Done, False); Modified: llvm-gcc-4.2/trunk/gcc/ada/par-util.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/par-util.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/par-util.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/par-util.adb Wed Apr 9 14:32:05 2008 @@ -61,7 +61,8 @@ end if; for J in S'Range loop - S (J) := Fold_Lower (Tname (Integer (J) + 4)); + -- LLVM local + S (J) := Fold_Lower (Tname (J + 4)); end loop; Get_Name_String (Token_Name); Modified: llvm-gcc-4.2/trunk/gcc/ada/rtsfind.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/rtsfind.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/rtsfind.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/rtsfind.adb Wed Apr 9 14:32:05 2008 @@ -1062,7 +1062,8 @@ -- Bump count of violations if we are in configurable run-time -- mode and this is not a continuation message. - if Configurable_Run_Time_Mode and then Msg (1) /= '\' then + -- LLVM local + if Configurable_Run_Time_Mode and then Msg (Msg'First) /= '\' then Configurable_Run_Time_Violations := Configurable_Run_Time_Violations + 1; end if; Modified: llvm-gcc-4.2/trunk/gcc/ada/scng.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/scng.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/scng.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/scng.adb Wed Apr 9 14:32:05 2008 @@ -477,7 +477,7 @@ UI_Int_Value := Uint_0; Scale := 0; Scan_Integer; - Scale := 0; + -- LLVM local deleted one line Point_Scanned := False; UI_Num_Value := UI_Int_Value; @@ -1140,7 +1140,11 @@ -- Horizontal tab, just skip past it when HT => - if Style_Check then Style.Check_HT; end if; + -- LLVM local begin + if Style_Check then + Style.Check_HT; + end if; + -- LLVM local end Scan_Ptr := Scan_Ptr + 1; -- End of file character, treated as an end of file only if it is @@ -1149,7 +1153,11 @@ when EOF => if Scan_Ptr = Source_Last (Current_Source_File) then Check_End_Of_Line; - if Style_Check then Style.Check_EOF; end if; + -- LLVM local begin + if Style_Check then + Style.Check_EOF; + end if; + -- LLVM local end Token := Tok_EOF; return; else @@ -1199,7 +1207,11 @@ if Double_Char_Token ('=') then Token := Tok_Colon_Equal; - if Style_Check then Style.Check_Colon_Equal; end if; + -- LLVM local begin + if Style_Check then + Style.Check_Colon_Equal; + end if; + -- LLVM local end return; elsif Source (Scan_Ptr + 1) = '-' @@ -1213,7 +1225,11 @@ else Scan_Ptr := Scan_Ptr + 1; Token := Tok_Colon; - if Style_Check then Style.Check_Colon; end if; + -- LLVM local begin + if Style_Check then + Style.Check_Colon; + end if; + -- LLVM local end return; end if; @@ -1223,7 +1239,11 @@ Accumulate_Checksum ('('); Scan_Ptr := Scan_Ptr + 1; Token := Tok_Left_Paren; - if Style_Check then Style.Check_Left_Paren; end if; + -- LLVM local begin + if Style_Check then + Style.Check_Left_Paren; + end if; + -- LLVM local end return; -- Left bracket @@ -1253,7 +1273,11 @@ Accumulate_Checksum (','); Scan_Ptr := Scan_Ptr + 1; Token := Tok_Comma; - if Style_Check then Style.Check_Comma; end if; + -- LLVM local begin + if Style_Check then + Style.Check_Comma; + end if; + -- LLVM local end return; -- Dot, which is either an isolated period, or part of a double dot @@ -1265,7 +1289,11 @@ if Double_Char_Token ('.') then Token := Tok_Dot_Dot; - if Style_Check then Style.Check_Dot_Dot; end if; + -- LLVM local begin + if Style_Check then + Style.Check_Dot_Dot; + end if; + -- LLVM local end return; elsif Source (Scan_Ptr + 1) in '0' .. '9' then @@ -1286,7 +1314,11 @@ if Double_Char_Token ('>') then Token := Tok_Arrow; - if Style_Check then Style.Check_Arrow; end if; + -- LLVM local begin + if Style_Check then + Style.Check_Arrow; + end if; + -- LLVM local end return; elsif Source (Scan_Ptr + 1) = '=' then @@ -1331,7 +1363,11 @@ elsif Double_Char_Token ('>') then Token := Tok_Box; - if Style_Check then Style.Check_Box; end if; + -- LLVM local begin + if Style_Check then + Style.Check_Box; + end if; + -- LLVM local end return; elsif Double_Char_Token ('<') then @@ -1363,7 +1399,11 @@ -- Comment else -- Source (Scan_Ptr + 1) = '-' then - if Style_Check then Style.Check_Comment; end if; + -- LLVM local begin + if Style_Check then + Style.Check_Comment; + end if; + -- LLVM local end Scan_Ptr := Scan_Ptr + 2; -- If we are in preprocessor mode with Replace_In_Comments set, @@ -1409,7 +1449,11 @@ -- Keep going if horizontal tab if Source (Scan_Ptr) = HT then - if Style_Check then Style.Check_HT; end if; + -- LLVM local begin + if Style_Check then + Style.Check_HT; + end if; + -- LLVM local end Scan_Ptr := Scan_Ptr + 1; -- Terminate scan of comment if line terminator @@ -1543,7 +1587,11 @@ or else Prev_Token in Token_Class_Literal then Token := Tok_Apostrophe; - if Style_Check then Style.Check_Apostrophe; end if; + -- LLVM local begin + if Style_Check then + Style.Check_Apostrophe; + end if; + -- LLVM local end return; -- Otherwise the apostrophe starts a character literal @@ -1648,7 +1696,11 @@ Accumulate_Checksum (')'); Scan_Ptr := Scan_Ptr + 1; Token := Tok_Right_Paren; - if Style_Check then Style.Check_Right_Paren; end if; + -- LLVM local begin + if Style_Check then + Style.Check_Right_Paren; + end if; + -- LLVM local end return; -- Right bracket or right brace, treated as right paren @@ -1679,7 +1731,11 @@ Accumulate_Checksum (';'); Scan_Ptr := Scan_Ptr + 1; Token := Tok_Semicolon; - if Style_Check then Style.Check_Semicolon; end if; + -- LLVM local begin + if Style_Check then + Style.Check_Semicolon; + end if; + -- LLVM local end return; -- Vertical bar @@ -1698,7 +1754,11 @@ else Scan_Ptr := Scan_Ptr + 1; Token := Tok_Vertical_Bar; - if Style_Check then Style.Check_Vertical_Bar; end if; + -- LLVM local begin + if Style_Check then + Style.Check_Vertical_Bar; + end if; + -- LLVM local end return; end if; end Vertical_Bar_Case; @@ -2385,7 +2445,11 @@ -- Outer loop keeps going only if a horizontal tab follows if Source (Scan_Ptr) = HT then - if Style_Check then Style.Check_HT; end if; + -- LLVM local begin + if Style_Check then + Style.Check_HT; + end if; + -- LLVM local end Scan_Ptr := Scan_Ptr + 1; Start_Column := (Start_Column / 8) * 8 + 8; else Modified: llvm-gcc-4.2/trunk/gcc/ada/sem_cat.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/sem_cat.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/sem_cat.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/sem_cat.adb Wed Apr 9 14:32:05 2008 @@ -1565,8 +1565,9 @@ -- If we have a true dereference that comes from source and that -- is a controlling argument for a dispatching call, accept it. - if K = N_Explicit_Dereference - and then Is_Actual_Parameter (N) + -- LLVM local begin + if Is_Actual_Parameter (N) + -- LLVM local end and then Is_Controlling_Actual (N) then return; Modified: llvm-gcc-4.2/trunk/gcc/ada/sem_ch3.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/sem_ch3.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/sem_ch3.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/sem_ch3.adb Wed Apr 9 14:32:05 2008 @@ -12723,7 +12723,7 @@ Ancestor := Etype (Ancestor); end loop; - return True; + -- LLVM local deleted unreachable line end; end if; end Is_Visible_Component; Modified: llvm-gcc-4.2/trunk/gcc/ada/sem_ch6.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/sem_ch6.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/sem_ch6.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/sem_ch6.adb Wed Apr 9 14:32:05 2008 @@ -2388,7 +2388,8 @@ -- Remove last character (question mark) to make this into an error, -- because the Inline_Always pragma cannot be obeyed. - Error_Msg_NE (Msg (1 .. Msg'Length - 1), N, Subp); + -- LLVM local + Error_Msg_NE (Msg (Msg'First .. Msg'Last - 1), N, Subp); elsif Ineffective_Inline_Warnings then Error_Msg_NE (Msg, N, Subp); @@ -2999,6 +3000,8 @@ Err_Loc : Node_Id := Empty) is Result : Boolean; + -- LLVM local + pragma Warnings (Off, Result); begin Check_Conformance (New_Id, Old_Id, Fully_Conformant, True, Result, Err_Loc); @@ -3015,6 +3018,8 @@ Get_Inst : Boolean := False) is Result : Boolean; + -- LLVM local + pragma Warnings (Off, Result); begin Check_Conformance @@ -3480,6 +3485,8 @@ Err_Loc : Node_Id := Empty) is Result : Boolean; + -- LLVM local + pragma Warnings (Off, Result); begin Check_Conformance (New_Id, Old_Id, Subtype_Conformant, True, Result, Err_Loc); @@ -3495,6 +3502,8 @@ Err_Loc : Node_Id := Empty) is Result : Boolean; + -- LLVM local + pragma Warnings (Off, Result); begin Check_Conformance (New_Id, Old_Id, Type_Conformant, True, Result, Err_Loc); Modified: llvm-gcc-4.2/trunk/gcc/ada/sem_elab.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/sem_elab.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/sem_elab.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/sem_elab.adb Wed Apr 9 14:32:05 2008 @@ -2824,7 +2824,7 @@ end if; end loop; - raise Program_Error; + -- LLVM local deleted unreachable line end Within; -------------------------- Modified: llvm-gcc-4.2/trunk/gcc/ada/sem_maps.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/sem_maps.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/sem_maps.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/sem_maps.adb Wed Apr 9 14:32:05 2008 @@ -55,7 +55,8 @@ --------------------- procedure Add_Association - (M : in out Map; + -- LLVM local + (M : Map; O_Id : Entity_Id; N_Id : Entity_Id; Kind : Scope_Kind := S_Local) @@ -318,7 +319,8 @@ ------------------------ procedure Update_Association - (M : in out Map; + -- LLVM local + (M : Map; O_Id : Entity_Id; N_Id : Entity_Id; Kind : Scope_Kind := S_Local) Modified: llvm-gcc-4.2/trunk/gcc/ada/sem_maps.ads URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/sem_maps.ads?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/sem_maps.ads (original) +++ llvm-gcc-4.2/trunk/gcc/ada/sem_maps.ads Wed Apr 9 14:32:05 2008 @@ -64,14 +64,16 @@ -- Retrieve image of E under M, Empty if undefined procedure Add_Association - (M : in out Map; + -- LLVM local + (M : Map; O_Id : Entity_Id; N_Id : Entity_Id; Kind : Scope_Kind := S_Local); -- Update M in place. On entry M (O_Id) must not be defined procedure Update_Association - (M : in out Map; + -- LLVM local + (M : Map; O_Id : Entity_Id; N_Id : Entity_Id; Kind : Scope_Kind := S_Local); Modified: llvm-gcc-4.2/trunk/gcc/ada/sem_res.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/sem_res.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/sem_res.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/sem_res.adb Wed Apr 9 14:32:05 2008 @@ -1363,23 +1363,42 @@ begin if Is_Binary then - if Op_Name = Name_Op_And then Kind := N_Op_And; - elsif Op_Name = Name_Op_Or then Kind := N_Op_Or; - elsif Op_Name = Name_Op_Xor then Kind := N_Op_Xor; - elsif Op_Name = Name_Op_Eq then Kind := N_Op_Eq; - elsif Op_Name = Name_Op_Ne then Kind := N_Op_Ne; - elsif Op_Name = Name_Op_Lt then Kind := N_Op_Lt; - elsif Op_Name = Name_Op_Le then Kind := N_Op_Le; - elsif Op_Name = Name_Op_Gt then Kind := N_Op_Gt; - elsif Op_Name = Name_Op_Ge then Kind := N_Op_Ge; - elsif Op_Name = Name_Op_Add then Kind := N_Op_Add; - elsif Op_Name = Name_Op_Subtract then Kind := N_Op_Subtract; - elsif Op_Name = Name_Op_Concat then Kind := N_Op_Concat; - elsif Op_Name = Name_Op_Multiply then Kind := N_Op_Multiply; - elsif Op_Name = Name_Op_Divide then Kind := N_Op_Divide; - elsif Op_Name = Name_Op_Mod then Kind := N_Op_Mod; - elsif Op_Name = Name_Op_Rem then Kind := N_Op_Rem; - elsif Op_Name = Name_Op_Expon then Kind := N_Op_Expon; + -- LLVM local begin + if Op_Name = Name_Op_And then + Kind := N_Op_And; + elsif Op_Name = Name_Op_Or then + Kind := N_Op_Or; + elsif Op_Name = Name_Op_Xor then + Kind := N_Op_Xor; + elsif Op_Name = Name_Op_Eq then + Kind := N_Op_Eq; + elsif Op_Name = Name_Op_Ne then + Kind := N_Op_Ne; + elsif Op_Name = Name_Op_Lt then + Kind := N_Op_Lt; + elsif Op_Name = Name_Op_Le then + Kind := N_Op_Le; + elsif Op_Name = Name_Op_Gt then + Kind := N_Op_Gt; + elsif Op_Name = Name_Op_Ge then + Kind := N_Op_Ge; + elsif Op_Name = Name_Op_Add then + Kind := N_Op_Add; + elsif Op_Name = Name_Op_Subtract then + Kind := N_Op_Subtract; + elsif Op_Name = Name_Op_Concat then + Kind := N_Op_Concat; + elsif Op_Name = Name_Op_Multiply then + Kind := N_Op_Multiply; + elsif Op_Name = Name_Op_Divide then + Kind := N_Op_Divide; + elsif Op_Name = Name_Op_Mod then + Kind := N_Op_Mod; + elsif Op_Name = Name_Op_Rem then + Kind := N_Op_Rem; + elsif Op_Name = Name_Op_Expon then + Kind := N_Op_Expon; + -- LLVM local end else raise Program_Error; end if; @@ -1387,10 +1406,16 @@ -- Unary operators else - if Op_Name = Name_Op_Add then Kind := N_Op_Plus; - elsif Op_Name = Name_Op_Subtract then Kind := N_Op_Minus; - elsif Op_Name = Name_Op_Abs then Kind := N_Op_Abs; - elsif Op_Name = Name_Op_Not then Kind := N_Op_Not; + -- LLVM local begin + if Op_Name = Name_Op_Add then + Kind := N_Op_Plus; + elsif Op_Name = Name_Op_Subtract then + Kind := N_Op_Minus; + elsif Op_Name = Name_Op_Abs then + Kind := N_Op_Abs; + elsif Op_Name = Name_Op_Not then + Kind := N_Op_Not; + -- LLVM local end else raise Program_Error; end if; Modified: llvm-gcc-4.2/trunk/gcc/ada/sem_type.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/sem_type.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/sem_type.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/sem_type.adb Wed Apr 9 14:32:05 2008 @@ -2254,8 +2254,10 @@ then return False; - else return - Is_Numeric_Type (T) + -- LLVM local begin + else + return Is_Numeric_Type (T) + -- LLVM local end and then not In_Open_Scopes (Scope (T)) and then not Is_Potentially_Use_Visible (T) and then not In_Use (T) Modified: llvm-gcc-4.2/trunk/gcc/ada/sem_util.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/sem_util.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/sem_util.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/sem_util.adb Wed Apr 9 14:32:05 2008 @@ -1130,7 +1130,8 @@ -- Message is a warning, even in Ada 95 case - if Msg (Msg'Length) = '?' then + -- LLVM local + if Msg (Msg'Last) = '?' then Wmsg := True; -- In Ada 83, all messages are warnings. In the private part and @@ -3835,7 +3836,7 @@ end loop; end if; - raise Program_Error; + -- LLVM local deleted unreachable line end Is_Descendent_Of; ------------------------------ Modified: llvm-gcc-4.2/trunk/gcc/ada/sprint.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/sprint.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/sprint.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/sprint.adb Wed Apr 9 14:32:05 2008 @@ -3694,8 +3694,10 @@ if Int (S'Last) + Column > Line_Limit then Write_Indent_Str (" "); - if S (1) = ' ' then - Write_Str (S (2 .. S'Length)); + -- LLVM local begin + if S (S'First) = ' ' then + Write_Str (S (S'First + 1 .. S'Last)); + -- LLVM local end else Write_Str (S); end if; @@ -3714,8 +3716,10 @@ if Int (S'Last) + Column > Line_Limit then Write_Indent_Str (" "); - if S (1) = ' ' then - Write_Str_Sloc (S (2 .. S'Length)); + -- LLVM local begin + if S (S'First) = ' ' then + Write_Str_Sloc (S (S'First + 1 .. S'Last)); + -- LLVM local end else Write_Str_Sloc (S); end if; Modified: llvm-gcc-4.2/trunk/gcc/ada/uintp.adb URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/uintp.adb?rev=49444&r1=49443&r2=49444&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/uintp.adb (original) +++ llvm-gcc-4.2/trunk/gcc/ada/uintp.adb Wed Apr 9 14:32:05 2008 @@ -1071,7 +1071,11 @@ X_Bigger := True; else Sum_Length := R_Length + 1; - if R_Length > L_Length then Y_Bigger := True; end if; + -- LLVM local begin + if R_Length > L_Length then + Y_Bigger := True; + end if; + -- LLVM local end end if; -- Make copies of the absolute values of L_Vec and R_Vec into From gohman at apple.com Wed Apr 9 15:08:06 2008 From: gohman at apple.com (Dan Gohman) Date: Wed, 09 Apr 2008 20:08:06 -0000 Subject: [llvm-commits] [llvm] r49445 - /llvm/trunk/include/llvm/Target/TargetInstrDesc.h Message-ID: <200804092008.m39K865m004362@zion.cs.uiuc.edu> Author: djg Date: Wed Apr 9 15:08:06 2008 New Revision: 49445 URL: http://llvm.org/viewvc/llvm-project?rev=49445&view=rev Log: Fix some minor errors in comments. Modified: llvm/trunk/include/llvm/Target/TargetInstrDesc.h Modified: llvm/trunk/include/llvm/Target/TargetInstrDesc.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrDesc.h?rev=49445&r1=49444&r2=49445&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetInstrDesc.h (original) +++ llvm/trunk/include/llvm/Target/TargetInstrDesc.h Wed Apr 9 15:08:06 2008 @@ -174,7 +174,7 @@ return Flags & (1 << TID::HasOptionalDef); } - /// getImplicitUses - Return a list of machine operands that are potentially + /// getImplicitUses - Return a list of registers that are potentially /// read by any instance of this machine instruction. For example, on X86, /// the "adc" instruction adds two register operands and adds the carry bit in /// from the flags register. In this case, the instruction is marked as @@ -187,7 +187,7 @@ return ImplicitUses; } - /// getImplicitDefs - Return a list of machine operands that are potentially + /// getImplicitDefs - Return a list of registers that are potentially /// written by any instance of this machine instruction. For example, on X86, /// many instructions implicitly set the flags register. In this case, they /// are marked as setting the FLAGS. Likewise, many instructions always @@ -196,7 +196,7 @@ /// registers. For that instruction, this will return a list containing the /// EAX/EDX/EFLAGS registers. /// - /// This method returns null if the instruction has no implicit uses. + /// This method returns null if the instruction has no implicit defs. const unsigned *getImplicitDefs() const { return ImplicitDefs; } From gohman at apple.com Wed Apr 9 15:09:42 2008 From: gohman at apple.com (Dan Gohman) Date: Wed, 09 Apr 2008 20:09:42 -0000 Subject: [llvm-commits] [llvm] r49446 - in /llvm/trunk: include/llvm/Target/TargetLowering.h lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.h Message-ID: <200804092009.m39K9hV3004458@zion.cs.uiuc.edu> Author: djg Date: Wed Apr 9 15:09:42 2008 New Revision: 49446 URL: http://llvm.org/viewvc/llvm-project?rev=49446&view=rev Log: Make isVectorClearMaskLegal's operand list const. Modified: llvm/trunk/include/llvm/Target/TargetLowering.h llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=49446&r1=49445&r2=49446&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Wed Apr 9 15:09:42 2008 @@ -268,7 +268,7 @@ /// used by Targets can use this to indicate if there is a suitable /// VECTOR_SHUFFLE that can be used to replace a VAND with a constant /// pool entry. - virtual bool isVectorClearMaskLegal(std::vector &BVOps, + virtual bool isVectorClearMaskLegal(const std::vector &BVOps, MVT::ValueType EVT, SelectionDAG &DAG) const { return false; Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=49446&r1=49445&r2=49446&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Apr 9 15:09:42 2008 @@ -5602,9 +5602,10 @@ X86::isUNPCKH_v_undef_Mask(Mask.Val)); } -bool X86TargetLowering::isVectorClearMaskLegal(std::vector &BVOps, - MVT::ValueType EVT, - SelectionDAG &DAG) const { +bool +X86TargetLowering::isVectorClearMaskLegal(const std::vector &BVOps, + MVT::ValueType EVT, + SelectionDAG &DAG) const { unsigned NumElts = BVOps.size(); // Only do shuffles on 128-bit vector types for now. if (MVT::getSizeInBits(EVT) * NumElts == 64) return false; Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=49446&r1=49445&r2=49446&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Wed Apr 9 15:09:42 2008 @@ -420,7 +420,7 @@ /// used by Targets can use this to indicate if there is a suitable /// VECTOR_SHUFFLE that can be used to replace a VAND with a constant /// pool entry. - virtual bool isVectorClearMaskLegal(std::vector &BVOps, + virtual bool isVectorClearMaskLegal(const std::vector &BVOps, MVT::ValueType EVT, SelectionDAG &DAG) const; From evan.cheng at apple.com Wed Apr 9 15:42:49 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 09 Apr 2008 20:42:49 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49447 - /llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Message-ID: <200804092042.m39Kgn8T005595@zion.cs.uiuc.edu> Author: evancheng Date: Wed Apr 9 15:42:48 2008 New Revision: 49447 URL: http://llvm.org/viewvc/llvm-project?rev=49447&view=rev Log: Unbreak Apple style build. Modified: llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp?rev=49447&r1=49446&r2=49447&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Wed Apr 9 15:42:48 2008 @@ -82,6 +82,7 @@ llvm::createDeadStoreEliminationPass(); llvm::createIPConstantPropagationPass(); llvm::createStripDeadPrototypesPass(); + llvm::createMemCpyOptPass(); } /* LLVM LOCAL end (ENTIRE FILE!) */ From evan.cheng at apple.com Wed Apr 9 15:57:25 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 09 Apr 2008 20:57:25 -0000 Subject: [llvm-commits] [llvm] r49448 - in /llvm/trunk: lib/CodeGen/LiveIntervalAnalysis.cpp lib/CodeGen/SimpleRegisterCoalescing.cpp lib/CodeGen/SimpleRegisterCoalescing.h test/CodeGen/X86/ins_subreg_coalesce-1.ll test/CodeGen/X86/ins_subreg_coalesce-2.ll test/CodeGen/X86/ins_subreg_coalesce-3.ll Message-ID: <200804092057.m39KvPmY005987@zion.cs.uiuc.edu> Author: evancheng Date: Wed Apr 9 15:57:25 2008 New Revision: 49448 URL: http://llvm.org/viewvc/llvm-project?rev=49448&view=rev Log: - More aggressively coalescing away copies whose source is defined by an implicit_def. - Added insert_subreg coalescing support. Added: llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-1.ll llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-2.ll llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-3.ll Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=49448&r1=49447&r2=49448&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Apr 9 15:57:25 2008 @@ -217,6 +217,7 @@ MachineInstr *CopyMI = NULL; unsigned SrcReg, DstReg; if (mi->getOpcode() == TargetInstrInfo::EXTRACT_SUBREG || + mi->getOpcode() == TargetInstrInfo::INSERT_SUBREG || tii_->isMoveInstr(*mi, SrcReg, DstReg)) CopyMI = mi; ValNo = interval.getNextValue(defIndex, CopyMI, VNInfoAllocator); @@ -372,6 +373,7 @@ MachineInstr *CopyMI = NULL; unsigned SrcReg, DstReg; if (mi->getOpcode() == TargetInstrInfo::EXTRACT_SUBREG || + mi->getOpcode() == TargetInstrInfo::INSERT_SUBREG || tii_->isMoveInstr(*mi, SrcReg, DstReg)) CopyMI = mi; ValNo = interval.getNextValue(defIndex, CopyMI, VNInfoAllocator); @@ -459,6 +461,7 @@ MachineInstr *CopyMI = NULL; unsigned SrcReg, DstReg; if (MI->getOpcode() == TargetInstrInfo::EXTRACT_SUBREG || + MI->getOpcode() == TargetInstrInfo::INSERT_SUBREG || tii_->isMoveInstr(*MI, SrcReg, DstReg)) CopyMI = MI; handlePhysicalRegisterDef(MBB, MI, MIIdx, getOrCreateInterval(reg), CopyMI); @@ -594,6 +597,8 @@ if (VNI->copy->getOpcode() == TargetInstrInfo::EXTRACT_SUBREG) return VNI->copy->getOperand(1).getReg(); + if (VNI->copy->getOpcode() == TargetInstrInfo::INSERT_SUBREG) + return VNI->copy->getOperand(2).getReg(); unsigned SrcReg, DstReg; if (tii_->isMoveInstr(*VNI->copy, SrcReg, DstReg)) return SrcReg; @@ -949,6 +954,8 @@ HasUse = false; HasDef = false; CanFold = false; + if (isRemoved(MI)) + break; goto RestartInstruction; } } else { @@ -1106,7 +1113,7 @@ unsigned end = getBaseIndex(I->end-1) + InstrSlots::NUM; // First collect all the def / use in this live range that will be rewritten. - // Make sure they are sorted according instruction index. + // Make sure they are sorted according to instruction index. std::vector RewriteMIs; for (MachineRegisterInfo::reg_iterator ri = mri_->reg_begin(li.reg), re = mri_->reg_end(); ri != re; ) { @@ -1533,7 +1540,7 @@ } } - // Else tell the spiller to issue a spill. + // Otherwise tell the spiller to issue a spill. if (!Folded) { LiveRange *LR = &nI.ranges[nI.ranges.size()-1]; bool isKill = LR->end == getStoreIndex(index); Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=49448&r1=49447&r2=49448&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Wed Apr 9 15:57:25 2008 @@ -404,7 +404,7 @@ /// isBackEdgeCopy - Returns true if CopyMI is a back edge copy. /// bool SimpleRegisterCoalescing::isBackEdgeCopy(MachineInstr *CopyMI, - unsigned DstReg) { + unsigned DstReg) const { MachineBasicBlock *MBB = CopyMI->getParent(); const MachineLoop *L = loopInfo->getLoopFor(MBB); if (!L) @@ -471,6 +471,35 @@ } } +/// RemoveDeadImpDef - Remove implicit_def instructions which are "re-defining" +/// registers due to insert_subreg coalescing. e.g. +/// r1024 = op +/// r1025 = implicit_def +/// r1025 = insert_subreg r1025, r1024 +/// = op r1025 +/// => +/// r1025 = op +/// r1025 = implicit_def +/// r1025 = insert_subreg r1025, r1025 +/// = op r1025 +void +SimpleRegisterCoalescing::RemoveDeadImpDef(unsigned Reg, LiveInterval &LI) { + for (MachineRegisterInfo::reg_iterator I = mri_->reg_begin(Reg), + E = mri_->reg_end(); I != E; ) { + MachineOperand &O = I.getOperand(); + MachineInstr *DefMI = &*I; + ++I; + if (!O.isDef()) + continue; + if (DefMI->getOpcode() != TargetInstrInfo::IMPLICIT_DEF) + continue; + if (!LI.liveBeforeAndAt(li_->getInstructionIndex(DefMI))) + continue; + li_->RemoveMachineInstrFromMaps(DefMI); + DefMI->eraseFromParent(); + } +} + /// RemoveUnnecessaryKills - Remove kill markers that are no longer accurate /// due to live range lengthening as the result of coalescing. void SimpleRegisterCoalescing::RemoveUnnecessaryKills(unsigned Reg, @@ -641,6 +670,82 @@ removeIntervalIfEmpty(li, li_, tri_); } +/// CanCoalesceWithImpDef - Returns true if the specified copy instruction +/// from an implicit def to another register can be coalesced away. +bool SimpleRegisterCoalescing::CanCoalesceWithImpDef(MachineInstr *CopyMI, + LiveInterval &li, + LiveInterval &ImpLi) const{ + if (!CopyMI->killsRegister(ImpLi.reg)) + return false; + unsigned CopyIdx = li_->getDefIndex(li_->getInstructionIndex(CopyMI)); + LiveInterval::iterator LR = li.FindLiveRangeContaining(CopyIdx); + if (LR == li.end()) + return false; + if (LR->valno->hasPHIKill) + return false; + if (LR->valno->def != CopyIdx) + return false; + // Make sure all of val# uses are copies. + for (MachineRegisterInfo::use_iterator UI = mri_->use_begin(li.reg), + UE = mri_->use_end(); UI != UE;) { + MachineInstr *UseMI = &*UI; + ++UI; + if (JoinedCopies.count(UseMI)) + continue; + unsigned UseIdx = li_->getUseIndex(li_->getInstructionIndex(UseMI)); + LiveInterval::iterator ULR = li.FindLiveRangeContaining(UseIdx); + if (ULR->valno != LR->valno) + continue; + // If the use is not a use, then it's not safe to coalesce the move. + unsigned SrcReg, DstReg; + if (!tii_->isMoveInstr(*UseMI, SrcReg, DstReg)) { + if (UseMI->getOpcode() == TargetInstrInfo::INSERT_SUBREG && + UseMI->getOperand(1).getReg() == li.reg) + continue; + return false; + } + } + return true; +} + + +/// RemoveCopiesFromValNo - The specified value# is defined by an implicit +/// def and it is being removed. Turn all copies from this value# into +/// identity copies so they will be removed. +void SimpleRegisterCoalescing::RemoveCopiesFromValNo(LiveInterval &li, + VNInfo *VNI) { + for (MachineRegisterInfo::use_iterator UI = mri_->use_begin(li.reg), + UE = mri_->use_end(); UI != UE;) { + MachineOperand &UseMO = UI.getOperand(); + MachineInstr *UseMI = &*UI; + ++UI; + if (JoinedCopies.count(UseMI)) + continue; + unsigned UseIdx = li_->getUseIndex(li_->getInstructionIndex(UseMI)); + LiveInterval::iterator ULR = li.FindLiveRangeContaining(UseIdx); + if (ULR->valno != VNI) + continue; + if (UseMI->getOpcode() == TargetInstrInfo::INSERT_SUBREG) + continue; + // If the use is a copy, turn it into an identity copy. + unsigned SrcReg, DstReg; + if (!tii_->isMoveInstr(*UseMI, SrcReg, DstReg) || SrcReg != li.reg) + assert(0 && "Unexpected use of implicit def!"); + UseMO.setReg(DstReg); + JoinedCopies.insert(UseMI); + } +} + +static unsigned getMatchingSuperReg(unsigned Reg, unsigned SubIdx, + const TargetRegisterClass *RC, + const TargetRegisterInfo* TRI) { + for (const unsigned *SRs = TRI->getSuperRegisters(Reg); + unsigned SR = *SRs; ++SRs) + if (Reg == TRI->getSubReg(SR, SubIdx) && RC->contains(SR)) + return SR; + return 0; +} + /// JoinCopy - Attempt to join intervals corresponding to SrcReg/DstReg, /// which are the src/dst of the copy instruction CopyMI. This returns true /// if the copy was successfully coalesced away. If it is not currently @@ -658,10 +763,19 @@ unsigned SrcReg; unsigned DstReg; bool isExtSubReg = CopyMI->getOpcode() == TargetInstrInfo::EXTRACT_SUBREG; + bool isInsSubReg = CopyMI->getOpcode() == TargetInstrInfo::INSERT_SUBREG; unsigned SubIdx = 0; if (isExtSubReg) { DstReg = CopyMI->getOperand(0).getReg(); SrcReg = CopyMI->getOperand(1).getReg(); + } else if (isInsSubReg) { + if (CopyMI->getOperand(2).getSubReg()) { + DOUT << "\tSource of insert_subreg is already coalesced " + << "to another register.\n"; + return false; // Not coalescable. + } + DstReg = CopyMI->getOperand(0).getReg(); + SrcReg = CopyMI->getOperand(2).getReg(); } else if (!tii_->isMoveInstr(*CopyMI, SrcReg, DstReg)) { assert(0 && "Unrecognized copy instruction!"); return false; @@ -693,39 +807,46 @@ } unsigned RealDstReg = 0; - if (isExtSubReg) { - SubIdx = CopyMI->getOperand(2).getImm(); - if (SrcIsPhys) { + unsigned RealSrcReg = 0; + if (isExtSubReg || isInsSubReg) { + SubIdx = CopyMI->getOperand(isExtSubReg ? 2 : 3).getImm(); + if (SrcIsPhys && isExtSubReg) { // r1024 = EXTRACT_SUBREG EAX, 0 then r1024 is really going to be // coalesced with AX. SrcReg = tri_->getSubReg(SrcReg, SubIdx); SubIdx = 0; - } else if (DstIsPhys) { + } else if (DstIsPhys && isInsSubReg) { + // EAX = INSERT_SUBREG EAX, r1024, 0 + DstReg = tri_->getSubReg(DstReg, SubIdx); + SubIdx = 0; + } else if ((DstIsPhys && isExtSubReg) || (SrcIsPhys && isInsSubReg)) { // If this is a extract_subreg where dst is a physical register, e.g. // cl = EXTRACT_SUBREG reg1024, 1 // then create and update the actual physical register allocated to RHS. - const TargetRegisterClass *RC = mri_->getRegClass(SrcReg); - for (const unsigned *SRs = tri_->getSuperRegisters(DstReg); - unsigned SR = *SRs; ++SRs) { - if (DstReg == tri_->getSubReg(SR, SubIdx) && - RC->contains(SR)) { - RealDstReg = SR; - break; - } + // Ditto for + // reg1024 = INSERT_SUBREG r1024, cl, 1 + const TargetRegisterClass *RC = + mri_->getRegClass(isExtSubReg ? SrcReg : DstReg); + if (isExtSubReg) { + RealDstReg = getMatchingSuperReg(DstReg, SubIdx, RC, tri_); + assert(RealDstReg && "Invalid extra_subreg instruction!"); + } else { + RealSrcReg = getMatchingSuperReg(SrcReg, SubIdx, RC, tri_); + assert(RealSrcReg && "Invalid extra_subreg instruction!"); } - assert(RealDstReg && "Invalid extra_subreg instruction!"); // For this type of EXTRACT_SUBREG, conservatively // check if the live interval of the source register interfere with the // actual super physical register we are trying to coalesce with. - LiveInterval &RHS = li_->getInterval(SrcReg); - if (li_->hasInterval(RealDstReg) && - RHS.overlaps(li_->getInterval(RealDstReg))) { + unsigned PhysReg = isExtSubReg ? RealDstReg : RealSrcReg; + LiveInterval &RHS = li_->getInterval(isExtSubReg ? SrcReg : DstReg); + if (li_->hasInterval(PhysReg) && + RHS.overlaps(li_->getInterval(PhysReg))) { DOUT << "Interfere with register "; - DEBUG(li_->getInterval(RealDstReg).print(DOUT, tri_)); + DEBUG(li_->getInterval(PhysReg).print(DOUT, tri_)); return false; // Not coalescable } - for (const unsigned* SR = tri_->getSubRegisters(RealDstReg); *SR; ++SR) + for (const unsigned* SR = tri_->getSubRegisters(PhysReg); *SR; ++SR) if (li_->hasInterval(*SR) && RHS.overlaps(li_->getInterval(*SR))) { DOUT << "Interfere with sub-register "; DEBUG(li_->getInterval(*SR).print(DOUT, tri_)); @@ -733,17 +854,22 @@ } SubIdx = 0; } else { - unsigned SrcSize= li_->getInterval(SrcReg).getSize() / InstrSlots::NUM; - unsigned DstSize= li_->getInterval(DstReg).getSize() / InstrSlots::NUM; - const TargetRegisterClass *RC = mri_->getRegClass(DstReg); + unsigned LargeReg = isExtSubReg ? SrcReg : DstReg; + unsigned SmallReg = isExtSubReg ? DstReg : SrcReg; + unsigned LargeRegSize = + li_->getInterval(LargeReg).getSize() / InstrSlots::NUM; + unsigned SmallRegSize = + li_->getInterval(SmallReg).getSize() / InstrSlots::NUM; + const TargetRegisterClass *RC = mri_->getRegClass(SmallReg); unsigned Threshold = allocatableRCRegs_[RC].count(); // Be conservative. If both sides are virtual registers, do not coalesce // if this will cause a high use density interval to target a smaller set // of registers. - if (DstSize > Threshold || SrcSize > Threshold) { - LiveVariables::VarInfo &svi = lv_->getVarInfo(SrcReg); - LiveVariables::VarInfo &dvi = lv_->getVarInfo(DstReg); - if ((float)dvi.NumUses / DstSize < (float)svi.NumUses / SrcSize) { + if (SmallRegSize > Threshold || LargeRegSize > Threshold) { + LiveVariables::VarInfo &svi = lv_->getVarInfo(LargeReg); + LiveVariables::VarInfo &dvi = lv_->getVarInfo(SmallReg); + if ((float)dvi.NumUses / SmallRegSize < + (float)svi.NumUses / LargeRegSize) { Again = true; // May be possible to coalesce later. return false; } @@ -777,34 +903,36 @@ DOUT << ": "; // Check if it is necessary to propagate "isDead" property. - MachineOperand *mopd = CopyMI->findRegisterDefOperand(DstReg, false); - bool isDead = mopd->isDead(); - - // We need to be careful about coalescing a source physical register with a - // virtual register. Once the coalescing is done, it cannot be broken and - // these are not spillable! If the destination interval uses are far away, - // think twice about coalescing them! - if (!isDead && (SrcIsPhys || DstIsPhys) && !isExtSubReg) { - LiveInterval &JoinVInt = SrcIsPhys ? DstInt : SrcInt; - unsigned JoinVReg = SrcIsPhys ? DstReg : SrcReg; - unsigned JoinPReg = SrcIsPhys ? SrcReg : DstReg; - const TargetRegisterClass *RC = mri_->getRegClass(JoinVReg); - unsigned Threshold = allocatableRCRegs_[RC].count() * 2; - if (TheCopy.isBackEdge) - Threshold *= 2; // Favors back edge copies. - - // If the virtual register live interval is long but it has low use desity, - // do not join them, instead mark the physical register as its allocation - // preference. - unsigned Length = JoinVInt.getSize() / InstrSlots::NUM; - LiveVariables::VarInfo &vi = lv_->getVarInfo(JoinVReg); - if (Length > Threshold && - (((float)vi.NumUses / Length) < (1.0 / Threshold))) { - JoinVInt.preference = JoinPReg; - ++numAborts; - DOUT << "\tMay tie down a physical register, abort!\n"; - Again = true; // May be possible to coalesce later. - return false; + if (!isExtSubReg && !isInsSubReg) { + MachineOperand *mopd = CopyMI->findRegisterDefOperand(DstReg, false); + bool isDead = mopd->isDead(); + + // We need to be careful about coalescing a source physical register with a + // virtual register. Once the coalescing is done, it cannot be broken and + // these are not spillable! If the destination interval uses are far away, + // think twice about coalescing them! + if (!isDead && (SrcIsPhys || DstIsPhys)) { + LiveInterval &JoinVInt = SrcIsPhys ? DstInt : SrcInt; + unsigned JoinVReg = SrcIsPhys ? DstReg : SrcReg; + unsigned JoinPReg = SrcIsPhys ? SrcReg : DstReg; + const TargetRegisterClass *RC = mri_->getRegClass(JoinVReg); + unsigned Threshold = allocatableRCRegs_[RC].count() * 2; + if (TheCopy.isBackEdge) + Threshold *= 2; // Favors back edge copies. + + // If the virtual register live interval is long but it has low use desity, + // do not join them, instead mark the physical register as its allocation + // preference. + unsigned Length = JoinVInt.getSize() / InstrSlots::NUM; + LiveVariables::VarInfo &vi = lv_->getVarInfo(JoinVReg); + if (Length > Threshold && + (((float)vi.NumUses / Length) < (1.0 / Threshold))) { + JoinVInt.preference = JoinPReg; + ++numAborts; + DOUT << "\tMay tie down a physical register, abort!\n"; + Again = true; // May be possible to coalesce later. + return false; + } } } @@ -815,9 +943,10 @@ bool Swapped = false; // If SrcInt is implicitly defined, it's safe to coalesce. bool isEmpty = SrcInt.empty(); - if (isEmpty && DstInt.getNumValNums() != 1) { + if (isEmpty && !CanCoalesceWithImpDef(CopyMI, DstInt, SrcInt)) { // Only coalesce an empty interval (defined by implicit_def) with - // another interval that's defined by a single copy. + // another interval which has a valno defined by the CopyMI and the CopyMI + // is a kill of the implicit def. DOUT << "Not profitable!\n"; return false; } @@ -826,7 +955,7 @@ // Coalescing failed. // If we can eliminate the copy without merging the live ranges, do so now. - if (!isExtSubReg && + if (!isExtSubReg && !isInsSubReg && (AdjustCopiesBackFrom(SrcInt, DstInt, CopyMI) || RemoveCopyByCommutingDef(SrcInt, DstInt, CopyMI))) { JoinedCopies.insert(CopyMI); @@ -855,8 +984,9 @@ // If this is a extract_subreg where dst is a physical register, e.g. // cl = EXTRACT_SUBREG reg1024, 1 // then create and update the actual physical register allocated to RHS. - if (RealDstReg) { - LiveInterval &RealDstInt = li_->getOrCreateInterval(RealDstReg); + if (RealDstReg || RealSrcReg) { + LiveInterval &RealInt = + li_->getOrCreateInterval(RealDstReg ? RealDstReg : RealSrcReg); SmallSet CopiedValNos; for (LiveInterval::Ranges::const_iterator I = ResSrcInt->ranges.begin(), E = ResSrcInt->ranges.end(); I != E; ++I) { @@ -865,14 +995,15 @@ assert(DstLR != ResDstInt->end() && "Invalid joined interval!"); const VNInfo *DstValNo = DstLR->valno; if (CopiedValNos.insert(DstValNo)) { - VNInfo *ValNo = RealDstInt.getNextValue(DstValNo->def, DstValNo->copy, - li_->getVNInfoAllocator()); + VNInfo *ValNo = RealInt.getNextValue(DstValNo->def, DstValNo->copy, + li_->getVNInfoAllocator()); ValNo->hasPHIKill = DstValNo->hasPHIKill; - RealDstInt.addKills(ValNo, DstValNo->kills); - RealDstInt.MergeValueInAsValue(*ResDstInt, DstValNo, ValNo); + RealInt.addKills(ValNo, DstValNo->kills); + RealInt.MergeValueInAsValue(*ResDstInt, DstValNo, ValNo); } } - DstReg = RealDstReg; + + DstReg = RealDstReg ? RealDstReg : RealSrcReg; } // Update the liveintervals of sub-registers. @@ -888,8 +1019,8 @@ // If this is a EXTRACT_SUBREG, make sure the result of coalescing is the // larger super-register. - if (isExtSubReg && !SrcIsPhys && !DstIsPhys) { - if (!Swapped) { + if ((isExtSubReg || isInsSubReg) && !SrcIsPhys && !DstIsPhys) { + if ((isExtSubReg && !Swapped) || (isInsSubReg && Swapped)) { ResSrcInt->Copy(*ResDstInt, li_->getVNInfoAllocator()); std::swap(SrcReg, DstReg); std::swap(ResSrcInt, ResDstInt); @@ -927,6 +1058,13 @@ // SrcReg is guarateed to be the register whose live interval that is // being merged. li_->removeInterval(SrcReg); + if (isInsSubReg) + // Avoid: + // r1024 = op + // r1024 = implicit_def + // ... + // = r1024 + RemoveDeadImpDef(DstReg, *ResDstInt); UpdateRegDefsUses(SrcReg, DstReg, SubIdx); if (isEmpty) { @@ -937,7 +1075,19 @@ LiveInterval::iterator LR = ResDstInt->FindLiveRangeContaining(CopyIdx); VNInfo *ImpVal = LR->valno; assert(ImpVal->def == CopyIdx); + unsigned NextDef = LR->end; + RemoveCopiesFromValNo(*ResDstInt, ImpVal); ResDstInt->removeValNo(ImpVal); + LR = ResDstInt->FindLiveRangeContaining(NextDef); + if (LR != ResDstInt->end() && LR->valno->def == NextDef) { + // Special case: vr1024 = implicit_def + // vr1024 = insert_subreg vr1024, vr1025, c + // The insert_subreg becomes a "copy" that defines a val# which can itself + // be coalesced away. + MachineInstr *DefMI = li_->getInstructionFromIndex(NextDef); + if (DefMI->getOpcode() == TargetInstrInfo::INSERT_SUBREG) + LR->valno->copy = DefMI; + } } DOUT << "\n\t\tJoined. Result = "; ResDstInt->print(DOUT, tri_); @@ -1002,6 +1152,33 @@ return std::find(V.begin(), V.end(), Val) != V.end(); } +/// RangeIsDefinedByCopyFromReg - Return true if the specified live range of +/// the specified live interval is defined by a copy from the specified +/// register. +bool SimpleRegisterCoalescing::RangeIsDefinedByCopyFromReg(LiveInterval &li, + LiveRange *LR, + unsigned Reg) { + unsigned SrcReg = li_->getVNInfoSourceReg(LR->valno); + if (SrcReg == Reg) + return true; + if (LR->valno->def == ~0U && + TargetRegisterInfo::isPhysicalRegister(li.reg) && + *tri_->getSuperRegisters(li.reg)) { + // It's a sub-register live interval, we may not have precise information. + // Re-compute it. + MachineInstr *DefMI = li_->getInstructionFromIndex(LR->start); + unsigned SrcReg, DstReg; + if (tii_->isMoveInstr(*DefMI, SrcReg, DstReg) && + DstReg == li.reg && SrcReg == Reg) { + // Cache computed info. + LR->valno->def = LR->start; + LR->valno->copy = DefMI; + return true; + } + } + return false; +} + /// SimpleJoin - Attempt to joint the specified interval into this one. The /// caller of this method must guarantee that the RHS only contains a single /// value number and that the RHS is not defined by a copy from this @@ -1045,8 +1222,7 @@ // If we haven't already recorded that this value # is safe, check it. if (!InVector(LHSIt->valno, EliminatedLHSVals)) { // Copy from the RHS? - unsigned SrcReg = li_->getVNInfoSourceReg(LHSIt->valno); - if (SrcReg != RHS.reg) + if (!RangeIsDefinedByCopyFromReg(LHS, LHSIt, RHS.reg)) return false; // Nope, bail out. EliminatedLHSVals.push_back(LHSIt->valno); @@ -1073,7 +1249,7 @@ } else { // Otherwise, if this is a copy from the RHS, mark it as being merged // in. - if (li_->getVNInfoSourceReg(LHSIt->valno) == RHS.reg) { + if (RangeIsDefinedByCopyFromReg(LHS, LHSIt, RHS.reg)) { EliminatedLHSVals.push_back(LHSIt->valno); // We know this entire LHS live range is okay, so skip it now. @@ -1108,8 +1284,13 @@ } } LHSValNo = Smallest; + } else if (EliminatedLHSVals.empty()) { + if (TargetRegisterInfo::isPhysicalRegister(LHS.reg) && + *tri_->getSuperRegisters(LHS.reg)) + // Imprecise sub-register information. Can't handle it. + return false; + assert(0 && "No copies from the RHS?"); } else { - assert(!EliminatedLHSVals.empty() && "No copies from the RHS?"); LHSValNo = EliminatedLHSVals[0]; } @@ -1422,6 +1603,7 @@ std::vector VirtCopies; std::vector PhysCopies; + std::vector ImpDefCopies; unsigned LoopDepth = loopInfo->getLoopDepth(MBB); for (MachineBasicBlock::iterator MII = MBB->begin(), E = MBB->end(); MII != E;) { @@ -1432,6 +1614,9 @@ if (Inst->getOpcode() == TargetInstrInfo::EXTRACT_SUBREG) { DstReg = Inst->getOperand(0).getReg(); SrcReg = Inst->getOperand(1).getReg(); + } else if (Inst->getOpcode() == TargetInstrInfo::INSERT_SUBREG) { + DstReg = Inst->getOperand(0).getReg(); + SrcReg = Inst->getOperand(2).getReg(); } else if (!tii_->isMoveInstr(*Inst, SrcReg, DstReg)) continue; @@ -1440,7 +1625,9 @@ if (NewHeuristic) { JoinQueue->push(CopyRec(Inst, LoopDepth, isBackEdgeCopy(Inst, DstReg))); } else { - if (SrcIsPhys || DstIsPhys) + if (li_->hasInterval(SrcReg) && li_->getInterval(SrcReg).empty()) + ImpDefCopies.push_back(CopyRec(Inst, 0, false)); + else if (SrcIsPhys || DstIsPhys) PhysCopies.push_back(CopyRec(Inst, 0, false)); else VirtCopies.push_back(CopyRec(Inst, 0, false)); @@ -1450,7 +1637,16 @@ if (NewHeuristic) return; - // Try coalescing physical register + virtual register first. + // Try coalescing implicit copies first, followed by copies to / from + // physical registers, then finally copies from virtual registers to + // virtual registers. + for (unsigned i = 0, e = ImpDefCopies.size(); i != e; ++i) { + CopyRec &TheCopy = ImpDefCopies[i]; + bool Again = false; + if (!JoinCopy(TheCopy, Again)) + if (Again) + TryAgain.push_back(TheCopy); + } for (unsigned i = 0, e = PhysCopies.size(); i != e; ++i) { CopyRec &TheCopy = PhysCopies[i]; bool Again = false; Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h?rev=49448&r1=49447&r2=49448&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h Wed Apr 9 15:57:25 2008 @@ -196,9 +196,25 @@ MachineBasicBlock *MBB, unsigned DstReg, unsigned SrcReg); - /// isBackEdgeCopy - Returns true if CopyMI is a back edge copy. + /// CanCoalesceWithImpDef - Returns true if the specified copy instruction + /// from an implicit def to another register can be coalesced away. + bool CanCoalesceWithImpDef(MachineInstr *CopyMI, + LiveInterval &li, LiveInterval &ImpLi) const; + + /// RemoveCopiesFromValNo - The specified value# is defined by an implicit + /// def and it is being removed. Turn all copies from this value# into + /// identity copies so they will be removed. + void RemoveCopiesFromValNo(LiveInterval &li, VNInfo *VNI); + + /// RangeIsDefinedByCopyFromReg - Return true if the specified live range of + /// the specified live interval is defined by a copy from the specified + /// register. + bool RangeIsDefinedByCopyFromReg(LiveInterval &li, LiveRange *LR, + unsigned Reg); + + /// isBackEdgeCopy - Return true if CopyMI is a back edge copy. /// - bool isBackEdgeCopy(MachineInstr *CopyMI, unsigned DstReg); + bool isBackEdgeCopy(MachineInstr *CopyMI, unsigned DstReg) const; /// UpdateRegDefsUses - Replace all defs and uses of SrcReg to DstReg and /// update the subregister number if it is not zero. If DstReg is a @@ -207,6 +223,8 @@ /// subregister. void UpdateRegDefsUses(unsigned SrcReg, unsigned DstReg, unsigned SubIdx); + void RemoveDeadImpDef(unsigned Reg, LiveInterval &LI); + /// RemoveUnnecessaryKills - Remove kill markers that are no longer accurate /// due to live range lengthening as the result of coalescing. void RemoveUnnecessaryKills(unsigned Reg, LiveInterval &LI); Added: llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-1.ll?rev=49448&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-1.ll (added) +++ llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-1.ll Wed Apr 9 15:57:25 2008 @@ -0,0 +1,24 @@ +; RUN: llvm-as < %s | llc -march=x86 | grep mov | count 2 + +define fastcc i32 @sqlite3ExprResolveNames() nounwind { +entry: + br i1 false, label %UnifiedReturnBlock, label %bb4 +bb4: ; preds = %entry + br i1 false, label %bb17, label %bb22 +bb17: ; preds = %bb4 + ret i32 1 +bb22: ; preds = %bb4 + br i1 true, label %walkExprTree.exit, label %bb4.i +bb4.i: ; preds = %bb22 + ret i32 0 +walkExprTree.exit: ; preds = %bb22 + %tmp83 = load i16* null, align 4 ; [#uses=1] + %tmp84 = or i16 %tmp83, 2 ; [#uses=2] + store i16 %tmp84, i16* null, align 4 + %tmp98993 = zext i16 %tmp84 to i32 ; [#uses=1] + %tmp1004 = lshr i32 %tmp98993, 3 ; [#uses=1] + %tmp100.lobit5 = and i32 %tmp1004, 1 ; [#uses=1] + ret i32 %tmp100.lobit5 +UnifiedReturnBlock: ; preds = %entry + ret i32 0 +} Added: llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-2.ll?rev=49448&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-2.ll (added) +++ llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-2.ll Wed Apr 9 15:57:25 2008 @@ -0,0 +1,7 @@ +; RUN: llvm-as < %s | llc -march=x86-64 | not grep movw + +define i16 @test5(i16 %f12) nounwind { + %f11 = shl i16 %f12, 2 ; [#uses=1] + %tmp7.25 = ashr i16 %f11, 8 ; [#uses=1] + ret i16 %tmp7.25 +} Added: llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-3.ll?rev=49448&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-3.ll (added) +++ llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-3.ll Wed Apr 9 15:57:25 2008 @@ -0,0 +1,93 @@ +; RUN: llvm-as < %s | llc -march=x86-64 | grep mov | count 9 + + %struct.COMPOSITE = type { i8, i16, i16 } + %struct.FILE = type { i8*, i32, i32, i16, i16, %struct.__sbuf, i32, i8*, i32 (i8*)*, i32 (i8*, i8*, i32)*, i64 (i8*, i64, i32)*, i32 (i8*, i8*, i32)*, %struct.__sbuf, %struct.__sFILEX*, i32, [3 x i8], [1 x i8], %struct.__sbuf, i32, i64 } + %struct.FILE_POS = type { i8, i8, i16, i32 } + %struct.FIRST_UNION = type { %struct.FILE_POS } + %struct.FONT_INFO = type { %struct.metrics*, i8*, i16*, %struct.COMPOSITE*, i32, %struct.rec*, %struct.rec*, i16, i16, i16*, i8*, i8*, i16* } + %struct.FOURTH_UNION = type { %struct.STYLE } + %struct.GAP = type { i8, i8, i16 } + %struct.LIST = type { %struct.rec*, %struct.rec* } + %struct.SECOND_UNION = type { { i16, i8, i8 } } + %struct.STYLE = type { { %struct.GAP }, { %struct.GAP }, i16, i16, i32 } + %struct.THIRD_UNION = type { %struct.FILE*, [8 x i8] } + %struct.__sFILEX = type opaque + %struct.__sbuf = type { i8*, i32 } + %struct.head_type = type { [2 x %struct.LIST], %struct.FIRST_UNION, %struct.SECOND_UNION, %struct.THIRD_UNION, %struct.FOURTH_UNION, %struct.rec*, { %struct.rec* }, %struct.rec*, %struct.rec*, %struct.rec*, %struct.rec*, %struct.rec*, %struct.rec*, %struct.rec*, %struct.rec*, i32 } + %struct.metrics = type { i16, i16, i16, i16, i16 } + %struct.rec = type { %struct.head_type } + +define void @FontChange() { +entry: + br i1 false, label %bb298, label %bb49 +bb49: ; preds = %entry + ret void +bb298: ; preds = %entry + br i1 false, label %bb304, label %bb366 +bb304: ; preds = %bb298 + br i1 false, label %bb330, label %bb428 +bb330: ; preds = %bb366, %bb304 + br label %bb366 +bb366: ; preds = %bb330, %bb298 + br i1 false, label %bb330, label %bb428 +bb428: ; preds = %bb366, %bb304 + br i1 false, label %bb650, label %bb433 +bb433: ; preds = %bb428 + ret void +bb650: ; preds = %bb650, %bb428 + %tmp658 = load i8* null, align 8 ; [#uses=1] + %tmp659 = icmp eq i8 %tmp658, 0 ; [#uses=1] + br i1 %tmp659, label %bb650, label %bb662 +bb662: ; preds = %bb650 + %tmp685 = icmp eq %struct.rec* null, null ; [#uses=1] + br i1 %tmp685, label %bb761, label %bb688 +bb688: ; preds = %bb662 + ret void +bb761: ; preds = %bb662 + %tmp487248736542 = load i32* null, align 4 ; [#uses=2] + %tmp487648776541 = and i32 %tmp487248736542, 57344 ; [#uses=1] + %tmp4881 = icmp eq i32 %tmp487648776541, 8192 ; [#uses=1] + br i1 %tmp4881, label %bb4884, label %bb4897 +bb4884: ; preds = %bb761 + %tmp488948906540 = and i32 %tmp487248736542, 7168 ; [#uses=1] + %tmp4894 = icmp eq i32 %tmp488948906540, 1024 ; [#uses=1] + br i1 %tmp4894, label %bb4932, label %bb4897 +bb4897: ; preds = %bb4884, %bb761 + ret void +bb4932: ; preds = %bb4884 + %tmp4933 = load i32* null, align 4 ; [#uses=1] + br i1 false, label %bb5054, label %bb4940 +bb4940: ; preds = %bb4932 + %tmp4943 = load i32* null, align 4 ; [#uses=2] + switch i32 %tmp4933, label %bb5054 [ + i32 159, label %bb4970 + i32 160, label %bb5002 + ] +bb4970: ; preds = %bb4940 + %tmp49746536 = trunc i32 %tmp4943 to i16 ; [#uses=1] + %tmp49764977 = and i16 %tmp49746536, 4095 ; [#uses=1] + %mask498049814982 = zext i16 %tmp49764977 to i64 ; [#uses=1] + %tmp4984 = getelementptr %struct.FONT_INFO* null, i64 %mask498049814982, i32 5 ; <%struct.rec**> [#uses=1] + %tmp4985 = load %struct.rec** %tmp4984, align 8 ; <%struct.rec*> [#uses=1] + %tmp4988 = getelementptr %struct.rec* %tmp4985, i64 0, i32 0, i32 3 ; <%struct.THIRD_UNION*> [#uses=1] + %tmp4991 = bitcast %struct.THIRD_UNION* %tmp4988 to i32* ; [#uses=1] + %tmp4992 = load i32* %tmp4991, align 8 ; [#uses=1] + %tmp49924993 = trunc i32 %tmp4992 to i16 ; [#uses=1] + %tmp4996 = add i16 %tmp49924993, 0 ; [#uses=1] + br label %bb5054 +bb5002: ; preds = %bb4940 + %tmp50066537 = trunc i32 %tmp4943 to i16 ; [#uses=1] + %tmp50085009 = and i16 %tmp50066537, 4095 ; [#uses=1] + %mask501250135014 = zext i16 %tmp50085009 to i64 ; [#uses=1] + %tmp5016 = getelementptr %struct.FONT_INFO* null, i64 %mask501250135014, i32 5 ; <%struct.rec**> [#uses=1] + %tmp5017 = load %struct.rec** %tmp5016, align 8 ; <%struct.rec*> [#uses=1] + %tmp5020 = getelementptr %struct.rec* %tmp5017, i64 0, i32 0, i32 3 ; <%struct.THIRD_UNION*> [#uses=1] + %tmp5023 = bitcast %struct.THIRD_UNION* %tmp5020 to i32* ; [#uses=1] + %tmp5024 = load i32* %tmp5023, align 8 ; [#uses=1] + %tmp50245025 = trunc i32 %tmp5024 to i16 ; [#uses=1] + %tmp5028 = sub i16 %tmp50245025, 0 ; [#uses=1] + br label %bb5054 +bb5054: ; preds = %bb5002, %bb4970, %bb4940, %bb4932 + %flen.0.reg2mem.0 = phi i16 [ %tmp4996, %bb4970 ], [ %tmp5028, %bb5002 ], [ 0, %bb4932 ], [ undef, %bb4940 ] ; [#uses=0] + ret void +} From criswell at uiuc.edu Wed Apr 9 16:08:24 2008 From: criswell at uiuc.edu (John Criswell) Date: Wed, 09 Apr 2008 21:08:24 -0000 Subject: [llvm-commits] [poolalloc] r49449 - /poolalloc/trunk/lib/DSA/Local.cpp Message-ID: <200804092108.m39L8O11006299@zion.cs.uiuc.edu> Author: criswell Date: Wed Apr 9 16:08:24 2008 New Revision: 49449 URL: http://llvm.org/viewvc/llvm-project?rev=49449&view=rev Log: Added a few more debugging intrinsics to ignore. Modified: poolalloc/trunk/lib/DSA/Local.cpp Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=49449&r1=49448&r2=49449&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Wed Apr 9 16:08:24 2008 @@ -543,6 +543,8 @@ case Intrinsic::dbg_func_start: case Intrinsic::dbg_region_end: case Intrinsic::dbg_stoppoint: + case Intrinsic::dbg_region_start: + case Intrinsic::dbg_declare: return true; // noop case Intrinsic::memcpy_i32: case Intrinsic::memcpy_i64: From criswell at uiuc.edu Wed Apr 9 16:11:11 2008 From: criswell at uiuc.edu (John Criswell) Date: Wed, 09 Apr 2008 21:11:11 -0000 Subject: [llvm-commits] [poolalloc] r49450 - /poolalloc/trunk/lib/DSA/StdLibPass.cpp Message-ID: <200804092111.m39LBBOB006439@zion.cs.uiuc.edu> Author: criswell Date: Wed Apr 9 16:11:11 2008 New Revision: 49450 URL: http://llvm.org/viewvc/llvm-project?rev=49450&view=rev Log: Added support for strdup(). Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/StdLibPass.cpp?rev=49450&r1=49449&r2=49450&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/StdLibPass.cpp (original) +++ poolalloc/trunk/lib/DSA/StdLibPass.cpp Wed Apr 9 16:11:11 2008 @@ -58,6 +58,9 @@ ->setHeapMarker()->setModifiedMarker(); Graph.getNodeForValue(I->arg_begin()).getNode()->clearNodeFlags() ->mergeWith(Graph.getReturnNodeFor(*I), 0); + } else if (Name == "strdup") { + Graph.getReturnNodeFor(*I).getNode()->clearNodeFlags() + ->setHeapMarker()->setModifiedMarker(); } else if (Name == "free") { Graph.getNodeForValue(&*I->arg_begin()).getNode()->clearNodeFlags() ->setHeapMarker()->setModifiedMarker(); From ggreif at gmail.com Wed Apr 9 16:28:25 2008 From: ggreif at gmail.com (Gabor Greif) Date: Wed, 09 Apr 2008 21:28:25 -0000 Subject: [llvm-commits] [llvm] r49451 - /llvm/branches/ggreif/use-diet/include/llvm/User.h Message-ID: <200804092128.m39LSPWQ006969@zion.cs.uiuc.edu> Author: ggreif Date: Wed Apr 9 16:28:25 2008 New Revision: 49451 URL: http://llvm.org/viewvc/llvm-project?rev=49451&view=rev Log: implement Op functions using trait redirection Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49451&r1=49450&r2=49451&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/User.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/User.h Wed Apr 9 16:28:25 2008 @@ -188,6 +188,26 @@ ==============================================================================*/ +/// OperandTraits - Compile-time customization of +/// operand-related allocators and accessors +/// for use of the User class +template +struct OperandTraits; + +class User; + +template <> +struct OperandTraits { + static inline Use *op_begin(User*); + static inline Use *op_end(User*); + static inline unsigned operands(User*); + template + struct Layout { + typedef U overlay; + }; + static inline void *allocate(unsigned); +}; + class User : public Value { User(const User &); // Do not implement void *operator new(size_t); // Do not implement @@ -225,8 +245,12 @@ else ::operator delete(Usr); } public: - template Use &Op(); - template const Use &Op() const; + template Use &Op() { + return OperandTraits::op_begin(this)[Idx]; + } + template const Use &Op() const { + return OperandTraits::op_begin(const_cast(this))[Idx]; + } Use *allocHangoffUses(unsigned) const; Value *getOperand(unsigned i) const { @@ -276,6 +300,26 @@ } }; +inline Use *OperandTraits::op_begin(User *U) { + return U->op_begin(); +} + +inline Use *OperandTraits::op_end(User *U) { + return U->op_end(); +} + +inline unsigned OperandTraits::operands(User *U) { + return U->getNumOperands(); +} + /* + template + struct Layout { + typedef U overlay; + }; + static inline void *allocate(unsigned); +}; + */ + template<> struct simplify_type { typedef Value* SimpleType; From arnold.schwaighofer at gmail.com Wed Apr 9 16:33:14 2008 From: arnold.schwaighofer at gmail.com (Arnold Schwaighofer) Date: Wed, 9 Apr 2008 23:33:14 +0200 Subject: [llvm-commits] PATCH: Tailcallopt x86 byval argument handling In-Reply-To: References: Message-ID: > i'll be back ... and here i am. no more checking for registers. removed the check for the known registers (e/rcx,si,di) that are overwritten by byval lowering. now all register arguments are protected by a copyto/from virtual reg sequence the register allocator does the rest of the work. regards arnold -------------- next part -------------- A non-text attachment was scrubbed... Name: x86-r48948-5.patch Type: application/octet-stream Size: 12444 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080409/d036defd/attachment.obj From criswell at uiuc.edu Wed Apr 9 16:39:13 2008 From: criswell at uiuc.edu (John Criswell) Date: Wed, 09 Apr 2008 21:39:13 -0000 Subject: [llvm-commits] [poolalloc] r49452 - /poolalloc/trunk/lib/DSA/Local.cpp Message-ID: <200804092139.m39LdDUh007328@zion.cs.uiuc.edu> Author: criswell Date: Wed Apr 9 16:39:13 2008 New Revision: 49452 URL: http://llvm.org/viewvc/llvm-project?rev=49452&view=rev Log: Handle the stack saving and restoring intrinsics. Modified: poolalloc/trunk/lib/DSA/Local.cpp Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=49452&r1=49451&r2=49452&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Wed Apr 9 16:39:13 2008 @@ -539,6 +539,19 @@ getValueDest(*CS.getInstruction()). mergeWith(getValueDest(**(CS.arg_begin()))); return true; + case Intrinsic::stacksave: { + DSNode * Node = createNode(); + Node->setAllocaMarker()->setIncompleteMarker()->setUnknownMarker(); + Node->foldNodeCompletely(); + setDestTo (*(CS.getInstruction()), Node); + return true; + } + case Intrinsic::stackrestore: + getValueDest(*CS.getInstruction()).getNode()->setAllocaMarker() + ->setIncompleteMarker() + ->setUnknownMarker() + ->foldNodeCompletely(); + return true; case Intrinsic::vaend: case Intrinsic::dbg_func_start: case Intrinsic::dbg_region_end: From ggreif at gmail.com Wed Apr 9 16:56:35 2008 From: ggreif at gmail.com (Gabor Greif) Date: Wed, 09 Apr 2008 21:56:35 -0000 Subject: [llvm-commits] [llvm] r49454 - /llvm/branches/ggreif/use-diet/include/llvm/User.h Message-ID: <200804092156.m39LuZka008035@zion.cs.uiuc.edu> Author: ggreif Date: Wed Apr 9 16:56:35 2008 New Revision: 49454 URL: http://llvm.org/viewvc/llvm-project?rev=49454&view=rev Log: implement allocHangoffUses Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49454&r1=49453&r2=49454&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/User.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/User.h Wed Apr 9 16:56:35 2008 @@ -251,7 +251,7 @@ template const Use &Op() const { return OperandTraits::op_begin(const_cast(this))[Idx]; } - Use *allocHangoffUses(unsigned) const; + inline Use *allocHangoffUses(unsigned) const; Value *getOperand(unsigned i) const { assert(i < NumOperands && "getOperand() out of range!"); @@ -320,6 +320,12 @@ }; */ +Use *User::allocHangoffUses(unsigned N) const { + Use *Begin = static_cast(::operator new(sizeof(Use) * N)); + Use::initTags(Begin, Begin + N); + return Begin; +} + template<> struct simplify_type { typedef Value* SimpleType; From evan.cheng at apple.com Wed Apr 9 20:32:41 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 10 Apr 2008 01:32:41 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49456 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Message-ID: <200804100132.m3A1Wfwq014450@zion.cs.uiuc.edu> Author: evancheng Date: Wed Apr 9 20:32:40 2008 New Revision: 49456 URL: http://llvm.org/viewvc/llvm-project?rev=49456&view=rev Log: Move memcpy / memset optimization pass after GVN. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=49456&r1=49455&r2=49456&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Wed Apr 9 20:32:40 2008 @@ -384,8 +384,8 @@ if (flag_unroll_loops) PM->add(createLoopUnrollPass()); // Unroll small loops PM->add(createInstructionCombiningPass()); // Clean up after the unroller - PM->add(createMemCpyOptPass()); // Remove dead memcpy's PM->add(createGVNPass()); // Remove redundancies + PM->add(createMemCpyOptPass()); // Remove memcpy / form memset PM->add(createSCCPPass()); // Constant prop with SCCP // Run instcombine after redundancy elimination to exploit opportunities From evan.cheng at apple.com Wed Apr 9 20:33:05 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 10 Apr 2008 01:33:05 -0000 Subject: [llvm-commits] [llvm] r49457 - /llvm/trunk/tools/opt/opt.cpp Message-ID: <200804100133.m3A1X5FU014499@zion.cs.uiuc.edu> Author: evancheng Date: Wed Apr 9 20:33:05 2008 New Revision: 49457 URL: http://llvm.org/viewvc/llvm-project?rev=49457&view=rev Log: Move memcpy / memset optimization pass after GVN. Modified: llvm/trunk/tools/opt/opt.cpp Modified: llvm/trunk/tools/opt/opt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=49457&r1=49456&r2=49457&view=diff ============================================================================== --- llvm/trunk/tools/opt/opt.cpp (original) +++ llvm/trunk/tools/opt/opt.cpp Wed Apr 9 20:33:05 2008 @@ -282,8 +282,8 @@ addPass(PM, createIndVarSimplifyPass()); // Canonicalize indvars addPass(PM, createLoopUnrollPass()); // Unroll small loops addPass(PM, createInstructionCombiningPass()); // Clean up after the unroller - addPass(PM, createMemCpyOptPass()); // Remove unneeded memcpy's addPass(PM, createGVNPass()); // Remove redundancies + addPass(PM, createMemCpyOptPass()); // Remove memcpy / form memset addPass(PM, createSCCPPass()); // Constant prop with SCCP // Run instcombine after redundancy elimination to exploit opportunities From sabre at nondot.org Wed Apr 9 21:07:51 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 10 Apr 2008 02:07:51 -0000 Subject: [llvm-commits] [llvm] r49458 - /llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp Message-ID: <200804100207.m3A27ph4015558@zion.cs.uiuc.edu> Author: lattner Date: Wed Apr 9 21:07:51 2008 New Revision: 49458 URL: http://llvm.org/viewvc/llvm-project?rev=49458&view=rev Log: Disable an xform we've had for a long time, pow(x,0.5) -> sqrt. This is not safe for all inputs. Modified: llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp Modified: llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp?rev=49458&r1=49457&r2=49458&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp Wed Apr 9 21:07:51 2008 @@ -1179,9 +1179,17 @@ // pow(x, 0.0) -> 1.0 return ReplaceCallWith(CI, ConstantFP::get(CI->getType(), 1.0)); } else if (Op2C->isExactlyValue(0.5)) { + // FIXME: This is not safe for -0.0 and -inf. This can only be done when + // 'unsafe' math optimizations are allowed. + // x pow(x, 0.5) sqrt(x) + // --------------------------------------------- + // -0.0 +0.0 -0.0 + // -inf +inf NaN +#if 0 // pow(x, 0.5) -> sqrt(x) Value *Sqrt = CallInst::Create(SLC.get_sqrt(), Op1, "sqrt", CI); return ReplaceCallWith(CI, Sqrt); +#endif } else if (Op2C->isExactlyValue(1.0)) { // pow(x, 1.0) -> x return ReplaceCallWith(CI, Op1); From evan.cheng at apple.com Wed Apr 9 21:32:10 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 10 Apr 2008 02:32:10 -0000 Subject: [llvm-commits] [llvm] r49461 - in /llvm/trunk: lib/CodeGen/BranchFolding.cpp test/CodeGen/X86/2007-06-14-branchfold.ll test/CodeGen/X86/2008-04-09-BranchFolding.ll Message-ID: <200804100232.m3A2WAiS016264@zion.cs.uiuc.edu> Author: evancheng Date: Wed Apr 9 21:32:10 2008 New Revision: 49461 URL: http://llvm.org/viewvc/llvm-project?rev=49461&view=rev Log: Teach branch folding pass about implicit_def instructions. Unfortunately we can't just eliminate them since register scavenger expects every register use to be defined. However, we can delete them when there are no intra-block uses. Carefully removing some implicit def's which enable more blocks to be optimized away. Added: llvm/trunk/test/CodeGen/X86/2008-04-09-BranchFolding.ll Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp llvm/trunk/test/CodeGen/X86/2007-06-14-branchfold.ll Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=49461&r1=49460&r2=49461&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Wed Apr 9 21:32:10 2008 @@ -27,6 +27,7 @@ #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" +#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/STLExtras.h" #include @@ -78,6 +79,7 @@ bool OptimizeBranches(MachineFunction &MF); void OptimizeBlock(MachineBasicBlock *MBB); void RemoveDeadBlock(MachineBasicBlock *MBB); + bool OptimizeImpDefsBlock(MachineBasicBlock *MBB); bool CanFallThrough(MachineBasicBlock *CurBB); bool CanFallThrough(MachineBasicBlock *CurBB, bool BranchUnAnalyzable, @@ -117,10 +119,63 @@ MF->getBasicBlockList().erase(MBB); } +/// OptimizeImpDefsBlock - If a basic block is just a bunch of implicit_def +/// followed by terminators, and if the implicitly defined registers are not +/// used by the terminators, remove those implicit_def's. e.g. +/// BB1: +/// r0 = implicit_def +/// r1 = implicit_def +/// br +/// This block can be optimized away later if the implicit instructions are +/// removed. +bool BranchFolder::OptimizeImpDefsBlock(MachineBasicBlock *MBB) { + SmallSet ImpDefRegs; + MachineBasicBlock::iterator I = MBB->begin(); + while (I != MBB->end()) { + if (I->getOpcode() != TargetInstrInfo::IMPLICIT_DEF) + break; + unsigned Reg = I->getOperand(0).getReg(); + ImpDefRegs.insert(Reg); + for (const unsigned *SubRegs = RegInfo->getSubRegisters(Reg); + unsigned SubReg = *SubRegs; ++SubRegs) + ImpDefRegs.insert(SubReg); + ++I; + } + if (ImpDefRegs.empty()) + return false; + + MachineBasicBlock::iterator FirstTerm = I; + while (I != MBB->end()) { + if (!TII->isUnpredicatedTerminator(I)) + return false; + // See if it uses any of the implicitly defined registers. + for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) { + MachineOperand &MO = I->getOperand(i); + if (!MO.isReg() || !MO.isUse()) + continue; + unsigned Reg = MO.getReg(); + if (ImpDefRegs.count(Reg)) + return false; + } + ++I; + } + + I = MBB->begin(); + while (I != FirstTerm) { + MachineInstr *ImpDefMI = &*I; + ++I; + MBB->erase(ImpDefMI); + } + + return true; +} + bool BranchFolder::runOnMachineFunction(MachineFunction &MF) { TII = MF.getTarget().getInstrInfo(); if (!TII) return false; + RegInfo = MF.getTarget().getRegisterInfo(); + // Fix CFG. The later algorithms expect it to be right. bool EverMadeChange = false; for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; I++) { @@ -128,9 +183,9 @@ std::vector Cond; if (!TII->AnalyzeBranch(*MBB, TBB, FBB, Cond)) EverMadeChange |= MBB->CorrectExtraCFGEdges(TBB, FBB, !Cond.empty()); + EverMadeChange |= OptimizeImpDefsBlock(MBB); } - RegInfo = MF.getTarget().getRegisterInfo(); RS = RegInfo->requiresRegisterScavenging(MF) ? new RegScavenger() : NULL; MMI = getAnalysisToUpdate(); Modified: llvm/trunk/test/CodeGen/X86/2007-06-14-branchfold.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-06-14-branchfold.ll?rev=49461&r1=49460&r2=49461&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2007-06-14-branchfold.ll (original) +++ llvm/trunk/test/CodeGen/X86/2007-06-14-branchfold.ll Wed Apr 9 21:32:10 2008 @@ -1,8 +1,6 @@ -; RUN: llvm-as < %s | llc -mcpu=i686 | not grep jmp +; RUN: llvm-as < %s | llc -march=x86 -mcpu=i686 | not grep jmp ; check that branch folding understands FP_REG_KILL is not a branch -; ModuleID = 'g.bc' -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64" target triple = "i686-pc-linux-gnu" %struct.FRAME.c34003a = type { float, float } @report_E = global i8 0 ; [#uses=0] Added: llvm/trunk/test/CodeGen/X86/2008-04-09-BranchFolding.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-04-09-BranchFolding.ll?rev=49461&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-04-09-BranchFolding.ll (added) +++ llvm/trunk/test/CodeGen/X86/2008-04-09-BranchFolding.ll Wed Apr 9 21:32:10 2008 @@ -0,0 +1,48 @@ +; RUN: llvm-as < %s | llc -march=x86 | not grep jmp + + %struct..0anon = type { i32 } + %struct.binding_level = type { %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.binding_level*, i8, i8, i8, i8, i8, i32, %struct.tree_node* } + %struct.lang_decl = type opaque + %struct.rtx_def = type { i16, i8, i8, [1 x %struct..0anon] } + %struct.tree_decl = type { [12 x i8], i8*, i32, %struct.tree_node*, i32, i8, i8, i8, i8, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.tree_node*, %struct.rtx_def*, %struct..0anon, { %struct.rtx_def* }, %struct.tree_node*, %struct.lang_decl* } + %struct.tree_node = type { %struct.tree_decl } + +define fastcc %struct.tree_node* @pushdecl(%struct.tree_node* %x) nounwind { +entry: + %tmp3.i40 = icmp eq %struct.binding_level* null, null ; [#uses=2] + br i1 false, label %bb143, label %bb140 +bb140: ; preds = %entry + br i1 %tmp3.i40, label %bb160, label %bb17.i +bb17.i: ; preds = %bb140 + ret %struct.tree_node* null +bb143: ; preds = %entry + %tmp8.i43 = load %struct.tree_node** null, align 4 ; <%struct.tree_node*> [#uses=1] + br i1 %tmp3.i40, label %bb160, label %bb9.i48 +bb9.i48: ; preds = %bb143 + ret %struct.tree_node* null +bb160: ; preds = %bb143, %bb140 + %t.0.reg2mem.0 = phi %struct.tree_node* [ null, %bb140 ], [ %tmp8.i43, %bb143 ] ; <%struct.tree_node*> [#uses=1] + %tmp162 = icmp eq %struct.tree_node* %t.0.reg2mem.0, null ; [#uses=2] + br i1 %tmp162, label %bb174, label %bb165 +bb165: ; preds = %bb160 + br label %bb174 +bb174: ; preds = %bb165, %bb160 + %line.0 = phi i32 [ 0, %bb165 ], [ undef, %bb160 ] ; [#uses=1] + %file.0 = phi i8* [ null, %bb165 ], [ undef, %bb160 ] ; [#uses=1] + br i1 %tmp162, label %bb344, label %bb73.i +bb73.i: ; preds = %bb174 + br i1 false, label %bb226.i, label %bb220.i +bb220.i: ; preds = %bb73.i + ret %struct.tree_node* null +bb226.i: ; preds = %bb73.i + br i1 false, label %bb260, label %bb273.i +bb273.i: ; preds = %bb226.i + ret %struct.tree_node* null +bb260: ; preds = %bb226.i + tail call void (i8*, i32, ...)* @pedwarn_with_file_and_line( i8* %file.0, i32 %line.0, i8* null ) nounwind + ret %struct.tree_node* null +bb344: ; preds = %bb174 + ret %struct.tree_node* null +} + +declare void @pedwarn_with_file_and_line(i8*, i32, ...) nounwind From evan.cheng at apple.com Wed Apr 9 22:06:42 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 9 Apr 2008 20:06:42 -0700 Subject: [llvm-commits] PATCH: Tailcallopt x86 byval argument handling In-Reply-To: References: Message-ID: <682C0CC5-A585-4985-BBE0-1CAFE76479AA@apple.com> On Apr 9, 2008, at 4:32 AM, Arnold Schwaighofer wrote: > > > BUT: I think it is possible to eliminate the check for esi, edi, ecx. > Instead of only copying the 'byval clobbered' registers to virtual > registers and back this will be done for all argument registers (if > byval args occur). The register allocator will than hopefully do the > rest (eliminating the unneccessary ones). > > D'oh - there is always a simpler solution waiting to be beaten out of > me by evan. ;-) I didn't do anything. You talked yourself into a better solution. :-) Evan > > > ill try this and correct the other stuff and hopefully return with a > new shiny patch > > i'll be back > > regards arnold > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Wed Apr 9 23:48:34 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 10 Apr 2008 04:48:34 -0000 Subject: [llvm-commits] [llvm] r49462 - /llvm/trunk/utils/TableGen/TGParser.cpp Message-ID: <200804100448.m3A4mZH0020336@zion.cs.uiuc.edu> Author: lattner Date: Wed Apr 9 23:48:34 2008 New Revision: 49462 URL: http://llvm.org/viewvc/llvm-project?rev=49462&view=rev Log: produce an error on invalid input instead of asserting: def : Pat<((v2f64 (vector_shuffle immAllZerosV_bc, ^ Modified: llvm/trunk/utils/TableGen/TGParser.cpp Modified: llvm/trunk/utils/TableGen/TGParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGParser.cpp?rev=49462&r1=49461&r2=49462&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGParser.cpp (original) +++ llvm/trunk/utils/TableGen/TGParser.cpp Wed Apr 9 23:48:34 2008 @@ -616,6 +616,11 @@ } case tgtok::l_paren: { // Value ::= '(' IDValue DagArgList ')' Lex.Lex(); // eat the '(' + if (Lex.getCode() != tgtok::Id) { + TokError("expected identifier in dag init"); + return 0; + } + Init *Operator = ParseIDValue(CurRec); if (Operator == 0) return 0; From sabre at nondot.org Thu Apr 10 00:13:43 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 10 Apr 2008 05:13:43 -0000 Subject: [llvm-commits] [llvm] r49463 - in /llvm/trunk: lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/vec_shuffle-17.ll Message-ID: <200804100513.m3A5DiuC021057@zion.cs.uiuc.edu> Author: lattner Date: Thu Apr 10 00:13:43 2008 New Revision: 49463 URL: http://llvm.org/viewvc/llvm-project?rev=49463&view=rev Log: Fix the x86-64 side of PR2108 by adding a v2f64 version of MOVZQI2PQIrr. This would be better handled as a dag combine (with the goal of eliminating the bitconvert) but I don't know how to do that safely. Thoughts welcome. Added: llvm/trunk/test/CodeGen/X86/vec_shuffle-17.ll Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=49463&r1=49462&r2=49463&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Thu Apr 10 00:13:43 2008 @@ -2305,6 +2305,16 @@ MOVL_shuffle_mask)))]>; } +// Handle the v2f64 form of 'MOVZQI2PQIrr' for PR2108. FIXME: this would be +// better written as a dag combine xform. +let AddedComplexity = 15 in +def : Pat<(v2f64 (vector_shuffle immAllZerosV_bc, + (v2f64 (scalar_to_vector + (f64 (bitconvert GR64:$src)))), + MOVL_shuffle_mask)), + (MOVZQI2PQIrr GR64:$src)>, Requires<[HasSSE3]>; + + let AddedComplexity = 20 in { def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src), "movd\t{$src, $dst|$dst, $src}", Added: llvm/trunk/test/CodeGen/X86/vec_shuffle-17.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_shuffle-17.ll?rev=49463&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_shuffle-17.ll (added) +++ llvm/trunk/test/CodeGen/X86/vec_shuffle-17.ll Thu Apr 10 00:13:43 2008 @@ -0,0 +1,13 @@ +; RUN: llvm-as < %s | llc -march=x86-64 | grep {movd.*%rdi, %xmm0} +; RUN: llvm-as < %s | llc -march=x86-64 | not grep xor +; PR2108 + +define <2 x i64> @doload64(i64 %x) nounwind { +entry: + %tmp717 = bitcast i64 %x to double ; [#uses=1] + %tmp8 = insertelement <2 x double> undef, double %tmp717, i32 0 ; <<2 x double>> [#uses=1] + %tmp9 = insertelement <2 x double> %tmp8, double 0.000000e+00, i32 1 ; <<2 x double>> [#uses=1] + %tmp11 = bitcast <2 x double> %tmp9 to <2 x i64> ; <<2 x i64>> [#uses=1] + ret <2 x i64> %tmp11 +} + From sabre at nondot.org Thu Apr 10 00:37:47 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 10 Apr 2008 05:37:47 -0000 Subject: [llvm-commits] [llvm] r49465 - /llvm/trunk/lib/Target/X86/README-SSE.txt Message-ID: <200804100537.m3A5blpu021759@zion.cs.uiuc.edu> Author: lattner Date: Thu Apr 10 00:37:47 2008 New Revision: 49465 URL: http://llvm.org/viewvc/llvm-project?rev=49465&view=rev Log: move the x86-32 part of PR2108 here. Modified: llvm/trunk/lib/Target/X86/README-SSE.txt Modified: llvm/trunk/lib/Target/X86/README-SSE.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README-SSE.txt?rev=49465&r1=49464&r2=49465&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/README-SSE.txt (original) +++ llvm/trunk/lib/Target/X86/README-SSE.txt Thu Apr 10 00:37:47 2008 @@ -428,6 +428,54 @@ //===---------------------------------------------------------------------===// +Consider (PR2108): + +#include +__m128i doload64(unsigned long long x) { return _mm_loadl_epi64(&x);} +__m128i doload64_2(unsigned long long *x) { return _mm_loadl_epi64(x);} + +These are very similar routines, but we generate significantly worse code for +the first one on x86-32: + +_doload64: + subl $12, %esp + movl 20(%esp), %eax + movl %eax, 4(%esp) + movl 16(%esp), %eax + movl %eax, (%esp) + movsd (%esp), %xmm0 + addl $12, %esp + ret +_doload64_2: + movl 4(%esp), %eax + movsd (%eax), %xmm0 + ret + +The problem is that the argument lowering logic splits the i64 argument into +2x i32 loads early, the f64 insert doesn't match. Here's a reduced testcase: + +define fastcc double @doload64(i64 %x) nounwind { +entry: + %tmp717 = bitcast i64 %x to double ; [#uses=1] + ret double %tmp717 +} + +compiles to: + +_doload64: + subl $12, %esp + movl 20(%esp), %eax + movl %eax, 4(%esp) + movl 16(%esp), %eax + movl %eax, (%esp) + movsd (%esp), %xmm0 + addl $12, %esp + ret + +instead of movsd from the stack. + +//===---------------------------------------------------------------------===// + __m128d test1( __m128d A, __m128d B) { return _mm_shuffle_pd(A, B, 0x3); } From sabre at nondot.org Thu Apr 10 00:54:51 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 10 Apr 2008 05:54:51 -0000 Subject: [llvm-commits] [llvm] r49466 - /llvm/trunk/lib/Target/X86/README-SSE.txt Message-ID: <200804100554.m3A5spL1022239@zion.cs.uiuc.edu> Author: lattner Date: Thu Apr 10 00:54:50 2008 New Revision: 49466 URL: http://llvm.org/viewvc/llvm-project?rev=49466&view=rev Log: add a note, this is actually not too bad to implement. Modified: llvm/trunk/lib/Target/X86/README-SSE.txt Modified: llvm/trunk/lib/Target/X86/README-SSE.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README-SSE.txt?rev=49466&r1=49465&r2=49466&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/README-SSE.txt (original) +++ llvm/trunk/lib/Target/X86/README-SSE.txt Thu Apr 10 00:54:50 2008 @@ -472,7 +472,13 @@ addl $12, %esp ret -instead of movsd from the stack. +instead of movsd from the stack. This is actually not too bad to implement. The +best way to do this is to implement a dag combine that turns +bitconvert(build_pair(load a, load b)) into one load of the right type. The +only trick to this is writing the predicate that determines that a/b are at the +right offset from each other. For the enterprising hacker, InferAlignment is a +helpful place to start poking if interested. + //===---------------------------------------------------------------------===// From evan.cheng at apple.com Thu Apr 10 03:03:14 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 10 Apr 2008 08:03:14 -0000 Subject: [llvm-commits] [llvm] r49469 - /llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h Message-ID: <200804100803.m3A83EhP001265@zion.cs.uiuc.edu> Author: evancheng Date: Thu Apr 10 03:03:14 2008 New Revision: 49469 URL: http://llvm.org/viewvc/llvm-project?rev=49469&view=rev Log: Add comment. Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h?rev=49469&r1=49468&r2=49469&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h Thu Apr 10 03:03:14 2008 @@ -223,6 +223,8 @@ /// subregister. void UpdateRegDefsUses(unsigned SrcReg, unsigned DstReg, unsigned SubIdx); + /// RemoveDeadImpDef - Remove implicit_def instructions which are + /// "re-defining" registers due to insert_subreg coalescing. e.g. void RemoveDeadImpDef(unsigned Reg, LiveInterval &LI); /// RemoveUnnecessaryKills - Remove kill markers that are no longer accurate From ggreif at gmail.com Thu Apr 10 03:12:39 2008 From: ggreif at gmail.com (Gabor Greif) Date: Thu, 10 Apr 2008 08:12:39 -0000 Subject: [llvm-commits] [llvm] r49470 - in /llvm/branches/ggreif/use-diet: CREDITS.TXT include/llvm/InstrTypes.h include/llvm/User.h Message-ID: <200804100812.m3A8CdeL001560@zion.cs.uiuc.edu> Author: ggreif Date: Thu Apr 10 03:12:39 2008 New Revision: 49470 URL: http://llvm.org/viewvc/llvm-project?rev=49470&view=rev Log: introduce and use FixedNumOperandTraits class, though its full potential is still not explored. enter myself in CREDITS Modified: llvm/branches/ggreif/use-diet/CREDITS.TXT llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h llvm/branches/ggreif/use-diet/include/llvm/User.h Modified: llvm/branches/ggreif/use-diet/CREDITS.TXT URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/CREDITS.TXT?rev=49470&r1=49469&r2=49470&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/CREDITS.TXT (original) +++ llvm/branches/ggreif/use-diet/CREDITS.TXT Thu Apr 10 03:12:39 2008 @@ -110,6 +110,10 @@ D: Miscellaneous bug fixes D: Register allocation refactoring +N: Gabor Greif +E: ggreif at gmail.com +D: Improvements for space efficiency + N: Gordon Henriksen E: gordonhenriksen at mac.com D: Pluggable GC support Modified: llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h?rev=49470&r1=49469&r2=49470&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h Thu Apr 10 03:12:39 2008 @@ -79,6 +79,36 @@ }; //===----------------------------------------------------------------------===// +// FixedNumOperands Trait Class +//===----------------------------------------------------------------------===// + +template +struct FixedNumOperandTraits { + static Use *op_begin(User* U) { + return reinterpret_cast(U) - ARITY; + } + static Use *op_end(User* U) { + return reinterpret_cast(U); + } + static unsigned operands(User*) { + return ARITY; + } + struct prefix { + Use Ops[ARITY]; + prefix(); // DO NOT IMPLEMENT + }; + template + struct Layout { + struct overlay : prefix, U { + overlay(); // DO NOT IMPLEMENT + }; + }; + static inline void *allocate(unsigned); // FIXME +}; + + + +//===----------------------------------------------------------------------===// // UnaryInstruction Class //===----------------------------------------------------------------------===// @@ -129,6 +159,10 @@ } }; +template <> +struct OperandTraits : FixedNumOperandTraits<1> { +}; + //===----------------------------------------------------------------------===// // BinaryOperator Class //===----------------------------------------------------------------------===// @@ -251,6 +285,10 @@ } }; +template <> +struct OperandTraits : FixedNumOperandTraits<2> { +}; + //===----------------------------------------------------------------------===// // CastInst Class //===----------------------------------------------------------------------===// Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49470&r1=49469&r2=49470&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/User.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/User.h Thu Apr 10 03:12:39 2008 @@ -312,10 +312,6 @@ return U->getNumOperands(); } /* - template - struct Layout { - typedef U overlay; - }; static inline void *allocate(unsigned); }; */ From ggreif at gmail.com Thu Apr 10 03:38:30 2008 From: ggreif at gmail.com (Gabor Greif) Date: Thu, 10 Apr 2008 08:38:30 -0000 Subject: [llvm-commits] [llvm] r49471 - in /llvm/branches/ggreif/use-diet/include/llvm: InstrTypes.h User.h Message-ID: <200804100838.m3A8cUSS002319@zion.cs.uiuc.edu> Author: ggreif Date: Thu Apr 10 03:38:30 2008 New Revision: 49471 URL: http://llvm.org/viewvc/llvm-project?rev=49471&view=rev Log: implement operand accessors in terms of traits (for BinaryOperator now) Modified: llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h llvm/branches/ggreif/use-diet/include/llvm/User.h Modified: llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h?rev=49471&r1=49470&r2=49471&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h Thu Apr 10 03:38:30 2008 @@ -90,7 +90,7 @@ static Use *op_end(User* U) { return reinterpret_cast(U); } - static unsigned operands(User*) { + static unsigned operands(const User*) { return ARITY; } struct prefix { @@ -182,15 +182,15 @@ } /// Transparently provide more efficient getOperand methods. - Value *getOperand(unsigned i) const { - assert(i < 2 && "getOperand() out of range!"); - return OperandList[i]; - } - void setOperand(unsigned i, Value *Val) { - assert(i < 2 && "setOperand() out of range!"); - OperandList[i] = Val; - } - unsigned getNumOperands() const { return 2; } + Value *getOperand(unsigned i) const; /*{ + assert(i < OperandTraits::operands && "getOperand() out of range!"); + return OperandTraits::op_begin(this)[i]; + }*/ + void setOperand(unsigned i, Value *Val); /*{ + assert(i < OperandTraits::operands && "setOperand() out of range!"); + OperandTraits::op_begin(this)[i] = Val; + }*/ + unsigned getNumOperands() const;// { return OperandTraits::operands; } /// create() - Construct a binary instruction, given the opcode and the two /// operands. Optionally (if InstBefore is specified) insert the instruction @@ -289,6 +289,17 @@ struct OperandTraits : FixedNumOperandTraits<2> { }; +Value *BinaryOperator::getOperand(unsigned i) const { + assert(i < OperandTraits::operands(this) && "getOperand() out of range!"); + return OperandTraits::op_begin(const_cast(this))[i]; +} +void BinaryOperator::setOperand(unsigned i, Value *Val) { + assert(i < OperandTraits::operands(this) && "setOperand() out of range!"); + OperandTraits::op_begin(this)[i] = Val; +} +unsigned BinaryOperator::getNumOperands() const { return OperandTraits::operands(this); } + + //===----------------------------------------------------------------------===// // CastInst Class //===----------------------------------------------------------------------===// Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49471&r1=49470&r2=49471&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/User.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/User.h Thu Apr 10 03:38:30 2008 @@ -200,7 +200,7 @@ struct OperandTraits { static inline Use *op_begin(User*); static inline Use *op_end(User*); - static inline unsigned operands(User*); + static inline unsigned operands(const User*); template struct Layout { typedef U overlay; @@ -308,7 +308,7 @@ return U->op_end(); } -inline unsigned OperandTraits::operands(User *U) { +inline unsigned OperandTraits::operands(const User *U) { return U->getNumOperands(); } /* From nicolas.geoffray at lip6.fr Thu Apr 10 03:57:20 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 10 Apr 2008 08:57:20 -0000 Subject: [llvm-commits] [vmkit] r49472 - /vmkit/trunk/lib/Mvm/Disassembler.cpp Message-ID: <200804100857.m3A8vKFM003009@zion.cs.uiuc.edu> Author: geoffray Date: Thu Apr 10 03:57:19 2008 New Revision: 49472 URL: http://llvm.org/viewvc/llvm-project?rev=49472&view=rev Log: Cmpilation fix for linux/x86 Modified: vmkit/trunk/lib/Mvm/Disassembler.cpp Modified: vmkit/trunk/lib/Mvm/Disassembler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Disassembler.cpp?rev=49472&r1=49471&r2=49472&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Disassembler.cpp (original) +++ vmkit/trunk/lib/Mvm/Disassembler.cpp Thu Apr 10 03:57:19 2008 @@ -49,7 +49,7 @@ # include // bfd types # include // disassemble_info int print_insn_i386_att(bfd_vma, disassemble_info *); -}; +} static struct disassemble_info info; From baldrick at free.fr Thu Apr 10 03:58:51 2008 From: baldrick at free.fr (Duncan Sands) Date: Thu, 10 Apr 2008 10:58:51 +0200 Subject: [llvm-commits] [llvm] r49458 - /llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp In-Reply-To: <200804100207.m3A27ph4015558@zion.cs.uiuc.edu> References: <200804100207.m3A27ph4015558@zion.cs.uiuc.edu> Message-ID: <200804101058.52981.baldrick@free.fr> Hi, > + // x pow(x, 0.5) sqrt(x) > + // --------------------------------------------- > + // -0.0 +0.0 -0.0 > + // -inf +inf NaN looks like pow is broken. Is pow's behaviour documented anywhere? On my machine the man page says: The pow() function can return the following error: EDOM The argument x is negative and y is not an integral value. This would result in a complex num? ber. Are you sure errno is not being set by pow in these cases? Ciao, Duncan. From ggreif at gmail.com Thu Apr 10 04:51:04 2008 From: ggreif at gmail.com (Gabor Greif) Date: Thu, 10 Apr 2008 09:51:04 -0000 Subject: [llvm-commits] [llvm] r49473 - /llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h Message-ID: <200804100951.m3A9p4V4005289@zion.cs.uiuc.edu> Author: ggreif Date: Thu Apr 10 04:51:03 2008 New Revision: 49473 URL: http://llvm.org/viewvc/llvm-project?rev=49473&view=rev Log: fix 'duplicate definition' linker errors by declaring methods as inline Modified: llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h Modified: llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h?rev=49473&r1=49472&r2=49473&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h Thu Apr 10 04:51:03 2008 @@ -182,15 +182,9 @@ } /// Transparently provide more efficient getOperand methods. - Value *getOperand(unsigned i) const; /*{ - assert(i < OperandTraits::operands && "getOperand() out of range!"); - return OperandTraits::op_begin(this)[i]; - }*/ - void setOperand(unsigned i, Value *Val); /*{ - assert(i < OperandTraits::operands && "setOperand() out of range!"); - OperandTraits::op_begin(this)[i] = Val; - }*/ - unsigned getNumOperands() const;// { return OperandTraits::operands; } + inline Value *getOperand(unsigned i) const; + inline void setOperand(unsigned i, Value *Val); + inline unsigned getNumOperands() const; /// create() - Construct a binary instruction, given the opcode and the two /// operands. Optionally (if InstBefore is specified) insert the instruction From isanbard at gmail.com Thu Apr 10 04:57:50 2008 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 10 Apr 2008 02:57:50 -0700 Subject: [llvm-commits] [llvm] r49458 - /llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp In-Reply-To: <200804101058.52981.baldrick@free.fr> References: <200804100207.m3A27ph4015558@zion.cs.uiuc.edu> <200804101058.52981.baldrick@free.fr> Message-ID: <9B4C520F-3E10-4183-891C-A5D83F70F0A7@gmail.com> On Apr 10, 2008, at 1:58 AM, Duncan Sands wrote: >> + // x pow(x, 0.5) sqrt(x) >> + // --------------------------------------------- >> + // -0.0 +0.0 -0.0 >> + // -inf +inf NaN > > looks like pow is broken. Is pow's behaviour documented > anywhere? On my machine the man page says: > > The pow() function can return the following error: > > EDOM The argument x is negative and y is not an integral > value. This would result in a complex num? > ber. > > Are you sure errno is not being set by pow in these cases? > This is what we have on Darwin: ... pow(x, y) returns a NaN and raises the "invalid" floating-point exception for finite x < 0 and finite non-integer y. ... The man page says nothing about errno. It claims to follow this standard: The pow() function conforms to ISO/IEC 9899:1999(E). -bw From ggreif at gmail.com Thu Apr 10 05:17:23 2008 From: ggreif at gmail.com (Gabor Greif) Date: Thu, 10 Apr 2008 10:17:23 -0000 Subject: [llvm-commits] [llvm] r49474 - /llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h Message-ID: <200804101017.m3AAHNj1006061@zion.cs.uiuc.edu> Author: ggreif Date: Thu Apr 10 05:17:22 2008 New Revision: 49474 URL: http://llvm.org/viewvc/llvm-project?rev=49474&view=rev Log: generate boilerplate accessors by means of DECLARE/DEFINE_TRANSPARENT_OPERAND_ACCESSORS Modified: llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h Modified: llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h?rev=49474&r1=49473&r2=49474&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h Thu Apr 10 05:17:22 2008 @@ -107,6 +107,23 @@ }; +#define DECLARE_TRANSPARENT_OPERAND_ACCESSORS(VALUECLASS) \ + inline VALUECLASS *getOperand(unsigned) const; \ + inline void setOperand(unsigned, VALUECLASS*); \ + inline unsigned getNumOperands() const + + +#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS) \ +VALUECLASS *CLASS::getOperand(unsigned i) const { \ + assert(i < OperandTraits::operands(this) && "getOperand() out of range!"); \ + return OperandTraits::op_begin(const_cast(this))[i]; \ +} \ +void CLASS::setOperand(unsigned i, VALUECLASS *Val) { \ + assert(i < OperandTraits::operands(this) && "setOperand() out of range!"); \ + OperandTraits::op_begin(this)[i] = Val; \ +} \ +unsigned CLASS::getNumOperands() const { return OperandTraits::operands(this); } + //===----------------------------------------------------------------------===// // UnaryInstruction Class @@ -133,8 +150,9 @@ // Out of line virtual method, so the vtable, etc has a home. ~UnaryInstruction(); - // Transparently provide more efficient getOperand methods. - Value *getOperand(unsigned i) const { + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +/* Value *getOperand(unsigned i) const { assert(i == 0 && "getOperand() out of range!"); return Op<0>(); } @@ -142,7 +160,7 @@ assert(i == 0 && "setOperand() out of range!"); Op<0>() = Val; } - unsigned getNumOperands() const { return 1; } + unsigned getNumOperands() const { return 1; }*/ // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const UnaryInstruction *) { return true; } @@ -163,6 +181,8 @@ struct OperandTraits : FixedNumOperandTraits<1> { }; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(UnaryInstruction, Value) + //===----------------------------------------------------------------------===// // BinaryOperator Class //===----------------------------------------------------------------------===// @@ -182,9 +202,10 @@ } /// Transparently provide more efficient getOperand methods. - inline Value *getOperand(unsigned i) const; + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +/* inline Value *getOperand(unsigned i) const; inline void setOperand(unsigned i, Value *Val); - inline unsigned getNumOperands() const; + inline unsigned getNumOperands() const;*/ /// create() - Construct a binary instruction, given the opcode and the two /// operands. Optionally (if InstBefore is specified) insert the instruction @@ -283,16 +304,7 @@ struct OperandTraits : FixedNumOperandTraits<2> { }; -Value *BinaryOperator::getOperand(unsigned i) const { - assert(i < OperandTraits::operands(this) && "getOperand() out of range!"); - return OperandTraits::op_begin(const_cast(this))[i]; -} -void BinaryOperator::setOperand(unsigned i, Value *Val) { - assert(i < OperandTraits::operands(this) && "setOperand() out of range!"); - OperandTraits::op_begin(this)[i] = Val; -} -unsigned BinaryOperator::getNumOperands() const { return OperandTraits::operands(this); } - +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BinaryOperator, Value) //===----------------------------------------------------------------------===// // CastInst Class @@ -540,6 +552,7 @@ /// This class is the base class for the comparison instructions. /// @brief Abstract base class of comparison instructions. +// FIXME: why not derive from BinaryOperator? class CmpInst: public Instruction { void *operator new(size_t, unsigned); // DO NOT IMPLEMENT CmpInst(); // do not implement @@ -589,7 +602,8 @@ } /// @brief Provide more efficient getOperand methods. - Value *getOperand(unsigned i) const { + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +/* Value *getOperand(unsigned i) const { assert(i < 2 && "getOperand() out of range!"); return OperandList[i]; } @@ -599,7 +613,7 @@ } /// @brief CmpInst instructions always have 2 operands. - unsigned getNumOperands() const { return 2; } + unsigned getNumOperands() const { return 2; }*/ /// This is just a convenience that dispatches to the subclasses. /// @brief Swap the operands and adjust predicate accordingly to retain @@ -639,6 +653,14 @@ } }; + +// FIXME: these are redundant if CmpInst < BinaryOperator +template <> +struct OperandTraits : FixedNumOperandTraits<2> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CmpInst, Value) + } // End llvm namespace #endif From ggreif at gmail.com Thu Apr 10 06:13:32 2008 From: ggreif at gmail.com (Gabor Greif) Date: Thu, 10 Apr 2008 11:13:32 -0000 Subject: [llvm-commits] [llvm] r49475 - in /llvm/branches/ggreif/use-diet: include/llvm/InstrTypes.h include/llvm/Instructions.h include/llvm/User.h lib/VMCore/Instructions.cpp Message-ID: <200804101113.m3ABDXJW007594@zion.cs.uiuc.edu> Author: ggreif Date: Thu Apr 10 06:13:26 2008 New Revision: 49475 URL: http://llvm.org/viewvc/llvm-project?rev=49475&view=rev Log: expand functionality of *_TRANSPARENT_OPERAND_ACCESSORS, cleanups, convert GetResultInst Modified: llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h llvm/branches/ggreif/use-diet/include/llvm/Instructions.h llvm/branches/ggreif/use-diet/include/llvm/User.h llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Modified: llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h?rev=49475&r1=49474&r2=49475&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h Thu Apr 10 06:13:26 2008 @@ -106,13 +106,15 @@ static inline void *allocate(unsigned); // FIXME }; - +/// Macro for generating in-class operand accessor declarations #define DECLARE_TRANSPARENT_OPERAND_ACCESSORS(VALUECLASS) \ inline VALUECLASS *getOperand(unsigned) const; \ inline void setOperand(unsigned, VALUECLASS*); \ - inline unsigned getNumOperands() const - + inline unsigned getNumOperands() const; \ + template inline Use &Op(); \ + template inline const Use &Op() const +/// Macro for generating out-of-class operand accessor definitions #define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS) \ VALUECLASS *CLASS::getOperand(unsigned i) const { \ assert(i < OperandTraits::operands(this) && "getOperand() out of range!"); \ @@ -122,7 +124,13 @@ assert(i < OperandTraits::operands(this) && "setOperand() out of range!"); \ OperandTraits::op_begin(this)[i] = Val; \ } \ -unsigned CLASS::getNumOperands() const { return OperandTraits::operands(this); } +unsigned CLASS::getNumOperands() const { return OperandTraits::operands(this); } \ +template Use &CLASS::Op() { \ + return OperandTraits::op_begin(this)[Idx]; \ +} \ +template const Use &CLASS::Op() const { \ + return OperandTraits::op_begin(const_cast(this))[Idx]; \ +} //===----------------------------------------------------------------------===// @@ -152,15 +160,6 @@ /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -/* Value *getOperand(unsigned i) const { - assert(i == 0 && "getOperand() out of range!"); - return Op<0>(); - } - void setOperand(unsigned i, Value *Val) { - assert(i == 0 && "setOperand() out of range!"); - Op<0>() = Val; - } - unsigned getNumOperands() const { return 1; }*/ // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const UnaryInstruction *) { return true; } @@ -203,9 +202,6 @@ /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -/* inline Value *getOperand(unsigned i) const; - inline void setOperand(unsigned i, Value *Val); - inline unsigned getNumOperands() const;*/ /// create() - Construct a binary instruction, given the opcode and the two /// operands. Optionally (if InstBefore is specified) insert the instruction @@ -603,17 +599,6 @@ /// @brief Provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -/* Value *getOperand(unsigned i) const { - assert(i < 2 && "getOperand() out of range!"); - return OperandList[i]; - } - void setOperand(unsigned i, Value *Val) { - assert(i < 2 && "setOperand() out of range!"); - OperandList[i] = Val; - } - - /// @brief CmpInst instructions always have 2 operands. - unsigned getNumOperands() const { return 2; }*/ /// This is just a convenience that dispatches to the subclasses. /// @brief Swap the operands and adjust predicate accordingly to retain Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=49475&r1=49474&r2=49475&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Thu Apr 10 06:13:26 2008 @@ -2578,7 +2578,8 @@ return Idx; } - unsigned getNumOperands() const { return 1; } + /// Provide fast operand accessors + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const GetResultInst *) { return true; } @@ -2590,6 +2591,14 @@ } }; +// FIXME: these are redundant if GetResultInst < UnaryInstruction +template <> +struct OperandTraits : FixedNumOperandTraits<1> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GetResultInst, Value) + + } // End llvm namespace #endif Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49475&r1=49474&r2=49475&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/User.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/User.h Thu Apr 10 06:13:26 2008 @@ -235,7 +235,7 @@ return Obj; } User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps) - : Value(Ty, vty)/*, OperandList(OpList), NumOperands(NumOps)*/ {} + : Value(Ty, vty), OperandList(OpList), NumOperands(NumOps) {} public: void operator delete(void *Usr) { User *Start = static_cast(Usr); Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp?rev=49475&r1=49474&r2=49475&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Thu Apr 10 06:13:26 2008 @@ -2253,7 +2253,10 @@ CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS, const std::string &Name, Instruction *InsertBefore) - : Instruction(Type::Int1Ty, op, /*Ops*/NULL, 2, InsertBefore) { + : Instruction(Type::Int1Ty, op, + OperandTraits::op_begin(this), + OperandTraits::operands(this), + InsertBefore) { Op<0>().init(LHS, this); Op<1>().init(RHS, this); SubclassData = predicate; @@ -2282,10 +2285,13 @@ assert(Op0Ty->isFloatingPoint() && "Invalid operand types for FCmp instruction"); } - + CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(Type::Int1Ty, op, /*Ops*/NULL, 2, InsertAtEnd) { + : Instruction(Type::Int1Ty, op, + OperandTraits::op_begin(this), + OperandTraits::operands(this), + InsertAtEnd) { Op<0>().init(LHS, this); Op<1>().init(RHS, this); SubclassData = predicate; @@ -2677,7 +2683,10 @@ const std::string &Name, Instruction *InsertBef) : Instruction(cast(Aggregate->getType())->getElementType(Index), - GetResult, /*&Aggr*/NULL, 1, InsertBef) { + GetResult, + OperandTraits::op_begin(this), + OperandTraits::operands(this), + InsertBef) { assert(isValidOperands(Aggregate, Index) && "Invalid GetResultInst operands!"); Op<0>().init(Aggregate, this); Idx = Index; From nicolas.geoffray at lip6.fr Thu Apr 10 06:23:37 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 10 Apr 2008 11:23:37 -0000 Subject: [llvm-commits] [vmkit] r49476 - in /vmkit/trunk: include/mvm/GC/GC.h include/mvm/Threads/Thread.h lib/Mvm/CommonThread/ctthread.cpp lib/Mvm/GCMmap2/gc.cpp lib/Mvm/GCMmap2/gccollector.cpp lib/Mvm/GCMmap2/gccollector.h lib/Mvm/GCMmap2/main.cpp lib/Mvm/Object.cpp Message-ID: <200804101123.m3ABNdlM007888@zion.cs.uiuc.edu> Author: geoffray Date: Thu Apr 10 06:23:26 2008 New Revision: 49476 URL: http://llvm.org/viewvc/llvm-project?rev=49476&view=rev Log: A thread now owns a collector for builds with MULTIPLE_VM Modified: vmkit/trunk/include/mvm/GC/GC.h vmkit/trunk/include/mvm/Threads/Thread.h vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h vmkit/trunk/lib/Mvm/GCMmap2/main.cpp vmkit/trunk/lib/Mvm/Object.cpp Modified: vmkit/trunk/include/mvm/GC/GC.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/GC/GC.h?rev=49476&r1=49475&r2=49476&view=diff ============================================================================== --- vmkit/trunk/include/mvm/GC/GC.h (original) +++ vmkit/trunk/include/mvm/GC/GC.h Thu Apr 10 06:23:26 2008 @@ -26,41 +26,43 @@ virtual void destroyer(size_t) {} virtual void tracer(size_t) {} - void markAndTrace() const; - size_t objectSize() const; - void * operator new(size_t sz, VirtualTable *VT); - void operator delete(void *); - void * realloc(size_t n); + void markAndTrace() const; + size_t objectSize() const; + void * operator new(size_t sz, VirtualTable *VT); + void * operator new(size_t sz); + void operator delete(void *); + void * realloc(size_t n); }; class gc_header { public: VirtualTable *_XXX_vt; - inline gc *_2gc() { return (gc *)this; } + inline gc *_2gc() { return (gc *)this; } }; class Collector { public: - typedef void (*markerFn)(void); - - static void initialise(markerFn mark, void *base_sp); - static void destroy(); + typedef void (*markerFn)(void); + + static void initialise(markerFn mark, void *base_sp); + static void destroy(); - static void die_if_sigsegv_occured_during_collection(void *addr); - static int isStable(gc_lock_recovery_fct_t, int, int, int, int, + static void die_if_sigsegv_occured_during_collection(void *addr); + static int isStable(gc_lock_recovery_fct_t, int, int, int, int, int, int, int, int); - static unsigned int enable(unsigned int n); - static void gcStats(size_t &no, size_t &nbb); - static void maybeCollect(); - static void collect(void); - static void inject_my_thread(void *sp); - static void remove_my_thread(); - - static gc *begOf(const void *o); - static int byteOffset(void *o); - inline static bool isObject(const void *o) { return begOf((void*)o); } + static unsigned int enable(unsigned int n); + static void gcStats(size_t &no, size_t &nbb); + static void maybeCollect(); + static void collect(void); + static void inject_my_thread(void *sp); + static void remove_my_thread(); + static Collector* allocate(); + + static gc *begOf(const void *o); + static int byteOffset(void *o); + inline static bool isObject(const void *o) { return begOf((void*)o); } static void applyFunc(void (*func)(gc *o, void *data), void *data); static void registerMemoryError(void (*func)(unsigned int)); static int getMaxMemory(void); Modified: vmkit/trunk/include/mvm/Threads/Thread.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/Thread.h?rev=49476&r1=49475&r2=49476&view=diff ============================================================================== --- vmkit/trunk/include/mvm/Threads/Thread.h (original) +++ vmkit/trunk/include/mvm/Threads/Thread.h Thu Apr 10 06:23:26 2008 @@ -10,14 +10,13 @@ #ifndef MVM_THREAD_H #define MVM_THREAD_H -#include "mvm/Object.h" #include "mvm/Threads/Key.h" class Collector; namespace mvm { -class Thread : public Object{ +class Thread : public gc { public: static void yield(void); static void yield(unsigned int *); @@ -28,10 +27,10 @@ static int start(int *tid, int (*fct)(void *), void *arg); static mvm::Key* threadKey; -#ifdef MULTIPLE_VM Collector* GC; -#endif - static Thread* get(); + static Thread* get() { + return (Thread*)Thread::threadKey->get(); + } }; Modified: vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp?rev=49476&r1=49475&r2=49476&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp (original) +++ vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp Thu Apr 10 06:23:26 2008 @@ -66,6 +66,9 @@ } void Thread::initialise() { + Thread::threadKey = new mvm::Key(); + Thread* th = new Thread(); + mvm::Thread::threadKey->set(th); } int Thread::start(int *tid, int (*fct)(void *), void *arg) { Modified: vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp?rev=49476&r1=49475&r2=49476&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp Thu Apr 10 06:23:26 2008 @@ -7,20 +7,26 @@ // //===----------------------------------------------------------------------===// +#include + #include "mvm/GC/GC.h" #include "gccollector.h" #include "gcerror.h" using namespace mvm; -static GCCollector TheCollector; +#ifdef MULTIPLE_VM +#define COLLECTOR ((GCCollector*)(mvm::Thread::get()->GC))-> +#else +#define COLLECTOR GCCollector:: +#endif typedef void (*memoryError_t)(unsigned int); memoryError_t GCCollector::internMemoryError; void gc::markAndTrace() const { - TheCollector.markAndTrace((void*)this); + COLLECTOR markAndTrace((void*)this); } size_t gc::objectSize() const { @@ -28,7 +34,11 @@ } void *gc::operator new(size_t sz, VirtualTable *vt) { - return TheCollector.gcmalloc(vt, sz); + return COLLECTOR gcmalloc(vt, sz); +} + +void *gc::operator new(size_t sz) { + return malloc(sz); } void gc::operator delete(void *) { @@ -36,52 +46,57 @@ } void *gc::realloc(size_t n) { - return TheCollector.gcrealloc(this, n); + return COLLECTOR gcrealloc(this, n); } unsigned int Collector::enable(unsigned int n) { - return TheCollector.enable(n); + return COLLECTOR enable(n); } int Collector::isStable(gc_lock_recovery_fct_t fct, int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7) { - return TheCollector.isStable(fct, a0, a1, a2, a3, a4, a5, a6, a7); + return COLLECTOR isStable(fct, a0, a1, a2, a3, a4, a5, a6, a7); } void Collector::die_if_sigsegv_occured_during_collection(void *addr) { - TheCollector.die_if_sigsegv_occured_during_collection(addr); + COLLECTOR die_if_sigsegv_occured_during_collection(addr); } void Collector::gcStats(size_t &no, size_t &nbb) { - TheCollector.gcStats(&no, &nbb); + COLLECTOR gcStats(&no, &nbb); } void Collector::initialise(markerFn marker, void *base_sp) { #ifdef HAVE_PTHREAD - Thread::initialise(); + Thread::initialise(); #endif - TheCollector.initialise(marker); -#ifdef HAVE_PTHREAD - TheCollector.inject_my_thread(base_sp); +#ifdef MULTIPLE_VM + GCCollector* GC = new GCCollector(); + GC->initialise(marker); + GC->inject_my_thread(base_sp); + mvm::Thread::get()->GC = GC; +#else + GCCollector::initialise(marker); + GCCollector::inject_my_thread(base_sp); #endif } void Collector::destroy() { - TheCollector.destroy(); + COLLECTOR destroy(); } void Collector::inject_my_thread(void *base_sp) { #ifdef HAVE_PTHREAD - TheCollector.inject_my_thread(base_sp); + COLLECTOR inject_my_thread(base_sp); #endif } void Collector::maybeCollect() { - TheCollector.maybeCollect(); + COLLECTOR maybeCollect(); } void Collector::collect(void) { - TheCollector.collect(); + COLLECTOR collect(); } gc *Collector::begOf(const void *obj) { @@ -96,7 +111,7 @@ void Collector::applyFunc(void (*func)(gc *o, void *data), void *data) { - return TheCollector.applyFunc(func, data); + return COLLECTOR applyFunc(func, data); } int Collector::getMaxMemory(void){ @@ -124,22 +139,22 @@ void Collector::remove_my_thread() { #ifdef HAVE_PTHREAD - TheCollector.remove_thread(TheCollector.threads->myloc()); + COLLECTOR remove_thread(COLLECTOR threads->myloc()); #endif } #ifdef HAVE_PTHREAD void GCCollector::siggc_handler(int) { - GCThreadCollector *loc = TheCollector.threads->myloc(); - register unsigned int cm = TheCollector.current_mark; + GCThreadCollector *loc = COLLECTOR threads->myloc(); + register unsigned int cm = COLLECTOR current_mark; // jmp_buf buf; // setjmp(buf); - TheCollector.threads->stackLock(); + COLLECTOR threads->stackLock(); if(!loc) /* a key is being destroyed */ - TheCollector.threads->another_mark(); + COLLECTOR threads->another_mark(); else if(loc->current_mark() != cm) { register unsigned int **cur = (unsigned int **)&cur; register unsigned int **max = loc->base_sp(); @@ -147,29 +162,33 @@ GCChunkNode *node; for(; curremove(); - node->append(TheCollector.used_nodes); - TheCollector.mark(node); + node->append(COLLECTOR used_nodes); + COLLECTOR mark(node); } } loc->current_mark(cm); - TheCollector.threads->another_mark(); + COLLECTOR threads->another_mark(); - TheCollector.threads->waitCollection(); + COLLECTOR threads->waitCollection(); } - TheCollector.threads->stackUnlock(); + COLLECTOR threads->stackUnlock(); } #endif void GCThread::waitCollection() { - unsigned int cm = TheCollector.current_mark; + unsigned int cm = COLLECTOR current_mark; if(Thread::self() != collector_tid) { collectorGo(); - while((TheCollector.current_mark == cm) && - (TheCollector.status == GCCollector::stat_collect)) + while((COLLECTOR current_mark == cm) && + (COLLECTOR status == GCCollector::stat_collect)) _collectionCond.wait(&_stackLock); } } + +Collector* Collector::allocate() { + return new GCCollector(); +} Modified: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp?rev=49476&r1=49475&r2=49476&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp Thu Apr 10 06:23:26 2008 @@ -12,6 +12,31 @@ using namespace mvm; +#ifndef MULTIPLE_VM +GCAllocator *GCCollector::allocator = 0; +#ifdef HAVE_PTHREAD +GCThread *GCCollector::threads; +#endif + +GCCollector::markerFn GCCollector::_marker; + +int GCCollector::_collect_freq_auto; +int GCCollector::_collect_freq_maybe; +int GCCollector::_since_last_collection; + +bool GCCollector::_enable_auto; +bool GCCollector::_enable_maybe; +bool GCCollector::_enable_collection; + +int GCCollector::status; + +GCChunkNode *GCCollector::used_nodes; +GCChunkNode *GCCollector::unused_nodes; + +unsigned int GCCollector::current_mark; +#endif + + void GCCollector::do_collect() { //printf("----- do collect -----\n"); jmp_buf buf; Modified: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h?rev=49476&r1=49475&r2=49476&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h Thu Apr 10 06:23:26 2008 @@ -17,45 +17,51 @@ #endif #include "mvm/GC/GC.h" +#ifdef MULTIPLE_VM +#define STATIC +#else +#define STATIC static +#endif + namespace mvm { class GCCollector : public Collector { #ifdef HAVE_PTHREAD friend class GCThread; #endif - GCAllocator *allocator; /* The allocator */ + STATIC GCAllocator *allocator; /* The allocator */ - Collector::markerFn _marker; /* The function which traces roots */ + STATIC Collector::markerFn _marker; /* The function which traces roots */ - GCChunkNode *used_nodes; /* Used memory nodes */ - GCChunkNode *unused_nodes; /* Unused memory nodes */ + STATIC GCChunkNode *used_nodes; /* Used memory nodes */ + STATIC GCChunkNode *unused_nodes; /* Unused memory nodes */ - unsigned int current_mark; + STATIC unsigned int current_mark; - int _collect_freq_auto; /* Collection frequency in gcmalloc/gcrealloc */ - int _collect_freq_maybe; /* Collection frequency in maybeCollect */ - int _since_last_collection; /* Bytes left since last collection */ - bool _enable_auto; /* Automatic collection? */ - bool _enable_maybe; /* Collection in maybeCollect()? */ - bool _enable_collection; /* collection authorized? */ - int status; + STATIC int _collect_freq_auto; /* Collection frequency in gcmalloc/gcrealloc */ + STATIC int _collect_freq_maybe; /* Collection frequency in maybeCollect */ + STATIC int _since_last_collection; /* Bytes left since last collection */ + STATIC bool _enable_auto; /* Automatic collection? */ + STATIC bool _enable_maybe; /* Collection in maybeCollect()? */ + STATIC bool _enable_collection; /* collection authorized? */ + STATIC int status; enum { stat_collect, stat_finalize, stat_alloc, stat_broken }; #ifdef HAVE_PTHREAD static void siggc_handler(int); - inline void lock() { threads->lock(); } - inline void unlock() { threads->unlock(); } + STATIC inline void lock() { threads->lock(); } + STATIC inline void unlock() { threads->unlock(); } #else static void siggc_handler(int) { } - inline void lock() { } - inline void unlock() { } + STATIC inline void lock() { } + STATIC inline void unlock() { } #endif /* Interface for collection, verifies enable_collect */ - void collect_unprotect(); + STATIC void collect_unprotect(); /* The collection */ - void do_collect(); + STATIC void do_collect(); static inline GCChunkNode *o2node(void *p) { return GCHash::get(p)->o2node(p, GCChunkNode::maskCollectable); @@ -66,48 +72,48 @@ } public: - GCThread *threads; /* le gestionnaire de thread et de synchro */ + STATIC GCThread *threads; /* le gestionnaire de thread et de synchro */ static void (*internMemoryError)(unsigned int); #ifdef HAVE_PTHREAD - inline void unlock_dont_recovery() { threads->unlock_dont_recovery(); } - void die_if_sigsegv_occured_during_collection(void *addr); + STATIC inline void unlock_dont_recovery() { threads->unlock_dont_recovery(); } + STATIC void die_if_sigsegv_occured_during_collection(void *addr); #else - void die_if_sigsegv_occured_during_collection(void *addr) { } + STATIC void die_if_sigsegv_occured_during_collection(void *addr) { } #endif - void defaultMemoryError(unsigned int sz){ + STATIC void defaultMemoryError(unsigned int sz){ unlock(); internMemoryError(sz); lock(); } - void initialise(Collector::markerFn marker); - void destroy(); + STATIC void initialise(Collector::markerFn marker); + STATIC void destroy(); static int siggc(); #ifdef HAVE_PTHREAD - void inject_my_thread(void *base_sp); - inline void remove_thread(GCThreadCollector *loc) { + STATIC void inject_my_thread(void *base_sp); + STATIC inline void remove_thread(GCThreadCollector *loc) { threads->remove(loc); } - inline int isStable(gc_lock_recovery_fct_t fct, int a0, int a1, int a2, - int a3, int a4, int a5, int a6, int a7) { + STATIC inline int isStable(gc_lock_recovery_fct_t fct, int a0, int a1, int a2, + int a3, int a4, int a5, int a6, int a7) { return threads->isStable(fct, a0, a1, a2, a3, a4, a5, a6, a7); } #else - inline int isStable(gc_lock_recovery_fct_t fct, int a0, int a1, int a2, - int a3, int a4, int a5, int a6, int a7) { + STATIC inline int isStable(gc_lock_recovery_fct_t fct, int a0, int a1, int a2, + int a3, int a4, int a5, int a6, int a7) { return 0; } #endif - inline void *allocate_unprotected(size_t sz) { + STATIC inline void *allocate_unprotected(size_t sz) { return allocator->alloc(sz); } - inline void free_unprotected(void *ptr) { + STATIC inline void free_unprotected(void *ptr) { allocator->free(ptr); } @@ -119,26 +125,26 @@ return 0; } - void gcStats(size_t *no, size_t *nbb); + STATIC void gcStats(size_t *no, size_t *nbb); static inline size_t objectSize(void *ptr) { GCChunkNode *node = o2node(ptr); return node ? real_nbb(node) : 0; } - inline void collect() { + STATIC inline void collect() { lock(); collect_unprotect(); unlock(); } - inline void maybeCollect() { + STATIC inline void maybeCollect() { if(_enable_auto && (_since_last_collection <= (_collect_freq_auto - _collect_freq_maybe))) collect(); } - inline gc *gcmalloc(VirtualTable *vt, size_t n) { + STATIC inline gc *gcmalloc(VirtualTable *vt, size_t n) { lock(); register GCChunkNode *header = allocator->alloc_chunk(n + sizeof(gc_header), 1, current_mark & 1); @@ -157,7 +163,7 @@ return p->_2gc(); } - inline gc *gcrealloc(void *ptr, size_t n) { + STATIC inline gc *gcrealloc(void *ptr, size_t n) { lock(); GCPage *desc = GCHash::get(ptr); @@ -184,27 +190,27 @@ return obj->_2gc(); } - inline unsigned int enable(unsigned int n) { + STATIC inline unsigned int enable(unsigned int n) { register unsigned int old = _enable_collection; _enable_collection = n; return old; } - inline bool isMarked(GCChunkNode *node) { + STATIC inline bool isMarked(GCChunkNode *node) { return node->mark() == (current_mark & 1); } - inline void mark(GCChunkNode *node) { + STATIC inline void mark(GCChunkNode *node) { node->_mark(current_mark & 1); } - inline void trace(GCChunkNode *node) { + STATIC inline void trace(GCChunkNode *node) { gc_header *o = node->chunk(); o->_2gc()->tracer(real_nbb(node)); markAndTrace(o); } - inline void markAndTrace(void *ptr) { + STATIC inline void markAndTrace(void *ptr) { GCChunkNode *node = o2node(ptr); if(node && !isMarked(node)) { @@ -215,7 +221,7 @@ } } - inline void applyFunc(void (*func)(gc *o, void *data), void *data){ + STATIC inline void applyFunc(void (*func)(gc *o, void *data), void *data){ lock(); /* Make sure no one collects or allocates */ status = stat_collect; /* Forbids collections */ GCChunkNode *cur=used_nodes->next(); /* Get starter */ Modified: vmkit/trunk/lib/Mvm/GCMmap2/main.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/main.cpp?rev=49476&r1=49475&r2=49476&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/main.cpp (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/main.cpp Thu Apr 10 06:23:26 2008 @@ -8,8 +8,11 @@ //===----------------------------------------------------------------------===// #include "mvm/GC/GC.h" +#include "mvm/Threads/Thread.h" #include +mvm::Key* mvm::Thread::threadKey = 0; + void destr(gc *me, size_t sz) { printf("Destroy %p\n", me); } @@ -24,9 +27,8 @@ int main(int argc, char **argv) { Collector::initialise(marker, 0); - - Collector::destroy(); - return 0; + Collector::destroy(); + return 0; } Modified: vmkit/trunk/lib/Mvm/Object.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Object.cpp?rev=49476&r1=49475&r2=49476&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Object.cpp (original) +++ vmkit/trunk/lib/Mvm/Object.cpp Thu Apr 10 06:23:26 2008 @@ -63,7 +63,6 @@ INIT(ExceptionTable); #undef INIT - Thread::threadKey = new mvm::Key(); } void Code::tracer(size_t sz) { @@ -175,7 +174,3 @@ } NativeString *PrintBuffer::getContents() { return contents(); } - -Thread* Thread::get() { - return (Thread*)Thread::threadKey->get(); -} From baldrick at free.fr Thu Apr 10 06:25:34 2008 From: baldrick at free.fr (Duncan Sands) Date: Thu, 10 Apr 2008 13:25:34 +0200 Subject: [llvm-commits] [llvm] r49458 - /llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp In-Reply-To: <9B4C520F-3E10-4183-891C-A5D83F70F0A7@gmail.com> References: <200804100207.m3A27ph4015558@zion.cs.uiuc.edu> <200804101058.52981.baldrick@free.fr> <9B4C520F-3E10-4183-891C-A5D83F70F0A7@gmail.com> Message-ID: <200804101325.35656.baldrick@free.fr> > >> + ? ? ?// x ? ?pow(x, 0.5) ?sqrt(x) > >> + ? ? ?// --------------------------------------------- > >> + ? ? ?// -0.0 ? ?+0.0 ? ? ? -0.0 > >> + ? ? ?// -inf ? ?+inf ? ? ? NaN > > > > looks like pow is broken. ?Is pow's behaviour documented > > anywhere? ?On my machine the man page says: > > > > ? ? ? The pow() function can return the following error: > > > > ? ? ? EDOM ? The ?argument x is negative and y is not an integral ? > > value. ?This would result in a complex num? > > ? ? ? ? ? ? ?ber. > > > > Are you sure errno is not being set by pow in these cases? > > This is what we have on Darwin: > > ... > ????????pow(x, y) returns a NaN and raises the "invalid" floating-point ? > exception for finite x < 0 and finite non-integer y. > ... > > The man page says nothing about errno. It claims to follow this ? > standard: > > ????????The pow() function conforms to ISO/IEC 9899:1999(E). That standard says: 7.12.7.4 The pow functions Synopsis #include double pow(double x, double y); float powf(float x, float y); long double powl(long double x, long double y); Description The pow functions compute x raised to the power y. A domain error occurs if x is ?nite and negative and y is ?nite and not an integer value. A domain error may occur if x is zero and y is less than or equal to zero. A range error may occur. Returns The pow functions return x^y . Elsewhere it says: For all functions, a domain error occurs if an input argument is outside the domain over which the mathematical function is de?ned. The description of each function lists any required domain errors; an implementation may de?ne additional domain errors, provided that such errors are consistent with the mathematical de?nition of the function.194) On a domain error, the function returns an implementation-de?ned value; if the integer expression math_errhandling & MATH_ERRNO is nonzero, the integer expression errno acquires the value EDOM; if the integer expression math_errhandling & MATH_ERREXCEPT is nonzero, the ??invalid?? ?oating-point exception is raised. This doesn't say anything about when x=-inf, and it is not clear to me if -0.0 is negative. Anyway, at first glance it looks like the Darwin implementation conforms to the standard, though the values it returns for x=-inf and x=-0.0 are surprising. As for sqrt it says: > 7.12.7.5 The sqrt functions > Synopsis > #include > double sqrt(double x); > float sqrtf(float x); > long double sqrtl(long double x); > Description > The sqrt functions compute the nonnegative square root of x. A domain error > occurs if the argument is less than zero. So it looks like Darwin is wrong not to raise a floating point exception for sqrt(-inf), since -inf is less than zero. I don't know if -0.0 is less than zero. Finally, returning -0.0 for sqrt(-0.0) is surprising, since (-0.0)*(-0.0)=+0.0 not -0.0. Mine says: CONFORMING TO SVr4, 4.3BSD, C89. The float and long double variants are C99 requirements. Ciao, Duncan. From nicolas.geoffray at lip6.fr Thu Apr 10 06:35:46 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 10 Apr 2008 11:35:46 -0000 Subject: [llvm-commits] [vmkit] r49477 - in /vmkit/trunk/lib/JnJVM: Classpath/ VMCore/ Message-ID: <200804101135.m3ABZn9q008283@zion.cs.uiuc.edu> Author: geoffray Date: Thu Apr 10 06:35:38 2008 New Revision: 49477 URL: http://llvm.org/viewvc/llvm-project?rev=49477&view=rev Log: Isolate allocations between different instances of virtual machines Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathConstructor.cpp vmkit/trunk/lib/JnJVM/Classpath/ClasspathMethod.cpp vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.h vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaString.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h vmkit/trunk/lib/JnJVM/VMCore/LockedMap.cpp vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp vmkit/trunk/lib/JnJVM/VMCore/Reader.cpp vmkit/trunk/lib/JnJVM/VMCore/Reader.h vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp vmkit/trunk/lib/JnJVM/VMCore/Zip.cpp vmkit/trunk/lib/JnJVM/VMCore/Zip.h Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathConstructor.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathConstructor.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathConstructor.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathConstructor.cpp Thu Apr 10 06:35:38 2008 @@ -70,7 +70,7 @@ Class* cl = (Class*)_cl; cl->initialiseClass(); - JavaObject* res = cl->doNew(); + JavaObject* res = cl->doNew(vm); for (std::vector::iterator i = meth->signature->args.begin(), e = meth->signature->args.end(); i != e; ++i, ++index) { Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathMethod.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathMethod.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathMethod.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathMethod.cpp Thu Apr 10 06:35:38 2008 @@ -130,42 +130,42 @@ } else if (retType == AssessorDesc::dBool) { uint32 val = 0; RUN_METH(Int); - res = (*Classpath::boolClass)(); + res = (*Classpath::boolClass)(vm); (*Classpath::boolValue)(res, val); } else if (retType == AssessorDesc::dByte) { uint32 val = 0; RUN_METH(Int); - res = (*Classpath::byteClass)(); + res = (*Classpath::byteClass)(vm); (*Classpath::byteValue)(res, val); } else if (retType == AssessorDesc::dChar) { uint32 val = 0; RUN_METH(Int); - res = (*Classpath::charClass)(); + res = (*Classpath::charClass)(vm); (*Classpath::charValue)(res, val); } else if (retType == AssessorDesc::dShort) { uint32 val = 0; RUN_METH(Int); - res = (*Classpath::shortClass)(); + res = (*Classpath::shortClass)(vm); (*Classpath::shortValue)(res, val); } else if (retType == AssessorDesc::dInt) { uint32 val = 0; RUN_METH(Int); - res = (*Classpath::intClass)(); + res = (*Classpath::intClass)(vm); (*Classpath::intValue)(res, val); } else if (retType == AssessorDesc::dLong) { sint64 val = 0; RUN_METH(Long); - res = (*Classpath::longClass)(); + res = (*Classpath::longClass)(vm); (*Classpath::longValue)(res, val); } else if (retType == AssessorDesc::dFloat) { float val = 0; RUN_METH(Float); - res = (*Classpath::floatClass)(); + res = (*Classpath::floatClass)(vm); (*Classpath::floatValue)(res, val); } else if (retType == AssessorDesc::dDouble) { double val = 0; RUN_METH(Double); - res = (*Classpath::doubleClass)(); + res = (*Classpath::doubleClass)(vm); (*Classpath::doubleValue)(res, val); } else if (retType == AssessorDesc::dTab || retType == AssessorDesc::dRef) { JavaObject* val = 0; Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp Thu Apr 10 06:35:38 2008 @@ -80,9 +80,10 @@ jboolean publicOnly) { CommonClass* cl = NativeUtil::resolvedImplClass(Cl, false); + Jnjvm* vm = JavaThread::get()->isolate; if (cl->isArray || isInterface(cl->access)) { - return (jobject)ArrayObject::acons(0, Classpath::constructorArrayClass); + return (jobject)ArrayObject::acons(0, Classpath::constructorArrayClass, vm); } else { std::vector meths = cl->virtualMethods; std::vector res; @@ -93,13 +94,13 @@ } } - ArrayObject* ret = ArrayObject::acons(res.size(), Classpath::constructorArrayClass); + ArrayObject* ret = ArrayObject::acons(res.size(), Classpath::constructorArrayClass, vm); sint32 index = 0; for (std::vector::iterator i = res.begin(), e = res.end(); i != e; ++i, ++index) { JavaMethod* meth = *i; // TODO: check parameter types - JavaObject* tmp = (*Classpath::newConstructor)(); + JavaObject* tmp = (*Classpath::newConstructor)(vm); Classpath::initConstructor->invokeIntSpecial(tmp, Cl, meth); ret->setAt(index, tmp); } @@ -120,7 +121,7 @@ CommonClass* cl = NativeUtil::resolvedImplClass(Cl, false); if (cl->isArray) { - return (jobject)ArrayObject::acons(0, Classpath::methodArrayClass); + return (jobject)ArrayObject::acons(0, Classpath::methodArrayClass, vm); } else { std::vector meths = cl->virtualMethods; std::vector res; @@ -138,13 +139,13 @@ } } - ArrayObject* ret = ArrayObject::acons(res.size(), Classpath::methodArrayClass); + ArrayObject* ret = ArrayObject::acons(res.size(), Classpath::methodArrayClass, vm); sint32 index = 0; for (std::vector::iterator i = res.begin(), e = res.end(); i != e; ++i, ++index) { JavaMethod* meth = *i; // TODO: check parameter types - JavaObject* tmp = (*Classpath::newMethod)(); + JavaObject* tmp = (*Classpath::newMethod)(vm); Classpath::initMethod->invokeIntSpecial(tmp, Cl, vm->UTF8ToStr(meth->name), meth); ret->setAt(index, tmp); } @@ -297,7 +298,7 @@ CommonClass* cl = NativeUtil::resolvedImplClass(Cl, false); if (cl->isArray) { - return (jobject)ArrayObject::acons(0, Classpath::fieldArrayClass); + return (jobject)ArrayObject::acons(0, Classpath::fieldArrayClass, vm); } else { std::vector fields = cl->virtualFields; std::vector res; @@ -315,13 +316,13 @@ } } - ArrayObject* ret = ArrayObject::acons(res.size(), Classpath::fieldArrayClass); + ArrayObject* ret = ArrayObject::acons(res.size(), Classpath::fieldArrayClass, vm); sint32 index = 0; for (std::vector::iterator i = res.begin(), e = res.end(); i != e; ++i, ++index) { JavaField* field = *i; // TODO: check parameter types - JavaObject* tmp = (*Classpath::newField)(); + JavaObject* tmp = (*Classpath::newField)(vm); Classpath::initField->invokeIntSpecial(tmp, Cl, vm->UTF8ToStr(field->name), field); ret->setAt(index, tmp); } @@ -338,7 +339,7 @@ Jnjvm* vm = JavaThread::get()->isolate; CommonClass* cl = NativeUtil::resolvedImplClass(Cl, false); std::vector & interfaces = cl->interfaces; - ArrayObject* ret = ArrayObject::acons(interfaces.size(), Classpath::classArrayClass); + ArrayObject* ret = ArrayObject::acons(interfaces.size(), Classpath::classArrayClass, vm); sint32 index = 0; for (std::vector::iterator i = interfaces.begin(), e = interfaces.end(); i != e; ++i, ++index) { @@ -352,7 +353,8 @@ Attribut* attribut = Attribut::lookup(&cl->attributs, Attribut::innerClassesAttribut); if (attribut != 0) { - Reader* reader = attribut->toReader(cl->bytes, attribut); + Reader* reader = attribut->toReader(JavaThread::get()->isolate, cl->bytes, + attribut); uint16 nbi = reader->readU2(); for (uint16 i = 0; i < nbi; ++i) { @@ -403,7 +405,7 @@ Class* cl = (Class*)NativeUtil::resolvedImplClass(Cl, false); if (!(cl->innerOuterResolved)) resolveInnerOuterClasses(cl); - ArrayObject* res = ArrayObject::acons(cl->innerClasses.size(), Classpath::constructorArrayClass); + ArrayObject* res = ArrayObject::acons(cl->innerClasses.size(), Classpath::constructorArrayClass, vm); uint32 index = 0; for (std::vector::iterator i = cl->innerClasses.begin(), e = cl->innerClasses.end(); i!= e; i++) { Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp Thu Apr 10 06:35:38 2008 @@ -163,31 +163,32 @@ const AssessorDesc* ass = type->funcs; JavaObject* obj = (JavaObject*)_obj; llvm::GenericValue gv = (*field)(obj); + Jnjvm* vm = JavaThread::get()->isolate; JavaObject* res = 0; if (ass == AssessorDesc::dBool) { - res = (*Classpath::boolClass)(); + res = (*Classpath::boolClass)(vm); (*Classpath::boolValue)(res, (uint32)gv.IntVal.getBoolValue()); } else if (ass == AssessorDesc::dByte) { - res = (*Classpath::byteClass)(); + res = (*Classpath::byteClass)(vm); (*Classpath::byteValue)(res, (uint32)gv.IntVal.getSExtValue()); } else if (ass == AssessorDesc::dChar) { - res = (*Classpath::charClass)(); + res = (*Classpath::charClass)(vm); (*Classpath::charValue)(res, (uint32)gv.IntVal.getZExtValue()); } else if (ass == AssessorDesc::dShort) { - res = (*Classpath::shortClass)(); + res = (*Classpath::shortClass)(vm); (*Classpath::shortValue)(res, (uint32)gv.IntVal.getSExtValue()); } else if (ass == AssessorDesc::dInt) { - res = (*Classpath::intClass)(); + res = (*Classpath::intClass)(vm); (*Classpath::intValue)(res, (uint32)gv.IntVal.getSExtValue()); } else if (ass == AssessorDesc::dLong) { - res = (*Classpath::longClass)(); + res = (*Classpath::longClass)(vm); (*Classpath::longValue)(res, (sint64)gv.IntVal.getSExtValue()); } else if (ass == AssessorDesc::dFloat) { - res = (*Classpath::floatClass)(); + res = (*Classpath::floatClass)(vm); (*Classpath::floatValue)(res, gv.FloatVal); } else if (ass == AssessorDesc::dDouble) { - res = (*Classpath::doubleClass)(); + res = (*Classpath::doubleClass)(vm); (*Classpath::doubleValue)(res, gv.DoubleVal); } else if (ass == AssessorDesc::dTab || ass == AssessorDesc::dRef) { res = (JavaObject*)gv.PointerVal; Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp Thu Apr 10 06:35:38 2008 @@ -46,7 +46,7 @@ sint32 lgPre = vm->prelib->size; sint32 lgPost = vm->postlib->size; - UTF8* res = UTF8::acons(lgPre + lgLib + lgPost, JavaArray::ofChar); + UTF8* res = UTF8::acons(lgPre + lgLib + lgPost, JavaArray::ofChar, vm); memmove(res->elements, vm->prelib->elements, lgPre * sizeof(uint16)); memmove(&(res->elements[lgPre]), &(utf8Lib->elements[stLib]), lgLib * sizeof(uint16)); Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp Thu Apr 10 06:35:38 2008 @@ -41,7 +41,8 @@ return recGetClassContext(stack, size, first + 1, rec); } } else { - return ArrayObject::acons(rec, Classpath::classArrayClass); + Jnjvm* vm = JavaThread::get()->isolate; + return ArrayObject::acons(rec, Classpath::classArrayClass, vm); } } Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp Thu Apr 10 06:35:38 2008 @@ -86,7 +86,7 @@ JavaObject* javaThread = (JavaObject*)(*ClasspathThread::assocThread)(vmThread).PointerVal; assert(javaThread); - JavaThread* th = gc_new(JavaThread)(); + JavaThread* th = vm_new(JavaThread::get()->isolate, JavaThread)(); th->initialise(javaThread, JavaThread::get()->isolate); (*ClasspathThread::vmdata)(vmThread, (JavaObject*)th); int tid = 0; Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp Thu Apr 10 06:35:38 2008 @@ -43,11 +43,12 @@ #endif jobject throwable) { //int** fp = (int**)__builtin_frame_address(0); + Jnjvm* vm = JavaThread::get()->isolate; int** stack = (int**)alloca(sizeof(int*) * 100); int real_size = backtrace((void**)stack, 100); - ArrayUInt32* obj = ArrayUInt32::acons(real_size, JavaArray::ofInt); + ArrayUInt32* obj = ArrayUInt32::acons(real_size, JavaArray::ofInt, vm); memcpy(obj->elements, stack, real_size * sizeof(int)); - JavaObject* vmThrowable = (*Classpath::newVMThrowable)(); + JavaObject* vmThrowable = (*Classpath::newVMThrowable)(vm); Classpath::initVMThrowable->invokeIntSpecial(vmThrowable); (*Classpath::vmDataVMThrowable)(vmThrowable, obj); return (jobject)vmThrowable; @@ -64,19 +65,21 @@ Attribut::sourceFileAttribut); if (sourceAtt) { - Reader* reader = sourceAtt->toReader(cl->bytes, sourceAtt); + Reader* reader = sourceAtt->toReader(JavaThread::get()->isolate, cl->bytes, + sourceAtt); uint16 index = reader->readU2(); sourceName = vm->UTF8ToStr(cl->ctpInfo->UTF8At(index)); } bool native = isNative(meth->access); - JavaObject* res = (*Classpath::newStackTraceElement)(); + JavaObject* res = (*Classpath::newStackTraceElement)(vm); Classpath::initStackTraceElement->invokeIntSpecial(res, sourceName, (uint32)ip, className, methodName, native); return res; } ArrayObject* recGetStackTrace(int** stack, uint32 size, uint32 first, uint32 rec) { + Jnjvm* vm = JavaThread::get()->isolate; if (size != first) { int *begIp = (int*)Collector::begOf(stack[first]); JavaMethod* meth = ip_to_meth(begIp); @@ -88,7 +91,7 @@ return recGetStackTrace(stack, size, first + 1, rec); } } else { - return ArrayObject::acons(rec, JavaArray::ofObject); + return ArrayObject::acons(rec, JavaArray::ofObject, vm); } } Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp Thu Apr 10 06:35:38 2008 @@ -41,8 +41,9 @@ ClassArray* JavaArray::ofString = 0; ClassArray* JavaArray::ofObject = 0; +#ifndef MULTIPLE_VM #define ACONS(name, elmt, primSize) \ - name *name::acons(sint32 n, ClassArray* atype) { \ + name *name::acons(sint32 n, ClassArray* atype, Jnjvm* vm) { \ if (n < 0) \ JavaThread::get()->isolate->negativeArraySizeException(n); \ else if (n > JavaArray::MaxArraySize) \ @@ -54,6 +55,21 @@ memset(res->elements, 0, primSize * n); \ return res; \ } +#else +#define ACONS(name, elmt, primSize) \ + name *name::acons(sint32 n, ClassArray* atype, Jnjvm* vm) { \ + if (n < 0) \ + JavaThread::get()->isolate->negativeArraySizeException(n); \ + else if (n > JavaArray::MaxArraySize) \ + JavaThread::get()->isolate->outOfMemoryError(n); \ + name* res = (name*) \ + (Object*) vm->allocateObject(sizeof(name) + n * primSize, name::VT); \ + res->initialise(atype); \ + res->size = n; \ + memset(res->elements, 0, primSize * n); \ + return res; \ + } +#endif #define AT(name, elmt) \ elmt name::at(sint32 offset) const { \ @@ -88,13 +104,17 @@ #undef ACONS #undef AT -ArrayObject *ArrayObject::acons(sint32 n, ClassArray* atype) { +ArrayObject *ArrayObject::acons(sint32 n, ClassArray* atype, Jnjvm* vm) { if (n < 0) JavaThread::get()->isolate->negativeArraySizeException(n); else if (n > JavaArray::MaxArraySize) JavaThread::get()->isolate->outOfMemoryError(n); ArrayObject* res = (ArrayObject*) +#ifndef MULTIPLE_VM (Object*) operator new(sizeof(ArrayObject) + n * sizeof(JavaObject*), JavaObject::VT); +#else + (Object*) vm->allocateObject(sizeof(ArrayObject) + n * sizeof(JavaObject*), JavaObject::VT); +#endif res->initialise(atype); res->size = n; memset(res->elements, 0, sizeof(JavaObject*) * n); @@ -258,9 +278,10 @@ static JavaArray* multiCallNewIntern(arrayCtor_t ctor, ClassArray* cl, uint32 len, - sint32* dims) { + sint32* dims, + Jnjvm* vm) { if (len <= 0) JavaThread::get()->isolate->unknownError("Can not happen"); - JavaArray* _res = ctor(dims[0], cl); + JavaArray* _res = ctor(dims[0], cl, vm); if (len > 1) { ArrayObject* res = (ArrayObject*)_res; CommonClass* _base = cl->baseClass(); @@ -270,7 +291,8 @@ arrayCtor_t newCtor = func->arrayCtor; if (dims[0] > 0) { for (sint32 i = 0; i < dims[0]; ++i) { - res->setAt(i, multiCallNewIntern(newCtor, base, (len - 1), &dims[1])); + res->setAt(i, multiCallNewIntern(newCtor, base, (len - 1), &dims[1], + vm)); } } else { for (uint32 i = 1; i < len; ++i) { @@ -292,5 +314,10 @@ for (uint32 i = 0; i < len; ++i){ dims[i] = va_arg(ap, int); } - return multiCallNewIntern((arrayCtor_t)ArrayObject::acons, cl, len, dims); +#ifdef MULTIPLE_VM + Jnjvm* vm = va_arg(ap, Jnjvm*); +#else + Jnjvm* vm = 0; +#endif + return multiCallNewIntern((arrayCtor_t)ArrayObject::acons, cl, len, dims, vm); } Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h Thu Apr 10 06:35:38 2008 @@ -61,7 +61,7 @@ }; -typedef JavaArray* (*arrayCtor_t)(uint32 len, CommonClass* cl); +typedef JavaArray* (*arrayCtor_t)(uint32 len, CommonClass* cl, Jnjvm* vm); #define ARRAYCLASS(name, elmt) \ class name : public JavaArray { \ @@ -69,7 +69,7 @@ static VirtualTable* VT; \ static const llvm::Type* llvmType; \ elmt elements[0]; \ - static name *acons(sint32 n, ClassArray* cl); \ + static name *acons(sint32 n, ClassArray* cl, Jnjvm* vm); \ elmt at(sint32) const; \ void setAt(sint32, elmt); \ virtual void print(mvm::PrintBuffer* buf) const; \ @@ -93,7 +93,7 @@ static VirtualTable* VT; static const llvm::Type* llvmType; JavaObject* elements[0]; - static ArrayObject *acons(sint32 n, ClassArray* cl); + static ArrayObject *acons(sint32 n, ClassArray* cl, Jnjvm* vm); JavaObject* at(sint32) const; void setAt(sint32, JavaObject*); virtual void print(mvm::PrintBuffer* buf) const; @@ -106,7 +106,7 @@ uint16 elements[0]; static const llvm::Type* llvmType; - static UTF8* acons(sint32 n, ClassArray* cl); + static UTF8* acons(sint32 n, ClassArray* cl, Jnjvm* vm); unsigned short int at(sint32) const; void setAt(sint32, uint16); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp Thu Apr 10 06:35:38 2008 @@ -47,17 +47,16 @@ buf->write("Enveloppe<>"); } -CacheNode* CacheNode::allocate() { - CacheNode* cache = gc_new(CacheNode)(); - cache->lastCible = 0; - cache->methPtr = 0; - cache->next = 0; - return cache; +void CacheNode::initialise() { + this->lastCible = 0; + this->methPtr = 0; + this->next = 0; } Enveloppe* Enveloppe::allocate(JavaCtpInfo* ctp, uint32 index) { - Enveloppe* enveloppe = gc_new(Enveloppe)(); - enveloppe->firstCache = CacheNode::allocate(); + Enveloppe* enveloppe = vm_new(ctp->classDef->isolate, Enveloppe)(); + enveloppe->firstCache = vm_new(ctp->classDef->isolate, CacheNode)(); + enveloppe->firstCache->initialise(); enveloppe->firstCache->enveloppe = enveloppe; enveloppe->cacheLock = mvm::Lock::allocNormal(); enveloppe->ctpInfo = ctp; @@ -93,8 +92,9 @@ mvm::jit::protectConstants();//->lock(); Value* llvmEnv = - ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (enveloppe)), - Enveloppe::llvmType); + ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, + uint64_t (enveloppe)), + Enveloppe::llvmType); mvm::jit::unprotectConstants();//->unlock(); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h Thu Apr 10 06:35:38 2008 @@ -36,7 +36,7 @@ Enveloppe* enveloppe; static const llvm::Type* llvmType; - static CacheNode* allocate(); + void initialise(); }; Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Thu Apr 10 06:35:38 2008 @@ -57,15 +57,13 @@ buf->write(">"); } -Attribut* Attribut::derive(const UTF8* name, unsigned int length, const Reader* - reader) { +void Attribut::derive(const UTF8* name, unsigned int length, + const Reader* reader) { - Attribut* attr = gc_new(Attribut)(); - attr->start = reader->cursor; - attr->nbb = length; - attr->name = name; + this->start = reader->cursor; + this->nbb = length; + this->name = name; - return attr; } // TODO: Optimize @@ -80,8 +78,8 @@ return 0; } -Reader* Attribut::toReader(ArrayUInt8* array, Attribut* attr) { - return Reader::allocateReader(array, attr->start, attr->nbb); +Reader* Attribut::toReader(Jnjvm* vm, ArrayUInt8* array, Attribut* attr) { + return vm_new(vm, Reader)(array, attr->start, attr->nbb); } @@ -217,13 +215,13 @@ llvmType = signature->virtualType; } if (!methPtr) { - JavaJIT* jit = gc_new(JavaJIT)(); - jit->compilingClass = classDef; - jit->compilingMethod = this; + JavaJIT jit; + jit.compilingClass = classDef; + jit.compilingMethod = this; if (isNative(access)) { - methPtr = jit->nativeCompile(); + methPtr = jit.nativeCompile(); } else { - methPtr = jit->javaCompile(); + methPtr = jit.javaCompile(); } } // We can compile it, since if we're here, it's for a good reason @@ -355,18 +353,33 @@ return res; } -JavaObject* Class::doNew() { +#ifndef MULTIPLE_VM +JavaObject* Class::doNew(Jnjvm* vm) { JavaObject* res = (JavaObject*)gc::operator new(virtualSize, virtualVT); memcpy(res, virtualInstance, virtualSize); return res; } // Copy doNew because LLVM wants two different pointers (for simplicity) -JavaObject* Class::doNewUnknown() { +JavaObject* Class::doNewUnknown(Jnjvm* vm) { JavaObject* res = (JavaObject*)gc::operator new(virtualSize, virtualVT); memcpy(res, virtualInstance, virtualSize); return res; } +#else +JavaObject* Class::doNew(Jnjvm* vm) { + JavaObject* res = (JavaObject*)vm->allocateObject(virtualSize, virtualVT); + memcpy(res, virtualInstance, virtualSize); + return res; +} + +// Copy doNew because LLVM wants two different pointers (for simplicity) +JavaObject* Class::doNewUnknown(Jnjvm* vm) { + JavaObject* res = (JavaObject*)vm->allocateObject(virtualSize, virtualVT); + memcpy(res, virtualInstance, virtualSize); + return res; +} +#endif JavaObject* Class::initialiseObject(JavaObject* res) { memcpy(res, virtualInstance, virtualSize); @@ -474,7 +487,8 @@ if (!attribut) { JavaJIT::initField(this, obj); } else { - Reader* reader = attribut->toReader(classDef->bytes, attribut); + Reader* reader = attribut->toReader(classDef->isolate, + classDef->bytes, attribut); JavaCtpInfo * ctpInfo = classDef->ctpInfo; uint16 idx = reader->readU2(); if (funcs == AssessorDesc::dLong) { @@ -525,7 +539,8 @@ cl->staticVT = VT; #ifndef MULTIPLE_VM - JavaObject* val = (JavaObject*)gc::operator new(cl->staticSize, cl->staticVT); + JavaObject* val = (JavaObject*)cl->isolate->allocateObject(cl->staticSize, + cl->staticVT); val->initialise(cl); for (std::vector::iterator i = cl->staticFields.begin(), e = cl->staticFields.end(); i!= e; ++i) { @@ -565,7 +580,7 @@ uint64 size = mvm::jit::getTypeSize(cl->virtualType->getContainedType(0)); cl->virtualSize = size; cl->virtualVT = VT; - cl->virtualInstance = (JavaObject*)gc::operator new(size, VT); + cl->virtualInstance = (JavaObject*)cl->isolate->allocateObject(size, VT); cl->virtualInstance->initialise(cl); for (std::vector::iterator i = cl->virtualFields.begin(), @@ -607,7 +622,9 @@ } void Class::createStaticInstance() { - JavaObject* val = (JavaObject*)gc::operator new(staticSize, staticVT); + JavaObject* val = + (JavaObject*)JavaThread::get()->isolate->allocateObject(staticSize, + staticVT); val->initialise(this); for (std::vector::iterator i = this->staticFields.begin(), e = this->staticFields.end(); i!= e; ++i) { Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Thu Apr 10 06:35:38 2008 @@ -56,11 +56,10 @@ unsigned int start; unsigned int nbb; - static Attribut* derive(const UTF8* name, unsigned int length, - const Reader* reader); + void derive(const UTF8* name, unsigned int length, const Reader* reader); static Attribut* lookup(const std::vector * vec, const UTF8* key); - Reader* toReader(ArrayUInt8* array, Attribut* attr); + Reader* toReader(Jnjvm *vm, ArrayUInt8* array, Attribut* attr); static const UTF8* codeAttribut; static const UTF8* exceptionsAttribut; @@ -190,13 +189,13 @@ VirtualTable* virtualVT; uint64 staticSize; VirtualTable* staticVT; - JavaObject* doNew(); - JavaObject* doNewUnknown(); + JavaObject* doNew(Jnjvm* vm); + JavaObject* doNewUnknown(Jnjvm* vm); JavaObject* initialiseObject(JavaObject* obj); virtual void print(mvm::PrintBuffer *buf) const; virtual void tracer(size_t sz); - JavaObject* operator()(); + JavaObject* operator()(Jnjvm* vm); #ifndef MULTIPLE_VM JavaObject* staticInstance() { Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp Thu Apr 10 06:35:38 2008 @@ -204,7 +204,7 @@ void JavaCtpInfo::read(Jnjvm *vm, Class* cl, Reader* reader) { uint32 nbCtp = reader->readU2(); - JavaCtpInfo* res = gc_new(JavaCtpInfo)(); + JavaCtpInfo* res = vm_new(vm, JavaCtpInfo)(); res->ctpRes = (void**)malloc(sizeof(void*)*nbCtp); res->ctpDef = (sint32*)malloc(sizeof(sint32)*nbCtp); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp Thu Apr 10 06:35:38 2008 @@ -57,8 +57,6 @@ INIT(JavaMethod); INIT(JavaField); INIT(JavaCtpInfo); - INIT(Exception); - INIT(JavaJIT); INIT(JavaCond); INIT(LockObj); INIT(JavaObject); @@ -204,6 +202,7 @@ } extern "C" int boot() { + struct sigaction sa; sigaction(SIGINT, 0, &sa); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp Thu Apr 10 06:35:38 2008 @@ -98,11 +98,11 @@ sprintf(temp, "%s:%s", vm->classpath, jarFile); vm->setClasspath(temp); - ZipArchive* archive = ZipArchive::singleArchive(jarFile); + ZipArchive* archive = ZipArchive::singleArchive(vm, jarFile); if (archive) { ZipFile* file = archive->getFile(PATH_MANIFEST); if (file) { - ArrayUInt8* res = ArrayUInt8::acons(file->ucsize, JavaArray::ofByte); + ArrayUInt8* res = ArrayUInt8::acons(file->ucsize, JavaArray::ofByte, vm); int ok = archive->readFile(res, file); if (ok) { char* mainClass = findInformation(res, MAIN_CLASS, LENGTH_MAIN_CLASS); @@ -296,12 +296,10 @@ } -ThreadSystem* ThreadSystem::allocateThreadSystem() { - ThreadSystem* res = gc_new(ThreadSystem)(); - res->nonDaemonThreads = 1; - res->nonDaemonLock = mvm::Lock::allocNormal(); - res->nonDaemonVar = mvm::Cond::allocCond(); - return res; +void ThreadSystem::initialise() { + nonDaemonThreads = 1; + nonDaemonLock = mvm::Lock::allocNormal(); + nonDaemonVar = mvm::Cond::allocCond(); } JavaObject* JavaIsolate::loadAppClassLoader() { @@ -388,7 +386,7 @@ } } - ArrayObject* args = ArrayObject::acons(argc - 2, JavaArray::ofString); + ArrayObject* args = ArrayObject::acons(argc - 2, JavaArray::ofString, this); for (int i = 2; i < argc; ++i) { args->setAt(i - 2, (JavaObject*)asciizToStr(argv[i])); } @@ -409,7 +407,7 @@ extern const char* GNUClasspathLibs; JavaIsolate* JavaIsolate::allocateIsolate(Jnjvm* callingVM) { - JavaIsolate *isolate= gc_new(JavaIsolate)(); + JavaIsolate *isolate= vm_new(callingVM, JavaIsolate)(); isolate->classpath = getenv("CLASSPATH"); if (!(isolate->classpath)) { @@ -426,7 +424,7 @@ isolate->analyseClasspathEnv(isolate->bootClasspathEnv); - isolate->functions = FunctionMap::allocate(); + isolate->functions = vm_new(isolate, FunctionMap)(); isolate->module = new llvm::Module("Isolate JnJVM"); isolate->protectModule = mvm::Lock::allocNormal(); isolate->TheModuleProvider = new JnjvmModuleProvider(isolate->module, @@ -434,28 +432,32 @@ JavaJIT::initialiseJITIsolateVM(isolate); - isolate->bootstrapThread = gc_new(JavaThread)(); + isolate->bootstrapThread = vm_new(isolate, JavaThread)(); isolate->bootstrapThread->initialise(0, isolate); + mvm::Thread* th = mvm::Thread::get(); + isolate->bootstrapThread->GC = th->GC; JavaThread::threadKey->set(isolate->bootstrapThread); - isolate->threadSystem = ThreadSystem::allocateThreadSystem(); + isolate->threadSystem = vm_new(isolate, ThreadSystem)(); + isolate->threadSystem->initialise(); isolate->name = "isolate"; isolate->appClassLoader = 0; isolate->jniEnv = &JNI_JNIEnvTable; isolate->javavmEnv = &JNI_JavaVMTable; // We copy so that bootstrap utf8 such as "" are unique - isolate->hashUTF8 = bootstrapVM->hashUTF8->copy(); - isolate->hashStr = StringMap::allocate(); + isolate->hashUTF8 = vm_new(isolate, UTF8Map)(); + bootstrapVM->hashUTF8->copy(isolate->hashUTF8); + isolate->hashStr = vm_new(isolate, StringMap)(); isolate->bootstrapClasses = callingVM->bootstrapClasses; - isolate->loadedMethods = MethodMap::allocate(); - isolate->loadedFields = FieldMap::allocate(); - isolate->javaTypes = jnjvm::TypeMap::allocate(); + isolate->loadedMethods = vm_new(isolate, MethodMap)(); + isolate->loadedFields = vm_new(isolate, FieldMap)(); + isolate->javaTypes = vm_new(isolate, TypeMap)(); isolate->globalRefsLock = mvm::Lock::allocNormal(); #ifdef MULTIPLE_VM - isolate->statics = StaticInstanceMap::allocate(); - isolate->delegatees = DelegateeMap::allocate(); + isolate->statics = vm_new(isolate, StaticInstanceMap)(); + isolate->delegatees = vm_new(isolate, DelegateeMap)(); #endif return isolate; @@ -479,36 +481,39 @@ isolate->analyseClasspathEnv(isolate->bootClasspathEnv); - isolate->functions = FunctionMap::allocate(); + isolate->functions = vm_new(isolate, FunctionMap)(); isolate->protectModule = mvm::Lock::allocNormal(); isolate->module = new llvm::Module("Bootstrap JnJVM"); isolate->TheModuleProvider = new JnjvmModuleProvider(isolate->module, isolate->functions); JavaJIT::initialiseJITBootstrapVM(isolate); - isolate->bootstrapThread = gc_new(JavaThread)(); + isolate->bootstrapThread = vm_new(isolate, JavaThread)(); isolate->bootstrapThread->initialise(0, isolate); + mvm::Thread* th = mvm::Thread::get(); + isolate->bootstrapThread->GC = th->GC; JavaThread::threadKey->set(isolate->bootstrapThread); isolate->name = "bootstrapVM"; isolate->appClassLoader = 0; - isolate->hashUTF8 = UTF8Map::allocate(); - isolate->hashStr = StringMap::allocate(); - isolate->bootstrapClasses = ClassMap::allocate(); - isolate->loadedMethods = MethodMap::allocate(); - isolate->loadedFields = FieldMap::allocate(); + isolate->hashUTF8 = vm_new(isolate, UTF8Map)(); + isolate->hashStr = vm_new(isolate, StringMap)(); + isolate->bootstrapClasses = vm_new(isolate, ClassMap)(); + isolate->loadedMethods = vm_new(isolate, MethodMap)(); + isolate->loadedFields = vm_new(isolate, FieldMap)(); isolate->jniEnv = &JNI_JNIEnvTable; isolate->javavmEnv = &JNI_JavaVMTable; isolate->globalRefsLock = mvm::Lock::allocNormal(); - isolate->javaTypes = jnjvm::TypeMap::allocate(); + isolate->javaTypes = vm_new(isolate, TypeMap)(); #ifdef MULTIPLE_VM - isolate->statics = StaticInstanceMap::allocate(); - isolate->delegatees = DelegateeMap::allocate(); + isolate->statics = vm_new(isolate, StaticInstanceMap)(); + isolate->delegatees = vm_new(isolate, DelegateeMap)(); #endif #if defined(SERVICE_VM) || !defined(MULTIPLE_VM) - isolate->threadSystem = ThreadSystem::allocateThreadSystem(); + isolate->threadSystem = vm_new(this, ThreadSystem)(); + isolate->threadSystem->initialise(); #endif return isolate; Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.h?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.h Thu Apr 10 06:35:38 2008 @@ -33,7 +33,7 @@ virtual void print(mvm::PrintBuffer* buf) const; virtual void tracer(size_t sz); - static ThreadSystem* allocateThreadSystem(); + void initialise(); }; class JavaIsolate : public Jnjvm { Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Thu Apr 10 06:35:38 2008 @@ -46,14 +46,6 @@ using namespace jnjvm; using namespace llvm; -void Exception::print(mvm::PrintBuffer* buf) const { - buf->write("Exception<>"); -} - -void JavaJIT::print(mvm::PrintBuffer* buf) const { - buf->write("JavaJIT<>"); -} - BasicBlock* JavaJIT::createBasicBlock(const char* name) { return llvm::BasicBlock::Create(name, llvmFunction); } @@ -258,7 +250,8 @@ compilingMethod->printString()); } - Reader* reader = codeAtt->toReader(compilingClass->bytes, codeAtt); + Reader* reader = codeAtt->toReader(compilingClass->isolate, + compilingClass->bytes, codeAtt); maxStack = reader->readU2(); maxLocals = reader->readU2(); codeLen = reader->readU4(); @@ -290,7 +283,7 @@ uint32 index = 0; uint32 count = 0; -#ifdef SERVICE_VM +#ifdef MULTIPLE_VM uint32 max = args.size() - 1; #else uint32 max = args.size(); @@ -317,6 +310,20 @@ new StoreInst(*i, objectLocals[index], false, currentBlock); } } + +#if defined(MULTIPLE_VM) +#if !defined(SERVICE_VM) + isolateLocal = args[args.size() - 1]; +#else + if (compilingClass->isolate == Jnjvm::bootstrapVM) { + isolateLocal = args[args.size() - 1]; + } else { + ServiceDomain* vm = + (ServiceDomain*)(*Classpath::vmdataClassLoader)(compilingClass->classLoader).PointerVal; + isolateLocal = new LoadInst(vm->llvmDelegatee(), "", currentBlock); + } +#endif +#endif exploreOpcodes(&compilingClass->bytes->elements[start], codeLen); @@ -351,7 +358,8 @@ compilingMethod->printString()); } - Reader* reader = codeAtt->toReader(compilingClass->bytes, codeAtt); + Reader* reader = codeAtt->toReader(compilingClass->isolate, + compilingClass->bytes, codeAtt); maxStack = reader->readU2(); maxLocals = reader->readU2(); codeLen = reader->readU4(); @@ -403,13 +411,13 @@ uint32 index = 0; uint32 count = 0; -#ifdef SERVICE_VM +#ifdef MULTIPLE_VM uint32 max = func->arg_size() - 1; #else uint32 max = func->arg_size(); #endif - for (Function::arg_iterator i = func->arg_begin(); - count < max; ++i, ++index, ++count) { + Function::arg_iterator i = func->arg_begin(); + for (;count < max; ++i, ++index, ++count) { const Type* cur = i->getType(); @@ -430,7 +438,20 @@ new StoreInst(i, objectLocals[index], false, currentBlock); } } - + +#if defined(MULTIPLE_VM) +#if !defined(SERVICE_VM) + isolateLocal = i; +#else + if (compilingClass->isolate == Jnjvm::bootstrapVM) { + isolateLocal = i; + } else { + ServiceDomain* vm = + (ServiceDomain*)(*Classpath::vmdataClassLoader)(compilingClass->classLoader).PointerVal; + isolateLocal = new LoadInst(vm->llvmDelegatee(), "", currentBlock); + } +#endif +#endif exploreOpcodes(&compilingClass->bytes->elements[start], codeLen); @@ -517,6 +538,7 @@ unsigned JavaJIT::readExceptionTable(Reader* reader) { uint16 nbe = reader->readU2(); + std::vector exceptions; unsigned sync = isSynchro(compilingMethod->access) ? 1 : 0; nbe += sync; JavaCtpInfo* ctpInfo = compilingClass->ctpInfo; @@ -571,7 +593,7 @@ } for (uint16 i = 0; i < nbe - sync; ++i) { - Exception* ex = gc_new(Exception)(); + Exception* ex = new Exception(); ex->startpc = reader->readU2(); ex->endpc = reader->readU2(); ex->handlerpc = reader->readU2(); @@ -696,6 +718,11 @@ } } + + for (std::vector::iterator i = exceptions.begin(), + e = exceptions.end(); i!= e; ++i) { + delete *i; + } return nbe; @@ -967,13 +994,13 @@ void JavaJIT::makeArgs(FunctionType::param_iterator it, uint32 index, std::vector& Args, uint32 nb) { -#ifdef SERVICE_VM +#ifdef MULTIPLE_VM nb++; #endif Args.reserve(nb + 2); Value* args[nb]; -#ifdef SERVICE_VM - args[nb - 1] = mvm::jit::constantPtrNull; +#ifdef MULTIPLE_VM + args[nb - 1] = isolateLocal; sint32 start = nb - 2; it--; #else @@ -1121,14 +1148,14 @@ Instruction* JavaJIT::invokeInline(JavaMethod* meth, std::vector& args) { - JavaJIT* jit = gc_new(JavaJIT)(); - jit->compilingClass = meth->classDef; - jit->compilingMethod = meth; - jit->unifiedUnreachable = unifiedUnreachable; - jit->inlineMethods = inlineMethods; - jit->inlineMethods[meth] = true; - Instruction* ret = jit->inlineCompile(llvmFunction, currentBlock, - currentExceptionBlock, args); + JavaJIT jit; + jit.compilingClass = meth->classDef; + jit.compilingMethod = meth; + jit.unifiedUnreachable = unifiedUnreachable; + jit.inlineMethods = inlineMethods; + jit.inlineMethods[meth] = true; + Instruction* ret = jit.inlineCompile(llvmFunction, currentBlock, + currentExceptionBlock, args); inlineMethods[meth] = false; return ret; } @@ -1262,11 +1289,19 @@ Value* val = 0; if (!cl || !cl->isReady()) { Value* node = getInitializedClass(index); +#ifndef MULTIPLE_VM val = invoke(doNewUnknownLLVM, node, "", currentBlock); +#else + val = invoke(doNewUnknownLLVM, node, isolateLocal, "", currentBlock); +#endif } else { Value* load = new LoadInst(cl->llvmVar(compilingClass->isolate->module), "", currentBlock); +#ifdef MULTIPLE_VM + val = invoke(doNewLLVM, load, isolateLocal, "", currentBlock); +#else val = invoke(doNewLLVM, load, "", currentBlock); +#endif // give the real type info, escape analysis uses it new BitCastInst(val, cl->virtualType, "", currentBlock); } Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Thu Apr 10 06:35:38 2008 @@ -43,9 +43,8 @@ class Signdef; class UTF8; -class Exception : public mvm::Object { +class Exception { public: - static VirtualTable* VT; uint32 startpc; uint32 endpc; uint32 handlerpc; @@ -56,29 +55,17 @@ llvm::BasicBlock* handler; llvm::PHINode* exceptionPHI; llvm::PHINode* handlerPHI; - - virtual void print(mvm::PrintBuffer* buf) const; - virtual void tracer(size_t sz); }; -class Opinfo : public mvm::Object { +class Opinfo { public: - static VirtualTable* VT; llvm::BasicBlock* newBlock; bool reqSuppl; - llvm::BasicBlock* exceptionBlock; - - virtual void print(mvm::PrintBuffer* buf) const { - buf->write("Opinfo"); - } - virtual void tracer(size_t sz); + llvm::BasicBlock* exceptionBlock; }; -class JavaJIT : public mvm::Object { +class JavaJIT { public: - static VirtualTable* VT; - virtual void print(mvm::PrintBuffer* buf) const; - virtual void tracer(size_t sz); static void invokeOnceVoid(Jnjvm* vm, JavaObject* loader, const char* className, @@ -139,7 +126,6 @@ // exception local llvm::Value* supplLocal; unsigned readExceptionTable(Reader* reader); - std::vector exceptions; llvm::BasicBlock* endExceptionBlock; llvm::BasicBlock* currentExceptionBlock; llvm::BasicBlock* unifiedUnreachable; @@ -224,6 +210,11 @@ uint16 maxLocals; uint32 codeLen; +#ifdef MULTIPLE_VM + llvm::Value* isolateLocal; +#endif + + static const char* OpcodeNames[256]; static VirtualTable* makeVT(Class* cl, bool stat); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp Thu Apr 10 06:35:38 2008 @@ -169,11 +169,14 @@ { std::vector args; args.push_back(mvm::jit::ptrType); +#ifdef MULTIPLE_VM + args.push_back(mvm::jit::ptrType); +#endif const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, false); doNewLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5jnjvm5Class5doNewEv", + "_ZN5jnjvm5Class5doNewEPNS_5JnjvmE", module); } @@ -181,11 +184,76 @@ { std::vector args; args.push_back(mvm::jit::ptrType); +#ifdef MULTIPLE_VM + args.push_back(mvm::jit::ptrType); +#endif const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, false); doNewUnknownLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5jnjvm5Class12doNewUnknownEv", + "_ZN5jnjvm5Class12doNewUnknownEPNS_5JnjvmE", + module); + } + + // Create multiCallNewLLVM + { + std::vector args; + args.push_back(mvm::jit::ptrType); + args.push_back(Type::Int32Ty); +#ifdef MULTIPLE_VM + args.push_back(mvm::jit::ptrType); +#endif + const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, + true); + + multiCallNewLLVM = Function::Create(type, GlobalValue::ExternalLinkage, + "_ZN5jnjvm9JavaArray12multiCallNewEPNS_10ClassArrayEjz", + module); + } + + + + // Create *AconsLLVM + { + std::vector args; + args.push_back(Type::Int32Ty); + args.push_back(mvm::jit::ptrType); +#ifdef MULTIPLE_VM + args.push_back(mvm::jit::ptrType); +#endif + const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, + false); + + FloatAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, + "_ZN5jnjvm10ArrayFloat5aconsEiPNS_10ClassArrayEPNS_5JnjvmE", + module); + + Int8AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, + "_ZN5jnjvm10ArraySInt85aconsEiPNS_10ClassArrayEPNS_5JnjvmE", + module); + + DoubleAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, + "_ZN5jnjvm11ArrayDouble5aconsEiPNS_10ClassArrayEPNS_5JnjvmE", + module); + + Int16AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, + "_ZN5jnjvm11ArraySInt165aconsEiPNS_10ClassArrayEPNS_5JnjvmE", + module); + + Int32AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, + "_ZN5jnjvm11ArraySInt325aconsEiPNS_10ClassArrayEPNS_5JnjvmE", + module); + + UTF8AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, + "_ZN5jnjvm4UTF85aconsEiPNS_10ClassArrayEPNS_5JnjvmE", + module); + + LongAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, + " _ZN5jnjvm9ArrayLong5aconsEiPNS_10ClassArrayEPNS_5JnjvmE", + module); + + ObjectAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, + "_ZN5jnjvm11ArrayObject5aconsEiPNS_10ClassArrayEPNS_5JnjvmE", module); } @@ -450,61 +518,6 @@ module); } - // Create multiCallNewLLVM - { - std::vector args; - args.push_back(mvm::jit::ptrType); - args.push_back(Type::Int32Ty); - const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, - true); - - multiCallNewLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5jnjvm9JavaArray12multiCallNewEPNS_10ClassArrayEjz", - module); - } - - - - // Create *AconsLLVM - { - std::vector args; - args.push_back(Type::Int32Ty); - args.push_back(mvm::jit::ptrType); - const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, - false); - - FloatAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5jnjvm10ArrayFloat5aconsEiPNS_10ClassArrayE", - module); - - Int8AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5jnjvm10ArraySInt85aconsEiPNS_10ClassArrayE", - module); - - DoubleAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5jnjvm11ArrayDouble5aconsEiPNS_10ClassArrayE", - module); - - Int16AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5jnjvm11ArraySInt165aconsEiPNS_10ClassArrayE", - module); - - Int32AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5jnjvm11ArraySInt325aconsEiPNS_10ClassArrayE", - module); - - UTF8AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5jnjvm4UTF85aconsEiPNS_10ClassArrayE", - module); - - LongAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5jnjvm9ArrayLong5aconsEiPNS_10ClassArrayE", - module); - - ObjectAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5jnjvm11ArrayObject5aconsEiPNS_10ClassArrayE", - module); - } { std::vector args; Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Thu Apr 10 06:35:38 2008 @@ -125,6 +125,7 @@ } void JavaJIT::compileOpcodes(uint8* bytecodes, uint32 codeLength) { + wide = false; uint32 jsrIndex = 0; for(uint32 i = 0; i < codeLength; ++i) { @@ -1771,8 +1772,15 @@ llvm::Value* valCl = new LoadInst(cl->llvmVar(vm->module), "", currentBlock); llvm::Value* arg1 = popAsInt(); - +#ifdef MULTIPLE_VM + std::vector args; + args.push_back(arg1); + args.push_back(valCl); + args.push_back(isolateLocal); + push(invoke(ctr, args, "", currentBlock), AssessorDesc::dRef); +#else push(invoke(ctr, arg1, valCl, "", currentBlock), AssessorDesc::dRef); +#endif break; } @@ -1792,8 +1800,15 @@ llvm::Value* valCl = new LoadInst(dcl->llvmVar(vm->module), "", currentBlock); llvm::Value* arg1 = popAsInt(); - +#ifdef MULTIPLE_VM + std::vector args; + args.push_back(arg1); + args.push_back(valCl); + args.push_back(isolateLocal); + push(invoke(ObjectAconsLLVM, args, "", currentBlock), AssessorDesc::dRef); +#else push(invoke(ObjectAconsLLVM, arg1, valCl, "", currentBlock), AssessorDesc::dRef); +#endif break; } @@ -1922,6 +1937,9 @@ for (sint32 v = 0; v < dim + 2; ++v) { Args.push_back(args[v]); } +#ifdef MULTIPLE_VM + Args.push_back(isolateLocal); +#endif push(invoke(multiCallNewLLVM, Args, "", currentBlock), AssessorDesc::dRef); break; } @@ -1966,6 +1984,7 @@ } void JavaJIT::exploreOpcodes(uint8* bytecodes, uint32 codeLength) { + wide = false; for(uint32 i = 0; i < codeLength; ++i) { PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "\t[at %5d] %-5d ", i, Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp Thu Apr 10 06:35:38 2008 @@ -277,10 +277,10 @@ ((float*)((uint64)obj + field->ptrOffset))[0] = val; } -JavaObject* Class::operator()() { +JavaObject* Class::operator()(Jnjvm* vm) { if (!isReady()) isolate->loadName(name, classLoader, true, true, true); - return doNew(); + return doNew(vm); } void JavaField::operator()(JavaObject* obj, float val) { @@ -750,7 +750,7 @@ } } -#ifdef SERVICE_VM +#ifdef MULTIPLE_VM Args.push_back(mvm::jit::constantPtrNull); #endif @@ -792,7 +792,7 @@ Args.push_back(new VAArgInst(ap, (*i)->funcs->llvmType, "", currentBlock)); } -#ifdef SERVICE_VM +#ifdef MULTIPLE_VM Args.push_back(mvm::jit::constantPtrNull); #endif Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp Thu Apr 10 06:35:38 2008 @@ -21,7 +21,8 @@ mvm::Lock* JavaObject::globalLock = 0; JavaCond* JavaCond::allocate() { - return gc_new(JavaCond)(); + // JavaCond::allocate must on behalf of the executing thread + return vm_new(JavaThread::get()->isolate, JavaCond)(); } void JavaCond::notify() { @@ -75,7 +76,7 @@ } LockObj* LockObj::allocate() { - LockObj* res = gc_new(LockObj)(); + LockObj* res = vm_new(JavaThread::get()->isolate, LockObj)(); res->lock = mvm::Lock::allocRecursive(); res->varcond = JavaCond::allocate(); return res; @@ -99,12 +100,6 @@ buf->write(">"); } -JavaObject* JavaObject::allocate(CommonClass* cl) { - JavaObject* res = gc_new(JavaObject)(); - res->classOf = cl; - return res; -} - static LockObj* myLock(JavaObject* obj) { verifyNull(obj); if (obj->lockObj == 0) { Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h Thu Apr 10 06:35:38 2008 @@ -72,7 +72,6 @@ virtual void print(mvm::PrintBuffer* buf) const; virtual void tracer(size_t sz); - static JavaObject* allocate(CommonClass* cl); void aquire(); void unlock(); void waitIntern(struct timeval *info, bool timed); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Thu Apr 10 06:35:38 2008 @@ -98,7 +98,8 @@ if (!rcache) { JavaMethod* dmeth = ocl->lookupMethod(utf8, sign->keyName, false, true); if (cache->methPtr) { - rcache = CacheNode::allocate(); + rcache = vm_new(ctpInfo->classDef->isolate, CacheNode)(); + rcache->initialise(); rcache->enveloppe = enveloppe; } else { rcache = cache; Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaString.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaString.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaString.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaString.cpp Thu Apr 10 06:35:38 2008 @@ -17,7 +17,7 @@ JavaString* JavaString::stringDup(const UTF8*& utf8, Jnjvm* vm) { - JavaString* res = (JavaString*)(*Classpath::newString)(); + JavaString* res = (JavaString*)(*Classpath::newString)(vm); // no need to call the function // Classpath::initString->run(res, utf8, 0, utf8->size, true); res->value = utf8; Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp Thu Apr 10 06:35:38 2008 @@ -60,7 +60,7 @@ const char* name, Jnjvm* vm, const llvm::Type* t, const char* assocName, arrayCtor_t ctor) { - AssessorDesc* res = gc_new(AssessorDesc)(); + AssessorDesc* res = vm_new(vm, AssessorDesc)(); res->doTrace = dt; res->byteId = bid; res->nbb = nb; @@ -474,7 +474,7 @@ llvmArgs.push_back(args->at(i)->funcs->llvmType); } -#ifdef SERVICE_VM +#ifdef MULTIPLE_VM llvmArgs.push_back(mvm::jit::ptrType); // domain #endif @@ -497,7 +497,7 @@ llvmArgs.push_back(args->at(i)->funcs->llvmType); } -#ifdef SERVICE_VM +#ifdef MULTIPLE_VM llvmArgs.push_back(mvm::jit::ptrType); // domain #endif @@ -521,7 +521,7 @@ llvmArgs.push_back(args->at(i)->funcs->llvmType); } -#ifdef SERVICE_VM +#ifdef MULTIPLE_VM llvmArgs.push_back(mvm::jit::ptrType); // domain #endif @@ -574,7 +574,7 @@ typeError(name, 0); } - Signdef* res = gc_new(Signdef)(); + Signdef* res = vm_new(vm, Signdef)(); res->args = buf; res->ret = vm->constructType(name->extract(vm, pos, pred)); res->isolate = vm; @@ -618,7 +618,7 @@ if (funcs == AssessorDesc::dParg) { return Signdef::signDup(name, vm); } else { - Typedef* res = gc_new(Typedef)(); + Typedef* res = vm_new(vm, Typedef)(); res->isolate = vm; res->keyName = name; res->funcs = funcs; Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp Thu Apr 10 06:35:38 2008 @@ -130,7 +130,7 @@ } void ClasspathThread::createInitialThread(Jnjvm* vm, JavaObject* th) { - JavaObject* vmth = (*newVMThread)(); + JavaObject* vmth = (*newVMThread)(vm); (*th)(name, (JavaObject*)vm->asciizToStr("main")); (*th)(priority, (uint32)1); (*th)(daemon, (uint32)0); @@ -143,7 +143,7 @@ } void ClasspathThread::mapInitialThread(Jnjvm* vm) { - JavaObject* th = (*newThread)(); + JavaObject* th = (*newThread)(vm); createInitialThread(vm, th); JavaThread* myth = JavaThread::get(); myth->javaThread = th; @@ -221,7 +221,7 @@ // Create getCallingClassLoader { std::vector args; -#ifdef SERVICE_VM +#ifdef MULTIPLE_VM args.push_back(mvm::jit::ptrType); #endif const llvm::FunctionType* type = @@ -238,7 +238,7 @@ { std::vector args; args.push_back(JavaObject::llvmType); -#ifdef SERVICE_VM +#ifdef MULTIPLE_VM args.push_back(mvm::jit::ptrType); #endif const llvm::FunctionType* type = @@ -255,7 +255,7 @@ { std::vector args; args.push_back(JavaObject::llvmType); -#ifdef SERVICE_VM +#ifdef MULTIPLE_VM args.push_back(mvm::jit::ptrType); #endif const llvm::FunctionType* type = @@ -281,7 +281,7 @@ JavaMethod* getCallingClass = UPCALL_METHOD(vm, "gnu/classpath/VMStackWalker", "getCallingClass", "()Ljava/lang/Object;", ACC_STATIC); { std::vector args; -#ifdef SERVICE_VM +#ifdef MULTIPLE_VM args.push_back(mvm::jit::ptrType); #endif const llvm::FunctionType* type = @@ -296,7 +296,7 @@ JavaMethod* getCallingClassLoader = UPCALL_METHOD(vm, "gnu/classpath/VMStackWalker", "getCallingClassLoader", "()Ljava/lang/Object;", ACC_STATIC); { std::vector args; -#ifdef SERVICE_VM +#ifdef MULTIPLE_VM args.push_back(mvm::jit::ptrType); #endif const llvm::FunctionType* type = Modified: vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp Thu Apr 10 06:35:38 2008 @@ -142,7 +142,7 @@ Jnjvm* vm = th->isolate; CommonClass* cl = NativeUtil::resolvedImplClass(clazz, true); if (cl->isArray) assert(0 && "implement me"); - JavaObject* res = ((Class*)cl)->doNew(); + JavaObject* res = ((Class*)cl)->doNew(vm); JavaMethod* init = cl->lookupMethod(Jnjvm::initName, vm->asciizConstructUTF8("(Ljava/lang/String;)V"), 0, 1); @@ -216,7 +216,7 @@ CommonClass* cl = NativeUtil::resolvedImplClass(clazz, true); if (cl->isArray) JavaThread::get()->isolate->unknownError("implement me"); - return (jobject)((Class*)cl)->doNew(); + return (jobject)((Class*)cl)->doNew(JavaThread::get()->isolate); END_EXCEPTION return 0; @@ -230,7 +230,7 @@ va_start(ap, methodID); JavaMethod* meth = (JavaMethod*)methodID; Class* cl = (Class*)NativeUtil::resolvedImplClass(clazz, true); - JavaObject* res = cl->doNew(); + JavaObject* res = cl->doNew(JavaThread::get()->isolate); meth->invokeIntSpecialAP(res, ap); va_end(ap); return (jobject)res; @@ -1630,7 +1630,7 @@ const UTF8* name = base->name; const UTF8* arrayName = AssessorDesc::constructArrayName(vm, 0, 1, name); ClassArray* array = vm->constructArray(arrayName, loader); - ArrayObject* res = ArrayObject::acons(length, array); + ArrayObject* res = ArrayObject::acons(length, array, vm); if (initialElement) { memset(res->elements, (int)initialElement, length * sizeof(JavaObject*)); @@ -1663,7 +1663,7 @@ BEGIN_EXCEPTION ArrayUInt8* res = 0; - res = ArrayUInt8::acons(len, JavaArray::ofBool); + res = ArrayUInt8::acons(len, JavaArray::ofBool, NativeUtil::myVM(env)); return (jbooleanArray)res; END_EXCEPTION @@ -1676,7 +1676,7 @@ BEGIN_EXCEPTION ArraySInt8* res = 0; - res = ArraySInt8::acons(len, JavaArray::ofByte); + res = ArraySInt8::acons(len, JavaArray::ofByte, NativeUtil::myVM(env)); return (jbyteArray) res; END_EXCEPTION @@ -1689,7 +1689,7 @@ BEGIN_EXCEPTION ArrayUInt16* res = 0; - res = ArrayUInt16::acons(len, JavaArray::ofChar); + res = ArrayUInt16::acons(len, JavaArray::ofChar, NativeUtil::myVM(env)); return (jcharArray) res; END_EXCEPTION @@ -1702,7 +1702,7 @@ BEGIN_EXCEPTION ArraySInt16* res = 0; - res = ArraySInt16::acons(len, JavaArray::ofShort); + res = ArraySInt16::acons(len, JavaArray::ofShort, NativeUtil::myVM(env)); return (jshortArray) res; END_EXCEPTION @@ -1715,7 +1715,7 @@ BEGIN_EXCEPTION ArraySInt32* res = 0; - res = ArraySInt32::acons(len, JavaArray::ofInt); + res = ArraySInt32::acons(len, JavaArray::ofInt, NativeUtil::myVM(env)); return (jintArray) res; END_EXCEPTION @@ -1728,7 +1728,7 @@ BEGIN_EXCEPTION ArrayLong* res = 0; - res = ArrayLong::acons(len, JavaArray::ofLong); + res = ArrayLong::acons(len, JavaArray::ofLong, NativeUtil::myVM(env)); return (jlongArray) res; END_EXCEPTION @@ -1741,7 +1741,7 @@ BEGIN_EXCEPTION ArrayFloat* res = 0; - res = ArrayFloat::acons(len, JavaArray::ofFloat); + res = ArrayFloat::acons(len, JavaArray::ofFloat, NativeUtil::myVM(env)); return (jfloatArray) res; END_EXCEPTION @@ -1754,7 +1754,7 @@ BEGIN_EXCEPTION ArrayDouble* res = 0; - res = ArrayDouble::acons(len, JavaArray::ofDouble); + res = ArrayDouble::acons(len, JavaArray::ofDouble, NativeUtil::myVM(env)); return (jdoubleArray) res; END_EXCEPTION Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Thu Apr 10 06:35:38 2008 @@ -198,7 +198,8 @@ for (int i = 0; i < nba; i++) { const UTF8* attName = ctpInfo->UTF8At(reader->readU2()); unsigned int attLen = reader->readU4(); - Attribut* att = Attribut::derive(attName, attLen, reader); + Attribut* att = vm_new(this, Attribut); + att->derive(attName, attLen, reader); attr.push_back(att); reader->seek(attLen, Reader::SeekCur); } @@ -245,7 +246,7 @@ PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "%s::%s\n", printString(), cl->printString()); - Reader* reader = Reader::allocateReader(cl->bytes); + Reader* reader = vm_new(this, Reader)(cl->bytes); uint32 magic = reader->readU4(); if (magic != Jnjvm::Magic) { Jnjvm::error(ClassFormatError, "bad magic number %p", magic); @@ -284,10 +285,10 @@ if (str[strLen - 1] == dirSeparator[0]) { sprintf(buf, "%s%s.class", str, asciiz); - res = Reader::openFile(buf); + res = Reader::openFile(this, buf); } else { sprintf(buf, "%s.class", asciiz); - res = Reader::openZip(str, buf); + res = Reader::openZip(this, str, buf); } idx++; } @@ -444,7 +445,7 @@ Class* cl = (Class*) this->loadName(this->asciizConstructUTF8(className), CommonClass::jnjvmClassLoader, true, true, true); - JavaObject* obj = (*cl)(); + JavaObject* obj = (*cl)(this); JavaJIT::invokeOnceVoid(this, CommonClass::jnjvmClassLoader, className, "", "(Ljava/lang/Throwable;)V", ACC_VIRTUAL, obj, excp); JavaThread::throwException(obj); @@ -460,7 +461,7 @@ vsnprintf(tmp, 4096, fmt, ap); va_end(ap); - JavaObject* obj = (*cl)(); + JavaObject* obj = (*cl)(this); JavaJIT::invokeOnceVoid(this, CommonClass::jnjvmClassLoader, className, "", "(Ljava/lang/String;)V", ACC_VIRTUAL, obj, this->asciizToStr(tmp)); @@ -475,7 +476,7 @@ true, true, true); vsnprintf(tmp, 4096, fmt, ap); va_end(ap); - JavaObject* obj = (*cl)(); + JavaObject* obj = (*cl)(this); JavaJIT::invokeOnceVoid(this, CommonClass::jnjvmClassLoader, className, "", "(Ljava/lang/String;)V", ACC_VIRTUAL, obj, this->asciizToStr(tmp)); @@ -632,7 +633,7 @@ ClassMap* map = (ClassMap*)(*Classpath::vmdataClassLoader)(loader).PointerVal; if (!map) { - map = ClassMap::allocate(); + map = vm_new(this, ClassMap)(); (*Classpath::vmdataClassLoader)(loader, (JavaObject*)map); } #else @@ -652,7 +653,7 @@ } static CommonClass* arrayDup(const UTF8*& name, Jnjvm *vm) { - ClassArray* cl = gc_new(ClassArray)(); + ClassArray* cl = vm_new(vm, ClassArray)(); cl->initialise(vm, true); cl->name = name; cl->classLoader = 0; @@ -681,7 +682,7 @@ ClassMap* map = (ClassMap*)(*Classpath::vmdataClassLoader)(loader).PointerVal; if (!map) { - map = ClassMap::allocate(); + map = vm_new(this, ClassMap)(); (*Classpath::vmdataClassLoader)(loader, (JavaObject*)map); } ClassArray* res = (ClassArray*)map->lookupOrCreate(name, this, arrayDup); @@ -705,7 +706,7 @@ static CommonClass* classDup(const UTF8*& name, Jnjvm *vm) { - Class* cl = gc_new(Class)(); + Class* cl = vm_new(vm, Class)(); cl->initialise(vm, false); cl->name = name; cl->classLoader = 0; @@ -723,7 +724,7 @@ ClassMap* map = (ClassMap*)(*Classpath::vmdataClassLoader)(loader).PointerVal; if (!map) { - map = ClassMap::allocate(); + map = vm_new(this, ClassMap)(); (*Classpath::vmdataClassLoader)(loader, (JavaObject*)map); } Class* res = (Class*)map->lookupOrCreate(name, this, classDup); @@ -746,7 +747,7 @@ } static JavaField* fieldDup(FieldCmp & cmp, Jnjvm *vm) { - JavaField* field = gc_new(JavaField)(); + JavaField* field = vm_new(vm, JavaField)(); field->name = cmp.name; field->type = cmp.type; field->classDef = (Class*)cmp.classDef; @@ -772,7 +773,7 @@ } static JavaMethod* methodDup(FieldCmp & cmp, Jnjvm *vm) { - JavaMethod* method = gc_new(JavaMethod)(); + JavaMethod* method = vm_new(vm, JavaMethod)(); method->name = cmp.name; method->type = cmp.type; method->classDef = (Class*)cmp.classDef; @@ -791,11 +792,11 @@ } const UTF8* Jnjvm::asciizConstructUTF8(const char* asciiz) { - return hashUTF8->lookupOrCreateAsciiz(asciiz); + return hashUTF8->lookupOrCreateAsciiz(this, asciiz); } const UTF8* Jnjvm::readerConstructUTF8(const uint16* buf, uint32 size) { - return hashUTF8->lookupOrCreateReader(buf, size); + return hashUTF8->lookupOrCreateReader(this, buf, size); } Typedef* Jnjvm::constructType(const UTF8* name) { @@ -835,12 +836,12 @@ #ifndef MULTIPLE_VM JavaObject* Jnjvm::getClassDelegatee(CommonClass* cl) { if (!(cl->delegatee)) { - JavaObject* delegatee = (*Classpath::newClass)(); + JavaObject* delegatee = (*Classpath::newClass)(this); cl->delegatee = delegatee; Classpath::initClass->invokeIntSpecial(delegatee, cl); } else if (cl->delegatee->classOf != Classpath::newClass) { JavaObject* pd = cl->delegatee; - JavaObject* delegatee = (*Classpath::newClass)(); + JavaObject* delegatee = (*Classpath::newClass)(this); cl->delegatee = delegatee;; Classpath::initClassWithProtectionDomain->invokeIntSpecial(delegatee, cl, pd); @@ -851,12 +852,12 @@ JavaObject* Jnjvm::getClassDelegatee(CommonClass* cl) { JavaObject* val = delegatees->lookup(cl); if (!val) { - val = (*Classpath::newClass)(); + val = (*Classpath::newClass)(this); delegatees->hash(cl, val); Classpath::initClass->invokeIntSpecial(val, cl); } else if (val->classOf != Classpath::newClass) { JavaObject* pd = val; - val = (*Classpath::newClass)(); + val = (*Classpath::newClass)(this); delegatees->hash(cl, val); Classpath::initClassWithProtectionDomain->invokeIntSpecial(val, cl, pd); } Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h Thu Apr 10 06:35:38 2008 @@ -22,6 +22,8 @@ #include "types.h" +#define vm_new(vm, cl) gc_new(cl) + namespace jnjvm { class ArrayUInt8; @@ -251,6 +253,16 @@ llvm::Module* module; JnjvmModuleProvider* TheModuleProvider; FunctionMap* functions; + +#ifndef MULTIPLE_VM + void* allocateObject(unsigned int sz, VirtualTable* VT) { + return gc::operator new(sz, VT); + } +#else + void* allocateObject(unsigned int sz, VirtualTable* VT) { + return gc::operator new(sz, VT); + } +#endif }; } // end namespace jnjvm Modified: vmkit/trunk/lib/JnJVM/VMCore/LockedMap.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/LockedMap.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/LockedMap.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/LockedMap.cpp Thu Apr 10 06:35:38 2008 @@ -74,7 +74,7 @@ } -const UTF8* UTF8Map::lookupOrCreateAsciiz(const char* asciiz) { +const UTF8* UTF8Map::lookupOrCreateAsciiz(Jnjvm* vm, const char* asciiz) { sint32 size = strlen(asciiz); uint32 key = asciizHasher(asciiz, size); const UTF8* res = 0; @@ -90,7 +90,7 @@ } if (res == 0) { - UTF8* tmp = UTF8::acons(size, JavaArray::ofChar); + UTF8* tmp = UTF8::acons(size, JavaArray::ofChar, vm); for (sint32 i = 0; i < size; i++) { tmp->setAt(i, asciiz[i]); } @@ -102,7 +102,8 @@ return res; } -const UTF8* UTF8Map::lookupOrCreateReader(const uint16* buf, uint32 len) { +const UTF8* UTF8Map::lookupOrCreateReader(Jnjvm* vm, const uint16* buf, + uint32 len) { sint32 size = (sint32)len; uint32 key = readerHasher(buf, size); const UTF8* res = 0; @@ -118,7 +119,7 @@ } if (res == 0) { - UTF8* tmp = UTF8::acons(size, JavaArray::ofChar); + UTF8* tmp = UTF8::acons(size, JavaArray::ofChar, vm); memcpy(tmp->elements, buf, len * sizeof(uint16)); res = (const UTF8*)tmp; map.insert(std::make_pair(key, res)); Modified: vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h Thu Apr 10 06:35:38 2008 @@ -101,8 +101,8 @@ mvm::Lock* lock; std::multimap map; static VirtualTable* VT; - const UTF8* lookupOrCreateAsciiz(const char* asciiz); - const UTF8* lookupOrCreateReader(const uint16* buf, uint32 size); + const UTF8* lookupOrCreateAsciiz(Jnjvm* vm, const char* asciiz); + const UTF8* lookupOrCreateReader(Jnjvm* vm, const uint16* buf, uint32 size); const UTF8* lookupAsciiz(const char* asciiz); const UTF8* lookupReader(const uint16* buf, uint32 size); @@ -117,18 +117,14 @@ buf->write("UTF8 Hashtable<>"); } - static UTF8Map* allocate() { - UTF8Map* map = gc_new(UTF8Map)(); - map->lock = mvm::Lock::allocNormal(); - return map; + UTF8Map() { + lock = mvm::Lock::allocNormal(); } - UTF8Map* copy() { - UTF8Map* newMap = allocate(); + void copy(UTF8Map* newMap) { for (iterator i = map.begin(), e = map.end(); i!= e; ++i) { newMap->map.insert(*i); } - return newMap; } void replace(const UTF8* oldUTF8, const UTF8* newUTF8); @@ -157,10 +153,9 @@ public LockedMap { public: static VirtualTable* VT; - static ClassMap* allocate() { - ClassMap* map = gc_new(ClassMap)(); - map->lock = mvm::Lock::allocNormal(); - return map; + + ClassMap() { + lock = mvm::Lock::allocNormal(); } virtual void tracer(size_t sz) { @@ -175,10 +170,9 @@ public LockedMap > { public: static VirtualTable* VT; - static FieldMap* allocate() { - FieldMap* map = gc_new(FieldMap)(); - map->lock = mvm::Lock::allocNormal(); - return map; + + FieldMap() { + lock = mvm::Lock::allocNormal(); } virtual void tracer(size_t sz) { @@ -193,10 +187,9 @@ public LockedMap > { public: static VirtualTable* VT; - static MethodMap* allocate() { - MethodMap* map = gc_new(MethodMap)(); - map->lock = mvm::Lock::allocNormal(); - return map; + + MethodMap() { + lock = mvm::Lock::allocNormal(); } virtual void tracer(size_t sz) { @@ -219,10 +212,9 @@ class ZipFileMap : public LockedMap { public: static VirtualTable* VT; - static ZipFileMap* allocate() { - ZipFileMap* map = gc_new(ZipFileMap)(); - map->lock = mvm::Lock::allocNormal(); - return map; + + ZipFileMap() { + lock = mvm::Lock::allocNormal(); } virtual void tracer(size_t sz) { @@ -237,10 +229,9 @@ public LockedMap { public: static VirtualTable* VT; - static StringMap* allocate() { - StringMap* map = gc_new(StringMap)(); - map->lock = mvm::Lock::allocRecursive(); - return map; + + StringMap() { + lock = mvm::Lock::allocRecursive(); } virtual void tracer(size_t sz) { @@ -255,10 +246,9 @@ public LockedMap*, std::less > { public: static VirtualTable* VT; - static FunctionMap* allocate() { - FunctionMap* map = gc_new(FunctionMap)(); - map->lock = mvm::Lock::allocNormal(); - return map; + + FunctionMap() { + lock = mvm::Lock::allocNormal(); } virtual void tracer(size_t sz) { @@ -273,10 +263,9 @@ public LockedMap > { public: static VirtualTable* VT; - static FunctionDefMap* allocate() { - FunctionDefMap* map = gc_new(FunctionDefMap)(); - map->lock = mvm::Lock::allocNormal(); - return map; + + FunctionDefMap() { + lock = mvm::Lock::allocNormal(); } virtual void tracer(size_t sz) { @@ -297,10 +286,8 @@ return 0; } - static TypeMap* allocate() { - TypeMap* map = gc_new(TypeMap)(); - map->lock = mvm::Lock::allocRecursive(); - return map; + TypeMap() { + lock = mvm::Lock::allocRecursive(); } virtual void tracer(size_t sz) { @@ -317,10 +304,8 @@ public: static VirtualTable* VT; - static StaticInstanceMap* allocate() { - StaticInstanceMap* map = gc_new(StaticInstanceMap)(); - map->lock = mvm::Lock::allocNormal(); - return map; + StaticInstanceMap() { + lock = mvm::Lock::allocNormal(); } virtual void tracer(size_t sz) { @@ -343,10 +328,8 @@ public: static VirtualTable* VT; - static DelegateeMap* allocate() { - DelegateeMap* map = gc_new(DelegateeMap)(); - map->lock = mvm::Lock::allocNormal(); - return map; + DelegateeMap() { + lock = mvm::Lock::allocNormal(); } virtual void tracer(size_t sz) { Modified: vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp Thu Apr 10 06:35:38 2008 @@ -445,7 +445,8 @@ ArrayObject* NativeUtil::getParameterTypes(JavaObject* loader, JavaMethod* meth) { std::vector& args = meth->signature->args; - ArrayObject* res = ArrayObject::acons(args.size(), Classpath::classArrayClass); + ArrayObject* res = ArrayObject::acons(args.size(), Classpath::classArrayClass, + JavaThread::get()->isolate); sint32 index = 0; for (std::vector::iterator i = args.begin(), e = args.end(); @@ -461,13 +462,16 @@ Attribut* exceptionAtt = Attribut::lookup(&meth->attributs, Attribut::exceptionsAttribut); if (exceptionAtt == 0) { - return ArrayObject::acons(0, Classpath::classArrayClass); + return ArrayObject::acons(0, Classpath::classArrayClass, + JavaThread::get()->isolate); } else { Class* cl = meth->classDef; JavaCtpInfo* ctp = cl->ctpInfo; - Reader* reader = exceptionAtt->toReader(cl->bytes, exceptionAtt); + Reader* reader = exceptionAtt->toReader(JavaThread::get()->isolate, + cl->bytes, exceptionAtt); uint16 nbe = reader->readU2(); - ArrayObject* res = ArrayObject::acons(nbe, Classpath::classArrayClass); + ArrayObject* res = ArrayObject::acons(nbe, Classpath::classArrayClass, + JavaThread::get()->isolate); for (uint16 i = 0; i < nbe; ++i) { uint16 idx = reader->readU2(); Modified: vmkit/trunk/lib/JnJVM/VMCore/Reader.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Reader.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/Reader.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/Reader.cpp Thu Apr 10 06:35:38 2008 @@ -52,27 +52,27 @@ const int Reader::SeekCur = SEEK_CUR; const int Reader::SeekEnd = SEEK_END; -ArrayUInt8* Reader::openFile(char* path) { +ArrayUInt8* Reader::openFile(Jnjvm* vm, char* path) { FILE* fp = fopen(path, "r"); ArrayUInt8* res = 0; if (fp != 0) { fseek(fp, 0, SeekEnd); long nbb = ftell(fp); fseek(fp, 0, SeekSet); - res = ArrayUInt8::acons(nbb, JavaArray::ofByte); + res = ArrayUInt8::acons(nbb, JavaArray::ofByte, vm); fread(res->elements, nbb, 1, fp); fclose(fp); } return res; } -ArrayUInt8* Reader::openZip(char* zipname, char* filename) { - ZipArchive* archive = ZipArchive::hashedArchive(zipname); +ArrayUInt8* Reader::openZip(Jnjvm* vm, char* zipname, char* filename) { + ZipArchive* archive = ZipArchive::hashedArchive(vm, zipname); ArrayUInt8* ret = 0; if (archive != 0) { ZipFile* file = archive->getFile(filename); if (file != 0) { - ArrayUInt8* res = ArrayUInt8::acons(file->ucsize, JavaArray::ofByte); + ArrayUInt8* res = ArrayUInt8::acons(file->ucsize, JavaArray::ofByte, vm); if (archive->readFile(res, file) != 0) { ret = res; } @@ -119,24 +119,20 @@ return tmp | ((sint64)(readS8())); } -Reader* Reader::allocateReader(ArrayUInt8* array, uint32 start, - uint32 end) { - Reader* reader = gc_new(Reader)(); +Reader::Reader(ArrayUInt8* array, uint32 start, uint32 end) { if (!end) end = array->size; - reader->bytes = array; - reader->cursor = start; - reader->min = start; - reader->max = start + end; - return reader; - + this->bytes = array; + this->cursor = start; + this->min = start; + this->max = start + end; } unsigned int Reader::tell() { return cursor - min; } -Reader* Reader::derive(uint32 nbb) { - return allocateReader(bytes, cursor, nbb); +Reader* Reader::derive(Jnjvm* vm, uint32 nbb) { + return vm_new(vm, Reader)(bytes, cursor, nbb); } void Reader::seek(uint32 pos, int from) { Modified: vmkit/trunk/lib/JnJVM/VMCore/Reader.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Reader.h?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/Reader.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/Reader.h Thu Apr 10 06:35:38 2008 @@ -17,6 +17,7 @@ namespace jnjvm { class ArrayUInt8; +class Jnjvm; class Reader : public mvm::Object { public: @@ -33,8 +34,8 @@ static const int SeekCur; static const int SeekEnd; - static ArrayUInt8* openFile(char* path); - static ArrayUInt8* openZip(char* zipname, char* filename); + static ArrayUInt8* openFile(Jnjvm* vm, char* path); + static ArrayUInt8* openZip(Jnjvm* vm, char* zipname, char* filename); uint8 readU1(); sint8 readS1(); uint16 readU2(); @@ -43,10 +44,10 @@ sint32 readS4(); uint64 readU8(); sint64 readS8(); - static Reader* allocateReader(ArrayUInt8* array, uint32 start = 0, - uint32 end = 0); + Reader(ArrayUInt8* array, uint32 start = 0, uint32 end = 0); + Reader() {} unsigned int tell(); - Reader* derive(uint32 nbb); + Reader* derive(Jnjvm* vm, uint32 nbb); void seek(uint32 pos, int from); virtual void print(mvm::PrintBuffer* buf) const; Modified: vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp Thu Apr 10 06:35:38 2008 @@ -32,9 +32,9 @@ } ServiceDomain* ServiceDomain::allocateService(Jnjvm* callingVM) { - ServiceDomain* service = gc_new(ServiceDomain)(); + ServiceDomain* service = vm_new(callingVM, ServiceDomain)(); - service->functions = FunctionMap::allocate(); + service->functions = vm_new(service, FunctionMap)(); service->module = new llvm::Module("Service Domain"); service->protectModule = mvm::Lock::allocNormal(); service->TheModuleProvider = new JnjvmModuleProvider(service->module, @@ -46,21 +46,22 @@ service->javavmEnv = &JNI_JavaVMTable; // We copy so that bootstrap utf8 such as "" are unique - service->hashUTF8 = callingVM->hashUTF8->copy(); - service->hashStr = StringMap::allocate(); + service->hashUTF8 = vm_new(service, UTF8Map)(); + callingVM->hashUTF8->copy(service->hashUTF8); + service->hashStr = vm_new(service, StringMap)(); service->bootstrapClasses = callingVM->bootstrapClasses; - service->loadedMethods = MethodMap::allocate(); - service->loadedFields = FieldMap::allocate(); - service->javaTypes = jnjvm::TypeMap::allocate(); + service->loadedMethods = vm_new(service, MethodMap)(); + service->loadedFields = vm_new(service, FieldMap)(); + service->javaTypes = vm_new(service, TypeMap)(); service->globalRefsLock = mvm::Lock::allocNormal(); #ifdef MULTIPLE_VM - service->statics = StaticInstanceMap::allocate(); - service->delegatees = DelegateeMap::allocate(); + service->statics = vm_new(service, StaticInstanceMap)(); + service->delegatees = vm_new(service, DelegateeMap)(); #endif // A service is related to a class loader // Here are the classes it loaded - service->classes = ClassMap::allocate(); + service->classes = vm_new(service, ClassMap)(); service->started = 0; service->executionTime = 0; Modified: vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp Thu Apr 10 06:35:38 2008 @@ -14,7 +14,6 @@ #include "JavaClass.h" #include "JavaConstantPool.h" #include "JavaIsolate.h" -#include "JavaJIT.h" #include "JavaObject.h" #include "JavaString.h" #include "JavaThread.h" @@ -50,8 +49,6 @@ INIT(JavaMethod); INIT(JavaField); INIT(JavaCtpInfo); - INIT(Exception); - INIT(JavaJIT); INIT(JavaCond); INIT(LockObj); INIT(JavaObject); @@ -76,7 +73,6 @@ INIT(FunctionDefMap); INIT(JavaIsolate); INIT(JavaString); - INIT(Opinfo); INIT(CacheNode); INIT(Enveloppe); INIT(DelegateeMap); @@ -189,21 +185,6 @@ // do not trace them here } -void Exception::tracer(size_t sz) { - catchClass->markAndTrace(); -} - -void Opinfo::tracer(size_t sz) { -} - -void JavaJIT::tracer(size_t sz) { - compilingClass->markAndTrace(); - compilingMethod->markAndTrace(); - TRACE_VECTOR(Exception*, exceptions); - - // Do not trace opinfos: they are allocated in stack -} - void JavaCond::tracer(size_t sz) { TRACE_VECTOR(JavaThread*, threads); } Modified: vmkit/trunk/lib/JnJVM/VMCore/Zip.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Zip.cpp?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/Zip.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/Zip.cpp Thu Apr 10 06:35:38 2008 @@ -10,26 +10,28 @@ #include #include "JavaArray.h" +#include "Jnjvm.h" #include "LockedMap.h" #include "Reader.h" #include "Zip.h" using namespace jnjvm; -ZipArchive* ZipArchive::hashedArchive(char* archname) { +ZipArchive* ZipArchive::hashedArchive(Jnjvm* vm, char* archname) { assert(0 && "implement hashedArchive"); return 0; } -ZipArchive* ZipArchive::singleArchive(char* archname) { - ZipArchive* ar = gc_new(ZipArchive)(); +ZipArchive* ZipArchive::singleArchive(Jnjvm* vm, char* archname) { + ZipArchive* ar = vm_new(vm, ZipArchive)(); + ar->vm = vm; ar->name = archname; - ArrayUInt8* bytes = Reader::openFile(archname); + ArrayUInt8* bytes = Reader::openFile(vm, archname); if (bytes != 0) { - ar->reader = Reader::allocateReader(bytes); + ar->reader = vm_new(vm, Reader)(bytes); ar->findOfscd(); if (ar->ofscd > -1) { - ar->filetable = ZipFileMap::allocate(); + ar->filetable = vm_new(vm, ZipFileMap)(); ar->addFiles(); return ar; } @@ -136,7 +138,7 @@ while (true) { if (memcmp(&(reader->bytes->elements[temp]), HDR_CENTRAL, 4)) return; - ZipFile* ptr = gc_new(ZipFile)(); + ZipFile* ptr = vm_new(vm, ZipFile)(); reader->cursor = temp + 4 + C_COMPRESSION_METHOD; ptr->compressionMethod = readEndianDep2(reader); Modified: vmkit/trunk/lib/JnJVM/VMCore/Zip.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Zip.h?rev=49477&r1=49476&r2=49477&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/Zip.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/Zip.h Thu Apr 10 06:35:38 2008 @@ -49,6 +49,7 @@ ZipFileMap* filetable; char* name; Reader* reader; + Jnjvm* vm; virtual void print(mvm::PrintBuffer* buf) const { buf->write("ZipArchive<"); @@ -57,8 +58,8 @@ } virtual void tracer(size_t sz); - static ZipArchive* hashedArchive(char* archname); - static ZipArchive* singleArchive(char* archname); + static ZipArchive* hashedArchive(Jnjvm* vm, char* archname); + static ZipArchive* singleArchive(Jnjvm* vm, char* archname); ZipFile* getFile(const char* filename); int readFile(ArrayUInt8* array, const ZipFile* file); void remove(); From ggreif at gmail.com Thu Apr 10 07:36:32 2008 From: ggreif at gmail.com (Gabor Greif) Date: Thu, 10 Apr 2008 12:36:32 -0000 Subject: [llvm-commits] [llvm] r49478 - /llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Message-ID: <200804101236.m3ACaWEx010249@zion.cs.uiuc.edu> Author: ggreif Date: Thu Apr 10 07:36:31 2008 New Revision: 49478 URL: http://llvm.org/viewvc/llvm-project?rev=49478&view=rev Log: correct some baseclass initializations Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp?rev=49478&r1=49477&r2=49478&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Thu Apr 10 07:36:31 2008 @@ -100,11 +100,14 @@ TerminatorInst::~TerminatorInst() { } +//===----------------------------------------------------------------------===// +// UnaryInstruction Class +//===----------------------------------------------------------------------===// + // Out of line virtual method, so the vtable, etc has a home. UnaryInstruction::~UnaryInstruction() { } - //===----------------------------------------------------------------------===// // PHINode Class //===----------------------------------------------------------------------===// @@ -455,49 +458,60 @@ //===----------------------------------------------------------------------===// ReturnInst::ReturnInst(const ReturnInst &RI) - : TerminatorInst(Type::VoidTy, Instruction::Ret, - /*&RetVal*/NULL, RI.getNumOperands()) { + : TerminatorInst(Type::VoidTy/*FIXME: correct?*/, Instruction::Ret, + OperandTraits::op_end(this) - RI.getNumOperands(), + RI.getNumOperands()) { unsigned N = RI.getNumOperands(); - if (N == 1) + if (N == 1) Op<0>().init(RI.Op<0>(), this); else if (N) { - Use *OL = OperandList = allocHangoffUses(N); + Use *OL = OperandList; for (unsigned i = 0; i < N; ++i) OL[i].init(RI.getOperand(i), this); } } ReturnInst::ReturnInst(Value *retVal, Instruction *InsertBefore) - : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, 0, InsertBefore) { + : TerminatorInst(Type::VoidTy, Instruction::Ret, + OperandTraits::op_end(this) - (retVal != 0), + retVal != 0, InsertBefore) { if (retVal) init(&retVal, 1); } ReturnInst::ReturnInst(Value *retVal, BasicBlock *InsertAtEnd) - : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, 0, InsertAtEnd) { + : TerminatorInst(Type::VoidTy, Instruction::Ret, + OperandTraits::op_end(this) - (retVal != 0), + retVal != 0, InsertAtEnd) { if (retVal) init(&retVal, 1); } ReturnInst::ReturnInst(BasicBlock *InsertAtEnd) - : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, 0, InsertAtEnd) { + : TerminatorInst(Type::VoidTy, Instruction::Ret, + OperandTraits::op_end(this), + 0, InsertAtEnd) { } ReturnInst::ReturnInst(Value * const* retVals, unsigned N, Instruction *InsertBefore) - : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, N, InsertBefore) { + : TerminatorInst(Type::VoidTy, Instruction::Ret, + OperandTraits::op_end(this) - N, + N, InsertBefore) { if (N != 0) init(retVals, N); } ReturnInst::ReturnInst(Value * const* retVals, unsigned N, BasicBlock *InsertAtEnd) - : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, N, InsertAtEnd) { - if (N != 0) - init(retVals, N); -} -ReturnInst::ReturnInst(Value * const* retVals, unsigned N) - : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, N) { + : TerminatorInst(Type::VoidTy, Instruction::Ret, + OperandTraits::op_end(this) - N, + N, InsertAtEnd) { if (N != 0) init(retVals, N); } +//ReturnInst::ReturnInst(Value * const* retVals, unsigned N) +// : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, N) { +// if (N != 0) +// init(retVals, N); +//} void ReturnInst::init(Value * const* retVals, unsigned N) { assert (N > 0 && "Invalid operands numbers in ReturnInst init"); @@ -1274,7 +1288,10 @@ BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty, const std::string &Name, Instruction *InsertBefore) - : Instruction(Ty, iType, /*Ops*/NULL, 2, InsertBefore) { + : Instruction(Ty, iType, + OperandTraits::op_begin(this), + OperandTraits::operands(this), + InsertBefore) { Op<0>().init(S1, this); Op<1>().init(S2, this); init(iType); @@ -1284,7 +1301,10 @@ BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) - : Instruction(Ty, iType, /*Ops*/NULL, 2, InsertAtEnd) { + : Instruction(Ty, iType, + OperandTraits::op_begin(this), + OperandTraits::operands(this), + InsertAtEnd) { Op<0>().init(S1, this); Op<1>().init(S2, this); init(iType); From ggreif at gmail.com Thu Apr 10 07:46:24 2008 From: ggreif at gmail.com (Gabor Greif) Date: Thu, 10 Apr 2008 12:46:24 -0000 Subject: [llvm-commits] [llvm] r49479 - in /llvm/branches/ggreif/use-diet: include/llvm/Instructions.h lib/VMCore/Instructions.cpp Message-ID: <200804101246.m3ACkOTN010509@zion.cs.uiuc.edu> Author: ggreif Date: Thu Apr 10 07:46:24 2008 New Revision: 49479 URL: http://llvm.org/viewvc/llvm-project?rev=49479&view=rev Log: ooops, forgot to check in the header.. * define VariadicOperandTraits * ReturnInst: use VariadicOperandTraits for accessors * ReturnInst: remove redundant constructor and Create method * ReturnInst: init() should not allocate hung off Uses Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=49479&r1=49478&r2=49479&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Thu Apr 10 07:46:24 2008 @@ -1483,6 +1483,24 @@ }; //===----------------------------------------------------------------------===// +// VariadicOperand Trait Class +//===----------------------------------------------------------------------===// + +template +struct VariadicOperandTraits { + static Use *op_begin(User* U) { + return reinterpret_cast(U) - U->getNumOperands(); + } + static Use *op_end(User* U) { + return reinterpret_cast(U); + } + static unsigned operands(const User*U) { + return U->getNumOperands(); + } + static inline void *allocate(unsigned); // FIXME +}; + +//===----------------------------------------------------------------------===// // ReturnInst Class //===----------------------------------------------------------------------===// @@ -1511,8 +1529,8 @@ // if it was passed NULL. explicit ReturnInst(Value *retVal = 0, Instruction *InsertBefore = 0); ReturnInst(Value *retVal, BasicBlock *InsertAtEnd); - ReturnInst(Value * const* retVals, unsigned N); - ReturnInst(Value * const* retVals, unsigned N, Instruction *InsertBefore); +/* ReturnInst(Value * const* retVals, unsigned N);*/ + ReturnInst(Value * const* retVals, unsigned N, Instruction *InsertBefore = 0); ReturnInst(Value * const* retVals, unsigned N, BasicBlock *InsertAtEnd); explicit ReturnInst(BasicBlock *InsertAtEnd); public: @@ -1522,10 +1540,10 @@ static ReturnInst* Create(Value *retVal, BasicBlock *InsertAtEnd) { return new(!!retVal) ReturnInst(retVal, InsertAtEnd); } - static ReturnInst* Create(Value * const* retVals, unsigned N) { - return new(N) ReturnInst(retVals, N); - } - static ReturnInst* Create(Value * const* retVals, unsigned N, Instruction *InsertBefore) { +// static ReturnInst* Create(Value * const* retVals, unsigned N) { +// return new(N) ReturnInst(retVals, N); +// } + static ReturnInst* Create(Value * const* retVals, unsigned N, Instruction *InsertBefore = 0) { return new(N) ReturnInst(retVals, N, InsertBefore); } static ReturnInst* Create(Value * const* retVals, unsigned N, BasicBlock *InsertAtEnd) { @@ -1538,13 +1556,16 @@ virtual ReturnInst *clone() const; + /// Provide fast operand accessors + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +/* Value *getOperand(unsigned n = 0) const { if (getNumOperands() > 1) return TerminatorInst::getOperand(n); else return Op<0>(); } - +*/ Value *getReturnValue(unsigned n = 0) const { return getOperand(n); } @@ -1565,6 +1586,12 @@ virtual void setSuccessorV(unsigned idx, BasicBlock *B); }; +template <> +struct OperandTraits : VariadicOperandTraits<> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ReturnInst, Value) + //===----------------------------------------------------------------------===// // BranchInst Class //===----------------------------------------------------------------------===// Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp?rev=49479&r1=49478&r2=49479&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Thu Apr 10 07:46:24 2008 @@ -524,7 +524,7 @@ Op<0>().init(V, this); } - Use *OL = OperandList = allocHangoffUses(NumOperands); + Use *OL = OperandList; for (unsigned i = 0; i < NumOperands; ++i) { Value *V = *retVals++; assert(!isa(V) && From ggreif at gmail.com Thu Apr 10 08:08:37 2008 From: ggreif at gmail.com (Gabor Greif) Date: Thu, 10 Apr 2008 13:08:37 -0000 Subject: [llvm-commits] [llvm] r49480 - in /llvm/branches/ggreif/use-diet: include/llvm/Instructions.h lib/VMCore/Instructions.cpp Message-ID: <200804101308.m3AD8bvp011242@zion.cs.uiuc.edu> Author: ggreif Date: Thu Apr 10 08:08:37 2008 New Revision: 49480 URL: http://llvm.org/viewvc/llvm-project?rev=49480&view=rev Log: ReturnInst: various cleanups, define 'operator delete' to do the right thing Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=49480&r1=49479&r2=49480&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Thu Apr 10 08:08:37 2008 @@ -1511,25 +1511,25 @@ class ReturnInst : public TerminatorInst { ReturnInst(const ReturnInst &RI); void init(Value * const* retVals, unsigned N); + void *operator new(size_t, unsigned); // Do not implement private: // ReturnInst constructors: // ReturnInst() - 'ret void' instruction // ReturnInst( null) - 'ret void' instruction // ReturnInst(Value* X) - 'ret X' instruction - // ReturnInst( null, Inst *) - 'ret void' instruction, insert before I + // ReturnInst( null, Inst *I) - 'ret void' instruction, insert before I // ReturnInst(Value* X, Inst *I) - 'ret X' instruction, insert before I - // ReturnInst( null, BB *B) - 'ret void' instruction, insert @ end of BB - // ReturnInst(Value* X, BB *B) - 'ret X' instruction, insert @ end of BB + // ReturnInst( null, BB *B) - 'ret void' instruction, insert @ end of B + // ReturnInst(Value* X, BB *B) - 'ret X' instruction, insert @ end of B // ReturnInst(Value* X, N) - 'ret X,X+1...X+N-1' instruction - // ReturnInst(Value* X, N, Inst *) - 'ret X,X+1...X+N-1', insert before I - // ReturnInst(Value* X, N, BB *) - 'ret X,X+1...X+N-1', insert @ end of BB + // ReturnInst(Value* X, N, Inst *I) - 'ret X,X+1...X+N-1', insert before I + // ReturnInst(Value* X, N, BB *B) - 'ret X,X+1...X+N-1', insert @ end of B // // NOTE: If the Value* passed is of type void then the constructor behaves as // if it was passed NULL. explicit ReturnInst(Value *retVal = 0, Instruction *InsertBefore = 0); ReturnInst(Value *retVal, BasicBlock *InsertAtEnd); -/* ReturnInst(Value * const* retVals, unsigned N);*/ ReturnInst(Value * const* retVals, unsigned N, Instruction *InsertBefore = 0); ReturnInst(Value * const* retVals, unsigned N, BasicBlock *InsertAtEnd); explicit ReturnInst(BasicBlock *InsertAtEnd); @@ -1540,9 +1540,6 @@ static ReturnInst* Create(Value *retVal, BasicBlock *InsertAtEnd) { return new(!!retVal) ReturnInst(retVal, InsertAtEnd); } -// static ReturnInst* Create(Value * const* retVals, unsigned N) { -// return new(N) ReturnInst(retVals, N); -// } static ReturnInst* Create(Value * const* retVals, unsigned N, Instruction *InsertBefore = 0) { return new(N) ReturnInst(retVals, N, InsertBefore); } @@ -1553,19 +1550,14 @@ return new(0) ReturnInst(InsertAtEnd); } virtual ~ReturnInst(); + inline void operator delete(void*); virtual ReturnInst *clone() const; /// Provide fast operand accessors DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -/* - Value *getOperand(unsigned n = 0) const { - if (getNumOperands() > 1) - return TerminatorInst::getOperand(n); - else - return Op<0>(); - } -*/ + + /// Convenience accessor Value *getReturnValue(unsigned n = 0) const { return getOperand(n); } @@ -1591,6 +1583,9 @@ }; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ReturnInst, Value) +void ReturnInst::operator delete(void *it) { + OperandTraits::op_begin(static_cast(it)); +} //===----------------------------------------------------------------------===// // BranchInst Class Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp?rev=49480&r1=49479&r2=49480&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Thu Apr 10 08:08:37 2008 @@ -458,7 +458,7 @@ //===----------------------------------------------------------------------===// ReturnInst::ReturnInst(const ReturnInst &RI) - : TerminatorInst(Type::VoidTy/*FIXME: correct?*/, Instruction::Ret, + : TerminatorInst(Type::VoidTy, Instruction::Ret, OperandTraits::op_end(this) - RI.getNumOperands(), RI.getNumOperands()) { unsigned N = RI.getNumOperands(); @@ -507,11 +507,6 @@ if (N != 0) init(retVals, N); } -//ReturnInst::ReturnInst(Value * const* retVals, unsigned N) -// : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, N) { -// if (N != 0) -// init(retVals, N); -//} void ReturnInst::init(Value * const* retVals, unsigned N) { assert (N > 0 && "Invalid operands numbers in ReturnInst init"); @@ -550,8 +545,6 @@ } ReturnInst::~ReturnInst() { -// if (NumOperands > 1) -// delete [] OperandList; } //===----------------------------------------------------------------------===// From ggreif at gmail.com Thu Apr 10 08:17:15 2008 From: ggreif at gmail.com (Gabor Greif) Date: Thu, 10 Apr 2008 13:17:15 -0000 Subject: [llvm-commits] [llvm] r49481 - /llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Message-ID: <200804101317.m3ADHF4j011466@zion.cs.uiuc.edu> Author: ggreif Date: Thu Apr 10 08:17:15 2008 New Revision: 49481 URL: http://llvm.org/viewvc/llvm-project?rev=49481&view=rev Log: resolve link error Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=49481&r1=49480&r2=49481&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Thu Apr 10 08:17:15 2008 @@ -1511,7 +1511,6 @@ class ReturnInst : public TerminatorInst { ReturnInst(const ReturnInst &RI); void init(Value * const* retVals, unsigned N); - void *operator new(size_t, unsigned); // Do not implement private: // ReturnInst constructors: From ggreif at gmail.com Thu Apr 10 09:09:31 2008 From: ggreif at gmail.com (Gabor Greif) Date: Thu, 10 Apr 2008 14:09:31 -0000 Subject: [llvm-commits] [llvm] r49482 - in /llvm/branches/ggreif/use-diet: include/llvm/Instructions.h lib/VMCore/Instructions.cpp Message-ID: <200804101409.m3AE9VNC013002@zion.cs.uiuc.edu> Author: ggreif Date: Thu Apr 10 09:09:30 2008 New Revision: 49482 URL: http://llvm.org/viewvc/llvm-project?rev=49482&view=rev Log: convert CallInst to VariadicOperandTraits Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=49482&r1=49481&r2=49482&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Thu Apr 10 09:09:30 2008 @@ -364,6 +364,24 @@ //===----------------------------------------------------------------------===// +// VariadicOperand Trait Class +//===----------------------------------------------------------------------===// + +template +struct VariadicOperandTraits { + static Use *op_begin(User* U) { + return reinterpret_cast(U) - U->getNumOperands(); + } + static Use *op_end(User* U) { + return reinterpret_cast(U); + } + static unsigned operands(const User*U) { + return U->getNumOperands(); + } + static inline void *allocate(unsigned); // FIXME +}; + +//===----------------------------------------------------------------------===// // GetElementPtrInst Class //===----------------------------------------------------------------------===// @@ -901,13 +919,13 @@ /// @brief Construct a CallInst from a range of arguments template CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd, - const std::string &Name = "", Instruction *InsertBefore = 0) + const std::string &Name = "", Instruction *InsertBefore = 0);/* : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), Instruction::Call, 0, 0, InsertBefore) { init(Func, ArgBegin, ArgEnd, Name, typename std::iterator_traits::iterator_category()); - } + }*/ /// Construct a CallInst given a range of arguments. InputIterator /// must be a random-access iterator pointing to contiguous storage @@ -916,14 +934,15 @@ /// incur runtime overhead. /// @brief Construct a CallInst from a range of arguments template - CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd, - const std::string &Name, BasicBlock *InsertAtEnd) + inline CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd, + const std::string &Name, BasicBlock *InsertAtEnd); + /* : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), Instruction::Call, 0, 0, InsertAtEnd) { init(Func, ArgBegin, ArgEnd, Name, typename std::iterator_traits::iterator_category()); - } + }*/ CallInst(Value *F, Value *Actual, const std::string& Name = "", Instruction *InsertBefore = 0); @@ -962,6 +981,9 @@ ~CallInst(); virtual CallInst *clone() const; + + /// Provide fast operand accessors + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); bool isTailCall() const { return SubclassData & 1; } void setTailCall(bool isTailCall = true) { @@ -1045,6 +1067,39 @@ } }; +template <> +struct OperandTraits : VariadicOperandTraits<1> { +}; + +template +CallInst::CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd, + const std::string &Name, BasicBlock *InsertAtEnd) + : Instruction(cast(cast(Func->getType()) + ->getElementType())->getReturnType(), + Instruction::Call, + OperandTraits::op_end(this) - (ArgEnd - ArgBegin + 1), + ArgEnd - ArgBegin + 1, InsertAtEnd) { + init(Func, ArgBegin, ArgEnd, Name, + typename std::iterator_traits::iterator_category()); +} + +template +CallInst::CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd, + const std::string &Name, Instruction *InsertBefore) + : Instruction(cast(cast(Func->getType()) + ->getElementType())->getReturnType(), + Instruction::Call, + OperandTraits::op_end(this) - (ArgEnd - ArgBegin + 1), + ArgEnd - ArgBegin + 1, InsertBefore) { + init(Func, ArgBegin, ArgEnd, Name, + typename std::iterator_traits::iterator_category()); +} + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CallInst, Value) +//void CallInst::operator delete(void *it) { +// OperandTraits::op_begin(static_cast(it)); +//} + //===----------------------------------------------------------------------===// // SelectInst Class //===----------------------------------------------------------------------===// @@ -1483,24 +1538,6 @@ }; //===----------------------------------------------------------------------===// -// VariadicOperand Trait Class -//===----------------------------------------------------------------------===// - -template -struct VariadicOperandTraits { - static Use *op_begin(User* U) { - return reinterpret_cast(U) - U->getNumOperands(); - } - static Use *op_end(User* U) { - return reinterpret_cast(U); - } - static unsigned operands(const User*U) { - return U->getNumOperands(); - } - static inline void *allocate(unsigned); // FIXME -}; - -//===----------------------------------------------------------------------===// // ReturnInst Class //===----------------------------------------------------------------------===// Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp?rev=49482&r1=49481&r2=49482&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Thu Apr 10 09:09:30 2008 @@ -244,12 +244,11 @@ //===----------------------------------------------------------------------===// CallInst::~CallInst() { -// delete [] OperandList; } void CallInst::init(Value *Func, Value* const *Params, unsigned NumParams) { NumOperands = NumParams+1; - Use *OL = OperandList = allocHangoffUses(NumParams+1); + Use *OL = OperandList; OL[0].init(Func, this); const FunctionType *FTy = @@ -269,7 +268,7 @@ void CallInst::init(Value *Func, Value *Actual1, Value *Actual2) { NumOperands = 3; - Use *OL = OperandList = allocHangoffUses(3); + Use *OL = OperandList; OL[0].init(Func, this); OL[1].init(Actual1, this); OL[2].init(Actual2, this); @@ -291,7 +290,7 @@ void CallInst::init(Value *Func, Value *Actual) { NumOperands = 2; - Use *OL = OperandList = allocHangoffUses(2); + Use *OL = OperandList; OL[0].init(Func, this); OL[1].init(Actual, this); @@ -309,7 +308,7 @@ void CallInst::init(Value *Func) { NumOperands = 1; - Use *OL = OperandList = allocHangoffUses(1); + Use *OL = OperandList; OL[0].init(Func, this); const FunctionType *FTy = @@ -323,7 +322,9 @@ Instruction *InsertBefore) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, 0, 0, InsertBefore) { + Instruction::Call, + OperandTraits::op_end(this) - 2, + 2, InsertBefore) { init(Func, Actual); setName(Name); } @@ -332,7 +333,9 @@ BasicBlock *InsertAtEnd) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, 0, 0, InsertAtEnd) { + Instruction::Call, + OperandTraits::op_end(this) - 2, + 2, InsertAtEnd) { init(Func, Actual); setName(Name); } @@ -340,7 +343,9 @@ Instruction *InsertBefore) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, 0, 0, InsertBefore) { + Instruction::Call, + OperandTraits::op_end(this) - 1, + 1, InsertBefore) { init(Func); setName(Name); } @@ -349,13 +354,16 @@ BasicBlock *InsertAtEnd) : Instruction(cast(cast(Func->getType()) ->getElementType())->getReturnType(), - Instruction::Call, 0, 0, InsertAtEnd) { + Instruction::Call, + OperandTraits::op_end(this) - 1, + 1, InsertAtEnd) { init(Func); setName(Name); } CallInst::CallInst(const CallInst &CI) - : Instruction(CI.getType(), Instruction::Call, allocHangoffUses(CI.getNumOperands()), + : Instruction(CI.getType(), Instruction::Call, + OperandTraits::op_end(this) - CI.getNumOperands(), CI.getNumOperands()) { setParamAttrs(CI.getParamAttrs()); SubclassData = CI.SubclassData; From ggreif at gmail.com Thu Apr 10 09:54:43 2008 From: ggreif at gmail.com (Gabor Greif) Date: Thu, 10 Apr 2008 14:54:43 -0000 Subject: [llvm-commits] [llvm] r49483 - /llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h Message-ID: <200804101454.m3AEsh5a014555@zion.cs.uiuc.edu> Author: ggreif Date: Thu Apr 10 09:54:43 2008 New Revision: 49483 URL: http://llvm.org/viewvc/llvm-project?rev=49483&view=rev Log: introduce GlobalVariable::Create methods Modified: llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h Modified: llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h?rev=49483&r1=49482&r2=49483&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h Thu Apr 10 09:54:43 2008 @@ -32,7 +32,6 @@ class GlobalVariable : public GlobalValue { friend class SymbolTableListTraits; - void *operator new(size_t, unsigned); // Do not implement void operator=(const GlobalVariable &); // Do not implement GlobalVariable(const GlobalVariable &); // Do not implement @@ -45,23 +44,39 @@ bool isConstantGlobal : 1; // Is this a global constant? bool isThreadLocalSymbol : 1; // Is this symbol "Thread Local"? -public: - // allocate space for exactly one operand - void *operator new(size_t s) { - return User::operator new(s, 1); // FIXME: if no initializer, then 0 - } - /// GlobalVariable ctor - If a parent module is specified, the global is - /// automatically inserted into the end of the specified modules global list. +private: + /// GlobalVariable ctor - for internal use. GlobalVariable(const Type *Ty, bool isConstant, LinkageTypes Linkage, - Constant *Initializer = 0, const std::string &Name = "", - Module *Parent = 0, bool ThreadLocal = false, - unsigned AddressSpace = 0); - /// GlobalVariable ctor - This creates a global and inserts it before the - /// specified other global. + Constant *Initializer, const std::string &Name, + Module *Parent, bool ThreadLocal, unsigned AddressSpace); + /// GlobalVariable ctor - for internal use. GlobalVariable(const Type *Ty, bool isConstant, LinkageTypes Linkage, Constant *Initializer, const std::string &Name, - GlobalVariable *InsertBefore, bool ThreadLocal = false, - unsigned AddressSpace = 0); + GlobalVariable *InsertBefore, bool ThreadLocal, + unsigned AddressSpace); + +public: + /// GlobalVariable creator - If a parent module is specified, the global is + /// automatically inserted into the end of the specified modules global list. + static GlobalVariable *Create(const Type *Ty, bool isConstant, LinkageTypes Linkage, + Constant *Initializer = 0, const std::string &Name = "", + Module *Parent = 0, bool ThreadLocal = false, + unsigned AddressSpace = 0) { + return new (!!Initializer) GlobalVariable(Ty, isConstant, Linkage, + Initializer, Name, Parent, + ThreadLocal, AddressSpace); + } + + /// GlobalVariable creator - This creates a global and inserts it before the + /// specified other global. + static GlobalVariable *Create(const Type *Ty, bool isConstant, LinkageTypes Linkage, + Constant *Initializer, const std::string &Name, + GlobalVariable *InsertBefore, bool ThreadLocal = false, + unsigned AddressSpace = 0) { + return new (!!Initializer) GlobalVariable(Ty, isConstant, Linkage, + Initializer, Name, InsertBefore, + ThreadLocal, AddressSpace); + } /// isDeclaration - Is this global variable lacking an initializer? If so, /// the global variable is defined in some other translation unit, and is thus From ggreif at gmail.com Thu Apr 10 10:13:21 2008 From: ggreif at gmail.com (Gabor Greif) Date: Thu, 10 Apr 2008 15:13:21 -0000 Subject: [llvm-commits] [llvm] r49484 - in /llvm/branches/ggreif/use-diet: examples/BrainF/ lib/Bitcode/Reader/ lib/CodeGen/ lib/Linker/ lib/Transforms/IPO/ lib/Transforms/Instrumentation/ lib/Transforms/Utils/ lib/VMCore/ tools/bugpoint/ tools/llvm2cpp/ Message-ID: <200804101513.m3AFDMeP015054@zion.cs.uiuc.edu> Author: ggreif Date: Thu Apr 10 10:13:21 2008 New Revision: 49484 URL: http://llvm.org/viewvc/llvm-project?rev=49484&view=rev Log: create-ify GlobalVariable Modified: llvm/branches/ggreif/use-diet/examples/BrainF/BrainF.cpp llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp llvm/branches/ggreif/use-diet/lib/CodeGen/MachineModuleInfo.cpp llvm/branches/ggreif/use-diet/lib/CodeGen/ShadowStackCollector.cpp llvm/branches/ggreif/use-diet/lib/Linker/LinkModules.cpp llvm/branches/ggreif/use-diet/lib/Transforms/IPO/ExtractGV.cpp llvm/branches/ggreif/use-diet/lib/Transforms/IPO/GlobalOpt.cpp llvm/branches/ggreif/use-diet/lib/Transforms/IPO/SimplifyLibCalls.cpp llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/BlockProfiling.cpp llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/EdgeProfiling.cpp llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/RSProfiling.cpp llvm/branches/ggreif/use-diet/lib/Transforms/Utils/CloneModule.cpp llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LowerInvoke.cpp llvm/branches/ggreif/use-diet/lib/VMCore/Core.cpp llvm/branches/ggreif/use-diet/lib/VMCore/Module.cpp llvm/branches/ggreif/use-diet/tools/bugpoint/ExtractFunction.cpp llvm/branches/ggreif/use-diet/tools/bugpoint/Miscompilation.cpp llvm/branches/ggreif/use-diet/tools/llvm2cpp/CppWriter.cpp Modified: llvm/branches/ggreif/use-diet/examples/BrainF/BrainF.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/examples/BrainF/BrainF.cpp?rev=49484&r1=49483&r2=49484&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/examples/BrainF/BrainF.cpp (original) +++ llvm/branches/ggreif/use-diet/examples/BrainF/BrainF.cpp Thu Apr 10 10:13:21 2008 @@ -124,7 +124,7 @@ Constant *msg_0 = ConstantArray:: get("Error: The head has left the tape.", true); - GlobalVariable *aberrormsg = new GlobalVariable( + GlobalVariable *aberrormsg = GlobalVariable::Create( msg_0->getType(), true, GlobalValue::InternalLinkage, Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp?rev=49484&r1=49483&r2=49484&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp Thu Apr 10 10:13:21 2008 @@ -1021,7 +1021,7 @@ isThreadLocal = Record[7]; GlobalVariable *NewGV = - new GlobalVariable(Ty, isConstant, Linkage, 0, "", TheModule, + GlobalVariable::Create(Ty, isConstant, Linkage, 0, "", TheModule, isThreadLocal, AddressSpace); NewGV->setAlignment(Alignment); if (!Section.empty()) Modified: llvm/branches/ggreif/use-diet/lib/CodeGen/MachineModuleInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/CodeGen/MachineModuleInfo.cpp?rev=49484&r1=49483&r2=49484&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/CodeGen/MachineModuleInfo.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/CodeGen/MachineModuleInfo.cpp Thu Apr 10 10:13:21 2008 @@ -337,7 +337,7 @@ } Constant *CA = ConstantArray::get(AT, ArrayElements); - GlobalVariable *CAGV = new GlobalVariable(AT, true, + GlobalVariable *CAGV = GlobalVariable::Create(AT, true, GlobalValue::InternalLinkage, CA, "llvm.dbg.array", SR.getModule()); @@ -1333,7 +1333,7 @@ // Construct string as an llvm constant. Constant *ConstStr = ConstantArray::get(String); // Otherwise create and return a new string global. - GlobalVariable *StrGV = new GlobalVariable(ConstStr->getType(), true, + GlobalVariable *StrGV = GlobalVariable::Create(ConstStr->getType(), true, GlobalVariable::InternalLinkage, ConstStr, ".str", M); StrGV->setSection("llvm.metadata"); @@ -1357,11 +1357,11 @@ const StructType *Ty = getTagType(DD); // Create the GlobalVariable early to prevent infinite recursion. - GlobalVariable *GV = new GlobalVariable(Ty, true, DD->getLinkage(), + GlobalVariable *GV = GlobalVariable::Create(Ty, true, DD->getLinkage(), NULL, DD->getDescString(), M); GV->setSection("llvm.metadata"); - // Insert new GlobalVariable in DescGlobals map. + // Insert GlobalVariable::Create in DescGlobals map. Slot = GV; // Set up elements vector Modified: llvm/branches/ggreif/use-diet/lib/CodeGen/ShadowStackCollector.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/CodeGen/ShadowStackCollector.cpp?rev=49484&r1=49483&r2=49484&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/CodeGen/ShadowStackCollector.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/CodeGen/ShadowStackCollector.cpp Thu Apr 10 10:13:21 2008 @@ -229,7 +229,7 @@ // to be a ModulePass (which means it cannot be in the 'llc' pipeline // (which uses a FunctionPassManager (which segfaults (not asserts) if // provided a ModulePass))). - Constant *GV = new GlobalVariable(FrameMap->getType(), true, + Constant *GV = GlobalVariable::Create(FrameMap->getType(), true, GlobalVariable::InternalLinkage, FrameMap, "__gc_" + F.getName(), F.getParent()); @@ -292,7 +292,7 @@ if (!Head) { // If the root chain does not exist, insert a new one with linkonce // linkage! - Head = new GlobalVariable(StackEntryPtrTy, false, + Head = GlobalVariable::Create(StackEntryPtrTy, false, GlobalValue::LinkOnceLinkage, Constant::getNullValue(StackEntryPtrTy), "llvm_gc_root_chain", &M); Modified: llvm/branches/ggreif/use-diet/lib/Linker/LinkModules.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Linker/LinkModules.cpp?rev=49484&r1=49483&r2=49484&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Linker/LinkModules.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/Linker/LinkModules.cpp Thu Apr 10 10:13:21 2008 @@ -499,7 +499,7 @@ // symbol over in the dest module... the initializer will be filled in // later by LinkGlobalInits... GlobalVariable *NewDGV = - new GlobalVariable(SGV->getType()->getElementType(), + GlobalVariable::Create(SGV->getType()->getElementType(), SGV->isConstant(), SGV->getLinkage(), /*init*/0, SGV->getName(), Dest); // Propagate alignment, visibility and section info. @@ -523,7 +523,7 @@ // AppendingVars map. The name is cleared out so that no linkage is // performed. GlobalVariable *NewDGV = - new GlobalVariable(SGV->getType()->getElementType(), + GlobalVariable::Create(SGV->getType()->getElementType(), SGV->isConstant(), SGV->getLinkage(), /*init*/0, "", Dest); @@ -558,7 +558,7 @@ // DGV and create a new one of the appropriate type. if (SGV->getType() != DGVar->getType()) { GlobalVariable *NewDGV = - new GlobalVariable(SGV->getType()->getElementType(), + GlobalVariable::Create(SGV->getType()->getElementType(), DGVar->isConstant(), DGVar->getLinkage(), /*init*/0, DGVar->getName(), Dest); CopyGVAttributes(NewDGV, DGVar); @@ -1034,7 +1034,7 @@ // Create the new global variable... GlobalVariable *NG = - new GlobalVariable(NewType, G1->isConstant(), G1->getLinkage(), + GlobalVariable::Create(NewType, G1->isConstant(), G1->getLinkage(), /*init*/0, First->first, M, G1->isThreadLocal()); // Propagate alignment, visibility and section info. Modified: llvm/branches/ggreif/use-diet/lib/Transforms/IPO/ExtractGV.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/IPO/ExtractGV.cpp?rev=49484&r1=49483&r2=49484&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Transforms/IPO/ExtractGV.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/Transforms/IPO/ExtractGV.cpp Thu Apr 10 10:13:21 2008 @@ -106,7 +106,7 @@ } ArrayType *AT = ArrayType::get(SBP, AUGs.size()); Constant *Init = ConstantArray::get(AT, AUGs); - GlobalValue *gv = new GlobalVariable(AT, false, + GlobalValue *gv = GlobalVariable::Create(AT, false, GlobalValue::AppendingLinkage, Init, "llvm.used", &M); gv->setSection("llvm.metadata"); Modified: llvm/branches/ggreif/use-diet/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/IPO/GlobalOpt.cpp?rev=49484&r1=49483&r2=49484&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/Transforms/IPO/GlobalOpt.cpp Thu Apr 10 10:13:21 2008 @@ -473,7 +473,7 @@ Constant *In = getAggregateConstantElement(Init, ConstantInt::get(Type::Int32Ty, i)); assert(In && "Couldn't get element of initializer?"); - GlobalVariable *NGV = new GlobalVariable(STy->getElementType(i), false, + GlobalVariable *NGV = GlobalVariable::Create(STy->getElementType(i), false, GlobalVariable::InternalLinkage, In, GV->getName()+"."+utostr(i), (Module *)NULL, @@ -498,7 +498,7 @@ ConstantInt::get(Type::Int32Ty, i)); assert(In && "Couldn't get element of initializer?"); - GlobalVariable *NGV = new GlobalVariable(STy->getElementType(), false, + GlobalVariable *NGV = GlobalVariable::Create(STy->getElementType(), false, GlobalVariable::InternalLinkage, In, GV->getName()+"."+utostr(i), (Module *)NULL, @@ -799,7 +799,7 @@ // Create the new global variable. The contents of the malloc'd memory is // undefined, so initialize with an undef value. Constant *Init = UndefValue::get(MI->getAllocatedType()); - GlobalVariable *NewGV = new GlobalVariable(MI->getAllocatedType(), false, + GlobalVariable *NewGV = GlobalVariable::Create(MI->getAllocatedType(), false, GlobalValue::InternalLinkage, Init, GV->getName()+".body", (Module *)NULL, @@ -817,7 +817,7 @@ // If there is a comparison against null, we will insert a global bool to // keep track of whether the global was initialized yet or not. GlobalVariable *InitBool = - new GlobalVariable(Type::Int1Ty, false, GlobalValue::InternalLinkage, + GlobalVariable::Create(Type::Int1Ty, false, GlobalValue::InternalLinkage, ConstantInt::getFalse(), GV->getName()+".init", (Module *)NULL, GV->isThreadLocal()); bool InitBoolUsed = false; @@ -1132,7 +1132,7 @@ const Type *PFieldTy = PointerType::getUnqual(FieldTy); GlobalVariable *NGV = - new GlobalVariable(PFieldTy, false, GlobalValue::InternalLinkage, + GlobalVariable::Create(PFieldTy, false, GlobalValue::InternalLinkage, Constant::getNullValue(PFieldTy), GV->getName() + ".f" + utostr(FieldNo), GV, GV->isThreadLocal()); @@ -1356,7 +1356,7 @@ DOUT << " *** SHRINKING TO BOOL: " << *GV; // Create the new global, initializing it to false. - GlobalVariable *NewGV = new GlobalVariable(Type::Int1Ty, false, + GlobalVariable *NewGV = GlobalVariable::Create(Type::Int1Ty, false, GlobalValue::InternalLinkage, ConstantInt::getFalse(), GV->getName()+".b", (Module *)NULL, @@ -1754,7 +1754,7 @@ } // Create the new global and insert it next to the existing list. - GlobalVariable *NGV = new GlobalVariable(CA->getType(), GCL->isConstant(), + GlobalVariable *NGV = GlobalVariable::Create(CA->getType(), GCL->isConstant(), GCL->getLinkage(), CA, "", (Module *)NULL, GCL->isThreadLocal()); @@ -1992,7 +1992,7 @@ } else if (AllocaInst *AI = dyn_cast(CurInst)) { if (AI->isArrayAllocation()) return false; // Cannot handle array allocs. const Type *Ty = AI->getType()->getElementType(); - AllocaTmps.push_back(new GlobalVariable(Ty, false, + AllocaTmps.push_back(GlobalVariable::Create(Ty, false, GlobalValue::InternalLinkage, UndefValue::get(Ty), AI->getName())); Modified: llvm/branches/ggreif/use-diet/lib/Transforms/IPO/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/IPO/SimplifyLibCalls.cpp?rev=49484&r1=49483&r2=49484&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Transforms/IPO/SimplifyLibCalls.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/Transforms/IPO/SimplifyLibCalls.cpp Thu Apr 10 10:13:21 2008 @@ -1232,7 +1232,7 @@ // pass to be run after this pass, to merge duplicate strings. FormatStr.erase(FormatStr.end()-1); Constant *Init = ConstantArray::get(FormatStr, true); - Constant *GV = new GlobalVariable(Init->getType(), true, + Constant *GV = GlobalVariable::Create(Init->getType(), true, GlobalVariable::InternalLinkage, Init, "str", CI->getParent()->getParent()->getParent()); Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/BlockProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/BlockProfiling.cpp?rev=49484&r1=49483&r2=49484&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/BlockProfiling.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/BlockProfiling.cpp Thu Apr 10 10:13:21 2008 @@ -64,7 +64,7 @@ const Type *ATy = ArrayType::get(Type::Int32Ty, NumFunctions); GlobalVariable *Counters = - new GlobalVariable(ATy, false, GlobalValue::InternalLinkage, + GlobalVariable::Create(ATy, false, GlobalValue::InternalLinkage, Constant::getNullValue(ATy), "FuncProfCounters", &M); // Instrument all of the functions... @@ -109,7 +109,7 @@ const Type *ATy = ArrayType::get(Type::Int32Ty, NumBlocks); GlobalVariable *Counters = - new GlobalVariable(ATy, false, GlobalValue::InternalLinkage, + GlobalVariable::Create(ATy, false, GlobalValue::InternalLinkage, Constant::getNullValue(ATy), "BlockProfCounters", &M); // Instrument all of the blocks... Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/EdgeProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/EdgeProfiling.cpp?rev=49484&r1=49483&r2=49484&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/EdgeProfiling.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/EdgeProfiling.cpp Thu Apr 10 10:13:21 2008 @@ -65,7 +65,7 @@ const Type *ATy = ArrayType::get(Type::Int32Ty, NumEdges); GlobalVariable *Counters = - new GlobalVariable(ATy, false, GlobalValue::InternalLinkage, + GlobalVariable::Create(ATy, false, GlobalValue::InternalLinkage, Constant::getNullValue(ATy), "EdgeProfCounters", &M); // Instrument all of the edges... Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/RSProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/RSProfiling.cpp?rev=49484&r1=49483&r2=49484&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/RSProfiling.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/Transforms/Instrumentation/RSProfiling.cpp Thu Apr 10 10:13:21 2008 @@ -193,7 +193,7 @@ uint64_t resetval) : T(t) { ConstantInt* Init = ConstantInt::get(T, resetval); ResetValue = Init; - Counter = new GlobalVariable(T, false, GlobalValue::InternalLinkage, + Counter = GlobalVariable::Create(T, false, GlobalValue::InternalLinkage, Init, "RandomSteeringCounter", &M); } @@ -230,7 +230,7 @@ : AI(0), T(t) { ConstantInt* Init = ConstantInt::get(T, resetval); ResetValue = Init; - Counter = new GlobalVariable(T, false, GlobalValue::InternalLinkage, + Counter = GlobalVariable::Create(T, false, GlobalValue::InternalLinkage, Init, "RandomSteeringCounter", &M); } Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Utils/CloneModule.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Utils/CloneModule.cpp?rev=49484&r1=49483&r2=49484&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Transforms/Utils/CloneModule.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/Transforms/Utils/CloneModule.cpp Thu Apr 10 10:13:21 2008 @@ -56,7 +56,7 @@ // for (Module::const_global_iterator I = M->global_begin(), E = M->global_end(); I != E; ++I) - ValueMap[I] = new GlobalVariable(I->getType()->getElementType(), false, + ValueMap[I] = GlobalVariable::Create(I->getType()->getElementType(), false, GlobalValue::ExternalLinkage, 0, I->getName(), New); Modified: llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LowerInvoke.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LowerInvoke.cpp?rev=49484&r1=49483&r2=49484&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LowerInvoke.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/Transforms/Utils/LowerInvoke.cpp Thu Apr 10 10:13:21 2008 @@ -138,7 +138,7 @@ // Now that we've done that, insert the jmpbuf list head global, unless it // already exists. if (!(JBListHead = M.getGlobalVariable("llvm.sjljeh.jblist", PtrJBList))) { - JBListHead = new GlobalVariable(PtrJBList, false, + JBListHead = GlobalVariable::Create(PtrJBList, false, GlobalValue::LinkOnceLinkage, Constant::getNullValue(PtrJBList), "llvm.sjljeh.jblist", &M); @@ -166,7 +166,7 @@ ConstantArray::get("ERROR: Exception thrown, but not caught!\n"); AbortMessageLength = Msg->getNumOperands()-1; // don't include \0 - GlobalVariable *MsgGV = new GlobalVariable(Msg->getType(), true, + GlobalVariable *MsgGV = GlobalVariable::Create(Msg->getType(), true, GlobalValue::InternalLinkage, Msg, "abortmsg", M); std::vector GEPIdx(2, Constant::getNullValue(Type::Int32Ty)); @@ -179,7 +179,7 @@ " program with -enable-correct-eh-support.\n"); AbortMessageLength = Msg->getNumOperands()-1; // don't include \0 - GlobalVariable *MsgGV = new GlobalVariable(Msg->getType(), true, + GlobalVariable *MsgGV = GlobalVariable::Create(Msg->getType(), true, GlobalValue::InternalLinkage, Msg, "abortmsg", M); std::vector GEPIdx(2, Constant::getNullValue(Type::Int32Ty)); Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Core.cpp?rev=49484&r1=49483&r2=49484&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Core.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Core.cpp Thu Apr 10 10:13:21 2008 @@ -592,7 +592,7 @@ /*--.. Operations on global variables ......................................--*/ LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name) { - return wrap(new GlobalVariable(unwrap(Ty), false, + return wrap(GlobalVariable::Create(unwrap(Ty), false, GlobalValue::ExternalLinkage, 0, Name, unwrap(M))); } Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Module.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Module.cpp?rev=49484&r1=49483&r2=49484&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Module.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Module.cpp Thu Apr 10 10:13:21 2008 @@ -38,7 +38,7 @@ return Ret; } GlobalVariable *ilist_traits::createSentinel() { - GlobalVariable *Ret = new GlobalVariable(Type::Int32Ty, false, + GlobalVariable *Ret = GlobalVariable::Create(Type::Int32Ty, false, GlobalValue::ExternalLinkage); // This should not be garbage monitored. LeakDetector::removeGarbageObject(Ret); Modified: llvm/branches/ggreif/use-diet/tools/bugpoint/ExtractFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/tools/bugpoint/ExtractFunction.cpp?rev=49484&r1=49483&r2=49484&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/tools/bugpoint/ExtractFunction.cpp (original) +++ llvm/branches/ggreif/use-diet/tools/bugpoint/ExtractFunction.cpp Thu Apr 10 10:13:21 2008 @@ -233,7 +233,7 @@ GV->eraseFromParent(); if (!M1Tors.empty()) { Constant *M1Init = GetTorInit(M1Tors); - new GlobalVariable(M1Init->getType(), false, GlobalValue::AppendingLinkage, + GlobalVariable::Create(M1Init->getType(), false, GlobalValue::AppendingLinkage, M1Init, GlobalName, M1); } @@ -244,7 +244,7 @@ GV->eraseFromParent(); if (!M2Tors.empty()) { Constant *M2Init = GetTorInit(M2Tors); - new GlobalVariable(M2Init->getType(), false, GlobalValue::AppendingLinkage, + GlobalVariable::Create(M2Init->getType(), false, GlobalValue::AppendingLinkage, M2Init, GlobalName, M2); } } Modified: llvm/branches/ggreif/use-diet/tools/bugpoint/Miscompilation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/tools/bugpoint/Miscompilation.cpp?rev=49484&r1=49483&r2=49484&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/tools/bugpoint/Miscompilation.cpp (original) +++ llvm/branches/ggreif/use-diet/tools/bugpoint/Miscompilation.cpp Thu Apr 10 10:13:21 2008 @@ -693,7 +693,7 @@ // 1. Add a string constant with its name to the global file Constant *InitArray = ConstantArray::get(F->getName()); GlobalVariable *funcName = - new GlobalVariable(InitArray->getType(), true /*isConstant*/, + GlobalVariable::Create(InitArray->getType(), true /*isConstant*/, GlobalValue::InternalLinkage, InitArray, F->getName() + "_name", Safe); @@ -712,7 +712,7 @@ // Create a new global to hold the cached function pointer. Constant *NullPtr = ConstantPointerNull::get(F->getType()); GlobalVariable *Cache = - new GlobalVariable(F->getType(), false,GlobalValue::InternalLinkage, + GlobalVariable::Create(F->getType(), false,GlobalValue::InternalLinkage, NullPtr,F->getName()+".fpcache", F->getParent()); // Construct a new stub function that will re-route calls to F Modified: llvm/branches/ggreif/use-diet/tools/llvm2cpp/CppWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/tools/llvm2cpp/CppWriter.cpp?rev=49484&r1=49483&r2=49484&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/tools/llvm2cpp/CppWriter.cpp (original) +++ llvm/branches/ggreif/use-diet/tools/llvm2cpp/CppWriter.cpp Thu Apr 10 10:13:21 2008 @@ -989,7 +989,7 @@ nl(Out) << "if (!" << getCppName(GV) << ") {"; in(); nl(Out) << getCppName(GV); } - Out << " = new GlobalVariable("; + Out << " = GlobalVariable::Create("; nl(Out) << "/*Type=*/"; printCppName(GV->getType()->getElementType()); Out << ","; From ggreif at gmail.com Thu Apr 10 11:15:39 2008 From: ggreif at gmail.com (Gabor Greif) Date: Thu, 10 Apr 2008 16:15:39 -0000 Subject: [llvm-commits] [llvm] r49487 - in /llvm/branches/ggreif/use-diet: include/llvm/GlobalVariable.h include/llvm/Instructions.h include/llvm/OperandTraits.h lib/VMCore/Globals.cpp Message-ID: <200804101615.m3AGFd5R016917@zion.cs.uiuc.edu> Author: ggreif Date: Thu Apr 10 11:15:39 2008 New Revision: 49487 URL: http://llvm.org/viewvc/llvm-project?rev=49487&view=rev Log: factor out VariadicOperandTraits to a header, use traits for GlobalVariable Added: llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h Modified: llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h llvm/branches/ggreif/use-diet/include/llvm/Instructions.h llvm/branches/ggreif/use-diet/lib/VMCore/Globals.cpp Modified: llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h?rev=49487&r1=49486&r2=49487&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h Thu Apr 10 11:15:39 2008 @@ -21,6 +21,7 @@ #define LLVM_GLOBAL_VARIABLE_H #include "llvm/GlobalValue.h" +#include "llvm/OperandTraits.h" namespace llvm { @@ -78,6 +79,9 @@ ThreadLocal, AddressSpace); } + /// Provide fast operand accessors + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); + /// isDeclaration - Is this global variable lacking an initializer? If so, /// the global variable is defined in some other translation unit, and is thus /// only a declaration here. @@ -155,6 +159,12 @@ const GlobalVariable *getPrev() const { return Prev; } }; +template <> +struct OperandTraits : VariadicOperandTraits<> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalVariable, Value) + } // End llvm namespace #endif Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=49487&r1=49486&r2=49487&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Thu Apr 10 11:15:39 2008 @@ -21,6 +21,7 @@ #include "llvm/InstrTypes.h" #include "llvm/DerivedTypes.h" #include "llvm/ParameterAttributes.h" +#include "llvm/OperandTraits.h" namespace llvm { @@ -364,24 +365,6 @@ //===----------------------------------------------------------------------===// -// VariadicOperand Trait Class -//===----------------------------------------------------------------------===// - -template -struct VariadicOperandTraits { - static Use *op_begin(User* U) { - return reinterpret_cast(U) - U->getNumOperands(); - } - static Use *op_end(User* U) { - return reinterpret_cast(U); - } - static unsigned operands(const User*U) { - return U->getNumOperands(); - } - static inline void *allocate(unsigned); // FIXME -}; - -//===----------------------------------------------------------------------===// // GetElementPtrInst Class //===----------------------------------------------------------------------===// Added: llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h?rev=49487&view=auto ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h (added) +++ llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h Thu Apr 10 11:15:39 2008 @@ -0,0 +1,67 @@ +//===-- llvm/OperandTraits.h - OperandTraits class definition ---------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the FIXME. +// + +#ifndef LLVM_OPERAND_TRAITS_H +#define LLVM_OPERAND_TRAITS_H + +#include "llvm/User.h" + +namespace llvm { + +//===----------------------------------------------------------------------===// +// VariadicOperand Trait Class +//===----------------------------------------------------------------------===// + +template +struct VariadicOperandTraits { + static Use *op_begin(User* U) { + return reinterpret_cast(U) - U->getNumOperands(); + } + static Use *op_end(User* U) { + return reinterpret_cast(U); + } + static unsigned operands(const User *U) { + return U->getNumOperands(); + } + static inline void *allocate(unsigned); // FIXME +}; + +/// Macro for generating in-class operand accessor declarations +#define DECLARE_TRANSPARENT_OPERAND_ACCESSORS(VALUECLASS) \ + inline VALUECLASS *getOperand(unsigned) const; \ + inline void setOperand(unsigned, VALUECLASS*); \ + inline unsigned getNumOperands() const; \ + template inline Use &Op(); \ + template inline const Use &Op() const + +/// Macro for generating out-of-class operand accessor definitions +#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS) \ +VALUECLASS *CLASS::getOperand(unsigned i) const { \ + assert(i < OperandTraits::operands(this) && "getOperand() out of range!"); \ + return OperandTraits::op_begin(const_cast(this))[i]; \ +} \ +void CLASS::setOperand(unsigned i, VALUECLASS *Val) { \ + assert(i < OperandTraits::operands(this) && "setOperand() out of range!"); \ + OperandTraits::op_begin(this)[i] = Val; \ +} \ +unsigned CLASS::getNumOperands() const { return OperandTraits::operands(this); } \ +template Use &CLASS::Op() { \ + return OperandTraits::op_begin(this)[Idx]; \ +} \ +template const Use &CLASS::Op() const { \ + return OperandTraits::op_begin(const_cast(this))[Idx]; \ +} + + +} // End llvm namespace + +#endif Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Globals.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Globals.cpp?rev=49487&r1=49486&r2=49487&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Globals.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Globals.cpp Thu Apr 10 11:15:39 2008 @@ -89,14 +89,13 @@ Module *ParentModule, bool ThreadLocal, unsigned AddressSpace) : GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalVariableVal, - &Op<0>(), InitVal != 0, Link, Name), + OperandTraits::op_end(this) - (InitVal != 0), + InitVal != 0, Link, Name), isConstantGlobal(constant), isThreadLocalSymbol(ThreadLocal) { if (InitVal) { assert(InitVal->getType() == Ty && "Initializer should be the same type as the GlobalVariable!"); Op<0>().init(InitVal, this); - } else { - Op<0>().init(0, this); // FIXME: if no InitVal, then none! } LeakDetector::addGarbageObject(this); @@ -110,14 +109,13 @@ GlobalVariable *Before, bool ThreadLocal, unsigned AddressSpace) : GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalVariableVal, - &Op<0>(), InitVal != 0, Link, Name), + OperandTraits::op_end(this) - (InitVal != 0), + InitVal != 0, Link, Name), isConstantGlobal(constant), isThreadLocalSymbol(ThreadLocal) { if (InitVal) { assert(InitVal->getType() == Ty && "Initializer should be the same type as the GlobalVariable!"); Op<0>().init(InitVal, this); - } else { - Op<0>().init(0, this); // FIXME: if no InitVal, then none! } LeakDetector::addGarbageObject(this); From sabre at nondot.org Thu Apr 10 11:21:24 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 10 Apr 2008 09:21:24 -0700 Subject: [llvm-commits] [llvm] r49458 - /llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp In-Reply-To: <200804101325.35656.baldrick@free.fr> References: <200804100207.m3A27ph4015558@zion.cs.uiuc.edu> <200804101058.52981.baldrick@free.fr> <9B4C520F-3E10-4183-891C-A5D83F70F0A7@gmail.com> <200804101325.35656.baldrick@free.fr> Message-ID: On Apr 10, 2008, at 4:25 AM, Duncan Sands wrote: >>>> + // x pow(x, 0.5) sqrt(x) >>>> + // --------------------------------------------- >>>> + // -0.0 +0.0 -0.0 >>>> + // -inf +inf NaN >>> >>> looks like pow is broken. Is pow's behaviour documented >>> anywhere? On my machine the man page says: >>> >>> The pow() function can return the following error: >>> >>> EDOM The argument x is negative and y is not an integral >>> value. This would result in a complex num? >>> ber. >>> -0.0 is negative, but it *is* an integral value, so EDOM doesn't apply. -Chris From sabre at nondot.org Thu Apr 10 11:23:34 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 10 Apr 2008 09:23:34 -0700 Subject: [llvm-commits] [llvm] r49458 - /llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp In-Reply-To: <200804101058.52981.baldrick@free.fr> References: <200804100207.m3A27ph4015558@zion.cs.uiuc.edu> <200804101058.52981.baldrick@free.fr> Message-ID: <83EEE184-8333-4449-83D8-C6834E2579C9@nondot.org> On Apr 10, 2008, at 1:58 AM, Duncan Sands wrote: > Hi, > >> + // x pow(x, 0.5) sqrt(x) >> + // --------------------------------------------- >> + // -0.0 +0.0 -0.0 >> + // -inf +inf NaN > > looks like pow is broken. Is pow's behaviour documented > anywhere? On my machine the man page says: > > The pow() function can return the following error: > > EDOM The argument x is negative and y is not an integral > value. This would result in a complex num? > ber. > > Are you sure errno is not being set by pow in these cases? Incidentally, gcc also does not perform this xform unless 'unsafe math optzns' are enabled. -Chris From baldrick at free.fr Thu Apr 10 11:47:00 2008 From: baldrick at free.fr (Duncan Sands) Date: Thu, 10 Apr 2008 18:47:00 +0200 Subject: [llvm-commits] [llvm] r49458 - /llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp In-Reply-To: References: <200804100207.m3A27ph4015558@zion.cs.uiuc.edu> <200804101325.35656.baldrick@free.fr> Message-ID: <200804101847.00651.baldrick@free.fr> On Thursday 10 April 2008 18:21:24 Chris Lattner wrote: > On Apr 10, 2008, at 4:25 AM, Duncan Sands wrote: > >>>> + // x pow(x, 0.5) sqrt(x) > >>>> + // --------------------------------------------- > >>>> + // -0.0 +0.0 -0.0 > >>>> + // -inf +inf NaN > >>> > >>> looks like pow is broken. Is pow's behaviour documented > >>> anywhere? On my machine the man page says: > >>> > >>> The pow() function can return the following error: > >>> > >>> EDOM The argument x is negative and y is not an integral > >>> value. This would result in a complex num? > >>> ber. > >>> > > -0.0 is negative, but it *is* an integral value, so EDOM doesn't apply. You are confusing x and y. D. From dalej at apple.com Thu Apr 10 11:50:41 2008 From: dalej at apple.com (Dale Johannesen) Date: Thu, 10 Apr 2008 09:50:41 -0700 Subject: [llvm-commits] [llvm] r49458 - /llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp In-Reply-To: <200804101058.52981.baldrick@free.fr> References: <200804100207.m3A27ph4015558@zion.cs.uiuc.edu> <200804101058.52981.baldrick@free.fr> Message-ID: <0D0ECC2C-FA9A-4089-A145-81095B980106@apple.com> On Apr 10, 2008, at 1:58 AM, Duncan Sands wrote: > Hi, > >> + // x pow(x, 0.5) sqrt(x) >> + // --------------------------------------------- >> + // -0.0 +0.0 -0.0 >> + // -inf +inf NaN > > looks like pow is broken. Is pow's behaviour documented > anywhere? On my machine the man page says: > > The pow() function can return the following error: > > EDOM The argument x is negative and y is not an integral > value. This would result in a complex num? > ber. > > Are you sure errno is not being set by pow in these cases? The Darwin math libraries do not set errno under any circumstances, and they never will. C99 makes this optional (see math_errhandling). From sabre at nondot.org Thu Apr 10 11:51:48 2008 From: sabre at nondot.org (Chris Lattner) Date: Thu, 10 Apr 2008 09:51:48 -0700 Subject: [llvm-commits] [llvm] r49458 - /llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp In-Reply-To: <200804101847.00651.baldrick@free.fr> References: <200804100207.m3A27ph4015558@zion.cs.uiuc.edu> <200804101325.35656.baldrick@free.fr> <200804101847.00651.baldrick@free.fr> Message-ID: On Apr 10, 2008, at 9:47 AM, Duncan Sands wrote: > On Thursday 10 April 2008 18:21:24 Chris Lattner wrote: >> On Apr 10, 2008, at 4:25 AM, Duncan Sands wrote: >>>>>> + // x pow(x, 0.5) sqrt(x) >>>>>> + // --------------------------------------------- >>>>>> + // -0.0 +0.0 -0.0 >>>>>> + // -inf +inf NaN >>>>> >>>>> looks like pow is broken. Is pow's behaviour documented >>>>> anywhere? On my machine the man page says: >>>>> >>>>> The pow() function can return the following error: >>>>> >>>>> EDOM The argument x is negative and y is not an integral >>>>> value. This would result in a complex num? >>>>> ber. >>>>> >> >> -0.0 is negative, but it *is* an integral value, so EDOM doesn't >> apply. > > You are confusing x and y. Whoa, you're right. I'll ping my numeric guru and ask why. :) -Chris From nicolas.geoffray at lip6.fr Thu Apr 10 12:17:12 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 10 Apr 2008 17:17:12 -0000 Subject: [llvm-commits] [vmkit] r49490 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaJIT.cpp ServiceDomain.cpp ServiceDomain.h Message-ID: <200804101717.m3AHHCbP018732@zion.cs.uiuc.edu> Author: geoffray Date: Thu Apr 10 12:17:12 2008 New Revision: 49490 URL: http://llvm.org/viewvc/llvm-project?rev=49490&view=rev Log: Give the virtual machine as a parameter to all functions if compiled with MULTIPLE_VM Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=49490&r1=49489&r2=49490&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Thu Apr 10 12:17:12 2008 @@ -43,6 +43,10 @@ #include "Reader.h" #include "Zip.h" +#ifdef SERVICE_VM +#include "ServiceDomain.h" +#endif + using namespace jnjvm; using namespace llvm; Modified: vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp?rev=49490&r1=49489&r2=49490&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp Thu Apr 10 12:17:12 2008 @@ -13,11 +13,40 @@ #include "JnjvmModuleProvider.h" #include "ServiceDomain.h" +#include +#include + extern "C" struct JNINativeInterface JNI_JNIEnvTable; extern "C" const struct JNIInvokeInterface JNI_JavaVMTable; using namespace jnjvm; + +GlobalVariable* ServiceDomain::llvmDelegatee() { + if (!_llvmDelegatee) { + lock->lock(); + if (!_llvmDelegatee) { + const Type* pty = mvm::jit::ptrType; + + mvm::jit::protectConstants();//->lock(); + Constant* cons = + ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64(this)), + pty); + mvm::jit::unprotectConstants();//->unlock(); + + this->protectModule->lock(); + _llvmDelegatee = new GlobalVariable(pty, true, + GlobalValue::ExternalLinkage, + cons, "", + this->module); + this->protectModule->unlock(); + } + lock->unlock(); + } + return _llvmDelegatee; +} + + void ServiceDomain::destroyer(size_t sz) { mvm::jit::protectEngine->lock(); mvm::jit::executionEngine->removeModuleProvider(TheModuleProvider); @@ -70,6 +99,7 @@ service->numThreads = 0; service->loadBootstrap(); + service->lock = mvm::Lock::allocNormal(); return service; } Modified: vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h?rev=49490&r1=49489&r2=49490&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h Thu Apr 10 12:17:12 2008 @@ -14,11 +14,22 @@ #include "Jnjvm.h" +namespace llvm { + class GlobalVariable; +} + +namespace mvm { + class Lock; +} + namespace jnjvm { class ClassMap; class ServiceDomain : public Jnjvm { +private: + llvm::GlobalVariable* _llvmDelegatee; + mvm::Lock* lock; public: static VirtualTable* VT; @@ -27,7 +38,8 @@ virtual void destroyer(size_t sz); void loadBootstrap(); static ServiceDomain* allocateService(Jnjvm* callingVM); - + llvm::GlobalVariable* llvmDelegatee(); + ClassMap* classes; time_t started; uint64 executionTime; From clattner at apple.com Thu Apr 10 12:25:16 2008 From: clattner at apple.com (Chris Lattner) Date: Thu, 10 Apr 2008 10:25:16 -0700 Subject: [llvm-commits] [llvm] r49458 - /llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp In-Reply-To: References: <200804100207.m3A27ph4015558@zion.cs.uiuc.edu> <200804101325.35656.baldrick@free.fr> <200804101847.00651.baldrick@free.fr> Message-ID: <2B008C76-4C5E-415F-A9B7-574BB330DF94@apple.com> On Apr 10, 2008, at 9:51 AM, Chris Lattner wrote: > On Apr 10, 2008, at 9:47 AM, Duncan Sands wrote: >> On Thursday 10 April 2008 18:21:24 Chris Lattner wrote: >>> On Apr 10, 2008, at 4:25 AM, Duncan Sands wrote: >>>>>>> + // x pow(x, 0.5) sqrt(x) >>>>>>> + // --------------------------------------------- >>>>>>> + // -0.0 +0.0 -0.0 >>>>>>> + // -inf +inf NaN >>>>>> >>>>>> looks like pow is broken. Is pow's behaviour documented >>>>>> anywhere? On my machine the man page says: >>>>>> >>>>>> The pow() function can return the following error: >>>>>> >>>>>> EDOM The argument x is negative and y is not an integral >>>>>> value. This would result in a complex num? >>>>>> ber. >>>>>> >>> >>> -0.0 is negative, but it *is* an integral value, so EDOM doesn't >>> apply. >> >> You are confusing x and y. > > Whoa, you're right. I'll ping my numeric guru and ask why. :) His response: I stand behind the claim that the behavior of the pow(x, 0.5) -> sqrt substitution is incompatible with C99. Here are the exact citations: From C99, Annex F (normative): F.9.4.4 The pow functions ? pow(+-0, y) returns +0 for y > 0 and not an odd integer. ? pow(-inf, y) returns +inf for y > 0 and not an odd integer. F.9.4.5 The sqrt functions sqrt is fully specified as a basic arithmetic operation in IEC 60559 From IEC 60559 (IEEE 754-1985), section 5.2: ... the square root of -0 shall be -0. Does that pin things down enough for you? ? Steve From evan.cheng at apple.com Thu Apr 10 13:38:47 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 10 Apr 2008 18:38:47 -0000 Subject: [llvm-commits] [llvm] r49491 - in /llvm/trunk: lib/CodeGen/SimpleRegisterCoalescing.cpp test/CodeGen/PowerPC/2008-04-10-LiveIntervalCrash.ll Message-ID: <200804101838.m3AIcl8j021089@zion.cs.uiuc.edu> Author: evancheng Date: Thu Apr 10 13:38:47 2008 New Revision: 49491 URL: http://llvm.org/viewvc/llvm-project?rev=49491&view=rev Log: A copy instruction may use a register multiple times on some targets. Change them all. Added: llvm/trunk/test/CodeGen/PowerPC/2008-04-10-LiveIntervalCrash.ll Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=49491&r1=49490&r2=49491&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Thu Apr 10 13:38:47 2008 @@ -716,7 +716,6 @@ VNInfo *VNI) { for (MachineRegisterInfo::use_iterator UI = mri_->use_begin(li.reg), UE = mri_->use_end(); UI != UE;) { - MachineOperand &UseMO = UI.getOperand(); MachineInstr *UseMI = &*UI; ++UI; if (JoinedCopies.count(UseMI)) @@ -731,7 +730,12 @@ unsigned SrcReg, DstReg; if (!tii_->isMoveInstr(*UseMI, SrcReg, DstReg) || SrcReg != li.reg) assert(0 && "Unexpected use of implicit def!"); - UseMO.setReg(DstReg); + // Each UseMI may have multiple uses of this register. Change them all. + for (unsigned i = 0, e = UseMI->getNumOperands(); i != e; ++i) { + MachineOperand &MO = UseMI->getOperand(i); + if (MO.isReg() && MO.getReg() == li.reg) + MO.setReg(DstReg); + } JoinedCopies.insert(UseMI); } } Added: llvm/trunk/test/CodeGen/PowerPC/2008-04-10-LiveIntervalCrash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/2008-04-10-LiveIntervalCrash.ll?rev=49491&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/2008-04-10-LiveIntervalCrash.ll (added) +++ llvm/trunk/test/CodeGen/PowerPC/2008-04-10-LiveIntervalCrash.ll Thu Apr 10 13:38:47 2008 @@ -0,0 +1,100 @@ +; RUN: llvm-as < %s | llc -mtriple=powerpc-apple-darwin + +define fastcc i64 @nonzero_bits1() nounwind { +entry: + switch i32 0, label %bb1385 [ + i32 28, label %bb235 + i32 35, label %bb153 + i32 37, label %bb951 + i32 40, label %bb289 + i32 44, label %bb1344 + i32 46, label %bb651 + i32 47, label %bb651 + i32 48, label %bb322 + i32 49, label %bb651 + i32 50, label %bb651 + i32 51, label %bb651 + i32 52, label %bb651 + i32 53, label %bb651 + i32 54, label %bb535 + i32 55, label %bb565 + i32 56, label %bb565 + i32 58, label %bb1100 + i32 59, label %bb1100 + i32 60, label %bb1100 + i32 61, label %bb1100 + i32 63, label %bb565 + i32 64, label %bb565 + i32 65, label %bb565 + i32 66, label %bb565 + i32 73, label %bb302 + i32 74, label %bb302 + i32 75, label %bb302 + i32 76, label %bb302 + i32 77, label %bb302 + i32 78, label %bb302 + i32 79, label %bb302 + i32 80, label %bb302 + i32 81, label %bb302 + i32 82, label %bb302 + i32 83, label %bb302 + i32 84, label %bb302 + i32 85, label %bb302 + i32 86, label %bb302 + i32 87, label %bb302 + i32 88, label %bb302 + i32 89, label %bb302 + i32 90, label %bb302 + i32 91, label %bb507 + i32 92, label %bb375 + i32 93, label %bb355 + i32 103, label %bb1277 + i32 104, label %bb1310 + i32 105, label %UnifiedReturnBlock + i32 106, label %bb1277 + i32 107, label %bb1343 + ] +bb153: ; preds = %entry + ret i64 0 +bb235: ; preds = %entry + br i1 false, label %bb245, label %UnifiedReturnBlock +bb245: ; preds = %bb235 + ret i64 0 +bb289: ; preds = %entry + ret i64 0 +bb302: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry + ret i64 0 +bb322: ; preds = %entry + ret i64 0 +bb355: ; preds = %entry + ret i64 0 +bb375: ; preds = %entry + ret i64 0 +bb507: ; preds = %entry + ret i64 0 +bb535: ; preds = %entry + ret i64 0 +bb565: ; preds = %entry, %entry, %entry, %entry, %entry, %entry + ret i64 0 +bb651: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry + ret i64 0 +bb951: ; preds = %entry + ret i64 0 +bb1100: ; preds = %entry, %entry, %entry, %entry + ret i64 0 +bb1277: ; preds = %entry, %entry + br i1 false, label %UnifiedReturnBlock, label %bb1284 +bb1284: ; preds = %bb1277 + ret i64 0 +bb1310: ; preds = %entry + ret i64 0 +bb1343: ; preds = %entry + ret i64 1 +bb1344: ; preds = %entry + ret i64 0 +bb1385: ; preds = %entry + ret i64 0 +UnifiedReturnBlock: ; preds = %bb1277, %bb235, %entry + %UnifiedRetVal = phi i64 [ 0, %bb235 ], [ undef, %bb1277 ], [ -1, %entry ] ; [#uses=1] + ret i64 %UnifiedRetVal +} From gohman at apple.com Thu Apr 10 13:43:06 2008 From: gohman at apple.com (Dan Gohman) Date: Thu, 10 Apr 2008 18:43:06 -0000 Subject: [llvm-commits] [llvm] r49492 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/align-2d-gep.ll test/Transforms/InstCombine/align-addr.ll Message-ID: <200804101843.m3AIh60R021223@zion.cs.uiuc.edu> Author: djg Date: Thu Apr 10 13:43:06 2008 New Revision: 49492 URL: http://llvm.org/viewvc/llvm-project?rev=49492&view=rev Log: Teach InstCombine's ComputeMaskedBits to handle pointer expressions in addition to integer expressions. Rewrite GetOrEnforceKnownAlignment as a ComputeMaskedBits problem, moving all of its special alignment knowledge to ComputeMaskedBits as low-zero-bits knowledge. Also, teach ComputeMaskedBits a few basic things about Mul and PHI instructions. This improves ComputeMaskedBits-based simplifications in a few cases, but more noticeably it significantly improves instcombine's alignment detection for loads, stores, and memory intrinsics. Added: llvm/trunk/test/Transforms/InstCombine/align-2d-gep.ll llvm/trunk/test/Transforms/InstCombine/align-addr.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=49492&r1=49491&r2=49492&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Thu Apr 10 13:43:06 2008 @@ -372,6 +372,15 @@ Value *EvaluateInDifferentType(Value *V, const Type *Ty, bool isSigned); + + void ComputeMaskedBits(Value *V, const APInt &Mask, APInt& KnownZero, + APInt& KnownOne, unsigned Depth = 0); + bool MaskedValueIsZero(Value *V, const APInt& Mask, unsigned Depth = 0); + bool CanEvaluateInDifferentType(Value *V, const IntegerType *Ty, + unsigned CastOpc, + int &NumCastsRemoved); + unsigned GetOrEnforceKnownAlignment(Value *V, + unsigned PrefAlign = 0); }; char InstCombiner::ID = 0; @@ -580,6 +589,17 @@ return false; } +/// getOpcode - If this is an Instruction or a ConstantExpr, return the +/// opcode value. Otherwise return UserOp1. +static unsigned getOpcode(User *U) { + if (Instruction *I = dyn_cast(U)) + return I->getOpcode(); + if (ConstantExpr *CE = dyn_cast(U)) + return CE->getOpcode(); + // Use UserOp1 to mean there's no opcode. + return Instruction::UserOp1; +} + /// AddOne - Add one to a ConstantInt static ConstantInt *AddOne(ConstantInt *C) { APInt Val(C->getValue()); @@ -639,12 +659,17 @@ /// optimized based on the contradictory assumption that it is non-zero. /// Because instcombine aggressively folds operations with undef args anyway, /// this won't lose us code quality. -static void ComputeMaskedBits(Value *V, const APInt &Mask, APInt& KnownZero, - APInt& KnownOne, unsigned Depth = 0) { +void InstCombiner::ComputeMaskedBits(Value *V, const APInt &Mask, + APInt& KnownZero, APInt& KnownOne, + unsigned Depth) { assert(V && "No Value?"); assert(Depth <= 6 && "Limit Search Depth"); uint32_t BitWidth = Mask.getBitWidth(); - assert(cast(V->getType())->getBitWidth() == BitWidth && + assert((V->getType()->isInteger() || isa(V->getType())) && + "Not integer or pointer type!"); + assert((!TD || TD->getTypeSizeInBits(V->getType()) == BitWidth) && + (!isa(V->getType()) || + V->getType()->getPrimitiveSizeInBits() == BitWidth) && KnownZero.getBitWidth() == BitWidth && KnownOne.getBitWidth() == BitWidth && "V, Mask, KnownOne and KnownZero should have same BitWidth"); @@ -654,17 +679,37 @@ KnownZero = ~KnownOne & Mask; return; } + // Null is all-zeros. + if (isa(V)) { + KnownOne.clear(); + KnownZero = Mask; + return; + } + // The address of an aligned GlobalValue has trailing zeros. + if (GlobalValue *GV = dyn_cast(V)) { + unsigned Align = GV->getAlignment(); + if (Align == 0 && TD && GV->getType()->getElementType()->isSized()) + Align = TD->getPrefTypeAlignment(GV->getType()->getElementType()); + if (Align > 0) + KnownZero = Mask & APInt::getLowBitsSet(BitWidth, + CountTrailingZeros_32(Align)); + else + KnownZero.clear(); + KnownOne.clear(); + return; + } if (Depth == 6 || Mask == 0) return; // Limit search depth. - Instruction *I = dyn_cast(V); + User *I = dyn_cast(V); if (!I) return; KnownZero.clear(); KnownOne.clear(); // Don't know anything. APInt KnownZero2(KnownZero), KnownOne2(KnownOne); - switch (I->getOpcode()) { + switch (getOpcode(I)) { + default: break; case Instruction::And: { // If either the LHS or the RHS are Zero, the result is zero. ComputeMaskedBits(I->getOperand(1), Mask, KnownZero, KnownOne, Depth+1); @@ -705,6 +750,24 @@ KnownZero = KnownZeroOut; return; } + case Instruction::Mul: { + APInt Mask2 = APInt::getAllOnesValue(BitWidth); + ComputeMaskedBits(I->getOperand(1), Mask2, KnownZero, KnownOne, Depth+1); + ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero2, KnownOne2, Depth+1); + assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); + assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one AND zero?"); + + // If low bits are zero in either operand, output low known-0 bits. + // More trickiness is possible, but this is sufficient for the + // interesting case of alignment computation. + KnownOne.clear(); + unsigned TrailZ = KnownZero.countTrailingOnes() + + KnownZero2.countTrailingOnes(); + TrailZ = std::min(TrailZ, BitWidth); + KnownZero = APInt::getLowBitsSet(BitWidth, TrailZ); + KnownZero &= Mask; + return; + } case Instruction::Select: ComputeMaskedBits(I->getOperand(2), Mask, KnownZero, KnownOne, Depth+1); ComputeMaskedBits(I->getOperand(1), Mask, KnownZero2, KnownOne2, Depth+1); @@ -720,48 +783,40 @@ case Instruction::FPToUI: case Instruction::FPToSI: case Instruction::SIToFP: - case Instruction::PtrToInt: case Instruction::UIToFP: + return; // Can't work with floating point. + case Instruction::PtrToInt: case Instruction::IntToPtr: - return; // Can't work with floating point or pointers + // We can't handle these if we don't know the pointer size. + if (!TD) return; + // Fall through and handle them the same as zext/trunc. + case Instruction::ZExt: case Instruction::Trunc: { // All these have integer operands - uint32_t SrcBitWidth = - cast(I->getOperand(0)->getType())->getBitWidth(); + const Type *SrcTy = I->getOperand(0)->getType(); + uint32_t SrcBitWidth = TD ? + TD->getTypeSizeInBits(SrcTy) : + SrcTy->getPrimitiveSizeInBits(); APInt MaskIn(Mask); - MaskIn.zext(SrcBitWidth); - KnownZero.zext(SrcBitWidth); - KnownOne.zext(SrcBitWidth); + MaskIn.zextOrTrunc(SrcBitWidth); + KnownZero.zextOrTrunc(SrcBitWidth); + KnownOne.zextOrTrunc(SrcBitWidth); ComputeMaskedBits(I->getOperand(0), MaskIn, KnownZero, KnownOne, Depth+1); - KnownZero.trunc(BitWidth); - KnownOne.trunc(BitWidth); + KnownZero.zextOrTrunc(BitWidth); + KnownOne.zextOrTrunc(BitWidth); + // Any top bits are known to be zero. + if (BitWidth > SrcBitWidth) + KnownZero |= APInt::getHighBitsSet(BitWidth, BitWidth - SrcBitWidth); return; } case Instruction::BitCast: { const Type *SrcTy = I->getOperand(0)->getType(); - if (SrcTy->isInteger()) { + if (SrcTy->isInteger() || isa(SrcTy)) { ComputeMaskedBits(I->getOperand(0), Mask, KnownZero, KnownOne, Depth+1); return; } break; } - case Instruction::ZExt: { - // Compute the bits in the result that are not present in the input. - const IntegerType *SrcTy = cast(I->getOperand(0)->getType()); - uint32_t SrcBitWidth = SrcTy->getBitWidth(); - - APInt MaskIn(Mask); - MaskIn.trunc(SrcBitWidth); - KnownZero.trunc(SrcBitWidth); - KnownOne.trunc(SrcBitWidth); - ComputeMaskedBits(I->getOperand(0), MaskIn, KnownZero, KnownOne, Depth+1); - assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); - // The top bits are known to be zero. - KnownZero.zext(BitWidth); - KnownOne.zext(BitWidth); - KnownZero |= APInt::getHighBitsSet(BitWidth, BitWidth - SrcBitWidth); - return; - } case Instruction::SExt: { // Compute the bits in the result that are not present in the input. const IntegerType *SrcTy = cast(I->getOperand(0)->getType()); @@ -835,6 +890,32 @@ return; } break; + case Instruction::Sub: { + if (ConstantInt *CLHS = dyn_cast(I->getOperand(0))) { + // We know that the top bits of C-X are clear if X contains less bits + // than C (i.e. no wrap-around can happen). For example, 20-X is + // positive if we can prove that X is >= 0 and < 16. + if (!CLHS->getValue().isNegative()) { + unsigned NLZ = (CLHS->getValue()+1).countLeadingZeros(); + // NLZ can't be BitWidth with no sign bit + APInt MaskV = APInt::getHighBitsSet(BitWidth, NLZ+1); + ComputeMaskedBits(I->getOperand(1), MaskV, KnownZero, KnownOne, Depth+1); + + // If all of the MaskV bits are known to be zero, then we know the output + // top bits are zero, because we now know that the output is from [0-C]. + if ((KnownZero & MaskV) == MaskV) { + unsigned NLZ2 = CLHS->getValue().countLeadingZeros(); + // Top bits known zero. + KnownZero = APInt::getHighBitsSet(BitWidth, NLZ2) & Mask; + KnownOne = APInt(BitWidth, 0); // No one bits known. + } else { + KnownZero = KnownOne = APInt(BitWidth, 0); // Otherwise, nothing known. + } + return; + } + } + } + // fall through case Instruction::Add: { // If either the LHS or the RHS are Zero, the result is zero. ComputeMaskedBits(I->getOperand(1), Mask, KnownZero, KnownOne, Depth+1); @@ -852,33 +933,6 @@ KnownOne = APInt(BitWidth, 0); return; } - case Instruction::Sub: { - ConstantInt *CLHS = dyn_cast(I->getOperand(0)); - if (!CLHS) break; - - // We know that the top bits of C-X are clear if X contains less bits - // than C (i.e. no wrap-around can happen). For example, 20-X is - // positive if we can prove that X is >= 0 and < 16. - if (CLHS->getValue().isNegative()) - break; - - unsigned NLZ = (CLHS->getValue()+1).countLeadingZeros(); - // NLZ can't be BitWidth with no sign bit - APInt MaskV = APInt::getHighBitsSet(BitWidth, NLZ+1); - ComputeMaskedBits(I->getOperand(1), MaskV, KnownZero, KnownOne, Depth+1); - - // If all of the MaskV bits are known to be zero, then we know the output - // top bits are zero, because we now know that the output is from [0-C]. - if ((KnownZero & MaskV) == MaskV) { - unsigned NLZ2 = CLHS->getValue().countLeadingZeros(); - // Top bits known zero. - KnownZero = APInt::getHighBitsSet(BitWidth, NLZ2) & Mask; - KnownOne = APInt(BitWidth, 0); // No one bits known. - } else { - KnownZero = KnownOne = APInt(BitWidth, 0); // Otherwise, nothing known. - } - return; - } case Instruction::SRem: if (ConstantInt *Rem = dyn_cast(I->getOperand(1))) { APInt RA = Rem->getValue(); @@ -923,13 +977,124 @@ assert((KnownZero & KnownOne) == 0&&"Bits known to be one AND zero?"); } break; + + case Instruction::Alloca: + case Instruction::Malloc: { + AllocationInst *AI = cast(V); + unsigned Align = AI->getAlignment(); + if (Align == 0 && TD) { + if (isa(AI)) + Align = TD->getPrefTypeAlignment(AI->getType()->getElementType()); + else if (isa(AI)) { + // Malloc returns maximally aligned memory. + Align = TD->getABITypeAlignment(AI->getType()->getElementType()); + Align = + std::max(Align, + (unsigned)TD->getABITypeAlignment(Type::DoubleTy)); + Align = + std::max(Align, + (unsigned)TD->getABITypeAlignment(Type::Int64Ty)); + } + } + + if (Align > 0) + KnownZero = Mask & APInt::getLowBitsSet(BitWidth, + CountTrailingZeros_32(Align)); + break; + } + case Instruction::GetElementPtr: { + // Analyze all of the subscripts of this getelementptr instruction + // to determine if we can prove known low zero bits. + APInt LocalMask = APInt::getAllOnesValue(BitWidth); + APInt LocalKnownZero(BitWidth, 0), LocalKnownOne(BitWidth, 0); + ComputeMaskedBits(I->getOperand(0), LocalMask, + LocalKnownZero, LocalKnownOne, Depth+1); + unsigned TrailZ = LocalKnownZero.countTrailingOnes(); + + gep_type_iterator GTI = gep_type_begin(I); + for (unsigned i = 1, e = I->getNumOperands(); i != e; ++i, ++GTI) { + Value *Index = I->getOperand(i); + if (const StructType *STy = dyn_cast(*GTI)) { + // Handle struct member offset arithmetic. + if (!TD) return; + const StructLayout *SL = TD->getStructLayout(STy); + unsigned Idx = cast(Index)->getZExtValue(); + uint64_t Offset = SL->getElementOffset(Idx); + TrailZ = std::min(TrailZ, + CountTrailingZeros_64(Offset)); + } else { + // Handle array index arithmetic. + const Type *IndexedTy = GTI.getIndexedType(); + if (!IndexedTy->isSized()) return; + unsigned GEPOpiBits = Index->getType()->getPrimitiveSizeInBits(); + uint64_t TypeSize = TD ? TD->getABITypeSize(IndexedTy) : 1; + LocalMask = APInt::getAllOnesValue(GEPOpiBits); + LocalKnownZero = LocalKnownOne = APInt(GEPOpiBits, 0); + ComputeMaskedBits(Index, LocalMask, + LocalKnownZero, LocalKnownOne, Depth+1); + TrailZ = std::min(TrailZ, + CountTrailingZeros_64(TypeSize) + + LocalKnownZero.countTrailingOnes()); + } + } + + KnownZero = APInt::getLowBitsSet(BitWidth, TrailZ) & Mask; + break; + } + case Instruction::PHI: { + PHINode *P = cast(I); + // Handle the case of a simple two-predecessor recurrence PHI. + // There's a lot more that could theoretically be done here, but + // this is sufficient to catch some interesting cases. + if (P->getNumIncomingValues() == 2) { + for (unsigned i = 0; i != 2; ++i) { + Value *L = P->getIncomingValue(i); + Value *R = P->getIncomingValue(!i); + User *LU = dyn_cast(L); + unsigned Opcode = LU ? getOpcode(LU) : (unsigned)Instruction::UserOp1; + // Check for operations that have the property that if + // both their operands have low zero bits, the result + // will have low zero bits. + if (Opcode == Instruction::Add || + Opcode == Instruction::Sub || + Opcode == Instruction::And || + Opcode == Instruction::Or || + Opcode == Instruction::Mul) { + Value *LL = LU->getOperand(0); + Value *LR = LU->getOperand(1); + // Find a recurrence. + if (LL == I) + L = LR; + else if (LR == I) + L = LL; + else + break; + // Ok, we have a PHI of the form L op= R. Check for low + // zero bits. + APInt Mask2 = APInt::getAllOnesValue(BitWidth); + ComputeMaskedBits(R, Mask2, KnownZero2, KnownOne2, Depth+1); + Mask2 = APInt::getLowBitsSet(BitWidth, + KnownZero2.countTrailingOnes()); + KnownOne2.clear(); + KnownZero2.clear(); + ComputeMaskedBits(L, Mask2, KnownZero2, KnownOne2, Depth+1); + KnownZero = Mask & + APInt::getLowBitsSet(BitWidth, + KnownZero2.countTrailingOnes()); + break; + } + } + } + break; + } } } /// MaskedValueIsZero - Return true if 'V & Mask' is known to be zero. We use /// this predicate to simplify operations downstream. Mask is known to be zero /// for bits that V cannot have. -static bool MaskedValueIsZero(Value *V, const APInt& Mask, unsigned Depth = 0) { +bool InstCombiner::MaskedValueIsZero(Value *V, const APInt& Mask, + unsigned Depth) { APInt KnownZero(Mask.getBitWidth(), 0), KnownOne(Mask.getBitWidth(), 0); ComputeMaskedBits(V, Mask, KnownZero, KnownOne, Depth); assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); @@ -6695,8 +6860,9 @@ /// /// This is a truncation operation if Ty is smaller than V->getType(), or an /// extension operation if Ty is larger. -static bool CanEvaluateInDifferentType(Value *V, const IntegerType *Ty, - unsigned CastOpc, int &NumCastsRemoved) { +bool InstCombiner::CanEvaluateInDifferentType(Value *V, const IntegerType *Ty, + unsigned CastOpc, + int &NumCastsRemoved) { // We can always evaluate constants in another type. if (isa(V)) return true; @@ -8062,94 +8228,83 @@ return 0; } -/// GetOrEnforceKnownAlignment - If the specified pointer has an alignment that -/// we can determine, return it, otherwise return 0. If PrefAlign is specified, -/// and it is more than the alignment of the ultimate object, see if we can -/// increase the alignment of the ultimate object, making this check succeed. -static unsigned GetOrEnforceKnownAlignment(Value *V, TargetData *TD, - unsigned PrefAlign = 0) { - if (GlobalVariable *GV = dyn_cast(V)) { - unsigned Align = GV->getAlignment(); - if (Align == 0 && TD && GV->getType()->getElementType()->isSized()) - Align = TD->getPrefTypeAlignment(GV->getType()->getElementType()); +/// EnforceKnownAlignment - If the specified pointer points to an object that +/// we control, modify the object's alignment to PrefAlign. This isn't +/// often possible though. If alignment is important, a more reliable approach +/// is to simply align all global variables and allocation instructions to +/// their preferred alignment from the beginning. +/// +static unsigned EnforceKnownAlignment(Value *V, + unsigned Align, unsigned PrefAlign) { + + User *U = dyn_cast(V); + if (!U) return Align; + + switch (getOpcode(U)) { + default: break; + case Instruction::BitCast: + return EnforceKnownAlignment(U->getOperand(0), Align, PrefAlign); + case Instruction::GetElementPtr: { + // If all indexes are zero, it is just the alignment of the base pointer. + bool AllZeroOperands = true; + for (unsigned i = 1, e = U->getNumOperands(); i != e; ++i) + if (!isa(U->getOperand(i)) || + !cast(U->getOperand(i))->isNullValue()) { + AllZeroOperands = false; + break; + } + + if (AllZeroOperands) { + // Treat this like a bitcast. + return EnforceKnownAlignment(U->getOperand(0), Align, PrefAlign); + } + break; + } + } + if (GlobalValue *GV = dyn_cast(V)) { // If there is a large requested alignment and we can, bump up the alignment // of the global. - if (PrefAlign > Align && GV->hasInitializer()) { + if (!GV->isDeclaration()) { GV->setAlignment(PrefAlign); Align = PrefAlign; } - return Align; } else if (AllocationInst *AI = dyn_cast(V)) { - unsigned Align = AI->getAlignment(); - if (Align == 0 && TD) { - if (isa(AI)) - Align = TD->getPrefTypeAlignment(AI->getType()->getElementType()); - else if (isa(AI)) { - // Malloc returns maximally aligned memory. - Align = TD->getABITypeAlignment(AI->getType()->getElementType()); - Align = - std::max(Align, - (unsigned)TD->getABITypeAlignment(Type::DoubleTy)); - Align = - std::max(Align, - (unsigned)TD->getABITypeAlignment(Type::Int64Ty)); - } - } - // If there is a requested alignment and if this is an alloca, round up. We // don't do this for malloc, because some systems can't respect the request. - if (PrefAlign > Align && isa(AI)) { + if (isa(AI)) { AI->setAlignment(PrefAlign); Align = PrefAlign; } - return Align; - } else if (isa(V) || - (isa(V) && - cast(V)->getOpcode() == Instruction::BitCast)) { - return GetOrEnforceKnownAlignment(cast(V)->getOperand(0), - TD, PrefAlign); - } else if (User *GEPI = dyn_castGetElementPtr(V)) { - // If all indexes are zero, it is just the alignment of the base pointer. - bool AllZeroOperands = true; - for (unsigned i = 1, e = GEPI->getNumOperands(); i != e; ++i) - if (!isa(GEPI->getOperand(i)) || - !cast(GEPI->getOperand(i))->isNullValue()) { - AllZeroOperands = false; - break; - } + } - if (AllZeroOperands) { - // Treat this like a bitcast. - return GetOrEnforceKnownAlignment(GEPI->getOperand(0), TD, PrefAlign); - } + return Align; +} - unsigned BaseAlignment = GetOrEnforceKnownAlignment(GEPI->getOperand(0),TD); - if (BaseAlignment == 0) return 0; +/// GetOrEnforceKnownAlignment - If the specified pointer has an alignment that +/// we can determine, return it, otherwise return 0. If PrefAlign is specified, +/// and it is more than the alignment of the ultimate object, see if we can +/// increase the alignment of the ultimate object, making this check succeed. +unsigned InstCombiner::GetOrEnforceKnownAlignment(Value *V, + unsigned PrefAlign) { + unsigned BitWidth = TD ? TD->getTypeSizeInBits(V->getType()) : + sizeof(PrefAlign) * CHAR_BIT; + APInt Mask = APInt::getAllOnesValue(BitWidth); + APInt KnownZero(BitWidth, 0), KnownOne(BitWidth, 0); + ComputeMaskedBits(V, Mask, KnownZero, KnownOne); + unsigned TrailZ = KnownZero.countTrailingOnes(); + unsigned Align = 1u << std::min(BitWidth - 1, TrailZ); - // Otherwise, if the base alignment is >= the alignment we expect for the - // base pointer type, then we know that the resultant pointer is aligned at - // least as much as its type requires. - if (!TD) return 0; - - const Type *BasePtrTy = GEPI->getOperand(0)->getType(); - const PointerType *PtrTy = cast(BasePtrTy); - unsigned Align = TD->getABITypeAlignment(PtrTy->getElementType()); - if (Align <= BaseAlignment) { - const Type *GEPTy = GEPI->getType(); - const PointerType *GEPPtrTy = cast(GEPTy); - Align = std::min(Align, (unsigned) - TD->getABITypeAlignment(GEPPtrTy->getElementType())); - return Align; - } - return 0; - } - return 0; + if (PrefAlign > Align) + Align = EnforceKnownAlignment(V, Align, PrefAlign); + + // We don't need to make any adjustment. + return Align; } Instruction *InstCombiner::SimplifyMemTransfer(MemIntrinsic *MI) { - unsigned DstAlign = GetOrEnforceKnownAlignment(MI->getOperand(1), TD); - unsigned SrcAlign = GetOrEnforceKnownAlignment(MI->getOperand(2), TD); + unsigned DstAlign = GetOrEnforceKnownAlignment(MI->getOperand(1)); + unsigned SrcAlign = GetOrEnforceKnownAlignment(MI->getOperand(2)); unsigned MinAlign = std::min(DstAlign, SrcAlign); unsigned CopyAlign = MI->getAlignment()->getZExtValue(); @@ -8270,7 +8425,7 @@ if (Instruction *I = SimplifyMemTransfer(MI)) return I; } else if (isa(MI)) { - unsigned Alignment = GetOrEnforceKnownAlignment(MI->getDest(), TD); + unsigned Alignment = GetOrEnforceKnownAlignment(MI->getDest()); if (MI->getAlignment()->getZExtValue() < Alignment) { MI->setAlignment(ConstantInt::get(Type::Int32Ty, Alignment)); Changed = true; @@ -8288,7 +8443,7 @@ case Intrinsic::x86_sse2_loadu_dq: // Turn PPC lvx -> load if the pointer is known aligned. // Turn X86 loadups -> load if the pointer is known aligned. - if (GetOrEnforceKnownAlignment(II->getOperand(1), TD, 16) >= 16) { + if (GetOrEnforceKnownAlignment(II->getOperand(1), 16) >= 16) { Value *Ptr = InsertBitCastBefore(II->getOperand(1), PointerType::getUnqual(II->getType()), CI); @@ -8298,7 +8453,7 @@ case Intrinsic::ppc_altivec_stvx: case Intrinsic::ppc_altivec_stvxl: // Turn stvx -> store if the pointer is known aligned. - if (GetOrEnforceKnownAlignment(II->getOperand(2), TD, 16) >= 16) { + if (GetOrEnforceKnownAlignment(II->getOperand(2), 16) >= 16) { const Type *OpPtrTy = PointerType::getUnqual(II->getOperand(1)->getType()); Value *Ptr = InsertBitCastBefore(II->getOperand(2), OpPtrTy, CI); @@ -8310,7 +8465,7 @@ case Intrinsic::x86_sse2_storeu_dq: case Intrinsic::x86_sse2_storel_dq: // Turn X86 storeu -> store if the pointer is known aligned. - if (GetOrEnforceKnownAlignment(II->getOperand(1), TD, 16) >= 16) { + if (GetOrEnforceKnownAlignment(II->getOperand(1), 16) >= 16) { const Type *OpPtrTy = PointerType::getUnqual(II->getOperand(2)->getType()); Value *Ptr = InsertBitCastBefore(II->getOperand(1), OpPtrTy, CI); @@ -9762,8 +9917,10 @@ Value *Op = LI.getOperand(0); // Attempt to improve the alignment. - unsigned KnownAlign = GetOrEnforceKnownAlignment(Op, TD); - if (KnownAlign > LI.getAlignment()) + unsigned KnownAlign = GetOrEnforceKnownAlignment(Op); + if (KnownAlign > + (LI.getAlignment() == 0 ? TD->getABITypeAlignment(LI.getType()) : + LI.getAlignment())) LI.setAlignment(KnownAlign); // load (cast X) --> cast (load X) iff safe @@ -9980,8 +10137,10 @@ } // Attempt to improve the alignment. - unsigned KnownAlign = GetOrEnforceKnownAlignment(Ptr, TD); - if (KnownAlign > SI.getAlignment()) + unsigned KnownAlign = GetOrEnforceKnownAlignment(Ptr); + if (KnownAlign > + (SI.getAlignment() == 0 ? TD->getABITypeAlignment(Val->getType()) : + SI.getAlignment())) SI.setAlignment(KnownAlign); // Do really simple DSE, to catch cases where there are several consequtive Added: llvm/trunk/test/Transforms/InstCombine/align-2d-gep.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/align-2d-gep.ll?rev=49492&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/align-2d-gep.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/align-2d-gep.ll Thu Apr 10 13:43:06 2008 @@ -0,0 +1,43 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {align 16} | count 1 + +; A multi-dimensional array in a nested loop doing vector stores that +; aren't yet aligned. Instcombine can understand the addressing in the +; Nice case to prove 16 byte alignment. In the Awkward case, the inner +; array dimension is not even, so the stores to it won't always be +; aligned. Instcombine should prove alignment in exactly one of the two +; stores. + + at Nice = global [1001 x [20000 x double]] zeroinitializer, align 32 + at Awkward = global [1001 x [20001 x double]] zeroinitializer, align 32 + +define void @foo() nounwind { +entry: + br label %bb7.outer + +bb7.outer: + %i = phi i64 [ 0, %entry ], [ %indvar.next26, %bb11 ] + br label %bb1 + +bb1: + %j = phi i64 [ 0, %bb7.outer ], [ %indvar.next, %bb1 ] + + %t4 = getelementptr [1001 x [20000 x double]]* @Nice, i64 0, i64 %i, i64 %j + %q = bitcast double* %t4 to <2 x double>* + store <2 x double>, <2 x double>* %q, align 8 + + %s4 = getelementptr [1001 x [20001 x double]]* @Awkward, i64 0, i64 %i, i64 %j + %r = bitcast double* %s4 to <2 x double>* + store <2 x double>, <2 x double>* %r, align 8 + + %indvar.next = add i64 %j, 2 + %exitcond = icmp eq i64 %indvar.next, 557 + br i1 %exitcond, label %bb11, label %bb1 + +bb11: + %indvar.next26 = add i64 %i, 1 + %exitcond27 = icmp eq i64 %indvar.next26, 991 + br i1 %exitcond27, label %return.split, label %bb7.outer + +return.split: + ret void +} Added: llvm/trunk/test/Transforms/InstCombine/align-addr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/align-addr.ll?rev=49492&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/align-addr.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/align-addr.ll Thu Apr 10 13:43:06 2008 @@ -0,0 +1,30 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {align 16} | count 1 + +; Instcombine should be able to prove vector alignment in the +; presence of a few mild address computation tricks. + +define void @foo(i8* %b, i64 %n, i64 %u, i64 %y) nounwind { +entry: + %c = ptrtoint i8* %b to i64 + %d = and i64 %c, -16 + %e = inttoptr i64 %d to double* + %v = mul i64 %u, 2 + %z = and i64 %y, -2 + %t1421 = icmp eq i64 %n, 0 + br i1 %t1421, label %return, label %bb + +bb: + %i = phi i64 [ %indvar.next, %bb ], [ 20, %entry ] + %j = mul i64 %i, %v + %h = add i64 %j, %z + %t8 = getelementptr double* %e, i64 %h + %p = bitcast double* %t8 to <2 x double>* + store <2 x double>, <2 x double>* %p, align 8 + %indvar.next = add i64 %i, 1 + %exitcond = icmp eq i64 %indvar.next, %n + br i1 %exitcond, label %return, label %bb + +return: + ret void +} + From foldr at codedgers.com Thu Apr 10 13:41:01 2008 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Thu, 10 Apr 2008 14:41:01 -0400 (EDT) Subject: [llvm-commits] [PATCH] Fix a potential segfault in IntrusiveRefCntPtr.h Message-ID: <45025.81.172.134.32.1207852861.squirrel@webmail.sophsolutions.com> This fixes a potential segfault in IntrusiveRefCntPtr. This class had no non-template assignment operator, so the default implementation was silently generated and used. Also fixes conversion to unspecified-bool-type and replace() method. -------------- next part -------------- A non-text attachment was scrubbed... Name: intrusive_ptr.patch Type: text/x-patch Size: 1034 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080410/a422d7d4/attachment.bin From dalej at apple.com Thu Apr 10 14:55:30 2008 From: dalej at apple.com (Dale Johannesen) Date: Thu, 10 Apr 2008 19:55:30 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49493 - /llvm-gcc-4.2/trunk/gcc/config/darwin.c Message-ID: <200804101955.m3AJtVoZ023199@zion.cs.uiuc.edu> Author: johannes Date: Thu Apr 10 14:55:30 2008 New Revision: 49493 URL: http://llvm.org/viewvc/llvm-project?rev=49493&view=rev Log: OBJC_CLASS_PROTOCOLS symbols go in cat_cls_meth section. Modified: llvm-gcc-4.2/trunk/gcc/config/darwin.c Modified: llvm-gcc-4.2/trunk/gcc/config/darwin.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/darwin.c?rev=49493&r1=49492&r2=49493&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/darwin.c (original) +++ llvm-gcc-4.2/trunk/gcc/config/darwin.c Thu Apr 10 14:55:30 2008 @@ -1563,7 +1563,7 @@ else if (!strncmp (name, "INSTANCE_VARIABLES_", 19)) return "__OBJC,__instance_vars,regular,no_dead_strip"; else if (!strncmp (name, "CLASS_PROTOCOLS_", 16)) - return "__OBJC,__cls_meth,regular,no_dead_strip"; + return "__OBJC,__cat_cls_meth,regular,no_dead_strip"; else if (!strncmp (name, "CLASS_NAME_", 11)) return "__TEXT,__cstring,cstring_literals"; else if (!strncmp (name, "METH_VAR_NAME_", 14)) From ggreif at gmail.com Thu Apr 10 15:31:54 2008 From: ggreif at gmail.com (Gabor Greif) Date: Thu, 10 Apr 2008 20:31:54 -0000 Subject: [llvm-commits] [llvm] r49494 - /llvm/branches/ggreif/use-diet/lib/AsmParser/llvmAsmParser.y Message-ID: <200804102031.m3AKVsuI024324@zion.cs.uiuc.edu> Author: ggreif Date: Thu Apr 10 15:31:52 2008 New Revision: 49494 URL: http://llvm.org/viewvc/llvm-project?rev=49494&view=rev Log: forgot to create-ify this Modified: llvm/branches/ggreif/use-diet/lib/AsmParser/llvmAsmParser.y Modified: llvm/branches/ggreif/use-diet/lib/AsmParser/llvmAsmParser.y URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/AsmParser/llvmAsmParser.y?rev=49494&r1=49493&r2=49494&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/AsmParser/llvmAsmParser.y (original) +++ llvm/branches/ggreif/use-diet/lib/AsmParser/llvmAsmParser.y Thu Apr 10 15:31:52 2008 @@ -495,8 +495,8 @@ if (const FunctionType *FTy = dyn_cast(ElTy)) V = Function::Create(FTy, GlobalValue::ExternalLinkage); else - V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage, 0, "", - (Module*)0, false, PTy->getAddressSpace()); + V = GlobalVariable::Create(ElTy, false, GlobalValue::ExternalLinkage, 0, "", + (Module*)0, false, PTy->getAddressSpace()); break; } default: @@ -784,8 +784,8 @@ // Otherwise there is no existing GV to use, create one now. GlobalVariable *GV = - new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, - CurModule.CurrentModule, IsThreadLocal, AddressSpace); + GlobalVariable::Create(Ty, isConstantGlobal, Linkage, Initializer, Name, + CurModule.CurrentModule, IsThreadLocal, AddressSpace); GV->setVisibility(Visibility); InsertValue(GV, CurModule.Values); return GV; @@ -1782,9 +1782,9 @@ GV = Function::Create(FTy, GlobalValue::ExternalWeakLinkage, Name, CurModule.CurrentModule); } else { - GV = new GlobalVariable(PT->getElementType(), false, - GlobalValue::ExternalWeakLinkage, 0, - Name, CurModule.CurrentModule); + GV = GlobalVariable::Create(PT->getElementType(), false, + GlobalValue::ExternalWeakLinkage, 0, + Name, CurModule.CurrentModule); } // Keep track of the fact that we have a forward ref to recycle it From ggreif at gmail.com Thu Apr 10 15:38:24 2008 From: ggreif at gmail.com (Gabor Greif) Date: Thu, 10 Apr 2008 20:38:24 -0000 Subject: [llvm-commits] [llvm] r49495 - in /llvm/branches/ggreif/use-diet/include/llvm: InstrTypes.h Instructions.h OperandTraits.h Message-ID: <200804102038.m3AKcOPJ024515@zion.cs.uiuc.edu> Author: ggreif Date: Thu Apr 10 15:38:24 2008 New Revision: 49495 URL: http://llvm.org/viewvc/llvm-project?rev=49495&view=rev Log: moved FixedNumOperands to OperandTraits.h Modified: llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h llvm/branches/ggreif/use-diet/include/llvm/Instructions.h llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h Modified: llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h?rev=49495&r1=49494&r2=49495&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h Thu Apr 10 15:38:24 2008 @@ -17,6 +17,7 @@ #define LLVM_INSTRUCTION_TYPES_H #include "llvm/Instruction.h" +#include "llvm/OperandTraits.h" namespace llvm { @@ -78,60 +79,6 @@ } }; -//===----------------------------------------------------------------------===// -// FixedNumOperands Trait Class -//===----------------------------------------------------------------------===// - -template -struct FixedNumOperandTraits { - static Use *op_begin(User* U) { - return reinterpret_cast(U) - ARITY; - } - static Use *op_end(User* U) { - return reinterpret_cast(U); - } - static unsigned operands(const User*) { - return ARITY; - } - struct prefix { - Use Ops[ARITY]; - prefix(); // DO NOT IMPLEMENT - }; - template - struct Layout { - struct overlay : prefix, U { - overlay(); // DO NOT IMPLEMENT - }; - }; - static inline void *allocate(unsigned); // FIXME -}; - -/// Macro for generating in-class operand accessor declarations -#define DECLARE_TRANSPARENT_OPERAND_ACCESSORS(VALUECLASS) \ - inline VALUECLASS *getOperand(unsigned) const; \ - inline void setOperand(unsigned, VALUECLASS*); \ - inline unsigned getNumOperands() const; \ - template inline Use &Op(); \ - template inline const Use &Op() const - -/// Macro for generating out-of-class operand accessor definitions -#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS) \ -VALUECLASS *CLASS::getOperand(unsigned i) const { \ - assert(i < OperandTraits::operands(this) && "getOperand() out of range!"); \ - return OperandTraits::op_begin(const_cast(this))[i]; \ -} \ -void CLASS::setOperand(unsigned i, VALUECLASS *Val) { \ - assert(i < OperandTraits::operands(this) && "setOperand() out of range!"); \ - OperandTraits::op_begin(this)[i] = Val; \ -} \ -unsigned CLASS::getNumOperands() const { return OperandTraits::operands(this); } \ -template Use &CLASS::Op() { \ - return OperandTraits::op_begin(this)[Idx]; \ -} \ -template const Use &CLASS::Op() const { \ - return OperandTraits::op_begin(const_cast(this))[Idx]; \ -} - //===----------------------------------------------------------------------===// // UnaryInstruction Class Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=49495&r1=49494&r2=49495&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Thu Apr 10 15:38:24 2008 @@ -21,7 +21,6 @@ #include "llvm/InstrTypes.h" #include "llvm/DerivedTypes.h" #include "llvm/ParameterAttributes.h" -#include "llvm/OperandTraits.h" namespace llvm { Modified: llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h?rev=49495&r1=49494&r2=49495&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h Thu Apr 10 15:38:24 2008 @@ -18,6 +18,34 @@ namespace llvm { //===----------------------------------------------------------------------===// +// FixedNumOperands Trait Class +//===----------------------------------------------------------------------===// + +template +struct FixedNumOperandTraits { + static Use *op_begin(User* U) { + return reinterpret_cast(U) - ARITY; + } + static Use *op_end(User* U) { + return reinterpret_cast(U); + } + static unsigned operands(const User*) { + return ARITY; + } + struct prefix { + Use Ops[ARITY]; + prefix(); // DO NOT IMPLEMENT + }; + template + struct Layout { + struct overlay : prefix, U { + overlay(); // DO NOT IMPLEMENT + }; + }; + static inline void *allocate(unsigned); // FIXME +}; + +//===----------------------------------------------------------------------===// // VariadicOperand Trait Class //===----------------------------------------------------------------------===// From gohman at apple.com Thu Apr 10 16:11:47 2008 From: gohman at apple.com (Dan Gohman) Date: Thu, 10 Apr 2008 21:11:47 -0000 Subject: [llvm-commits] [llvm] r49496 - in /llvm/trunk/lib: Support/APFloat.cpp Support/APInt.cpp System/Unix/Signals.inc VMCore/LeakDetector.cpp Message-ID: <200804102111.m3ALBlNH025415@zion.cs.uiuc.edu> Author: djg Date: Thu Apr 10 16:11:47 2008 New Revision: 49496 URL: http://llvm.org/viewvc/llvm-project?rev=49496&view=rev Log: Make several symbols static. Modified: llvm/trunk/lib/Support/APFloat.cpp llvm/trunk/lib/Support/APInt.cpp llvm/trunk/lib/System/Unix/Signals.inc llvm/trunk/lib/VMCore/LeakDetector.cpp Modified: llvm/trunk/lib/Support/APFloat.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=49496&r1=49495&r2=49496&view=diff ============================================================================== --- llvm/trunk/lib/Support/APFloat.cpp (original) +++ llvm/trunk/lib/Support/APFloat.cpp Thu Apr 10 16:11:47 2008 @@ -78,20 +78,20 @@ /* Put a bunch of private, handy routines in an anonymous namespace. */ namespace { - inline unsigned int + static inline unsigned int partCountForBits(unsigned int bits) { return ((bits) + integerPartWidth - 1) / integerPartWidth; } /* Returns 0U-9U. Return values >= 10U are not digits. */ - inline unsigned int + static inline unsigned int decDigitValue(unsigned int c) { return c - '0'; } - unsigned int + static unsigned int hexDigitValue(unsigned int c) { unsigned int r; @@ -111,7 +111,7 @@ return -1U; } - inline void + static inline void assertArithmeticOK(const llvm::fltSemantics &semantics) { assert(semantics.arithmeticOK && "Compile-time arithmetic does not support these semantics"); @@ -122,7 +122,7 @@ If the exponent overflows, returns a large exponent with the appropriate sign. */ - int + static int readExponent(const char *p) { bool isNegative; @@ -160,7 +160,7 @@ /* This is ugly and needs cleaning up, but I don't immediately see how whilst remaining safe. */ - int + static int totalExponent(const char *p, int exponentAdjustment) { integerPart unsignedExponent; @@ -206,7 +206,7 @@ return exponent; } - const char * + static const char * skipLeadingZeroesAndAnyDot(const char *p, const char **dot) { *dot = 0; @@ -242,7 +242,7 @@ int normalizedExponent; }; - void + static void interpretDecimal(const char *p, decimalInfo *D) { const char *dot; @@ -291,7 +291,7 @@ /* Return the trailing fraction of a hexadecimal number. DIGITVALUE is the first hex digit of the fraction, P points to the next digit. */ - lostFraction + static lostFraction trailingHexadecimalFraction(const char *p, unsigned int digitValue) { unsigned int hexDigit; @@ -319,7 +319,7 @@ /* Return the fraction lost were a bignum truncated losing the least significant BITS bits. */ - lostFraction + static lostFraction lostFractionThroughTruncation(const integerPart *parts, unsigned int partCount, unsigned int bits) @@ -341,7 +341,7 @@ } /* Shift DST right BITS bits noting lost fraction. */ - lostFraction + static lostFraction shiftRight(integerPart *dst, unsigned int parts, unsigned int bits) { lostFraction lost_fraction; @@ -354,7 +354,7 @@ } /* Combine the effect of two lost fractions. */ - lostFraction + static lostFraction combineLostFractions(lostFraction moreSignificant, lostFraction lessSignificant) { @@ -375,7 +375,7 @@ See "How to Read Floating Point Numbers Accurately" by William D Clinger. */ - unsigned int + static unsigned int HUerrBound(bool inexactMultiply, unsigned int HUerr1, unsigned int HUerr2) { assert(HUerr1 < 2 || HUerr2 < 2 || (HUerr1 + HUerr2 < 8)); @@ -389,7 +389,7 @@ /* The number of ulps from the boundary (zero, or half if ISNEAREST) when the least significant BITS are truncated. BITS cannot be zero. */ - integerPart + static integerPart ulpsFromBoundary(const integerPart *parts, unsigned int bits, bool isNearest) { unsigned int count, partBits; @@ -434,7 +434,7 @@ /* Place pow(5, power) in DST, and return the number of parts used. DST must be at least one part larger than size of the answer. */ - unsigned int + static unsigned int powerOf5(integerPart *dst, unsigned int power) { static integerPart firstEightPowers[] = { 1, 5, 25, 125, 625, 3125, @@ -505,7 +505,7 @@ /* Write out an integerPart in hexadecimal, starting with the most significant nibble. Write out exactly COUNT hexdigits, return COUNT. */ - unsigned int + static unsigned int partAsHex (char *dst, integerPart part, unsigned int count, const char *hexDigitChars) { @@ -523,7 +523,7 @@ } /* Write out an unsigned decimal integer. */ - char * + static char * writeUnsignedDecimal (char *dst, unsigned int n) { char buff[40], *p; @@ -541,7 +541,7 @@ } /* Write out a signed decimal integer. */ - char * + static char * writeSignedDecimal (char *dst, int value) { if (value < 0) { Modified: llvm/trunk/lib/Support/APInt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=49496&r1=49495&r2=49496&view=diff ============================================================================== --- llvm/trunk/lib/Support/APInt.cpp (original) +++ llvm/trunk/lib/Support/APInt.cpp Thu Apr 10 16:11:47 2008 @@ -2087,7 +2087,7 @@ /* Returns the integer part with the least significant BITS set. BITS cannot be zero. */ - inline integerPart + static inline integerPart lowBitMask(unsigned int bits) { assert (bits != 0 && bits <= integerPartWidth); @@ -2096,14 +2096,14 @@ } /* Returns the value of the lower half of PART. */ - inline integerPart + static inline integerPart lowHalf(integerPart part) { return part & lowBitMask(integerPartWidth / 2); } /* Returns the value of the upper half of PART. */ - inline integerPart + static inline integerPart highHalf(integerPart part) { return part >> (integerPartWidth / 2); @@ -2111,7 +2111,7 @@ /* Returns the bit number of the most significant set bit of a part. If the input number has no bits set -1U is returned. */ - unsigned int + static unsigned int partMSB(integerPart value) { unsigned int n, msb; @@ -2136,7 +2136,7 @@ /* Returns the bit number of the least significant set bit of a part. If the input number has no bits set -1U is returned. */ - unsigned int + static unsigned int partLSB(integerPart value) { unsigned int n, lsb; Modified: llvm/trunk/lib/System/Unix/Signals.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Signals.inc?rev=49496&r1=49495&r2=49496&view=diff ============================================================================== --- llvm/trunk/lib/System/Unix/Signals.inc (original) +++ llvm/trunk/lib/System/Unix/Signals.inc Thu Apr 10 16:11:47 2008 @@ -29,32 +29,32 @@ namespace { -bool StackTraceRequested = false; +static bool StackTraceRequested = false; /// InterruptFunction - The function to call if ctrl-c is pressed. -void (*InterruptFunction)() = 0; +static void (*InterruptFunction)() = 0; -std::vector *FilesToRemove = 0 ; -std::vector *DirectoriesToRemove = 0; +static std::vector *FilesToRemove = 0 ; +static std::vector *DirectoriesToRemove = 0; // IntSigs - Signals that may interrupt the program at any time. -const int IntSigs[] = { +static const int IntSigs[] = { SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGTERM, SIGUSR1, SIGUSR2 }; -const int *IntSigsEnd = IntSigs + sizeof(IntSigs) / sizeof(IntSigs[0]); +static const int *IntSigsEnd = IntSigs + sizeof(IntSigs) / sizeof(IntSigs[0]); // KillSigs - Signals that are synchronous with the program that will cause it // to die. -const int KillSigs[] = { +static const int KillSigs[] = { SIGILL, SIGTRAP, SIGABRT, SIGFPE, SIGBUS, SIGSEGV, SIGSYS, SIGXCPU, SIGXFSZ #ifdef SIGEMT , SIGEMT #endif }; -const int *KillSigsEnd = KillSigs + sizeof(KillSigs) / sizeof(KillSigs[0]); +static const int *KillSigsEnd = KillSigs + sizeof(KillSigs) / sizeof(KillSigs[0]); #ifdef HAVE_BACKTRACE -void* StackTrace[256]; +static void* StackTrace[256]; #endif // PrintStackTrace - In the case of a program crash or fault, print out a stack @@ -62,7 +62,7 @@ // // On glibc systems we have the 'backtrace' function, which works nicely, but // doesn't demangle symbols. -void PrintStackTrace() { +static void PrintStackTrace() { #ifdef HAVE_BACKTRACE // Use backtrace() to output a backtrace on Linux systems with glibc. int depth = backtrace(StackTrace, array_lengthof(StackTrace)); @@ -71,7 +71,7 @@ } // SignalHandler - The signal handler that runs... -RETSIGTYPE SignalHandler(int Sig) { +static RETSIGTYPE SignalHandler(int Sig) { if (FilesToRemove != 0) while (!FilesToRemove->empty()) { FilesToRemove->back().eraseFromDisk(true); @@ -103,7 +103,7 @@ } // Just call signal -void RegisterHandler(int Signal) { +static void RegisterHandler(int Signal) { signal(Signal, SignalHandler); } Modified: llvm/trunk/lib/VMCore/LeakDetector.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LeakDetector.cpp?rev=49496&r1=49495&r2=49496&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/LeakDetector.cpp (original) +++ llvm/trunk/lib/VMCore/LeakDetector.cpp Thu Apr 10 16:11:47 2008 @@ -79,22 +79,22 @@ const char* const Name; }; - LeakDetectorImpl *Objects; - LeakDetectorImpl *LLVMObjects; + static LeakDetectorImpl *Objects; + static LeakDetectorImpl *LLVMObjects; - LeakDetectorImpl &getObjects() { + static LeakDetectorImpl &getObjects() { if (Objects == 0) Objects = new LeakDetectorImpl("GENERIC"); return *Objects; } - LeakDetectorImpl &getLLVMObjects() { + static LeakDetectorImpl &getLLVMObjects() { if (LLVMObjects == 0) LLVMObjects = new LeakDetectorImpl("LLVM"); return *LLVMObjects; } - void clearGarbage() { + static void clearGarbage() { delete Objects; delete LLVMObjects; Objects = 0; From ggreif at gmail.com Thu Apr 10 16:27:40 2008 From: ggreif at gmail.com (Gabor Greif) Date: Thu, 10 Apr 2008 21:27:40 -0000 Subject: [llvm-commits] [llvm] r49497 - in /llvm/branches/ggreif/use-diet: include/llvm/User.h lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Reader/BitcodeReader.h Message-ID: <200804102127.m3ALReHx025821@zion.cs.uiuc.edu> Author: ggreif Date: Thu Apr 10 16:27:40 2008 New Revision: 49497 URL: http://llvm.org/viewvc/llvm-project?rev=49497&view=rev Log: first attempt at repairing BitcodeReaderValueList Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49497&r1=49496&r2=49497&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/User.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/User.h Thu Apr 10 16:27:40 2008 @@ -252,6 +252,7 @@ return OperandTraits::op_begin(const_cast(this))[Idx]; } inline Use *allocHangoffUses(unsigned) const; + void dropHungoffUses(Use*); Value *getOperand(unsigned i) const { assert(i < NumOperands && "getOperand() out of range!"); Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp?rev=49497&r1=49496&r2=49497&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp Thu Apr 10 16:27:40 2008 @@ -23,6 +23,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/OperandTraits.h" using namespace llvm; void BitcodeReader::FreeState() { @@ -115,7 +116,7 @@ } } - +namespace llvm { namespace { /// @brief A class for maintaining the slot number definition /// as a placeholder for the actual definition for forward constants defs. @@ -128,51 +129,62 @@ return User::operator new(s, 1); } explicit ConstantPlaceHolder(const Type *Ty) - : ConstantExpr(Ty, Instruction::UserOp1, /*&Op*/NULL, 1) { + : ConstantExpr(Ty, Instruction::UserOp1, &Op<0>(), 1) { Op<0>() = UndefValue::get(Type::Int32Ty); } + /// Provide fast operand accessors + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); }; } + + // FIXME: can we inherit this from ConstantExpr? +template <> +struct OperandTraits : FixedNumOperandTraits<1> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantPlaceHolder, Value) +} + Constant *BitcodeReaderValueList::getConstantFwdRef(unsigned Idx, const Type *Ty) { if (Idx >= size()) { // Insert a bunch of null values. -// Uses.resize(Idx+1); + resize(Idx * 2 + 1); // OperandList = &Uses[0]; - NumOperands = Idx+1; +// NumOperands = Idx+1; } -// if (Value *V = Uses[Idx]) { -// assert(Ty == V->getType() && "Type mismatch in constant table!"); -// return cast(V); -// } + if (Value *V = OperandList[Idx]) { + assert(Ty == V->getType() && "Type mismatch in constant table!"); + return cast(V); + } // Create and return a placeholder, which will later be RAUW'd. Constant *C = new ConstantPlaceHolder(Ty); -// Uses[Idx].init(C, this); + OperandList[Idx].init(C, this); return C; } Value *BitcodeReaderValueList::getValueFwdRef(unsigned Idx, const Type *Ty) { if (Idx >= size()) { // Insert a bunch of null values. -// Uses.resize(Idx+1); + resize(Idx * 2 + 1); // OperandList = &Uses[0]; - NumOperands = Idx+1; +// NumOperands = Idx+1; } -/* if (Value *V = Uses[Idx]) { + if (Value *V = OperandList[Idx]) { assert((Ty == 0 || Ty == V->getType()) && "Type mismatch in value table!"); return V; - }*/ + } // No type specified, must be invalid reference. if (Ty == 0) return 0; // Create and return a placeholder, which will later be RAUW'd. Value *V = new Argument(Ty); -// Uses[Idx].init(V, this); + OperandList[Idx].init(V, this); return V; } Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h?rev=49497&r1=49496&r2=49497&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h (original) +++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h Thu Apr 10 16:27:40 2008 @@ -26,12 +26,35 @@ namespace llvm { class MemoryBuffer; +//===----------------------------------------------------------------------===// +// HungoffOperand Trait Class +//===----------------------------------------------------------------------===// + +template +struct HungoffOperandTraits { + static Use *op_begin(User* U) { + return U->OperandList; + } + static Use *op_end(User* U) { + return U->OperandList + U->getNumOperands(); + } + static unsigned operands(const User *U) { + return U->getNumOperands(); + } + static inline void *allocate(unsigned); // FIXME +}; + +//===----------------------------------------------------------------------===// +// BitcodeReaderValueList Class +//===----------------------------------------------------------------------===// + class BitcodeReaderValueList : public User { public: BitcodeReaderValueList() : User(Type::VoidTy, Value::ArgumentVal, 0, 0) {} // vector compatibility methods unsigned size() const { return getNumOperands(); } + void resize(unsigned); void push_back(Value *V) { // Uses.push_back(Use(V, this)); // OperandList = &Uses[0]; @@ -39,18 +62,20 @@ } void clear() { -// std::vector().swap(Uses); + dropHungoffUses(OperandList); } Value *operator[](unsigned i) const { return getOperand(i); } - Value *back() const { /*return Uses.back();*/ } - void pop_back() { /*Uses.pop_back(); --NumOperands;*/ } + Value *back() const { return getOperand(size() - 1); } + void pop_back() { setOperand(size() - 1, 0); --NumOperands; } bool empty() const { return NumOperands == 0; } void shrinkTo(unsigned N) { assert(N <= NumOperands && "Invalid shrinkTo request!"); // Uses.resize(N); - NumOperands = N; +// NumOperands = N; + while (NumOperands > N) + pop_back(); } virtual void print(std::ostream&) const {} From ggreif at gmail.com Thu Apr 10 17:12:32 2008 From: ggreif at gmail.com (Gabor Greif) Date: Thu, 10 Apr 2008 22:12:32 -0000 Subject: [llvm-commits] [llvm] r49498 - in /llvm/branches/ggreif/use-diet: include/llvm/User.h lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Reader/BitcodeReader.h Message-ID: <200804102212.m3AMCXut026961@zion.cs.uiuc.edu> Author: ggreif Date: Thu Apr 10 17:12:32 2008 New Revision: 49498 URL: http://llvm.org/viewvc/llvm-project?rev=49498&view=rev Log: more BitcodeReaderValueList stuff. this does not link yet Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49498&r1=49497&r2=49498&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/User.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/User.h Thu Apr 10 17:12:32 2008 @@ -211,6 +211,8 @@ class User : public Value { User(const User &); // Do not implement void *operator new(size_t); // Do not implement + template + friend struct HungoffOperandTraits; protected: /// OperandList - This is a pointer to the array of Users for this operand. /// For nodes of fixed arity (e.g. a binary operator) this array will live Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp?rev=49498&r1=49497&r2=49498&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp Thu Apr 10 17:12:32 2008 @@ -146,6 +146,18 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantPlaceHolder, Value) } +void BitcodeReaderValueList::resize(unsigned Desired) { + unsigned Capacity = 0; + if (OperandList) { + Capacity = OperandList->getImpliedUser() - OperandList; + } + + if (Desired > Capacity) + { + // FIXME + } +} + Constant *BitcodeReaderValueList::getConstantFwdRef(unsigned Idx, const Type *Ty) { if (Idx >= size()) { Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h?rev=49498&r1=49497&r2=49498&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h (original) +++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h Thu Apr 10 17:12:32 2008 @@ -17,7 +17,7 @@ #include "llvm/ModuleProvider.h" #include "llvm/ParameterAttributes.h" #include "llvm/Type.h" -#include "llvm/User.h" +#include "llvm/OperandTraits.h" #include "llvm/Bitcode/BitstreamReader.h" #include "llvm/Bitcode/LLVMBitCodes.h" #include "llvm/ADT/DenseMap.h" @@ -30,7 +30,7 @@ // HungoffOperand Trait Class //===----------------------------------------------------------------------===// -template +template struct HungoffOperandTraits { static Use *op_begin(User* U) { return U->OperandList; @@ -52,6 +52,9 @@ public: BitcodeReaderValueList() : User(Type::VoidTy, Value::ArgumentVal, 0, 0) {} + /// Provide fast operand accessors + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); + // vector compatibility methods unsigned size() const { return getNumOperands(); } void resize(unsigned); @@ -101,7 +104,12 @@ // Uses[Idx].init(V, this); } }; - + +template <> +struct OperandTraits : HungoffOperandTraits { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BitcodeReaderValueList, Value) class BitcodeReader : public ModuleProvider { MemoryBuffer *Buffer; From resistor at mac.com Thu Apr 10 17:13:32 2008 From: resistor at mac.com (Owen Anderson) Date: Thu, 10 Apr 2008 22:13:32 -0000 Subject: [llvm-commits] [llvm] r49499 - /llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Message-ID: <200804102213.m3AMDXTN026997@zion.cs.uiuc.edu> Author: resistor Date: Thu Apr 10 17:13:32 2008 New Revision: 49499 URL: http://llvm.org/viewvc/llvm-project?rev=49499&view=rev Log: Fix for PR2190. Memdep's non-local caching was checking dirtied blocks in the wrong order. Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=49499&r1=49498&r2=49499&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Thu Apr 10 17:13:32 2008 @@ -181,7 +181,9 @@ // Current stack of the DFS SmallVector stack; - stack.push_back(block); + for (pred_iterator PI = pred_begin(block), PE = pred_end(block); + PI != PE; ++PI) + stack.push_back(*PI); // Do a basic DFS while (!stack.empty()) { @@ -208,7 +210,7 @@ // If we re-encounter the starting block, we still need to search it // because there might be a dependency in the starting block AFTER // the position of the query. This is necessary to get loops right. - } else if (BB == block && stack.size() > 1) { + } else if (BB == block) { visited.insert(BB); Instruction* localDep = getDependency(query, 0, BB); From gohman at apple.com Thu Apr 10 17:27:06 2008 From: gohman at apple.com (Dan Gohman) Date: Thu, 10 Apr 2008 22:27:06 -0000 Subject: [llvm-commits] [llvm] r49502 - /llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h Message-ID: <200804102227.m3AMR654027443@zion.cs.uiuc.edu> Author: djg Date: Thu Apr 10 17:27:06 2008 New Revision: 49502 URL: http://llvm.org/viewvc/llvm-project?rev=49502&view=rev Log: Fix a typo in a comment. Modified: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h Modified: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h?rev=49502&r1=49501&r2=49502&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h Thu Apr 10 17:27:06 2008 @@ -256,7 +256,7 @@ DenseMap > SUnitMap; // SDNode to SUnit mapping (n -> n). std::vector SUnits; // The scheduling units. - SmallSet CommuteSet; // Nodes the should be commuted. + SmallSet CommuteSet; // Nodes that should be commuted. ScheduleDAG(SelectionDAG &dag, MachineBasicBlock *bb, const TargetMachine &tm); From gohman at apple.com Thu Apr 10 18:02:38 2008 From: gohman at apple.com (Dan Gohman) Date: Thu, 10 Apr 2008 23:02:38 -0000 Subject: [llvm-commits] [llvm] r49504 - /llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Message-ID: <200804102302.m3AN2c7t028637@zion.cs.uiuc.edu> Author: djg Date: Thu Apr 10 18:02:38 2008 New Revision: 49504 URL: http://llvm.org/viewvc/llvm-project?rev=49504&view=rev Log: Fix a typo in a comment. Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=49504&r1=49503&r2=49504&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Thu Apr 10 18:02:38 2008 @@ -298,7 +298,7 @@ } /// getDependency - Return the instruction on which a memory operation -/// depends. The local paramter indicates if the query should only +/// depends. The local parameter indicates if the query should only /// evaluate dependencies within the same basic block. Instruction* MemoryDependenceAnalysis::getDependency(Instruction* query, Instruction* start, From evan.cheng at apple.com Thu Apr 10 18:36:03 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 10 Apr 2008 23:36:03 -0000 Subject: [llvm-commits] [test-suite] r49507 - in /test-suite/trunk/MultiSource/Applications/sqlite3: Makefile smalltest.tcl Message-ID: <200804102336.m3ANa4eH029712@zion.cs.uiuc.edu> Author: evancheng Date: Thu Apr 10 18:36:03 2008 New Revision: 49507 URL: http://llvm.org/viewvc/llvm-project?rev=49507&view=rev Log: Shrink test size for SMALL_PROBLEM_SIZE=1. Added: test-suite/trunk/MultiSource/Applications/sqlite3/smalltest.tcl Modified: test-suite/trunk/MultiSource/Applications/sqlite3/Makefile Modified: test-suite/trunk/MultiSource/Applications/sqlite3/Makefile URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/sqlite3/Makefile?rev=49507&r1=49506&r2=49507&view=diff ============================================================================== --- test-suite/trunk/MultiSource/Applications/sqlite3/Makefile (original) +++ test-suite/trunk/MultiSource/Applications/sqlite3/Makefile Thu Apr 10 18:36:03 2008 @@ -18,8 +18,13 @@ # it needs to be generated before sqlite is run sqlite3.c: $(PROJ_SRC_DIR)/test15.sql +ifdef SMALL_PROBLEM_SIZE +$(PROJ_SRC_DIR)/test15.sql: $(PROJ_SRC_DIR)/smalltest.tcl + $(TCLSH) $(PROJ_SRC_DIR)/smalltest.tcl +else $(PROJ_SRC_DIR)/test15.sql: $(PROJ_SRC_DIR)/speedtest.tcl $(TCLSH) $(PROJ_SRC_DIR)/speedtest.tcl +endif clean:: rm -f test*.sql Added: test-suite/trunk/MultiSource/Applications/sqlite3/smalltest.tcl URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/sqlite3/smalltest.tcl?rev=49507&view=auto ============================================================================== --- test-suite/trunk/MultiSource/Applications/sqlite3/smalltest.tcl (added) +++ test-suite/trunk/MultiSource/Applications/sqlite3/smalltest.tcl Thu Apr 10 18:36:03 2008 @@ -0,0 +1,192 @@ +#!/usr/bin/tclsh +# +# Run this script using TCLSH to do a speed comparison between +# various versions of SQLite and PostgreSQL and MySQL +# + +# Run a test +# +set cnt 1 +proc runtest {title} { + global cnt + incr cnt +} + +# Initialize the environment +# +expr srand(1) +set ones {zero one two three four five six seven eight nine + ten eleven twelve thirteen fourteen fifteen sixteen seventeen + eighteen nineteen} +set tens {{} ten twenty thirty forty fifty sixty seventy eighty ninety} +proc number_name {n} { + if {$n>=1000} { + set txt "[number_name [expr {$n/1000}]] thousand" + set n [expr {$n%1000}] + } else { + set txt {} + } + if {$n>=100} { + append txt " [lindex $::ones [expr {$n/100}]] hundred" + set n [expr {$n%100}] + } + if {$n>=20} { + append txt " [lindex $::tens [expr {$n/10}]]" + set n [expr {$n%10}] + } + if {$n>0} { + append txt " [lindex $::ones $n]" + } + set txt [string trim $txt] + if {$txt==""} {set txt zero} + return $txt +} + + + +set fd [open test$cnt.sql w] +puts $fd "CREATE TABLE t1(a INTEGER, b INTEGER, c VARCHAR(100));" +for {set i 1} {$i<=100} {incr i} { + set r [expr {int(rand()*100000)}] + puts $fd "INSERT INTO t1 VALUES($i,$r,'[number_name $r]');" +} +close $fd +runtest {100 INSERTs} + + + +set fd [open test$cnt.sql w] +puts $fd "BEGIN;" +puts $fd "CREATE TABLE t2(a INTEGER, b INTEGER, c VARCHAR(100));" +for {set i 1} {$i<=2500} {incr i} { + set r [expr {int(rand()*500000)}] + puts $fd "INSERT INTO t2 VALUES($i,$r,'[number_name $r]');" +} +puts $fd "COMMIT;" +close $fd +runtest {2500 INSERTs in a transaction} + + + +set fd [open test$cnt.sql w] +for {set i 0} {$i<10} {incr i} { + set lwr [expr {$i*100}] + set upr [expr {($i+10)*100}] + puts $fd "SELECT count(*), avg(b) FROM t2 WHERE b>=$lwr AND b<$upr;" +} +close $fd +runtest {10 SELECTs without an index} + + + +set fd [open test$cnt.sql w] +for {set i 1} {$i<=10} {incr i} { + puts $fd "SELECT count(*), avg(b) FROM t2 WHERE c LIKE '%[number_name $i]%';" +} +close $fd +runtest {10 SELECTs on a string comparison} + + + +set fd [open test$cnt.sql w] +puts $fd {CREATE INDEX i2a ON t2(a);} +puts $fd {CREATE INDEX i2b ON t2(b);} +close $fd +runtest {Creating an index} + + + +set fd [open test$cnt.sql w] +for {set i 0} {$i<500} {incr i} { + set lwr [expr {$i*100}] + set upr [expr {($i+1)*100}] + puts $fd "SELECT count(*), avg(b) FROM t2 WHERE b>=$lwr AND b<$upr;" +} +close $fd +runtest {500 SELECTs with an index} + + + +set fd [open test$cnt.sql w] +puts $fd "BEGIN;" +for {set i 0} {$i<100} {incr i} { + set lwr [expr {$i*10}] + set upr [expr {($i+1)*10}] + puts $fd "UPDATE t1 SET b=b*2 WHERE a>=$lwr AND a<$upr;" +} +puts $fd "COMMIT;" +close $fd +runtest {100 UPDATEs without an index} + + + +set fd [open test$cnt.sql w] +puts $fd "BEGIN;" +for {set i 1} {$i<=2500} {incr i} { + set r [expr {int(rand()*500000)}] + puts $fd "UPDATE t2 SET b=$r WHERE a=$i;" +} +puts $fd "COMMIT;" +close $fd +runtest {2500 UPDATEs with an index} + + +set fd [open test$cnt.sql w] +puts $fd "BEGIN;" +for {set i 1} {$i<=2500} {incr i} { + set r [expr {int(rand()*500000)}] + puts $fd "UPDATE t2 SET c='[number_name $r]' WHERE a=$i;" +} +puts $fd "COMMIT;" +close $fd +runtest {2500 text UPDATEs with an index} + + + +set fd [open test$cnt.sql w] +puts $fd "BEGIN;" +puts $fd "INSERT INTO t1 SELECT * FROM t2;" +puts $fd "INSERT INTO t2 SELECT * FROM t1;" +puts $fd "COMMIT;" +close $fd +runtest {INSERTs from a SELECT} + + + +set fd [open test$cnt.sql w] +puts $fd {DELETE FROM t2 WHERE c LIKE '%fifty%';} +close $fd +runtest {DELETE without an index} + + + +set fd [open test$cnt.sql w] +puts $fd {DELETE FROM t2 WHERE a>10 AND a<20000;} +close $fd +runtest {DELETE with an index} + + + +set fd [open test$cnt.sql w] +puts $fd {INSERT INTO t2 SELECT * FROM t1;} +close $fd +runtest {A big INSERT after a big DELETE} + + + +set fd [open test$cnt.sql w] +puts $fd {BEGIN;} +puts $fd {DELETE FROM t1;} +for {set i 1} {$i<=300} {incr i} { + set r [expr {int(rand()*100000)}] + puts $fd "INSERT INTO t1 VALUES($i,$r,'[number_name $r]');" +} +puts $fd {COMMIT;} +close $fd +runtest {A big DELETE followed by many small INSERTs} + +set fd [open test$cnt.sql w] +puts $fd {DROP TABLE t1;} +puts $fd {DROP TABLE t2;} +close $fd +runtest {DROP TABLE} From evan.cheng at apple.com Thu Apr 10 18:40:51 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 10 Apr 2008 23:40:51 -0000 Subject: [llvm-commits] [test-suite] r49508 - /test-suite/trunk/MultiSource/Benchmarks/BitBench/five11/five11.c Message-ID: <200804102340.m3ANepdN029832@zion.cs.uiuc.edu> Author: evancheng Date: Thu Apr 10 18:40:51 2008 New Revision: 49508 URL: http://llvm.org/viewvc/llvm-project?rev=49508&view=rev Log: SMALL_PROBLEM_SIZE Modified: test-suite/trunk/MultiSource/Benchmarks/BitBench/five11/five11.c Modified: test-suite/trunk/MultiSource/Benchmarks/BitBench/five11/five11.c URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/BitBench/five11/five11.c?rev=49508&r1=49507&r2=49508&view=diff ============================================================================== --- test-suite/trunk/MultiSource/Benchmarks/BitBench/five11/five11.c (original) +++ test-suite/trunk/MultiSource/Benchmarks/BitBench/five11/five11.c Thu Apr 10 18:40:51 2008 @@ -177,7 +177,11 @@ } size = read_data(in, inbuf); gettimeofday(&pre,0); +#ifdef SMALL_PROBLEM_SIZE + for(i=0;i<500;i++){ +#else for(i=0;i<10000;i++){ +#endif list = five11(inbuf); outsize = calc_sum2(list); free_list2(list); @@ -185,4 +189,4 @@ gettimeofday(&post,0); printf("%d", outsize); exit(0); -} \ No newline at end of file +} From isanbard at gmail.com Thu Apr 10 18:47:27 2008 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 10 Apr 2008 23:47:27 -0000 Subject: [llvm-commits] [llvm] r49510 - /llvm/tags/Apple/llvmCore-2033/ Message-ID: <200804102347.m3ANlRNS030163@zion.cs.uiuc.edu> Author: void Date: Thu Apr 10 18:47:27 2008 New Revision: 49510 URL: http://llvm.org/viewvc/llvm-project?rev=49510&view=rev Log: Creating llvmCore-2033 branch Added: llvm/tags/Apple/llvmCore-2033/ - copied from r49509, llvm/trunk/ From isanbard at gmail.com Thu Apr 10 18:47:33 2008 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 10 Apr 2008 23:47:33 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49511 - /llvm-gcc-4.2/tags/Apple/llvmgcc42-2033/ Message-ID: <200804102347.m3ANlXEc030176@zion.cs.uiuc.edu> Author: void Date: Thu Apr 10 18:47:33 2008 New Revision: 49511 URL: http://llvm.org/viewvc/llvm-project?rev=49511&view=rev Log: Creating llvmgcc42-2033 branch Added: llvm-gcc-4.2/tags/Apple/llvmgcc42-2033/ - copied from r49510, llvm-gcc-4.2/trunk/ From evan.cheng at apple.com Thu Apr 10 18:47:54 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 10 Apr 2008 23:47:54 -0000 Subject: [llvm-commits] [llvm] r49512 - in /llvm/trunk: include/llvm/CodeGen/RegisterScavenging.h lib/CodeGen/RegisterScavenging.cpp Message-ID: <200804102347.m3ANlsbJ030200@zion.cs.uiuc.edu> Author: evancheng Date: Thu Apr 10 18:47:53 2008 New Revision: 49512 URL: http://llvm.org/viewvc/llvm-project?rev=49512&view=rev Log: Allow registers defined by implicit_def to be clobbered. Modified: llvm/trunk/include/llvm/CodeGen/RegisterScavenging.h llvm/trunk/lib/CodeGen/RegisterScavenging.cpp Modified: llvm/trunk/include/llvm/CodeGen/RegisterScavenging.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/RegisterScavenging.h?rev=49512&r1=49511&r2=49512&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/RegisterScavenging.h (original) +++ llvm/trunk/include/llvm/CodeGen/RegisterScavenging.h Thu Apr 10 18:47:53 2008 @@ -53,6 +53,10 @@ /// available, unset means the register is currently being used. BitVector RegsAvailable; + /// ImplicitDefed - If bit is set that means the register is defined by an + /// implicit_def instructions. That means it can be clobbered at will. + BitVector ImplicitDefed; + public: RegScavenger() : MBB(NULL), NumPhysRegs(0), Tracking(false), @@ -92,15 +96,26 @@ bool isUsed(unsigned Reg) const { return !RegsAvailable[Reg]; } bool isUnused(unsigned Reg) const { return RegsAvailable[Reg]; } + bool isImplicitlyDefined(unsigned Reg) const { return ImplicitDefed[Reg]; } + /// getRegsUsed - return all registers currently in use in used. void getRegsUsed(BitVector &used, bool includeReserved); /// setUsed / setUnused - Mark the state of one or a number of registers. /// - void setUsed(unsigned Reg); - void setUsed(BitVector Regs) { RegsAvailable &= ~Regs; } + void setUsed(unsigned Reg, bool ImpDef = false); + void setUsed(BitVector Regs, bool ImpDef = false) { + RegsAvailable &= ~Regs; + if (ImpDef) + ImplicitDefed |= Regs; + else + ImplicitDefed &= ~Regs; + } void setUnused(unsigned Reg, const MachineInstr *MI); - void setUnused(BitVector Regs) { RegsAvailable |= Regs; } + void setUnused(BitVector Regs) { + RegsAvailable |= Regs; + ImplicitDefed &= ~Regs; + } /// FindUnusedReg - Find a unused register of the specified register class /// from the specified set of registers. It return 0 is none is found. Modified: llvm/trunk/lib/CodeGen/RegisterScavenging.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterScavenging.cpp?rev=49512&r1=49511&r2=49512&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegisterScavenging.cpp (original) +++ llvm/trunk/lib/CodeGen/RegisterScavenging.cpp Thu Apr 10 18:47:53 2008 @@ -55,22 +55,28 @@ } /// setUsed - Set the register and its sub-registers as being used. -void RegScavenger::setUsed(unsigned Reg) { +void RegScavenger::setUsed(unsigned Reg, bool ImpDef) { RegsAvailable.reset(Reg); + ImplicitDefed[Reg] = ImpDef; for (const unsigned *SubRegs = TRI->getSubRegisters(Reg); - unsigned SubReg = *SubRegs; ++SubRegs) + unsigned SubReg = *SubRegs; ++SubRegs) { RegsAvailable.reset(SubReg); + ImplicitDefed[SubReg] = ImpDef; + } } /// setUnused - Set the register and its sub-registers as being unused. void RegScavenger::setUnused(unsigned Reg, const MachineInstr *MI) { RegsAvailable.set(Reg); + ImplicitDefed.reset(Reg); for (const unsigned *SubRegs = TRI->getSubRegisters(Reg); unsigned SubReg = *SubRegs; ++SubRegs) - if (!RedefinesSuperRegPart(MI, Reg, TRI)) + if (!RedefinesSuperRegPart(MI, Reg, TRI)) { RegsAvailable.set(SubReg); + ImplicitDefed.reset(SubReg); + } } void RegScavenger::enterBasicBlock(MachineBasicBlock *mbb) { @@ -86,6 +92,7 @@ if (!MBB) { NumPhysRegs = TRI->getNumRegs(); RegsAvailable.resize(NumPhysRegs); + ImplicitDefed.resize(NumPhysRegs); // Create reserved registers bitvector. ReservedRegs = TRI->getReservedRegs(MF); @@ -216,6 +223,7 @@ setUnused(ChangedRegs); // Process defs. + bool IsImpDef = MI->getOpcode() == TargetInstrInfo::IMPLICIT_DEF; for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { const MachineOperand &MO = MI->getOperand(i); @@ -240,12 +248,13 @@ if (RedefinesSuperRegPart(MI, MO, TRI)) continue; - // Implicit def is allowed to "re-define" any register. + // Implicit def is allowed to "re-define" any register. Similarly, + // implicitly defined registers can be clobbered. assert((isReserved(Reg) || isUnused(Reg) || - MI->getOpcode() == TargetInstrInfo::IMPLICIT_DEF || + IsImpDef || isImplicitlyDefined(Reg) || isLiveInButUnusedBefore(Reg, MI, MBB, TRI, MRI)) && "Re-defining a live register!"); - setUsed(Reg); + setUsed(Reg, IsImpDef); } } From evan.cheng at apple.com Thu Apr 10 18:48:35 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 10 Apr 2008 23:48:35 -0000 Subject: [llvm-commits] [llvm] r49513 - /llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Message-ID: <200804102348.m3ANmZH2030226@zion.cs.uiuc.edu> Author: evancheng Date: Thu Apr 10 18:48:35 2008 New Revision: 49513 URL: http://llvm.org/viewvc/llvm-project?rev=49513&view=rev Log: Remove implicit_def instructions that become dead as result of coalescing. Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=49513&r1=49512&r2=49513&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Thu Apr 10 18:48:35 2008 @@ -632,8 +632,8 @@ return; unsigned LastUseIdx; - MachineOperand *LastUse = - lastRegisterUse(LR->start, CopyIdx-1, li.reg, LastUseIdx); + MachineOperand *LastUse = lastRegisterUse(LR->start, CopyIdx-1, li.reg, + LastUseIdx); if (LastUse) { // There are uses before the copy, just shorten the live range to the end // of last use. @@ -714,29 +714,48 @@ /// identity copies so they will be removed. void SimpleRegisterCoalescing::RemoveCopiesFromValNo(LiveInterval &li, VNInfo *VNI) { - for (MachineRegisterInfo::use_iterator UI = mri_->use_begin(li.reg), - UE = mri_->use_end(); UI != UE;) { - MachineInstr *UseMI = &*UI; - ++UI; - if (JoinedCopies.count(UseMI)) + MachineInstr *ImpDef = NULL; + MachineOperand *LastUse = NULL; + unsigned LastUseIdx = li_->getUseIndex(VNI->def); + for (MachineRegisterInfo::reg_iterator RI = mri_->reg_begin(li.reg), + RE = mri_->reg_end(); RI != RE;) { + MachineOperand *MO = &RI.getOperand(); + MachineInstr *MI = &*RI; + ++RI; + if (MO->isDef()) { + if (MI->getOpcode() == TargetInstrInfo::IMPLICIT_DEF) { + assert(!ImpDef && "Multiple implicit_def defining same register?"); + ImpDef = MI; + } continue; - unsigned UseIdx = li_->getUseIndex(li_->getInstructionIndex(UseMI)); + } + if (JoinedCopies.count(MI)) + continue; + unsigned UseIdx = li_->getUseIndex(li_->getInstructionIndex(MI)); LiveInterval::iterator ULR = li.FindLiveRangeContaining(UseIdx); if (ULR->valno != VNI) continue; - if (UseMI->getOpcode() == TargetInstrInfo::INSERT_SUBREG) - continue; // If the use is a copy, turn it into an identity copy. unsigned SrcReg, DstReg; - if (!tii_->isMoveInstr(*UseMI, SrcReg, DstReg) || SrcReg != li.reg) - assert(0 && "Unexpected use of implicit def!"); - // Each UseMI may have multiple uses of this register. Change them all. - for (unsigned i = 0, e = UseMI->getNumOperands(); i != e; ++i) { - MachineOperand &MO = UseMI->getOperand(i); - if (MO.isReg() && MO.getReg() == li.reg) - MO.setReg(DstReg); + if (tii_->isMoveInstr(*MI, SrcReg, DstReg) && SrcReg == li.reg) { + // Each use MI may have multiple uses of this register. Change them all. + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + MachineOperand &MO = MI->getOperand(i); + if (MO.isReg() && MO.getReg() == li.reg) + MO.setReg(DstReg); + } + JoinedCopies.insert(MI); + } else if (UseIdx > LastUseIdx) { + LastUseIdx = UseIdx; + LastUse = MO; } - JoinedCopies.insert(UseMI); + } + if (LastUse) + LastUse->setIsKill(); + else { + // Remove dead implicit_def. + li_->RemoveMachineInstrFromMaps(ImpDef); + ImpDef->eraseFromParent(); } } @@ -1874,7 +1893,6 @@ assert(DefMI->getOpcode() == TargetInstrInfo::IMPLICIT_DEF); li_->RemoveMachineInstrFromMaps(DefMI); DefMI->eraseFromParent(); - ++numPeep; } } ++I; From evan.cheng at apple.com Thu Apr 10 18:49:09 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 10 Apr 2008 23:49:09 -0000 Subject: [llvm-commits] [llvm] r49514 - in /llvm/trunk/test/CodeGen/ARM: 2008-04-04-ScavengerAssert.ll 2008-04-10-ScavengerAssert.ll Message-ID: <200804102349.m3ANnAlB030256@zion.cs.uiuc.edu> Author: evancheng Date: Thu Apr 10 18:49:09 2008 New Revision: 49514 URL: http://llvm.org/viewvc/llvm-project?rev=49514&view=rev Log: New test. Added: llvm/trunk/test/CodeGen/ARM/2008-04-10-ScavengerAssert.ll Modified: llvm/trunk/test/CodeGen/ARM/2008-04-04-ScavengerAssert.ll Modified: llvm/trunk/test/CodeGen/ARM/2008-04-04-ScavengerAssert.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2008-04-04-ScavengerAssert.ll?rev=49514&r1=49513&r2=49514&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2008-04-04-ScavengerAssert.ll (original) +++ llvm/trunk/test/CodeGen/ARM/2008-04-04-ScavengerAssert.ll Thu Apr 10 18:49:09 2008 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=arm +; RUN: llvm-as < %s | llc -mtriple=arm-apple-darwin @numBinsY = external global i32 ; [#uses=1] Added: llvm/trunk/test/CodeGen/ARM/2008-04-10-ScavengerAssert.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2008-04-10-ScavengerAssert.ll?rev=49514&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2008-04-10-ScavengerAssert.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2008-04-10-ScavengerAssert.ll Thu Apr 10 18:49:09 2008 @@ -0,0 +1,258 @@ +; RUN: llvm-as < %s | llc -mtriple=arm-apple-darwin + + %struct.CONTENTBOX = type { i32, i32, i32, i32, i32 } + %struct.FILE = type { i8*, i32, i32, i16, i16, %struct.__sbuf, i32, i8*, i32 (i8*)*, i32 (i8*, i8*, i32)*, i64 (i8*, i64, i32)*, i32 (i8*, i8*, i32)*, %struct.__sbuf, %struct.__sFILEX*, i32, [3 x i8], [1 x i8], %struct.__sbuf, i32, i64 } + %struct.LOCBOX = type { i32, i32, i32, i32 } + %struct.SIDEBOX = type { i32, i32 } + %struct.UNCOMBOX = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } + %struct.__sFILEX = type opaque + %struct.__sbuf = type { i8*, i32 } + %struct.cellbox = type { i8*, i32, i32, i32, [9 x i32], i32, i32, i32, i32, i32, i32, i32, double, double, double, double, double, i32, i32, %struct.CONTENTBOX*, %struct.UNCOMBOX*, [8 x %struct.tilebox*], %struct.SIDEBOX* } + %struct.termbox = type { %struct.termbox*, i32, i32, i32, i32, i32 } + %struct.tilebox = type { %struct.tilebox*, double, double, double, double, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, %struct.termbox*, %struct.LOCBOX* } + at .str127 = external constant [2 x i8] ; <[2 x i8]*> [#uses=1] + at .str584 = external constant [5 x i8] ; <[5 x i8]*> [#uses=1] + at .str8115 = external constant [9 x i8] ; <[9 x i8]*> [#uses=1] + +declare %struct.FILE* @fopen(i8*, i8*) + +declare i32 @strcmp(i8*, i8*) + +declare i32 @fscanf(%struct.FILE*, i8*, ...) + +define void @main(i32 %argc, i8** %argv) noreturn { +entry: + br i1 false, label %cond_next48, label %cond_false674 +cond_next48: ; preds = %entry + %tmp61 = call %struct.FILE* @fopen( i8* null, i8* getelementptr ([2 x i8]* @.str127, i32 0, i32 0) ) ; <%struct.FILE*> [#uses=2] + br i1 false, label %bb220.i.i.i, label %bb62.preheader.i.i.i +bb62.preheader.i.i.i: ; preds = %cond_next48 + ret void +bb220.i.i.i: ; preds = %cond_next48 + br i1 false, label %bb248.i.i.i, label %cond_next232.i.i.i +cond_next232.i.i.i: ; preds = %bb220.i.i.i + ret void +bb248.i.i.i: ; preds = %bb220.i.i.i + br i1 false, label %bb300.i.i.i, label %cond_false256.i.i.i +cond_false256.i.i.i: ; preds = %bb248.i.i.i + ret void +bb300.i.i.i: ; preds = %bb248.i.i.i + br label %bb.i.i347.i +bb.i.i347.i: ; preds = %bb.i.i347.i, %bb300.i.i.i + br i1 false, label %bb894.loopexit.i.i, label %bb.i.i347.i +bb.i350.i: ; preds = %bb894.i.i + br i1 false, label %bb24.i.i, label %cond_false373.i.i +bb24.i.i: ; preds = %bb24.i.i, %bb.i350.i + br i1 false, label %bb40.i.i, label %bb24.i.i +bb40.i.i: ; preds = %bb24.i.i + br i1 false, label %bb177.i393.i, label %bb82.i.i +bb82.i.i: ; preds = %bb40.i.i + ret void +bb177.i393.i: ; preds = %bb40.i.i + br i1 false, label %bb894.i.i, label %bb192.i.i +bb192.i.i: ; preds = %bb177.i393.i + ret void +cond_false373.i.i: ; preds = %bb.i350.i + %tmp376.i.i = call i32 @strcmp( i8* null, i8* getelementptr ([9 x i8]* @.str8115, i32 0, i32 0) ) ; [#uses=0] + br i1 false, label %cond_true380.i.i, label %cond_next602.i.i +cond_true380.i.i: ; preds = %cond_false373.i.i + %tmp394.i418.i = add i32 %cell.0.i.i, 1 ; [#uses=1] + %tmp397.i420.i = load %struct.cellbox** null, align 4 ; <%struct.cellbox*> [#uses=1] + br label %bb398.i.i +bb398.i.i: ; preds = %bb398.i.i, %cond_true380.i.i + br i1 false, label %bb414.i.i, label %bb398.i.i +bb414.i.i: ; preds = %bb398.i.i + br i1 false, label %bb581.i.i, label %bb455.i442.i +bb455.i442.i: ; preds = %bb414.i.i + ret void +bb581.i.i: ; preds = %bb581.i.i, %bb414.i.i + br i1 false, label %bb894.i.i, label %bb581.i.i +cond_next602.i.i: ; preds = %cond_false373.i.i + br i1 false, label %bb609.i.i, label %bb661.i.i +bb609.i.i: ; preds = %cond_next602.i.i + br label %bb620.i.i +bb620.i.i: ; preds = %bb620.i.i, %bb609.i.i + %indvar166.i465.i = phi i32 [ %indvar.next167.i.i, %bb620.i.i ], [ 0, %bb609.i.i ] ; [#uses=1] + %tmp640.i.i = call i32 (%struct.FILE*, i8*, ...)* @fscanf( %struct.FILE* %tmp61, i8* getelementptr ([5 x i8]* @.str584, i32 0, i32 0), [1024 x i8]* null ) ; [#uses=0] + %tmp648.i.i = load i32* null, align 4 ; [#uses=1] + %tmp650.i468.i = icmp sgt i32 0, %tmp648.i.i ; [#uses=1] + %tmp624.i469.i = call i32 (%struct.FILE*, i8*, ...)* @fscanf( %struct.FILE* %tmp61, i8* getelementptr ([5 x i8]* @.str584, i32 0, i32 0), [1024 x i8]* null ) ; [#uses=0] + %indvar.next167.i.i = add i32 %indvar166.i465.i, 1 ; [#uses=1] + br i1 %tmp650.i468.i, label %bb653.i.i.loopexit, label %bb620.i.i +bb653.i.i.loopexit: ; preds = %bb620.i.i + %tmp642.i466.i = add i32 0, 1 ; [#uses=1] + br label %bb894.i.i +bb661.i.i: ; preds = %cond_next602.i.i + ret void +bb894.loopexit.i.i: ; preds = %bb.i.i347.i + br label %bb894.i.i +bb894.i.i: ; preds = %bb894.loopexit.i.i, %bb653.i.i.loopexit, %bb581.i.i, %bb177.i393.i + %pinctr.0.i.i = phi i32 [ 0, %bb894.loopexit.i.i ], [ %tmp642.i466.i, %bb653.i.i.loopexit ], [ %pinctr.0.i.i, %bb177.i393.i ], [ %pinctr.0.i.i, %bb581.i.i ] ; [#uses=2] + %soft.0.i.i = phi i32 [ undef, %bb894.loopexit.i.i ], [ %soft.0.i.i, %bb653.i.i.loopexit ], [ 0, %bb177.i393.i ], [ 1, %bb581.i.i ] ; [#uses=1] + %cell.0.i.i = phi i32 [ 0, %bb894.loopexit.i.i ], [ %cell.0.i.i, %bb653.i.i.loopexit ], [ 0, %bb177.i393.i ], [ %tmp394.i418.i, %bb581.i.i ] ; [#uses=2] + %ptr.0.i.i = phi %struct.cellbox* [ undef, %bb894.loopexit.i.i ], [ %ptr.0.i.i, %bb653.i.i.loopexit ], [ null, %bb177.i393.i ], [ %tmp397.i420.i, %bb581.i.i ] ; <%struct.cellbox*> [#uses=1] + br i1 false, label %bb.i350.i, label %bb902.i502.i +bb902.i502.i: ; preds = %bb894.i.i + ret void +cond_false674: ; preds = %entry + ret void +} + + %struct.III_psy_xmin = type { [22 x double], [13 x [3 x double]] } + %struct.III_scalefac_t = type { [22 x i32], [13 x [3 x i32]] } + %struct.gr_info = type { i32, i32, i32, i32, i32, i32, i32, i32, [3 x i32], [3 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32*, [4 x i32] } + %struct.lame_global_flags = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i8*, i8*, i32, i32, float, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, float, i32, i32, i32, float, float, float, float, i32, i32, i32, i32, i32, i32, i32, i32 } + at scalefac_band.1 = external global [14 x i32] ; <[14 x i32]*> [#uses=2] + +declare fastcc i32 @init_outer_loop(%struct.lame_global_flags*, double*, %struct.gr_info*) + +define fastcc void @outer_loop(%struct.lame_global_flags* %gfp, double* %xr, i32 %targ_bits, double* %best_noise, %struct.III_psy_xmin* %l3_xmin, i32* %l3_enc, %struct.III_scalefac_t* %scalefac, %struct.gr_info* %cod_info, i32 %ch) { +entry: + %cod_info.182 = getelementptr %struct.gr_info* %cod_info, i32 0, i32 1 ; [#uses=1] + br label %bb +bb: ; preds = %bb226, %entry + %save_cod_info.1.1 = phi i32 [ undef, %entry ], [ %save_cod_info.1.1, %bb226 ] ; [#uses=2] + br i1 false, label %cond_next, label %cond_true +cond_true: ; preds = %bb + ret void +cond_next: ; preds = %bb + br i1 false, label %cond_next144, label %cond_false +cond_false: ; preds = %cond_next + ret void +cond_next144: ; preds = %cond_next + br i1 false, label %cond_next205, label %cond_true163 +cond_true163: ; preds = %cond_next144 + br i1 false, label %bb34.i, label %bb.i53 +bb.i53: ; preds = %cond_true163 + ret void +bb34.i: ; preds = %cond_true163 + %tmp37.i55 = load i32* null, align 4 ; [#uses=1] + br i1 false, label %bb65.preheader.i, label %bb78.i +bb65.preheader.i: ; preds = %bb34.i + br label %bb65.outer.us.i +bb65.outer.us.i: ; preds = %bb65.outer.us.i, %bb65.preheader.i + br i1 false, label %bb78.i, label %bb65.outer.us.i +bb78.i: ; preds = %bb65.outer.us.i, %bb34.i + br i1 false, label %bb151.i.preheader, label %bb90.i +bb90.i: ; preds = %bb78.i + ret void +bb151.i.preheader: ; preds = %bb78.i + br label %bb151.i +bb151.i: ; preds = %bb226.backedge.i, %bb151.i.preheader + %i.154.i = phi i32 [ %tmp15747.i, %bb226.backedge.i ], [ 0, %bb151.i.preheader ] ; [#uses=2] + %tmp15747.i = add i32 %i.154.i, 1 ; [#uses=3] + br i1 false, label %bb155.i, label %bb226.backedge.i +bb226.backedge.i: ; preds = %cond_next215.i, %bb151.i + %tmp228.i71 = icmp slt i32 %tmp15747.i, 3 ; [#uses=1] + br i1 %tmp228.i71, label %bb151.i, label %amp_scalefac_bands.exit +bb155.i: ; preds = %cond_next215.i, %bb151.i + %indvar90.i = phi i32 [ %indvar.next91.i, %cond_next215.i ], [ 0, %bb151.i ] ; [#uses=2] + %sfb.3.reg2mem.0.i = add i32 %indvar90.i, %tmp37.i55 ; [#uses=4] + %tmp161.i = getelementptr [4 x [21 x double]]* null, i32 0, i32 %tmp15747.i, i32 %sfb.3.reg2mem.0.i ; [#uses=1] + %tmp162.i74 = load double* %tmp161.i, align 4 ; [#uses=0] + br i1 false, label %cond_true167.i, label %cond_next215.i +cond_true167.i: ; preds = %bb155.i + %tmp173.i = getelementptr %struct.III_scalefac_t* null, i32 0, i32 1, i32 %sfb.3.reg2mem.0.i, i32 %i.154.i ; [#uses=1] + store i32 0, i32* %tmp173.i, align 4 + %tmp182.1.i = getelementptr [14 x i32]* @scalefac_band.1, i32 0, i32 %sfb.3.reg2mem.0.i ; [#uses=0] + %tmp185.i78 = add i32 %sfb.3.reg2mem.0.i, 1 ; [#uses=1] + %tmp187.1.i = getelementptr [14 x i32]* @scalefac_band.1, i32 0, i32 %tmp185.i78 ; [#uses=1] + %tmp188.i = load i32* %tmp187.1.i, align 4 ; [#uses=1] + %tmp21153.i = icmp slt i32 0, %tmp188.i ; [#uses=1] + br i1 %tmp21153.i, label %bb190.preheader.i, label %cond_next215.i +bb190.preheader.i: ; preds = %cond_true167.i + ret void +cond_next215.i: ; preds = %cond_true167.i, %bb155.i + %indvar.next91.i = add i32 %indvar90.i, 1 ; [#uses=2] + %exitcond99.i87 = icmp eq i32 %indvar.next91.i, 0 ; [#uses=1] + br i1 %exitcond99.i87, label %bb226.backedge.i, label %bb155.i +amp_scalefac_bands.exit: ; preds = %bb226.backedge.i + br i1 false, label %bb19.i, label %bb.i16 +bb.i16: ; preds = %amp_scalefac_bands.exit + ret void +bb19.i: ; preds = %amp_scalefac_bands.exit + br i1 false, label %bb40.outer.i, label %cond_next205 +bb40.outer.i: ; preds = %bb19.i + ret void +cond_next205: ; preds = %bb19.i, %cond_next144 + br i1 false, label %bb226, label %cond_true210 +cond_true210: ; preds = %cond_next205 + br i1 false, label %bb226, label %cond_true217 +cond_true217: ; preds = %cond_true210 + %tmp221 = call fastcc i32 @init_outer_loop( %struct.lame_global_flags* %gfp, double* %xr, %struct.gr_info* %cod_info ) ; [#uses=0] + ret void +bb226: ; preds = %cond_true210, %cond_next205 + br i1 false, label %bb231, label %bb +bb231: ; preds = %bb226 + store i32 %save_cod_info.1.1, i32* %cod_info.182 + ret void +} + + %struct.III_psy_xmin = type { [22 x double], [13 x [3 x double]] } + %struct.III_scalefac_t = type { [22 x i32], [13 x [3 x i32]] } + %struct.gr_info = type { i32, i32, i32, i32, i32, i32, i32, i32, [3 x i32], [3 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32*, [4 x i32] } + %struct.lame_global_flags = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i8*, i8*, i32, i32, float, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, float, i32, i32, i32, float, float, float, float, i32, i32, i32, i32, i32, i32, i32, i32 } + +define fastcc void @outer_loop2(%struct.lame_global_flags* %gfp, double* %xr, i32 %targ_bits, double* %best_noise, %struct.III_psy_xmin* %l3_xmin, i32* %l3_enc, %struct.III_scalefac_t* %scalefac, %struct.gr_info* %cod_info, i32 %ch) { +entry: + %cod_info.20128.1 = getelementptr %struct.gr_info* %cod_info, i32 0, i32 20, i32 1 ; [#uses=1] + %cod_info.20128.2 = getelementptr %struct.gr_info* %cod_info, i32 0, i32 20, i32 2 ; [#uses=1] + %cod_info.20128.3 = getelementptr %struct.gr_info* %cod_info, i32 0, i32 20, i32 3 ; [#uses=1] + br label %bb +bb: ; preds = %bb226, %entry + %save_cod_info.19.1 = phi i32* [ undef, %entry ], [ %save_cod_info.19.0, %bb226 ] ; [#uses=1] + %save_cod_info.0.1 = phi i32 [ undef, %entry ], [ %save_cod_info.0.0, %bb226 ] ; [#uses=1] + br i1 false, label %cond_next144, label %cond_false +cond_false: ; preds = %bb + br i1 false, label %cond_true56, label %cond_false78 +cond_true56: ; preds = %cond_false + br i1 false, label %inner_loop.exit, label %cond_next85 +inner_loop.exit: ; preds = %cond_true56 + br i1 false, label %cond_next104, label %cond_false96 +cond_false78: ; preds = %cond_false + ret void +cond_next85: ; preds = %cond_true56 + ret void +cond_false96: ; preds = %inner_loop.exit + ret void +cond_next104: ; preds = %inner_loop.exit + br i1 false, label %cond_next144, label %cond_false110 +cond_false110: ; preds = %cond_next104 + ret void +cond_next144: ; preds = %cond_next104, %bb + %save_cod_info.19.0 = phi i32* [ %save_cod_info.19.1, %bb ], [ null, %cond_next104 ] ; [#uses=1] + %save_cod_info.4.0 = phi i32 [ 0, %bb ], [ 0, %cond_next104 ] ; [#uses=1] + %save_cod_info.3.0 = phi i32 [ 0, %bb ], [ 0, %cond_next104 ] ; [#uses=1] + %save_cod_info.2.0 = phi i32 [ 0, %bb ], [ 0, %cond_next104 ] ; [#uses=1] + %save_cod_info.1.0 = phi i32 [ 0, %bb ], [ 0, %cond_next104 ] ; [#uses=1] + %save_cod_info.0.0 = phi i32 [ %save_cod_info.0.1, %bb ], [ 0, %cond_next104 ] ; [#uses=1] + %over.1 = phi i32 [ 0, %bb ], [ 0, %cond_next104 ] ; [#uses=1] + %best_over.0 = phi i32 [ 0, %bb ], [ 0, %cond_next104 ] ; [#uses=1] + %notdone.0 = phi i32 [ 0, %bb ], [ 0, %cond_next104 ] ; [#uses=1] + %tmp147 = load i32* null, align 4 ; [#uses=1] + %tmp148 = icmp eq i32 %tmp147, 0 ; [#uses=1] + %tmp153 = icmp eq i32 %over.1, 0 ; [#uses=1] + %bothcond = and i1 %tmp148, %tmp153 ; [#uses=1] + %notdone.2 = select i1 %bothcond, i32 0, i32 %notdone.0 ; [#uses=1] + br i1 false, label %cond_next205, label %cond_true163 +cond_true163: ; preds = %cond_next144 + ret void +cond_next205: ; preds = %cond_next144 + br i1 false, label %bb226, label %cond_true210 +cond_true210: ; preds = %cond_next205 + ret void +bb226: ; preds = %cond_next205 + %tmp228 = icmp eq i32 %notdone.2, 0 ; [#uses=1] + br i1 %tmp228, label %bb231, label %bb +bb231: ; preds = %bb226 + store i32 %save_cod_info.1.0, i32* null + store i32 %save_cod_info.2.0, i32* null + store i32 %save_cod_info.3.0, i32* null + store i32 %save_cod_info.4.0, i32* null + store i32 0, i32* %cod_info.20128.1 + store i32 0, i32* %cod_info.20128.2 + store i32 0, i32* %cod_info.20128.3 + %tmp244245 = sitofp i32 %best_over.0 to double ; [#uses=1] + store double %tmp244245, double* %best_noise, align 4 + ret void +} From evan.cheng at apple.com Thu Apr 10 19:10:00 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 10 Apr 2008 17:10:00 -0700 Subject: [llvm-commits] PATCH: Tailcallopt x86 byval argument handling In-Reply-To: References: Message-ID: <57E157A7-FF7F-4CCD-B4B1-44919CF8AAC3@apple.com> On Apr 9, 2008, at 2:33 PM, Arnold Schwaighofer wrote: >> i'll be back > ... and here i am. no more checking for registers. removed the check > for the known registers (e/rcx,si,di) that are overwritten by byval > lowering. now all register arguments are protected by a copyto/from > virtual reg sequence the register allocator does the rest of the work. Thanks. The patch looks good. Have you verified the register allocator does eliminate the unnecessary copies? Evan > > > regards arnold > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From arnold.schwaighofer at gmail.com Thu Apr 10 19:52:19 2008 From: arnold.schwaighofer at gmail.com (Arnold Schwaighofer) Date: Fri, 11 Apr 2008 02:52:19 +0200 Subject: [llvm-commits] PATCH: Tailcallopt x86 byval argument handling In-Reply-To: <57E157A7-FF7F-4CCD-B4B1-44919CF8AAC3@apple.com> References: <57E157A7-FF7F-4CCD-B4B1-44919CF8AAC3@apple.com> Message-ID: On Fri, Apr 11, 2008 at 2:10 AM, Evan Cheng wrote: > Thanks. The patch looks good. Have you verified the register allocator > does eliminate the unnecessary copies? Depends on what your notion of verify is. I checked with a few examples. :) The copying of arguments for register parameters to virtual registers and back to the parameter's register is only emitted in cases where tail call opt is on and the function call contains a byval argument. So tail calls without byval arguments would not pay the price. So even in this case i wouldn't be so bad? take for example the following call: define fastcc i64 @tailcaller(i64 %b, %struct.s* byval %a) { entry: %tmp2 = getelementptr %struct.s* %a, i32 0, i32 1 %tmp3 = load i64* %tmp2, align 8 %tmp4 = tail call fastcc i64 @tailcallee(%struct.s* %a byval, i64 %tmp3, i64 %b, i64 7, i64 13, i64 17) ret i64 %tmp4 } as you can see 3rd (7) and 5th (17) argument are directly moved to their corresponding argument register (rdx,r8). only rsi, rdi, rcx are moved to intermediate registers as expected (killed by byval lowering). as note that when i say 3rd i really mean 4th (b) but since the first argument is byval and passed on the stack it i do not take into account. so it seems the allocator is doing it's job nicely. tailcaller: pushq %rbx subq $32, %rsp movq %rdi, %rax movq 56(%rsp), %r9 movl $6, %r10d leaq 48(%rsp), %rsi movq %r10, %rcx movq %rsp, %rdi rep;movsl leaq 48(%rsp), %rdi movl $13, %ebx movl $7, %edx movl $17, %r8d movq %r10, %rcx movq %rsp, %rsi rep;movsl movq %r9, %rdi movq %rax, %rsi movq %rbx, %rcx addq $32, %rsp popq %rbx jmp tailcallee # TAILCALL .size tailcaller, .-tailcaller okay to commit? From arnold.schwaighofer at gmail.com Thu Apr 10 20:10:07 2008 From: arnold.schwaighofer at gmail.com (Arnold Schwaighofer) Date: Fri, 11 Apr 2008 03:10:07 +0200 Subject: [llvm-commits] PATCH: Tailcallopt x86 byval argument handling In-Reply-To: References: <57E157A7-FF7F-4CCD-B4B1-44919CF8AAC3@apple.com> Message-ID: On Fri, Apr 11, 2008 at 2:52 AM, Arnold Schwaighofer wrote: > as note that when i say 3rd i really mean 4th (b) but since also note ... mean 4th (7) > the first argument is byval and passed on the stack it i do not take > into account. so it seems the allocator is doing it's job nicely. it into sheesh sorry really should read thrice what i write a 3am in the morning before i hit the post button ;) From ggreif at gmail.com Thu Apr 10 21:23:38 2008 From: ggreif at gmail.com (Gabor Greif) Date: Fri, 11 Apr 2008 02:23:38 -0000 Subject: [llvm-commits] [llvm] r49515 - in /llvm/branches/ggreif/use-diet: include/llvm/Use.h include/llvm/User.h lib/VMCore/Use.cpp Message-ID: <200804110223.m3B2Nc2K002565@zion.cs.uiuc.edu> Author: ggreif Date: Thu Apr 10 21:23:37 2008 New Revision: 49515 URL: http://llvm.org/viewvc/llvm-project?rev=49515&view=rev Log: implement dropHungoffUses in terms of the new Use:zap method (naively) Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h llvm/branches/ggreif/use-diet/include/llvm/User.h llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Use.h?rev=49515&r1=49514&r2=49515&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Use.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Use.h Thu Apr 10 21:23:37 2008 @@ -55,6 +55,7 @@ User *getUser() const { return U; } const Use* getImpliedUser() const; static void initTags(Use *Start, Use *Stop, ptrdiff_t Done = 0); + static void zap(Use *Start, const Use *Stop); inline void set(Value *Val); Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49515&r1=49514&r2=49515&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/User.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/User.h Thu Apr 10 21:23:37 2008 @@ -254,7 +254,9 @@ return OperandTraits::op_begin(const_cast(this))[Idx]; } inline Use *allocHangoffUses(unsigned) const; - void dropHungoffUses(Use*); + void dropHungoffUses(Use *U) { + U->zap(U, U->getImpliedUser()); + } Value *getOperand(unsigned i) const { assert(i < NumOperands && "getOperand() out of range!"); Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp?rev=49515&r1=49514&r2=49515&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Thu Apr 10 21:23:37 2008 @@ -49,6 +49,10 @@ } } +//===----------------------------------------------------------------------===// +// Use initTags Implementation +//===----------------------------------------------------------------------===// + void Use::initTags(Use *Start, Use *Stop, ptrdiff_t Done) { ptrdiff_t Count = 0; while (Start != Stop) @@ -66,5 +70,14 @@ } } +//===----------------------------------------------------------------------===// +// Use zap Implementation +//===----------------------------------------------------------------------===// +void Use::zap(Use *Start, const Use *Stop) { + while (Start != Stop) { + (Start++)->set(0); + } } + +} // End llvm namespace From nicholas at mxc.ca Thu Apr 10 21:52:58 2008 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 10 Apr 2008 19:52:58 -0700 Subject: [llvm-commits] [llvm] r49515 - in /llvm/branches/ggreif/use-diet: include/llvm/Use.h include/llvm/User.h lib/VMCore/Use.cpp In-Reply-To: <200804110223.m3B2Nc2K002565@zion.cs.uiuc.edu> References: <200804110223.m3B2Nc2K002565@zion.cs.uiuc.edu> Message-ID: <47FED28A.7080806@mxc.ca> Gabor Greif wrote: > Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h > URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49515&r1=49514&r2=49515&view=diff > > ============================================================================== > --- llvm/branches/ggreif/use-diet/include/llvm/User.h (original) > +++ llvm/branches/ggreif/use-diet/include/llvm/User.h Thu Apr 10 21:23:37 2008 > @@ -254,7 +254,9 @@ > return OperandTraits::op_begin(const_cast(this))[Idx]; > } > inline Use *allocHangoffUses(unsigned) const; > - void dropHungoffUses(Use*); > + void dropHungoffUses(Use *U) { > + U->zap(U, U->getImpliedUser()); > + } Tab. > > Value *getOperand(unsigned i) const { > assert(i < NumOperands && "getOperand() out of range!"); > > Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp?rev=49515&r1=49514&r2=49515&view=diff > > ============================================================================== > --- llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp (original) > +++ llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Thu Apr 10 21:23:37 2008 > @@ -49,6 +49,10 @@ > } > } > > +//===----------------------------------------------------------------------===// > +// Use initTags Implementation > +//===----------------------------------------------------------------------===// > + > void Use::initTags(Use *Start, Use *Stop, ptrdiff_t Done) { > ptrdiff_t Count = 0; > while (Start != Stop) > @@ -66,5 +70,14 @@ > } > } > > +//===----------------------------------------------------------------------===// > +// Use zap Implementation > +//===----------------------------------------------------------------------===// > > +void Use::zap(Use *Start, const Use *Stop) { > + while (Start != Stop) { > + (Start++)->set(0); > + } Tab. From resistor at mac.com Fri Apr 11 00:11:50 2008 From: resistor at mac.com (Owen Anderson) Date: Fri, 11 Apr 2008 05:11:50 -0000 Subject: [llvm-commits] [llvm] r49516 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp Message-ID: <200804110511.m3B5BowI007350@zion.cs.uiuc.edu> Author: resistor Date: Fri Apr 11 00:11:49 2008 New Revision: 49516 URL: http://llvm.org/viewvc/llvm-project?rev=49516&view=rev Log: Fix PR2213 by simultaneously making GVN more aggressive with the return values of calls and less aggressive with non-readnone calls. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=49516&r1=49515&r2=49516&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Fri Apr 11 00:11:49 2008 @@ -159,7 +159,6 @@ void erase(Value* v); unsigned size(); void setAliasAnalysis(AliasAnalysis* A) { AA = A; } - uint32_t hash_operand(Value* v); }; } @@ -283,14 +282,6 @@ } } -uint32_t ValueTable::hash_operand(Value* v) { - if (CallInst* CI = dyn_cast(v)) - if (!AA->doesNotAccessMemory(CI)) - return nextValueNumber++; - - return lookup_or_add(v); -} - Expression ValueTable::create_expression(CallInst* C) { Expression e; @@ -303,7 +294,7 @@ for (CallInst::op_iterator I = C->op_begin()+1, E = C->op_end(); I != E; ++I) - e.varargs.push_back(hash_operand(*I)); + e.varargs.push_back(lookup_or_add(*I)); return e; } @@ -311,8 +302,8 @@ Expression ValueTable::create_expression(BinaryOperator* BO) { Expression e; - e.firstVN = hash_operand(BO->getOperand(0)); - e.secondVN = hash_operand(BO->getOperand(1)); + e.firstVN = lookup_or_add(BO->getOperand(0)); + e.secondVN = lookup_or_add(BO->getOperand(1)); e.thirdVN = 0; e.function = 0; e.type = BO->getType(); @@ -324,8 +315,8 @@ Expression ValueTable::create_expression(CmpInst* C) { Expression e; - e.firstVN = hash_operand(C->getOperand(0)); - e.secondVN = hash_operand(C->getOperand(1)); + e.firstVN = lookup_or_add(C->getOperand(0)); + e.secondVN = lookup_or_add(C->getOperand(1)); e.thirdVN = 0; e.function = 0; e.type = C->getType(); @@ -337,7 +328,7 @@ Expression ValueTable::create_expression(CastInst* C) { Expression e; - e.firstVN = hash_operand(C->getOperand(0)); + e.firstVN = lookup_or_add(C->getOperand(0)); e.secondVN = 0; e.thirdVN = 0; e.function = 0; @@ -350,9 +341,9 @@ Expression ValueTable::create_expression(ShuffleVectorInst* S) { Expression e; - e.firstVN = hash_operand(S->getOperand(0)); - e.secondVN = hash_operand(S->getOperand(1)); - e.thirdVN = hash_operand(S->getOperand(2)); + e.firstVN = lookup_or_add(S->getOperand(0)); + e.secondVN = lookup_or_add(S->getOperand(1)); + e.thirdVN = lookup_or_add(S->getOperand(2)); e.function = 0; e.type = S->getType(); e.opcode = Expression::SHUFFLE; @@ -363,8 +354,8 @@ Expression ValueTable::create_expression(ExtractElementInst* E) { Expression e; - e.firstVN = hash_operand(E->getOperand(0)); - e.secondVN = hash_operand(E->getOperand(1)); + e.firstVN = lookup_or_add(E->getOperand(0)); + e.secondVN = lookup_or_add(E->getOperand(1)); e.thirdVN = 0; e.function = 0; e.type = E->getType(); @@ -376,9 +367,9 @@ Expression ValueTable::create_expression(InsertElementInst* I) { Expression e; - e.firstVN = hash_operand(I->getOperand(0)); - e.secondVN = hash_operand(I->getOperand(1)); - e.thirdVN = hash_operand(I->getOperand(2)); + e.firstVN = lookup_or_add(I->getOperand(0)); + e.secondVN = lookup_or_add(I->getOperand(1)); + e.thirdVN = lookup_or_add(I->getOperand(2)); e.function = 0; e.type = I->getType(); e.opcode = Expression::INSERT; @@ -389,9 +380,9 @@ Expression ValueTable::create_expression(SelectInst* I) { Expression e; - e.firstVN = hash_operand(I->getCondition()); - e.secondVN = hash_operand(I->getTrueValue()); - e.thirdVN = hash_operand(I->getFalseValue()); + e.firstVN = lookup_or_add(I->getCondition()); + e.secondVN = lookup_or_add(I->getTrueValue()); + e.thirdVN = lookup_or_add(I->getFalseValue()); e.function = 0; e.type = I->getType(); e.opcode = Expression::SELECT; @@ -402,7 +393,7 @@ Expression ValueTable::create_expression(GetElementPtrInst* G) { Expression e; - e.firstVN = hash_operand(G->getPointerOperand()); + e.firstVN = lookup_or_add(G->getPointerOperand()); e.secondVN = 0; e.thirdVN = 0; e.function = 0; @@ -411,7 +402,7 @@ for (GetElementPtrInst::op_iterator I = G->idx_begin(), E = G->idx_end(); I != E; ++I) - e.varargs.push_back(hash_operand(*I)); + e.varargs.push_back(lookup_or_add(*I)); return e; } @@ -428,7 +419,7 @@ return VI->second; if (CallInst* C = dyn_cast(V)) { - if (AA->onlyReadsMemory(C)) { // includes doesNotAccessMemory + if (AA->doesNotAccessMemory(C)) { Expression e = create_expression(C); DenseMap::iterator EI = expressionNumbering.find(e); From resistor at mac.com Fri Apr 11 00:13:33 2008 From: resistor at mac.com (Owen Anderson) Date: Fri, 11 Apr 2008 05:13:33 -0000 Subject: [llvm-commits] [llvm] r49517 - /llvm/trunk/test/Transforms/GVN/call.ll Message-ID: <200804110513.m3B5DXDa007403@zion.cs.uiuc.edu> Author: resistor Date: Fri Apr 11 00:13:32 2008 New Revision: 49517 URL: http://llvm.org/viewvc/llvm-project?rev=49517&view=rev Log: Add testcase for PR2213. Added: llvm/trunk/test/Transforms/GVN/call.ll Added: llvm/trunk/test/Transforms/GVN/call.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/call.ll?rev=49517&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GVN/call.ll (added) +++ llvm/trunk/test/Transforms/GVN/call.ll Fri Apr 11 00:13:32 2008 @@ -0,0 +1,12 @@ +; RUN: llvm-as < %s | opt -gvn | llvm-dis | not grep tmp2 +; PR2213 + +define i32* @f(i8* %x) { +entry: + %tmp = call i8* @m( i32 12 ) ; [#uses=2] + %tmp1 = bitcast i8* %tmp to i32* ; [#uses=0] + %tmp2 = bitcast i8* %tmp to i32* ; [#uses=0] + ret i32* %tmp2 +} + +declare i8* @m(i32) From ggreif at gmail.com Fri Apr 11 02:00:04 2008 From: ggreif at gmail.com (Gabor Greif) Date: Fri, 11 Apr 2008 07:00:04 -0000 Subject: [llvm-commits] [llvm] r49519 - in /llvm/branches/ggreif/use-diet: include/llvm/User.h lib/VMCore/Use.cpp Message-ID: <200804110700.m3B704S5010320@zion.cs.uiuc.edu> Author: ggreif Date: Fri Apr 11 02:00:04 2008 New Revision: 49519 URL: http://llvm.org/viewvc/llvm-project?rev=49519&view=rev Log: detabify Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49519&r1=49518&r2=49519&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/User.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/User.h Fri Apr 11 02:00:04 2008 @@ -200,19 +200,19 @@ struct OperandTraits { static inline Use *op_begin(User*); static inline Use *op_end(User*); - static inline unsigned operands(const User*); + static inline unsigned operands(const User*); template - struct Layout { - typedef U overlay; - }; - static inline void *allocate(unsigned); + struct Layout { + typedef U overlay; + }; + static inline void *allocate(unsigned); }; class User : public Value { User(const User &); // Do not implement void *operator new(size_t); // Do not implement template - friend struct HungoffOperandTraits; + friend struct HungoffOperandTraits; protected: /// OperandList - This is a pointer to the array of Users for this operand. /// For nodes of fixed arity (e.g. a binary operator) this array will live @@ -248,15 +248,15 @@ } public: template Use &Op() { - return OperandTraits::op_begin(this)[Idx]; - } + return OperandTraits::op_begin(this)[Idx]; + } template const Use &Op() const { - return OperandTraits::op_begin(const_cast(this))[Idx]; - } + return OperandTraits::op_begin(const_cast(this))[Idx]; + } inline Use *allocHangoffUses(unsigned) const; void dropHungoffUses(Use *U) { U->zap(U, U->getImpliedUser()); - } + } Value *getOperand(unsigned i) const { assert(i < NumOperands && "getOperand() out of range!"); @@ -306,25 +306,25 @@ }; inline Use *OperandTraits::op_begin(User *U) { - return U->op_begin(); + return U->op_begin(); } inline Use *OperandTraits::op_end(User *U) { - return U->op_end(); + return U->op_end(); } inline unsigned OperandTraits::operands(const User *U) { - return U->getNumOperands(); + return U->getNumOperands(); } - /* - static inline void *allocate(unsigned); + /* + static inline void *allocate(unsigned); }; - */ + */ Use *User::allocHangoffUses(unsigned N) const { Use *Begin = static_cast(::operator new(sizeof(Use) * N)); - Use::initTags(Begin, Begin + N); - return Begin; + Use::initTags(Begin, Begin + N); + return Begin; } template<> struct simplify_type { Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp?rev=49519&r1=49518&r2=49519&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Fri Apr 11 02:00:04 2008 @@ -76,8 +76,8 @@ void Use::zap(Use *Start, const Use *Stop) { while (Start != Stop) { - (Start++)->set(0); - } + (Start++)->set(0); + } } } // End llvm namespace From ggreif at gmail.com Fri Apr 11 02:12:28 2008 From: ggreif at gmail.com (Gabor Greif) Date: Fri, 11 Apr 2008 07:12:28 -0000 Subject: [llvm-commits] [llvm] r49522 - in /llvm/branches/ggreif/use-diet: include/llvm/OperandTraits.h lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Reader/BitcodeReader.h Message-ID: <200804110712.m3B7CSBD010652@zion.cs.uiuc.edu> Author: ggreif Date: Fri Apr 11 02:12:28 2008 New Revision: 49522 URL: http://llvm.org/viewvc/llvm-project?rev=49522&view=rev Log: more detabification Modified: llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h Modified: llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h?rev=49522&r1=49521&r2=49522&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h Fri Apr 11 02:12:28 2008 @@ -24,25 +24,25 @@ template struct FixedNumOperandTraits { static Use *op_begin(User* U) { - return reinterpret_cast(U) - ARITY; - } + return reinterpret_cast(U) - ARITY; + } static Use *op_end(User* U) { - return reinterpret_cast(U); - } - static unsigned operands(const User*) { - return ARITY; - } - struct prefix { - Use Ops[ARITY]; - prefix(); // DO NOT IMPLEMENT - }; + return reinterpret_cast(U); + } + static unsigned operands(const User*) { + return ARITY; + } + struct prefix { + Use Ops[ARITY]; + prefix(); // DO NOT IMPLEMENT + }; template - struct Layout { - struct overlay : prefix, U { - overlay(); // DO NOT IMPLEMENT - }; - }; - static inline void *allocate(unsigned); // FIXME + struct Layout { + struct overlay : prefix, U { + overlay(); // DO NOT IMPLEMENT + }; + }; + static inline void *allocate(unsigned); // FIXME }; //===----------------------------------------------------------------------===// @@ -74,12 +74,12 @@ /// Macro for generating out-of-class operand accessor definitions #define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS) \ VALUECLASS *CLASS::getOperand(unsigned i) const { \ - assert(i < OperandTraits::operands(this) && "getOperand() out of range!"); \ - return OperandTraits::op_begin(const_cast(this))[i]; \ + assert(i < OperandTraits::operands(this) && "getOperand() out of range!"); \ + return OperandTraits::op_begin(const_cast(this))[i]; \ } \ void CLASS::setOperand(unsigned i, VALUECLASS *Val) { \ - assert(i < OperandTraits::operands(this) && "setOperand() out of range!"); \ - OperandTraits::op_begin(this)[i] = Val; \ + assert(i < OperandTraits::operands(this) && "setOperand() out of range!"); \ + OperandTraits::op_begin(this)[i] = Val; \ } \ unsigned CLASS::getNumOperands() const { return OperandTraits::operands(this); } \ template Use &CLASS::Op() { \ Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp?rev=49522&r1=49521&r2=49522&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp Fri Apr 11 02:12:28 2008 @@ -138,7 +138,7 @@ } - // FIXME: can we inherit this from ConstantExpr? + // FIXME: can we inherit this from ConstantExpr? template <> struct OperandTraits : FixedNumOperandTraits<1> { }; @@ -148,14 +148,14 @@ void BitcodeReaderValueList::resize(unsigned Desired) { unsigned Capacity = 0; - if (OperandList) { - Capacity = OperandList->getImpliedUser() - OperandList; - } - - if (Desired > Capacity) - { - // FIXME - } + if (OperandList) { + Capacity = OperandList->getImpliedUser() - OperandList; + } + + if (Desired > Capacity) + { + // FIXME + } } Constant *BitcodeReaderValueList::getConstantFwdRef(unsigned Idx, Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h?rev=49522&r1=49521&r2=49522&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h (original) +++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h Fri Apr 11 02:12:28 2008 @@ -53,11 +53,11 @@ BitcodeReaderValueList() : User(Type::VoidTy, Value::ArgumentVal, 0, 0) {} /// Provide fast operand accessors - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); // vector compatibility methods unsigned size() const { return getNumOperands(); } - void resize(unsigned); + void resize(unsigned); void push_back(Value *V) { // Uses.push_back(Use(V, this)); // OperandList = &Uses[0]; From nicolas.geoffray at lip6.fr Fri Apr 11 02:22:32 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 11 Apr 2008 07:22:32 -0000 Subject: [llvm-commits] [vmkit] r49523 - /vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp Message-ID: <200804110722.m3B7MWfY010965@zion.cs.uiuc.edu> Author: geoffray Date: Fri Apr 11 02:22:31 2008 New Revision: 49523 URL: http://llvm.org/viewvc/llvm-project?rev=49523&view=rev Log: Typo in acons name Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp?rev=49523&r1=49522&r2=49523&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp Fri Apr 11 02:22:31 2008 @@ -249,7 +249,7 @@ module); LongAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - " _ZN5jnjvm9ArrayLong5aconsEiPNS_10ClassArrayEPNS_5JnjvmE", + "_ZN5jnjvm9ArrayLong5aconsEiPNS_10ClassArrayEPNS_5JnjvmE", module); ObjectAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, From resistor at mac.com Fri Apr 11 02:52:33 2008 From: resistor at mac.com (Owen Anderson) Date: Fri, 11 Apr 2008 02:52:33 -0500 Subject: [llvm-commits] [vmkit] r49523 - /vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp In-Reply-To: <200804110722.m3B7MWfY010965@zion.cs.uiuc.edu> References: <200804110722.m3B7MWfY010965@zion.cs.uiuc.edu> Message-ID: <1F7CE341-1972-4EA7-A66C-161D96AFCD83@mac.com> On Apr 11, 2008, at 2:22 AM, Nicolas Geoffray wrote: > LongAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, > - " > _ZN5jnjvm9ArrayLong5aconsEiPNS_10ClassArrayEPNS_5JnjvmE", > + > "_ZN5jnjvm9ArrayLong5aconsEiPNS_10ClassArrayEPNS_5JnjvmE", > module); > > ObjectAconsLLVM = Function::Create(type, > GlobalValue::ExternalLinkage, > For the record that's, um, kind of horrible. Could you perhaps make a wrapper function in extern "C" that calls into the Array one? That way you wouldn't have to encode the C++ name mangling, and perhaps make it more portable to Win32, or anything that doesn't use Itanium ABI mangling. --Owen -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2555 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080411/79945b68/attachment.bin From echristo at apple.com Fri Apr 11 02:57:37 2008 From: echristo at apple.com (Eric Christopher) Date: Fri, 11 Apr 2008 00:57:37 -0700 Subject: [llvm-commits] [vmkit] r49523 - /vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp In-Reply-To: <1F7CE341-1972-4EA7-A66C-161D96AFCD83@mac.com> References: <200804110722.m3B7MWfY010965@zion.cs.uiuc.edu> <1F7CE341-1972-4EA7-A66C-161D96AFCD83@mac.com> Message-ID: On Apr 11, 2008, at 12:52 AM, Owen Anderson wrote: > > On Apr 11, 2008, at 2:22 AM, Nicolas Geoffray wrote: >> LongAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, >> - " >> _ZN5jnjvm9ArrayLong5aconsEiPNS_10ClassArrayEPNS_5JnjvmE", >> + >> "_ZN5jnjvm9ArrayLong5aconsEiPNS_10ClassArrayEPNS_5JnjvmE", >> module); >> >> ObjectAconsLLVM = Function::Create(type, >> GlobalValue::ExternalLinkage, >> > > For the record that's, um, kind of horrible. Could you perhaps make > a wrapper function in extern "C" that calls into the Array one? > That way you wouldn't have to encode the C++ name mangling, and > perhaps make it more portable to Win32, or anything that doesn't use > Itanium ABI mangling. FWIW I have an idea of a Function::Create that takes a mangler function as an option and will mangle the name as it creates the instruction. Just haven't gotten to it yet. -eric From nicolas.geoffray at lip6.fr Fri Apr 11 03:28:45 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 11 Apr 2008 10:28:45 +0200 Subject: [llvm-commits] [vmkit] r49523 - /vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp In-Reply-To: References: <200804110722.m3B7MWfY010965@zion.cs.uiuc.edu> <1F7CE341-1972-4EA7-A66C-161D96AFCD83@mac.com> Message-ID: <47FF213D.9040204@lip6.fr> Eric Christopher wrote: > > FWIW I have an idea of a Function::Create that takes a mangler > function as an option and will mangle the name as it creates the > instruction. > > Just haven't gotten to it yet. > Great, that's the kind of thing I was waiting for, before making my code less horrible ;-). Nicolas > -eric > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From ggreif at gmail.com Fri Apr 11 04:34:58 2008 From: ggreif at gmail.com (Gabor Greif) Date: Fri, 11 Apr 2008 09:34:58 -0000 Subject: [llvm-commits] [llvm] r49524 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Message-ID: <200804110934.m3B9Ywno023217@zion.cs.uiuc.edu> Author: ggreif Date: Fri Apr 11 04:34:57 2008 New Revision: 49524 URL: http://llvm.org/viewvc/llvm-project?rev=49524&view=rev Log: detabify Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=49524&r1=49523&r2=49524&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Apr 11 04:34:57 2008 @@ -3507,7 +3507,7 @@ for (; Op != E; ++Op) { if (*Op == From) { From.Val->removeUser(Op-User->op_begin(), User); - *Op = To; + *Op = To; Op->setUser(User); To.Val->addUser(Op-User->op_begin(), User); } From ggreif at gmail.com Fri Apr 11 05:15:42 2008 From: ggreif at gmail.com (Gabor Greif) Date: Fri, 11 Apr 2008 10:15:42 -0000 Subject: [llvm-commits] [llvm] r49525 - in /llvm/branches/ggreif/use-diet: include/llvm/OperandTraits.h lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Reader/BitcodeReader.h Message-ID: <200804111015.m3BAFgI0024376@zion.cs.uiuc.edu> Author: ggreif Date: Fri Apr 11 05:15:41 2008 New Revision: 49525 URL: http://llvm.org/viewvc/llvm-project?rev=49525&view=rev Log: implement more bits of BitcodeReader. move HungoffOperand to OperandTraits.h Modified: llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h Modified: llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h?rev=49525&r1=49524&r2=49525&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h Fri Apr 11 05:15:41 2008 @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // -// This file defines the FIXME. +// This file defines the traits classes that are handy for enforcing the correct +// layout of various User subclasses. It also provides the means for accessing +// the operands in the most efficient manner. // #ifndef LLVM_OPERAND_TRAITS_H @@ -63,6 +65,24 @@ static inline void *allocate(unsigned); // FIXME }; +//===----------------------------------------------------------------------===// +// HungoffOperand Trait Class +//===----------------------------------------------------------------------===// + +template +struct HungoffOperandTraits { + static Use *op_begin(User* U) { + return U->OperandList; + } + static Use *op_end(User* U) { + return U->OperandList + U->getNumOperands(); + } + static unsigned operands(const User *U) { + return U->getNumOperands(); + } + static inline void *allocate(unsigned); // FIXME +}; + /// Macro for generating in-class operand accessor declarations #define DECLARE_TRANSPARENT_OPERAND_ACCESSORS(VALUECLASS) \ inline VALUECLASS *getOperand(unsigned) const; \ Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp?rev=49525&r1=49524&r2=49525&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp Fri Apr 11 05:15:41 2008 @@ -154,7 +154,10 @@ if (Desired > Capacity) { - // FIXME + Use *New = allocHangoffUses(Desired); + for (int i(getNumOperands() - 1); i >= 0; --i) + New[i] = getOperand(i); + OperandList = New; } } Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h?rev=49525&r1=49524&r2=49525&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h (original) +++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h Fri Apr 11 05:15:41 2008 @@ -27,24 +27,6 @@ class MemoryBuffer; //===----------------------------------------------------------------------===// -// HungoffOperand Trait Class -//===----------------------------------------------------------------------===// - -template -struct HungoffOperandTraits { - static Use *op_begin(User* U) { - return U->OperandList; - } - static Use *op_end(User* U) { - return U->OperandList + U->getNumOperands(); - } - static unsigned operands(const User *U) { - return U->getNumOperands(); - } - static inline void *allocate(unsigned); // FIXME -}; - -//===----------------------------------------------------------------------===// // BitcodeReaderValueList Class //===----------------------------------------------------------------------===// @@ -59,8 +41,6 @@ unsigned size() const { return getNumOperands(); } void resize(unsigned); void push_back(Value *V) { -// Uses.push_back(Use(V, this)); -// OperandList = &Uses[0]; ++NumOperands; } @@ -75,8 +55,6 @@ bool empty() const { return NumOperands == 0; } void shrinkTo(unsigned N) { assert(N <= NumOperands && "Invalid shrinkTo request!"); -// Uses.resize(N); -// NumOperands = N; while (NumOperands > N) pop_back(); } @@ -100,8 +78,12 @@ private: void initVal(unsigned Idx, Value *V) { -// assert(Uses[Idx] == 0 && "Cannot init an already init'd Use!"); -// Uses[Idx].init(V, this); + if (Idx >= size()) { + // Insert a bunch of null values. + resize(Idx * 2 + 1); + } + assert(getOperand(Idx) == 0 && "Cannot init an already init'd Use!"); + OperandList[Idx].init(V, this); } }; From ggreif at gmail.com Fri Apr 11 06:22:09 2008 From: ggreif at gmail.com (Gabor Greif) Date: Fri, 11 Apr 2008 11:22:09 -0000 Subject: [llvm-commits] [llvm] r49526 - in /llvm/branches/ggreif/use-diet/include/llvm: Use.h Value.h Message-ID: <200804111122.m3BBMAYq026779@zion.cs.uiuc.edu> Author: ggreif Date: Fri Apr 11 06:22:04 2008 New Revision: 49526 URL: http://llvm.org/viewvc/llvm-project?rev=49526&view=rev Log: implement transferTag and use it in Use::init and Use::set Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h llvm/branches/ggreif/use-diet/include/llvm/Value.h Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Use.h?rev=49526&r1=49525&r2=49526&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Use.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Use.h Fri Apr 11 06:22:04 2008 @@ -80,6 +80,9 @@ static Value *stripTag(Value *V) { return reinterpret_cast(reinterpret_cast(V) & ~3UL); } + Value *transferTag(Value *V) { + return reinterpret_cast(reinterpret_cast(V) + (reinterpret_cast(Val) & ~3UL)); + } void addToList(Use **List) { Next = *List; if (Next) Next->Prev = &Next; Modified: llvm/branches/ggreif/use-diet/include/llvm/Value.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Value.h?rev=49526&r1=49525&r2=49526&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Value.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Value.h Fri Apr 11 06:22:04 2008 @@ -223,15 +223,15 @@ return OS; } -void Use::init(Value *v, User *user) { - Val = v; +void Use::init(Value *V, User *user) { + Val = transferTag(V); U = user; - if (Val) Val->addUse(*this); + if (V) V->addUse(*this); } void Use::set(Value *V) { - if (Val) removeFromList(); - Val = V; + if (stripTag(Val)) removeFromList(); + Val = transferTag(V); if (V) V->addUse(*this); } From ggreif at gmail.com Fri Apr 11 07:29:51 2008 From: ggreif at gmail.com (Gabor Greif) Date: Fri, 11 Apr 2008 12:29:51 -0000 Subject: [llvm-commits] [llvm] r49527 - in /llvm/branches/ggreif/use-diet: include/llvm/Use.h lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Reader/BitcodeReader.h Message-ID: <200804111229.m3BCTqSs028739@zion.cs.uiuc.edu> Author: ggreif Date: Fri Apr 11 07:29:35 2008 New Revision: 49527 URL: http://llvm.org/viewvc/llvm-project?rev=49527&view=rev Log: small(ish) fixes :-> Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Use.h?rev=49527&r1=49526&r2=49527&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Use.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Use.h Fri Apr 11 07:29:35 2008 @@ -81,7 +81,7 @@ return reinterpret_cast(reinterpret_cast(V) & ~3UL); } Value *transferTag(Value *V) { - return reinterpret_cast(reinterpret_cast(V) + (reinterpret_cast(Val) & ~3UL)); + return reinterpret_cast(reinterpret_cast(V) + (reinterpret_cast(Val) & 3UL)); } void addToList(Use **List) { Next = *List; Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp?rev=49527&r1=49526&r2=49527&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp Fri Apr 11 07:29:35 2008 @@ -157,7 +157,9 @@ Use *New = allocHangoffUses(Desired); for (int i(getNumOperands() - 1); i >= 0; --i) New[i] = getOperand(i); + Use *Old = OperandList; OperandList = New; + dropHungoffUses(Old); } } Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h?rev=49527&r1=49526&r2=49527&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h (original) +++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h Fri Apr 11 07:29:35 2008 @@ -41,6 +41,8 @@ unsigned size() const { return getNumOperands(); } void resize(unsigned); void push_back(Value *V) { + resize(NumOperands + 1); + setOperand(NumOperands, V); ++NumOperands; } From ggreif at gmail.com Fri Apr 11 08:05:15 2008 From: ggreif at gmail.com (Gabor Greif) Date: Fri, 11 Apr 2008 13:05:15 -0000 Subject: [llvm-commits] [llvm] r49528 - in /llvm/branches/ggreif/use-diet/lib/Bitcode/Reader: BitcodeReader.cpp BitcodeReader.h Message-ID: <200804111305.m3BD5Guc029705@zion.cs.uiuc.edu> Author: ggreif Date: Fri Apr 11 08:05:14 2008 New Revision: 49528 URL: http://llvm.org/viewvc/llvm-project?rev=49528&view=rev Log: squash more bugs Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp?rev=49528&r1=49527&r2=49528&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp Fri Apr 11 08:05:14 2008 @@ -159,7 +159,7 @@ New[i] = getOperand(i); Use *Old = OperandList; OperandList = New; - dropHungoffUses(Old); + if (Old) dropHungoffUses(Old); } } Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h?rev=49528&r1=49527&r2=49528&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h (original) +++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h Fri Apr 11 08:05:14 2008 @@ -42,8 +42,8 @@ void resize(unsigned); void push_back(Value *V) { resize(NumOperands + 1); - setOperand(NumOperands, V); ++NumOperands; + setOperand(NumOperands - 1, V); } void clear() { From baldrick at free.fr Fri Apr 11 08:24:43 2008 From: baldrick at free.fr (Duncan Sands) Date: Fri, 11 Apr 2008 13:24:43 -0000 Subject: [llvm-commits] [llvm] r49529 - /llvm/trunk/docs/GCCFEBuildInstrs.html Message-ID: <200804111324.m3BDOh9b030229@zion.cs.uiuc.edu> Author: baldrick Date: Fri Apr 11 08:24:43 2008 New Revision: 49529 URL: http://llvm.org/viewvc/llvm-project?rev=49529&view=rev Log: The Ada front-end from the LLVM 2.2 release cannot be build with GNAT GPL 2006, only with GNAT GPL 2005. Modified: llvm/trunk/docs/GCCFEBuildInstrs.html Modified: llvm/trunk/docs/GCCFEBuildInstrs.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/GCCFEBuildInstrs.html?rev=49529&r1=49528&r2=49529&view=diff ============================================================================== --- llvm/trunk/docs/GCCFEBuildInstrs.html (original) +++ llvm/trunk/docs/GCCFEBuildInstrs.html Fri Apr 11 08:24:43 2008 @@ -92,21 +92,23 @@ systems without some work.

    3. The build requires having a compiler that supports Ada, C and C++. The Ada front-end is written in Ada so an Ada compiler is needed to - build it. Appropriate Ada compilers are gcc-4.2 (or earlier) or the - 2006 GNAT GPL Edition - (or earlier). As a general rule, the Ada compiler used for the - build must not be more recent than the Ada compiler it is building. - This is why the build fails with gcc-4.3 and the 2007 GNAT GPL Edition. + build it. Compilers known to work with the + LLVM 2.2 release + are gcc-4.2 and the + 2005 GNAT GPL Edition. + LLVM from subversion + also works with the + 2006 and 2007 GNAT GPL Editions. The LLVM parts of llvm-gcc are written in C++ so a C++ compiler is needed to build them. The rest of gcc is written in C. Some linux distributions provide a version of gcc that supports all three languages (the Ada part often comes as an add-on package to the rest of gcc). Otherwise it is possible to combine two versions of gcc, one that supports Ada and C (such as the - 2006 GNAT GPL Edition) + 2005 GNAT GPL Edition) and another which supports C++, see below.

    4. Because the Ada front-end is experimental, it is wise to build the - compiler with checking enabled. This causes it to run slower, but + compiler with checking enabled. This causes it to run much slower, but helps catch mistakes in the compiler (please report any problems using LLVM bugzilla).

    From neil at daikokuya.co.uk Fri Apr 11 09:33:10 2008 From: neil at daikokuya.co.uk (Neil Booth) Date: Fri, 11 Apr 2008 23:33:10 +0900 Subject: [llvm-commits] [llvm] r49458 - /llvm/trunk/lib/Transforms/IPO/SimplifyLibCalls.cpp In-Reply-To: <2B008C76-4C5E-415F-A9B7-574BB330DF94@apple.com> References: <200804100207.m3A27ph4015558@zion.cs.uiuc.edu> <200804101325.35656.baldrick@free.fr> <200804101847.00651.baldrick@free.fr> <2B008C76-4C5E-415F-A9B7-574BB330DF94@apple.com> Message-ID: <20080411143310.GF18285@daikokuya.co.uk> Chris Lattner wrote:- > His response: > > I stand behind the claim that the behavior of the pow(x, 0.5) -> sqrt > substitution is incompatible with C99. Here are the exact citations: > > From C99, Annex F (normative): > > F.9.4.4 The pow functions > > ? pow(+-0, y) returns +0 for y > 0 and not an odd integer. > ? pow(-inf, y) returns +inf for y > 0 and not an odd integer. > > F.9.4.5 The sqrt functions > > sqrt is fully specified as a basic arithmetic operation in IEC 60559 > > From IEC 60559 (IEEE 754-1985), section 5.2: > > ... the square root of -0 shall be -0. > > Does that pin things down enough for you? I have no opinion on this, but I'll note that NetBSD's man page says something subtlely different: The function pow(x, y) checks to see if x < 0 and y is not an integer, in the event this is true, the global variable errno is set to EDOM and on the VAX generate a reserved operand fault. I assume we're talking about pow (-0.0, 0.5) here. I'm not sure whether -0.0 qualifies as negative. Clearly it's sign is negative, but it is not less than zero (both being quite reasonable definitions of "negative"). NetBSD's man page removes the ambiguity; on NetBSD this transformation is unambiguously valid, because -0.0 < 0 is false. The choice of the ambiguous adjective "negative" when applied to a value is unfortunate here. It's probably best to ask on comp.std.c what was intended. Personally I would be surprised if the intent was to differ from IEEE 754 as that is what the C standard has been doing its best recently to converge on, as far as is possible. Whereas F.9.4.4 seems clear that pow (-0, 0.5) is +0.0, F.9.1 confusingly states "this subclause contains specifications of facilities that are particularly suited for IEC 60559 implementations." See also F.9.3, which basically claims math.h is intended to be consistent with IEC 60559. Hoho. The fact that -0 is apparently 0.0 after promotion doesn't help either. Hehe. Neil. From ggreif at gmail.com Fri Apr 11 09:56:22 2008 From: ggreif at gmail.com (Gabor Greif) Date: Fri, 11 Apr 2008 14:56:22 -0000 Subject: [llvm-commits] [llvm] r49531 - in /llvm/branches/ggreif/use-diet: include/llvm/Use.h include/llvm/User.h lib/Bitcode/Reader/BitcodeReader.h lib/VMCore/Use.cpp Message-ID: <200804111456.m3BEuMMu032712@zion.cs.uiuc.edu> Author: ggreif Date: Fri Apr 11 09:56:22 2008 New Revision: 49531 URL: http://llvm.org/viewvc/llvm-project?rev=49531&view=rev Log: redefine Use::getUser() to always get the implied one and assert on perceived discrepancies Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h llvm/branches/ggreif/use-diet/include/llvm/User.h llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Use.h?rev=49531&r1=49530&r2=49531&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Use.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Use.h Fri Apr 11 09:56:22 2008 @@ -52,7 +52,7 @@ operator Value*() const { return stripTag(Val); } Value *get() const { return stripTag(Val); } - User *getUser() const { return U; } + User *getUser() const; const Use* getImpliedUser() const; static void initTags(Use *Start, Use *Stop, ptrdiff_t Done = 0); static void zap(Use *Start, const Use *Stop); @@ -81,7 +81,7 @@ return reinterpret_cast(reinterpret_cast(V) & ~3UL); } Value *transferTag(Value *V) { - return reinterpret_cast(reinterpret_cast(V) + (reinterpret_cast(Val) & 3UL)); + return reinterpret_cast(reinterpret_cast(V) | (reinterpret_cast(Val) & 3UL)); } void addToList(Use **List) { Next = *List; Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49531&r1=49530&r2=49531&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/User.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/User.h Fri Apr 11 09:56:22 2008 @@ -322,8 +322,10 @@ */ Use *User::allocHangoffUses(unsigned N) const { - Use *Begin = static_cast(::operator new(sizeof(Use) * N)); - Use::initTags(Begin, Begin + N); + Use *Begin = static_cast(::operator new(sizeof(Use) * N + sizeof this)); + Use *End = Begin + N; + (*(User**)End) = (User*)(ptrdiff_t(this) | 1); + Use::initTags(Begin, End); return Begin; } Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h?rev=49531&r1=49530&r2=49531&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h (original) +++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h Fri Apr 11 09:56:22 2008 @@ -41,9 +41,9 @@ unsigned size() const { return getNumOperands(); } void resize(unsigned); void push_back(Value *V) { - resize(NumOperands + 1); - ++NumOperands; - setOperand(NumOperands - 1, V); + resize(++NumOperands); + OperandList[NumOperands - 1].init(V, this); + //setOperand(NumOperands - 1, V); } void clear() { Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp?rev=49531&r1=49530&r2=49531&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Fri Apr 11 09:56:22 2008 @@ -80,4 +80,20 @@ } } +//===----------------------------------------------------------------------===// +// Use getUser Implementation +//===----------------------------------------------------------------------===// + +User *Use::getUser() const { + const Use* End = getImpliedUser(); + User *She = End->U; + if (ptrdiff_t(She) & 1UL) + She = (User*)(ptrdiff_t(She) & ~1UL); + else + She = (User*)End; + + assert((!U || U == She) && "Implicit User differs?"); + return She; +} + } // End llvm namespace From ggreif at gmail.com Fri Apr 11 10:21:17 2008 From: ggreif at gmail.com (Gabor Greif) Date: Fri, 11 Apr 2008 15:21:17 -0000 Subject: [llvm-commits] [llvm] r49533 - /llvm/branches/ggreif/README Message-ID: <200804111521.m3BFLHDH001080@zion.cs.uiuc.edu> Author: ggreif Date: Fri Apr 11 10:21:17 2008 New Revision: 49533 URL: http://llvm.org/viewvc/llvm-project?rev=49533&view=rev Log: update agenda Modified: llvm/branches/ggreif/README Modified: llvm/branches/ggreif/README URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/README?rev=49533&r1=49532&r2=49533&view=diff ============================================================================== --- llvm/branches/ggreif/README (original) +++ llvm/branches/ggreif/README Fri Apr 11 10:21:17 2008 @@ -54,13 +54,16 @@ WAVE2: Remove Use objects that are embedded in Users. 'operator new' now performs real work. Create wrappers to destructor and 'operator delete' that do the right thing (where needed). + Assertions ensure consistency of stored and computed User in the Use. WAVE3: Flip indexing order of Uses. This involves changing the iterators. + NOTE: This wave is probably void. WAVE4: Remove User* from Use, introducing surrogate getters. Embedded and out-of-object representations being considered. WAVE5: Stylistic and performance tweaks. Valgrind testing. + Doxygenizing of new interfaces. WAVE6: Realizing additional savings. Several space vs. time tradeoffs to be balanced. May involve tweaking some basic interfaces. From ggreif at gmail.com Fri Apr 11 10:40:12 2008 From: ggreif at gmail.com (Gabor Greif) Date: Fri, 11 Apr 2008 15:40:12 -0000 Subject: [llvm-commits] [llvm] r49534 - /llvm/branches/ggreif/use-diet/include/llvm/User.h Message-ID: <200804111540.m3BFeCut001678@zion.cs.uiuc.edu> Author: ggreif Date: Fri Apr 11 10:40:12 2008 New Revision: 49534 URL: http://llvm.org/viewvc/llvm-project?rev=49534&view=rev Log: make sure that the operand list is zapped on destruction Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49534&r1=49533&r2=49534&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/User.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/User.h Fri Apr 11 10:40:12 2008 @@ -239,11 +239,14 @@ User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps) : Value(Ty, vty), OperandList(OpList), NumOperands(NumOps) {} public: + ~User() { + Use::zap(OperandList, OperandList + NumOperands); + } void operator delete(void *Usr) { User *Start = static_cast(Usr); Use *Storage = static_cast(Usr) - Start->NumOperands; if (Storage == Start->OperandList) - ::operator delete(Storage); // FIXME: destructors of Uses? + ::operator delete(Storage); else ::operator delete(Usr); } public: @@ -255,7 +258,7 @@ } inline Use *allocHangoffUses(unsigned) const; void dropHungoffUses(Use *U) { - U->zap(U, U->getImpliedUser()); + Use::zap(U, U->getImpliedUser()); } Value *getOperand(unsigned i) const { From jon at alacatialabs.com Fri Apr 11 10:56:31 2008 From: jon at alacatialabs.com (Jonathan Johnson) Date: Fri, 11 Apr 2008 10:56:31 -0500 Subject: [llvm-commits] CVS: llvm-www/devmtg/current/index.html Message-ID: <200804111556.m3BFuVUL002512@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/current: index.html updated: 1.8 -> 1.9 --- Log message: Added additional attendees. --- Diffs of the changes: (+7 -1) index.html | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletion(-) Index: llvm-www/devmtg/current/index.html diff -u llvm-www/devmtg/current/index.html:1.8 llvm-www/devmtg/current/index.html:1.9 --- llvm-www/devmtg/current/index.html:1.8 Mon Mar 31 10:42:21 2008 +++ llvm-www/devmtg/current/index.html Fri Apr 11 10:55:44 2008 @@ -43,10 +43,12 @@ Unconfirmed Attendees NameOrganization Owen AndersonApple, Inc. + Daniel BerlinGoogle Chandler Carruth Evan ChengApple, Inc. Eric ChristopherApple, Inc. Samuel Crow + Ryan GovostesAlacatia Labs, Inc. Kurt HarrimanGreenplum Robert HundtGoogle Dale JohannesenApple, Inc. @@ -54,19 +56,23 @@ Ted KremenekApple, Inc. Chris LattnerApple, Inc. Nick LewyckyGoogle + Bruno Cardoso Lopes + Nuno Lopes Harry Metcalfe Steve NaroffApple, Inc. Ted Neward Devang PatelApple, Inc. Joseph RanieriAlacatia Labs, Inc. Chuck RoseAdobe Systems Incorporated + Tim Sander Robert StaudingerUniversity of Salzburg, Austria + Joe StroutInspiring Applications, Inc. Mike StumpApple, Inc. Bill WendlingApple, Inc. Robert Zeh Chuck (Chengyan) ZhaoUniversity of Toronto -

    Total unconfirmed: 23

    +

    Total unconfirmed: 29

    If your name is misspelled, or organization affiliation isn't correct, please email us, and we'll correct it. From baldrick at free.fr Fri Apr 11 11:11:25 2008 From: baldrick at free.fr (Duncan Sands) Date: Fri, 11 Apr 2008 18:11:25 +0200 Subject: [llvm-commits] =?ansi_x3.4-1968?q?=5Bllvm-gcc-4=2E2=5D_r49171_-_i?= =?ansi_x3.4-1968?q?n=09/llvm-gcc-4=2E2/trunk/gcc=3A_llvm-convert=2Ecpp_ll?= =?ansi_x3.4-1968?q?vm-types=2Ecpp?= In-Reply-To: References: <200804031727.m33HRR6h004565@zion.cs.uiuc.edu> <200804080858.56612.baldrick@free.fr> Message-ID: <200804111811.26652.baldrick@free.fr> > >>>> I think a point I made earlier has gotten lost: it is not possible > >>>> to > >>>> handle this without changing the linker. > >>> > >>> I've created PR2205 for this. > >> > >> What about the case when system linker (e.g. gnu ld or darwin ld on > >> Mac OS X) ? > > > > Do you mean when doing LTO? > > No. > > I mean, when two separate source files with conflicting (or rather not > matching) declarations are compiled into the native .o files and > linked together using system linker. It should be fine - these attributes have no impact on what turns up in the .o as far as I can see (not talking about the code for a function definition, which is influenced by the attributes the optimizers see). Ciao, Duncan. From nicolas.geoffray at lip6.fr Fri Apr 11 11:20:49 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 11 Apr 2008 16:20:49 -0000 Subject: [llvm-commits] [vmkit] r49536 - in /vmkit/trunk: ./ include/mvm/ include/mvm/GC/ include/mvm/Threads/ lib/JnJVM/ lib/JnJVM/Classpath/ lib/JnJVM/VMCore/ lib/Mvm/ lib/Mvm/Allocator/ lib/Mvm/CommonThread/ lib/Mvm/GCMmap2/ lib/N3/ lib/N3/VMCore/ Message-ID: <200804111620.m3BGKoKO003229@zion.cs.uiuc.edu> Author: geoffray Date: Fri Apr 11 11:20:48 2008 New Revision: 49536 URL: http://llvm.org/viewvc/llvm-project?rev=49536&view=rev Log: vmkit can now use boehmgc Modified: vmkit/trunk/NEWS vmkit/trunk/configure.ac vmkit/trunk/include/mvm/GC/GC.h vmkit/trunk/include/mvm/Method.h vmkit/trunk/include/mvm/Object.h vmkit/trunk/include/mvm/PrintBuffer.h vmkit/trunk/include/mvm/Threads/Cond.h vmkit/trunk/include/mvm/Threads/Key.h vmkit/trunk/include/mvm/Threads/Locks.h vmkit/trunk/include/mvm/Threads/Thread.h vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp vmkit/trunk/lib/JnJVM/Classpath/Makefile.am vmkit/trunk/lib/JnJVM/Main.cpp vmkit/trunk/lib/JnJVM/Makefile.am vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h vmkit/trunk/lib/JnJVM/VMCore/Makefile.am vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp vmkit/trunk/lib/Mvm/Allocator/Makefile.am vmkit/trunk/lib/Mvm/CommandLine.cpp vmkit/trunk/lib/Mvm/CommonThread/Makefile.am vmkit/trunk/lib/Mvm/GCMmap2/Makefile.am vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h vmkit/trunk/lib/Mvm/Main.cpp vmkit/trunk/lib/Mvm/Makefile.am vmkit/trunk/lib/Mvm/MvmMemoryManager.cpp vmkit/trunk/lib/Mvm/Object.cpp vmkit/trunk/lib/Mvm/Sigsegv.cpp vmkit/trunk/lib/Mvm/VTOffset.cpp vmkit/trunk/lib/N3/Main.cpp vmkit/trunk/lib/N3/Makefile.am vmkit/trunk/lib/N3/VMCore/Assembly.cpp vmkit/trunk/lib/N3/VMCore/Assembly.h vmkit/trunk/lib/N3/VMCore/BackTrace.cpp vmkit/trunk/lib/N3/VMCore/CLIJit.cpp vmkit/trunk/lib/N3/VMCore/CLIJit.h vmkit/trunk/lib/N3/VMCore/LockedMap.h vmkit/trunk/lib/N3/VMCore/Makefile.am vmkit/trunk/lib/N3/VMCore/N3.cpp vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp vmkit/trunk/lib/N3/VMCore/PNetLib.cpp vmkit/trunk/lib/N3/VMCore/VMClass.h vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp Modified: vmkit/trunk/NEWS URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/NEWS?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/NEWS (original) +++ vmkit/trunk/NEWS Fri Apr 11 11:20:48 2008 @@ -1,3 +1,6 @@ +(April 11, 2008) +* Interface with boehm-gc + (March 21, 2008) * VMKit goes public! Modified: vmkit/trunk/configure.ac URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/configure.ac?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/configure.ac (original) +++ vmkit/trunk/configure.ac Fri Apr 11 11:20:48 2008 @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script -AC_INIT([micro-vm],[0.0.1]) +AC_INIT([vmkit],[0.0.1]) AC_PREREQ([2.59]) AC_CONFIG_SRCDIR([lib/Mvm/Main.cpp]) @@ -28,17 +28,6 @@ esac AM_CONDITIONAL(IS_LINUX, [test x$is_linux = xtrue]) -echo $host -dnl ************************************************************************** -dnl Check system name -dnl ************************************************************************** -case $host in - *linux*) dlsyms_name='dlsyms';; - *darwin*) dlsyms_name='dlsyms';; - *) dlsyms_name='dlsyms-unknow';; -esac -AC_SUBST([dlsyms_name]) - dnl ************************************************************************** dnl Initialize automake with a package version dnl ************************************************************************** @@ -148,13 +137,13 @@ dnl ************************************************************************** dnl VVM thread type dnl ************************************************************************** -AC_ARG_WITH(vvm-thread-type, - [AS_HELP_STRING(--with-vvm-thread-type=something, - [VVM Thread type ('common' or 'no')])], - [vvmthreadtype=$withval],[vvmthreadtype=common] +AC_ARG_WITH(thread, + [AS_HELP_STRING(--with-thread=something, + [Thread type ('common' or 'no')])], + [thread=$withval],[thread=common] ) -AS_IF([test "x$vvmthreadtype" != "xno"], +AS_IF([test "x$thread" != "xno"], [AC_CHECK_HEADER([pthread.h],, [AC_MSG_WARN(phtread include NOT found)]) AC_CHECK_LIB(pthread, pthread_create, [], @@ -162,13 +151,13 @@ ] ) -AM_CONDITIONAL([HAVE_PTHREAD], [test "x$vvmthreadtype" != "xno"]) -if test "x$vvmthreadtype" = xcommon; then +AM_CONDITIONAL([HAVE_PTHREAD], [test "x$thread" != "xno"]) +if test "x$thread" = xcommon; then AC_DEFINE([HAVE_PTHREAD], [1], [Using pthread library]) fi -AC_SUBST([vvmthreadtype]) -GCTHREAD_SUBDIRS="$GCTHREAD_SUBDIRS $vvmthreadtype-thread" +GCTHREAD_LIBS="$PWD/lib/Mvm/CommonThread/libuvm_common_thread.a" +AC_SUBST([GCTHREAD_LIBS]) dnl ************************************************************************** @@ -186,28 +175,41 @@ dnl ************************************************************************** dnl VVM GC type dnl ************************************************************************** -AC_ARG_WITH(vvm-gc-type, - [AS_HELP_STRING(--with-vvm-gc-type=something, - [VVM GC type ('mmap2' or 'boehm')])], - [[vvmgctype=$withval]], +AC_ARG_WITH(gc, + [AS_HELP_STRING(--with-gc=something, + [GC type ('mmap2' or 'boehm')])], + [[gc=$withval]], [[ echo Using mmap2 as vvm gc type. - vvmgctype=mmap2 + gc=mmap2 ]] ) -AC_SUBST([vvmgctype]) -GCTHREAD_SUBDIRS="$GCTHREAD_SUBDIRS gc-$vvmgctype" -AC_SUBST([GCTHREAD_SUBDIRS]) - -GC_DEFINE="" -GC_LIBS="" dnl TODO find the libgc.a -if test "x$vvmgctype" = "xboehm"; then - GC_DEFINE="-DGC_BOEHM" - GC_LIBS="/usr/lib/libgc.a" +if test "x$gc" = "xboehm"; then + AC_CHECK_LIB(gccpp, GC_malloc, [], \ + [AC_MSG_ERROR([You need to install the boehm-gc package (gccpp).])] + ) + AC_CHECK_HEADER([gc/gc.h], [], \ + AC_MSG_ERROR([You need to install the boehm-gc devel package (gc/gc.h).]) + ) + GC_LIBS="-lgccpp -gc" + CFLAGS="$CFLAGS -I$PWD/lib/Mvm/BoehmGC -DGC_THREADS" + CXXFLAGS="$CXXFLAGS -I$PWD/lib/Mvm/BoehmGC -DGC_THREADS" + AC_DEFINE([USE_GC_BOEHM], [1], [Using the boehm gc]) + case $target_os in + *linux*) + CFLAGS="-DGC_LINUX_THREADS" + CXXFLAGS="$CXXFLAGS -DGC_LINUX_THREADS" + ;; + esac +else + GC_LIBS="$PWD/lib/Mvm/GCMmap2/libuvm_gc_mmap2.a \ + $PWD/lib/Mvm/Allocator/libuvm_alloc.a" + CFLAGS="$CFLAGS -I$PWD/lib/Mvm/GCMmap2 -DWITH_TRACER" + CXXFLAGS="$CXXFLAGS -I$PWD/lib/Mvm/GCMmap2 -DWITH_TRACER" + AC_DEFINE([USE_GC_MMAP2], [1], [Using the gcmmap2]) fi -AC_SUBST([GC_DEFINE]) AC_SUBST([GC_LIBS]) dnl ************************************************************************** @@ -248,8 +250,8 @@ echo Using ${gnuclasspathinstallationprefix} as GNU CLASSPATH installation prefix; classpathglibj=${gnuclasspathinstallationprefix}/share/classpath/glibj.zip; classpathlibs=${gnuclasspathinstallationprefix}/lib/classpath/; - CFLAGS=$CFLAGS -I$gnuclasspathinstallationprefix/include - CXXFLAGS=$CXXFLAGS -I$gnuclasspathinstallationprefix/include + CFLAGS="$CFLAGS -I$gnuclasspathinstallationprefix/include" + CXXFLAGS="$CXXFLAGS -I$gnuclasspathinstallationprefix/include" else echo Using ${gnuclasspathlocalprefix} as GNU CLASSPATH local prefix; classpathglibj=${gnuclasspathlocalprefix}/lib/; Modified: vmkit/trunk/include/mvm/GC/GC.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/GC/GC.h?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/include/mvm/GC/GC.h (original) +++ vmkit/trunk/include/mvm/GC/GC.h Fri Apr 11 11:20:48 2008 @@ -15,63 +15,19 @@ typedef void (*gc_lock_recovery_fct_t)(int, int, int, int, int, int, int, int); -class gc; - typedef void VirtualTable; -#define gc_new(Class) __gc_new(Class::VT) Class -class gc { +class gcRoot { public: - virtual ~gc() {} + virtual ~gcRoot() {} virtual void destroyer(size_t) {} virtual void tracer(size_t) {} - - void markAndTrace() const; - size_t objectSize() const; - void * operator new(size_t sz, VirtualTable *VT); - void * operator new(size_t sz); - void operator delete(void *); - void * realloc(size_t n); - }; class gc_header { public: VirtualTable *_XXX_vt; - inline gc *_2gc() { return (gc *)this; } -}; - -class Collector { -public: - - typedef void (*markerFn)(void); - - static void initialise(markerFn mark, void *base_sp); - static void destroy(); - - static void die_if_sigsegv_occured_during_collection(void *addr); - static int isStable(gc_lock_recovery_fct_t, int, int, int, int, - int, int, int, int); - static unsigned int enable(unsigned int n); - static void gcStats(size_t &no, size_t &nbb); - static void maybeCollect(); - static void collect(void); - static void inject_my_thread(void *sp); - static void remove_my_thread(); - static Collector* allocate(); - - static gc *begOf(const void *o); - static int byteOffset(void *o); - inline static bool isObject(const void *o) { return begOf((void*)o); } - static void applyFunc(void (*func)(gc *o, void *data), void *data); - static void registerMemoryError(void (*func)(unsigned int)); - static int getMaxMemory(void); - static int getFreeMemory(void); - static int getTotalMemory(void); - static void setMaxMemory(size_t); - static void setMinMemory(size_t); + inline gcRoot *_2gc() { return (gcRoot *)this; } }; -#define __gc_new new - #endif Modified: vmkit/trunk/include/mvm/Method.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Method.h?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/include/mvm/Method.h (original) +++ vmkit/trunk/include/mvm/Method.h Fri Apr 11 11:20:48 2008 @@ -43,19 +43,18 @@ public: inline Code() {} static VirtualTable* VT; - static void *allocate(size_t _nbb, void* metaInfo); + Method* meth; inline Method *method(Method *m, size_t nbb) { - return - (Method *)gcset((gc **)((uintptr_t)this + nbb), m); + return (meth = m); } inline Method *method(size_t nbb) { - return ((Method **)((uintptr_t)this + nbb))[0]; + return meth; } - inline Method *method(Method *m) { return method(m, objectSize()); } - inline Method *method() { return method(objectSize()); } + inline Method *method(Method *m) { return meth = m; } + inline Method *method() { return meth; } virtual void print(PrintBuffer *buf) const; virtual void tracer(size_t sz); @@ -65,19 +64,18 @@ public: inline ExceptionTable() {} static VirtualTable* VT; + void* framePtr; inline void *frameRegister(void *m, size_t nbb) { - return - (void *)gcset((gc **)((uintptr_t)this + nbb), - (Object*)m); + return (framePtr = m); } inline void *frameRegister(size_t nbb) { - return ((void **)((uintptr_t)this + nbb))[0]; + return framePtr; } - inline void *frameRegister(void *m) { return frameRegister(m, objectSize()); } - inline void *frameRegister() { return frameRegister(objectSize()); } + inline void *frameRegister(void *m) { return (framePtr = m); } + inline void *frameRegister() { return framePtr; } virtual void destroyer(size_t sz); }; Modified: vmkit/trunk/include/mvm/Object.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Object.h?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/include/mvm/Object.h (original) +++ vmkit/trunk/include/mvm/Object.h Fri Apr 11 11:20:48 2008 @@ -13,7 +13,7 @@ #include #include "types.h" -#include "mvm/GC/GC.h" +#include "MvmGC.h" namespace mvm { Modified: vmkit/trunk/include/mvm/PrintBuffer.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/PrintBuffer.h?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/include/mvm/PrintBuffer.h (original) +++ vmkit/trunk/include/mvm/PrintBuffer.h Fri Apr 11 11:20:48 2008 @@ -23,22 +23,22 @@ static VirtualTable* VT; - inline char *cString() { return (char *)(this + 1); } + inline char *cString() { return (char *)(this + 1); } inline static NativeString *readString(char *cStr) { - size_t nbb = strlen(cStr); - NativeString * res = alloc(nbb + 1); - memcpy(res->cString(), cStr, nbb + 1); - return res; - } - - static inline NativeString *alloc(size_t len) { - return (NativeString *)gc::operator new(len, VT); - } - - inline NativeString *realloc(size_t len) { - return (NativeString *)gc::realloc(len); - } + size_t nbb = strlen(cStr); + NativeString * res = alloc(nbb + 1); + memcpy(res->cString(), cStr, nbb + 1); + return res; + } + + static inline NativeString *alloc(size_t len) { + return (NativeString *)gc::operator new(len, VT); + } + + inline NativeString *realloc(size_t len) { + return (NativeString *)gc::realloc(len); + } inline void setAt(int pos, char c) { cString()[pos] = c; @@ -70,16 +70,16 @@ PrintBuffer* pbf = gc_new(PrintBuffer)(); pbf->capacity= 32; pbf->writePosition= 0; - pbf->contents(NativeString::alloc(pbf->capacity)); + pbf->contents(NativeString::alloc(pbf->capacity)); return pbf; } inline PrintBuffer *write(const char *string) { size_t len= strlen(string); if ((writePosition + len + 1) >= capacity) { - while ((writePosition + len + 1) >= capacity) - capacity*= 4; - contents(contents()->realloc(capacity)); + while ((writePosition + len + 1) >= capacity) + capacity*= 4; + contents(contents()->realloc(capacity)); } strcpy(contents()->cString() + writePosition, string); writePosition+= len; @@ -120,19 +120,19 @@ inline PrintBuffer *writeBytes(unsigned char *bytes, size_t len) { write("["); for (size_t idx= 0; idx < len; ++idx) { - if (idx > 0) - write(" "); - char buf[32]; - sprintf(buf, "%d", bytes[idx]); - write(buf); + if (idx > 0) + write(" "); + char buf[32]; + sprintf(buf, "%d", bytes[idx]); + write(buf); } write("]"); return this; } - PrintBuffer *writeObj(const Object *); + PrintBuffer *writeObj(const Object *); - NativeString *getContents(); + NativeString *getContents(); static PrintBuffer *write_static(PrintBuffer*, char *); Modified: vmkit/trunk/include/mvm/Threads/Cond.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/Cond.h?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/include/mvm/Threads/Cond.h (original) +++ vmkit/trunk/include/mvm/Threads/Cond.h Fri Apr 11 11:20:48 2008 @@ -14,7 +14,6 @@ #include "config.h" #endif -#include "mvm/GC/GC.h" #include "mvm/Threads/Locks.h" #include Modified: vmkit/trunk/include/mvm/Threads/Key.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/Key.h?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/include/mvm/Threads/Key.h (original) +++ vmkit/trunk/include/mvm/Threads/Key.h Fri Apr 11 11:20:48 2008 @@ -14,7 +14,7 @@ #include "config.h" #endif -#include "mvm/GC/GC.h" +#include namespace mvm { Modified: vmkit/trunk/include/mvm/Threads/Locks.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/Locks.h?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/include/mvm/Threads/Locks.h (original) +++ vmkit/trunk/include/mvm/Threads/Locks.h Fri Apr 11 11:20:48 2008 @@ -14,63 +14,60 @@ #include "config.h" #endif -#include "mvm/GC/GC.h" - namespace mvm { class SpinLock { - unsigned int value; + unsigned int value; public: - static VirtualTable *VT; - SpinLock() { value = 0; } - - void slock(); - void sunlock() { - value = 0; - } + SpinLock() { value = 0; } + + void slock(); + void sunlock() { + value = 0; + } }; class Lock : public SpinLock { protected: - void (*xlock)(Lock *); - void (*xunlock)(Lock *); - int (*xtrylock)(Lock *); + void (*xlock)(Lock *); + void (*xunlock)(Lock *); + int (*xtrylock)(Lock *); - int _owner; + int _owner; public: - inline Lock() { _owner = 0; } - inline int owner() { return _owner; } - inline void owner(int o) { _owner = o; } - - void lock() { - xlock(this); - } - - void unlock() { - xunlock(this); - } - - int trylock() { - int res = xtrylock(this); - return res; - } - - static Lock *allocNormal(); - static Lock *allocRecursive(); - static void destroy(Lock *); + inline Lock() { _owner = 0; } + inline int owner() { return _owner; } + inline void owner(int o) { _owner = o; } + + void lock() { + xlock(this); + } + + void unlock() { + xunlock(this); + } + + int trylock() { + int res = xtrylock(this); + return res; + } - static bool selfOwner(Lock *); - static int getOwner(Lock *); + static Lock *allocNormal(); + static Lock *allocRecursive(); + static void destroy(Lock *); + + static bool selfOwner(Lock *); + static int getOwner(Lock *); }; class LockNormal : public Lock { - static void my_lock(Lock *); - static void my_unlock(Lock *); - static int my_trylock(Lock *); + static void my_lock(Lock *); + static void my_unlock(Lock *); + static int my_trylock(Lock *); public: - LockNormal() { + LockNormal() { xlock = my_lock; xunlock = my_unlock; xtrylock = my_trylock; } @@ -78,15 +75,15 @@ xlock = my_lock; xunlock = my_unlock; xtrylock = my_trylock; } }; - + class LockRecursive : public Lock { - int n; + int n; - static void my_lock(Lock *); - static void my_unlock(Lock *); - static int my_trylock(Lock *); + static void my_lock(Lock *); + static void my_unlock(Lock *); + static int my_trylock(Lock *); public: - LockRecursive() { + LockRecursive() { xlock = my_lock; xunlock = my_unlock; xtrylock = my_trylock; n = 0; } Modified: vmkit/trunk/include/mvm/Threads/Thread.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/Thread.h?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/include/mvm/Threads/Thread.h (original) +++ vmkit/trunk/include/mvm/Threads/Thread.h Fri Apr 11 11:20:48 2008 @@ -10,8 +10,10 @@ #ifndef MVM_THREAD_H #define MVM_THREAD_H +#include "MvmGC.h" #include "mvm/Threads/Key.h" + class Collector; namespace mvm { Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp Fri Apr 11 11:20:48 2008 @@ -10,7 +10,7 @@ #include #include -#include "mvm/GC/GC.h" +#include "MvmGC.h" #include "llvm/Type.h" Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp (original) +++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp Fri Apr 11 11:20:48 2008 @@ -49,7 +49,7 @@ Collector::inject_my_thread(&argc); JavaObject* vmThread = arg->vmThread; JavaThread* intern = arg->intern; - delete arg; + free(arg); mvm::Thread::threadKey->set(intern); CommonClass* vmthClass = vmThread->classOf; JavaObject* thread = (JavaObject*)((*ClasspathThread::assocThread)(vmThread).PointerVal); Modified: vmkit/trunk/lib/JnJVM/Classpath/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/Makefile.am?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Classpath/Makefile.am (original) +++ vmkit/trunk/lib/JnJVM/Classpath/Makefile.am Fri Apr 11 11:20:48 2008 @@ -1,11 +1,5 @@ lib_LTLIBRARIES = libClasspath.la -THREADDIR=../../Mvm/CommonThread -ALLOCDIR=../../Mvm/Allocator -GCDIR=../../Mvm/GCMmap2 -INCLUDEDIRS=-I at srcdir@/$(THREADDIR) -I at srcdir@/$(ALLOCDIR) -I at srcdir@/$(GCDIR)\ - -I../VMCore - PREFIX=@prefix@ libClasspath_la_SOURCES = \ @@ -17,4 +11,4 @@ ClasspathVMThrowable.h ClasspathVMThrowable.cpp ClasspathMethod.h ClasspathMethod.cpp \ ClasspathVMField.h ClasspathVMField.cpp ClasspathVMStackWalker.cpp ClasspathVMStackWalker.h -libClasspath_la_CXXFLAGS =$(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -O2 -g -Werror +libClasspath_la_CXXFLAGS =-I../VMCore -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -O2 -g -Werror Modified: vmkit/trunk/lib/JnJVM/Main.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Main.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Main.cpp (original) +++ vmkit/trunk/lib/JnJVM/Main.cpp Fri Apr 11 11:20:48 2008 @@ -7,9 +7,10 @@ // //===----------------------------------------------------------------------===// +#include "MvmGC.h" #include "mvm/JIT.h" #include "mvm/Object.h" -#include "mvm/GC/GC.h" +#include "mvm/Threads/Thread.h" #include "llvm/Support/ManagedStatic.h" @@ -25,6 +26,7 @@ jit::initialise(); Object::initialise(); + Thread::initialise(); Collector::initialise(Object::markAndTraceRoots, &base); boot(); start_app(argc, argv); Modified: vmkit/trunk/lib/JnJVM/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Makefile.am?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Makefile.am (original) +++ vmkit/trunk/lib/JnJVM/Makefile.am Fri Apr 11 11:20:48 2008 @@ -4,21 +4,9 @@ bin_PROGRAMS = main #lib_LTLIBRARIES = libjnjvm.la -THREADDIR=../Mvm/CommonThread -ALLOCDIR=../Mvm/Allocator -GCDIR=../Mvm/GCMmap2 -INCLUDEDIRS=-I at srcdir@/$(THREADDIR) -I at srcdir@/$(ALLOCDIR) -I at srcdir@/$(GCDIR) - -LIBTHREAD=$(THREADDIR)/libuvm_ at vvmthreadtype@_thread.a -LIBALLOC=$(ALLOCDIR)/libuvm_alloc.a -LIBGC=$(GCDIR)/libuvm_gc_ at vvmgctype@.a @GC_LIBS@ -LIBSUVM=$(LIBGC) $(LIBALLOC) $(LIBTHREAD) - main_SOURCES = ../Mvm/Object.cpp ../Mvm/Sigsegv.cpp Main.cpp ../Mvm/MvmMemoryManager.cpp ../Mvm/JIT.cpp ../Mvm/EscapeAnalysis.cpp - - -main_CXXFLAGS = $(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -Werror -O2 -main_LDADD = VMCore/.libs/libJnJVM.a Classpath/.libs/libClasspath.a $(LIBSUVM) @LLVMDYLIB@ +main_CXXFLAGS = -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -Werror -O2 +main_LDADD = VMCore/.libs/libJnJVM.a Classpath/.libs/libClasspath.a @GC_LIBS@ @GCTHREAD_LIBS@ @LLVMDYLIB@ main_LDFLAGS = @rdynamic@ #libjnjvm.la: Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp Fri Apr 11 11:20:48 2008 @@ -73,8 +73,9 @@ extern "C" JavaMethod* ip_to_meth(int* begIp) { if (begIp) { + unsigned char* val = (unsigned char*)begIp + sizeof(mvm::Code); const llvm::GlobalValue * glob = - mvm::jit::executionEngine->getGlobalValueAtAddress(begIp + 1); + mvm::jit::executionEngine->getGlobalValueAtAddress(val); if (glob) { if (llvm::isa(glob)) { mvm::Code* c = (mvm::Code*)begIp; @@ -121,8 +122,9 @@ int * ip = debug_frame_ip(fp); int *begIp = (int*)Collector::begOf(ip); if (begIp) { + unsigned char* val = (unsigned char*)begIp + sizeof(mvm::Code); const llvm::GlobalValue * glob = - mvm::jit::executionEngine->getGlobalValueAtAddress(begIp + 1); + mvm::jit::executionEngine->getGlobalValueAtAddress(val); if (glob) { if (llvm::isa(glob)) { printf("; 0x%p in %s\n", ip, @@ -148,8 +150,9 @@ while (n < real_size) { int *begIp = (int*)Collector::begOf(ips[n++]); if (begIp) { + unsigned char* val = (unsigned char*)begIp + sizeof(mvm::Code); const llvm::GlobalValue * glob = - mvm::jit::executionEngine->getGlobalValueAtAddress(begIp + 1); + mvm::jit::executionEngine->getGlobalValueAtAddress(val); if (glob) { if (llvm::isa(glob)) { mvm::Code* c = (mvm::Code*)begIp; @@ -158,7 +161,8 @@ if (meth) printf("; 0x%p in %s\n", ips[n - 1], meth->printString()); else - printf("; 0x%p in %s\n", ips[n - 1], ((llvm::Function*)glob)->getNameStr().c_str()); + printf("; 0x%p in %s\n", ips[n - 1], + ((llvm::Function*)glob)->getNameStr().c_str()); } else JavaThread::get()->isolate->unknownError("in global variable?"); } else printf("; 0x%p in stub\n", ips[n - 1]); } else { @@ -184,8 +188,9 @@ while (n < real_size) { int *begIp = (int*)Collector::begOf(ips[n++]); if (begIp) { + unsigned char* val = (unsigned char*)begIp + sizeof(mvm::Code); const llvm::GlobalValue * glob = - mvm::jit::executionEngine->getGlobalValueAtAddress(begIp + 1); + mvm::jit::executionEngine->getGlobalValueAtAddress(val); if (glob) { if (llvm::isa(glob)) { mvm::Code* c = (mvm::Code*)begIp; @@ -210,8 +215,9 @@ while (n < real_size) { int *begIp = (int*)Collector::begOf(ips[n++]); if (begIp) { + unsigned char* val = (unsigned char*)begIp + sizeof(mvm::Code); const llvm::GlobalValue * glob = - mvm::jit::executionEngine->getGlobalValueAtAddress(begIp + 1); + mvm::jit::executionEngine->getGlobalValueAtAddress(val); if (glob) { if (llvm::isa(glob)) { mvm::Code* c = (mvm::Code*)begIp; Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Fri Apr 11 11:20:48 2008 @@ -16,8 +16,6 @@ #include "mvm/JIT.h" -#include "mvm/GC/GC.h" - #include "types.h" #include "JavaArray.h" @@ -67,7 +65,8 @@ } // TODO: Optimize -Attribut* Attribut::lookup(const std::vector* vec, +Attribut* Attribut::lookup(const std::vector >* vec, const UTF8* key ) { for (uint32 i = 0; i < vec->size(); i++) { @@ -227,7 +226,7 @@ // We can compile it, since if we're here, it's for a good reason void* val = mvm::jit::executionEngine->getPointerToGlobal(methPtr); if (Collector::isObject(val)) { - mvm::Code* temp = (mvm::Code*)((unsigned*)val - 1); + mvm::Code* temp = (mvm::Code*)((unsigned*)val - 2); temp->method()->definition(this); } code = (mvm::Code*)val; Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Fri Apr 11 11:20:48 2008 @@ -57,7 +57,7 @@ unsigned int nbb; void derive(const UTF8* name, unsigned int length, const Reader* reader); - static Attribut* lookup(const std::vector * vec, + static Attribut* lookup(const std::vector > * vec, const UTF8* key); Reader* toReader(Jnjvm *vm, ArrayUInt8* array, Attribut* attr); @@ -176,7 +176,7 @@ mvm::Code* codeVirtualTracer; mvm::Code* codeStaticTracer; JavaCtpInfo* ctpInfo; - std::vector attributs; + std::vector > attributs; std::vector innerClasses; Class* outerClass; uint32 innerAccess; @@ -241,8 +241,8 @@ llvm::Function* methPtr; unsigned int access; Signdef* signature; - std::vector attributs; - std::vector caches; + std::vector > attributs; + std::vector > caches; Class* classDef; const UTF8* name; const UTF8* type; @@ -318,7 +318,7 @@ const UTF8* name; Typedef* signature; const UTF8* type; - std::vector attributs; + std::vector > attributs; Class* classDef; uint64 ptrOffset; Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp Fri Apr 11 11:20:48 2008 @@ -202,7 +202,7 @@ } extern "C" int boot() { - + struct sigaction sa; sigaction(SIGINT, 0, &sa); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Fri Apr 11 11:20:48 2008 @@ -265,9 +265,12 @@ static Class* getCallingClassWalker(); static JavaObject* getCallingClassLoader(); static void printBacktrace(); - + +#ifdef WITH_TRACER static llvm::Function* markAndTraceLLVM; static const llvm::FunctionType* markAndTraceLLVMType; +#endif + static llvm::Constant* constantJavaObjectNull; static llvm::Constant* constantUTF8Null; }; Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp Fri Apr 11 11:20:48 2008 @@ -28,7 +28,9 @@ using namespace jnjvm; using namespace llvm; +#ifdef WITH_TRACER const llvm::FunctionType* JavaJIT::markAndTraceLLVMType = 0; +#endif const llvm::Type* JavaObject::llvmType = 0; const llvm::Type* JavaArray::llvmType = 0; @@ -543,8 +545,9 @@ } - - // Create markAndTraceLLVM + +#ifdef WITH_TRACER + // Create markAndTraceLLVM { std::vector args; args.push_back(JavaObject::llvmType); @@ -553,7 +556,8 @@ GlobalValue::ExternalLinkage, "_ZNK2gc12markAndTraceEv", module); - } + } +#endif mvm::jit::unprotectTypes();//->unlock(); mvm::jit::protectConstants();//->lock(); constantUTF8Null = Constant::getNullValue(UTF8::llvmType); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp Fri Apr 11 11:20:48 2008 @@ -173,6 +173,10 @@ VirtualTable* JavaJIT::makeVT(Class* cl, bool stat) { + VirtualTable * res = malloc(VT_SIZE); + memcpy(res, JavaObject::VT, VT_SIZE); + +#ifdef WITH_TRACER const Type* type = stat ? cl->staticType : cl->virtualType; std::vector &fields = stat ? cl->staticFields : cl->virtualFields; @@ -210,8 +214,6 @@ ReturnInst::Create(block); - VirtualTable * res = malloc(VT_SIZE); - memcpy(res, JavaObject::VT, VT_SIZE); void* codePtr = mvm::jit::executionEngine->getPointerToGlobal(func); ((void**)res)[VT_TRACER_OFFSET] = codePtr; @@ -222,6 +224,7 @@ cl->staticTracer = func; cl->codeStaticTracer = (mvm::Code*)((unsigned*)codePtr - 1); } +#endif return res; } Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Fri Apr 11 11:20:48 2008 @@ -26,6 +26,9 @@ using namespace jnjvm; +#ifdef WITH_TRACER +llvm::Function* JavaJIT::markAndTraceLLVM = 0; +#endif llvm::Function* JavaJIT::getSJLJBufferLLVM = 0; llvm::Function* JavaJIT::throwExceptionLLVM = 0; llvm::Function* JavaJIT::getExceptionLLVM = 0; @@ -35,7 +38,6 @@ llvm::Function* JavaJIT::nullPointerExceptionLLVM = 0; llvm::Function* JavaJIT::classCastExceptionLLVM = 0; llvm::Function* JavaJIT::indexOutOfBoundsExceptionLLVM = 0; -llvm::Function* JavaJIT::markAndTraceLLVM = 0; llvm::Function* JavaJIT::javaObjectTracerLLVM = 0; llvm::Function* JavaJIT::virtualLookupLLVM = 0; llvm::Function* JavaJIT::fieldLookupLLVM = 0; Modified: vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp Fri Apr 11 11:20:48 2008 @@ -2103,7 +2103,8 @@ void DeleteGlobalRef(JNIEnv* env, jobject globalRef) { Jnjvm* vm = NativeUtil::myVM(env); vm->globalRefsLock->lock(); - for (std::vector::iterator i = vm->globalRefs.begin(), + for (std::vector >::iterator i = + vm->globalRefs.begin(), e = vm->globalRefs.end(); i!= e; ++i) { if ((*i) == (JavaObject*)globalRef) { vm->globalRefs.erase(i); Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Fri Apr 11 11:20:48 2008 @@ -191,7 +191,8 @@ } void Jnjvm::readAttributs(Class* cl, Reader* reader, - std::vector& attr) { + std::vector >& attr) { JavaCtpInfo* ctpInfo = cl->ctpInfo; unsigned short int nba = reader->readU2(); Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h Fri Apr 11 11:20:48 2008 @@ -186,7 +186,8 @@ void readParents(Class* cl, Reader* reader); void loadParents(Class* cl); - void readAttributs(Class* cl, Reader* reader, std::vector & attr); + void readAttributs(Class* cl, Reader* reader, + std::vector > & attr); void readFields(Class* cl, Reader* reader); void readMethods(Class* cl, Reader* reader); void readClass(Class* cl); @@ -228,7 +229,7 @@ const char* classpath; const char* libClasspathEnv; const char* bootClasspathEnv; - std::vector globalRefs; + std::vector > globalRefs; mvm::Lock* globalRefsLock; void setClasspath(char* cp) { Modified: vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h Fri Apr 11 11:20:48 2008 @@ -56,7 +56,8 @@ typedef Container (*funcCreate)(Key& V, Jnjvm *vm); mvm::Lock* lock; - std::map map; + std::map > > map; inline Container lookupOrCreate(Key& V, Jnjvm *vm, funcCreate func) { lock->lock(); @@ -99,7 +100,8 @@ typedef std::multimap::iterator iterator; mvm::Lock* lock; - std::multimap map; + std::multimap, + gc_allocator< std::pair > > map; static VirtualTable* VT; const UTF8* lookupOrCreateAsciiz(Jnjvm* vm, const char* asciiz); const UTF8* lookupOrCreateReader(Jnjvm* vm, const uint16* buf, uint32 size); Modified: vmkit/trunk/lib/JnJVM/VMCore/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Makefile.am?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/Makefile.am (original) +++ vmkit/trunk/lib/JnJVM/VMCore/Makefile.am Fri Apr 11 11:20:48 2008 @@ -1,11 +1,6 @@ EXTRA_DIST = OpcodeNames.def lib_LTLIBRARIES = libJnJVM.la -THREADDIR=../../Mvm/CommonThread -ALLOCDIR=../../Mvm/Allocator -GCDIR=../../Mvm/GCMmap2 -INCLUDEDIRS=-I at srcdir@/$(THREADDIR) -I at srcdir@/$(ALLOCDIR) -I at srcdir@/$(GCDIR) - PREFIX=@prefix@ libJnJVM_la_SOURCES = \ @@ -20,4 +15,4 @@ JnjvmModuleProvider.h JnjvmModuleProvider.cpp JavaRuntimeJIT.cpp JavaMetaJIT.cpp JavaJITInitialise.cpp \ LowerArrayLength.cpp ServiceDomain.cpp -libJnJVM_la_CXXFLAGS =$(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -Werror -O2 +libJnJVM_la_CXXFLAGS =-DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -Werror -O2 Modified: vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp Fri Apr 11 11:20:48 2008 @@ -116,28 +116,28 @@ name->markAndTrace(); } -#define TRACE_VECTOR(type,name) { \ - for (std::vector::iterator i = name.begin(), e = name.end(); \ - i!= e; ++i) { \ +#define TRACE_VECTOR(type,alloc,name) { \ + for (std::vector >::iterator i = name.begin(), \ + e = name.end(); i!= e; ++i) { \ (*i)->markAndTrace(); }} void CommonClass::tracer(size_t sz) { name->markAndTrace(); super->markAndTrace(); superUTF8->markAndTrace(); - TRACE_VECTOR(const UTF8*, interfacesUTF8); - TRACE_VECTOR(Class*, interfaces); + TRACE_VECTOR(const UTF8*, std::allocator, interfacesUTF8); + TRACE_VECTOR(Class*, std::allocator, interfaces); //lockVar->markAndTrace(); //condVar->markAndTrace(); - TRACE_VECTOR(JavaMethod*, virtualMethods); - TRACE_VECTOR(JavaMethod*, staticMethods); - TRACE_VECTOR(JavaField*, virtualFields); - TRACE_VECTOR(JavaField*, staticFields); + TRACE_VECTOR(JavaMethod*, std::allocator, virtualMethods); + TRACE_VECTOR(JavaMethod*, std::allocator, staticMethods); + TRACE_VECTOR(JavaField*, std::allocator, virtualFields); + TRACE_VECTOR(JavaField*, std::allocator, staticFields); classLoader->markAndTrace(); #ifndef MULTIPLE_VM delegatee->markAndTrace(); #endif - TRACE_VECTOR(CommonClass*, display); + TRACE_VECTOR(CommonClass*, std::allocator, display); isolate->markAndTrace(); } @@ -147,8 +147,8 @@ _staticInstance->markAndTrace(); virtualInstance->markAndTrace(); ctpInfo->markAndTrace(); - TRACE_VECTOR(Attribut*, attributs); - TRACE_VECTOR(Class*, innerClasses); + TRACE_VECTOR(Attribut*, gc_allocator, attributs); + TRACE_VECTOR(Class*, std::allocator, innerClasses); outerClass->markAndTrace(); codeStaticTracer->markAndTrace(); codeVirtualTracer->markAndTrace(); @@ -163,8 +163,8 @@ void JavaMethod::tracer(size_t sz) { signature->markAndTrace(); - TRACE_VECTOR(Attribut*, attributs); - TRACE_VECTOR(Enveloppe*, caches); + TRACE_VECTOR(Attribut*, gc_allocator, attributs); + TRACE_VECTOR(Enveloppe*, gc_allocator, caches); classDef->markAndTrace(); name->markAndTrace(); type->markAndTrace(); @@ -175,7 +175,7 @@ name->markAndTrace(); signature->markAndTrace(); type->markAndTrace(); - TRACE_VECTOR(Attribut*, attributs); + TRACE_VECTOR(Attribut*, gc_allocator, attributs); classDef->markAndTrace(); } @@ -186,7 +186,7 @@ } void JavaCond::tracer(size_t sz) { - TRACE_VECTOR(JavaThread*, threads); + TRACE_VECTOR(JavaThread*, std::allocator, threads); } void LockObj::tracer(size_t sz) { @@ -220,7 +220,7 @@ void Signdef::tracer(size_t sz) { Typedef::tracer(sz); - TRACE_VECTOR(Typedef*, args); + TRACE_VECTOR(Typedef*, std::allocator, args); ret->markAndTrace(); _staticCallBuf->markAndTrace(); _virtualCallBuf->markAndTrace(); @@ -241,7 +241,7 @@ loadedMethods->markAndTrace(); loadedFields->markAndTrace(); javaTypes->markAndTrace(); - TRACE_VECTOR(JavaObject*, globalRefs); + TRACE_VECTOR(JavaObject*, gc_allocator, globalRefs); //globalRefsLock->markAndTrace(); functions->markAndTrace(); #ifdef MULTIPLE_VM Modified: vmkit/trunk/lib/Mvm/Allocator/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Allocator/Makefile.am?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Allocator/Makefile.am (original) +++ vmkit/trunk/lib/Mvm/Allocator/Makefile.am Fri Apr 11 11:20:48 2008 @@ -2,7 +2,7 @@ noinst_PROGRAMS = mainuvm_alloc libuvm_alloc_a_SOURCES = gcalloc.cpp gcalloc.h gcchunk.cpp gcchunk.h gcerror.cpp gcerror.h gcmapper.cpp gcmapper.h osdep.h -libuvm_alloc_a_CXXFLAGS = -O2 -W -Wall -Werror -ansi -pedantic -Wno-variadic-macros -Wno-unused-parameter -DSERVICE_VM +libuvm_alloc_a_CXXFLAGS = -O2 -W -Wall -Werror -ansi -pedantic -Wno-variadic-macros -Wno-unused-parameter mainuvm_alloc_SOURCES = main.cpp mainuvm_alloc_CXXFLAGS = Modified: vmkit/trunk/lib/Mvm/CommandLine.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommandLine.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/CommandLine.cpp (original) +++ vmkit/trunk/lib/Mvm/CommandLine.cpp Fri Apr 11 11:20:48 2008 @@ -13,7 +13,7 @@ #include #include "CommandLine.h" -#include "mvm/GC/GC.h" +#include "MvmGC.h" #include "mvm/Threads/Thread.h" using namespace mvm; Modified: vmkit/trunk/lib/Mvm/CommonThread/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/Makefile.am?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/CommonThread/Makefile.am (original) +++ vmkit/trunk/lib/Mvm/CommonThread/Makefile.am Fri Apr 11 11:20:48 2008 @@ -1,11 +1,6 @@ noinst_LIBRARIES = libuvm_common_thread.a -GCDIR = ../GCMmap2 -GCLIBS = $(GCDIR)/libuvm_gc_mmap2.a -ALLOCDIR = ../Allocator -ALLOCLIBS = $(ALLOCDIR)/libuvm_alloc.a - libuvm_common_thread_a_SOURCES = cterror.h ctthread.cpp cterror.cpp ctlock.cpp -libuvm_common_thread_a_CXXFLAGS = -frepo -O2 -W -Wall -Werror -ansi -pedantic -Wno-unused-parameter -DSERVICE_VM +libuvm_common_thread_a_CXXFLAGS = -frepo -O2 -W -Wall -Werror -ansi -pedantic -Wno-unused-parameter CLEANFILES = *~ *.bak .*.sw? Modified: vmkit/trunk/lib/Mvm/GCMmap2/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/Makefile.am?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/Makefile.am (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/Makefile.am Fri Apr 11 11:20:48 2008 @@ -5,7 +5,7 @@ ALLOCDIR=../Allocator INCLUDEDIRS=-I at srcdir@/$(THREADDIR) -I at srcdir@/$(ALLOCDIR) -LIBTHREAD=$(THREADDIR)/libuvm_ at vvmthreadtype@_thread.a +LIBTHREAD=$(THREADDIR)/libuvm_common_thread.a LIBALLOC=$(ALLOCDIR)/libuvm_alloc.a libuvm_gc_mmap2_a_SOURCES = gc.cpp gccollector.cpp gcinit.cpp gccollector.h Modified: vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp Fri Apr 11 11:20:48 2008 @@ -15,103 +15,87 @@ using namespace mvm; -#ifdef MULTIPLE_VM -#define COLLECTOR ((GCCollector*)(mvm::Thread::get()->GC))-> -#else -#define COLLECTOR GCCollector:: -#endif - typedef void (*memoryError_t)(unsigned int); memoryError_t GCCollector::internMemoryError; void gc::markAndTrace() const { - COLLECTOR markAndTrace((void*)this); + GCCollector::markAndTrace((void*)this); } size_t gc::objectSize() const { - return GCCollector::objectSize((gc*)this); + return GCCollector::objectSize((gc*)this); } void *gc::operator new(size_t sz, VirtualTable *vt) { - return COLLECTOR gcmalloc(vt, sz); + return GCCollector::gcmalloc(vt, sz); } void *gc::operator new(size_t sz) { - return malloc(sz); + return malloc(sz); } void gc::operator delete(void *) { - gcfatal(0, "never call directly a destructor....."); + gcfatal(0, "never call directly a destructor....."); } void *gc::realloc(size_t n) { - return COLLECTOR gcrealloc(this, n); + return GCCollector::gcrealloc(this, n); } unsigned int Collector::enable(unsigned int n) { - return COLLECTOR enable(n); + return GCCollector::enable(n); } int Collector::isStable(gc_lock_recovery_fct_t fct, int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7) { - return COLLECTOR isStable(fct, a0, a1, a2, a3, a4, a5, a6, a7); + return GCCollector::isStable(fct, a0, a1, a2, a3, a4, a5, a6, a7); } void Collector::die_if_sigsegv_occured_during_collection(void *addr) { - COLLECTOR die_if_sigsegv_occured_during_collection(addr); + GCCollector::die_if_sigsegv_occured_during_collection(addr); } void Collector::gcStats(size_t &no, size_t &nbb) { - COLLECTOR gcStats(&no, &nbb); + GCCollector::gcStats(&no, &nbb); } void Collector::initialise(markerFn marker, void *base_sp) { -#ifdef HAVE_PTHREAD - Thread::initialise(); -#endif -#ifdef MULTIPLE_VM - GCCollector* GC = new GCCollector(); - GC->initialise(marker); - GC->inject_my_thread(base_sp); - mvm::Thread::get()->GC = GC; -#else GCCollector::initialise(marker); GCCollector::inject_my_thread(base_sp); -#endif } void Collector::destroy() { - COLLECTOR destroy(); + GCCollector::destroy(); } void Collector::inject_my_thread(void *base_sp) { #ifdef HAVE_PTHREAD - COLLECTOR inject_my_thread(base_sp); + GCCollector::inject_my_thread(base_sp); #endif } void Collector::maybeCollect() { - COLLECTOR maybeCollect(); + GCCollector::maybeCollect(); } void Collector::collect(void) { - COLLECTOR collect(); + GCCollector::collect(); } gc *Collector::begOf(const void *obj) { - return GCCollector::begOf((void*)obj); + return (gc*)GCCollector::begOf((void*)obj); } int Collector::byteOffset(void *obj) { - int beg = (intptr_t)GCCollector::begOf(obj); + int beg = (intptr_t)GCCollector::begOf(obj); intptr_t off = (intptr_t)obj; return (off-beg); } -void Collector::applyFunc(void (*func)(gc *o, void *data), void *data) { - return COLLECTOR applyFunc(func, data); +void Collector::applyFunc(void (*func)(gcRoot *o, void *data), void *data) { + return GCCollector::applyFunc(func, data); } int Collector::getMaxMemory(void){ @@ -139,56 +123,57 @@ void Collector::remove_my_thread() { #ifdef HAVE_PTHREAD - COLLECTOR remove_thread(COLLECTOR threads->myloc()); + GCCollector::remove_thread(GCCollector::threads->myloc()); #endif } #ifdef HAVE_PTHREAD void GCCollector::siggc_handler(int) { - GCThreadCollector *loc = COLLECTOR threads->myloc(); - register unsigned int cm = COLLECTOR current_mark; - // jmp_buf buf; - - // setjmp(buf); - - COLLECTOR threads->stackLock(); - - if(!loc) /* a key is being destroyed */ - COLLECTOR threads->another_mark(); - else if(loc->current_mark() != cm) { - register unsigned int **cur = (unsigned int **)&cur; - register unsigned int **max = loc->base_sp(); - - GCChunkNode *node; - - for(; curremove(); - node->append(COLLECTOR used_nodes); - COLLECTOR mark(node); - } - } - - loc->current_mark(cm); - COLLECTOR threads->another_mark(); - - COLLECTOR threads->waitCollection(); - } - COLLECTOR threads->stackUnlock(); + GCThreadCollector *loc = GCCollector::threads->myloc(); + register unsigned int cm = GCCollector::current_mark; + // jmp_buf buf; + + // setjmp(buf); + + GCCollector::threads->stackLock(); + + if(!loc) /* a key is being destroyed */ + GCCollector::threads->another_mark(); + else if(loc->current_mark() != cm) { + register unsigned int **cur = (unsigned int **)&cur; + register unsigned int **max = loc->base_sp(); + + GCChunkNode *node; + + for(; curremove(); + node->append(GCCollector::used_nodes); + GCCollector::mark(node); + } + } + + loc->current_mark(cm); + GCCollector::threads->another_mark(); + + GCCollector::threads->waitCollection(); + } + GCCollector::threads->stackUnlock(); } #endif void GCThread::waitCollection() { - unsigned int cm = COLLECTOR current_mark; + unsigned int cm = GCCollector::current_mark; - if(Thread::self() != collector_tid) { - collectorGo(); - while((COLLECTOR current_mark == cm) && - (COLLECTOR status == GCCollector::stat_collect)) - _collectionCond.wait(&_stackLock); - } + if(Thread::self() != collector_tid) { + collectorGo(); + while((GCCollector::current_mark == cm) && + (GCCollector::status == GCCollector::stat_collect)) + _collectionCond.wait(&_stackLock); + } } Collector* Collector::allocate() { return new GCCollector(); } + Modified: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h Fri Apr 11 11:20:48 2008 @@ -117,7 +117,7 @@ allocator->free(ptr); } - static inline gc *begOf(void *p) { + static inline void *begOf(void *p) { GCChunkNode *node = o2node(p); if(node) return node->chunk()->_2gc(); @@ -144,7 +144,7 @@ collect(); } - STATIC inline gc *gcmalloc(VirtualTable *vt, size_t n) { + STATIC inline void *gcmalloc(VirtualTable *vt, size_t n) { lock(); register GCChunkNode *header = allocator->alloc_chunk(n + sizeof(gc_header), 1, current_mark & 1); @@ -163,7 +163,7 @@ return p->_2gc(); } - STATIC inline gc *gcrealloc(void *ptr, size_t n) { + STATIC inline void *gcrealloc(void *ptr, size_t n) { lock(); GCPage *desc = GCHash::get(ptr); @@ -221,7 +221,7 @@ } } - STATIC inline void applyFunc(void (*func)(gc *o, void *data), void *data){ + STATIC inline void applyFunc(void (*func)(gcRoot *o, void *data), void *data){ lock(); /* Make sure no one collects or allocates */ status = stat_collect; /* Forbids collections */ GCChunkNode *cur=used_nodes->next(); /* Get starter */ Modified: vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h (original) +++ vmkit/trunk/lib/Mvm/GCMmap2/gcthread.h Fri Apr 11 11:20:48 2008 @@ -11,7 +11,6 @@ #define _GC_THREAD_H_ #include "ctcircular.h" -#include "mvm/GC/GC.h" #include "mvm/Threads/Cond.h" #include "mvm/Threads/Key.h" #include "mvm/Threads/Locks.h" @@ -22,117 +21,117 @@ namespace mvm { class GCThreadCollector : public CircularBase { - void *_base_sp; - int _cur_mark; - int _tid; - + void *_base_sp; + int _cur_mark; + int _tid; + public: - inline GCThreadCollector() {} - inline GCThreadCollector(GCThreadCollector *pred, int t, void *p, int m) : CircularBase(pred) { - _base_sp = p; - _cur_mark = m; - _tid = t; - } - - /* This function is only called in two cases: - * 1) When a thread quits, in which case everything is already done. - * 2) When the collector quits, in which case all memory is freed. - */ - inline ~GCThreadCollector() {} - - inline int tid() { return _tid; } - inline unsigned int current_mark() { return _cur_mark; } - inline void current_mark(unsigned int m) { _cur_mark = m; } - inline unsigned int **base_sp() { return (unsigned int **)_base_sp; } + inline GCThreadCollector() {} + inline GCThreadCollector(GCThreadCollector *pred, int t, void *p, int m) : CircularBase(pred) { + _base_sp = p; + _cur_mark = m; + _tid = t; + } + + /* This function is only called in two cases: + * 1) When a thread quits, in which case everything is already done. + * 2) When the collector quits, in which case all memory is freed. + */ + inline ~GCThreadCollector() {} + + inline int tid() { return _tid; } + inline unsigned int current_mark() { return _cur_mark; } + inline void current_mark(unsigned int m) { _cur_mark = m; } + inline unsigned int **base_sp() { return (unsigned int **)_base_sp; } }; class GCLockRecovery : public LockNormal { - gc_lock_recovery_fct_t _fct; - int _args[8]; - + gc_lock_recovery_fct_t _fct; + int _args[8]; + public: - inline GCLockRecovery() { _fct = 0; } + inline GCLockRecovery() { _fct = 0; } - int verify_recall(gc_lock_recovery_fct_t fct, int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7); + int verify_recall(gc_lock_recovery_fct_t fct, int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7); - inline void unlock_dont_recovery() { - if(owner() == Thread::self()) { - LockNormal::unlock(); - } - } - - inline void unlock() { - if(_fct) { - gc_lock_recovery_fct_t tmp = _fct; - int l[8]; - l[0] = _args[0]; l[1] = _args[1]; l[2] = _args[2]; l[3] = _args[3]; - l[4] = _args[4]; l[5] = _args[5]; l[6] = _args[6]; l[7] = _args[7]; - _fct = 0; - LockNormal::unlock(); - tmp(l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7]); - } else - LockNormal::unlock(); - } + inline void unlock_dont_recovery() { + if(owner() == Thread::self()) { + LockNormal::unlock(); + } + } + + inline void unlock() { + if(_fct) { + gc_lock_recovery_fct_t tmp = _fct; + int l[8]; + l[0] = _args[0]; l[1] = _args[1]; l[2] = _args[2]; l[3] = _args[3]; + l[4] = _args[4]; l[5] = _args[5]; l[6] = _args[6]; l[7] = _args[7]; + _fct = 0; + LockNormal::unlock(); + tmp(l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7]); + } else + LockNormal::unlock(); + } }; class GCThread { - Key _loc; - GCThreadCollector base; - GCLockRecovery _globalLock; /* global lock for gcmalloc */ - LockNormal _stackLock; /* stack lock for synchronization */ - Cond _stackCond; /* condition for unlocking other tasks (write protect) */ - Cond _collectionCond;/* condition for unblocking the collecter */ - unsigned int _nb_threads; /* number of active threads */ - unsigned int _nb_collected; /* number of threads collected */ - int collector_tid; /* don't synchonize this one */ + Key _loc; + GCThreadCollector base; + GCLockRecovery _globalLock; /* global lock for gcmalloc */ + LockNormal _stackLock; /* stack lock for synchronization */ + Cond _stackCond; /* condition for unlocking other tasks (write protect) */ + Cond _collectionCond;/* condition for unblocking the collecter */ + unsigned int _nb_threads; /* number of active threads */ + unsigned int _nb_collected; /* number of threads collected */ + int collector_tid; /* don't synchonize this one */ public: - inline void lock() { _globalLock.lock(); } - inline void unlock() { _globalLock.unlock(); } - inline void unlock_dont_recovery() { _globalLock.unlock_dont_recovery(); } - inline int isStable(gc_lock_recovery_fct_t fct, int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7) { - return _globalLock.verify_recall(fct, a0, a1, a2, a3, a4, a5, a6, a7); - } - - inline void stackLock() { _stackLock.lock(); } - inline void stackUnlock() { _stackLock.unlock(); } - - void waitStacks(); - void waitCollection(); - inline void collectionFinished() { _collectionCond.broadcast(); } - inline void collectorGo() { _stackCond.broadcast(); } - - inline void cancel() { - _nb_collected = _nb_threads; /* all stacks have been collected */ - collectorGo(); /* unblock all threads in stack collection */ - collectionFinished(); /* unblock mutators */ - } - - inline GCThreadCollector *myloc() { return _loc.get(); } - - inline void another_mark() { _nb_collected++; } - - void synchronize(); - - inline void remove(GCThreadCollector *loc) { - lock(); - loc->remove(); - _nb_threads--; - delete loc; - unlock(); - } - - inline void inject(void *sp, int m) { - GCThreadCollector *me = _loc.get(); - if(me) - gcfatal("thread %d is already in pool for allocator %p", Thread::self(), this); - lock(); /* the new should be protected */ - me = new GCThreadCollector(&base, Thread::self(), sp, m); - _nb_threads++; - _loc.set(me); - unlock(); - } + inline void lock() { _globalLock.lock(); } + inline void unlock() { _globalLock.unlock(); } + inline void unlock_dont_recovery() { _globalLock.unlock_dont_recovery(); } + inline int isStable(gc_lock_recovery_fct_t fct, int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7) { + return _globalLock.verify_recall(fct, a0, a1, a2, a3, a4, a5, a6, a7); + } + + inline void stackLock() { _stackLock.lock(); } + inline void stackUnlock() { _stackLock.unlock(); } + + void waitStacks(); + void waitCollection(); + inline void collectionFinished() { _collectionCond.broadcast(); } + inline void collectorGo() { _stackCond.broadcast(); } + + inline void cancel() { + _nb_collected = _nb_threads; /* all stacks have been collected */ + collectorGo(); /* unblock all threads in stack collection */ + collectionFinished(); /* unblock mutators */ + } + + inline GCThreadCollector *myloc() { return _loc.get(); } + + inline void another_mark() { _nb_collected++; } + + void synchronize(); + + inline void remove(GCThreadCollector *loc) { + lock(); + loc->remove(); + _nb_threads--; + delete loc; + unlock(); + } + + inline void inject(void *sp, int m) { + GCThreadCollector *me = _loc.get(); + if(me) + gcfatal("thread %d is already in pool for allocator %p", Thread::self(), this); + lock(); /* the new should be protected */ + me = new GCThreadCollector(&base, Thread::self(), sp, m); + _nb_threads++; + _loc.set(me); + unlock(); + } }; } Modified: vmkit/trunk/lib/Mvm/Main.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Main.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Main.cpp (original) +++ vmkit/trunk/lib/Mvm/Main.cpp Fri Apr 11 11:20:48 2008 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "mvm/GC/GC.h" +#include "MvmGC.h" #include "mvm/JIT.h" #include "mvm/PrintBuffer.h" #include "mvm/Threads/Thread.h" @@ -45,6 +45,7 @@ " VMKit: a virtual machine launcher\n"); jit::initialise(); Object::initialise(); + Thread::initialise(); Collector::initialise(Object::markAndTraceRoots, &base); CommandLine cl; Modified: vmkit/trunk/lib/Mvm/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Makefile.am?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Makefile.am (original) +++ vmkit/trunk/lib/Mvm/Makefile.am Fri Apr 11 11:20:48 2008 @@ -3,18 +3,9 @@ bin_PROGRAMS = main -THREADDIR=CommonThread -ALLOCDIR=Allocator -GCDIR=GCMmap2 -INCLUDEDIRS=-I at srcdir@/$(THREADDIR) -I at srcdir@/$(ALLOCDIR) -I at srcdir@/$(GCDIR) - -LIBTHREAD=$(THREADDIR)/libuvm_ at vvmthreadtype@_thread.a -LIBALLOC=$(ALLOCDIR)/libuvm_alloc.a -LIBGC=$(GCDIR)/libuvm_gc_ at vvmgctype@.a @GC_LIBS@ -LIBSUVM=$(LIBGC) $(LIBALLOC) $(LIBTHREAD) PREFIX=@prefix@ main_SOURCES = Main.cpp Object.cpp Sigsegv.cpp JIT.cpp CommandLine.cpp CommandLine.h MvmMemoryManager.h MvmMemoryManager.cpp EscapeAnalysis.cpp Disassembler.cpp -main_CXXFLAGS = $(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -pedantic -Wno-long-long -fno-omit-frame-pointer -O2 -g -DSERVICE_VM +main_CXXFLAGS = -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -pedantic -Wno-long-long -fno-omit-frame-pointer -O2 -g main_LDFLAGS=@rdynamic@ -main_LDADD = $(LIBSUVM) @LLVMDYLIB@ +main_LDADD = @LLVMDYLIB@ @GC_LIBS@ @GCTHREAD_LIBS@ Modified: vmkit/trunk/lib/Mvm/MvmMemoryManager.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/MvmMemoryManager.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/MvmMemoryManager.cpp (original) +++ vmkit/trunk/lib/Mvm/MvmMemoryManager.cpp Fri Apr 11 11:20:48 2008 @@ -25,7 +25,7 @@ Method* meth = gc_new(Method)(res, ActualSize); res->method(meth); currentMethod = meth; - return (unsigned char*) (res + 1); + return (unsigned char*)((unsigned int*)res + 2); } unsigned char *MvmMemoryManager::allocateStub(unsigned StubSize, @@ -35,7 +35,7 @@ Method* meth = gc_new(Method)(res, StubSize); res->method(meth); Object::pushRoot(meth); - return (unsigned char*) (res + 1); + return (unsigned char*)((unsigned int*)res + 2); } void MvmMemoryManager::endFunctionBody(const Function *F, @@ -62,7 +62,7 @@ ExceptionTable *res = (ExceptionTable*)gc::operator new(ActualSize + 4, ExceptionTable::VT); currentMethod->exceptionTable(res); - return (unsigned char*)(res + 1); + return (unsigned char*)((unsigned int*)res + 2); } void MvmMemoryManager::endExceptionTable(const Function *F, Modified: vmkit/trunk/lib/Mvm/Object.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Object.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Object.cpp (original) +++ vmkit/trunk/lib/Mvm/Object.cpp Fri Apr 11 11:20:48 2008 @@ -9,10 +9,10 @@ #include +#include "MvmGC.h" #include "mvm/Method.h" #include "mvm/Object.h" #include "mvm/PrintBuffer.h" -#include "mvm/GC/GC.h" #include "mvm/Threads/Key.h" #include "mvm/Threads/Thread.h" Modified: vmkit/trunk/lib/Mvm/Sigsegv.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Sigsegv.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Sigsegv.cpp (original) +++ vmkit/trunk/lib/Mvm/Sigsegv.cpp Fri Apr 11 11:20:48 2008 @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// -#include "mvm/GC/GC.h" +#include "MvmGC.h" #include "mvm/Sigsegv.h" #include Modified: vmkit/trunk/lib/Mvm/VTOffset.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/VTOffset.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/VTOffset.cpp (original) +++ vmkit/trunk/lib/Mvm/VTOffset.cpp Fri Apr 11 11:20:48 2008 @@ -12,7 +12,7 @@ #include #include -#include "mvm/GC/GC.h" +#include "MvmGC.h" #include "mvm/PrintBuffer.h" #include "mvm/Threads/Thread.h" #include "mvm/Sigsegv.h" Modified: vmkit/trunk/lib/N3/Main.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/Main.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/N3/Main.cpp (original) +++ vmkit/trunk/lib/N3/Main.cpp Fri Apr 11 11:20:48 2008 @@ -7,9 +7,10 @@ // //===----------------------------------------------------------------------===// +#include "MvmGC.h" #include "mvm/JIT.h" -#include "mvm/GC/GC.h" #include "mvm/PrintBuffer.h" +#include "mvm/Threads/Thread.h" #include "llvm/Support/ManagedStatic.h" @@ -24,6 +25,7 @@ llvm::llvm_shutdown_obj X; int base; + Thread::initialise(); jit::initialise(); Object::initialise(); Collector::initialise(Object::markAndTraceRoots, &base); Modified: vmkit/trunk/lib/N3/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/Makefile.am?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/N3/Makefile.am (original) +++ vmkit/trunk/lib/N3/Makefile.am Fri Apr 11 11:20:48 2008 @@ -1,19 +1,10 @@ SUBDIRS = VMCore bin_PROGRAMS = main -THREADDIR=../Mvm/CommonThread -ALLOCDIR=../Mvm/Allocator -GCDIR=../Mvm/GCMmap2 -INCLUDEDIRS=-I at srcdir@/$(THREADDIR) -I at srcdir@/$(ALLOCDIR) -I at srcdir@/$(GCDIR) - -LIBTHREAD=$(THREADDIR)/libuvm_ at vvmthreadtype@_thread.a -LIBALLOC=$(ALLOCDIR)/libuvm_alloc.a -LIBGC=$(GCDIR)/libuvm_gc_ at vvmgctype@.a @GC_LIBS@ PREFIX=@prefix@ -LIBSUVM=$(LIBGC) $(LIBALLOC) $(LIBTHREAD) main_SOURCES = ../Mvm/Object.cpp ../Mvm/Sigsegv.cpp Main.cpp ../Mvm/MvmMemoryManager.cpp ../Mvm/JIT.cpp ../Mvm/EscapeAnalysis.cpp -main_CXXFLAGS = $(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -Werror -O2 -DSINGLE_VM -main_LDADD = VMCore/.libs/libN3.a $(LIBSUVM) @LLVMDYLIB@ +main_CXXFLAGS = -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -Werror -O2 +main_LDADD = VMCore/.libs/libN3.a @GC_LIBS@ @GCTHREAD_LIBS@ @LLVMDYLIB@ main_LDFLAGS = @rdynamic@ Modified: vmkit/trunk/lib/N3/VMCore/Assembly.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Assembly.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/Assembly.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/Assembly.cpp Fri Apr 11 11:20:48 2008 @@ -189,7 +189,8 @@ return ass; } -static void unimplemented(uint32 index, std::vector& tables, +static void unimplemented(uint32 index, + std::vector >& tables, uint32 heapSizes) { VMThread::get()->vm->error("Unknown table %x", index); } @@ -523,7 +524,8 @@ offset = reader->cursor; uint32 index = 0; - for (std::vector::iterator i = CLIHeader->tables.begin(), + for (std::vector >::iterator i = + CLIHeader->tables.begin(), e = CLIHeader->tables.end(); i != e; ++i, ++index) { Table* table = (*i); if (table->rowsNumber) { Modified: vmkit/trunk/lib/N3/VMCore/Assembly.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Assembly.h?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/Assembly.h (original) +++ vmkit/trunk/lib/N3/VMCore/Assembly.h Fri Apr 11 11:20:48 2008 @@ -118,12 +118,13 @@ Stream* usStream; Stream* blobStream; Stream* guidStream; - std::vector tables; + std::vector > tables; void read(Reader* reader, N3* vm); }; -typedef void (*maskVector_t)(uint32 index, std::vector& tables, +typedef void (*maskVector_t)(uint32 index, + std::vector >& tables, uint32 heapSizes); typedef VMCommonClass* (*signatureVector_t)(uint32 op, Assembly* ass, @@ -562,7 +563,9 @@ #define DEF_TABLE_MASK(name, nb, ...) \ - static void name(uint32 index, std::vector& tables, uint32 heapSizes) { \ + static void name(uint32 index, \ + std::vector >& tables, \ + uint32 heapSizes) { \ Table* table = tables[index]; \ uint32 rowSize = 0; \ uint32 bitmask = 0; \ Modified: vmkit/trunk/lib/N3/VMCore/BackTrace.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/BackTrace.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/BackTrace.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/BackTrace.cpp Fri Apr 11 11:20:48 2008 @@ -37,8 +37,9 @@ while (n < real_size) { int *begIp = (int*)Collector::begOf(ips[n++]); if (begIp) { + unsigned char* val = (unsigned char*)begIp + sizeof(mvm::Code); const llvm::GlobalValue * glob = - mvm::jit::executionEngine->getGlobalValueAtAddress(begIp + 1); + mvm::jit::executionEngine->getGlobalValueAtAddress(val); if (glob) { if (llvm::isa(glob)) { mvm::Code* c = (mvm::Code*)begIp; @@ -47,7 +48,8 @@ if (meth) printf("; 0x%08x in %s\n", (uint32) ips[n - 1], meth->printString()); else - printf("; 0x%08x in %s\n", (uint32) ips[n - 1], ((llvm::Function*)glob)->getNameStr().c_str()); + printf("; 0x%08x in %s\n", (uint32) ips[n - 1], + ((llvm::Function*)glob)->getNameStr().c_str()); } else VMThread::get()->vm->unknownError("in global variable?"); } else printf("; 0x%08x in stub\n", (uint32) ips[n - 1]); } else { @@ -72,8 +74,9 @@ while (n < real_size) { int *begIp = (int*)Collector::begOf(ips[n++]); if (begIp) { + unsigned char* val = (unsigned char*)begIp + sizeof(mvm::Code); const llvm::GlobalValue * glob = - mvm::jit::executionEngine->getGlobalValueAtAddress(begIp + 1); + mvm::jit::executionEngine->getGlobalValueAtAddress(val); if (glob) { if (llvm::isa(glob)) { mvm::Code* c = (mvm::Code*)begIp; @@ -101,8 +104,9 @@ while (n < real_size) { int *begIp = (int*)Collector::begOf(ips[n++]); if (begIp) { + unsigned char* val = (unsigned char*)begIp + sizeof(mvm::Code); const llvm::GlobalValue * glob = - mvm::jit::executionEngine->getGlobalValueAtAddress(begIp + 1); + mvm::jit::executionEngine->getGlobalValueAtAddress(val); if (glob) { if (llvm::isa(glob)) { mvm::Code* c = (mvm::Code*)begIp; Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/CLIJit.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/CLIJit.cpp Fri Apr 11 11:20:48 2008 @@ -53,6 +53,7 @@ buf->write("Exception<>"); } +#ifdef WITH_TRACER // for structs static void traceStruct(VMCommonClass* cl, BasicBlock* block, Value* arg) { for (std::vector::iterator i = cl->virtualFields.begin(), @@ -115,8 +116,12 @@ } } } +#endif VirtualTable* CLIJit::makeArrayVT(VMClassArray* cl) { + VirtualTable * res = malloc(VT_SIZE); + memcpy(res, VMObject::VT, VT_SIZE); +#ifdef WITH_TRACER Function* func = Function::Create(markAndTraceLLVMType, GlobalValue::ExternalLinkage, "markAndTraceObject", @@ -194,17 +199,19 @@ } - VirtualTable * res = malloc(VT_SIZE); - memcpy(res, VMObject::VT, VT_SIZE); void* tracer = mvm::jit::executionEngine->getPointerToGlobal(func); ((void**)res)[VT_TRACER_OFFSET] = tracer; cl->virtualTracer = func; cl->codeVirtualTracer = (mvm::Code*)((intptr_t)tracer - sizeof(intptr_t)); +#endif return res; } VirtualTable* CLIJit::makeVT(VMClass* cl, bool stat) { + VirtualTable * res = malloc(VT_SIZE); + memcpy(res, VMObject::VT, VT_SIZE); +#ifdef WITH_TRACER const Type* type = stat ? cl->staticType : cl->virtualType; std::vector &fields = stat ? cl->staticFields : cl->virtualFields; @@ -226,8 +233,6 @@ traceClass(cl, block, realArg, fields, (cl->super == N3::pValue && !stat)); ReturnInst::Create(block); - VirtualTable * res = malloc(VT_SIZE); - memcpy(res, VMObject::VT, VT_SIZE); void* tracer = mvm::jit::executionEngine->getPointerToGlobal(func); ((void**)res)[VT_TRACER_OFFSET] = tracer; @@ -238,8 +243,8 @@ cl->staticTracer = func; cl->codeStaticTracer = (mvm::Code*)((intptr_t)tracer - sizeof(intptr_t)); } +#endif return res; - } BasicBlock* CLIJit::createBasicBlock(const char* name) { @@ -1570,6 +1575,7 @@ PointerType::getUnqual(StructType::get(arrayFields, false)); } +#ifdef WITH_TRACER // Create markAndTraceLLVM { std::vector args; @@ -1580,6 +1586,7 @@ "_ZNK2gc12markAndTraceEv", module); } +#endif // Create vmObjectTracerLLVM { Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.h?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/CLIJit.h (original) +++ vmkit/trunk/lib/N3/VMCore/CLIJit.h Fri Apr 11 11:20:48 2008 @@ -158,8 +158,10 @@ static llvm::Function* compile(VMClass* cl, VMMethod* meth); +#ifdef WITH_TRACER static llvm::Function* markAndTraceLLVM; static const llvm::FunctionType* markAndTraceLLVMType; +#endif static llvm::Function* vmObjectTracerLLVM; static llvm::Function* arrayConsLLVM; static llvm::Function* arrayMultiConsLLVM; Modified: vmkit/trunk/lib/N3/VMCore/LockedMap.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/LockedMap.h?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/LockedMap.h (original) +++ vmkit/trunk/lib/N3/VMCore/LockedMap.h Fri Apr 11 11:20:48 2008 @@ -44,7 +44,8 @@ typedef Container* (*funcCreate)(Key& V, Upcall* ass); mvm::Lock* lock; - std::map map; + std::map > > map; inline Container* lookupOrCreate(Key& V, Upcall* ass, funcCreate func) { lock->lock(); @@ -203,7 +204,8 @@ typedef std::multimap::iterator iterator; mvm::Lock* lock; - std::multimap map; + std::multimap, + gc_allocator > > map; static VirtualTable* VT; const UTF8* lookupOrCreateAsciiz(const char* asciiz); const UTF8* lookupOrCreateReader(const uint16* buf, uint32 size); Modified: vmkit/trunk/lib/N3/VMCore/Makefile.am URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Makefile.am?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/Makefile.am (original) +++ vmkit/trunk/lib/N3/VMCore/Makefile.am Fri Apr 11 11:20:48 2008 @@ -1,11 +1,6 @@ EXTRA_DIST = SignatureNames.def OpcodeNames.def lib_LTLIBRARIES = libN3.la -THREADDIR=../../Mvm/CommonThread -ALLOCDIR=../../Mvm/Allocator -GCDIR=../../Mvm/GCMmap2 -INCLUDEDIRS=-I at srcdir@/$(THREADDIR) -I at srcdir@/$(ALLOCDIR) -I at srcdir@/$(GCDIR) - PREFIX=@prefix@ libN3_la_SOURCES = \ @@ -16,4 +11,4 @@ Opcodes.cpp NativeUtil.h NativeUtil.cpp PNetLib.cpp N3ModuleProvider.cpp N3ModuleProvider.h \ PNetLib.h BackTrace.cpp LowerArrayLength.cpp -libN3_la_CXXFLAGS =$(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -O2 -DSINGLE_VM +libN3_la_CXXFLAGS =-DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -O2 Modified: vmkit/trunk/lib/N3/VMCore/N3.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/N3.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/N3.cpp Fri Apr 11 11:20:48 2008 @@ -117,7 +117,7 @@ } else { sprintf(buf, "%s%s", cur, asciiz); } - + res = Reader::openFile(buf); ++idx; } Modified: vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp Fri Apr 11 11:20:48 2008 @@ -128,8 +128,10 @@ llvm::Function* CLIJit::compareExceptionLLVM; llvm::Function* CLIJit::arrayLengthLLVM; +#ifdef WITH_TRACER llvm::Function* CLIJit::markAndTraceLLVM; const llvm::FunctionType* CLIJit::markAndTraceLLVMType; +#endif llvm::Function* CLIJit::vmObjectTracerLLVM; llvm::Function* CLIJit::initialiseClassLLVM; llvm::Function* CLIJit::virtualLookupLLVM; @@ -251,7 +253,7 @@ const UTF8* mscorlib = vm->asciizConstructUTF8("mscorlib"); Assembly* ass = vm->loadAssembly(mscorlib, "dll"); if (ass == 0) - VMThread::get()->vm->error("can not find mscorlib.dll. Abort"); + VMThread::get()->vm->error("can not load mscorlib.dll. Abort"); vm->coreAssembly = ass; Modified: vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp Fri Apr 11 11:20:48 2008 @@ -11,6 +11,7 @@ #include #include "mvm/JIT.h" +#include "mvm/Method.h" #include "Assembly.h" #include "CLIJit.h" @@ -39,7 +40,7 @@ if (res == 0) { CLIJit::compile(meth->classDef, meth); void* res = mvm::jit::executionEngine->getPointerToGlobal(meth->methPtr); - meth->code = (mvm::Code*)((intptr_t)res - sizeof(intptr_t)); + meth->code = (mvm::Code*)((intptr_t)res - sizeof(mvm::Code)); meth->code->method()->definition(meth); } meth->classDef->release(); Modified: vmkit/trunk/lib/N3/VMCore/PNetLib.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/PNetLib.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/PNetLib.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/PNetLib.cpp Fri Apr 11 11:20:48 2008 @@ -678,21 +678,19 @@ #define ASSEMBLY_VALUE(obj) ((Assembly**)obj)[3] -#if !defined(__GNU__) -void* memrchr(const void* s, int c, size_t n) { - unsigned char* m = (unsigned char*) s; +void* sys_memrchr(const void* s, int c, size_t n) { + unsigned char* m = (unsigned char*) s + n; for (;;) { if (!(n--)) return NULL; else if (*m-- == (unsigned char)c) return (void*)(m+1); } } -#endif extern "C" VMObject* System_Reflection_Assembly_GetType(VMObject* obj, CLIString* str, bool onError, bool ignoreCase) { Assembly* ass = ASSEMBLY_VALUE(obj); const UTF8* utf8 = str->value; char* asciiz = utf8->UTF8ToAsciiz(); - char* index = (char*)memrchr(asciiz, '.', strlen(asciiz)); + char* index = (char*)sys_memrchr(asciiz, '.', strlen(asciiz)); N3* vm = ass->vm; index[0] = 0; @@ -717,9 +715,10 @@ VMCommonClass* type = (VMCommonClass*)((*N3::typeClrType)(Type).PointerVal); const UTF8* name = str->value; if (memberTypes == MEMBER_TYPES_PROPERTY) { - std::vector properties = type->properties; + std::vector > properties = + type->properties; Property *res = 0; - for (std::vector::iterator i = properties.begin(), + for (std::vector >::iterator i = properties.begin(), e = properties.end(); i!= e; ++i) { if ((*i)->name == name) { res = *i; Modified: vmkit/trunk/lib/N3/VMCore/VMClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMClass.h?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/VMClass.h (original) +++ vmkit/trunk/lib/N3/VMCore/VMClass.h Fri Apr 11 11:20:48 2008 @@ -62,7 +62,7 @@ VMObject* delegatee; std::vector display; Assembly* assembly; - std::vector properties; + std::vector > properties; llvm::Function* virtualTracer; llvm::Function* staticTracer; @@ -196,8 +196,8 @@ VMObject* delegatee; VMObject* getMethodDelegatee(); - std::vector params; - std::vector caches; + std::vector > params; + std::vector > caches; std::vector parameters; VMClass* classDef; llvm::Function* compiledPtr(); Modified: vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp?rev=49536&r1=49535&r2=49536&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/VirtualTables.cpp Fri Apr 11 11:20:48 2008 @@ -136,8 +136,8 @@ #undef ARRAYTRACER -#define TRACE_VECTOR(type,name) { \ - for (std::vector::iterator i = name.begin(), e = name.end(); \ +#define TRACE_VECTOR(type, name, alloc) { \ + for (std::vector >::iterator i = name.begin(), e = name.end(); \ i!= e; ++i) { \ (*i)->markAndTrace(); }} @@ -145,20 +145,20 @@ name->markAndTrace(); nameSpace->markAndTrace(); super->markAndTrace(); - TRACE_VECTOR(VMClass*, interfaces); + TRACE_VECTOR(VMClass*, interfaces, std::allocator); //lockVar->markAndTrace(); //condVar->markAndTrace(); - TRACE_VECTOR(VMMethod*, virtualMethods); - TRACE_VECTOR(VMMethod*, staticMethods); - TRACE_VECTOR(VMField*, virtualFields); - TRACE_VECTOR(VMField*, staticFields); + TRACE_VECTOR(VMMethod*, virtualMethods, std::allocator); + TRACE_VECTOR(VMMethod*, staticMethods, std::allocator); + TRACE_VECTOR(VMField*, virtualFields, std::allocator); + TRACE_VECTOR(VMField*, staticFields, std::allocator); delegatee->markAndTrace(); - TRACE_VECTOR(VMCommonClass*, display); + TRACE_VECTOR(VMCommonClass*, display, std::allocator); vm->markAndTrace(); assembly->markAndTrace(); //funcs->markAndTrace(); - TRACE_VECTOR(Property*, properties); + TRACE_VECTOR(Property*, properties, gc_allocator); codeVirtualTracer->markAndTrace(); codeStaticTracer->markAndTrace(); } @@ -167,7 +167,7 @@ VMCommonClass::tracer(sz); staticInstance->markAndTrace(); virtualInstance->markAndTrace(); - TRACE_VECTOR(VMClass*, innerClasses); + TRACE_VECTOR(VMClass*, innerClasses, std::allocator); outerClass->markAndTrace(); } @@ -186,8 +186,8 @@ delegatee->markAndTrace(); //signature->markAndTrace(); classDef->markAndTrace(); - TRACE_VECTOR(Param*, params); - TRACE_VECTOR(Enveloppe*, caches); + TRACE_VECTOR(Param*, params, gc_allocator); + TRACE_VECTOR(Enveloppe*, caches, gc_allocator); name->markAndTrace(); code->markAndTrace(); } @@ -199,7 +199,7 @@ } void VMCond::tracer(size_t sz) { - TRACE_VECTOR(VMThread*, threads); + TRACE_VECTOR(VMThread*, threads, std::allocator); } void LockObj::tracer(size_t sz) { @@ -281,7 +281,7 @@ usStream->markAndTrace(); blobStream->markAndTrace(); guidStream->markAndTrace(); - TRACE_VECTOR(Table*, tables); + TRACE_VECTOR(Table*, tables, gc_allocator); } void CLIString::tracer(size_t sz) { From dalej at apple.com Fri Apr 11 11:39:41 2008 From: dalej at apple.com (Dale Johannesen) Date: Fri, 11 Apr 2008 16:39:41 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49537 - /llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c Message-ID: <200804111639.m3BGdg0g003752@zion.cs.uiuc.edu> Author: johannes Date: Fri Apr 11 11:39:41 2008 New Revision: 49537 URL: http://llvm.org/viewvc/llvm-project?rev=49537&view=rev Log: Allow for null TYPE_SIZE_UNIT. Fixes 5847737. Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c?rev=49537&r1=49536&r2=49537&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c (original) +++ llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.c Fri Apr 11 11:39:41 2008 @@ -4898,7 +4898,7 @@ static bool rs6000_return_in_memory (tree type, tree fntype ATTRIBUTE_UNUSED) { - /* LLVM LOCAL begin strcut return check */ + /* LLVM LOCAL begin struct return check */ /* FIXME darwin ppc64 often returns structs partly in memory and partly in regs. The binary interface of return_in_memory (which does the work for aggregate_value_p) is not a good match for this; in fact @@ -4906,10 +4906,11 @@ means aggregate_value_p is not useful on this target for this purpose. This is a big nasty longterm problem. For now put things back the way they used to be (wrong, but fewer crashes). */ - if (TARGET_64BIT && TREE_CODE(TYPE_SIZE_UNIT(type)) == INTEGER_CST && + if (TARGET_64BIT && TYPE_SIZE_UNIT(type) && + TREE_CODE(TYPE_SIZE_UNIT(type)) == INTEGER_CST && TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type)) > 8) return true; - /* LLVM LOCAL end strcut return check */ + /* LLVM LOCAL end struct return check */ /* In the darwin64 abi, try to use registers for larger structs if possible. */ From sabre at nondot.org Fri Apr 11 11:42:06 2008 From: sabre at nondot.org (Chris Lattner) Date: Fri, 11 Apr 2008 16:42:06 -0000 Subject: [llvm-commits] [llvm] r49538 - /llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h Message-ID: <200804111642.m3BGg6OG003832@zion.cs.uiuc.edu> Author: lattner Date: Fri Apr 11 11:42:06 2008 New Revision: 49538 URL: http://llvm.org/viewvc/llvm-project?rev=49538&view=rev Log: improvements for IntrusiveRefCntPtr, patch by Mikhail Glushenkov Modified: llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h Modified: llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h?rev=49538&r1=49537&r2=49538&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h (original) +++ llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h Fri Apr 11 11:42:06 2008 @@ -121,6 +121,11 @@ retain(); } + IntrusiveRefCntPtr& operator=(const IntrusiveRefCntPtr& S) { + replace(S.getPtr()); + return *this; + } + template IntrusiveRefCntPtr& operator=(const IntrusiveRefCntPtr& S) { replace(S.getPtr()); @@ -140,7 +145,7 @@ T* getPtr() const { return Obj; } - typedef T * IntrusiveRefCntPtr::*unspecified_bool_type; + typedef T* (IntrusiveRefCntPtr::*unspecified_bool_type) () const; operator unspecified_bool_type() const { return Obj == 0 ? 0 : &IntrusiveRefCntPtr::getPtr; } @@ -156,7 +161,7 @@ void release() { if (Obj) Obj->Release(); } void replace(T* S) { - this_type(S).swap(this); + this_type(S).swap(*this); } }; From clattner at apple.com Fri Apr 11 11:42:23 2008 From: clattner at apple.com (Chris Lattner) Date: Fri, 11 Apr 2008 09:42:23 -0700 Subject: [llvm-commits] [PATCH] Fix a potential segfault in IntrusiveRefCntPtr.h In-Reply-To: <45025.81.172.134.32.1207852861.squirrel@webmail.sophsolutions.com> References: <45025.81.172.134.32.1207852861.squirrel@webmail.sophsolutions.com> Message-ID: <3BBCFE95-2DD8-49EA-829F-2460A1FBC34F@apple.com> On Apr 10, 2008, at 11:41 AM, Mikhail Glushenkov wrote: > This fixes a potential segfault in IntrusiveRefCntPtr. This class > had no > non-template assignment operator, so the default implementation was > silently generated and used. > > Also fixes conversion to unspecified-bool-type and replace() method. Thanks, applied: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080407/060980.html -Chris From evan.cheng at apple.com Fri Apr 11 11:57:32 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 11 Apr 2008 09:57:32 -0700 Subject: [llvm-commits] PATCH: Tailcallopt x86 byval argument handling In-Reply-To: References: <57E157A7-FF7F-4CCD-B4B1-44919CF8AAC3@apple.com> Message-ID: <31B9A299-A35C-4E4D-BA51-906C9AD743B1@apple.com> Looks good. Thanks! Evan On Apr 10, 2008, at 5:52 PM, Arnold Schwaighofer wrote: > On Fri, Apr 11, 2008 at 2:10 AM, Evan Cheng > wrote: >> Thanks. The patch looks good. Have you verified the register >> allocator >> does eliminate the unnecessary copies? > Depends on what your notion of verify is. I checked with a few > examples. :) > > The copying of arguments for register parameters to virtual registers > and back to the parameter's register is only emitted in cases where > tail call opt is on and the function call contains a byval argument. > So tail calls without byval arguments would not pay the price. So even > in this case i wouldn't be so bad? > > take for example the following call: > > define fastcc i64 @tailcaller(i64 %b, %struct.s* byval %a) { > entry: > %tmp2 = getelementptr %struct.s* %a, i32 0, i32 1 > %tmp3 = load i64* %tmp2, align 8 > %tmp4 = tail call fastcc i64 @tailcallee(%struct.s* %a byval, > i64 %tmp3, i64 %b, i64 7, i64 13, i64 17) > ret i64 %tmp4 > } > > as you can see 3rd (7) and 5th (17) argument are directly moved to > their corresponding argument register (rdx,r8). only rsi, rdi, rcx are > moved to intermediate registers as expected (killed by byval > lowering). as note that when i say 3rd i really mean 4th (b) but since > the first argument is byval and passed on the stack it i do not take > into account. so it seems the allocator is doing it's job nicely. > > tailcaller: > pushq %rbx > subq $32, %rsp > movq %rdi, %rax > movq 56(%rsp), %r9 > movl $6, %r10d > leaq 48(%rsp), %rsi > movq %r10, %rcx > movq %rsp, %rdi > rep;movsl > leaq 48(%rsp), %rdi > movl $13, %ebx > movl $7, %edx > movl $17, %r8d > movq %r10, %rcx > movq %rsp, %rsi > rep;movsl > movq %r9, %rdi > movq %rax, %rsi > movq %rbx, %rcx > addq $32, %rsp > popq %rbx > jmp tailcallee # TAILCALL > .size tailcaller, .-tailcaller > > okay to commit? > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From dpatel at apple.com Fri Apr 11 12:45:39 2008 From: dpatel at apple.com (Devang Patel) Date: Fri, 11 Apr 2008 17:45:39 -0000 Subject: [llvm-commits] [llvm] r49540 - /llvm/trunk/utils/buildit/build_llvm Message-ID: <200804111745.m3BHjda2005853@zion.cs.uiuc.edu> Author: dpatel Date: Fri Apr 11 12:45:39 2008 New Revision: 49540 URL: http://llvm.org/viewvc/llvm-project?rev=49540&view=rev Log: Change llvm tools install location. Modified: llvm/trunk/utils/buildit/build_llvm Modified: llvm/trunk/utils/buildit/build_llvm URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/buildit/build_llvm?rev=49540&r1=49539&r2=49540&view=diff ============================================================================== --- llvm/trunk/utils/buildit/build_llvm (original) +++ llvm/trunk/utils/buildit/build_llvm Fri Apr 11 12:45:39 2008 @@ -59,6 +59,11 @@ # If the user has CC set in their environment unset it now unset CC +DT_HOME=$DEST_DIR//Developer/usr +if [ "x$DEVELOPER_BIN" != "x" ]; then +DT_HOME=$DEST_DIR/$DEVELOPER_DIR/usr +fi + ################################################################################ # Run the build. @@ -75,7 +80,7 @@ cd $DIR/obj-llvm || exit 1 if [ \! -f Makefile.config ]; then - $SRC_DIR/llvm/configure --prefix=$DEST_DIR$DEST_ROOT \ + $SRC_DIR/llvm/configure --prefix=$DT_HOME/local \ --enable-targets=x86,powerpc,cbe \ --enable-assertions=$LLVM_ASSERTIONS \ --enable-optimized=$LLVM_OPTIMIZED \ @@ -145,14 +150,9 @@ fi cd $DEST_DIR$DEST_ROOT -# LTO is part of developer tools -LTO_HOME=$DEST_DIR//Developer/usr -if [ "x$DEVELOPER_BIN" != "x" ]; then -LTO_HOME=$DEST_DIR/$DEVELOPER_DIR/usr -fi -mkdir -p $LTO_HOME/lib -mv lib/libLTO.dylib $LTO_HOME/lib/libLTO.dylib +mkdir -p $DT_HOME/lib +mv lib/libLTO.dylib $DT_HOME/lib/libLTO.dylib rm -f lib/libLTO.a lib/libLTO.la From ggreif at gmail.com Fri Apr 11 12:52:40 2008 From: ggreif at gmail.com (Gabor Greif) Date: Fri, 11 Apr 2008 17:52:40 -0000 Subject: [llvm-commits] [llvm] r49541 - /llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Message-ID: <200804111752.m3BHqeM4006086@zion.cs.uiuc.edu> Author: ggreif Date: Fri Apr 11 12:52:40 2008 New Revision: 49541 URL: http://llvm.org/viewvc/llvm-project?rev=49541&view=rev Log: fix double-init problem caused in r49425 Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp?rev=49541&r1=49540&r2=49541&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Fri Apr 11 12:52:40 2008 @@ -525,6 +525,7 @@ if (V->getType() == Type::VoidTy) return; Op<0>().init(V, this); + return; } Use *OL = OperandList; From evan.cheng at apple.com Fri Apr 11 12:53:36 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 11 Apr 2008 17:53:36 -0000 Subject: [llvm-commits] [llvm] r49542 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/LiveIntervalAnalysis.cpp lib/CodeGen/VirtRegMap.cpp lib/CodeGen/VirtRegMap.h Message-ID: <200804111753.m3BHrbYj006126@zion.cs.uiuc.edu> Author: evancheng Date: Fri Apr 11 12:53:36 2008 New Revision: 49542 URL: http://llvm.org/viewvc/llvm-project?rev=49542&view=rev Log: Use of implicit_def is not part of live interval. Create empty intervals for the uses when the live interval is being spilled. Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/lib/CodeGen/VirtRegMap.cpp llvm/trunk/lib/CodeGen/VirtRegMap.h Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h?rev=49542&r1=49541&r2=49542&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Fri Apr 11 12:53:36 2008 @@ -394,9 +394,11 @@ BitVector &RestoreMBBs, std::map >&RestoreIdxes); - /// removeSpilledImpDefs - Remove IMPLICIT_DEF instructions which are being - /// spilled. - void removeSpilledImpDefs(const LiveInterval &li, VirtRegMap &vrm); + /// handleSpilledImpDefs - Remove IMPLICIT_DEF instructions which are being + /// spilled and create empty intervals for their uses. + void handleSpilledImpDefs(const LiveInterval &li, VirtRegMap &vrm, + const TargetRegisterClass* rc, + std::vector &NewLIs); /// rewriteImplicitOps - Rewrite implicit use operands of MI (i.e. uses of /// interval on to-be re-materialized operands of MI) with new register. Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=49542&r1=49541&r2=49542&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Fri Apr 11 12:53:36 2008 @@ -1319,19 +1319,37 @@ Restores[i].index = -1; } -/// removeSpilledImpDefs - Remove IMPLICIT_DEF instructions which are being -/// spilled. -void LiveIntervals::removeSpilledImpDefs(const LiveInterval &li, - VirtRegMap &vrm) { +/// handleSpilledImpDefs - Remove IMPLICIT_DEF instructions which are being +/// spilled and create empty intervals for their uses. +void +LiveIntervals::handleSpilledImpDefs(const LiveInterval &li, VirtRegMap &vrm, + const TargetRegisterClass* rc, + std::vector &NewLIs) { for (MachineRegisterInfo::reg_iterator ri = mri_->reg_begin(li.reg), re = mri_->reg_end(); ri != re; ) { + MachineOperand &O = ri.getOperand(); MachineInstr *MI = &*ri; ++ri; - if (MI->getOpcode() != TargetInstrInfo::IMPLICIT_DEF) - continue; - RemoveMachineInstrFromMaps(MI); - vrm.RemoveMachineInstrFromMaps(MI); - MI->eraseFromParent(); + if (O.isDef()) { + assert(MI->getOpcode() == TargetInstrInfo::IMPLICIT_DEF && + "Register def was not rewritten?"); + RemoveMachineInstrFromMaps(MI); + vrm.RemoveMachineInstrFromMaps(MI); + MI->eraseFromParent(); + } else { + // This must be an use of an implicit_def so it's not part of the live + // interval. Create a new empty live interval for it. + // FIXME: Can we simply erase some of the instructions? e.g. Stores? + unsigned NewVReg = mri_->createVirtualRegister(rc); + vrm.grow(); + vrm.setIsImplicitlyDefined(NewVReg); + NewLIs.push_back(&getOrCreateInterval(NewVReg)); + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + MachineOperand &MO = MI->getOperand(i); + if (MO.isReg() && MO.getReg() == li.reg) + MO.setReg(NewVReg); + } + } } } @@ -1415,7 +1433,7 @@ IsFirstRange = false; } - removeSpilledImpDefs(li, vrm); + handleSpilledImpDefs(li, vrm, rc, NewLIs); return NewLIs; } @@ -1485,7 +1503,7 @@ // Insert spills / restores if we are splitting. if (!TrySplit) { - removeSpilledImpDefs(li, vrm); + handleSpilledImpDefs(li, vrm, rc, NewLIs); return NewLIs; } @@ -1640,7 +1658,7 @@ } } - removeSpilledImpDefs(li, vrm); + handleSpilledImpDefs(li, vrm, rc, RetNewLIs); return RetNewLIs; } Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegMap.cpp?rev=49542&r1=49541&r2=49542&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/VirtRegMap.cpp (original) +++ llvm/trunk/lib/CodeGen/VirtRegMap.cpp Fri Apr 11 12:53:36 2008 @@ -21,6 +21,7 @@ #include "llvm/Function.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetInstrInfo.h" @@ -69,6 +70,8 @@ Virt2SplitKillMap(0), ReMatMap(NULL), ReMatId(MAX_STACK_SLOT+1), LowSpillSlot(NO_STACK_SLOT), HighSpillSlot(NO_STACK_SLOT) { SpillSlotToUsesMap.resize(8); + ImplicitDefed.resize(MF.getRegInfo().getLastVirtReg()+1- + TargetRegisterInfo::FirstVirtualRegister); grow(); } @@ -80,6 +83,7 @@ Virt2SplitMap.grow(LastVirtReg); Virt2SplitKillMap.grow(LastVirtReg); ReMatMap.grow(LastVirtReg); + ImplicitDefed.resize(LastVirtReg-TargetRegisterInfo::FirstVirtualRegister+1); } int VirtRegMap::assignVirt2StackSlot(unsigned virtReg) { @@ -1155,6 +1159,8 @@ // We want to process implicit virtual register uses first. if (MO.isImplicit()) + // If the virtual register is implicitly defined, emit a implicit_def + // before so scavenger knows it's "defined". VirtUseOps.insert(VirtUseOps.begin(), i); else VirtUseOps.push_back(i); @@ -1177,6 +1183,8 @@ ReusedOperands.markClobbered(Phys); unsigned RReg = SubIdx ? TRI->getSubReg(Phys, SubIdx) : Phys; MI.getOperand(i).setReg(RReg); + if (VRM.isImplicitlyDefined(VirtReg)) + BuildMI(MBB, MI, TII->get(TargetInstrInfo::IMPLICIT_DEF), RReg); continue; } Modified: llvm/trunk/lib/CodeGen/VirtRegMap.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegMap.h?rev=49542&r1=49541&r2=49542&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/VirtRegMap.h (original) +++ llvm/trunk/lib/CodeGen/VirtRegMap.h Fri Apr 11 12:53:36 2008 @@ -18,6 +18,7 @@ #define LLVM_CODEGEN_VIRTREGMAP_H #include "llvm/Target/TargetRegisterInfo.h" +#include "llvm/ADT/BitVector.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/IndexedMap.h" #include "llvm/ADT/SmallPtrSet.h" @@ -116,6 +117,10 @@ /// SpillSlotToUsesMap - Records uses for each register spill slot. SmallVector, 8> SpillSlotToUsesMap; + /// ImplicitDefed - One bit for each virtual register. If set it indicates + /// the register is implicitly defined. + BitVector ImplicitDefed; + VirtRegMap(const VirtRegMap&); // DO NOT IMPLEMENT void operator=(const VirtRegMap&); // DO NOT IMPLEMENT @@ -382,6 +387,16 @@ return !SpillSlotToUsesMap[FrameIndex-LowSpillSlot].empty(); } + /// @brief Mark the specified register as being implicitly defined. + void setIsImplicitlyDefined(unsigned VirtReg) { + ImplicitDefed.set(VirtReg-TargetRegisterInfo::FirstVirtualRegister); + } + + /// @brief Returns true if the virtual register is implicitly defined. + bool isImplicitlyDefined(unsigned VirtReg) const { + return ImplicitDefed[VirtReg-TargetRegisterInfo::FirstVirtualRegister]; + } + /// @brief Updates information about the specified virtual register's value /// folded into newMI machine instruction. void virtFolded(unsigned VirtReg, MachineInstr *OldMI, MachineInstr *NewMI, From evan.cheng at apple.com Fri Apr 11 12:54:45 2008 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 11 Apr 2008 17:54:45 -0000 Subject: [llvm-commits] [llvm] r49543 - in /llvm/trunk: lib/CodeGen/PHIElimination.cpp test/CodeGen/ARM/2008-04-11-PHIofImpDef.ll Message-ID: <200804111754.m3BHsj6I006167@zion.cs.uiuc.edu> Author: evancheng Date: Fri Apr 11 12:54:45 2008 New Revision: 49543 URL: http://llvm.org/viewvc/llvm-project?rev=49543&view=rev Log: If a PHI node has a single implicit_def source, replace it with an implicit_def instead of a copy. Added: llvm/trunk/test/CodeGen/ARM/2008-04-11-PHIofImpDef.ll Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.cpp?rev=49543&r1=49542&r2=49543&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.cpp (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.cpp Fri Apr 11 12:54:45 2008 @@ -18,6 +18,7 @@ #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstr.h" +#include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" @@ -126,6 +127,13 @@ return true; } +static bool isSourceDefinedByImplicitDef(MachineInstr *MPhi, unsigned SrcIdx, + MachineRegisterInfo *MRI) { + unsigned SrcReg = MPhi->getOperand(SrcIdx*2+1).getReg(); + MachineInstr *DefMI = MRI->getVRegDef(SrcReg); + return DefMI->getOpcode() == TargetInstrInfo::IMPLICIT_DEF; +} + /// LowerAtomicPHINode - Lower the PHI node at the top of the specified block, /// under the assuption that it needs to be lowered in a way that supports /// atomic execution of PHIs. This lowering method is always correct all of the @@ -135,6 +143,7 @@ // Unlink the PHI node from the basic block, but don't delete the PHI yet. MachineInstr *MPhi = MBB.remove(MBB.begin()); + unsigned NumSrcs = (MPhi->getNumOperands() - 1) / 2; unsigned DestReg = MPhi->getOperand(0).getReg(); // Create a new register for the incoming PHI arguments. @@ -147,7 +156,12 @@ // into the phi node destination. // const TargetInstrInfo *TII = MF.getTarget().getInstrInfo(); - TII->copyRegToReg(MBB, AfterPHIsIt, DestReg, IncomingReg, RC, RC); + if (NumSrcs == 1 && isSourceDefinedByImplicitDef(MPhi, 0, MRI)) + // If the only source of a PHI node is an implicit_def, just emit an + // implicit_def instead of a copy. + BuildMI(MBB, AfterPHIsIt, TII->get(TargetInstrInfo::IMPLICIT_DEF), DestReg); + else + TII->copyRegToReg(MBB, AfterPHIsIt, DestReg, IncomingReg, RC, RC); // Update live variable information if there is any... LiveVariables *LV = getAnalysisToUpdate(); @@ -189,13 +203,13 @@ // the IncomingReg register in the corresponding predecessor basic block. // SmallPtrSet MBBsInsertedInto; - for (int i = MPhi->getNumOperands() - 1; i >= 2; i-=2) { - unsigned SrcReg = MPhi->getOperand(i-1).getReg(); + for (int i = NumSrcs - 1; i >= 0; --i) { + unsigned SrcReg = MPhi->getOperand(i*2+1).getReg(); assert(TargetRegisterInfo::isVirtualRegister(SrcReg) && "Machine PHI Operands must all be virtual registers!"); // If source is defined by an implicit def, there is no need to insert - // a copy. + // a copy unless it's the only source. MachineInstr *DefMI = MRI->getVRegDef(SrcReg); if (DefMI->getOpcode() == TargetInstrInfo::IMPLICIT_DEF) { ImpDefs.insert(DefMI); @@ -204,7 +218,7 @@ // Get the MachineBasicBlock equivalent of the BasicBlock that is the // source path the PHI. - MachineBasicBlock &opBlock = *MPhi->getOperand(i).getMBB(); + MachineBasicBlock &opBlock = *MPhi->getOperand(i*2+2).getMBB(); // Check to make sure we haven't already emitted the copy for this block. // This can happen because PHI nodes may have multiple entries for the Added: llvm/trunk/test/CodeGen/ARM/2008-04-11-PHIofImpDef.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2008-04-11-PHIofImpDef.ll?rev=49543&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2008-04-11-PHIofImpDef.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2008-04-11-PHIofImpDef.ll Fri Apr 11 12:54:45 2008 @@ -0,0 +1,3544 @@ +; RUN: llvm-as < %s | llc -mtriple=arm-apple-darwin + +declare void @foo(i8*, i8*, i32, i32, i32, i32, i32, i32, i32) + +define void @t() nounwind { + br label %1 +;

       BasicBlock* block = new BasicBlock("entry", mul_add);
    -  LLVMBuilder builder(block);
    +  IRBuilder builder(block);
     
    -

    We create a new basic block, as you might expect, by calling its constructor. All we need to tell it is its name and the function to which it belongs. In addition, we???re creating an LLVMBuilder object, which is a convenience interface for creating instructions and appending them to the end of a block. Instructions can be created through their constructors as well, but some of their interfaces are quite complicated. Unless you need a lot of control, using LLVMBuilder will make your life simpler.

    +

    We create a new basic block, as you might expect, by calling its constructor. All we need to tell it is its name and the function to which it belongs. In addition, we???re creating an IRBuilder object, which is a convenience interface for creating instructions and appending them to the end of a block. Instructions can be created through their constructors as well, but some of their interfaces are quite complicated. Unless you need a lot of control, using IRBuilder will make your life simpler.

    @@ -163,7 +163,7 @@
     
    -

    The final step in creating our function is to create the instructions that make it up. Our mul_add function is composed of just three instructions: a multiply, an add, and a return. LLVMBuilder gives us a simple interface for constructing these instructions and appending them to the ???entry??? block. Each of the calls to LLVMBuilder returns a Value* that represents the value yielded by the instruction. You???ll also notice that, above, x, y, and z are also Value*???s, so it???s clear that instructions operate on Value*???s.

    +

    The final step in creating our function is to create the instructions that make it up. Our mul_add function is composed of just three instructions: a multiply, an add, and a return. IRBuilder gives us a simple interface for constructing these instructions and appending them to the ???entry??? block. Each of the calls to IRBuilder returns a Value* that represents the value yielded by the instruction. You???ll also notice that, above, x, y, and z are also Value*???s, so it???s clear that instructions operate on Value*???s.

    And that???s it! Now you can compile and run your code, and get a wonderful textual print out of the LLVM IR we saw at the beginning. To compile, use the following command line as a guide:

    Modified: llvm/trunk/docs/tutorial/JITTutorial2.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/JITTutorial2.html?rev=49604&r1=49603&r2=49604&view=diff ============================================================================== --- llvm/trunk/docs/tutorial/JITTutorial2.html (original) +++ llvm/trunk/docs/tutorial/JITTutorial2.html Sun Apr 13 01:22:09 2008 @@ -56,7 +56,7 @@ #include <llvm/PassManager.h> #include <llvm/Analysis/Verifier.h> #include <llvm/Assembly/PrintModulePass.h> -#include <llvm/Support/LLVMBuilder.h> +#include <llvm/Support/IRBuilder.h> using namespace llvm; @@ -110,13 +110,13 @@
    -  LLVMBuilder builder(entry);
    +  IRBuilder builder(entry);
       Value* xEqualsY = builder.CreateICmpEQ(x, y, "tmp");
       builder.CreateCondBr(xEqualsY, ret, cond_false);
     
    -

    Our next block, ret, is pretty simple: it just returns the value of x. Recall that this block is only reached if x == y, so this is the correct behavior. Notice that instead of creating a new LLVMBuilder for each block, we can use SetInsertPoint to retarget our existing one. This saves on construction and memory allocation costs.

    +

    Our next block, ret, is pretty simple: it just returns the value of x. Recall that this block is only reached if x == y, so this is the correct behavior. Notice that instead of creating a new IRBuilder for each block, we can use SetInsertPoint to retarget our existing one. This saves on construction and memory allocation costs.

    
    Modified: llvm/trunk/docs/tutorial/LangImpl3.html
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl3.html?rev=49604&r1=49603&r2=49604&view=diff
    
    ==============================================================================
    --- llvm/trunk/docs/tutorial/LangImpl3.html (original)
    +++ llvm/trunk/docs/tutorial/LangImpl3.html Sun Apr 13 01:22:09 2008
    @@ -111,7 +111,7 @@
     Value *ErrorV(const char *Str) { Error(Str); return 0; }
     
     static Module *TheModule;
    -static LLVMBuilder Builder;
    +static IRBuilder Builder;
     static std::map<std::string, Value*> NamedValues;
     
    @@ -123,7 +123,7 @@

    The Builder object is a helper object that makes it easy to generate LLVM instructions. Instances of the LLVMBuilder +href="http://llvm.org/doxygen/IRBuilder_8h-source.html">IRBuilder class keep track of the current place to insert instructions and has methods to create new instructions.

    @@ -216,7 +216,7 @@

    In the example above, the LLVM builder class is starting to show its value. -LLVMBuilder knows where to insert the newly created instruction, all you have to +IRBuilder knows where to insert the newly created instruction, all you have to do is specify what instruction to create (e.g. with CreateAdd), which operands to use (L and R here) and optionally provide a name for the generated instruction.

    @@ -680,7 +680,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/Module.h" #include "llvm/Analysis/Verifier.h" -#include "llvm/Support/LLVMBuilder.h" +#include "llvm/Support/IRBuilder.h" #include <cstdio> #include <string> #include <map> @@ -1023,7 +1023,7 @@ //===----------------------------------------------------------------------===// static Module *TheModule; -static LLVMBuilder Builder; +static IRBuilder Builder; static std::map<std::string, Value*> NamedValues; Value *ErrorV(const char *Str) { Error(Str); return 0; } Modified: llvm/trunk/docs/tutorial/LangImpl4.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl4.html?rev=49604&r1=49603&r2=49604&view=diff ============================================================================== --- llvm/trunk/docs/tutorial/LangImpl4.html (original) +++ llvm/trunk/docs/tutorial/LangImpl4.html Sun Apr 13 01:22:09 2008 @@ -56,8 +56,8 @@

    Our demonstration for Chapter 3 is elegant and easy to extend. Unfortunately, -it does not produce wonderful code. For example, when compiling simple code, -we don't get obvious optimizations:

    +it does not produce wonderful code. The IRBuilder, however, does give us +obvious optimizations when compiling simple code:

    @@ -65,36 +65,14 @@
     Read function definition:
     define double @test(double %x) {
     entry:
    -        %addtmp = add double 1.000000e+00, 2.000000e+00
    -        %addtmp1 = add double %addtmp, %x
    -        ret double %addtmp1
    +        %addtmp = add double 3.000000e+00, %x
    +        ret double %addtmp
     }
     
    -

    This code is a very, very literal transcription of the AST built by parsing -the input. As such, this transcription lacks optimizations like constant folding (we'd like to get "add x, 3.0" in the example above) as well as other more important -optimizations. Constant folding, in particular, is a very common and very -important optimization: so much so that many language implementors implement -constant folding support in their AST representation.

    - -

    With LLVM, you don't need this support in the AST. Since all calls to build LLVM IR go through -the LLVM builder, it would be nice if the builder itself checked to see if there -was a constant folding opportunity when you call it. If so, it could just do -the constant fold and return the constant instead of creating an instruction. -This is exactly what the LLVMFoldingBuilder class does. Lets make one -change: - -

    -
    -static LLVMFoldingBuilder Builder;
    -
    -
    - -

    All we did was switch from LLVMBuilder to -LLVMFoldingBuilder. Though we change no other code, we now have all of our -instructions implicitly constant folded without us having to do anything -about it. For example, the input above now compiles to:

    +

    This code is not a literal transcription of the AST built by parsing the +input. That would be:

    @@ -102,20 +80,30 @@
     Read function definition:
     define double @test(double %x) {
     entry:
    -        %addtmp = add double 3.000000e+00, %x
    -        ret double %addtmp
    +        %addtmp = add double 2.000000e+00, 1.000000e+00
    +        %addtmp1 = add double %addtmp, %x
    +        ret double %addtmp1
     }
     
    +Constant folding, as seen above, in particular, is a very common and very +important optimization: so much so that many language implementors implement +constant folding support in their AST representation.

    + +

    With LLVM, you don't need this support in the AST. Since all calls to build +LLVM IR go through the LLVM IR builder, the builder itself checked to see if +there was a constant folding opportunity when you call it. If so, it just does +the constant fold and return the constant instead of creating an instruction. +

    Well, that was easy :). In practice, we recommend always using -LLVMFoldingBuilder when generating code like this. It has no +IRBuilder when generating code like this. It has no "syntactic overhead" for its use (you don't have to uglify your compiler with constant checks everywhere) and it can dramatically reduce the amount of LLVM IR that is generated in some cases (particular for languages with a macro preprocessor or that use a lot of constants).

    -

    On the other hand, the LLVMFoldingBuilder is limited by the fact +

    On the other hand, the IRBuilder is limited by the fact that it does all of its analysis inline with the code as it is built. If you take a slightly more complex example:

    @@ -525,7 +513,7 @@ #include "llvm/Analysis/Verifier.h" #include "llvm/Target/TargetData.h" #include "llvm/Transforms/Scalar.h" -#include "llvm/Support/LLVMBuilder.h" +#include "llvm/Support/IRBuilder.h" #include <cstdio> #include <string> #include <map> @@ -868,7 +856,7 @@ //===----------------------------------------------------------------------===// static Module *TheModule; -static LLVMFoldingBuilder Builder; +static IRBuilder Builder; static std::map<std::string, Value*> NamedValues; static FunctionPassManager *TheFPM; Modified: llvm/trunk/docs/tutorial/LangImpl5.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl5.html?rev=49604&r1=49603&r2=49604&view=diff ============================================================================== --- llvm/trunk/docs/tutorial/LangImpl5.html (original) +++ llvm/trunk/docs/tutorial/LangImpl5.html Sun Apr 13 01:22:09 2008 @@ -400,7 +400,7 @@

    Once the blocks are created, we can emit the conditional branch that chooses between them. Note that creating new blocks does not implicitly affect the -LLVMBuilder, so it is still inserting into the block that the condition +IRBuilder, so it is still inserting into the block that the condition went into. Also note that it is creating a branch to the "then" block and the "else" block, even though the "else" block isn't inserted into the function yet. This is all ok: it is the standard way that LLVM supports forward @@ -907,7 +907,7 @@ #include "llvm/Analysis/Verifier.h" #include "llvm/Target/TargetData.h" #include "llvm/Transforms/Scalar.h" -#include "llvm/Support/LLVMBuilder.h" +#include "llvm/Support/IRBuilder.h" #include <cstdio> #include <string> #include <map> @@ -1352,7 +1352,7 @@ //===----------------------------------------------------------------------===// static Module *TheModule; -static LLVMFoldingBuilder Builder; +static IRBuilder Builder; static std::map<std::string, Value*> NamedValues; static FunctionPassManager *TheFPM; Modified: llvm/trunk/docs/tutorial/LangImpl6.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl6.html?rev=49604&r1=49603&r2=49604&view=diff ============================================================================== --- llvm/trunk/docs/tutorial/LangImpl6.html (original) +++ llvm/trunk/docs/tutorial/LangImpl6.html Sun Apr 13 01:22:09 2008 @@ -827,7 +827,7 @@ #include "llvm/Analysis/Verifier.h" #include "llvm/Target/TargetData.h" #include "llvm/Transforms/Scalar.h" -#include "llvm/Support/LLVMBuilder.h" +#include "llvm/Support/IRBuilder.h" #include <cstdio> #include <string> #include <map> @@ -1357,7 +1357,7 @@ //===----------------------------------------------------------------------===// static Module *TheModule; -static LLVMFoldingBuilder Builder; +static IRBuilder Builder; static std::map<std::string, Value*> NamedValues; static FunctionPassManager *TheFPM; Modified: llvm/trunk/docs/tutorial/LangImpl7.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl7.html?rev=49604&r1=49603&r2=49604&view=diff ============================================================================== --- llvm/trunk/docs/tutorial/LangImpl7.html (original) +++ llvm/trunk/docs/tutorial/LangImpl7.html Sun Apr 13 01:22:09 2008 @@ -422,14 +422,14 @@ /// the function. This is used for mutable variables etc. static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction, const std::string &VarName) { - LLVMBuilder TmpB(&TheFunction->getEntryBlock(), - TheFunction->getEntryBlock().begin()); + IRBuilder TmpB(&TheFunction->getEntryBlock(), + TheFunction->getEntryBlock().begin()); return TmpB.CreateAlloca(Type::DoubleTy, 0, VarName.c_str()); } -

    This funny looking code creates an LLVMBuilder object that is pointing at +

    This funny looking code creates an IRBuilder object that is pointing at the first instruction (.begin()) of the entry block. It then creates an alloca with the expected name and returns it. Because all values in Kaleidoscope are doubles, there is no need to pass in a type to use.

    @@ -1009,7 +1009,7 @@ #include "llvm/Analysis/Verifier.h" #include "llvm/Target/TargetData.h" #include "llvm/Transforms/Scalar.h" -#include "llvm/Support/LLVMBuilder.h" +#include "llvm/Support/IRBuilder.h" #include <cstdio> #include <string> #include <map> @@ -1605,7 +1605,7 @@ //===----------------------------------------------------------------------===// static Module *TheModule; -static LLVMFoldingBuilder Builder; +static IRBuilder Builder; static std::map<std::string, AllocaInst*> NamedValues; static FunctionPassManager *TheFPM; @@ -1615,8 +1615,8 @@ /// the function. This is used for mutable variables etc. static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction, const std::string &VarName) { - LLVMBuilder TmpB(&TheFunction->getEntryBlock(), - TheFunction->getEntryBlock().begin()); + IRBuilder TmpB(&TheFunction->getEntryBlock(), + TheFunction->getEntryBlock().begin()); return TmpB.CreateAlloca(Type::DoubleTy, 0, VarName.c_str()); } Modified: llvm/trunk/docs/tutorial/OCamlLangImpl3.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/OCamlLangImpl3.html?rev=49604&r1=49603&r2=49604&view=diff ============================================================================== --- llvm/trunk/docs/tutorial/OCamlLangImpl3.html (original) +++ llvm/trunk/docs/tutorial/OCamlLangImpl3.html Sun Apr 13 01:22:09 2008 @@ -108,7 +108,7 @@

    The Codegen.builder object is a helper object that makes it easy to generate LLVM instructions. Instances of the LLVMBuilder +href="http://llvm.org/doxygen/IRBuilder_8h-source.html">IRBuilder class keep track of the current place to insert instructions and has methods to create new instructions.

    @@ -194,7 +194,7 @@

    In the example above, the LLVM builder class is starting to show its value. -LLVMBuilder knows where to insert the newly created instruction, all you have to +IRBuilder knows where to insert the newly created instruction, all you have to do is specify what instruction to create (e.g. with Llvm.create_add), which operands to use (lhs and rhs here) and optionally provide a name for the generated instruction.

    Modified: llvm/trunk/docs/tutorial/OCamlLangImpl4.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/OCamlLangImpl4.html?rev=49604&r1=49603&r2=49604&view=diff ============================================================================== --- llvm/trunk/docs/tutorial/OCamlLangImpl4.html (original) +++ llvm/trunk/docs/tutorial/OCamlLangImpl4.html Sun Apr 13 01:22:09 2008 @@ -58,7 +58,8 @@
    -

    Note: the ocaml bindings already use LLVMFoldingBuilder.

    +

    Note: the default IRBuilder now always includes the constant +folding optimisations below.

    Our demonstration for Chapter 3 is elegant and easy to extend. Unfortunately, Modified: llvm/trunk/docs/tutorial/OCamlLangImpl5.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/OCamlLangImpl5.html?rev=49604&r1=49603&r2=49604&view=diff ============================================================================== --- llvm/trunk/docs/tutorial/OCamlLangImpl5.html (original) +++ llvm/trunk/docs/tutorial/OCamlLangImpl5.html Sun Apr 13 01:22:09 2008 @@ -455,7 +455,7 @@

    Once the blocks are created, we can emit the conditional branch that chooses between them. Note that creating new blocks does not implicitly affect the -LLVMBuilder, so it is still inserting into the block that the condition +IRBuilder, so it is still inserting into the block that the condition went into. This is why we needed to save the "start" block.

    Modified: llvm/trunk/examples/BrainF/BrainF.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainF.cpp?rev=49604&r1=49603&r2=49604&view=diff ============================================================================== --- llvm/trunk/examples/BrainF/BrainF.cpp (original) +++ llvm/trunk/examples/BrainF/BrainF.cpp Sun Apr 13 01:22:09 2008 @@ -71,7 +71,7 @@ brainf_func = cast(module-> getOrInsertFunction("brainf", Type::VoidTy, NULL)); - builder = new LLVMBuilder(BasicBlock::Create(label, brainf_func)); + builder = new IRBuilder(BasicBlock::Create(label, brainf_func)); //%arr = malloc i8, i32 %d ConstantInt *val_mem = ConstantInt::get(APInt(32, memtotal)); @@ -193,7 +193,7 @@ Value *tape_0 = getchar_call; //%tape.%d = trunc i32 %tape.%d to i8 - TruncInst *tape_1 = builder-> + Value *tape_1 = builder-> CreateTrunc(tape_0, IntegerType::Int8Ty, tapereg); //store i8 %tape.%d, i8 *%head.%d @@ -207,7 +207,7 @@ LoadInst *tape_0 = builder->CreateLoad(curhead, tapereg); //%tape.%d = sext i8 %tape.%d to i32 - SExtInst *tape_1 = builder-> + Value *tape_1 = builder-> CreateSExt(tape_0, IntegerType::Int32Ty, tapereg); //call i32 @putchar(i32 %tape.%d) @@ -232,15 +232,15 @@ if (comflag & flag_arraybounds) { //%test.%d = icmp uge i8 *%head.%d, %arrmax - ICmpInst *test_0 = builder-> + Value *test_0 = builder-> CreateICmpUGE(curhead, ptr_arrmax, testreg); //%test.%d = icmp ult i8 *%head.%d, %arr - ICmpInst *test_1 = builder-> + Value *test_1 = builder-> CreateICmpULT(curhead, ptr_arr, testreg); //%test.%d = or i1 %test.%d, %test.%d - BinaryOperator *test_2 = builder-> + Value *test_2 = builder-> CreateOr(test_0, test_1, testreg); //br i1 %test.%d, label %main.%d, label %main.%d @@ -259,7 +259,7 @@ LoadInst *tape_0 = builder->CreateLoad(curhead, tapereg); //%tape.%d = add i8 %tape.%d, %d - BinaryOperator *tape_1 = builder-> + Value *tape_1 = builder-> CreateAdd(tape_0, ConstantInt::get(APInt(8, curvalue)), tapereg); //store i8 %tape.%d, i8 *%head.%d\n" Modified: llvm/trunk/examples/BrainF/BrainF.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainF.h?rev=49604&r1=49603&r2=49604&view=diff ============================================================================== --- llvm/trunk/examples/BrainF/BrainF.h (original) +++ llvm/trunk/examples/BrainF/BrainF.h Sun Apr 13 01:22:09 2008 @@ -16,7 +16,7 @@ #define BRAINF_H #include "llvm/Module.h" -#include "llvm/Support/LLVMBuilder.h" +#include "llvm/Support/IRBuilder.h" using namespace llvm; @@ -84,7 +84,7 @@ BasicBlock *aberrorbb; /// Variables - LLVMBuilder *builder; + IRBuilder *builder; Value *curhead; }; Modified: llvm/trunk/include/llvm-c/Core.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=49604&r1=49603&r2=49604&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Core.h (original) +++ llvm/trunk/include/llvm-c/Core.h Sun Apr 13 01:22:09 2008 @@ -38,7 +38,7 @@ /* Need these includes to support the LLVM 'cast' template for the C++ 'wrap' and 'unwrap' conversion functions. */ #include "llvm/Module.h" -#include "llvm/Support/LLVMBuilder.h" +#include "llvm/Support/IRBuilder.h" extern "C" { #endif @@ -689,7 +689,7 @@ DEFINE_ISA_CONVERSION_FUNCTIONS (Value, LLVMValueRef ) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module, LLVMModuleRef ) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef ) - DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMFoldingBuilder, LLVMBuilderRef ) + DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder, LLVMBuilderRef ) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(PATypeHolder, LLVMTypeHandleRef ) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ModuleProvider, LLVMModuleProviderRef) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef ) Added: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=49604&view=auto ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (added) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Sun Apr 13 01:22:09 2008 @@ -0,0 +1,527 @@ +//===---- llvm/Support/IRBuilder.h - Builder for LLVM Instrs ----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the IRBuilder class, which is used as a convenient way +// to create LLVM instructions with a consistent and simplified interface. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_IRBUILDER_H +#define LLVM_SUPPORT_IRBUILDER_H + +#include "llvm/BasicBlock.h" +#include "llvm/Instructions.h" +#include "llvm/Constants.h" + +namespace llvm { + +/// IRBuilder - This provides a uniform API for creating instructions and +/// inserting them into a basic block: either at the end of a BasicBlock, or +/// at a specific iterator location in a block. +/// +/// Note that the builder does not expose the full generality of LLVM +/// instructions. For example, it cannot be used to create instructions with +/// arbitrary names (specifically, names with nul characters in them) - It only +/// supports nul-terminated C strings. For fully generic names, use +/// I->setName(). For access to extra instruction properties, use the mutators +/// (e.g. setVolatile) on the instructions after they have been created. +class IRBuilder { + BasicBlock *BB; + BasicBlock::iterator InsertPt; +public: + IRBuilder() { ClearInsertionPoint(); } + explicit IRBuilder(BasicBlock *TheBB) { SetInsertPoint(TheBB); } + IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP) { + SetInsertPoint(TheBB, IP); + } + + //===--------------------------------------------------------------------===// + // Builder configuration methods + //===--------------------------------------------------------------------===// + + /// ClearInsertionPoint - Clear the insertion point: created instructions will + /// not be inserted into a block. + void ClearInsertionPoint() { + BB = 0; + } + + BasicBlock *GetInsertBlock() const { return BB; } + + /// SetInsertPoint - This specifies that created instructions should be + /// appended to the end of the specified block. + void SetInsertPoint(BasicBlock *TheBB) { + BB = TheBB; + InsertPt = BB->end(); + } + + /// SetInsertPoint - This specifies that created instructions should be + /// inserted at the specified point. + void SetInsertPoint(BasicBlock *TheBB, BasicBlock::iterator IP) { + BB = TheBB; + InsertPt = IP; + } + + /// Insert - Insert and return the specified instruction. + template + InstTy *Insert(InstTy *I) const { + InsertHelper(I); + return I; + } + + /// InsertHelper - Insert the specified instruction at the specified insertion + /// point. This is split out of Insert so that it isn't duplicated for every + /// template instantiation. + void InsertHelper(Instruction *I) const { + if (BB) BB->getInstList().insert(InsertPt, I); + } + + //===--------------------------------------------------------------------===// + // Instruction creation methods: Terminators + //===--------------------------------------------------------------------===// + + /// CreateRetVoid - Create a 'ret void' instruction. + ReturnInst *CreateRetVoid() { + return Insert(ReturnInst::Create()); + } + + /// @verbatim + /// CreateRet - Create a 'ret ' instruction. + /// @endverbatim + ReturnInst *CreateRet(Value *V) { + return Insert(ReturnInst::Create(V)); + } + + ReturnInst *CreateRet(Value * const* retVals, unsigned N) { + return Insert(ReturnInst::Create(retVals, N)); + } + + GetResultInst *CreateGetResult(Value *V, unsigned Index, + const char *Name = "") { + return Insert(new GetResultInst(V, Index, Name)); + } + + /// CreateBr - Create an unconditional 'br label X' instruction. + BranchInst *CreateBr(BasicBlock *Dest) { + return Insert(BranchInst::Create(Dest)); + } + + /// CreateCondBr - Create a conditional 'br Cond, TrueDest, FalseDest' + /// instruction. + BranchInst *CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False) { + return Insert(BranchInst::Create(True, False, Cond)); + } + + /// CreateSwitch - Create a switch instruction with the specified value, + /// default dest, and with a hint for the number of cases that will be added + /// (for efficient allocation). + SwitchInst *CreateSwitch(Value *V, BasicBlock *Dest, unsigned NumCases = 10) { + return Insert(SwitchInst::Create(V, Dest, NumCases)); + } + + /// CreateInvoke - Create an invoke instruction. + template + InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest, + BasicBlock *UnwindDest, InputIterator ArgBegin, + InputIterator ArgEnd, const char *Name = "") { + return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, + ArgBegin, ArgEnd, Name)); + } + + UnwindInst *CreateUnwind() { + return Insert(new UnwindInst()); + } + + UnreachableInst *CreateUnreachable() { + return Insert(new UnreachableInst()); + } + + //===--------------------------------------------------------------------===// + // Instruction creation methods: Binary Operators + //===--------------------------------------------------------------------===// + + Value *CreateAdd(Value *LHS, Value *RHS, const char *Name = "") { + if (Constant *LC = dyn_cast(LHS)) + if (Constant *RC = dyn_cast(RHS)) + return ConstantExpr::getAdd(LC, RC); + return Insert(BinaryOperator::createAdd(LHS, RHS, Name)); + } + Value *CreateSub(Value *LHS, Value *RHS, const char *Name = "") { + if (Constant *LC = dyn_cast(LHS)) + if (Constant *RC = dyn_cast(RHS)) + return ConstantExpr::getSub(LC, RC); + return Insert(BinaryOperator::createSub(LHS, RHS, Name)); + } + Value *CreateMul(Value *LHS, Value *RHS, const char *Name = "") { + if (Constant *LC = dyn_cast(LHS)) + if (Constant *RC = dyn_cast(RHS)) + return ConstantExpr::getMul(LC, RC); + return Insert(BinaryOperator::createMul(LHS, RHS, Name)); + } + Value *CreateUDiv(Value *LHS, Value *RHS, const char *Name = "") { + if (Constant *LC = dyn_cast(LHS)) + if (Constant *RC = dyn_cast(RHS)) + return ConstantExpr::getUDiv(LC, RC); + return Insert(BinaryOperator::createUDiv(LHS, RHS, Name)); + } + Value *CreateSDiv(Value *LHS, Value *RHS, const char *Name = "") { + if (Constant *LC = dyn_cast(LHS)) + if (Constant *RC = dyn_cast(RHS)) + return ConstantExpr::getSDiv(LC, RC); + return Insert(BinaryOperator::createSDiv(LHS, RHS, Name)); + } + Value *CreateFDiv(Value *LHS, Value *RHS, const char *Name = "") { + if (Constant *LC = dyn_cast(LHS)) + if (Constant *RC = dyn_cast(RHS)) + return ConstantExpr::getFDiv(LC, RC); + return Insert(BinaryOperator::createFDiv(LHS, RHS, Name)); + } + Value *CreateURem(Value *LHS, Value *RHS, const char *Name = "") { + if (Constant *LC = dyn_cast(LHS)) + if (Constant *RC = dyn_cast(RHS)) + return ConstantExpr::getURem(LC, RC); + return Insert(BinaryOperator::createURem(LHS, RHS, Name)); + } + Value *CreateSRem(Value *LHS, Value *RHS, const char *Name = "") { + if (Constant *LC = dyn_cast(LHS)) + if (Constant *RC = dyn_cast(RHS)) + return ConstantExpr::getSRem(LC, RC); + return Insert(BinaryOperator::createSRem(LHS, RHS, Name)); + } + Value *CreateFRem(Value *LHS, Value *RHS, const char *Name = "") { + if (Constant *LC = dyn_cast(LHS)) + if (Constant *RC = dyn_cast(RHS)) + return ConstantExpr::getFRem(LC, RC); + return Insert(BinaryOperator::createFRem(LHS, RHS, Name)); + } + Value *CreateShl(Value *LHS, Value *RHS, const char *Name = "") { + if (Constant *LC = dyn_cast(LHS)) + if (Constant *RC = dyn_cast(RHS)) + return ConstantExpr::getShl(LC, RC); + return Insert(BinaryOperator::createShl(LHS, RHS, Name)); + } + Value *CreateLShr(Value *LHS, Value *RHS, const char *Name = "") { + if (Constant *LC = dyn_cast(LHS)) + if (Constant *RC = dyn_cast(RHS)) + return ConstantExpr::getLShr(LC, RC); + return Insert(BinaryOperator::createLShr(LHS, RHS, Name)); + } + Value *CreateAShr(Value *LHS, Value *RHS, const char *Name = "") { + if (Constant *LC = dyn_cast(LHS)) + if (Constant *RC = dyn_cast(RHS)) + return ConstantExpr::getAShr(LC, RC); + return Insert(BinaryOperator::createAShr(LHS, RHS, Name)); + } + Value *CreateAnd(Value *LHS, Value *RHS, const char *Name = "") { + if (Constant *LC = dyn_cast(LHS)) + if (Constant *RC = dyn_cast(RHS)) + return ConstantExpr::getAnd(LC, RC); + return Insert(BinaryOperator::createAnd(LHS, RHS, Name)); + } + Value *CreateOr(Value *LHS, Value *RHS, const char *Name = "") { + if (Constant *LC = dyn_cast(LHS)) + if (Constant *RC = dyn_cast(RHS)) + return ConstantExpr::getOr(LC, RC); + return Insert(BinaryOperator::createOr(LHS, RHS, Name)); + } + Value *CreateXor(Value *LHS, Value *RHS, const char *Name = "") { + if (Constant *LC = dyn_cast(LHS)) + if (Constant *RC = dyn_cast(RHS)) + return ConstantExpr::getXor(LC, RC); + return Insert(BinaryOperator::createXor(LHS, RHS, Name)); + } + + BinaryOperator *CreateBinOp(Instruction::BinaryOps Opc, + Value *LHS, Value *RHS, const char *Name = "") { + return Insert(BinaryOperator::create(Opc, LHS, RHS, Name)); + } + + BinaryOperator *CreateNeg(Value *V, const char *Name = "") { + return Insert(BinaryOperator::createNeg(V, Name)); + } + BinaryOperator *CreateNot(Value *V, const char *Name = "") { + return Insert(BinaryOperator::createNot(V, Name)); + } + + //===--------------------------------------------------------------------===// + // Instruction creation methods: Memory Instructions + //===--------------------------------------------------------------------===// + + MallocInst *CreateMalloc(const Type *Ty, Value *ArraySize = 0, + const char *Name = "") { + return Insert(new MallocInst(Ty, ArraySize, Name)); + } + AllocaInst *CreateAlloca(const Type *Ty, Value *ArraySize = 0, + const char *Name = "") { + return Insert(new AllocaInst(Ty, ArraySize, Name)); + } + FreeInst *CreateFree(Value *Ptr) { + return Insert(new FreeInst(Ptr)); + } + LoadInst *CreateLoad(Value *Ptr, const char *Name = 0) { + return Insert(new LoadInst(Ptr, Name)); + } + LoadInst *CreateLoad(Value *Ptr, bool isVolatile, const char *Name = 0) { + return Insert(new LoadInst(Ptr, Name, isVolatile)); + } + StoreInst *CreateStore(Value *Val, Value *Ptr, bool isVolatile = false) { + return Insert(new StoreInst(Val, Ptr, isVolatile)); + } + template + Value *CreateGEP(Value *Ptr, InputIterator IdxBegin, + InputIterator IdxEnd, const char *Name = "") { + + if (Constant *PC = dyn_cast(Ptr)) { + // Every index must be constant. + InputIterator i; + for (i = IdxBegin; i < IdxEnd; ++i) { + if (!dyn_cast(*i)) + break; + } + if (i == IdxEnd) + return ConstantExpr::getGetElementPtr(PC, &IdxBegin[0], IdxEnd - IdxBegin); + } + return(Insert(GetElementPtrInst::Create(Ptr, IdxBegin, IdxEnd, Name))); + } + Value *CreateGEP(Value *Ptr, Value *Idx, const char *Name = "") { + if (Constant *PC = dyn_cast(Ptr)) + if (Constant *IC = dyn_cast(Idx)) + return ConstantExpr::getGetElementPtr(PC, &IC, 1); + return Insert(GetElementPtrInst::Create(Ptr, Idx, Name)); + } + Value *CreateStructGEP(Value *Ptr, unsigned Idx, const char *Name = "") { + llvm::Value *Idxs[] = { + ConstantInt::get(llvm::Type::Int32Ty, 0), + ConstantInt::get(llvm::Type::Int32Ty, Idx) + }; + + if (Constant *PC = dyn_cast(Ptr)) + return ConstantExpr::getGetElementPtr(PC, Idxs, 2); + + return Insert(GetElementPtrInst::Create(Ptr, Idxs, Idxs+2, Name)); + } + + //===--------------------------------------------------------------------===// + // Instruction creation methods: Cast/Conversion Operators + //===--------------------------------------------------------------------===// + + Value *CreateTrunc(Value *V, const Type *DestTy, const char *Name = "") { + return CreateCast(Instruction::Trunc, V, DestTy, Name); + } + Value *CreateZExt(Value *V, const Type *DestTy, const char *Name = "") { + return CreateCast(Instruction::ZExt, V, DestTy, Name); + } + Value *CreateSExt(Value *V, const Type *DestTy, const char *Name = "") { + return CreateCast(Instruction::SExt, V, DestTy, Name); + } + Value *CreateFPToUI(Value *V, const Type *DestTy, const char *Name = ""){ + return CreateCast(Instruction::FPToUI, V, DestTy, Name); + } + Value *CreateFPToSI(Value *V, const Type *DestTy, const char *Name = ""){ + return CreateCast(Instruction::FPToSI, V, DestTy, Name); + } + Value *CreateUIToFP(Value *V, const Type *DestTy, const char *Name = ""){ + return CreateCast(Instruction::UIToFP, V, DestTy, Name); + } + Value *CreateSIToFP(Value *V, const Type *DestTy, const char *Name = ""){ + return CreateCast(Instruction::SIToFP, V, DestTy, Name); + } + Value *CreateFPTrunc(Value *V, const Type *DestTy, + const char *Name = "") { + return CreateCast(Instruction::FPTrunc, V, DestTy, Name); + } + Value *CreateFPExt(Value *V, const Type *DestTy, const char *Name = "") { + return CreateCast(Instruction::FPExt, V, DestTy, Name); + } + Value *CreatePtrToInt(Value *V, const Type *DestTy, + const char *Name = "") { + return CreateCast(Instruction::PtrToInt, V, DestTy, Name); + } + Value *CreateIntToPtr(Value *V, const Type *DestTy, + const char *Name = "") { + return CreateCast(Instruction::IntToPtr, V, DestTy, Name); + } + Value *CreateBitCast(Value *V, const Type *DestTy, + const char *Name = "") { + return CreateCast(Instruction::BitCast, V, DestTy, Name); + } + + Value *CreateCast(Instruction::CastOps Op, Value *V, const Type *DestTy, + const char *Name = "") { + if (V->getType() == DestTy) + return V; + if (Constant *VC = dyn_cast(V)) + return ConstantExpr::getCast(Op, VC, DestTy); + return Insert(CastInst::create(Op, V, DestTy, Name)); + } + Value *CreateIntCast(Value *V, const Type *DestTy, bool isSigned, + const char *Name = "") { + if (V->getType() == DestTy) + return V; + if (Constant *VC = dyn_cast(V)) + return ConstantExpr::getIntegerCast(VC, DestTy, isSigned); + return Insert(CastInst::createIntegerCast(V, DestTy, isSigned, Name)); + } + + //===--------------------------------------------------------------------===// + // Instruction creation methods: Compare Instructions + //===--------------------------------------------------------------------===// + + Value *CreateICmpEQ(Value *LHS, Value *RHS, const char *Name = "") { + return CreateICmp(ICmpInst::ICMP_EQ, LHS, RHS, Name); + } + Value *CreateICmpNE(Value *LHS, Value *RHS, const char *Name = "") { + return CreateICmp(ICmpInst::ICMP_NE, LHS, RHS, Name); + } + Value *CreateICmpUGT(Value *LHS, Value *RHS, const char *Name = "") { + return CreateICmp(ICmpInst::ICMP_UGT, LHS, RHS, Name); + } + Value *CreateICmpUGE(Value *LHS, Value *RHS, const char *Name = "") { + return CreateICmp(ICmpInst::ICMP_UGE, LHS, RHS, Name); + } + Value *CreateICmpULT(Value *LHS, Value *RHS, const char *Name = "") { + return CreateICmp(ICmpInst::ICMP_ULT, LHS, RHS, Name); + } + Value *CreateICmpULE(Value *LHS, Value *RHS, const char *Name = "") { + return CreateICmp(ICmpInst::ICMP_ULE, LHS, RHS, Name); + } + Value *CreateICmpSGT(Value *LHS, Value *RHS, const char *Name = "") { + return CreateICmp(ICmpInst::ICMP_SGT, LHS, RHS, Name); + } + Value *CreateICmpSGE(Value *LHS, Value *RHS, const char *Name = "") { + return CreateICmp(ICmpInst::ICMP_SGE, LHS, RHS, Name); + } + Value *CreateICmpSLT(Value *LHS, Value *RHS, const char *Name = "") { + return CreateICmp(ICmpInst::ICMP_SLT, LHS, RHS, Name); + } + Value *CreateICmpSLE(Value *LHS, Value *RHS, const char *Name = "") { + return CreateICmp(ICmpInst::ICMP_SLE, LHS, RHS, Name); + } + + Value *CreateFCmpOEQ(Value *LHS, Value *RHS, const char *Name = "") { + return CreateFCmp(FCmpInst::FCMP_OEQ, LHS, RHS, Name); + } + Value *CreateFCmpOGT(Value *LHS, Value *RHS, const char *Name = "") { + return CreateFCmp(FCmpInst::FCMP_OGT, LHS, RHS, Name); + } + Value *CreateFCmpOGE(Value *LHS, Value *RHS, const char *Name = "") { + return CreateFCmp(FCmpInst::FCMP_OGE, LHS, RHS, Name); + } + Value *CreateFCmpOLT(Value *LHS, Value *RHS, const char *Name = "") { + return CreateFCmp(FCmpInst::FCMP_OLT, LHS, RHS, Name); + } + Value *CreateFCmpOLE(Value *LHS, Value *RHS, const char *Name = "") { + return CreateFCmp(FCmpInst::FCMP_OLE, LHS, RHS, Name); + } + Value *CreateFCmpONE(Value *LHS, Value *RHS, const char *Name = "") { + return CreateFCmp(FCmpInst::FCMP_ONE, LHS, RHS, Name); + } + Value *CreateFCmpORD(Value *LHS, Value *RHS, const char *Name = "") { + return CreateFCmp(FCmpInst::FCMP_ORD, LHS, RHS, Name); + } + Value *CreateFCmpUNO(Value *LHS, Value *RHS, const char *Name = "") { + return CreateFCmp(FCmpInst::FCMP_UNO, LHS, RHS, Name); + } + Value *CreateFCmpUEQ(Value *LHS, Value *RHS, const char *Name = "") { + return CreateFCmp(FCmpInst::FCMP_UEQ, LHS, RHS, Name); + } + Value *CreateFCmpUGT(Value *LHS, Value *RHS, const char *Name = "") { + return CreateFCmp(FCmpInst::FCMP_UGT, LHS, RHS, Name); + } + Value *CreateFCmpUGE(Value *LHS, Value *RHS, const char *Name = "") { + return CreateFCmp(FCmpInst::FCMP_UGE, LHS, RHS, Name); + } + Value *CreateFCmpULT(Value *LHS, Value *RHS, const char *Name = "") { + return CreateFCmp(FCmpInst::FCMP_ULT, LHS, RHS, Name); + } + Value *CreateFCmpULE(Value *LHS, Value *RHS, const char *Name = "") { + return CreateFCmp(FCmpInst::FCMP_ULE, LHS, RHS, Name); + } + Value *CreateFCmpUNE(Value *LHS, Value *RHS, const char *Name = "") { + return CreateFCmp(FCmpInst::FCMP_UNE, LHS, RHS, Name); + } + + Value *CreateICmp(ICmpInst::Predicate P, Value *LHS, Value *RHS, + const char *Name = "") { + if (Constant *LC = dyn_cast(LHS)) + if (Constant *RC = dyn_cast(RHS)) + return ConstantExpr::getCompare(P, LC, RC); + return Insert(new ICmpInst(P, LHS, RHS, Name)); + } + Value *CreateFCmp(FCmpInst::Predicate P, Value *LHS, Value *RHS, + const char *Name = "") { + if (Constant *LC = dyn_cast(LHS)) + if (Constant *RC = dyn_cast(RHS)) + return ConstantExpr::getCompare(P, LC, RC); + return Insert(new FCmpInst(P, LHS, RHS, Name)); + } + + //===--------------------------------------------------------------------===// + // Instruction creation methods: Other Instructions + //===--------------------------------------------------------------------===// + + PHINode *CreatePHI(const Type *Ty, const char *Name = "") { + return Insert(PHINode::Create(Ty, Name)); + } + + CallInst *CreateCall(Value *Callee, const char *Name = "") { + return Insert(CallInst::Create(Callee, Name)); + } + CallInst *CreateCall(Value *Callee, Value *Arg, const char *Name = "") { + return Insert(CallInst::Create(Callee, Arg, Name)); + } + + template + CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, + InputIterator ArgEnd, const char *Name = "") { + return Insert(CallInst::Create(Callee, ArgBegin, ArgEnd, Name)); + } + + Value *CreateSelect(Value *C, Value *True, Value *False, + const char *Name = "") { + if (Constant *CC = dyn_cast(C)) + if (Constant *TC = dyn_cast(True)) + if (Constant *FC = dyn_cast(False)) + return ConstantExpr::getSelect(CC, TC, FC); + return Insert(SelectInst::Create(C, True, False, Name)); + } + + VAArgInst *CreateVAArg(Value *List, const Type *Ty, const char *Name = "") { + return Insert(new VAArgInst(List, Ty, Name)); + } + + Value *CreateExtractElement(Value *Vec, Value *Idx, + const char *Name = "") { + if (Constant *VC = dyn_cast(Vec)) + if (Constant *IC = dyn_cast(Idx)) + return ConstantExpr::getExtractElement(VC, IC); + return Insert(new ExtractElementInst(Vec, Idx, Name)); + } + + Value *CreateInsertElement(Value *Vec, Value *NewElt, Value *Idx, + const char *Name = "") { + if (Constant *VC = dyn_cast(Vec)) + if (Constant *NC = dyn_cast(NewElt)) + if (Constant *IC = dyn_cast(Idx)) + return ConstantExpr::getInsertElement(VC, NC, IC); + return Insert(InsertElementInst::Create(Vec, NewElt, Idx, Name)); + } + + Value *CreateShuffleVector(Value *V1, Value *V2, Value *Mask, + const char *Name = "") { + if (Constant *V1C = dyn_cast(V1)) + if (Constant *V2C = dyn_cast(V2)) + if (Constant *MC = dyn_cast(Mask)) + return ConstantExpr::getShuffleVector(V1C, V2C, MC); + return Insert(new ShuffleVectorInst(V1, V2, Mask, Name)); + } +}; + +} + +#endif Removed: llvm/trunk/include/llvm/Support/LLVMBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/LLVMBuilder.h?rev=49603&view=auto ============================================================================== --- llvm/trunk/include/llvm/Support/LLVMBuilder.h (original) +++ llvm/trunk/include/llvm/Support/LLVMBuilder.h (removed) @@ -1,780 +0,0 @@ -//===-- llvm/Support/LLVMBuilder.h - Builder for LLVM Instrs ----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines the LLVMBuilder class, which is used as a convenient way -// to create LLVM instructions with a consistent and simplified interface. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_LLVMBUILDER_H -#define LLVM_SUPPORT_LLVMBUILDER_H - -#include "llvm/BasicBlock.h" -#include "llvm/Instructions.h" -#include "llvm/Constants.h" - -namespace llvm { - -/// LLVMBuilder - This provides a uniform API for creating instructions and -/// inserting them into a basic block: either at the end of a BasicBlock, or -/// at a specific iterator location in a block. -/// -/// Note that the builder does not expose the full generality of LLVM -/// instructions. For example, it cannot be used to create instructions with -/// arbitrary names (specifically, names with nul characters in them) - It only -/// supports nul-terminated C strings. For fully generic names, use -/// I->setName(). For access to extra instruction properties, use the mutators -/// (e.g. setVolatile) on the instructions after they have been created. -class LLVMBuilder { - BasicBlock *BB; - BasicBlock::iterator InsertPt; -public: - LLVMBuilder() { ClearInsertionPoint(); } - explicit LLVMBuilder(BasicBlock *TheBB) { SetInsertPoint(TheBB); } - LLVMBuilder(BasicBlock *TheBB, BasicBlock::iterator IP) { - SetInsertPoint(TheBB, IP); - } - - //===--------------------------------------------------------------------===// - // Builder configuration methods - //===--------------------------------------------------------------------===// - - /// ClearInsertionPoint - Clear the insertion point: created instructions will - /// not be inserted into a block. - void ClearInsertionPoint() { - BB = 0; - } - - BasicBlock *GetInsertBlock() const { return BB; } - - /// SetInsertPoint - This specifies that created instructions should be - /// appended to the end of the specified block. - void SetInsertPoint(BasicBlock *TheBB) { - BB = TheBB; - InsertPt = BB->end(); - } - - /// SetInsertPoint - This specifies that created instructions should be - /// inserted at the specified point. - void SetInsertPoint(BasicBlock *TheBB, BasicBlock::iterator IP) { - BB = TheBB; - InsertPt = IP; - } - - /// Insert - Insert and return the specified instruction. - template - InstTy *Insert(InstTy *I) const { - InsertHelper(I); - return I; - } - - /// InsertHelper - Insert the specified instruction at the specified insertion - /// point. This is split out of Insert so that it isn't duplicated for every - /// template instantiation. - void InsertHelper(Instruction *I) const { - if (BB) BB->getInstList().insert(InsertPt, I); - } - - //===--------------------------------------------------------------------===// - // Instruction creation methods: Terminators - //===--------------------------------------------------------------------===// - - /// CreateRetVoid - Create a 'ret void' instruction. - ReturnInst *CreateRetVoid() { - return Insert(ReturnInst::Create()); - } - - /// @verbatim - /// CreateRet - Create a 'ret ' instruction. - /// @endverbatim - ReturnInst *CreateRet(Value *V) { - return Insert(ReturnInst::Create(V)); - } - - ReturnInst *CreateRet(Value * const* retVals, unsigned N) { - return Insert(ReturnInst::Create(retVals, N)); - } - - GetResultInst *CreateGetResult(Value *V, unsigned Index, const char *Name = "") { - return Insert(new GetResultInst(V, Index, Name)); - } - - /// CreateBr - Create an unconditional 'br label X' instruction. - BranchInst *CreateBr(BasicBlock *Dest) { - return Insert(BranchInst::Create(Dest)); - } - - /// CreateCondBr - Create a conditional 'br Cond, TrueDest, FalseDest' - /// instruction. - BranchInst *CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False) { - return Insert(BranchInst::Create(True, False, Cond)); - } - - /// CreateSwitch - Create a switch instruction with the specified value, - /// default dest, and with a hint for the number of cases that will be added - /// (for efficient allocation). - SwitchInst *CreateSwitch(Value *V, BasicBlock *Dest, unsigned NumCases = 10) { - return Insert(SwitchInst::Create(V, Dest, NumCases)); - } - - /// CreateInvoke - Create an invoke instruction. - template - InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest, - BasicBlock *UnwindDest, InputIterator ArgBegin, - InputIterator ArgEnd, const char *Name = "") { - return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, - ArgBegin, ArgEnd, Name)); - } - - UnwindInst *CreateUnwind() { - return Insert(new UnwindInst()); - } - - UnreachableInst *CreateUnreachable() { - return Insert(new UnreachableInst()); - } - - //===--------------------------------------------------------------------===// - // Instruction creation methods: Binary Operators - //===--------------------------------------------------------------------===// - - BinaryOperator *CreateAdd(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(BinaryOperator::createAdd(LHS, RHS, Name)); - } - BinaryOperator *CreateSub(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(BinaryOperator::createSub(LHS, RHS, Name)); - } - BinaryOperator *CreateMul(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(BinaryOperator::createMul(LHS, RHS, Name)); - } - BinaryOperator *CreateUDiv(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(BinaryOperator::createUDiv(LHS, RHS, Name)); - } - BinaryOperator *CreateSDiv(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(BinaryOperator::createSDiv(LHS, RHS, Name)); - } - BinaryOperator *CreateFDiv(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(BinaryOperator::createFDiv(LHS, RHS, Name)); - } - BinaryOperator *CreateURem(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(BinaryOperator::createURem(LHS, RHS, Name)); - } - BinaryOperator *CreateSRem(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(BinaryOperator::createSRem(LHS, RHS, Name)); - } - BinaryOperator *CreateFRem(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(BinaryOperator::createFRem(LHS, RHS, Name)); - } - BinaryOperator *CreateShl(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(BinaryOperator::createShl(LHS, RHS, Name)); - } - BinaryOperator *CreateLShr(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(BinaryOperator::createLShr(LHS, RHS, Name)); - } - BinaryOperator *CreateAShr(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(BinaryOperator::createAShr(LHS, RHS, Name)); - } - BinaryOperator *CreateAnd(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(BinaryOperator::createAnd(LHS, RHS, Name)); - } - BinaryOperator *CreateOr(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(BinaryOperator::createOr(LHS, RHS, Name)); - } - BinaryOperator *CreateXor(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(BinaryOperator::createXor(LHS, RHS, Name)); - } - - BinaryOperator *CreateBinOp(Instruction::BinaryOps Opc, - Value *LHS, Value *RHS, const char *Name = "") { - return Insert(BinaryOperator::create(Opc, LHS, RHS, Name)); - } - - BinaryOperator *CreateNeg(Value *V, const char *Name = "") { - return Insert(BinaryOperator::createNeg(V, Name)); - } - BinaryOperator *CreateNot(Value *V, const char *Name = "") { - return Insert(BinaryOperator::createNot(V, Name)); - } - - //===--------------------------------------------------------------------===// - // Instruction creation methods: Memory Instructions - //===--------------------------------------------------------------------===// - - MallocInst *CreateMalloc(const Type *Ty, Value *ArraySize = 0, - const char *Name = "") { - return Insert(new MallocInst(Ty, ArraySize, Name)); - } - AllocaInst *CreateAlloca(const Type *Ty, Value *ArraySize = 0, - const char *Name = "") { - return Insert(new AllocaInst(Ty, ArraySize, Name)); - } - FreeInst *CreateFree(Value *Ptr) { - return Insert(new FreeInst(Ptr)); - } - LoadInst *CreateLoad(Value *Ptr, const char *Name = 0) { - return Insert(new LoadInst(Ptr, Name)); - } - LoadInst *CreateLoad(Value *Ptr, bool isVolatile, const char *Name = 0) { - return Insert(new LoadInst(Ptr, Name, isVolatile)); - } - StoreInst *CreateStore(Value *Val, Value *Ptr, bool isVolatile = false) { - return Insert(new StoreInst(Val, Ptr, isVolatile)); - } - template - GetElementPtrInst *CreateGEP(Value *Ptr, InputIterator IdxBegin, - InputIterator IdxEnd, const char *Name = "") { - return(Insert(GetElementPtrInst::Create(Ptr, IdxBegin, IdxEnd, Name))); - } - GetElementPtrInst *CreateGEP(Value *Ptr, Value *Idx, const char *Name = "") { - return Insert(GetElementPtrInst::Create(Ptr, Idx, Name)); - } - GetElementPtrInst *CreateStructGEP(Value *Ptr, unsigned Idx, - const char *Name = "") { - llvm::Value *Idxs[] = { - ConstantInt::get(llvm::Type::Int32Ty, 0), - ConstantInt::get(llvm::Type::Int32Ty, Idx) - }; - return Insert(GetElementPtrInst::Create(Ptr, Idxs, Idxs+2, Name)); - } - - //===--------------------------------------------------------------------===// - // Instruction creation methods: Cast/Conversion Operators - //===--------------------------------------------------------------------===// - - TruncInst *CreateTrunc(Value *V, const Type *DestTy, const char *Name = "") { - return Insert(new TruncInst(V, DestTy, Name)); - } - ZExtInst *CreateZExt(Value *V, const Type *DestTy, const char *Name = "") { - return Insert(new ZExtInst(V, DestTy, Name)); - } - SExtInst *CreateSExt(Value *V, const Type *DestTy, const char *Name = "") { - return Insert(new SExtInst(V, DestTy, Name)); - } - FPToUIInst *CreateFPToUI(Value *V, const Type *DestTy, const char *Name = ""){ - return Insert(new FPToUIInst(V, DestTy, Name)); - } - FPToSIInst *CreateFPToSI(Value *V, const Type *DestTy, const char *Name = ""){ - return Insert(new FPToSIInst(V, DestTy, Name)); - } - UIToFPInst *CreateUIToFP(Value *V, const Type *DestTy, const char *Name = ""){ - return Insert(new UIToFPInst(V, DestTy, Name)); - } - SIToFPInst *CreateSIToFP(Value *V, const Type *DestTy, const char *Name = ""){ - return Insert(new SIToFPInst(V, DestTy, Name)); - } - FPTruncInst *CreateFPTrunc(Value *V, const Type *DestTy, - const char *Name = "") { - return Insert(new FPTruncInst(V, DestTy, Name)); - } - FPExtInst *CreateFPExt(Value *V, const Type *DestTy, const char *Name = "") { - return Insert(new FPExtInst(V, DestTy, Name)); - } - PtrToIntInst *CreatePtrToInt(Value *V, const Type *DestTy, - const char *Name = "") { - return Insert(new PtrToIntInst(V, DestTy, Name)); - } - IntToPtrInst *CreateIntToPtr(Value *V, const Type *DestTy, - const char *Name = "") { - return Insert(new IntToPtrInst(V, DestTy, Name)); - } - BitCastInst *CreateBitCast(Value *V, const Type *DestTy, - const char *Name = "") { - return Insert(new BitCastInst(V, DestTy, Name)); - } - - CastInst *CreateCast(Instruction::CastOps Op, Value *V, const Type *DestTy, - const char *Name = "") { - return Insert(CastInst::create(Op, V, DestTy, Name)); - } - CastInst *CreateIntCast(Value *V, const Type *DestTy, bool isSigned, - const char *Name = "") { - return Insert(CastInst::createIntegerCast(V, DestTy, isSigned, Name)); - } - - - - //===--------------------------------------------------------------------===// - // Instruction creation methods: Compare Instructions - //===--------------------------------------------------------------------===// - - ICmpInst *CreateICmpEQ(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new ICmpInst(ICmpInst::ICMP_EQ, LHS, RHS, Name)); - } - ICmpInst *CreateICmpNE(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new ICmpInst(ICmpInst::ICMP_NE, LHS, RHS, Name)); - } - ICmpInst *CreateICmpUGT(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new ICmpInst(ICmpInst::ICMP_UGT, LHS, RHS, Name)); - } - ICmpInst *CreateICmpUGE(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new ICmpInst(ICmpInst::ICMP_UGE, LHS, RHS, Name)); - } - ICmpInst *CreateICmpULT(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new ICmpInst(ICmpInst::ICMP_ULT, LHS, RHS, Name)); - } - ICmpInst *CreateICmpULE(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new ICmpInst(ICmpInst::ICMP_ULE, LHS, RHS, Name)); - } - ICmpInst *CreateICmpSGT(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new ICmpInst(ICmpInst::ICMP_SGT, LHS, RHS, Name)); - } - ICmpInst *CreateICmpSGE(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new ICmpInst(ICmpInst::ICMP_SGE, LHS, RHS, Name)); - } - ICmpInst *CreateICmpSLT(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new ICmpInst(ICmpInst::ICMP_SLT, LHS, RHS, Name)); - } - ICmpInst *CreateICmpSLE(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new ICmpInst(ICmpInst::ICMP_SLE, LHS, RHS, Name)); - } - - FCmpInst *CreateFCmpOEQ(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new FCmpInst(FCmpInst::FCMP_OEQ, LHS, RHS, Name)); - } - FCmpInst *CreateFCmpOGT(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new FCmpInst(FCmpInst::FCMP_OGT, LHS, RHS, Name)); - } - FCmpInst *CreateFCmpOGE(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new FCmpInst(FCmpInst::FCMP_OGE, LHS, RHS, Name)); - } - FCmpInst *CreateFCmpOLT(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new FCmpInst(FCmpInst::FCMP_OLT, LHS, RHS, Name)); - } - FCmpInst *CreateFCmpOLE(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new FCmpInst(FCmpInst::FCMP_OLE, LHS, RHS, Name)); - } - FCmpInst *CreateFCmpONE(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new FCmpInst(FCmpInst::FCMP_ONE, LHS, RHS, Name)); - } - FCmpInst *CreateFCmpORD(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new FCmpInst(FCmpInst::FCMP_ORD, LHS, RHS, Name)); - } - FCmpInst *CreateFCmpUNO(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new FCmpInst(FCmpInst::FCMP_UNO, LHS, RHS, Name)); - } - FCmpInst *CreateFCmpUEQ(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new FCmpInst(FCmpInst::FCMP_UEQ, LHS, RHS, Name)); - } - FCmpInst *CreateFCmpUGT(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new FCmpInst(FCmpInst::FCMP_UGT, LHS, RHS, Name)); - } - FCmpInst *CreateFCmpUGE(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new FCmpInst(FCmpInst::FCMP_UGE, LHS, RHS, Name)); - } - FCmpInst *CreateFCmpULT(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new FCmpInst(FCmpInst::FCMP_ULT, LHS, RHS, Name)); - } - FCmpInst *CreateFCmpULE(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new FCmpInst(FCmpInst::FCMP_ULE, LHS, RHS, Name)); - } - FCmpInst *CreateFCmpUNE(Value *LHS, Value *RHS, const char *Name = "") { - return Insert(new FCmpInst(FCmpInst::FCMP_UNE, LHS, RHS, Name)); - } - - - ICmpInst *CreateICmp(ICmpInst::Predicate P, Value *LHS, Value *RHS, - const char *Name = "") { - return Insert(new ICmpInst(P, LHS, RHS, Name)); - } - FCmpInst *CreateFCmp(FCmpInst::Predicate P, Value *LHS, Value *RHS, - const char *Name = "") { - return Insert(new FCmpInst(P, LHS, RHS, Name)); - } - - //===--------------------------------------------------------------------===// - // Instruction creation methods: Other Instructions - //===--------------------------------------------------------------------===// - - PHINode *CreatePHI(const Type *Ty, const char *Name = "") { - return Insert(PHINode::Create(Ty, Name)); - } - - CallInst *CreateCall(Value *Callee, const char *Name = "") { - return Insert(CallInst::Create(Callee, Name)); - } - CallInst *CreateCall(Value *Callee, Value *Arg, const char *Name = "") { - return Insert(CallInst::Create(Callee, Arg, Name)); - } - - template - CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, - InputIterator ArgEnd, const char *Name = "") { - return Insert(CallInst::Create(Callee, ArgBegin, ArgEnd, Name)); - } - - SelectInst *CreateSelect(Value *C, Value *True, Value *False, - const char *Name = "") { - return Insert(SelectInst::Create(C, True, False, Name)); - } - - VAArgInst *CreateVAArg(Value *List, const Type *Ty, const char *Name = "") { - return Insert(new VAArgInst(List, Ty, Name)); - } - - ExtractElementInst *CreateExtractElement(Value *Vec, Value *Idx, - const char *Name = "") { - return Insert(new ExtractElementInst(Vec, Idx, Name)); - } - - InsertElementInst *CreateInsertElement(Value *Vec, Value *NewElt, Value *Idx, - const char *Name = "") { - return Insert(InsertElementInst::Create(Vec, NewElt, Idx, Name)); - } - - ShuffleVectorInst *CreateShuffleVector(Value *V1, Value *V2, Value *Mask, - const char *Name = "") { - return Insert(new ShuffleVectorInst(V1, V2, Mask, Name)); - } -}; - -/// LLVMFoldingBuilder - A version of LLVMBuilder that constant folds operands -/// as they come in. -class LLVMFoldingBuilder : public LLVMBuilder { - -public: - LLVMFoldingBuilder() {} - explicit LLVMFoldingBuilder(BasicBlock *TheBB) - : LLVMBuilder(TheBB) {} - LLVMFoldingBuilder(BasicBlock *TheBB, BasicBlock::iterator IP) - : LLVMBuilder(TheBB, IP) {} - - //===--------------------------------------------------------------------===// - // Instruction creation methods: Binary Operators - //===--------------------------------------------------------------------===// - - Value *CreateAdd(Value *LHS, Value *RHS, const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return ConstantExpr::getAdd(LC, RC); - return LLVMBuilder::CreateAdd(LHS, RHS, Name); - } - - Value *CreateSub(Value *LHS, Value *RHS, const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return ConstantExpr::getSub(LC, RC); - return LLVMBuilder::CreateSub(LHS, RHS, Name); - } - - Value *CreateMul(Value *LHS, Value *RHS, const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return ConstantExpr::getMul(LC, RC); - return LLVMBuilder::CreateMul(LHS, RHS, Name); - } - - Value *CreateUDiv(Value *LHS, Value *RHS, const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return ConstantExpr::getUDiv(LC, RC); - return LLVMBuilder::CreateUDiv(LHS, RHS, Name); - } - - Value *CreateSDiv(Value *LHS, Value *RHS, const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return ConstantExpr::getSDiv(LC, RC); - return LLVMBuilder::CreateSDiv(LHS, RHS, Name); - } - - Value *CreateFDiv(Value *LHS, Value *RHS, const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return ConstantExpr::getFDiv(LC, RC); - return LLVMBuilder::CreateFDiv(LHS, RHS, Name); - } - - Value *CreateURem(Value *LHS, Value *RHS, const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return ConstantExpr::getURem(LC, RC); - return LLVMBuilder::CreateURem(LHS, RHS, Name); - } - - Value *CreateSRem(Value *LHS, Value *RHS, const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return ConstantExpr::getSRem(LC, RC); - return LLVMBuilder::CreateSRem(LHS, RHS, Name); - } - - Value *CreateFRem(Value *LHS, Value *RHS, const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return ConstantExpr::getFRem(LC, RC); - return LLVMBuilder::CreateFRem(LHS, RHS, Name); - } - - Value *CreateAnd(Value *LHS, Value *RHS, const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return ConstantExpr::getAnd(LC, RC); - return LLVMBuilder::CreateAnd(LHS, RHS, Name); - } - - Value *CreateOr(Value *LHS, Value *RHS, const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return ConstantExpr::getOr(LC, RC); - return LLVMBuilder::CreateOr(LHS, RHS, Name); - } - - Value *CreateXor(Value *LHS, Value *RHS, const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return ConstantExpr::getXor(LC, RC); - return LLVMBuilder::CreateXor(LHS, RHS, Name); - } - - Value *CreateShl(Value *LHS, Value *RHS, const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return ConstantExpr::getShl(LC, RC); - return LLVMBuilder::CreateShl(LHS, RHS, Name); - } - - Value *CreateLShr(Value *LHS, Value *RHS, const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return ConstantExpr::getLShr(LC, RC); - return LLVMBuilder::CreateLShr(LHS, RHS, Name); - } - - Value *CreateAShr(Value *LHS, Value *RHS, const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return ConstantExpr::getAShr(LC, RC); - return LLVMBuilder::CreateAShr(LHS, RHS, Name); - } - - //===--------------------------------------------------------------------===// - // Instruction creation methods: Memory Instructions - //===--------------------------------------------------------------------===// - - template - Value *CreateGEP(Value *Ptr, InputIterator IdxBegin, - InputIterator IdxEnd, const char *Name = "") { - - if (Constant *PC = dyn_cast(Ptr)) { - // Every index must be constant. - InputIterator i; - for (i = IdxBegin; i < IdxEnd; ++i) - if (!dyn_cast(*i)) - break; - if (i == IdxEnd) - return ConstantExpr::getGetElementPtr(PC, &IdxBegin[0], IdxEnd - IdxBegin); - } - return LLVMBuilder::CreateGEP(Ptr, IdxBegin, IdxEnd, Name); - } - Value *CreateGEP(Value *Ptr, Value *Idx, const char *Name = "") { - if (Constant *PC = dyn_cast(Ptr)) - if (Constant *IC = dyn_cast(Idx)) - return ConstantExpr::getGetElementPtr(PC, &IC, 1); - return LLVMBuilder::CreateGEP(Ptr, Idx, Name); - } - - //===--------------------------------------------------------------------===// - // Instruction creation methods: Cast/Conversion Operators - //===--------------------------------------------------------------------===// - - Value *CreateTrunc(Value *V, const Type *DestTy, const char *Name = "") { - return CreateCast(Instruction::Trunc, V, DestTy, Name); - } - Value *CreateZExt(Value *V, const Type *DestTy, const char *Name = "") { - return CreateCast(Instruction::ZExt, V, DestTy, Name); - } - Value *CreateSExt(Value *V, const Type *DestTy, const char *Name = "") { - return CreateCast(Instruction::SExt, V, DestTy, Name); - } - Value *CreateFPToUI(Value *V, const Type *DestTy, const char *Name = ""){ - return CreateCast(Instruction::FPToUI, V, DestTy, Name); - } - Value *CreateFPToSI(Value *V, const Type *DestTy, const char *Name = ""){ - return CreateCast(Instruction::FPToSI, V, DestTy, Name); - } - Value *CreateUIToFP(Value *V, const Type *DestTy, const char *Name = ""){ - return CreateCast(Instruction::UIToFP, V, DestTy, Name); - } - Value *CreateSIToFP(Value *V, const Type *DestTy, const char *Name = ""){ - return CreateCast(Instruction::SIToFP, V, DestTy, Name); - } - Value *CreateFPTrunc(Value *V, const Type *DestTy, - const char *Name = "") { - return CreateCast(Instruction::FPTrunc, V, DestTy, Name); - } - Value *CreateFPExt(Value *V, const Type *DestTy, const char *Name = "") { - return CreateCast(Instruction::FPExt, V, DestTy, Name); - } - Value *CreatePtrToInt(Value *V, const Type *DestTy, - const char *Name = "") { - return CreateCast(Instruction::PtrToInt, V, DestTy, Name); - } - Value *CreateIntToPtr(Value *V, const Type *DestTy, - const char *Name = "") { - return CreateCast(Instruction::IntToPtr, V, DestTy, Name); - } - Value *CreateBitCast(Value *V, const Type *DestTy, - const char *Name = "") { - return CreateCast(Instruction::BitCast, V, DestTy, Name); - } - - Value *CreateCast(Instruction::CastOps Op, Value *V, const Type *DestTy, - const char *Name = "") { - if (V->getType() == DestTy) - return V; - if (Constant *VC = dyn_cast(V)) - return ConstantExpr::getCast(Op, VC, DestTy); - return LLVMBuilder::CreateCast(Op, V, DestTy, Name); - } - Value *CreateIntCast(Value *V, const Type *DestTy, bool isSigned, - const char *Name = "") { - if (V->getType() == DestTy) - return V; - if (Constant *VC = dyn_cast(V)) - return ConstantExpr::getIntegerCast(VC, DestTy, isSigned); - return LLVMBuilder::CreateIntCast(V, DestTy, isSigned, Name); - } - - //===--------------------------------------------------------------------===// - // Instruction creation methods: Compare Instructions - //===--------------------------------------------------------------------===// - - Value *CreateICmpEQ(Value *LHS, Value *RHS, const char *Name = "") { - return CreateICmp(ICmpInst::ICMP_EQ, LHS, RHS, Name); - } - Value *CreateICmpNE(Value *LHS, Value *RHS, const char *Name = "") { - return CreateICmp(ICmpInst::ICMP_NE, LHS, RHS, Name); - } - Value *CreateICmpUGT(Value *LHS, Value *RHS, const char *Name = "") { - return CreateICmp(ICmpInst::ICMP_UGT, LHS, RHS, Name); - } - Value *CreateICmpUGE(Value *LHS, Value *RHS, const char *Name = "") { - return CreateICmp(ICmpInst::ICMP_UGE, LHS, RHS, Name); - } - Value *CreateICmpULT(Value *LHS, Value *RHS, const char *Name = "") { - return CreateICmp(ICmpInst::ICMP_ULT, LHS, RHS, Name); - } - Value *CreateICmpULE(Value *LHS, Value *RHS, const char *Name = "") { - return CreateICmp(ICmpInst::ICMP_ULE, LHS, RHS, Name); - } - Value *CreateICmpSGT(Value *LHS, Value *RHS, const char *Name = "") { - return CreateICmp(ICmpInst::ICMP_SGT, LHS, RHS, Name); - } - Value *CreateICmpSGE(Value *LHS, Value *RHS, const char *Name = "") { - return CreateICmp(ICmpInst::ICMP_SGE, LHS, RHS, Name); - } - Value *CreateICmpSLT(Value *LHS, Value *RHS, const char *Name = "") { - return CreateICmp(ICmpInst::ICMP_SLT, LHS, RHS, Name); - } - Value *CreateICmpSLE(Value *LHS, Value *RHS, const char *Name = "") { - return CreateICmp(ICmpInst::ICMP_SLE, LHS, RHS, Name); - } - - Value *CreateFCmpOEQ(Value *LHS, Value *RHS, const char *Name = "") { - return CreateFCmp(FCmpInst::FCMP_OEQ, LHS, RHS, Name); - } - Value *CreateFCmpOGT(Value *LHS, Value *RHS, const char *Name = "") { - return CreateFCmp(FCmpInst::FCMP_OGT, LHS, RHS, Name); - } - Value *CreateFCmpOGE(Value *LHS, Value *RHS, const char *Name = "") { - return CreateFCmp(FCmpInst::FCMP_OGE, LHS, RHS, Name); - } - Value *CreateFCmpOLT(Value *LHS, Value *RHS, const char *Name = "") { - return CreateFCmp(FCmpInst::FCMP_OLT, LHS, RHS, Name); - } - Value *CreateFCmpOLE(Value *LHS, Value *RHS, const char *Name = "") { - return CreateFCmp(FCmpInst::FCMP_OLE, LHS, RHS, Name); - } - Value *CreateFCmpONE(Value *LHS, Value *RHS, const char *Name = "") { - return CreateFCmp(FCmpInst::FCMP_ONE, LHS, RHS, Name); - } - Value *CreateFCmpORD(Value *LHS, Value *RHS, const char *Name = "") { - return CreateFCmp(FCmpInst::FCMP_ORD, LHS, RHS, Name); - } - Value *CreateFCmpUNO(Value *LHS, Value *RHS, const char *Name = "") { - return CreateFCmp(FCmpInst::FCMP_UNO, LHS, RHS, Name); - } - Value *CreateFCmpUEQ(Value *LHS, Value *RHS, const char *Name = "") { - return CreateFCmp(FCmpInst::FCMP_UEQ, LHS, RHS, Name); - } - Value *CreateFCmpUGT(Value *LHS, Value *RHS, const char *Name = "") { - return CreateFCmp(FCmpInst::FCMP_UGT, LHS, RHS, Name); - } - Value *CreateFCmpUGE(Value *LHS, Value *RHS, const char *Name = "") { - return CreateFCmp(FCmpInst::FCMP_UGE, LHS, RHS, Name); - } - Value *CreateFCmpULT(Value *LHS, Value *RHS, const char *Name = "") { - return CreateFCmp(FCmpInst::FCMP_ULT, LHS, RHS, Name); - } - Value *CreateFCmpULE(Value *LHS, Value *RHS, const char *Name = "") { - return CreateFCmp(FCmpInst::FCMP_ULE, LHS, RHS, Name); - } - Value *CreateFCmpUNE(Value *LHS, Value *RHS, const char *Name = "") { - return CreateFCmp(FCmpInst::FCMP_UNE, LHS, RHS, Name); - } - - Value *CreateICmp(ICmpInst::Predicate P, Value *LHS, Value *RHS, - const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return ConstantExpr::getCompare(P, LC, RC); - return LLVMBuilder::CreateICmp(P, LHS, RHS, Name); - } - - Value *CreateFCmp(FCmpInst::Predicate P, Value *LHS, Value *RHS, - const char *Name = "") { - if (Constant *LC = dyn_cast(LHS)) - if (Constant *RC = dyn_cast(RHS)) - return ConstantExpr::getCompare(P, LC, RC); - return LLVMBuilder::CreateFCmp(P, LHS, RHS, Name); - } - - //===--------------------------------------------------------------------===// - // Instruction creation methods: Other Instructions - //===--------------------------------------------------------------------===// - - Value *CreateSelect(Value *C, Value *True, Value *False, - const char *Name = "") { - if (Constant *CC = dyn_cast(C)) - if (Constant *TC = dyn_cast(True)) - if (Constant *FC = dyn_cast(False)) - return ConstantExpr::getSelect(CC, TC, FC); - return LLVMBuilder::CreateSelect(C, True, False, Name); - } - - Value *CreateExtractElement(Value *Vec, Value *Idx, - const char *Name = "") { - if (Constant *VC = dyn_cast(Vec)) - if (Constant *IC = dyn_cast(Idx)) - return ConstantExpr::getExtractElement(VC, IC); - return LLVMBuilder::CreateExtractElement(Vec, Idx, Name); - } - - Value *CreateInsertElement(Value *Vec, Value *NewElt, Value *Idx, - const char *Name = "") { - if (Constant *VC = dyn_cast(Vec)) - if (Constant *NC = dyn_cast(NewElt)) - if (Constant *IC = dyn_cast(Idx)) - return ConstantExpr::getInsertElement(VC, NC, IC); - return LLVMBuilder::CreateInsertElement(Vec, NewElt, Idx, Name); - } - - Value *CreateShuffleVector(Value *V1, Value *V2, Value *Mask, - const char *Name = "") { - if (Constant *V1C = dyn_cast(V1)) - if (Constant *V2C = dyn_cast(V2)) - if (Constant *MC = dyn_cast(Mask)) - return ConstantExpr::getShuffleVector(V1C, V2C, MC); - return LLVMBuilder::CreateShuffleVector(V1, V2, Mask, Name); - } -}; - -} - -#endif Modified: llvm/trunk/lib/CodeGen/ShadowStackCollector.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ShadowStackCollector.cpp?rev=49604&r1=49603&r2=49604&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ShadowStackCollector.cpp (original) +++ llvm/trunk/lib/CodeGen/ShadowStackCollector.cpp Sun Apr 13 01:22:09 2008 @@ -31,7 +31,7 @@ #include "llvm/CodeGen/Collector.h" #include "llvm/IntrinsicInst.h" #include "llvm/Module.h" -#include "llvm/Support/LLVMBuilder.h" +#include "llvm/Support/IRBuilder.h" using namespace llvm; @@ -61,9 +61,9 @@ Constant *GetFrameMap(Function &F); const Type* GetConcreteStackEntryType(Function &F); void CollectRoots(Function &F); - static GetElementPtrInst *CreateGEP(LLVMBuilder &B, Value *BasePtr, + static GetElementPtrInst *CreateGEP(IRBuilder &B, Value *BasePtr, int Idx1, const char *Name); - static GetElementPtrInst *CreateGEP(LLVMBuilder &B, Value *BasePtr, + static GetElementPtrInst *CreateGEP(IRBuilder &B, Value *BasePtr, int Idx1, int Idx2, const char *Name); }; @@ -86,13 +86,13 @@ // State. int State; Function::iterator StateBB, StateE; - LLVMBuilder Builder; + IRBuilder Builder; public: EscapeEnumerator(Function &F, const char *N = "cleanup") : F(F), CleanupBBName(N), State(0) {} - LLVMBuilder *Next() { + IRBuilder *Next() { switch (State) { default: return 0; @@ -339,20 +339,28 @@ } GetElementPtrInst * -ShadowStackCollector::CreateGEP(LLVMBuilder &B, Value *BasePtr, +ShadowStackCollector::CreateGEP(IRBuilder &B, Value *BasePtr, int Idx, int Idx2, const char *Name) { Value *Indices[] = { ConstantInt::get(Type::Int32Ty, 0), ConstantInt::get(Type::Int32Ty, Idx), ConstantInt::get(Type::Int32Ty, Idx2) }; - return B.CreateGEP(BasePtr, Indices, Indices + 3, Name); + Value* Val = B.CreateGEP(BasePtr, Indices, Indices + 3, Name); + + assert(isa(Val) && "Unexpected folded constant"); + + return dyn_cast(Val); } GetElementPtrInst * -ShadowStackCollector::CreateGEP(LLVMBuilder &B, Value *BasePtr, +ShadowStackCollector::CreateGEP(IRBuilder &B, Value *BasePtr, int Idx, const char *Name) { Value *Indices[] = { ConstantInt::get(Type::Int32Ty, 0), ConstantInt::get(Type::Int32Ty, Idx) }; - return B.CreateGEP(BasePtr, Indices, Indices + 2, Name); + Value *Val = B.CreateGEP(BasePtr, Indices, Indices + 2, Name); + + assert(isa(Val) && "Unexpected folded constant"); + + return dyn_cast(Val); } /// runOnFunction - Insert code to maintain the shadow stack. @@ -371,7 +379,7 @@ // Build the shadow stack entry at the very start of the function. BasicBlock::iterator IP = F.getEntryBlock().begin(); - LLVMBuilder AtEntry(IP->getParent(), IP); + IRBuilder AtEntry(IP->getParent(), IP); Instruction *StackEntry = AtEntry.CreateAlloca(ConcreteStackEntryTy, 0, "gc_frame"); @@ -409,7 +417,7 @@ // For each instruction that escapes... EscapeEnumerator EE(F, "gc_cleanup"); - while (LLVMBuilder *AtExit = EE.Next()) { + while (IRBuilder *AtExit = EE.Next()) { // Pop the entry from the shadow stack. Don't reuse CurrentHead from // AtEntry, since that would make the value live for the entire function. Instruction *EntryNextPtr2 = CreateGEP(*AtExit, StackEntry, 0, 0, Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=49604&r1=49603&r2=49604&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Sun Apr 13 01:22:09 2008 @@ -962,7 +962,7 @@ /*===-- Instruction builders ----------------------------------------------===*/ LLVMBuilderRef LLVMCreateBuilder() { - return wrap(new LLVMFoldingBuilder()); + return wrap(new IRBuilder()); } void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block, From baldrick at free.fr Sun Apr 13 01:27:04 2008 From: baldrick at free.fr (Duncan Sands) Date: Sun, 13 Apr 2008 06:27:04 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r49605 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp llvm-internal.h Message-ID: <200804130627.m3D6R49O011417@zion.cs.uiuc.edu> Author: baldrick Date: Sun Apr 13 01:27:04 2008 New Revision: 49605 URL: http://llvm.org/viewvc/llvm-project?rev=49605&view=rev Log: LLVMFoldingBuilder is now IRBuilder. Patch by Dominic Hamon. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/llvm-internal.h Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=49605&r1=49604&r2=49605&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Sun Apr 13 01:27:04 2008 @@ -406,12 +406,12 @@ struct FunctionPrologArgumentConversion : public DefaultABIClient { tree FunctionDecl; Function::arg_iterator &AI; - LLVMFoldingBuilder Builder; + IRBuilder Builder; std::vector LocStack; std::vector NameStack; FunctionPrologArgumentConversion(tree FnDecl, Function::arg_iterator &ai, - const LLVMFoldingBuilder &B) + const IRBuilder &B) : FunctionDecl(FnDecl), AI(ai), Builder(B) {} void setName(const std::string &Name) { @@ -1251,7 +1251,7 @@ /// CopyAggregate - Recursively traverse the potientially aggregate src/dest /// ptrs, copying all of the elements. static void CopyAggregate(MemRef DestLoc, MemRef SrcLoc, - LLVMFoldingBuilder &Builder, tree gccType) { + IRBuilder &Builder, tree gccType) { assert(DestLoc.Ptr->getType() == SrcLoc.Ptr->getType() && "Cannot copy between two pointers of different type!"); const Type *ElTy = @@ -1341,7 +1341,7 @@ /// ZeroAggregate - Recursively traverse the potentially aggregate DestLoc, /// zero'ing all of the elements. -static void ZeroAggregate(MemRef DestLoc, LLVMFoldingBuilder &Builder) { +static void ZeroAggregate(MemRef DestLoc, IRBuilder &Builder) { const Type *ElTy = cast(DestLoc.Ptr->getType())->getElementType(); if (ElTy->isFirstClassType()) { @@ -2308,7 +2308,7 @@ const FunctionType *FTy; const MemRef *DestLoc; bool useReturnSlot; - LLVMFoldingBuilder &Builder; + IRBuilder &Builder; Value *TheValue; MemRef RetBuf; bool isShadowRet; @@ -2318,7 +2318,7 @@ const FunctionType *FnTy, const MemRef *destloc, bool ReturnSlotOpt, - LLVMFoldingBuilder &b) + IRBuilder &b) : CallOperands(ops), FTy(FnTy), DestLoc(destloc), useReturnSlot(ReturnSlotOpt), Builder(b), isShadowRet(false), isAggrRet(false) { } Modified: llvm-gcc-4.2/trunk/gcc/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-internal.h?rev=49605&r1=49604&r2=49605&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-internal.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-internal.h Sun Apr 13 01:27:04 2008 @@ -37,7 +37,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SetVector.h" #include "llvm/Support/DataTypes.h" -#include "llvm/Support/LLVMBuilder.h" +#include "llvm/Support/IRBuilder.h" #include "llvm/Support/Streams.h" extern "C" { @@ -279,7 +279,7 @@ /// Builder - Instruction creator, the location to insert into is always the /// same as &Fn->back(). - LLVMFoldingBuilder Builder; + IRBuilder Builder; // AllocaInsertionPoint - Place to insert alloca instructions. Lazily created // and managed by CreateTemporary. From sabre at nondot.org Sun Apr 13 02:04:56 2008 From: sabre at nondot.org (Chris Lattner) Date: Sun, 13 Apr 2008 07:04:56 -0000 Subject: [llvm-commits] [llvm] r49606 - /llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Message-ID: <200804130704.m3D74u9c012353@zion.cs.uiuc.edu> Author: lattner Date: Sun Apr 13 02:04:56 2008 New Revision: 49606 URL: http://llvm.org/viewvc/llvm-project?rev=49606&view=rev Log: Fix some serious logic errors that broke the jit on darwin/x86-64. Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=49606&r1=49605&r2=49606&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Sun Apr 13 02:04:56 2008 @@ -370,17 +370,17 @@ // If we have space in the table, reallocate the table. if (SymTabPtr->NumSymbols >= SymTabPtr->NumAllocated) { // If we don't have space, reallocate the table. - unsigned NewSize = std::min(64U, SymTabPtr->NumAllocated*2); + unsigned NewSize = std::max(64U, SymTabPtr->NumAllocated*2); JitSymbolEntry *NewSymbols = new JitSymbolEntry[NewSize]; JitSymbolEntry *OldSymbols = SymTabPtr->Symbols; // Copy the old entries over. memcpy(NewSymbols, OldSymbols, - SymTabPtr->NumAllocated*sizeof(JitSymbolEntry)); + SymTabPtr->NumSymbols*sizeof(OldSymbols[0])); // Swap the new symbols in, delete the old ones. SymTabPtr->Symbols = NewSymbols; - SymTabPtr->NumSymbols = NewSize; + SymTabPtr->NumAllocated = NewSize; delete [] OldSymbols; } From resistor at mac.com Sun Apr 13 04:51:06 2008 From: resistor at mac.com (Owen Anderson) Date: Sun, 13 Apr 2008 09:51:06 -0000 Subject: [llvm-commits] [llvm] r49610 - in /llvm/trunk/test/Analysis/BasicAA: const-dce.ll pure-const-dce.ll Message-ID: <200804130951.m3D9p7u0016877@zion.cs.uiuc.edu> Author: resistor Date: Sun Apr 13 04:51:06 2008 New Revision: 49610 URL: http://llvm.org/viewvc/llvm-project?rev=49610&view=rev Log: The functionality being tested was removed because it was horribly unsafe. Added: llvm/trunk/test/Analysis/BasicAA/const-dce.ll - copied, changed from r49609, llvm/trunk/test/Analysis/BasicAA/pure-const-dce.ll Removed: llvm/trunk/test/Analysis/BasicAA/pure-const-dce.ll Copied: llvm/trunk/test/Analysis/BasicAA/const-dce.ll (from r49609, llvm/trunk/test/Analysis/BasicAA/pure-const-dce.ll) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/const-dce.ll?p2=llvm/trunk/test/Analysis/BasicAA/const-dce.ll&p1=llvm/trunk/test/Analysis/BasicAA/pure-const-dce.ll&r1=49609&r2=49610&rev=49610&view=diff ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/pure-const-dce.ll (original) +++ llvm/trunk/test/Analysis/BasicAA/const-dce.ll Sun Apr 13 04:51:06 2008 @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | opt -basicaa -gvn | llvm-dis | grep TestConst | count 2 -; RUN: llvm-as < %s | opt -basicaa -gvn | llvm-dis | grep TestPure | count 3 +; RUN: llvm-as < %s | opt -basicaa -gvn | llvm-dis | grep TestPure | count 4 ; RUN: llvm-as < %s | opt -basicaa -gvn | llvm-dis | grep TestNone | count 4 @g = global i32 0 ; [#uses=1] Removed: llvm/trunk/test/Analysis/BasicAA/pure-const-dce.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/pure-const-dce.ll?rev=49609&view=auto ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/pure-const-dce.ll (original) +++ llvm/trunk/test/Analysis/BasicAA/pure-const-dce.ll (removed) @@ -1,33 +0,0 @@ -; RUN: llvm-as < %s | opt -basicaa -gvn | llvm-dis | grep TestConst | count 2 -; RUN: llvm-as < %s | opt -basicaa -gvn | llvm-dis | grep TestPure | count 3 -; RUN: llvm-as < %s | opt -basicaa -gvn | llvm-dis | grep TestNone | count 4 - at g = global i32 0 ; [#uses=1] - -define i32 @test() { -entry: - %tmp0 = call i32 @TestConst( i32 5 ) readnone ; [#uses=1] - %tmp1 = call i32 @TestPure( i32 6 ) readonly ; [#uses=1] - %tmp2 = call i32 @TestNone( i32 7 ) ; [#uses=1] - store i32 1, i32* @g - %tmp3 = call i32 @TestConst( i32 5 ) readnone ; [#uses=1] - %tmp4 = call i32 @TestConst( i32 5 ) readnone ; [#uses=1] - %tmp5 = call i32 @TestPure( i32 6 ) readonly ; [#uses=1] - %tmp6 = call i32 @TestPure( i32 6 ) readonly ; [#uses=1] - %tmp7 = call i32 @TestNone( i32 7 ) ; [#uses=1] - %tmp8 = call i32 @TestNone( i32 7 ) ; [#uses=1] - %sum0 = add i32 %tmp0, %tmp1 ; [#uses=1] - %sum1 = add i32 %sum0, %tmp2 ; [#uses=1] - %sum2 = add i32 %sum1, %tmp3 ; [#uses=1] - %sum3 = add i32 %sum2, %tmp4 ; [#uses=1] - %sum4 = add i32 %sum3, %tmp5 ; [#uses=1] - %sum5 = add i32 %sum4, %tmp6 ; [#uses=1] - %sum6 = add i32 %sum5, %tmp7 ; [#uses=1] - %sum7 = add i32 %sum6, %tmp8 ; [#uses=1] - ret i32 %sum7 -} - -declare i32 @TestConst(i32) readnone - -declare i32 @TestPure(i32) readonly - -declare i32 @TestNone(i32) From nicolas.geoffray at lip6.fr Sun Apr 13 08:40:23 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 13 Apr 2008 13:40:23 -0000 Subject: [llvm-commits] [llvm] r49611 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp lib/Target/PowerPC/PPCISelLowering.cpp Message-ID: <200804131340.m3DDeOMc022958@zion.cs.uiuc.edu> Author: geoffray Date: Sun Apr 13 08:40:22 2008 New Revision: 49611 URL: http://llvm.org/viewvc/llvm-project?rev=49611&view=rev Log: Add a divided flag for the first piece of an argument divided into mulitple parts. Fixes PR1643 Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=49611&r1=49610&r2=49611&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Sun Apr 13 08:40:22 2008 @@ -1734,6 +1734,8 @@ static const uint64_t NestOffs = 5; static const uint64_t ByValAlign = 0xFULL << 6; //< Struct alignment static const uint64_t ByValAlignOffs = 6; + static const uint64_t Divided = 1ULL << 10; + static const uint64_t DividedOffs = 10; static const uint64_t OrigAlign = 0x1FULL<<27; static const uint64_t OrigAlignOffs = 27; static const uint64_t ByValSize = 0xffffffffULL << 32; //< Struct size @@ -1770,6 +1772,9 @@ Flags = (Flags & ~ByValAlign) | (uint64_t(Log2_32(A) + 1) << ByValAlignOffs); } + + bool isDivided() const { return Flags & Divided; } + void setDivided() { Flags |= One << DividedOffs; } unsigned getOrigAlign() const { return (One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=49611&r1=49610&r2=49611&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sun Apr 13 08:40:22 2008 @@ -4162,8 +4162,11 @@ unsigned NumRegs = getNumRegisters(VT); for (unsigned i = 0; i != NumRegs; ++i) { RetVals.push_back(RegisterVT); + + if (NumRegs > 1 && i == 0) + Flags.setDivided(); // if it isn't first piece, alignment must be 1 - if (i > 0) + else if (i > 0) Flags.setOrigAlign(1); Ops.push_back(DAG.getArgFlags(Flags)); } @@ -4285,7 +4288,9 @@ for (unsigned i = 0; i != NumParts; ++i) { // if it isn't first piece, alignment must be 1 ISD::ArgFlagsTy MyFlags = Flags; - if (i != 0) + if (NumParts > 1 && i == 0) + MyFlags.setDivided(); + else if (i != 0) MyFlags.setOrigAlign(1); Ops.push_back(Parts[i]); Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=49611&r1=49610&r2=49611&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Sun Apr 13 08:40:22 2008 @@ -1410,7 +1410,7 @@ // // In the ELF 32 ABI, GPRs and stack are double word align: an argument // represented with two words (long long or double) must be copied to an - // even GPR_idx value or to an even ArgOffset value. TODO: implement this. + // even GPR_idx value or to an even ArgOffset value. SmallVector MemOps; @@ -1423,7 +1423,7 @@ ISD::ArgFlagsTy Flags = cast(Op.getOperand(ArgNo+3))->getArgFlags(); // See if next argument requires stack alignment in ELF - bool Expand = false; // TODO: implement this. + bool Align = Flags.isDivided(); unsigned CurArgOffset = ArgOffset; @@ -1435,7 +1435,7 @@ ObjSize = Flags.getByValSize(); ArgSize = ((ObjSize + PtrByteSize - 1)/PtrByteSize) * PtrByteSize; // Double word align in ELF - if (Expand && isELF32_ABI) GPR_idx += (GPR_idx % 2); + if (Align && isELF32_ABI) GPR_idx += (GPR_idx % 2); // Objects of size 1 and 2 are right justified, everything else is // left justified. This means the memory address is adjusted forwards. if (ObjSize==1 || ObjSize==2) { @@ -1487,7 +1487,7 @@ case MVT::i32: if (!isPPC64) { // Double word align in ELF - if (Expand && isELF32_ABI) GPR_idx += (GPR_idx % 2); + if (Align && isELF32_ABI) GPR_idx += (GPR_idx % 2); if (GPR_idx != Num_GPR_Regs) { unsigned VReg = RegInfo.createVirtualRegister(&PPC::GPRCRegClass); @@ -1499,7 +1499,7 @@ ArgSize = PtrByteSize; } // Stack align in ELF - if (needsLoad && Expand && isELF32_ABI) + if (needsLoad && Align && isELF32_ABI) ArgOffset += ((ArgOffset/4) % 2) * PtrByteSize; // All int arguments reserve stack space in Macho ABI. if (isMachoABI || needsLoad) ArgOffset += PtrByteSize; @@ -1556,7 +1556,7 @@ } // Stack align in ELF - if (needsLoad && Expand && isELF32_ABI) + if (needsLoad && Align && isELF32_ABI) ArgOffset += ((ArgOffset/4) % 2) * PtrByteSize; // All FP arguments reserve stack space in Macho ABI. if (isMachoABI || needsLoad) ArgOffset += isPPC64 ? 8 : ObjSize; @@ -1855,14 +1855,14 @@ ISD::ArgFlagsTy Flags = cast(Op.getOperand(5+2*i+1))->getArgFlags(); // See if next argument requires stack alignment in ELF - bool Expand = false; // TODO: implement this. + bool Align = Flags.isDivided(); // PtrOff will be used to store the current argument to the stack if a // register cannot be found for it. SDOperand PtrOff; // Stack align in ELF 32 - if (isELF32_ABI && Expand) + if (isELF32_ABI && Align) PtrOff = DAG.getConstant(ArgOffset + ((ArgOffset/4) % 2) * PtrByteSize, StackPtr.getValueType()); else @@ -1881,7 +1881,7 @@ // FIXME memcpy is used way more than necessary. Correctness first. if (Flags.isByVal()) { unsigned Size = Flags.getByValSize(); - if (isELF32_ABI && Expand) GPR_idx += (GPR_idx % 2); + if (isELF32_ABI && Align) GPR_idx += (GPR_idx % 2); if (Size==1 || Size==2) { // Very small objects are passed right-justified. // Everything else is passed left-justified. @@ -1942,7 +1942,7 @@ case MVT::i32: case MVT::i64: // Double word align in ELF - if (isELF32_ABI && Expand) GPR_idx += (GPR_idx % 2); + if (isELF32_ABI && Align) GPR_idx += (GPR_idx % 2); if (GPR_idx != NumGPRs) { RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Arg)); } else { @@ -1951,7 +1951,7 @@ } if (inMem || isMachoABI) { // Stack align in ELF - if (isELF32_ABI && Expand) + if (isELF32_ABI && Align) ArgOffset += ((ArgOffset/4) % 2) * PtrByteSize; ArgOffset += PtrByteSize; @@ -1999,7 +1999,7 @@ } if (inMem || isMachoABI) { // Stack align in ELF - if (isELF32_ABI && Expand) + if (isELF32_ABI && Align) ArgOffset += ((ArgOffset/4) % 2) * PtrByteSize; if (isPPC64) ArgOffset += 8; From baldrick at free.fr Sun Apr 13 11:04:03 2008 From: baldrick at free.fr (Duncan Sands) Date: Sun, 13 Apr 2008 16:04:03 -0000 Subject: [llvm-commits] [llvm] r49612 - in /llvm/trunk/lib/CodeGen/SelectionDAG: LegalizeTypes.cpp LegalizeTypes.h Message-ID: <200804131604.m3DG43jT027064@zion.cs.uiuc.edu> Author: baldrick Date: Sun Apr 13 11:04:03 2008 New Revision: 49612 URL: http://llvm.org/viewvc/llvm-project?rev=49612&view=rev Log: LegalizeTypes can sometimes have deleted nodes in its maps. Add some sanity checks that catch this kind of thing. Hopefully these can be removed one day (once all problems are fixed!) but for the moment it seems wise to have them in. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp?rev=49612&r1=49611&r2=49612&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp Sun Apr 13 11:04:03 2008 @@ -267,6 +267,51 @@ Worklist.push_back(N); } +void DAGTypeLegalizer::SanityCheck(SDNode *N) { + for (SmallVector::iterator I = Worklist.begin(), + E = Worklist.end(); I != E; ++I) + assert(*I != N); + + for (DenseMap::iterator I = ReplacedNodes.begin(), + E = ReplacedNodes.end(); I != E; ++I) { + assert(I->first.Val != N); + assert(I->second.Val != N); + } + + for (DenseMap::iterator I = PromotedNodes.begin(), + E = PromotedNodes.end(); I != E; ++I) { + assert(I->first.Val != N); + assert(I->second.Val != N); + } + + for (DenseMap::iterator + I = FloatToIntedNodes.begin(), + E = FloatToIntedNodes.end(); I != E; ++I) { + assert(I->first.Val != N); + assert(I->second.Val != N); + } + + for (DenseMap::iterator I = ScalarizedNodes.begin(), + E = ScalarizedNodes.end(); I != E; ++I) { + assert(I->first.Val != N); + assert(I->second.Val != N); + } + + for (DenseMap >::iterator + I = ExpandedNodes.begin(), E = ExpandedNodes.end(); I != E; ++I) { + assert(I->first.Val != N); + assert(I->second.first.Val != N); + assert(I->second.second.Val != N); + } + + for (DenseMap >::iterator + I = SplitNodes.begin(), E = SplitNodes.end(); I != E; ++I) { + assert(I->first.Val != N); + assert(I->second.first.Val != N); + assert(I->second.second.Val != N); + } +} + namespace { /// NodeUpdateListener - This class is a DAGUpdateListener that listens for /// updates to nodes and recomputes their ready state. @@ -281,6 +326,9 @@ assert(N->getNodeId() != DAGTypeLegalizer::Processed && N->getNodeId() != DAGTypeLegalizer::ReadyToProcess && "RAUW deleted processed node!"); +#ifndef NDEBUG + DTL.SanityCheck(N); +#endif } virtual void NodeUpdated(SDNode *N) { Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h?rev=49612&r1=49611&r2=49612&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h Sun Apr 13 11:04:03 2008 @@ -379,6 +379,9 @@ SDOperand SplitOp_RET(SDNode *N, unsigned OpNo); SDOperand SplitOp_STORE(StoreSDNode *N, unsigned OpNo); SDOperand SplitOp_VECTOR_SHUFFLE(SDNode *N, unsigned OpNo); + +public: + void SanityCheck(SDNode *N); }; } // end namespace llvm. From clattner at apple.com Sun Apr 13 14:15:04 2008 From: clattner at apple.com (Chris Lattner) Date: Sun, 13 Apr 2008 12:15:04 -0700 Subject: [llvm-commits] [llvm] r49610 - in /llvm/trunk/test/Analysis/BasicAA: const-dce.ll pure-const-dce.ll In-Reply-To: <200804130951.m3D9p7u0016877@zion.cs.uiuc.edu> References: <200804130951.m3D9p7u0016877@zion.cs.uiuc.edu> Message-ID: <133A220E-FFCA-49EC-B2B7-6D106B21566B@apple.com> On Apr 13, 2008, at 2:51 AM, Owen Anderson wrote: > Author: resistor > Date: Sun Apr 13 04:51:06 2008 > New Revision: 49610 > > URL: http://llvm.org/viewvc/llvm-project?rev=49610&view=rev > Log: > The functionality being tested was removed because it was horribly > unsafe. What functionality was that? -Chris From resistor at mac.com Sun Apr 13 14:15:18 2008 From: resistor at mac.com (Owen Anderson) Date: Sun, 13 Apr 2008 19:15:18 -0000 Subject: [llvm-commits] [llvm] r49614 - in /llvm/trunk: lib/Linker/LinkModules.cpp lib/Transforms/Scalar/LoopRotation.cpp lib/Transforms/Scalar/LoopUnroll.cpp lib/Transforms/Scalar/TailDuplication.cpp lib/Transforms/Utils/CodeExtractor.cpp tools/bugpoint/Miscompilation.cpp Message-ID: <200804131915.m3DJFIC8032349@zion.cs.uiuc.edu> Author: resistor Date: Sun Apr 13 14:15:17 2008 New Revision: 49614 URL: http://llvm.org/viewvc/llvm-project?rev=49614&view=rev Log: Replace calls of the form V1->setName(V2->getName()) with V1->takeName(V2), which is significantly more efficient. Modified: llvm/trunk/lib/Linker/LinkModules.cpp llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp llvm/trunk/lib/Transforms/Scalar/LoopUnroll.cpp llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp llvm/trunk/tools/bugpoint/Miscompilation.cpp Modified: llvm/trunk/lib/Linker/LinkModules.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=49614&r1=49613&r2=49614&view=diff ============================================================================== --- llvm/trunk/lib/Linker/LinkModules.cpp (original) +++ llvm/trunk/lib/Linker/LinkModules.cpp Sun Apr 13 14:15:17 2008 @@ -930,7 +930,7 @@ Function::arg_iterator DI = Dest->arg_begin(); for (Function::arg_iterator I = Src->arg_begin(), E = Src->arg_end(); I != E; ++I, ++DI) { - DI->setName(I->getName()); // Copy the name information over... + DI->takeName(I); // Copy the name information over... // Add a mapping to our local map ValueMap[I] = DI; Modified: llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp?rev=49614&r1=49613&r2=49614&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Sun Apr 13 14:15:17 2008 @@ -226,7 +226,7 @@ // If this instruction is using a value from same basic block then // update it to use value from cloned instruction. Instruction *C = In->clone(); - C->setName(In->getName()); + C->takeName(In); OrigPreHeader->getInstList().push_back(C); for (unsigned opi = 0, e = In->getNumOperands(); opi != e; ++opi) { Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnroll.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnroll.cpp?rev=49614&r1=49613&r2=49614&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopUnroll.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopUnroll.cpp Sun Apr 13 14:15:17 2008 @@ -179,8 +179,8 @@ BB->eraseFromParent(); // Inherit predecessor's name if it exists... - if (!OldName.empty() && !OnlyPred->hasName()) - OnlyPred->setName(OldName); + if (BB->hasName() && !OnlyPred->hasName()) + OnlyPred->takeName(BB); return OnlyPred; } Modified: llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp?rev=49614&r1=49613&r2=49614&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/TailDuplication.cpp Sun Apr 13 14:15:17 2008 @@ -317,7 +317,7 @@ // for (; BI != DestBlock->end(); ++BI) { Instruction *New = BI->clone(); - New->setName(BI->getName()); + New->takeName(BI); SourceBlock->getInstList().push_back(New); ValueMapping[BI] = New; } Modified: llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp?rev=49614&r1=49613&r2=49614&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp Sun Apr 13 14:15:17 2008 @@ -317,7 +317,7 @@ if (!AggregateArgs) { AI = newFunction->arg_begin(); for (unsigned i = 0, e = inputs.size(); i != e; ++i, ++AI) - AI->setName(inputs[i]->getName()); + AI->takeName(inputs[i]); for (unsigned i = 0, e = outputs.size(); i != e; ++i, ++AI) AI->setName(outputs[i]->getName()+".out"); } Modified: llvm/trunk/tools/bugpoint/Miscompilation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/Miscompilation.cpp?rev=49614&r1=49613&r2=49614&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/Miscompilation.cpp (original) +++ llvm/trunk/tools/bugpoint/Miscompilation.cpp Sun Apr 13 14:15:17 2008 @@ -657,7 +657,7 @@ for (Function::arg_iterator I = newMain->arg_begin(), E = newMain->arg_end(), OI = oldMain->arg_begin(); I != E; ++I, ++OI) { - I->setName(OI->getName()); // Copy argument names from oldMain + I->takeName(OI); // Copy argument names from oldMain args.push_back(I); } From sabre at nondot.org Sun Apr 13 14:40:26 2008 From: sabre at nondot.org (Chris Lattner) Date: Sun, 13 Apr 2008 19:40:26 -0000 Subject: [llvm-commits] [llvm] r49616 - /llvm/trunk/include/llvm/Support/CallSite.h Message-ID: <200804131940.m3DJeQZv000833@zion.cs.uiuc.edu> Author: lattner Date: Sun Apr 13 14:40:26 2008 New Revision: 49616 URL: http://llvm.org/viewvc/llvm-project?rev=49616&view=rev Log: Add support for equality comparison of CallSite's. Modified: llvm/trunk/include/llvm/Support/CallSite.h Modified: llvm/trunk/include/llvm/Support/CallSite.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CallSite.h?rev=49616&r1=49615&r2=49616&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/CallSite.h (original) +++ llvm/trunk/include/llvm/Support/CallSite.h Sun Apr 13 14:40:26 2008 @@ -39,6 +39,9 @@ CallSite(const CallSite &CS) : I(CS.I) {} CallSite &operator=(const CallSite &CS) { I = CS.I; return *this; } + bool operator==(const CallSite &CS) const { return I == CS.I; } + bool operator!=(const CallSite &CS) const { return I != CS.I; } + /// CallSite::get - This static method is sort of like a constructor. It will /// create an appropriate call site for a Call or Invoke instruction, but it /// can also create a null initialized CallSite object for something which is From sabre at nondot.org Sun Apr 13 14:41:25 2008 From: sabre at nondot.org (Chris Lattner) Date: Sun, 13 Apr 2008 19:41:25 -0000 Subject: [llvm-commits] [llvm] r49617 - in /llvm/trunk: include/llvm/Analysis/CallGraph.h lib/Analysis/IPA/CallGraph.cpp Message-ID: <200804131941.m3DJfPNN000869@zion.cs.uiuc.edu> Author: lattner Date: Sun Apr 13 14:41:25 2008 New Revision: 49617 URL: http://llvm.org/viewvc/llvm-project?rev=49617&view=rev Log: add a new CallGraphNode::removeCallEdgeFor method, tidy some comments. Modified: llvm/trunk/include/llvm/Analysis/CallGraph.h llvm/trunk/lib/Analysis/IPA/CallGraph.cpp Modified: llvm/trunk/include/llvm/Analysis/CallGraph.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/CallGraph.h?rev=49617&r1=49616&r2=49617&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/CallGraph.h (original) +++ llvm/trunk/include/llvm/Analysis/CallGraph.h Sun Apr 13 14:41:25 2008 @@ -103,13 +103,13 @@ return I->second; } - //Returns the CallGraphNode which is used to represent undetermined calls - // into the callgraph. Override this if you want behavioural inheritance. + /// Returns the CallGraphNode which is used to represent undetermined calls + /// into the callgraph. Override this if you want behavioral inheritance. virtual CallGraphNode* getExternalCallingNode() const { return 0; } - //Return the root/main method in the module, or some other root node, such - // as the externalcallingnode. Overload these if you behavioural - // inheritance. + /// Return the root/main method in the module, or some other root node, such + /// as the externalcallingnode. Overload these if you behavioral + /// inheritance. virtual CallGraphNode* getRoot() { return 0; } virtual const CallGraphNode* getRoot() const { return 0; } @@ -227,6 +227,11 @@ /// used sparingly. void removeCallEdgeTo(CallGraphNode *Callee); + /// removeCallEdgeFor - This method removes the edge in the node for the + /// specified call site. Note that this method takes linear time, so it + /// should be used sparingly. + void removeCallEdgeFor(CallSite CS); + /// removeAnyCallEdgeTo - This method removes any call edges from this node to /// the specified callee function. This takes more time to execute than /// removeCallEdgeTo, so it should not be used unless necessary. Modified: llvm/trunk/lib/Analysis/IPA/CallGraph.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/CallGraph.cpp?rev=49617&r1=49616&r2=49617&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IPA/CallGraph.cpp (original) +++ llvm/trunk/lib/Analysis/IPA/CallGraph.cpp Sun Apr 13 14:41:25 2008 @@ -293,6 +293,20 @@ } } +/// removeCallEdgeFor - This method removes the edge in the node for the +/// specified call site. Note that this method takes linear time, so it +/// should be used sparingly. +void CallGraphNode::removeCallEdgeFor(CallSite CS) { + for (unsigned i = CalledFunctions.size(); ; --i) { + assert(i && "Cannot find callee to remove!"); + if (CalledFunctions[i-1].first == CS) { + CalledFunctions.erase(CalledFunctions.begin()+i-1); + return; + } + } +} + + // removeAnyCallEdgeTo - This method removes any call edges from this node to // the specified callee function. This takes more time to execute than // removeCallEdgeTo, so it should not be used unless necessary. From ggreif at gmail.com Sun Apr 13 15:56:58 2008 From: ggreif at gmail.com (Gabor Greif) Date: Sun, 13 Apr 2008 20:56:58 -0000 Subject: [llvm-commits] [llvm] r49620 - /llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Message-ID: <200804132056.m3DKux97003242@zion.cs.uiuc.edu> Author: ggreif Date: Sun Apr 13 15:56:57 2008 New Revision: 49620 URL: http://llvm.org/viewvc/llvm-project?rev=49620&view=rev Log: debugging Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=49620&r1=49619&r2=49620&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Sun Apr 13 15:56:57 2008 @@ -25,7 +25,6 @@ namespace llvm { -class BasicBlock; class ConstantInt; class PointerType; class VectorType; @@ -1650,7 +1649,8 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ReturnInst, Value) void ReturnInst::operator delete(void *it) { - OperandTraits::op_begin(static_cast(it)); + assert(0 && "ReturnInst::operator delete"); + ::operator delete(OperandTraits::op_begin(static_cast(it))); } //===----------------------------------------------------------------------===// @@ -1695,6 +1695,8 @@ return new(3) BranchInst(IfTrue, IfFalse, Cond, InsertAtEnd); } + // not yet ~BranchInst(); + /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); From ggreif at gmail.com Sun Apr 13 16:15:11 2008 From: ggreif at gmail.com (Gabor Greif) Date: Sun, 13 Apr 2008 21:15:11 -0000 Subject: [llvm-commits] [llvm] r49622 - in /llvm/branches/ggreif/use-diet: include/llvm/Instructions.h include/llvm/Use.h lib/VMCore/Use.cpp Message-ID: <200804132115.m3DLFBTR003791@zion.cs.uiuc.edu> Author: ggreif Date: Sun Apr 13 16:15:09 2008 New Revision: 49622 URL: http://llvm.org/viewvc/llvm-project?rev=49622&view=rev Log: correctly zap uses in ReturnInst::operator delete Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h llvm/branches/ggreif/use-diet/include/llvm/Use.h llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=49622&r1=49621&r2=49622&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Sun Apr 13 16:15:09 2008 @@ -1649,8 +1649,10 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ReturnInst, Value) void ReturnInst::operator delete(void *it) { - assert(0 && "ReturnInst::operator delete"); - ::operator delete(OperandTraits::op_begin(static_cast(it))); + ReturnInst* me(static_cast(it)); + Use::zap(OperandTraits::op_begin(me), + OperandTraits::op_end(me), + true); } //===----------------------------------------------------------------------===// Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Use.h?rev=49622&r1=49621&r2=49622&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Use.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Use.h Sun Apr 13 16:15:09 2008 @@ -55,7 +55,7 @@ User *getUser() const; const Use* getImpliedUser() const; static void initTags(Use *Start, Use *Stop, ptrdiff_t Done = 0); - static void zap(Use *Start, const Use *Stop); + static void zap(Use *Start, const Use *Stop, bool del = false); inline void set(Value *Val); Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp?rev=49622&r1=49621&r2=49622&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Sun Apr 13 16:15:09 2008 @@ -75,10 +75,12 @@ // Use zap Implementation //===----------------------------------------------------------------------===// -void Use::zap(Use *Start, const Use *Stop) { +void Use::zap(Use *Start, const Use *Stop, bool del) { while (Start != Stop) { - (Start++)->set(0); + (--Stop)->set(0); } + if (del) + ::operator delete(Start); } //===----------------------------------------------------------------------===// From ggreif at gmail.com Sun Apr 13 16:47:53 2008 From: ggreif at gmail.com (Gabor Greif) Date: Sun, 13 Apr 2008 21:47:53 -0000 Subject: [llvm-commits] [llvm] r49624 - /llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Message-ID: <200804132147.m3DLlrL1004801@zion.cs.uiuc.edu> Author: ggreif Date: Sun Apr 13 16:47:51 2008 New Revision: 49624 URL: http://llvm.org/viewvc/llvm-project?rev=49624&view=rev Log: ooops, fix compilation error Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp?rev=49624&r1=49623&r2=49624&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Sun Apr 13 16:47:51 2008 @@ -76,8 +76,9 @@ //===----------------------------------------------------------------------===// void Use::zap(Use *Start, const Use *Stop, bool del) { - while (Start != Stop) { - (--Stop)->set(0); + Use *Iter = Start; + while (Iter != Stop) { + (Iter++)->set(0); } if (del) ::operator delete(Start); From ggreif at gmail.com Sun Apr 13 17:10:06 2008 From: ggreif at gmail.com (Gabor Greif) Date: Sun, 13 Apr 2008 22:10:06 -0000 Subject: [llvm-commits] [llvm] r49625 - in /llvm/branches/ggreif/use-diet: include/llvm/Instructions.h lib/VMCore/Instructions.cpp Message-ID: <200804132210.m3DMA69m005452@zion.cs.uiuc.edu> Author: ggreif Date: Sun Apr 13 17:10:04 2008 New Revision: 49625 URL: http://llvm.org/viewvc/llvm-project?rev=49625&view=rev Log: trait-ify Insert/ExtractElementInst Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=49625&r1=49624&r2=49625&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Sun Apr 13 17:10:04 2008 @@ -1252,7 +1252,8 @@ virtual ExtractElementInst *clone() const; /// Transparently provide more efficient getOperand methods. - Value *getOperand(unsigned i) const { + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); + /* Value *getOperand(unsigned i) const { assert(i < 2 && "getOperand() out of range!"); return OperandList[i]; } @@ -1260,7 +1261,7 @@ assert(i < 2 && "setOperand() out of range!"); OperandList[i] = Val; } - unsigned getNumOperands() const { return 2; } + unsigned getNumOperands() const { return 2; }*/ // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const ExtractElementInst *) { return true; } @@ -1272,6 +1273,12 @@ } }; +template <> +struct OperandTraits : FixedNumOperandTraits<2> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractElementInst, Value) + //===----------------------------------------------------------------------===// // InsertElementInst Class //===----------------------------------------------------------------------===// @@ -1299,7 +1306,7 @@ } static InsertElementInst *Create(Value *Vec, Value *NewElt, unsigned Idx, const std::string &Name = "",Instruction *InsertBefore = 0) { - return new(3/*FIXME*/) InsertElementInst(Vec, NewElt, Idx, Name, InsertBefore); + return new(3) InsertElementInst(Vec, NewElt, Idx, Name, InsertBefore); } static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx, const std::string &Name, BasicBlock *InsertAtEnd) { @@ -1307,7 +1314,7 @@ } static InsertElementInst *Create(Value *Vec, Value *NewElt, unsigned Idx, const std::string &Name, BasicBlock *InsertAtEnd) { - return new(3/*FIXME*/) InsertElementInst(Vec, NewElt, Idx, Name, InsertAtEnd); + return new(3) InsertElementInst(Vec, NewElt, Idx, Name, InsertAtEnd); } /// isValidOperands - Return true if an insertelement instruction can be @@ -1324,7 +1331,8 @@ } /// Transparently provide more efficient getOperand methods. - Value *getOperand(unsigned i) const { + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); + /* Value *getOperand(unsigned i) const { assert(i < 3 && "getOperand() out of range!"); return OperandList[i]; } @@ -1332,7 +1340,7 @@ assert(i < 3 && "setOperand() out of range!"); OperandList[i] = Val; } - unsigned getNumOperands() const { return 3; } + unsigned getNumOperands() const { return 3; }*/ // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const InsertElementInst *) { return true; } @@ -1344,6 +1352,12 @@ } }; +template <> +struct OperandTraits : FixedNumOperandTraits<3> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertElementInst, Value) + //===----------------------------------------------------------------------===// // ShuffleVectorInst Class //===----------------------------------------------------------------------===// @@ -1378,19 +1392,6 @@ /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); - /* const Value *getOperand(unsigned i) const { - assert(i < 3 && "getOperand() out of range!"); - return OperandList[i]; - } - Value *getOperand(unsigned i) { - assert(i < 3 && "getOperand() out of range!"); - return OperandList[i]; - } - void setOperand(unsigned i, Value *Val) { - assert(i < 3 && "setOperand() out of range!"); - OperandList[i] = Val; - } - unsigned getNumOperands() const { return 3; }*/ /// getMaskValue - Return the index from the shuffle mask for the specified /// output result. This is either -1 if the element is undef or a number less Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp?rev=49625&r1=49624&r2=49625&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp (original) +++ llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Sun Apr 13 17:10:04 2008 @@ -1114,7 +1114,9 @@ const std::string &Name, Instruction *InsertBef) : Instruction(cast(Val->getType())->getElementType(), - ExtractElement, /*Ops*/NULL, 2, InsertBef) { + ExtractElement, + OperandTraits::op_begin(this), + 2, InsertBef) { assert(isValidOperands(Val, Index) && "Invalid extractelement instruction operands!"); Op<0>().init(Val, this); @@ -1126,7 +1128,9 @@ const std::string &Name, Instruction *InsertBef) : Instruction(cast(Val->getType())->getElementType(), - ExtractElement, /*Ops*/NULL, 2, InsertBef) { + ExtractElement, + OperandTraits::op_begin(this), + 2, InsertBef) { Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV); assert(isValidOperands(Val, Index) && "Invalid extractelement instruction operands!"); @@ -1140,7 +1144,9 @@ const std::string &Name, BasicBlock *InsertAE) : Instruction(cast(Val->getType())->getElementType(), - ExtractElement, /*Ops*/NULL, 2, InsertAE) { + ExtractElement, + OperandTraits::op_begin(this), + 2, InsertAE) { assert(isValidOperands(Val, Index) && "Invalid extractelement instruction operands!"); @@ -1153,7 +1159,9 @@ const std::string &Name, BasicBlock *InsertAE) : Instruction(cast(Val->getType())->getElementType(), - ExtractElement, /*Ops*/NULL, 2, InsertAE) { + ExtractElement, + OperandTraits::op_begin(this), + 2, InsertAE) { Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV); assert(isValidOperands(Val, Index) && "Invalid extractelement instruction operands!"); @@ -1176,7 +1184,8 @@ //===----------------------------------------------------------------------===// InsertElementInst::InsertElementInst(const InsertElementInst &IE) - : Instruction(IE.getType(), InsertElement, /*Ops*/NULL, 3) { + : Instruction(IE.getType(), InsertElement, + OperandTraits::op_begin(this), 3) { Op<0>().init(IE.Op<0>(), this); Op<1>().init(IE.Op<1>(), this); Op<2>().init(IE.Op<2>(), this); @@ -1184,7 +1193,9 @@ InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index, const std::string &Name, Instruction *InsertBef) - : Instruction(Vec->getType(), InsertElement, /*Ops*/NULL, 3, InsertBef) { + : Instruction(Vec->getType(), InsertElement, + OperandTraits::op_begin(this), + 3, InsertBef) { assert(isValidOperands(Vec, Elt, Index) && "Invalid insertelement instruction operands!"); Op<0>().init(Vec, this); @@ -1196,7 +1207,9 @@ InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV, const std::string &Name, Instruction *InsertBef) - : Instruction(Vec->getType(), InsertElement, /*Ops*/NULL, 3, InsertBef) { + : Instruction(Vec->getType(), InsertElement, + OperandTraits::op_begin(this), + 3, InsertBef) { Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV); assert(isValidOperands(Vec, Elt, Index) && "Invalid insertelement instruction operands!"); @@ -1210,7 +1223,9 @@ InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index, const std::string &Name, BasicBlock *InsertAE) - : Instruction(Vec->getType(), InsertElement, /*Ops*/NULL, 3, InsertAE) { + : Instruction(Vec->getType(), InsertElement, + OperandTraits::op_begin(this), + 3, InsertAE) { assert(isValidOperands(Vec, Elt, Index) && "Invalid insertelement instruction operands!"); @@ -1223,7 +1238,9 @@ InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV, const std::string &Name, BasicBlock *InsertAE) -: Instruction(Vec->getType(), InsertElement, /*Ops*/NULL, 3, InsertAE) { +: Instruction(Vec->getType(), InsertElement, + OperandTraits::op_begin(this), + 3, InsertAE) { Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV); assert(isValidOperands(Vec, Elt, Index) && "Invalid insertelement instruction operands!"); From ggreif at gmail.com Sun Apr 13 17:51:07 2008 From: ggreif at gmail.com (Gabor Greif) Date: Sun, 13 Apr 2008 22:51:07 -0000 Subject: [llvm-commits] [llvm] r49626 - /llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Message-ID: <200804132251.m3DMp7SE006497@zion.cs.uiuc.edu> Author: ggreif Date: Sun Apr 13 17:51:07 2008 New Revision: 49626 URL: http://llvm.org/viewvc/llvm-project?rev=49626&view=rev Log: cope with BranchInst's possibly shrinking operand list Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=49626&r1=49625&r2=49626&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Sun Apr 13 17:51:07 2008 @@ -1698,7 +1698,13 @@ return new(3) BranchInst(IfTrue, IfFalse, Cond, InsertAtEnd); } - // not yet ~BranchInst(); + ~BranchInst() + { + if (NumOperands == 1) + { + NumOperands = (Use*)this - OperandList; + } + } /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -1722,12 +1728,12 @@ // targeting the specified block. // FIXME: Eliminate this ugly method. void setUnconditionalDest(BasicBlock *Dest) { + Op<0>() = Dest; if (isConditional()) { // Convert this to an uncond branch. - NumOperands = 1; Op<1>().set(0); Op<2>().set(0); + NumOperands = 1; } - Op<0>() = Dest; } unsigned getNumSuccessors() const { return 1+isConditional(); } @@ -1757,7 +1763,10 @@ }; template <> -struct OperandTraits : VariadicOperandTraits<1> { +struct OperandTraits : HungoffOperandTraits<> { + // we need to access operands via OperandList, since + // the NumOperands may change from 3 to 1 + static inline void *allocate(unsigned); // FIXME }; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BranchInst, Value) From ggreif at gmail.com Sun Apr 13 18:20:26 2008 From: ggreif at gmail.com (Gabor Greif) Date: Sun, 13 Apr 2008 23:20:26 -0000 Subject: [llvm-commits] [llvm] r49627 - /llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Message-ID: <200804132320.m3DNKQeo007373@zion.cs.uiuc.edu> Author: ggreif Date: Sun Apr 13 18:20:25 2008 New Revision: 49627 URL: http://llvm.org/viewvc/llvm-project?rev=49627&view=rev Log: cleanups Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=49627&r1=49626&r2=49627&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Sun Apr 13 18:20:25 2008 @@ -329,15 +329,6 @@ /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); - /* Value *getOperand(unsigned i) const { - assert(i < 2 && "getOperand() out of range!"); - return OperandList[i]; - } - void setOperand(unsigned i, Value *Val) { - assert(i < 2 && "setOperand() out of range!"); - OperandList[i] = Val; - } - unsigned getNumOperands() const { return 2; }*/ /// getAlignment - Return the alignment of the access that is being performed /// @@ -1253,15 +1244,6 @@ /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); - /* Value *getOperand(unsigned i) const { - assert(i < 2 && "getOperand() out of range!"); - return OperandList[i]; - } - void setOperand(unsigned i, Value *Val) { - assert(i < 2 && "setOperand() out of range!"); - OperandList[i] = Val; - } - unsigned getNumOperands() const { return 2; }*/ // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const ExtractElementInst *) { return true; } @@ -1332,15 +1314,6 @@ /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); - /* Value *getOperand(unsigned i) const { - assert(i < 3 && "getOperand() out of range!"); - return OperandList[i]; - } - void setOperand(unsigned i, Value *Val) { - assert(i < 3 && "setOperand() out of range!"); - OperandList[i] = Val; - } - unsigned getNumOperands() const { return 3; }*/ // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const InsertElementInst *) { return true; } @@ -1957,13 +1930,7 @@ inline InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, InputIterator ArgBegin, InputIterator ArgEnd, unsigned Values, - const std::string &Name, Instruction *InsertBefore);/* - : TerminatorInst(cast(cast(Func->getType()) - ->getElementType())->getReturnType(), - Instruction::Invoke, 0, Values, InsertBefore) { - init(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name, - typename std::iterator_traits::iterator_category()); - }*/ + const std::string &Name, Instruction *InsertBefore); /// Construct an InvokeInst given a range of arguments. /// InputIterator must be a random-access iterator pointing to @@ -1974,15 +1941,9 @@ /// @brief Construct an InvokeInst from a range of arguments template inline InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, - InputIterator ArgBegin, InputIterator ArgEnd, - unsigned Values, - const std::string &Name, BasicBlock *InsertAtEnd);/* - : TerminatorInst(cast(cast(Func->getType()) - ->getElementType())->getReturnType(), - Instruction::Invoke, 0, Values, InsertAtEnd) { - init(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name, - typename std::iterator_traits::iterator_category()); - }*/ + InputIterator ArgBegin, InputIterator ArgEnd, + unsigned Values, + const std::string &Name, BasicBlock *InsertAtEnd); public: template static InvokeInst *Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, From ggreif at gmail.com Sun Apr 13 19:14:34 2008 From: ggreif at gmail.com (Gabor Greif) Date: Mon, 14 Apr 2008 00:14:34 -0000 Subject: [llvm-commits] [llvm] r49630 - in /llvm/branches/ggreif/use-diet: include/llvm/Constants.h lib/VMCore/Constants.cpp Message-ID: <200804140014.m3E0EYE5008860@zion.cs.uiuc.edu> Author: ggreif Date: Sun Apr 13 19:14:34 2008 New Revision: 49630 URL: http://llvm.org/viewvc/llvm-project?rev=49630&view=rev Log: convert Constant{Array|Struct|Vector} to prefix allocation. does not compile yet Modified: llvm/branches/ggreif/use-diet/include/llvm/Constants.h llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp Modified: llvm/branches/ggreif/use-diet/include/llvm/Constants.h URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Constants.h?rev=49630&r1=49629&r2=49630&view=diff ============================================================================== --- llvm/branches/ggreif/use-diet/include/llvm/Constants.h (original) +++ llvm/branches/ggreif/use-diet/include/llvm/Constants.h Sun Apr 13 19:14:34 2008 @@ -331,6 +331,9 @@ /// null termination. static Constant *get(const std::string &Initializer, bool AddNull = true); + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); + /// getType - Specialize the getType() method to always return an ArrayType, /// which reduces the amount of casting needed in parts of the compiler. /// @@ -369,6 +372,11 @@ } }; +template <> +struct OperandTraits : VariadicOperandTraits<> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantArray, Value) //===----------------------------------------------------------------------===// // ConstantStruct - Constant Struct Declarations @@ -391,6 +399,9 @@ return get(std::vector(Vals, Vals+NumVals), Packed); } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); + /// getType() specialization - Reduce amount of casting... /// inline const StructType *getType() const { @@ -414,6 +425,12 @@ } }; +template <> +struct OperandTraits : VariadicOperandTraits<> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantStruct, Value) + //===----------------------------------------------------------------------===// /// ConstantVector - Constant Vector Declarations /// @@ -433,6 +450,9 @@ return get(std::vector(Vals, Vals+NumVals)); } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); + /// getType - Specialize the getType() method to always return a VectorType, /// which reduces the amount of casting needed in parts of the compiler. /// @@ -470,6 +490,12 @@ } }; +template <> +struct OperandTraits : VariadicOperandTraits<> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantVector, Value) + //===----------------------------------------------------------------------===// /// ConstantPointerNull - a constant pointer value that points to null /// @@ -568,6 +594,9 @@ static Constant *getIntToPtr(Constant *C, const Type *Ty); static Constant *getBitCast (Constant *C, const Type *Ty); + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); + // @brief Convenience function for getting one of the casting operations // using a CastOps opcode. static Constant *getCast( @@ -720,6 +749,11 @@ } }; +template <> +struct OperandTraits : VariadicOperandTraits<1> { +}; + +DEFINE_TRANSPAR