[llvm-commits] [llvm] r44858 - in /llvm/trunk: include/llvm/Bitcode/LLVMBitCodes.h include/llvm/DerivedTypes.h include/llvm/GlobalVariable.h include/llvm/Instructions.h lib/AsmParser/LLLexer.cpp lib/A
Author: clamb Date: Tue Dec 11 02:59:05 2007 New Revision: 44858 URL: http://llvm.org/viewvc/llvm-project?rev=44858&view=rev Log: Implement address space attribute for LLVM pointer types. Address spaces are regions of memory that have a target specific relationship, as described in the Embedded C Technical Report. This also implements the 2007-12-11-AddressSpaces test, which demonstrates how address space attributes can be used in LLVM IR. In addition, this patch changes the bitcode signature for stores (in a backwards compatible manner), such that the pointer type, rather than the pointee type, is encoded. This permits type information in the pointer (e.g. address space) to be preserved for stores. LangRef updates are forthcoming. Added: llvm/trunk/test/Assembler/2007-12-11-AddressSpaces.ll Modified: llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h llvm/trunk/include/llvm/DerivedTypes.h llvm/trunk/include/llvm/GlobalVariable.h llvm/trunk/include/llvm/Instructions.h llvm/trunk/lib/AsmParser/LLLexer.cpp llvm/trunk/lib/AsmParser/llvmAsmParser.y llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/trunk/lib/VMCore/AsmWriter.cpp llvm/trunk/lib/VMCore/Constants.cpp llvm/trunk/lib/VMCore/Globals.cpp llvm/trunk/lib/VMCore/Instructions.cpp llvm/trunk/lib/VMCore/Type.cpp llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp Modified: llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h?rev=44858&r1=44857&r2=44858&view=diff == --- llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h (original) +++ llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h Tue Dec 11 02:59:05 2007 @@ -46,7 +46,7 @@ MODULE_CODE_SECTIONNAME = 5,// SECTIONNAME: [strchr x N] MODULE_CODE_DEPLIB = 6,// DEPLIB: [strchr x N] -// GLOBALVAR: [type, isconst, initid, +// GLOBALVAR: [pointer type, isconst, initid, // linkage, alignment, section, visibility, threadlocal] MODULE_CODE_GLOBALVAR = 7, @@ -194,9 +194,13 @@ FUNC_CODE_INST_FREE= 18, // FREE: [opty, op] FUNC_CODE_INST_ALLOCA = 19, // ALLOCA: [instty, op, align] FUNC_CODE_INST_LOAD= 20, // LOAD: [opty, op, align, vol] -FUNC_CODE_INST_STORE = 21, // STORE: [ptrty,val,ptr, align, vol] +FUNC_CODE_INST_STORE = 21, // STORE: [valty,val,ptr, align, vol] FUNC_CODE_INST_CALL= 22, // CALL: [attr, fnty, fnid, args...] -FUNC_CODE_INST_VAARG = 23 // VAARG: [valistty, valist, instty] +FUNC_CODE_INST_VAARG = 23, // VAARG: [valistty, valist, instty] +// This store code encodes the pointer type, rather than the value type +// this is so information only available in the pointer type (e.g. address +// spaces) is retained. +FUNC_CODE_INST_STORE2 = 24 // STORE: [ptrty,ptr,val, align, vol] }; } // End bitc namespace } // End llvm namespace Modified: llvm/trunk/include/llvm/DerivedTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DerivedTypes.h?rev=44858&r1=44857&r2=44858&view=diff == --- llvm/trunk/include/llvm/DerivedTypes.h (original) +++ llvm/trunk/include/llvm/DerivedTypes.h Tue Dec 11 02:59:05 2007 @@ -363,12 +363,17 @@ /// class PointerType : public SequentialType { friend class TypeMap; + unsigned AddressSpace; + PointerType(const PointerType &); // Do not implement const PointerType &operator=(const PointerType &); // Do not implement - explicit PointerType(const Type *ElType); + explicit PointerType(const Type *ElType, unsigned AddrSpace); public: /// PointerType::get - This is the only way to construct a new pointer type. - static PointerType *get(const Type *ElementType); + static PointerType *get(const Type *ElementType, unsigned AddressSpace = 0); + + /// @brief Return the address space of the Pointer type. + inline unsigned getAddressSpace() const { return AddressSpace; } // Implement the AbstractTypeUser interface. virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy); Modified: llvm/trunk/include/llvm/GlobalVariable.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/GlobalVariable.h?rev=44858&r1=44857&r2=44858&view=diff == --- llvm/trunk/include/llvm/GlobalVariable.h (original) +++ llvm/trunk/include/llvm/GlobalVariable.h Tue Dec 11 02:59:05 2007 @@ -50,12 +50,14 @@ /// automatically inserted into the end of the specified modules global list. GlobalVariable(const Type *Ty, bool isConstant, LinkageTypes Linkage, Constant
Re: [llvm-commits] [llvm] r44825 - in /llvm/trunk: include/llvm/Target/TargetData.h lib/Target/TargetData.cpp
Hi Chris, > Duncan, this patch gets llvm-gcc to build, but it still doesn't > answer the big question: why does TargetData contain information > about the host? well, it needed to go somewhere. Any suggestions for a better place? Another possibility is to have a function isWrongEndian in target data, which tells you if the target has opposite endianness to the host. > I don't think this is the right approach. Also, you > can get the host endianness without autoconf by using something > simple like: > > bool islittleendian() { >union { > int i; > char c; >}; > >i = 1; >return c; > } I have no particular opinion on this (except that it's amazing to me that there's no standard way to query the compiler for this in C++ :) ). Presumably the compiler will reduce this function to: return true; (or false) at compile time, so there's no cost to your approach. I suppose that plenty of things that autoconf does could also be done in a special function like this, yet they are left to autoconf - I have no idea what the criteria are for doing something via autoconf or via a runtime test. Having the function inline in a header would have the advantage that the compiler would eliminate a bunch of code in ExecutionEngine at runtime. Since it seems that the autoconf solution is not compatible with being exposed in a header, that suggests your solution is the way to go. Ciao, Duncan. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44860 - /llvm/trunk/docs/LangRef.html
Author: clamb Date: Tue Dec 11 03:31:00 2007 New Revision: 44860 URL: http://llvm.org/viewvc/llvm-project?rev=44860&view=rev Log: Add information on address space qualifiers for pointer types and global declarations to the LangRef. Modified: llvm/trunk/docs/LangRef.html Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=44860&r1=44859&r2=44860&view=diff == --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Tue Dec 11 03:31:00 2007 @@ -668,6 +668,11 @@ describe a region of memory, and all memory objects in LLVM are accessed through pointers. +A global variable may be declared to reside in a target-specifc numbered +address space. For targets that support them, address spaces may affect how +optimizations are performed and/or what target instructions are used to access +the variable. The default address space is zero. + LLVM allows an explicit section to be specified for globals. If the target supports it, it will emit globals to the section specified. @@ -677,12 +682,12 @@ global is forced to have at least that much alignment. All alignments must be a power of 2. -For example, the following defines a global with an initializer, section, - and alignment: +For example, the following defines a global in a numbered address space with +an initializer, section, and alignment: [EMAIL PROTECTED] = constant float 1.0, section "foo", align 4 [EMAIL PROTECTED] = constant float 1.0 addrspace(5), section "foo", align 4 @@ -1256,7 +1261,10 @@ Overview: As in many languages, the pointer type represents a pointer or -reference to another object, which must live in memory. +reference to another object, which must live in memory. Pointer types may have +an optional address space attribute defining the target-specific numbered +address space where the pointed-to object resides. The default address space is +zero. Syntax:* Examples: @@ -1265,6 +1273,7 @@ [4x i32]* i32 (i32 *) * + i32 addrspace(5)* A pointer to array of @@ -1272,6 +1281,8 @@ A pointer to a function that takes an i32*, returning an i32. + A pointer to an i32 value that resides + in address space 5. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [support] r44862 - /support/trunk/include/llvm/Support/StringPool.h
Author: reid Date: Tue Dec 11 03:51:22 2007 New Revision: 44862 URL: http://llvm.org/viewvc/llvm-project?rev=44862&view=rev Log: Add a missing file to the support module. Added: support/trunk/include/llvm/Support/StringPool.h - copied unchanged from r44861, llvm/trunk/include/llvm/Support/StringPool.h ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [support] r44863 - /support/trunk/lib/Support/StringPool.cpp
Author: reid Date: Tue Dec 11 03:54:37 2007 New Revision: 44863 URL: http://llvm.org/viewvc/llvm-project?rev=44863&view=rev Log: Add a missing file to the support module. Added: support/trunk/lib/Support/StringPool.cpp - copied unchanged from r44862, llvm/trunk/lib/Support/StringPool.cpp ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44861 - /llvm/trunk/CREDITS.TXT
Author: clamb Date: Tue Dec 11 03:32:07 2007 New Revision: 44861 URL: http://llvm.org/viewvc/llvm-project?rev=44861&view=rev Log: Update credits. Modified: llvm/trunk/CREDITS.TXT Modified: llvm/trunk/CREDITS.TXT URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CREDITS.TXT?rev=44861&r1=44860&r2=44861&view=diff == --- llvm/trunk/CREDITS.TXT (original) +++ llvm/trunk/CREDITS.TXT Tue Dec 11 03:32:07 2007 @@ -154,6 +154,7 @@ E: [EMAIL PROTECTED] D: aligned load/store support, parts of noalias and restrict support D: vreg subreg infrastructure, X86 codegen improvements based on subregs +D: address spaces N: Jim Laskey E: [EMAIL PROTECTED] ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44864 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
Author: baldrick Date: Tue Dec 11 06:20:47 2007 New Revision: 44864 URL: http://llvm.org/viewvc/llvm-project?rev=44864&view=rev Log: Fix compilation. Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=44864&r1=44863&r2=44864&view=diff == --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Dec 11 06:20:47 2007 @@ -196,7 +196,7 @@ Code = bitc::TYPE_CODE_INTEGER; TypeVals.push_back(cast(T)->getBitWidth()); break; -case Type::PointerTyID: +case Type::PointerTyID: { const PointerType *PTy = cast(T); // POINTER: [pointee type] or [pointee type, address space] Code = bitc::TYPE_CODE_POINTER; @@ -206,6 +206,7 @@ else AbbrevToUse = PtrAbbrev; break; +} case Type::FunctionTyID: { const FunctionType *FT = cast(T); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44851 - /llvm/trunk/include/llvm/ADT/Trie.h
Anton Korobeynikov wrote: > +template > +class Trie { > + class Edge; > + class Node; > + > + class Edge { > +std::string Label; > +Node *Parent, *Child; The Parent field seems to be unused internally by the Trie implementation. Assuming the Edge interface is invisible for Trie clients, may this field be removed? > + std::vector Nodes; I guess this vector is purely for destruction purposes... Have you considered storing a root node only and performing destruction by postorder trie traversal? > + inline Node* getRoot() const { return Nodes[0]; } I'm not familiar what Trie structure will be used for, but shouldn't this method be private? Currently, it exposes a way to call most of the Node's (and indirectly Edge's) methods, which I suppose, should be inaccessible to clients. > + bool addString(const std::string& s, const Payload& data) { > +Node* cNode = getRoot(); > +Edge* nEdge = NULL; > +std::string s1(s); > + > +while (nEdge == NULL) { > + if (cNode->Edges.count(s1[0])) { > +Edge& cEdge = cNode->Edges[s1[0]]; > +typename Edge::QueryResult r = cEdge.query(s1); > + > +switch (r) { > +case Edge::Same: Do we really want to hit the assert here, and not only return false? > +case Edge::StringIsPrefix: Shouldn't the edge be splitted in this case and the payload be attached to the new node? -Wojtek ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44865 - in /llvm/trunk/test/Assembler: 2007-04-20-AlignedLoad.ll 2007-04-20-AlignedStore.ll
Author: djg Date: Tue Dec 11 09:41:11 2007 New Revision: 44865 URL: http://llvm.org/viewvc/llvm-project?rev=44865&view=rev Log: Don't redirect stderr when it isn't needed. Modified: llvm/trunk/test/Assembler/2007-04-20-AlignedLoad.ll llvm/trunk/test/Assembler/2007-04-20-AlignedStore.ll Modified: llvm/trunk/test/Assembler/2007-04-20-AlignedLoad.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/2007-04-20-AlignedLoad.ll?rev=44865&r1=44864&r2=44865&view=diff == --- llvm/trunk/test/Assembler/2007-04-20-AlignedLoad.ll (original) +++ llvm/trunk/test/Assembler/2007-04-20-AlignedLoad.ll Tue Dec 11 09:41:11 2007 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llvm-dis |& grep {align 1024} +; RUN: llvm-as < %s | llvm-dis | grep {align 1024} define i32 @test(i32* %arg) { entry: Modified: llvm/trunk/test/Assembler/2007-04-20-AlignedStore.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/2007-04-20-AlignedStore.ll?rev=44865&r1=44864&r2=44865&view=diff == --- llvm/trunk/test/Assembler/2007-04-20-AlignedStore.ll (original) +++ llvm/trunk/test/Assembler/2007-04-20-AlignedStore.ll Tue Dec 11 09:41:11 2007 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s |& llvm-dis | grep {align 1024} +; RUN: llvm-as < %s | llvm-dis | grep {align 1024} define void @test(i32* %arg) { entry: ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44866 - in /llvm/trunk/test: Assembler/2004-11-28-InvalidTypeCrash.ll Assembler/2005-01-31-CallingAggregateFunction.ll CFrontend/2006-09-25-DebugFilename.c Feature/globalredefin
Author: djg Date: Tue Dec 11 09:50:23 2007 New Revision: 44866 URL: http://llvm.org/viewvc/llvm-project?rev=44866&view=rev Log: Use not instead of ignore when an exit status is expected to always be non-zero. Modified: llvm/trunk/test/Assembler/2004-11-28-InvalidTypeCrash.ll llvm/trunk/test/Assembler/2005-01-31-CallingAggregateFunction.ll llvm/trunk/test/CFrontend/2006-09-25-DebugFilename.c llvm/trunk/test/Feature/globalredefinition3.ll llvm/trunk/test/Linker/link-messages.ll llvm/trunk/test/Linker/redefinition.ll llvm/trunk/test/Verifier/2006-10-15-AddrLabel.ll Modified: llvm/trunk/test/Assembler/2004-11-28-InvalidTypeCrash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/2004-11-28-InvalidTypeCrash.ll?rev=44866&r1=44865&r2=44866&view=diff == --- llvm/trunk/test/Assembler/2004-11-28-InvalidTypeCrash.ll (original) +++ llvm/trunk/test/Assembler/2004-11-28-InvalidTypeCrash.ll Tue Dec 11 09:50:23 2007 @@ -1,5 +1,5 @@ ; Test for PR463. This program is erroneous, but should not crash llvm-as. -; RUN: ignore llvm-as < %s -o /dev/null -f |& \ +; RUN: not llvm-as < %s -o /dev/null -f |& \ ; RUN: grep {Cannot create a null initialized value of this type} @.FOO = internal global %struct.none zeroinitializer Modified: llvm/trunk/test/Assembler/2005-01-31-CallingAggregateFunction.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/2005-01-31-CallingAggregateFunction.ll?rev=44866&r1=44865&r2=44866&view=diff == --- llvm/trunk/test/Assembler/2005-01-31-CallingAggregateFunction.ll (original) +++ llvm/trunk/test/Assembler/2005-01-31-CallingAggregateFunction.ll Tue Dec 11 09:50:23 2007 @@ -1,4 +1,4 @@ -; RUN: ignore llvm-as < %s -o /dev/null -f |& \ +; RUN: not llvm-as < %s -o /dev/null -f |& \ ; RUN:grep {LLVM functions cannot return aggregate types} define void @test() { Modified: llvm/trunk/test/CFrontend/2006-09-25-DebugFilename.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CFrontend/2006-09-25-DebugFilename.c?rev=44866&r1=44865&r2=44866&view=diff == --- llvm/trunk/test/CFrontend/2006-09-25-DebugFilename.c (original) +++ llvm/trunk/test/CFrontend/2006-09-25-DebugFilename.c Tue Dec 11 09:50:23 2007 @@ -1,4 +1,4 @@ -// RUN: ignore %llvmgcc -xc %s -S -o /dev/null |& \ +// RUN: not %llvmgcc -xc %s -S -o /dev/null |& \ // RUN: grep fluffy | grep 2006-09-25-DebugFilename.c #include "2006-09-25-DebugFilename.h" int func1() { return hfunc1(); } Modified: llvm/trunk/test/Feature/globalredefinition3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Feature/globalredefinition3.ll?rev=44866&r1=44865&r2=44866&view=diff == --- llvm/trunk/test/Feature/globalredefinition3.ll (original) +++ llvm/trunk/test/Feature/globalredefinition3.ll Tue Dec 11 09:50:23 2007 @@ -1,4 +1,4 @@ -; RUN: ignore llvm-as < %s -o /dev/null -f |& grep \ +; RUN: not llvm-as < %s -o /dev/null -f |& grep \ ; RUN: "Redefinition of global variable named 'B'" ; END. Modified: llvm/trunk/test/Linker/link-messages.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/link-messages.ll?rev=44866&r1=44865&r2=44866&view=diff == --- llvm/trunk/test/Linker/link-messages.ll (original) +++ llvm/trunk/test/Linker/link-messages.ll Tue Dec 11 09:50:23 2007 @@ -2,7 +2,7 @@ ; that error is printed out. ; RUN: llvm-as %s -o %t.one.bc -f ; RUN: llvm-as %s -o %t.two.bc -f -; RUN: ignore llvm-ld -disable-opt -link-as-library %t.one.bc %t.two.bc \ +; RUN: not llvm-ld -disable-opt -link-as-library %t.one.bc %t.two.bc \ ; RUN: -o %t.bc 2>%t.err ; RUN: grep "Function is already defined" %t.err Modified: llvm/trunk/test/Linker/redefinition.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/redefinition.ll?rev=44866&r1=44865&r2=44866&view=diff == --- llvm/trunk/test/Linker/redefinition.ll (original) +++ llvm/trunk/test/Linker/redefinition.ll Tue Dec 11 09:50:23 2007 @@ -3,8 +3,8 @@ ; RUN: llvm-as %s -o %t.foo1.bc -f ; RUN: llvm-as %s -o %t.foo2.bc -f ; RUN: echo {define void @foo(i32 %x) { ret void }} | llvm-as -o %t.foo3.bc -f -; RUN: ignore llvm-link %t.foo1.bc %t.foo2.bc -o %t.bc |& \ +; RUN: not llvm-link %t.foo1.bc %t.foo2.bc -o %t.bc |& \ ; RUN: grep {Function is already defined} -; RUN: ignore llvm-link %t.foo1.bc %t.foo3.bc -o %t.bc |& \ +; RUN: not llvm-link %t.foo1.bc %t.foo3.bc -o %t.bc |& \ ; RUN: grep {Function 'foo' defined as both} define void @foo() { ret void } Modified: llvm/trunk/test/Verifier/2006-10-15-AddrLabel.ll URL: http://llvm.or
[llvm-commits] [llvm] r44867 - in /llvm/trunk/test: C++Frontend/2007-10-01-StructResize.cpp C++Frontend/2007-10-01-StructResize.ll FrontendObjC/2007-10-18-ProDescriptor.ll FrontendObjC/2007-10-18-ProD
Author: djg Date: Tue Dec 11 09:55:52 2007 New Revision: 44867 URL: http://llvm.org/viewvc/llvm-project?rev=44867&view=rev Log: Rename these tests to use the appropriate suffixes. Added: llvm/trunk/test/C++Frontend/2007-10-01-StructResize.cpp - copied unchanged from r44792, llvm/trunk/test/C++Frontend/2007-10-01-StructResize.ll llvm/trunk/test/FrontendObjC/2007-10-18-ProDescriptor.m - copied unchanged from r44792, llvm/trunk/test/FrontendObjC/2007-10-18-ProDescriptor.ll Removed: llvm/trunk/test/C++Frontend/2007-10-01-StructResize.ll llvm/trunk/test/FrontendObjC/2007-10-18-ProDescriptor.ll Removed: llvm/trunk/test/C++Frontend/2007-10-01-StructResize.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/C%2B%2BFrontend/2007-10-01-StructResize.ll?rev=44866&view=auto == --- llvm/trunk/test/C++Frontend/2007-10-01-StructResize.ll (original) +++ llvm/trunk/test/C++Frontend/2007-10-01-StructResize.ll (removed) @@ -1,14 +0,0 @@ -// RUN: %llvmgxx -c %s -o /dev/null - -#pragma pack(4) - -struct Bork { - unsigned int f1 : 3; - unsigned int f2 : 30; -}; - -int Foo(Bork *hdr) { - hdr->f1 = 7; - hdr->f2 = 927; -} - Removed: llvm/trunk/test/FrontendObjC/2007-10-18-ProDescriptor.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendObjC/2007-10-18-ProDescriptor.ll?rev=44866&view=auto == --- llvm/trunk/test/FrontendObjC/2007-10-18-ProDescriptor.ll (original) +++ llvm/trunk/test/FrontendObjC/2007-10-18-ProDescriptor.ll (removed) @@ -1,19 +0,0 @@ -// RUN: %llvmgcc -x objective-c -c %s -o /dev/null [EMAIL PROTECTED] O [EMAIL PROTECTED] [EMAIL PROTECTED] O < O > { -} [EMAIL PROTECTED] -struct A { -}; [EMAIL PROTECTED] AB -- (unsigned) ver; [EMAIL PROTECTED] [EMAIL PROTECTED] AGy:O < AB > { -} [EMAIL PROTECTED] [EMAIL PROTECTED] AGy -- (unsigned) ver { -} [EMAIL PROTECTED] - ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44825 - in /llvm/trunk: include/llvm/Target/TargetData.h lib/Target/TargetData.cpp
On Dec 11, 2007, at 1:25 AM, Duncan Sands wrote: > Hi Chris, > >> Duncan, this patch gets llvm-gcc to build, but it still doesn't >> answer the big question: why does TargetData contain information >> about the host? > > well, it needed to go somewhere. Any suggestions for a better place? > Another possibility is to have a function isWrongEndian in target > data, > which tells you if the target has opposite endianness to the host. How about a static function in ExecutionEngine.cpp that takes a TargetData& ? >> I don't think this is the right approach. Also, you >> can get the host endianness without autoconf by using something >> simple like: >> >> bool islittleendian() { >>union { >> int i; >> char c; >>}; >> >>i = 1; >>return c; >> } > > I have no particular opinion on this (except that it's amazing to me > that there's no standard way to query the compiler for this in C+ > + :) ). Ah, but no "well defined" code should depend on endianness. :) Ah the differences in reality between standards and actual usage. > Presumably the compiler will reduce this function to: return true; > (or false) > at compile time, so there's no cost to your approach. Right. > I suppose that plenty > of things that autoconf does could also be done in a special > function like this, > yet they are left to autoconf - I have no idea what the criteria > are for doing > something via autoconf or via a runtime test. A lot of things can't be done that way, for example finding the path to an external tool, checking to see if your assembler has some feature (e.g. .cfi support), etc. > Having the function inline in a > header would have the advantage that the compiler would eliminate a > bunch of code > in ExecutionEngine at runtime. Since it seems that the autoconf > solution is not > compatible with being exposed in a header, that suggests your > solution is the way > to go. Thanks! -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44825 - in /llvm/trunk: include/llvm/Target/TargetData.h lib/Target/TargetData.cpp
On Dec 11, 2007, at 9:19 AM, Chris Lattner wrote: > >> I suppose that plenty >> of things that autoconf does could also be done in a special >> function like this, >> yet they are left to autoconf - I have no idea what the criteria >> are for doing >> something via autoconf or via a runtime test. > > A lot of things can't be done that way, for example finding the path > to an external tool, checking to see if your assembler has some > feature (e.g. .cfi support), etc. gcc's configure script has examples of both of these. Not that I am holding this up as something to imitate. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44868 - /llvm/trunk/include/llvm/ADT/GraphTraits.h
Author: wmat Date: Tue Dec 11 11:46:25 2007 New Revision: 44868 URL: http://llvm.org/viewvc/llvm-project?rev=44868&view=rev Log: Use correct member access operator. (my test commit as well) Modified: llvm/trunk/include/llvm/ADT/GraphTraits.h Modified: llvm/trunk/include/llvm/ADT/GraphTraits.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/GraphTraits.h?rev=44868&r1=44867&r2=44868&view=diff == --- llvm/trunk/include/llvm/ADT/GraphTraits.h (original) +++ llvm/trunk/include/llvm/ADT/GraphTraits.h Tue Dec 11 11:46:25 2007 @@ -86,7 +86,7 @@ typedef typename GraphTraits::ChildIteratorType ChildIteratorType; static NodeType *getEntryNode(Inverse > *G) { -return GraphTraits::getEntryNode(G.Graph.Graph); +return GraphTraits::getEntryNode(G->Graph.Graph); } static ChildIteratorType child_begin(NodeType* N) { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44869 - /llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
Author: sampo Date: Tue Dec 11 12:06:14 2007 New Revision: 44869 URL: http://llvm.org/viewvc/llvm-project?rev=44869&view=rev Log: Allow the JIT to encode MMX instructions Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=44869&r1=44868&r2=44869&view=diff == --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Tue Dec 11 12:06:14 2007 @@ -713,21 +713,21 @@ case X86::ST4: case X86::ST5: case X86::ST6: case X86::ST7: return RegNo-X86::ST0; - case X86::XMM0: case X86::XMM8: + case X86::XMM0: case X86::XMM8: case X86::MM0: return 0; - case X86::XMM1: case X86::XMM9: + case X86::XMM1: case X86::XMM9: case X86::MM1: return 1; - case X86::XMM2: case X86::XMM10: + case X86::XMM2: case X86::XMM10: case X86::MM2: return 2; - case X86::XMM3: case X86::XMM11: + case X86::XMM3: case X86::XMM11: case X86::MM3: return 3; - case X86::XMM4: case X86::XMM12: + case X86::XMM4: case X86::XMM12: case X86::MM4: return 4; - case X86::XMM5: case X86::XMM13: + case X86::XMM5: case X86::XMM13: case X86::MM5: return 5; - case X86::XMM6: case X86::XMM14: + case X86::XMM6: case X86::XMM14: case X86::MM6: return 6; - case X86::XMM7: case X86::XMM15: + case X86::XMM7: case X86::XMM15: case X86::MM7: return 7; default: ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44851 - /llvm/trunk/include/llvm/ADT/Trie.h
Hello, Wojciech. > The Parent field seems to be unused internally by the Trie > implementation. Assuming the Edge interface is invisible for Trie > clients, may this field be removed? The whole Edge is not needed actually. See a list of FIXMEs in the beginning :) > I'm not familiar what Trie structure will be used for, but shouldn't > this method be private? Currently, it exposes a way to call most of the > Node's (and indirectly Edge's) methods, which I suppose, should be > inaccessible to clients. This will be needed for GraphTraits stuff. In the future I will want to iterate over nodes. > Do we really want to hit the assert here, and not only return false? Right. It's here just for debugging purposes. I'll clean most of asserts. > > +case Edge::StringIsPrefix: > > Shouldn't the edge be splitted in this case and the payload be attached > to the new node? Current implementation doesn't allow to have two strings in the trie, one being a prefix of another. I will remove this requirement soon. This will beed to introduce splitting here and some more bookkeeping in another place. -- With best regards, Anton Korobeynikov. Faculty of Mathematics & Mechanics, Saint Petersburg State University. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44871 - /llvm/trunk/lib/CodeGen/MachineLICM.cpp
Author: void Date: Tue Dec 11 12:45:11 2007 New Revision: 44871 URL: http://llvm.org/viewvc/llvm-project?rev=44871&view=rev Log: Checking for "zero operands" during the "CanHoistInst()" method isn't necessary because those with side effects will be caught by other checks in here. Also, simplify the check for a BB in a sub loop. Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineLICM.cpp?rev=44871&r1=44870&r2=44871&view=diff == --- llvm/trunk/lib/CodeGen/MachineLICM.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineLICM.cpp Tue Dec 11 12:45:11 2007 @@ -99,13 +99,7 @@ /// bool IsInSubLoop(MachineBasicBlock *BB) { assert(CurLoop->contains(BB) && "Only valid if BB is IN the loop"); - - for (MachineLoop::iterator - I = CurLoop->begin(), E = CurLoop->end(); I != E; ++I) -if ((*I)->contains(BB)) - return true; // A subloop actually contains this block! - - return false; + return LI->getLoopFor(BB) != CurLoop; } /// CanHoistInst - Checks that this instructions is one that can be hoisted @@ -115,9 +109,8 @@ bool CanHoistInst(MachineInstr &I) const { const TargetInstrDescriptor *TID = I.getInstrDescriptor(); - // Don't hoist if this instruction implicitly reads physical registers or - // doesn't take any operands. - if (TID->ImplicitUses || !I.getNumOperands()) return false; + // Don't hoist if this instruction implicitly reads physical registers. + if (TID->ImplicitUses) return false; MachineOpCode Opcode = TID->Opcode; return TII->isTriviallyReMaterializable(&I) && @@ -142,7 +135,7 @@ /// FindPredecessors - Get all of the predecessors of the loop that are not /// back-edges. /// -void FindPredecessors(std::vector &Preds){ +void FindPredecessors(std::vector &Preds) { const MachineBasicBlock *Header = CurLoop->getHeader(); for (MachineBasicBlock::const_pred_iterator ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44873 - /llvm/trunk/lib/CodeGen/MachineLICM.cpp
Author: void Date: Tue Dec 11 13:17:04 2007 New Revision: 44873 URL: http://llvm.org/viewvc/llvm-project?rev=44873&view=rev Log: - Update the virtual reg to machine instruction map when hoisting. - Fix subtle bug when creating initially creating this map. Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineLICM.cpp?rev=44873&r1=44872&r2=44873&view=diff == --- llvm/trunk/lib/CodeGen/MachineLICM.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineLICM.cpp Tue Dec 11 13:17:04 2007 @@ -215,7 +215,7 @@ const MachineInstr &MI = *II; for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) { -const MachineOperand &MO = MI.getOperand(0); +const MachineOperand &MO = MI.getOperand(i); if (MO.isRegister() && MO.isDef() && MRegisterInfo::isVirtualRegister(MO.getReg())) @@ -317,7 +317,17 @@ "The predecessor doesn't feed directly into the loop header!"); // Now move the instructions to the predecessor. - MoveInstToEndOfBlock(MBB, MI.clone()); + MachineInstr *NewMI = MI.clone(); + MoveInstToEndOfBlock(MBB, NewMI); + + // Update VRegDefs. + for (unsigned i = 0, e = NewMI->getNumOperands(); i != e; ++i) { +const MachineOperand &MO = NewMI->getOperand(i); + +if (MO.isRegister() && MO.isDef() && +MRegisterInfo::isVirtualRegister(MO.getReg())) + VRegDefs[MO.getReg()] = NewMI; + } // Hoisting was successful! Remove bothersome instruction now. MI.getParent()->remove(&MI); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44874 - /llvm/trunk/lib/CodeGen/MachineLICM.cpp
Author: void Date: Tue Dec 11 13:40:06 2007 New Revision: 44874 URL: http://llvm.org/viewvc/llvm-project?rev=44874&view=rev Log: Blark! How in the world did this work without this?! Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineLICM.cpp?rev=44874&r1=44873&r2=44874&view=diff == --- llvm/trunk/lib/CodeGen/MachineLICM.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineLICM.cpp Tue Dec 11 13:40:06 2007 @@ -43,6 +43,8 @@ namespace { class VISIBILITY_HIDDEN MachineLICM : public MachineFunctionPass { +MachineFunction *CurMF;// Current MachineFunction + // Various analyses that we use... MachineLoopInfo *LI; // Current MachineLoopInfo MachineDominatorTree *DT; // Machine dominator tree for the current Loop @@ -91,7 +93,7 @@ /// MapVirtualRegisterDefs - Create a map of which machine instruction /// defines a virtual register. /// -void MapVirtualRegisterDefs(const MachineFunction &MF); +void MapVirtualRegisterDefs(); /// IsInSubLoop - A little predicate that returns true if the specified /// basic block is in a subloop of the current one, not the current one @@ -182,12 +184,15 @@ if (!PerformLICM) return false; // For debugging. Changed = false; - TII = MF.getTarget().getInstrInfo(); + CurMF = &MF; + TII = CurMF->getTarget().getInstrInfo(); // Get our Loop information... LI = &getAnalysis(); DT = &getAnalysis(); + MapVirtualRegisterDefs(); + for (MachineLoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I) { MachineLoop *L = *I; @@ -205,9 +210,9 @@ /// MapVirtualRegisterDefs - Create a map of which machine instruction defines a /// virtual register. /// -void MachineLICM::MapVirtualRegisterDefs(const MachineFunction &MF) { +void MachineLICM::MapVirtualRegisterDefs() { for (MachineFunction::const_iterator - I = MF.begin(), E = MF.end(); I != E; ++I) { + I = CurMF->begin(), E = CurMF->end(); I != E; ++I) { const MachineBasicBlock &MBB = *I; for (MachineBasicBlock::const_iterator ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44877 - /llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
Author: resistor Date: Tue Dec 11 14:12:11 2007 New Revision: 44877 URL: http://llvm.org/viewvc/llvm-project?rev=44877&view=rev Log: More progress on StrongPHIElimination. Now we actually USE the DomForest! Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp?rev=44877&r1=44876&r2=44877&view=diff == --- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original) +++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Tue Dec 11 14:12:11 2007 @@ -97,6 +97,9 @@ void processBlock(MachineBasicBlock* MBB); std::vector computeDomForest(std::set& instrs); +void processPHIUnion(MachineInstr* Inst, + std::set& PHIUnion, + std::vector& DF); void breakCriticalEdges(MachineFunction &Fn); }; @@ -303,6 +306,92 @@ } } +void StrongPHIElimination::processPHIUnion(MachineInstr* Inst, + std::set& PHIUnion, +std::vector& DF) { + + std::vector worklist(DF.begin(), DF.end()); + SmallPtrSet visited; + + LiveVariables& LV = getAnalysis(); + unsigned DestReg = Inst->getOperand(0).getReg(); + + while (!worklist.empty()) { +DomForestNode* DFNode = worklist.back(); + +LiveVariables::VarInfo& Info = LV.getVarInfo(DFNode->getReg()); +visited.insert(DFNode); + +bool inserted = false; +SmallPtrSet interferences; +for (DomForestNode::iterator CI = DFNode->begin(), CE = DFNode->end(); + CI != CE; ++CI) { + DomForestNode* child = *CI; + LiveVariables::VarInfo& CInfo = LV.getVarInfo(child->getReg()); + + if (isLiveOut(Info, CInfo.DefInst->getParent())) { +interferences.insert(child); + } else if (isLiveIn(Info, CInfo.DefInst->getParent()) || + Info.DefInst->getParent() == CInfo.DefInst->getParent()) { +// FIXME: Add (p, c) to possible local interferences + } + + if (!visited.count(child)) { +worklist.push_back(child); +inserted = true; + } +} + +if (interferences.size() == 1) { + DomForestNode* child = *interferences.begin(); + + unsigned numParentCopies = 0; + unsigned numChildCopies = 0; + for (int i = Inst->getNumOperands() - 1; i >= 2; i-=2) { +unsigned SrcReg = Inst->getOperand(i-1).getReg(); +if (SrcReg == DFNode->getReg()) numParentCopies++; +else if (SrcReg == child->getReg()) numChildCopies++; + } + + if (numParentCopies < numChildCopies) { +// Insert copies for child +for (int i = Inst->getNumOperands() - 1; i >= 2; i-=2) { + if (Inst->getOperand(i-1).getReg() == child->getReg()) { +unsigned SrcReg = Inst->getOperand(i-1).getReg(); +MachineBasicBlock* From = Inst->getOperand(i).getMBB(); + +Waiting[From].push_back(std::make_pair(SrcReg, DestReg)); + } +} + +// FIXME: Make child's children parent's children + } else { +// Insert copies for parent +for (int i = Inst->getNumOperands() - 1; i >= 2; i-=2) { + if (Inst->getOperand(i-1).getReg() == DFNode->getReg()) { +unsigned SrcReg = Inst->getOperand(i-1).getReg(); +MachineBasicBlock* From = Inst->getOperand(i).getMBB(); + +Waiting[From].push_back(std::make_pair(SrcReg, DestReg)); + } +} + } +} else if (interferences.size() > 1) { + // Insert copies for parent + for (int i = Inst->getNumOperands() - 1; i >= 2; i-=2) { +if (Inst->getOperand(i-1).getReg() == DFNode->getReg()) { + unsigned SrcReg = Inst->getOperand(i-1).getReg(); + MachineBasicBlock* From = Inst->getOperand(i).getMBB(); + + Waiting[From].push_back(std::make_pair(SrcReg, DestReg)); +} + } +} + +if (!inserted) worklist.pop_back(); + } +} + /// breakCriticalEdges - Break critical edges coming into blocks with PHI /// nodes, preserving dominator and livevariable info. void StrongPHIElimination::breakCriticalEdges(MachineFunction &Fn) { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44880 - /llvm/trunk/include/llvm/ADT/Trie.h
Author: asl Date: Tue Dec 11 15:55:38 2007 New Revision: 44880 URL: http://llvm.org/viewvc/llvm-project?rev=44880&view=rev Log: Remove Trie::Edge class. Now edge labels are stored into nodes itself. Modified: llvm/trunk/include/llvm/ADT/Trie.h Modified: llvm/trunk/include/llvm/ADT/Trie.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Trie.h?rev=44880&r1=44879&r2=44880&view=diff == --- llvm/trunk/include/llvm/ADT/Trie.h (original) +++ llvm/trunk/include/llvm/ADT/Trie.h Tue Dec 11 15:55:38 2007 @@ -24,19 +24,14 @@ // - Labels are usually small, maybe it's better to use SmallString // - Something efficient for child storage // - Should we use char* during construction? +// - Should we templatize Empty with traits-like interface? // - GraphTraits interface -// - Eliminate Edge class, which is ok for debugging, but not for end code template class Trie { - class Edge; - class Node; - - class Edge { -std::string Label; -Node *Parent, *Child; + class Node { +friend class Trie; - public: typedef enum { Same = -3, StringIsPrefix = -2, @@ -45,26 +40,50 @@ HaveCommonPart } QueryResult; -inline explicit Edge(std::string label = "", - Node* parent = NULL, Node* child = NULL): - Label(label), Parent(parent), Child(child) { } - -inline void setParent(Node* parent) { Parent = parent; } -inline Node* getParent() const { return Parent; } -inline void setChild(Node* child) { Child = child; } -inline Node* getChild() const { return Child; } +std::string Label; +Payload Data; +std::map Children; + public: +inline explicit Node(const Payload& data, const std::string& label = ""): +Label(label), Data(data) { } + +inline Node(const Node& n) { + Data = n.Data; + Children = n.Children; + Label = n.Label; +} +inline Node& operator=(const Node& n) { + if (&n != this) { +Data = n.Data; +Children = n.Children; +Label = n.Label; + } + + return *this; +} + +inline bool isLeaf() const { return Children.empty(); } + +inline const Payload& getData() const { return Data; } +inline void setData(const Payload& data) { Data = data; } + inline void setLabel(const std::string& label) { Label = label; } inline const std::string& getLabel() const { return Label; } -QueryResult query(const std::string& string) const { +inline bool addEdge(Node* N) { + const std::string& Label = N->getLabel(); + return Children.insert(std::make_pair(Label[0], N)).second; +} + +QueryResult query(const std::string& s) const { unsigned i, l; - unsigned l1 = string.length(); + unsigned l1 = s.length(); unsigned l2 = Label.length(); // Find the length of common part l = std::min(l1, l2); i = 0; - while ((i < l) && (string[i] == Label[i])) + while ((i < l) && (s[i] == Label[i])) ++i; if (i == l) { // One is prefix of another, find who is who @@ -74,67 +93,36 @@ return StringIsPrefix; else return LabelIsPrefix; - } else // String and Label just have common part, return its length + } else // s and Label have common (possible empty) part, return its length return (QueryResult)i; } }; - class Node { -friend class Trie; - -std::map Edges; -Payload Data; - public: -inline explicit Node(const Payload& data):Data(data) { } -inline Node(const Node& n) { - Data = n.Data; - Edges = n.Edges; -} -inline Node& operator=(const Node& n) { - if (&n != this) { -Data = n.Data; -Edges = n.Edges; - } - - return *this; -} - -inline bool isLeaf() const { return Edges.empty(); } - -inline const Payload& getData() const { return Data; } -inline void setData(const Payload& data) { Data = data; } - -inline Edge* addEdge(const std::string& Label) { - if (!Edges.insert(std::make_pair(Label[0], - Edge(Label, this))).second) { -assert(0 && "Edge already exists!"); -return NULL; - } else -return &Edges[Label[0]]; -} - }; - std::vector Nodes; Payload Empty; - inline Node* addNode(const Payload& data) { -Node* N = new Node(data); + inline Node* addNode(const Payload& data, const std::string label = "") { +Node* N = new Node(data, label); Nodes.push_back(N); return N; } - inline Node* splitEdge(Edge& cEdge, size_t index) { -const std::string& l = cEdge.getLabel(); -assert(index < l.length() && "Trying to split too far!"); + inline Node* splitEdge(Node* N, char Id, size_t index) { +assert(N->Children.count(Id) && "Node doesn't exist"); + +Node* eNode = N->Children[Id]; +const std::string &l
[llvm-commits] [llvm-gcc-4.2] r44891 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp testsuite/g++.dg/init/llvm-convert-1.C
Author: dpatel Date: Tue Dec 11 17:17:57 2007 New Revision: 44891 URL: http://llvm.org/viewvc/llvm-project?rev=44891&view=rev Log: Do not emit pending decls twice. This fixes PR1805. Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/init/llvm-convert-1.C 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=44891&r1=44890&r2=44891&view=diff == --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Tue Dec 11 17:17:57 2007 @@ -897,7 +897,8 @@ } if (TheDebugInfo) TheDebugInfo->EmitGlobalVariable(GV, decl); - + + TREE_ASM_WRITTEN(decl) = 1; timevar_pop(TV_LLVM_GLOBALS); } Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/init/llvm-convert-1.C URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.dg/init/llvm-convert-1.C?rev=44891&view=auto == --- llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/init/llvm-convert-1.C (added) +++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/init/llvm-convert-1.C Tue Dec 11 17:17:57 2007 @@ -0,0 +1,21 @@ +// LLVM LOCAL file +// { dg-do compile } +// { dg-options "" } +// PR 1805 + +int baz(void*); + +int foo() { + static void* bar[] = { &&bb1, &&bb2, &&bb3 }; + switch (baz(bar)) { + case 1: + goto bb1; + case 2: + goto bb2; + default: + goto bb3; + } + bb1: return 1; + bb2: return 2; + bb3: return 3; +} ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44892 - /llvm/trunk/lib/CodeGen/MachineLICM.cpp
Author: void Date: Tue Dec 11 17:27:51 2007 New Revision: 44892 URL: http://llvm.org/viewvc/llvm-project?rev=44892&view=rev Log: Need to grow the indexed map. Added debug statements. Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineLICM.cpp?rev=44892&r1=44891&r2=44892&view=diff == --- llvm/trunk/lib/CodeGen/MachineLICM.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineLICM.cpp Tue Dec 11 17:27:51 2007 @@ -21,12 +21,12 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineLoopInfo.h" #include "llvm/CodeGen/Passes.h" -#include "llvm/Target/TargetInstrInfo.h" #include "llvm/Support/CFG.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Target/MRegisterInfo.h" +#include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" using namespace llvm; @@ -43,14 +43,13 @@ namespace { class VISIBILITY_HIDDEN MachineLICM : public MachineFunctionPass { -MachineFunction *CurMF;// Current MachineFunction +const TargetInstrInfo *TII; +MachineFunction *CurMF; // Current MachineFunction // Various analyses that we use... MachineLoopInfo *LI; // Current MachineLoopInfo MachineDominatorTree *DT; // Machine dominator tree for the current Loop -const TargetInstrInfo *TII; - // State that is updated as we process loops bool Changed; // True if a loop is changed. MachineLoop *CurLoop; // The current loop we are working on. @@ -109,22 +108,18 @@ /// instr, etc. /// bool CanHoistInst(MachineInstr &I) const { - const TargetInstrDescriptor *TID = I.getInstrDescriptor(); - +#ifndef NDEBUG + DEBUG({ + DOUT << "--- Checking if we can hoist " << I << "\n"; + if (I.getInstrDescriptor()->ImplicitUses) +DOUT << " * Instruction has implicit uses.\n"; + else if (!TII->isTriviallyReMaterializable(&I)) +DOUT << " * Instruction has side effects.\n"; +}); +#endif // Don't hoist if this instruction implicitly reads physical registers. - if (TID->ImplicitUses) return false; - - MachineOpCode Opcode = TID->Opcode; - return TII->isTriviallyReMaterializable(&I) && -// FIXME: Below necessary? -!(TII->isReturn(Opcode) || - TII->isTerminatorInstr(Opcode) || - TII->isBranch(Opcode) || - TII->isIndirectBranch(Opcode) || - TII->isBarrier(Opcode) || - TII->isCall(Opcode) || - TII->isLoad(Opcode) || // TODO: Do loads and stores. - TII->isStore(Opcode)); + if (I.getInstrDescriptor()->ImplicitUses) return false; + return TII->isTriviallyReMaterializable(&I); } /// IsLoopInvariantInst - Returns true if the instruction is loop @@ -150,6 +145,13 @@ /// the predecessor basic block (but before the terminator instructions). /// void MoveInstToEndOfBlock(MachineBasicBlock *MBB, MachineInstr *MI) { + DEBUG({ + DOUT << "Hoisting " << *MI; + if (MBB->getBasicBlock()) +DOUT << " to MachineBasicBlock " + << MBB->getBasicBlock()->getName(); + DOUT << "\n"; +}); MachineBasicBlock::iterator Iter = MBB->getFirstTerminator(); MBB->insert(Iter, MI); ++NumHoisted; @@ -224,8 +226,10 @@ const MachineOperand &MO = MI.getOperand(i); if (MO.isRegister() && MO.isDef() && -MRegisterInfo::isVirtualRegister(MO.getReg())) +MRegisterInfo::isVirtualRegister(MO.getReg())) { + VRegDefs.grow(MO.getReg()); VRegDefs[MO.getReg()] = &MI; +} } } } @@ -331,8 +335,10 @@ const MachineOperand &MO = NewMI->getOperand(i); if (MO.isRegister() && MO.isDef() && -MRegisterInfo::isVirtualRegister(MO.getReg())) +MRegisterInfo::isVirtualRegister(MO.getReg())) { + VRegDefs.grow(MO.getReg()); VRegDefs[MO.getReg()] = NewMI; +} } // Hoisting was successful! Remove bothersome instruction now. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44881 - /llvm/trunk/lib/CodeGen/MachineLICM.cpp
Author: void Date: Tue Dec 11 16:22:22 2007 New Revision: 44881 URL: http://llvm.org/viewvc/llvm-project?rev=44881&view=rev Log: Simplify slightly. Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp Modified: llvm/trunk/lib/CodeGen/MachineLICM.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineLICM.cpp?rev=44881&r1=44880&r2=44881&view=diff == --- llvm/trunk/lib/CodeGen/MachineLICM.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineLICM.cpp Tue Dec 11 16:22:22 2007 @@ -183,6 +183,8 @@ bool MachineLICM::runOnMachineFunction(MachineFunction &MF) { if (!PerformLICM) return false; // For debugging. + DOUT << " Machine LICM \n"; + Changed = false; CurMF = &MF; TII = CurMF->getTarget().getInstrInfo(); @@ -195,13 +197,12 @@ for (MachineLoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I) { -MachineLoop *L = *I; -CurLoop = L; +CurLoop = *I; // Visit all of the instructions of the loop. We want to visit the subloops // first, though, so that we can hoist their invariants first into their // containing loop before we process that loop. -VisitAllLoops(L); +VisitAllLoops(CurLoop); } return Changed; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44894 - /llvm/trunk/lib/CodeGen/VirtRegMap.cpp
Author: evancheng Date: Tue Dec 11 17:36:57 2007 New Revision: 44894 URL: http://llvm.org/viewvc/llvm-project?rev=44894&view=rev Log: If deleting a reload instruction due to reuse (value is available in register R and reload is targeting R), make sure to invalidate the kill information of the last kill. Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegMap.cpp?rev=44894&r1=44893&r2=44894&view=diff == --- llvm/trunk/lib/CodeGen/VirtRegMap.cpp (original) +++ llvm/trunk/lib/CodeGen/VirtRegMap.cpp Tue Dec 11 17:36:57 2007 @@ -474,6 +474,17 @@ } } +/// InvalidateKill - A MI that defines the specified register is being deleted, +/// invalidate the register kill information. +static void InvalidateKill(unsigned Reg, BitVector &RegKills, + std::vector &KillOps) { + if (RegKills[Reg]) { +KillOps[Reg]->unsetIsKill(); +KillOps[Reg] = NULL; +RegKills.reset(Reg); + } +} + /// InvalidateRegDef - If the def operand of the specified def MI is now dead /// (since it's spill instruction is removed), mark it isDead. Also checks if /// the def MI has other definition operands that are not dead. Returns it by @@ -537,12 +548,13 @@ // That can't be right. Register is killed but not re-defined and it's // being reused. Let's fix that. KillOps[Reg]->unsetIsKill(); + KillOps[Reg] = NULL; + RegKills.reset(Reg); if (i < TID->numOperands && TID->getOperandConstraint(i, TOI::TIED_TO) == -1) // Unless it's a two-address operand, this is the new kill. MO.setIsKill(); } - if (MO.isKill()) { RegKills.set(Reg); KillOps[Reg] = &MO; @@ -1261,8 +1273,11 @@ NextMII = &MI; --NextMII; // backtrack to the copy. BackTracked = true; -} else +} else { DOUT << "Removing now-noop copy: " << MI; + // Unset last kill since it's being reused. + InvalidateKill(InReg, RegKills, KillOps); +} VRM.RemoveMachineInstrFromMaps(&MI); MBB.erase(&MI); @@ -1298,6 +1313,7 @@ // the value and there isn't an earlier def that has already clobbered the // physreg. if (PhysReg && + !TII->isStoreToStackSlot(&MI, SS) && // Not profitable! DeadStore->findRegisterUseOperandIdx(PhysReg, true) != -1 && MRI->unfoldMemoryOperand(MF, &MI, PhysReg, false, true, NewMIs)) { MBB.insert(MII, NewMIs[0]); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44860 - /llvm/trunk/docs/LangRef.html
On Dec 11, 2007, at 1:31 AM, Christopher Lamb wrote: > Add information on address space qualifiers for pointer types and > global > declarations to the LangRef. Nice! > > > [EMAIL PROTECTED] = constant float 1.0 addrspace(5), section "foo", align 4 Is there a comma after 1.0? -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44858 - in /llvm/trunk: include/llvm/Bitcode/LLVMBitCodes.h include/llvm/DerivedTypes.h include/llvm/GlobalVariable.h include/llvm/Instructions.h lib/AsmParser/LLLexer.cpp l
On Dec 11, 2007, at 12:59 AM, Christopher Lamb wrote: > URL: http://llvm.org/viewvc/llvm-project?rev=44858&view=rev > Log: > Implement address space attribute for LLVM pointer types. Address > spaces are > regions of memory that have a target specific relationship, as > described in the > Embedded C Technical Report. Woohoo!Minor stuff: > +++ llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h Tue Dec 11 > 02:59:05 2007 > @@ -194,9 +194,13 @@ > FUNC_CODE_INST_FREE= 18, // FREE: [opty, op] > FUNC_CODE_INST_ALLOCA = 19, // ALLOCA: [instty, op, > align] > FUNC_CODE_INST_LOAD= 20, // LOAD: [opty, op, > align, vol] > -FUNC_CODE_INST_STORE = 21, // STORE: > [ptrty,val,ptr, align, vol] > +FUNC_CODE_INST_STORE = 21, // STORE: > [valty,val,ptr, align, vol] > FUNC_CODE_INST_CALL= 22, // CALL: [attr, fnty, > fnid, args...] > -FUNC_CODE_INST_VAARG = 23 // VAARG: [valistty, > valist, instty] > +FUNC_CODE_INST_VAARG = 23, // VAARG: [valistty, > valist, instty] > +// This store code encodes the pointer type, rather than the > value type > +// this is so information only available in the pointer type > (e.g. address > +// spaces) is retained. Please add a "FIXME: Remove this in LLVM 3.0" to FUNC_CODE_INST_STORE. > +++ llvm/trunk/include/llvm/DerivedTypes.h Tue Dec 11 02:59:05 2007 > @@ -363,12 +363,17 @@ > /// > class PointerType : public SequentialType { >friend class TypeMap; > + unsigned AddressSpace; > + >PointerType(const PointerType &); // Do not > implement >const PointerType &operator=(const PointerType &); // Do not > implement > - explicit PointerType(const Type *ElType); > + explicit PointerType(const Type *ElType, unsigned AddrSpace); > public: >/// PointerType::get - This is the only way to construct a new > pointer type. > - static PointerType *get(const Type *ElementType); > + static PointerType *get(const Type *ElementType, unsigned > AddressSpace = 0); Making the address space default to zero is convenient, but dangerous. This means that xforms that play with pointers need to be very careful to propagate this info in some cases. Do you think this is the best way to go? Do many clients of PointerType::get need to be aware of addr spaces? > == > > --- llvm/trunk/lib/AsmParser/llvmAsmParser.y (original) > +++ llvm/trunk/lib/AsmParser/llvmAsmParser.y Tue Dec 11 02:59:05 2007 > @@ -1320,6 +1323,13 @@ > delete $1; > CHECK_FOR_ERROR >} > + | Types ADDRSPACE '(' EUINT64VAL ')' '*' { // > Pointer type? > +if (*$1 == Type::LabelTy) > + GEN_ERROR("Cannot form a pointer to a basic block"); > +$$ = new PATypeHolder(HandleUpRefs(PointerType::get(*$1, $4))); > +delete $1; > +CHECK_FOR_ERROR > + } It would probably be better to factor this as an new production: OptAddrSpace ::= ADDRSPACE '(' EUINT64VAL ')' { $$=$3; } OptAddrSpace ::= /*empty*/ { $$ = 0; } Which thing allows you to change the current pointer production to: | Types OptAddrSpace '*' { // Pointer type? if (*$1 == Type::LabelTy) GEN_ERROR("Cannot form a pointer to a basic block"); $$ = new PATypeHolder(HandleUpRefs(PointerType::get(*$1, $2))); delete $1; CHECK_FOR_ERROR This becomes useful later when: > @@ -2073,6 +2083,17 @@ >} GlobalVarAttributes { > CurGV = 0; >} > + | OptGlobalAssign GVVisibilityStyle ThreadLocal GlobalType ConstVal > +ADDRSPACE '(' EUINT64VAL ')' { > +/* "Externally Visible" Linkage with address space qualifier */ > +if ($5 == 0) > + GEN_ERROR("Global value initializer is not a constant"); > +CurGV = ParseGlobalVariable($1, GlobalValue::ExternalLinkage, > +$2, $4, $5->getType(), $5, $3, $8); > +CHECK_FOR_ERROR > + } GlobalVarAttributes { > +CurGV = 0; > + } It would be nice to use the above stuff to avoid duplicating this production. Maybe it would need to be: OptCommaAddrSpace ::= ',' ADDRSPACE '(' EUINT64VAL ')' { $$=$4; } OptCommaAddrSpace ::= /*empty*/ { $$ = 0; } And then just add OptCommaAddrSpace to the existing production. What do you think? Also, should it be possible to place a function in an address space? Does the embedded C spec allow this? > == > > --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) > +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Dec 11 > 02:59:05 2007 > @@ -197,10 +197,14 @@ >TypeVals.push_back(cast(T)->getBitWidth()); >break; > case Type::PointerTyID: > + const PointerType *PTy = cast(T); > + // POINTER: [pointee type] or [pointee type, address space] >Cod
[llvm-commits] [llvm] r44895 - /llvm/trunk/lib/Analysis/IPA/Andersens.cpp
Author: dannyb Date: Tue Dec 11 18:37:04 2007 New Revision: 44895 URL: http://llvm.org/viewvc/llvm-project?rev=44895&view=rev Log: Changes from Curtis Dunham implementing lazy cycle detection algorithm. Changes from me implementing different way of representing points-to anything. Changes from me that improve slightly on LCD. 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=44895&r1=44894&r2=44895&view=diff == --- llvm/trunk/lib/Analysis/IPA/Andersens.cpp (original) +++ llvm/trunk/lib/Analysis/IPA/Andersens.cpp Tue Dec 11 18:37:04 2007 @@ -71,12 +71,20 @@ #include #include #include +#include + +// Determining the actual set of nodes the universal set can consist of is very +// expensive because it means propagating around very large sets. We rely on +// other analysis being able to determine which nodes can never be pointed to in +// order to disambiguate further than "points-to anything". +#define FULL_UNIVERSAL 0 using namespace llvm; STATISTIC(NumIters , "Number of iterations to reach convergence"); STATISTIC(NumConstraints, "Number of constraints"); STATISTIC(NumNodes , "Number of nodes"); STATISTIC(NumUnified, "Number of variables unified"); +STATISTIC(NumErased , "Number of redundant constraints erased"); namespace { const unsigned SelfRep = (unsigned)-1; @@ -157,6 +165,24 @@ } }; +// Information DenseSet requires implemented in order to be able to do +// it's thing +struct PairKeyInfo { + static inline std::pair getEmptyKey() { +return std::make_pair(~0UL, ~0UL); + } + static inline std::pair getTombstoneKey() { +return std::make_pair(~0UL - 1, ~0UL - 1); + } + static unsigned getHashValue(const std::pair &P) { +return P.first ^ P.second; + } + static unsigned isEqual(const std::pair &LHS, + const std::pair &RHS) { +return LHS == RHS; + } +}; + struct ConstraintKeyInfo { static inline Constraint getEmptyKey() { return Constraint(Constraint::Copy, ~0UL, ~0UL, ~0UL); @@ -180,11 +206,14 @@ // artificial Node's that represent the set of pointed-to variables shared // for each location equivalent Node. struct Node { +private: + static unsigned Counter; + +public: Value *Val; SparseBitVector<> *Edges; SparseBitVector<> *PointsTo; SparseBitVector<> *OldPointsTo; - bool Changed; std::list Constraints; // Pointer and location equivalence labels @@ -212,14 +241,17 @@ // standard union-find representation with path compression. NodeRep // gives the index into GraphNodes for the representative Node. unsigned NodeRep; -public: + + // Modification timestamp. Assigned from Counter. + // Used for work list prioritization. + unsigned Timestamp; Node(bool direct = true) : -Val(0), Edges(0), PointsTo(0), OldPointsTo(0), Changed(false), +Val(0), Edges(0), PointsTo(0), OldPointsTo(0), PointerEquivLabel(0), LocationEquivLabel(0), PredEdges(0), ImplicitPredEdges(0), PointedToBy(0), NumInEdges(0), StoredInHash(false), Direct(direct), AddressTaken(false), -NodeRep(SelfRep) { } +NodeRep(SelfRep), Timestamp(0) { } Node *setValue(Value *V) { assert(Val == 0 && "Value already set for this node!"); @@ -246,6 +278,60 @@ /// intersects with the points-to set of the specified node on any nodes /// except for the specified node to ignore. bool intersectsIgnoring(Node *N, unsigned) const; + + // Timestamp a node (used for work list prioritization) + void Stamp() { +Timestamp = Counter++; + } + + bool isRep() { +return( (int) NodeRep < 0 ); + } +}; + +struct WorkListElement { + Node* node; + unsigned Timestamp; + WorkListElement(Node* n, unsigned t) : node(n), Timestamp(t) {} + + // Note that we reverse the sense of the comparison because we + // actually want to give low timestamps the priority over high, + // whereas priority is typically interpreted as a greater value is + // given high priority. + bool operator<(const WorkListElement& that) const { +return( this->Timestamp > that.Timestamp ); + } +}; + +// Priority-queue based work list specialized for Nodes. +class WorkList { + std::priority_queue Q; + +public: + void insert(Node* n) { +Q.push( WorkListElement(n, n->Timestamp) ); + } + + // We automatically discard non-representative nodes and nodes + // that were in the work list twice (we keep a copy of the + // timestamp in the work lis
[llvm-commits] [llvm] r44896 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
Author: evancheng Date: Tue Dec 11 18:51:06 2007 New Revision: 44896 URL: http://llvm.org/viewvc/llvm-project?rev=44896&view=rev Log: Bug fix. Only safe to perform extension uses optimization if the source of extension is also defined in the same BB as the extension. Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=44896&r1=44895&r2=44896&view=diff == --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Tue Dec 11 18:51:06 2007 @@ -929,6 +929,11 @@ if (Src->hasOneUse()) return false; + // Only safe to perform the optimization if the source is also defined in + // this block. + if (DefBB != cast(Src)->getParent()) +return false; + bool DefIsLiveOut = false; for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E; ++UI) { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44899 - in /llvm/trunk: bindings/ocaml/llvm/llvm.ml bindings/ocaml/llvm/llvm.mli bindings/ocaml/llvm/llvm_ocaml.c include/llvm-c/BitReader.h include/llvm-c/Core.h lib/VMCore/Cor
Author: gordon Date: Tue Dec 11 19:04:30 2007 New Revision: 44899 URL: http://llvm.org/viewvc/llvm-project?rev=44899&view=rev Log: Add (very basic) bindings for ModuleProvider. Modified: llvm/trunk/bindings/ocaml/llvm/llvm.ml llvm/trunk/bindings/ocaml/llvm/llvm.mli llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c llvm/trunk/include/llvm-c/BitReader.h llvm/trunk/include/llvm-c/Core.h llvm/trunk/lib/VMCore/Core.cpp llvm/trunk/test/Bindings/Ocaml/vmcore.ml Modified: llvm/trunk/bindings/ocaml/llvm/llvm.ml URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.ml?rev=44899&r1=44898&r2=44899&view=diff == --- llvm/trunk/bindings/ocaml/llvm/llvm.ml (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm.ml Tue Dec 11 19:04:30 2007 @@ -14,6 +14,7 @@ type llvalue type llbasicblock type llbuilder +type llmoduleprovider type type_kind = Void_type @@ -427,6 +428,13 @@ llbuilder -> llvalue = "llvm_build_shufflevector" +(*===-- Module providers --===*) +external create_module_provider : llmodule -> llmoduleprovider += "LLVMCreateModuleProviderForExistingModule" +external dispose_module_provider : llmoduleprovider -> unit + = "llvm_dispose_module_provider" + + (*===-- Non-Externs ---===*) (* These functions are built using the externals, so must be declared late. *) Modified: llvm/trunk/bindings/ocaml/llvm/llvm.mli URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.mli?rev=44899&r1=44898&r2=44899&view=diff == --- llvm/trunk/bindings/ocaml/llvm/llvm.mli (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm.mli Tue Dec 11 19:04:30 2007 @@ -40,6 +40,9 @@ class. **) type llbuilder +(** Used to provide a module to JIT or interpreter. **) +type llmoduleprovider + (** The kind of an [lltype], the result of [classify_type ty]. See the [llvm::Type::TypeID] enumeration. **) type type_kind = @@ -1217,3 +1220,17 @@ See the method [llvm::LLVMBuilder::CreateShuffleVector]. **) external build_shufflevector : llvalue -> llvalue -> llvalue -> string -> llbuilder -> llvalue = "llvm_build_shufflevector" + + +(*===-- Module providers --===*) + +(** [create_module_provider m] encapsulates [m] in a module provider and takes +ownership of the module. See the constructor +[llvm::ExistingModuleProvider::ExistingModuleProvider]. **) +external create_module_provider : llmodule -> llmoduleprovider += "LLVMCreateModuleProviderForExistingModule" + +(** [dispose_module_provider mp] destroys the module provider [mp] as well as +the contained module. **) +external dispose_module_provider : llmoduleprovider -> unit + = "llvm_dispose_module_provider" Modified: llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c?rev=44899&r1=44898&r2=44899&view=diff == --- llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c Tue Dec 11 19:04:30 2007 @@ -1047,3 +1047,11 @@ return LLVMBuildShuffleVector(Builder_val(B), V1, V2, Mask, String_val(Name)); } + +/*===-- Module Providers --===*/ + +/* llmoduleprovider -> unit */ +CAMLprim value llvm_dispose_module_provider(LLVMModuleProviderRef MP) { + LLVMDisposeModuleProvider(MP); + return Val_unit; +} Modified: llvm/trunk/include/llvm-c/BitReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/BitReader.h?rev=44899&r1=44898&r2=44899&view=diff == --- llvm/trunk/include/llvm-c/BitReader.h (original) +++ llvm/trunk/include/llvm-c/BitReader.h Tue Dec 11 19:04:30 2007 @@ -32,6 +32,13 @@ int LLVMReadBitcodeFromFile(const char *Path, LLVMModuleRef *OutModule, char **OutMessage); +/* Reads a module from the specified path, returning a reference to a lazy + module provider via the OutModule parameter. Returns 0 on success. Optionally + returns a human-readable error message. */ +int LLVMCreateModuleProviderFromFile(const char *Path, + LLVMModuleProviderRef *OutMP, + char **OutMessage); + /* Disposes of the message allocated by the bitcode reader, if any. */ void LLVMDisposeBitcodeReaderMessage(char *Message); Modified: llvm/trunk/include/llvm-c/Core.h URL:
[llvm-commits] [llvm] r44902 - /llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
Author: resistor Date: Tue Dec 11 19:25:08 2007 New Revision: 44902 URL: http://llvm.org/viewvc/llvm-project?rev=44902&view=rev Log: Forgot to remove a register from the PHI-union after I'd determined that it interfered with other registers. Seems like that might be a good thing to do. :-) Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp?rev=44902&r1=44901&r2=44902&view=diff == --- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original) +++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Tue Dec 11 19:25:08 2007 @@ -357,10 +357,11 @@ // Insert copies for child for (int i = Inst->getNumOperands() - 1; i >= 2; i-=2) { if (Inst->getOperand(i-1).getReg() == child->getReg()) { -unsigned SrcReg = Inst->getOperand(i-1).getReg(); +unsigned SrcReg = child->getReg(); MachineBasicBlock* From = Inst->getOperand(i).getMBB(); Waiting[From].push_back(std::make_pair(SrcReg, DestReg)); +PHIUnion.erase(SrcReg); } } @@ -369,10 +370,11 @@ // Insert copies for parent for (int i = Inst->getNumOperands() - 1; i >= 2; i-=2) { if (Inst->getOperand(i-1).getReg() == DFNode->getReg()) { -unsigned SrcReg = Inst->getOperand(i-1).getReg(); +unsigned SrcReg = DFNode->getReg(); MachineBasicBlock* From = Inst->getOperand(i).getMBB(); Waiting[From].push_back(std::make_pair(SrcReg, DestReg)); +PHIUnion.erase(SrcReg); } } } @@ -380,10 +382,11 @@ // Insert copies for parent for (int i = Inst->getNumOperands() - 1; i >= 2; i-=2) { if (Inst->getOperand(i-1).getReg() == DFNode->getReg()) { - unsigned SrcReg = Inst->getOperand(i-1).getReg(); + unsigned SrcReg = DFNode->getReg(); MachineBasicBlock* From = Inst->getOperand(i).getMBB(); Waiting[From].push_back(std::make_pair(SrcReg, DestReg)); + PHIUnion.erase(SrcReg); } } } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44903 - /llvm/trunk/include/llvm/Target/TargetInstrInfo.h
Author: void Date: Tue Dec 11 19:51:58 2007 New Revision: 44903 URL: http://llvm.org/viewvc/llvm-project?rev=44903&view=rev Log: Bit masks conflicted. Needed to bump them by one. Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=44903&r1=44902&r2=44903&view=diff == --- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Tue Dec 11 19:51:58 2007 @@ -54,42 +54,42 @@ // changed into a 3-address instruction if the first two operands cannot be // assigned to the same register. The target must implement the // TargetInstrInfo::convertToThreeAddress method for this instruction. -const unsigned M_CONVERTIBLE_TO_3_ADDR = 1 << 7; +const unsigned M_CONVERTIBLE_TO_3_ADDR = 1 << 8; // This M_COMMUTABLE - is a 2- or 3-address instruction (of the form X = op Y, // Z), which produces the same result if Y and Z are exchanged. -const unsigned M_COMMUTABLE= 1 << 8; +const unsigned M_COMMUTABLE= 1 << 9; // M_TERMINATOR_FLAG - Is this instruction part of the terminator for a basic // block? Typically this is things like return and branch instructions. // Various passes use this to insert code into the bottom of a basic block, but // before control flow occurs. -const unsigned M_TERMINATOR_FLAG = 1 << 9; +const unsigned M_TERMINATOR_FLAG = 1 << 10; // M_USES_CUSTOM_DAG_SCHED_INSERTION - Set if this instruction requires custom // insertion support when the DAG scheduler is inserting it into a machine basic // block. -const unsigned M_USES_CUSTOM_DAG_SCHED_INSERTION = 1 << 10; +const unsigned M_USES_CUSTOM_DAG_SCHED_INSERTION = 1 << 11; // M_VARIABLE_OPS - Set if this instruction can have a variable number of extra // operands in addition to the minimum number operands specified. -const unsigned M_VARIABLE_OPS = 1 << 11; +const unsigned M_VARIABLE_OPS = 1 << 12; // M_PREDICABLE - Set if this instruction has a predicate operand that // controls execution. It may be set to 'always'. -const unsigned M_PREDICABLE = 1 << 12; +const unsigned M_PREDICABLE= 1 << 13; // M_REMATERIALIZIBLE - Set if this instruction can be trivally re-materialized // at any time, e.g. constant generation, load from constant pool. -const unsigned M_REMATERIALIZIBLE = 1 << 13; +const unsigned M_REMATERIALIZIBLE = 1 << 14; // M_NOT_DUPLICABLE - Set if this instruction cannot be safely duplicated. // (e.g. instructions with unique labels attached). -const unsigned M_NOT_DUPLICABLE = 1 << 14; +const unsigned M_NOT_DUPLICABLE= 1 << 15; // M_HAS_OPTIONAL_DEF - Set if this instruction has an optional definition, e.g. // ARM instructions which can set condition code if 's' bit is set. -const unsigned M_HAS_OPTIONAL_DEF = 1 << 15; +const unsigned M_HAS_OPTIONAL_DEF = 1 << 16; // Machine operand flags // M_LOOK_UP_PTR_REG_CLASS - Set if this operand is a pointer value and it ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44860 - /llvm/trunk/docs/LangRef.html
On Dec 11, 2007, at 3:54 PM, Chris Lattner wrote: On Dec 11, 2007, at 1:31 AM, Christopher Lamb wrote: Add information on address space qualifiers for pointer types and global declarations to the LangRef. Nice! [EMAIL PROTECTED] = constant float 1.0 addrspace(5), section "foo", align 4 Is there a comma after 1.0? Nope. It's not treated like other attributes as it affects the type of the GlobalVariable that's created, rather than modifying it after the fact. Ideally I would have liked it to be between the type name and the initializer value, but the current Assembly parser made this very yucky. The other option would be to support the addrspace attribute on types other than pointers in the Assembly syntax, but discard them in all cases except when declaring a global variable, also yucky. The key here is that the order of asterisks and addrspace() qualifiers are consistent in the global variable declaration and the type name: @foo = constant float addrspace(1)* 1.0 addrspace(2) @foo has a type of float addrspace(1)* addrspace(2)* -- Christopher Lamb ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44858 - in /llvm/trunk: include/llvm/Bitcode/LLVMBitCodes.h include/llvm/DerivedTypes.h include/llvm/GlobalVariable.h include/llvm/Instructions.h lib/AsmParser/LLLexer.cpp l
On Dec 11, 2007, at 4:12 PM, Chris Lattner wrote: On Dec 11, 2007, at 12:59 AM, Christopher Lamb wrote: URL: http://llvm.org/viewvc/llvm-project?rev=44858&view=rev Log: Implement address space attribute for LLVM pointer types. Address spaces are regions of memory that have a target specific relationship, as described in the Embedded C Technical Report. Woohoo!Minor stuff: +++ llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h Tue Dec 11 02:59:05 2007 @@ -194,9 +194,13 @@ FUNC_CODE_INST_FREE= 18, // FREE: [opty, op] FUNC_CODE_INST_ALLOCA = 19, // ALLOCA: [instty, op, align] FUNC_CODE_INST_LOAD= 20, // LOAD: [opty, op, align, vol] -FUNC_CODE_INST_STORE = 21, // STORE: [ptrty,val,ptr, align, vol] +FUNC_CODE_INST_STORE = 21, // STORE: [valty,val,ptr, align, vol] FUNC_CODE_INST_CALL= 22, // CALL: [attr, fnty, fnid, args...] -FUNC_CODE_INST_VAARG = 23 // VAARG: [valistty, valist, instty] +FUNC_CODE_INST_VAARG = 23, // VAARG: [valistty, valist, instty] +// This store code encodes the pointer type, rather than the value type +// this is so information only available in the pointer type (e.g. address +// spaces) is retained. Please add a "FIXME: Remove this in LLVM 3.0" to FUNC_CODE_INST_STORE. Ok. +++ llvm/trunk/include/llvm/DerivedTypes.h Tue Dec 11 02:59:05 2007 @@ -363,12 +363,17 @@ /// class PointerType : public SequentialType { friend class TypeMap; + unsigned AddressSpace; + PointerType(const PointerType &); // Do not implement const PointerType &operator=(const PointerType &); // Do not implement - explicit PointerType(const Type *ElType); + explicit PointerType(const Type *ElType, unsigned AddrSpace); public: /// PointerType::get - This is the only way to construct a new pointer type. - static PointerType *get(const Type *ElementType); + static PointerType *get(const Type *ElementType, unsigned AddressSpace = 0); Making the address space default to zero is convenient, but dangerous. This means that xforms that play with pointers need to be very careful to propagate this info in some cases. This is true. Do you think this is the best way to go? As opposed to no default value, forcing clients to propagate this information? Do many clients of PointerType::get need to be aware of addr spaces? Many do. Unfortunately it seems common to simply pass a value's type around and synthesize a pointer when needed. The addition of address spaces means that this approach is no longer equivalent to passing the pointer type, and I expect there will be fixes needed to once a back end depends on this feature. = = --- llvm/trunk/lib/AsmParser/llvmAsmParser.y (original) +++ llvm/trunk/lib/AsmParser/llvmAsmParser.y Tue Dec 11 02:59:05 2007 @@ -1320,6 +1323,13 @@ delete $1; CHECK_FOR_ERROR } + | Types ADDRSPACE '(' EUINT64VAL ')' '*' { // Pointer type? +if (*$1 == Type::LabelTy) + GEN_ERROR("Cannot form a pointer to a basic block"); +$$ = new PATypeHolder(HandleUpRefs(PointerType::get(*$1, $4))); +delete $1; +CHECK_FOR_ERROR + } It would probably be better to factor this as an new production: OptAddrSpace ::= ADDRSPACE '(' EUINT64VAL ')' { $$=$3; } OptAddrSpace ::= /*empty*/ { $$ = 0; } Which thing allows you to change the current pointer production to: | Types OptAddrSpace '*' { // Pointer type? if (*$1 == Type::LabelTy) GEN_ERROR("Cannot form a pointer to a basic block"); $$ = new PATypeHolder(HandleUpRefs(PointerType::get(*$1, $2))); delete $1; CHECK_FOR_ERROR This becomes useful later when: @@ -2073,6 +2083,17 @@ } GlobalVarAttributes { CurGV = 0; } + | OptGlobalAssign GVVisibilityStyle ThreadLocal GlobalType ConstVal +ADDRSPACE '(' EUINT64VAL ')' { +/* "Externally Visible" Linkage with address space qualifier */ +if ($5 == 0) + GEN_ERROR("Global value initializer is not a constant"); +CurGV = ParseGlobalVariable($1, GlobalValue::ExternalLinkage, +$2, $4, $5->getType(), $5, $3, $8); +CHECK_FOR_ERROR + } GlobalVarAttributes { +CurGV = 0; + } It would be nice to use the above stuff to avoid duplicating this production. Maybe it would need to be: OptCommaAddrSpace ::= ',' ADDRSPACE '(' EUINT64VAL ')' { $$=$4; } OptCommaAddrSpace ::= /*empty*/ { $$ = 0; } And then just add OptCommaAddrSpace to the existing production. What do you think? Avoiding the duplicate production is good, but I'm not sure about the comma. The addrspace() qualifier can not be positionally permuted with other attributes, the comma gives the impression that it can be. Also, should it be possible to place a function in an address space? Does the embedded C spec allow
[llvm-commits] [llvm] r44905 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
Author: evancheng Date: Tue Dec 11 20:53:41 2007 New Revision: 44905 URL: http://llvm.org/viewvc/llvm-project?rev=44905&view=rev Log: Don't muck with phi nodes; bug fixes. Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=44905&r1=44904&r2=44905&view=diff == --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Tue Dec 11 20:53:41 2007 @@ -930,8 +930,8 @@ return false; // Only safe to perform the optimization if the source is also defined in - // this block. - if (DefBB != cast(Src)->getParent()) + // this block. + if (!isa(Src) || DefBB != cast(Src)->getParent()) return false; bool DefIsLiveOut = false; @@ -948,6 +948,15 @@ if (!DefIsLiveOut) return false; + // Make sure non of the uses are PHI nodes. + for (Value::use_iterator UI = Src->use_begin(), E = Src->use_end(); + UI != E; ++UI) { +Instruction *User = cast(*UI); +if (User->getParent() == DefBB) continue; +if (isa(User)) + return false; + } + // InsertedTruncs - Only insert one trunc in each block once. DenseMap InsertedTruncs; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44904 - /llvm/trunk/lib/Target/X86/X86JITInfo.cpp
Author: pingbak Date: Tue Dec 11 20:38:28 2007 New Revision: 44904 URL: http://llvm.org/viewvc/llvm-project?rev=44904&view=rev Log: Correct typo for Linux: s/esp/%rsp/ Modified: llvm/trunk/lib/Target/X86/X86JITInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86JITInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86JITInfo.cpp?rev=44904&r1=44903&r2=44904&view=diff == --- llvm/trunk/lib/Target/X86/X86JITInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86JITInfo.cpp Tue Dec 11 20:38:28 2007 @@ -116,7 +116,7 @@ "movaps (%rsp), %xmm0\n" // Restore RSP "movq%rbp, %rsp\n" -CFI(".cfi_def_cfa_register esp\n") +CFI(".cfi_def_cfa_register %rsp\n") // Restore all int arg registers "subq$48, %rsp\n" CFI(".cfi_adjust_cfa_offset 48\n") ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44907 - /llvm/trunk/lib/Analysis/ConstantFolding.cpp
Author: lattner Date: Tue Dec 11 21:56:54 2007 New Revision: 44907 URL: http://llvm.org/viewvc/llvm-project?rev=44907&view=rev Log: Fix a bug in my previous patch, thanks to Jay Foad for pointing this out and correcting the patch! Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=44907&r1=44906&r2=44907&view=diff == --- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original) +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Tue Dec 11 21:56:54 2007 @@ -427,10 +427,10 @@ // there is a truncation or extension that we aren't modeling. if ((CE0->getOpcode() == Instruction::IntToPtr && CE0->getOperand(0)->getType() == IntPtrTy && - CE0->getOperand(1)->getType() == IntPtrTy) || + Ops[1]->getOperand(0)->getType() == IntPtrTy) || (CE0->getOpcode() == Instruction::PtrToInt && CE0->getType() == IntPtrTy && - CE0->getOperand(0)->getType() == CE0->getOperand(1)->getType())) { + CE0->getOperand(0)->getType() == Ops[1]->getOperand(0)->getType())) { Constant *NewOps[] = { CE0->getOperand(0), cast(Ops[1])->getOperand(0) }; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44905 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
On Dec 11, 2007, at 6:53 PM, Evan Cheng wrote: > Author: evancheng > Date: Tue Dec 11 20:53:41 2007 > New Revision: 44905 > > URL: http://llvm.org/viewvc/llvm-project?rev=44905&view=rev > Log: > Don't muck with phi nodes; bug fixes. Hey Evan, testcase please :) -Chris > > Modified: >llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp > > Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=44905&r1=44904&r2=44905&view=diff > > = > = > = > = > = > = > = > = > == > --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Tue Dec 11 > 20:53:41 2007 > @@ -930,8 +930,8 @@ > return false; > > // Only safe to perform the optimization if the source is also > defined in > - // this block. > - if (DefBB != cast(Src)->getParent()) > + // this block. > + if (!isa(Src) || DefBB != cast(Src)- > >getParent()) > return false; > > bool DefIsLiveOut = false; > @@ -948,6 +948,15 @@ > if (!DefIsLiveOut) > return false; > > + // Make sure non of the uses are PHI nodes. > + for (Value::use_iterator UI = Src->use_begin(), E = Src->use_end(); > + UI != E; ++UI) { > +Instruction *User = cast(*UI); > +if (User->getParent() == DefBB) continue; > +if (isa(User)) > + return false; > + } > + > // InsertedTruncs - Only insert one trunc in each block once. > DenseMap InsertedTruncs; > > > > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44860 - /llvm/trunk/docs/LangRef.html
On Dec 11, 2007, at 5:56 PM, Christopher Lamb wrote: > > On Dec 11, 2007, at 3:54 PM, Chris Lattner wrote: > >> On Dec 11, 2007, at 1:31 AM, Christopher Lamb wrote: >>> Add information on address space qualifiers for pointer types and >>> global >>> declarations to the LangRef. >> >> Nice! >> >>> >>> >>> [EMAIL PROTECTED] = constant float 1.0 addrspace(5), section "foo", align 4 >> >> Is there a comma after 1.0? > > Nope. It's not treated like other attributes as it affects the type > of the GlobalVariable that's created, rather than modifying it after > the fact. Ideally I would have liked it to be between the type name > and the initializer value, but the current Assembly parser made this > very yucky. The other option would be to support the addrspace > attribute on types other than pointers in the Assembly syntax, but > discard them in all cases except when declaring a global variable, > also yucky. > > The key here is that the order of asterisks and addrspace() > qualifiers are consistent in the global variable declaration and the > type name: > > @foo = constant float addrspace(1)* 1.0 addrspace(2) > > @foo has a type of > > float addrspace(1)* addrspace(2)* That is a very strong argument to me, but it seems to argue even more strongly for: @G = constant float addrspace(5) 1.0, section "foo", align 4 Your example above would then be: > @foo = constant float addrspace(1)* addrspace(2) 1.0 which has type: > float addrspace(1)* addrspace(2)* What do you think? the downside is that this may cause bison to have issues :) -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44860 - /llvm/trunk/docs/LangRef.html
On Dec 11, 2007, at 8:34 PM, Chris Lattner wrote: On Dec 11, 2007, at 5:56 PM, Christopher Lamb wrote: On Dec 11, 2007, at 3:54 PM, Chris Lattner wrote: On Dec 11, 2007, at 1:31 AM, Christopher Lamb wrote: Add information on address space qualifiers for pointer types and global declarations to the LangRef. Nice! [EMAIL PROTECTED] = constant float 1.0 addrspace(5), section "foo", align 4 Is there a comma after 1.0? Nope. It's not treated like other attributes as it affects the type of the GlobalVariable that's created, rather than modifying it after the fact. Ideally I would have liked it to be between the type name and the initializer value, but the current Assembly parser made this very yucky. The other option would be to support the addrspace attribute on types other than pointers in the Assembly syntax, but discard them in all cases except when declaring a global variable, also yucky. The key here is that the order of asterisks and addrspace() qualifiers are consistent in the global variable declaration and the type name: @foo = constant float addrspace(1)* 1.0 addrspace(2) @foo has a type of float addrspace(1)* addrspace(2)* That is a very strong argument to me, but it seems to argue even more strongly for: @G = constant float addrspace(5) 1.0, section "foo", align 4 Your example above would then be: @foo = constant float addrspace(1)* addrspace(2) 1.0 which has type: float addrspace(1)* addrspace(2)* What do you think? the downside is that this may cause bison to have issues :) This is ideally what I wanted, but it would mean seriously mucking with bison and changing how all CosntVal's are handled. I can give it a try. -- Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44860 - /llvm/trunk/docs/LangRef.html
>> That is a very strong argument to me, but it seems to argue even more >> strongly for: >> >> @G = constant float addrspace(5) 1.0, section "foo", align 4 >> >> Your example above would then be: >> >>> @foo = constant float addrspace(1)* addrspace(2) 1.0 >> >> which has type: >> >>> float addrspace(1)* addrspace(2)* >> >> What do you think? the downside is that this may cause bison to have >> issues :) > > This is ideally what I wanted, but it would mean seriously mucking > with bison and changing how all CosntVal's are handled. I can give > it a try. Hrm, I think bison will get extremely grumpy about this. Quick question, what is the syntax for an external GV with an ASI? -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44910 - in /llvm/trunk: lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp test/ExecutionEngine/2007-12-11-APIntExFuncCall.ll
Author: sheng Date: Tue Dec 11 22:55:43 2007 New Revision: 44910 URL: http://llvm.org/viewvc/llvm-project?rev=44910&view=rev Log: Fixed PR1629. Make lli interpreter correctly call external functions sin()/cos(), __cxa_guard_acquire() and __cxa_guard_release(). Added: llvm/trunk/test/ExecutionEngine/2007-12-11-APIntExFuncCall.ll Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp?rev=44910&r1=44909&r2=44910&view=diff == --- llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Tue Dec 11 22:55:43 2007 @@ -29,6 +29,7 @@ #include #include #include +#include using std::vector; using namespace llvm; @@ -200,6 +201,22 @@ return GV; } +// double sin(double) +GenericValue lle_X_sin(FunctionType *FT, const vector &Args) { + assert(Args.size() == 1); + GenericValue GV; + GV.DoubleVal = sin(Args[0].DoubleVal); + return GV; +} + +// double cos(double) +GenericValue lle_X_cos(FunctionType *FT, const vector &Args) { + assert(Args.size() == 1); + GenericValue GV; + GV.DoubleVal = cos(Args[0].DoubleVal); + return GV; +} + // double exp(double) GenericValue lle_X_exp(FunctionType *FT, const vector &Args) { assert(Args.size() == 1); @@ -705,6 +722,24 @@ return GV; } +// int __cxa_guard_acquire (__guard *g); +GenericValue lle_X___cxa_guard_acquire(FunctionType *FT, + const vector &Args) { + assert(Args.size() == 1); + GenericValue GV; + GV.IntVal = APInt(32, __cxxabiv1::__cxa_guard_acquire ( + (__cxxabiv1::__guard*)GVTOP(Args[0]))); + return GV; +} + +// void __cxa_guard_release (__guard *g); +GenericValue lle_X___cxa_guard_release(FunctionType *FT, + const vector &Args) { + assert(Args.size() == 1); + __cxxabiv1::__cxa_guard_release ((__cxxabiv1::__guard*)GVTOP(Args[0])); + return GenericValue(); +} + } // End extern "C" @@ -719,6 +754,8 @@ FuncNames["lle_X_free"] = lle_X_free; FuncNames["lle_X_atoi"] = lle_X_atoi; FuncNames["lle_X_pow"] = lle_X_pow; + FuncNames["lle_X_sin"] = lle_X_sin; + FuncNames["lle_X_cos"] = lle_X_cos; FuncNames["lle_X_exp"] = lle_X_exp; FuncNames["lle_X_log"] = lle_X_log; FuncNames["lle_X_floor"]= lle_X_floor; @@ -759,5 +796,8 @@ FuncNames["lle_X_ungetc"] = lle_X_ungetc; FuncNames["lle_X_fprintf"] = lle_X_fprintf; FuncNames["lle_X_freopen"] = lle_X_freopen; + + FuncNames["lle_X___cxa_guard_acquire"] = lle_X___cxa_guard_acquire; + FuncNames["lle_Xcxa_guard_release"] = lle_X___cxa_guard_release; } Added: llvm/trunk/test/ExecutionEngine/2007-12-11-APIntExFuncCall.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ExecutionEngine/2007-12-11-APIntExFuncCall.ll?rev=44910&view=auto == --- llvm/trunk/test/ExecutionEngine/2007-12-11-APIntExFuncCall.ll (added) +++ llvm/trunk/test/ExecutionEngine/2007-12-11-APIntExFuncCall.ll Tue Dec 11 22:55:43 2007 @@ -0,0 +1,54 @@ +; RUN: llvm-as < %s -o - | lli -force-interpreter +; PR1629 + +; ModuleID = '' +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 = "i686-pc-linux-gnu" + %struct.X = type { i32 } [EMAIL PROTECTED] = internal global i64 0, align 8 ; [#uses=3] [EMAIL PROTECTED] = internal global %struct.X zeroinitializer ; <%struct.X*> [#uses=1] + +define i32 @main() nounwind { +entry: + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + %tmp2 = call double @sin( double 1.999000e+00 ) nounwind readonly ; [#uses=1] + %tmp3 = call double @cos( double 1.99e+00 ) nounwind readonly ; [#uses=1] + %tmp4 = add double %tmp2, %tmp3 ; [#uses=1] + %tmp5 = load i8* bitcast (i64* @_ZGVZ4mainE1a to i8*), align 1 ; [#uses=1] + %tmp6 = icmp eq i8 %tmp5, 0 ; [#uses=1] + %tmp67 = zext i1 %tmp6 to i8; [#uses=1] + %toBool = icmp ne i8 %tmp67, 0 ; [#uses=1] + br i1 %toBool, label %cond_true, label %cond_next14 + +cond_true: ; preds = %entry + %tmp8 = call i32 @__cxa_guard_acquire( i64* @_ZGVZ4mainE1a ) nounwind ; [#uses=1] + %tmp9 = icmp ne i32 %tmp8, 0; [#uses=1] + %tmp910 = zext i1 %tmp9 to i8 ; [#uses=1] + %toBool12 = icmp ne i8 %tmp910, 0 ; [#uses=1] + br i1 %toBool12
Re: [llvm-commits] [llvm] r44910 - in /llvm/trunk: lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp test/ExecutionEngine/2007-12-11-APIntExFuncCall.ll
> URL: http://llvm.org/viewvc/llvm-project?rev=44910&view=rev > Log: > Fixed PR1629. > Make lli interpreter correctly call external functions sin()/cos(), > __cxa_guard_acquire() and __cxa_guard_release(). > #include > +#include > using std::vector; hi Sheng, What provides this non-standard header? I don't know for sure, but I bet you just made our win32 friends very unhappy. -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44858 - in /llvm/trunk: include/llvm/Bitcode/LLVMBitCodes.h include/llvm/DerivedTypes.h include/llvm/GlobalVariable.h include/llvm/Instructions.h lib/AsmParser/LLLexer.cpp l
>> Making the address space default to zero is convenient, but >> dangerous. This means that xforms that play with pointers need to be >> very careful to propagate this info in some cases. > > This is true. > >> Do you think this is the best way to go? > > As opposed to no default value, forcing clients to propagate this > information? Yep. >> Do many clients of PointerType::get need to be aware of addr spaces? > > Many do. Unfortunately it seems common to simply pass a value's type > around and synthesize a pointer when needed. The addition of address > spaces means that this approach is no longer equivalent to passing > the pointer type, and I expect there will be fixes needed to once a > back end depends on this feature. I think I'd really rather have people have to provide it so that people cons'ing up pointers have to think about alternate address spaces and that all existing code gets updated. This makes it much less likely that alternate address spaces are a second class feature that is just too buggy to rely on. >> It would be nice to use the above stuff to avoid duplicating this >> production. Maybe it would need to be: >> >> OptCommaAddrSpace ::= ',' ADDRSPACE '(' EUINT64VAL ')' { $$=$4; } >> OptCommaAddrSpace ::= /*empty*/ { $$ = 0; } >> >> And then just add OptCommaAddrSpace to the existing production. What >> do you think? > > Avoiding the duplicate production is good, but I'm not sure about > the comma. The addrspace() qualifier can not be positionally > permuted with other attributes, the comma gives the impression that > it can be. Good point, but I don't think lack of comma really makes it clear either... -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44858 - in /llvm/trunk: include/llvm/Bitcode/LLVMBitCodes.h include/llvm/DerivedTypes.h include/llvm/GlobalVariable.h include/llvm/Instructions.h lib/AsmParser/LLLexer.cpp l
On Dec 11, 2007, at 8:36 PM, Chris Lattner wrote: Making the address space default to zero is convenient, but dangerous. This means that xforms that play with pointers need to be very careful to propagate this info in some cases. This is true. Do you think this is the best way to go? As opposed to no default value, forcing clients to propagate this information? Yep. Do many clients of PointerType::get need to be aware of addr spaces? Many do. Unfortunately it seems common to simply pass a value's type around and synthesize a pointer when needed. The addition of address spaces means that this approach is no longer equivalent to passing the pointer type, and I expect there will be fixes needed to once a back end depends on this feature. I think I'd really rather have people have to provide it so that people cons'ing up pointers have to think about alternate address spaces and that all existing code gets updated. This makes it much less likely that alternate address spaces are a second class feature that is just too buggy to rely on. First class it is, sir. It would be nice to use the above stuff to avoid duplicating this production. Maybe it would need to be: OptCommaAddrSpace ::= ',' ADDRSPACE '(' EUINT64VAL ')' { $$=$4; } OptCommaAddrSpace ::= /*empty*/ { $$ = 0; } And then just add OptCommaAddrSpace to the existing production. What do you think? Avoiding the duplicate production is good, but I'm not sure about the comma. The addrspace() qualifier can not be positionally permuted with other attributes, the comma gives the impression that it can be. Good point, but I don't think lack of comma really makes it clear either... I agree. No compromises. I will improve my bison-fu. -- Christopher Lamb ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44860 - /llvm/trunk/docs/LangRef.html
On Dec 11, 2007, at 9:08 PM, Christopher Lamb wrote: > > On Dec 11, 2007, at 8:50 PM, Chris Lattner wrote: > That is a very strong argument to me, but it seems to argue even more strongly for: @G = constant float addrspace(5) 1.0, section "foo", align 4 Your example above would then be: > @foo = constant float addrspace(1)* addrspace(2) 1.0 which has type: > float addrspace(1)* addrspace(2)* What do you think? the downside is that this may cause bison to have issues :) >>> >>> This is ideally what I wanted, but it would mean seriously mucking >>> with bison and changing how all CosntVal's are handled. I can give >>> it a try. >> >> Hrm, I think bison will get extremely grumpy about this. > > I feared. > >> Quick question, what is the syntax for an external GV with an ASI? > > > Sticky wicket, that. It should be: > > @foo = external global i32 addrspace(1) > > But that's not working right now Right, because it would require the same parsing logic as the proposal above :). How horrible would: > @foo = addrspace(1) external global i32 be? -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44858 - in /llvm/trunk: include/llvm/Bitcode/LLVMBitCodes.h include/llvm/DerivedTypes.h include/llvm/GlobalVariable.h include/llvm/Instructions.h lib/AsmParser/LLLexer.cpp l
On Dec 11, 2007, at 9:16 PM, Christopher Lamb wrote: > > On Dec 11, 2007, at 4:12 PM, Chris Lattner wrote: > >> On Dec 11, 2007, at 12:59 AM, Christopher Lamb wrote: >> >>> = >>> = >>> >>> >>> --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) >>> +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Dec 11 >>> 02:59:05 2007 >>> @@ -197,10 +197,14 @@ >>>TypeVals.push_back(cast(T)->getBitWidth()); >>>break; >>> case Type::PointerTyID: >>> + const PointerType *PTy = cast(T); >>> + // POINTER: [pointee type] or [pointee type, address space] >>>Code = bitc::TYPE_CODE_POINTER; >>> + TypeVals.push_back(VE.getTypeID(PTy->getElementType())); >>> + if (unsigned AddressSpace = PTy->getAddressSpace()) >>> +TypeVals.push_back(AddressSpace); >>> + else >>> +AbbrevToUse = PtrAbbrev; >>>break; >> >> This can be simplified. In this code, I'd just unconditionally >> emit it: >> >>> case Type::PointerTyID: >>> + const PointerType *PTy = cast(T); >>> + // POINTER: [pointee type] or [pointee type, address space] >>>Code = bitc::TYPE_CODE_POINTER; >>> + TypeVals.push_back(VE.getTypeID(PTy->getElementType())); >>>TypeVals.push_back(PTy->getAddressSpace()); >>>AbbrevToUse = PtrAbbrev; >>>break; >> >> And change the abbreviation to match, which would apply only if the >> addrspace is zero (and thus not encode it at all): >> >>// Abbrev for TYPE_CODE_POINTER. >>BitCodeAbbrev *Abbv = new BitCodeAbbrev(); >>Abbv->Add(BitCodeAbbrevOp(bitc::TYPE_CODE_POINTER)); >>Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, >> Log2_32_Ceil(VE.getTypes().size()+1))); >>Abbv->Add(BitCodeAbbrevOp(0)); // Addr space = 0. >>unsigned PtrAbbrev = Stream.EmitAbbrev(Abbv); >> >> The presence of the abbreviation means that any pointers with >> addrspace 0 will not need per-instance space to represent this. > > This means moving the assert conditional into the if conditional and > removing the assert in BitstreamWriter.h. Sound OK? Ah, right, sorry I misremembered. In that case, make the PointerTyID handling code do something like: if (Addrspace == 0) AbbrevToUse = PtrAbbrev; Thanks! -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44860 - /llvm/trunk/docs/LangRef.html
On Dec 11, 2007, at 8:50 PM, Chris Lattner wrote: That is a very strong argument to me, but it seems to argue even more strongly for: @G = constant float addrspace(5) 1.0, section "foo", align 4 Your example above would then be: @foo = constant float addrspace(1)* addrspace(2) 1.0 which has type: float addrspace(1)* addrspace(2)* What do you think? the downside is that this may cause bison to have issues :) This is ideally what I wanted, but it would mean seriously mucking with bison and changing how all CosntVal's are handled. I can give it a try. Hrm, I think bison will get extremely grumpy about this. I feared. Quick question, what is the syntax for an external GV with an ASI? Sticky wicket, that. It should be: @foo = external global i32 addrspace(1) But that's not working right now -- Christopher Lamb ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44858 - in /llvm/trunk: include/llvm/Bitcode/LLVMBitCodes.h include/llvm/DerivedTypes.h include/llvm/GlobalVariable.h include/llvm/Instructions.h lib/AsmParser/LLLexer.cpp l
On Dec 11, 2007, at 4:12 PM, Chris Lattner wrote: On Dec 11, 2007, at 12:59 AM, Christopher Lamb wrote: = = --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Dec 11 02:59:05 2007 @@ -197,10 +197,14 @@ TypeVals.push_back(cast(T)->getBitWidth()); break; case Type::PointerTyID: + const PointerType *PTy = cast(T); + // POINTER: [pointee type] or [pointee type, address space] Code = bitc::TYPE_CODE_POINTER; + TypeVals.push_back(VE.getTypeID(PTy->getElementType())); + if (unsigned AddressSpace = PTy->getAddressSpace()) +TypeVals.push_back(AddressSpace); + else +AbbrevToUse = PtrAbbrev; break; This can be simplified. In this code, I'd just unconditionally emit it: case Type::PointerTyID: + const PointerType *PTy = cast(T); + // POINTER: [pointee type] or [pointee type, address space] Code = bitc::TYPE_CODE_POINTER; + TypeVals.push_back(VE.getTypeID(PTy->getElementType())); TypeVals.push_back(PTy->getAddressSpace()); AbbrevToUse = PtrAbbrev; break; And change the abbreviation to match, which would apply only if the addrspace is zero (and thus not encode it at all): // Abbrev for TYPE_CODE_POINTER. BitCodeAbbrev *Abbv = new BitCodeAbbrev(); Abbv->Add(BitCodeAbbrevOp(bitc::TYPE_CODE_POINTER)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, Log2_32_Ceil(VE.getTypes().size()+1))); Abbv->Add(BitCodeAbbrevOp(0)); // Addr space = 0. unsigned PtrAbbrev = Stream.EmitAbbrev(Abbv); The presence of the abbreviation means that any pointers with addrspace 0 will not need per-instance space to represent this. This means moving the assert conditional into the if conditional and removing the assert in BitstreamWriter.h. Sound OK? void EmitAbbreviatedField(const BitCodeAbbrevOp &Op, uintty V) { if (Op.isLiteral()) { // If the abbrev specifies the literal value to use, don't emit // anything. assert(V == Op.getLiteralValue() && "Invalid abbrev for record!"); return; } -- Christopher Lamb ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] RFC: patch for PR1782 (BasicAliasAnalyis)
On Dec 9, 2007, at 2:57 PM, Wojciech Matyjewicz wrote: > Chris Lattner wrote: > >> Yep, it looks Gordon was right :). Thanks again Wojtek, I applied >> the >> patch. Please close the PR, > > Before I close the PR, I would like to discuss one more issue > discovered > while working on it. > > Suppose, we have a target with 32-bit pointers and the following > instructions: > > %p = getelementptr i32* %x, i32 -1 > %q = getelementptr i32* %x, i32 1073741823 ;(1073741823 == 2^30 - 1) > > TargetData::getIndexedOffset() uses 64-bit arithmetic to perform > offset > computation and return 64-bit values. Hence, it will return -4 as an > offset for %p, and 2^32 - 4 for %q. Based on these offsets, it may > seem > that %p and %q point to different memory objects. However, they don't, > taking into account that pointers are 32-bit long. Ok. > I guess, such a large positive index in GEP as seen above can be > introduced by -instcombine pass. Ok. This is somewhat dubious though, as it is wrapping around the end of the address space which is undefined in C. > BasicAA seems to be affected by the issue. For the attached example > opt > -aa-eval says that %p and %q don't alias. > > I think, the simplest way to fix it is to truncate the computed offset > to the target pointer size before returning it in > TargetData::getIndexedOffset(). If you think this is the correct > approach, I may prepare a patch. Ah, that does make a lot of sense. Since the fix is simple, please go for it! -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44910 - in /llvm/trunk: lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp test/ExecutionEngine/2007-12-11-APIntExFuncCall.ll
Hi Chris, 2007/12/12, Chris Lattner <[EMAIL PROTECTED]>: > > > URL: http://llvm.org/viewvc/llvm-project?rev=44910&view=rev > > Log: > > Fixed PR1629. > > Make lli interpreter correctly call external functions sin()/cos(), > > __cxa_guard_acquire() and __cxa_guard_release(). > > #include > > +#include > > using std::vector; > > hi Sheng, > > What provides this non-standard header? I don't know for sure, but I > bet you just made our win32 friends very unhappy. I added a guard (__linux__) to this for which I'm assuming linux platform will provide this header. Is this OKay? Sheng. -Chris > > ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44860 - /llvm/trunk/docs/LangRef.html
On Dec 11, 2007, at 9:16 PM, Chris Lattner wrote: > > On Dec 11, 2007, at 9:08 PM, Christopher Lamb wrote: > >> >> On Dec 11, 2007, at 8:50 PM, Chris Lattner wrote: >> > That is a very strong argument to me, but it seems to argue even > more > strongly for: > > @G = constant float addrspace(5) 1.0, section "foo", align 4 > > Your example above would then be: > >> @foo = constant float addrspace(1)* addrspace(2) 1.0 > > which has type: > >> float addrspace(1)* addrspace(2)* > > What do you think? the downside is that this may cause bison to > have > issues :) This is ideally what I wanted, but it would mean seriously mucking with bison and changing how all CosntVal's are handled. I can give it a try. >>> >>> Hrm, I think bison will get extremely grumpy about this. >> >> I feared. >> >>> Quick question, what is the syntax for an external GV with an ASI? >> >> >> Sticky wicket, that. It should be: >> >> @foo = external global i32 addrspace(1) >> >> But that's not working right now > > Right, because it would require the same parsing logic as the proposal > above :). I don't think so. I think the rules were simply missing the OptAddrSpace. > > How horrible would: > >> @foo = addrspace(1) external global i32 > > be? I like that the order in the decl is the order in the type lots. These now work with the rules being adjusted. @foo = extern_weak global i32 addrspace(1) @foo = external global i32 addrspace(1) @foo = dllimport global i32 addrspace(1) @foo = internal global i32 addrspace(1) @foo = weak global i32 addrspace(1) @foo = linkonce global i32 addrspace(1) @foo = appending global i32 addrspace(1) @foo = dllexport global i32 addrspace(1) -- Christopher Lamb ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44914 - /llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
Author: sheng Date: Wed Dec 12 00:16:47 2007 New Revision: 44914 URL: http://llvm.org/viewvc/llvm-project?rev=44914&view=rev Log: Add a guard to cxxabi header as other platform may not support it. Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp?rev=44914&r1=44913&r2=44914&view=diff == --- llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Wed Dec 12 00:16:47 2007 @@ -29,7 +29,11 @@ #include #include #include + +#ifdef __linux__ #include +#endif + using std::vector; using namespace llvm; @@ -727,8 +731,12 @@ const vector &Args) { assert(Args.size() == 1); GenericValue GV; +#ifdef __linux__ GV.IntVal = APInt(32, __cxxabiv1::__cxa_guard_acquire ( (__cxxabiv1::__guard*)GVTOP(Args[0]))); +#else + assert(0 && "Can't call __cxa_guard_acquire on this platform"); +#endif return GV; } @@ -736,7 +744,11 @@ GenericValue lle_X___cxa_guard_release(FunctionType *FT, const vector &Args) { assert(Args.size() == 1); +#ifdef __linux__ __cxxabiv1::__cxa_guard_release ((__cxxabiv1::__guard*)GVTOP(Args[0])); +#else + assert(0 && "Can't call __cxa_guard_release on this platform"); +#endif return GenericValue(); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44910 - in /llvm/trunk: lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp test/ExecutionEngine/2007-12-11-APIntExFuncCall.ll
On Dec 11, 2007, at 10:12 PM, Zhou Sheng wrote: Hi Chris, 2007/12/12, Chris Lattner <[EMAIL PROTECTED]>: > URL: http://llvm.org/viewvc/llvm-project?rev=44910&view=rev > Log: > Fixed PR1629. > Make lli interpreter correctly call external functions sin()/cos(), > __cxa_guard_acquire() and __cxa_guard_release(). > #include > +#include > using std::vector; hi Sheng, What provides this non-standard header? I don't know for sure, but I bet you just made our win32 friends very unhappy. I added a guard (__linux__) to this for which I'm assuming linux platform will provide this header. Is this OKay? That's fine with me. The rest of the code in that file is already a gross hack, so this seems reasonable :) Thanks Sheng, -Chris___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44860 - /llvm/trunk/docs/LangRef.html
>>> How horrible would: >>> @foo = addrspace(1) external global i32 >>> >>> be? >> >> I like that the order in the decl is the order in the type lots. >> >> These now work with the rules being adjusted. >> >> @foo = extern_weak global i32 addrspace(1) >> @foo = external global i32 addrspace(1) >> @foo = dllimport global i32 addrspace(1) >> > rather... > > @foo = internal global i32 0 addrspace(1) > @foo = weak global i32 0 addrspace(1) > @foo = linkonce global i32 0 addrspace(1) > @foo = appending global i32 0 addrspace(1) > @foo = dllexport global i32 0 addrspace(1) I prefer that too, but I don't see how you're going to get bison to accept "external global i32 addrspace(1)". Please verify that the number of shift/reduce and reduce/reduce conflicts doesn't go up. -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44860 - /llvm/trunk/docs/LangRef.html
On Dec 11, 2007, at 10:12 PM, Christopher Lamb wrote: On Dec 11, 2007, at 9:16 PM, Chris Lattner wrote: On Dec 11, 2007, at 9:08 PM, Christopher Lamb wrote: On Dec 11, 2007, at 8:50 PM, Chris Lattner wrote: That is a very strong argument to me, but it seems to argue even more strongly for: @G = constant float addrspace(5) 1.0, section "foo", align 4 Your example above would then be: @foo = constant float addrspace(1)* addrspace(2) 1.0 which has type: float addrspace(1)* addrspace(2)* What do you think? the downside is that this may cause bison to have issues :) This is ideally what I wanted, but it would mean seriously mucking with bison and changing how all CosntVal's are handled. I can give it a try. Hrm, I think bison will get extremely grumpy about this. I feared. Quick question, what is the syntax for an external GV with an ASI? Sticky wicket, that. It should be: @foo = external global i32 addrspace(1) But that's not working right now Right, because it would require the same parsing logic as the proposal above :). I don't think so. I think the rules were simply missing the OptAddrSpace. How horrible would: @foo = addrspace(1) external global i32 be? I like that the order in the decl is the order in the type lots. These now work with the rules being adjusted. @foo = extern_weak global i32 addrspace(1) @foo = external global i32 addrspace(1) @foo = dllimport global i32 addrspace(1) rather... @foo = internal global i32 0 addrspace(1) @foo = weak global i32 0 addrspace(1) @foo = linkonce global i32 0 addrspace(1) @foo = appending global i32 0 addrspace(1) @foo = dllexport global i32 0 addrspace(1) -- Christopher Lamb ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44860 - /llvm/trunk/docs/LangRef.html
On Dec 11, 2007, at 10:30 PM, Chris Lattner wrote: How horrible would: @foo = addrspace(1) external global i32 be? I like that the order in the decl is the order in the type lots. These now work with the rules being adjusted. @foo = extern_weak global i32 addrspace(1) @foo = external global i32 addrspace(1) @foo = dllimport global i32 addrspace(1) rather... @foo = internal global i32 0 addrspace(1) @foo = weak global i32 0 addrspace(1) @foo = linkonce global i32 0 addrspace(1) @foo = appending global i32 0 addrspace(1) @foo = dllexport global i32 0 addrspace(1) I prefer that too, but I don't see how you're going to get bison to accept "external global i32 addrspace(1)". The problem is placing the 'addrspace()' betwen the type name and the value of a 'ConstVal'. The pattern for external linkage global variables refers to 'Types' rather than 'ConstVal', so it works just fine. Please verify that the number of shift/reduce and reduce/reduce conflicts doesn't go up. They don't. -- Christopher Lamb ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44921 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/vec_return.ll
Author: evancheng Date: Wed Dec 12 00:45:40 2007 New Revision: 44921 URL: http://llvm.org/viewvc/llvm-project?rev=44921&view=rev Log: Lower a build_vector with all constants into a constpool load unless it can be done with a move to low part. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/test/CodeGen/X86/vec_return.ll Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=44921&r1=44920&r2=44921&view=diff == --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Dec 12 00:45:40 2007 @@ -3157,21 +3157,21 @@ unsigned NumZero = 0; unsigned NumNonZero = 0; unsigned NonZeros = 0; - unsigned NumNonZeroImms = 0; + bool HasNonImms = false; SmallSet Values; for (unsigned i = 0; i < NumElems; ++i) { SDOperand Elt = Op.getOperand(i); -if (Elt.getOpcode() != ISD::UNDEF) { - Values.insert(Elt); - if (isZeroNode(Elt)) -NumZero++; - else { -NonZeros |= (1 << i); -NumNonZero++; -if (Elt.getOpcode() == ISD::Constant || -Elt.getOpcode() == ISD::ConstantFP) - NumNonZeroImms++; - } +if (Elt.getOpcode() == ISD::UNDEF) + continue; +Values.insert(Elt); +if (Elt.getOpcode() != ISD::Constant && +Elt.getOpcode() != ISD::ConstantFP) + HasNonImms = true; +if (isZeroNode(Elt)) + NumZero++; +else { + NonZeros |= (1 << i); + NumNonZero++; } } @@ -3185,7 +3185,7 @@ return SDOperand(); // Special case for single non-zero element. - if (NumNonZero == 1) { + if (NumNonZero == 1 && NumElems <= 4) { unsigned Idx = CountTrailingZeros_32(NonZeros); SDOperand Item = Op.getOperand(Idx); Item = DAG.getNode(ISD::SCALAR_TO_VECTOR, VT, Item); @@ -3193,6 +3193,8 @@ // Turn it into a MOVL (i.e. movss, movsd, or movd) to a zero vector. return getShuffleVectorZeroOrUndef(Item, VT, NumElems, Idx, NumZero > 0, DAG); +else if (!HasNonImms) // Otherwise, it's better to do a constpool load. + return SDOperand(); if (EVTBits == 32) { // Turn it into a shuffle of zero and zero-extended scalar to vector. @@ -3212,7 +3214,7 @@ // A vector full of immediates; various special cases are already // handled, so this is best done with a single constant-pool load. - if (NumNonZero == NumNonZeroImms) + if (!HasNonImms) return SDOperand(); // Let legalizer expand 2-wide build_vectors. Modified: llvm/trunk/test/CodeGen/X86/vec_return.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_return.ll?rev=44921&r1=44920&r2=44921&view=diff == --- llvm/trunk/test/CodeGen/X86/vec_return.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_return.ll Wed Dec 12 00:45:40 2007 @@ -1,5 +1,12 @@ -; RUN: llvm-upgrade < %s | llvm-as | llc -march=x86 -mcpu=yonah +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep xorps | count 1 +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | grep movaps | count 1 +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 | not grep shuf -<2 x double> %test() { - ret <2 x double> +define <2 x double> @test() { + ret <2 x double> zeroinitializer +} + +define <4 x i32> @test2() nounwind { + ret <4 x i32> < i32 0, i32 0, i32 1, i32 0 > } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44860 - /llvm/trunk/docs/LangRef.html
>>> @foo = internal global i32 0 addrspace(1) >>> @foo = weak global i32 0 addrspace(1) >>> @foo = linkonce global i32 0 addrspace(1) >>> @foo = appending global i32 0 addrspace(1) >>> @foo = dllexport global i32 0 addrspace(1) >> >> I prefer that too, but I don't see how you're going to get bison to >> accept "external global i32 addrspace(1)". > > The problem is placing the 'addrspace()' betwen the type name and > the value of a 'ConstVal'. The pattern for external linkage global > variables refers to 'Types' rather than 'ConstVal', so it works just > fine. > >> Please verify that the number of shift/reduce and reduce/reduce >> conflicts doesn't go up. > > > They don't. Ok. It would still be nicer to get to: >>> @foo = dllexport global i32 addrspace(1) 0 :) -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44928 - /llvm/trunk/test/CodeGen/X86/opt-ext-uses.ll
Author: evancheng Date: Wed Dec 12 01:54:08 2007 New Revision: 44928 URL: http://llvm.org/viewvc/llvm-project?rev=44928&view=rev Log: Add a test case for -optimize-ext-uses. Added: llvm/trunk/test/CodeGen/X86/opt-ext-uses.ll Added: llvm/trunk/test/CodeGen/X86/opt-ext-uses.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/opt-ext-uses.ll?rev=44928&view=auto == --- llvm/trunk/test/CodeGen/X86/opt-ext-uses.ll (added) +++ llvm/trunk/test/CodeGen/X86/opt-ext-uses.ll Wed Dec 12 01:54:08 2007 @@ -0,0 +1,19 @@ +; RUN: llvm-as < %s | llc -march=x86 -optimize-ext-uses=true | grep movw | count 1 + +define i16 @t() signext { +entry: +%tmp180 = load i16* null, align 2 ; [#uses=3] +%tmp180181 = sext i16 %tmp180 to i32; [#uses=1] +%tmp182 = add i16 %tmp180, 10 +%tmp185 = icmp slt i16 %tmp182, 0 ; [#uses=1] +br i1 %tmp185, label %cond_true188, label %cond_next245 + +cond_true188: ; preds = %entry +%tmp195196 = trunc i16 %tmp180 to i8; [#uses=0] +ret i16 %tmp180 + +cond_next245: ; preds = %entry +%tmp256 = and i32 %tmp180181, 15; [#uses=0] +%tmp3 = trunc i32 %tmp256 to i16 +ret i16 %tmp3 +} ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44929 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/2007-07-31-VInsertBug.ll test/CodeGen/X86/vec_insert-2.ll test/CodeGen/X86/vec_insert-3.ll test/CodeG
Author: evancheng Date: Wed Dec 12 01:55:34 2007 New Revision: 44929 URL: http://llvm.org/viewvc/llvm-project?rev=44929&view=rev Log: Use shuffles to implement insert_vector_elt for i32, i64, f32, and f64. Added: llvm/trunk/test/CodeGen/X86/vec_insert-2.ll llvm/trunk/test/CodeGen/X86/vec_insert-3.ll Removed: llvm/trunk/test/CodeGen/X86/2007-07-31-VInsertBug.ll Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/test/CodeGen/X86/vec_insert.ll Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=44929&r1=44928&r2=44929&view=diff == --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Dec 12 01:55:34 2007 @@ -3922,53 +3922,35 @@ SDOperand X86TargetLowering::LowerINSERT_VECTOR_ELT(SDOperand Op, SelectionDAG &DAG) { - // Transform it so it match pinsrw which expects a 16-bit value in a GR32 - // as its second argument. MVT::ValueType VT = Op.getValueType(); - MVT::ValueType BaseVT = MVT::getVectorElementType(VT); + MVT::ValueType EVT = MVT::getVectorElementType(VT); + if (EVT == MVT::i8) +return SDOperand(); + SDOperand N0 = Op.getOperand(0); SDOperand N1 = Op.getOperand(1); SDOperand N2 = Op.getOperand(2); - if (MVT::getSizeInBits(BaseVT) == 16) { + + if (MVT::getSizeInBits(EVT) == 16) { +// Transform it so it match pinsrw which expects a 16-bit value in a GR32 +// as its second argument. if (N1.getValueType() != MVT::i32) N1 = DAG.getNode(ISD::ANY_EXTEND, MVT::i32, N1); if (N2.getValueType() != MVT::i32) N2 = DAG.getConstant(cast(N2)->getValue(),getPointerTy()); return DAG.getNode(X86ISD::PINSRW, VT, N0, N1, N2); - } else if (MVT::getSizeInBits(BaseVT) == 32) { -unsigned Idx = cast(N2)->getValue(); -if (Idx == 0) { - // Use a movss. - N1 = DAG.getNode(ISD::SCALAR_TO_VECTOR, VT, N1); - MVT::ValueType MaskVT = MVT::getIntVectorWithNumElements(4); - MVT::ValueType BaseVT = MVT::getVectorElementType(MaskVT); - SmallVector MaskVec; - MaskVec.push_back(DAG.getConstant(4, BaseVT)); - for (unsigned i = 1; i <= 3; ++i) -MaskVec.push_back(DAG.getConstant(i, BaseVT)); - return DAG.getNode(ISD::VECTOR_SHUFFLE, VT, N0, N1, - DAG.getNode(ISD::BUILD_VECTOR, MaskVT, - &MaskVec[0], MaskVec.size())); -} else { - // Use two pinsrw instructions to insert a 32 bit value. - Idx <<= 1; - if (MVT::isFloatingPoint(N1.getValueType())) { -N1 = DAG.getNode(ISD::SCALAR_TO_VECTOR, MVT::v4f32, N1); -N1 = DAG.getNode(ISD::BIT_CONVERT, MVT::v4i32, N1); -N1 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, MVT::i32, N1, - DAG.getConstant(0, getPointerTy())); - } - N0 = DAG.getNode(ISD::BIT_CONVERT, MVT::v8i16, N0); - N0 = DAG.getNode(X86ISD::PINSRW, MVT::v8i16, N0, N1, - DAG.getConstant(Idx, getPointerTy())); - N1 = DAG.getNode(ISD::SRL, MVT::i32, N1, DAG.getConstant(16, MVT::i8)); - N0 = DAG.getNode(X86ISD::PINSRW, MVT::v8i16, N0, N1, - DAG.getConstant(Idx+1, getPointerTy())); - return DAG.getNode(ISD::BIT_CONVERT, VT, N0); -} } - return SDOperand(); + N1 = DAG.getNode(ISD::SCALAR_TO_VECTOR, VT, N1); + unsigned Idx = cast(N2)->getValue(); + MVT::ValueType MaskVT = MVT::getIntVectorWithNumElements(4); + MVT::ValueType MaskEVT = MVT::getVectorElementType(MaskVT); + SmallVector MaskVec; + for (unsigned i = 0; i < 4; ++i) +MaskVec.push_back(DAG.getConstant((i == Idx) ? i+4 : i, MaskEVT)); + return DAG.getNode(ISD::VECTOR_SHUFFLE, VT, N0, N1, + DAG.getNode(ISD::BUILD_VECTOR, MaskVT, + &MaskVec[0], MaskVec.size())); } SDOperand Removed: llvm/trunk/test/CodeGen/X86/2007-07-31-VInsertBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-07-31-VInsertBug.ll?rev=44928&view=auto == --- llvm/trunk/test/CodeGen/X86/2007-07-31-VInsertBug.ll (original) +++ llvm/trunk/test/CodeGen/X86/2007-07-31-VInsertBug.ll (removed) @@ -1,16 +0,0 @@ -; RUN: llvm-as < %s | llc -mtriple=i686-apple-darwin -mattr=+sse2 | %prcontext {pinsrw \$2} 1 | grep "movl \$1" -; RUN: llvm-as < %s | llc -mtriple=i686-apple-darwin -mattr=+sse2 | not grep movss - [EMAIL PROTECTED] = global <4 x float> zeroinitializer - -define void @test(i32 *%P1, i32* %P2, float *%FP) { -%T = load float* %FP -store i32 0, i32* %P1 - -%U = load <4 x float>* @G -store i32 1, i32* %P1 -%V = insertelement <4 x float> %U, float %T, i32 1 -store <4 x float> %V, <4 x float>* @G - -ret void -} Added: ll