From sanjiv.gupta at microchip.com Mon Apr 6 05:55:06 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Mon, 06 Apr 2009 10:55:06 -0000 Subject: [llvm-commits] [llvm] r68442 - in /llvm/trunk/lib/Target/PIC16: PIC16AsmPrinter.cpp PIC16AsmPrinter.h PIC16ISelLowering.cpp PIC16ISelLowering.h PIC16InstrInfo.cpp Message-ID: <200904061055.n36AtBPH027278@zion.cs.uiuc.edu> Author: sgupta Date: Mon Apr 6 05:54:50 2009 New Revision: 68442 URL: http://llvm.org/viewvc/llvm-project?rev=68442&view=rev Log: Map stack based frameindices for spills to zero based indices that can be accessed based on an external symbol defining the location of temporary data for a function. For example: we have spill slots addressed as foo.tmp + 0, foo.tmp + 1 etc. Modified: llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.h llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.h llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp Modified: llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp?rev=68442&r1=68441&r2=68442&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp Mon Apr 6 05:54:50 2009 @@ -343,7 +343,6 @@ void PIC16AsmPrinter::emitFunctionData(MachineFunction &MF) { const Function *F = MF.getFunction(); std::string FuncName = Mang->getValueName(F); - MachineFrameInfo *MFI= MF.getFrameInfo(); Module *M = const_cast(F->getParent()); const TargetData *TD = TM.getTargetData(); unsigned FrameSize = 0; @@ -406,15 +405,7 @@ O << VarName << " RES " << Size << "\n"; } - - // Emit the variable to hold the space for temporary locations - // in function frame. - if (MFI->hasStackObjects()) { - int indexBegin = MFI->getObjectIndexBegin(); - int indexEnd = MFI->getObjectIndexEnd(); - if (indexBegin < indexEnd) { - int TempSize = indexEnd - indexBegin; - O << CurrentFnName << ".tmp RES " << TempSize <<"\n"; - } - } + int TempSize = PTLI->GetTmpSize(); + if (TempSize > 0 ) + O << CurrentFnName << ".tmp RES " << TempSize <<"\n"; } Modified: llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.h?rev=68442&r1=68441&r2=68442&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.h Mon Apr 6 05:54:50 2009 @@ -24,11 +24,12 @@ namespace llvm { struct VISIBILITY_HIDDEN PIC16AsmPrinter : public AsmPrinter { - PIC16AsmPrinter(raw_ostream &O, TargetMachine &TM, + PIC16AsmPrinter(raw_ostream &O, PIC16TargetMachine &TM, const TargetAsmInfo *T, bool F, bool V) : AsmPrinter(O, TM, T, F, V) { CurBank = ""; IsRomData = false; + PTLI = TM.getTargetLowering(); } private : virtual const char *getPassName() const { @@ -51,6 +52,7 @@ bool doFinalization(Module &M); private: + PIC16TargetLowering *PTLI; std::string CurBank; bool IsRomData; }; Modified: llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp?rev=68442&r1=68441&r2=68442&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Mon Apr 6 05:54:50 2009 @@ -31,7 +31,7 @@ // PIC16TargetLowering Constructor. PIC16TargetLowering::PIC16TargetLowering(PIC16TargetMachine &TM) - : TargetLowering(TM) { + : TargetLowering(TM), TmpSize(0) { Subtarget = &TM.getSubtarget(); @@ -154,6 +154,17 @@ return Flag; } +// Get the TmpOffset for FrameIndex +unsigned PIC16TargetLowering::GetTmpOffsetForFI(unsigned FI) { + std::map::iterator + MapIt = FiTmpOffsetMap.find(FI); + if (MapIt != FiTmpOffsetMap.end()) + return MapIt->second; + + // This FI (FrameIndex) is not yet mapped, so map it + FiTmpOffsetMap[FI] = TmpSize; + return TmpSize++; +} // To extract chain value from the SDValue Nodes // This function will help to maintain the chain extracting @@ -541,9 +552,9 @@ // and non-constant operand of ADD will be treated as pointer. // Returns the high and lo part of the address, and the offset(in case of ADD). -void PIC16TargetLowering:: LegalizeAddress(SDValue Ptr, SelectionDAG &DAG, - SDValue &Lo, SDValue &Hi, - unsigned &Offset, DebugLoc dl) { +void PIC16TargetLowering::LegalizeAddress(SDValue Ptr, SelectionDAG &DAG, + SDValue &Lo, SDValue &Hi, + unsigned &Offset, DebugLoc dl) { // Offset, by default, should be 0 Offset = 0; @@ -849,13 +860,15 @@ DAG.getEntryNode(), Op, ES, DAG.getConstant (1, MVT::i8), // Banksel. - DAG.getConstant (FI, MVT::i8)); + DAG.getConstant (GetTmpOffsetForFI(FI), + MVT::i8)); // Load the value from ES. SDVTList Tys = DAG.getVTList(MVT::i8, MVT::Other); SDValue Load = DAG.getNode(PIC16ISD::PIC16Load, dl, Tys, Store, ES, DAG.getConstant (1, MVT::i8), - DAG.getConstant (FI, MVT::i8)); + DAG.getConstant (GetTmpOffsetForFI(FI), + MVT::i8)); return Load.getValue(0); } @@ -1212,40 +1225,45 @@ return DAG.getNode(Op.getOpcode(), dl, Tys, NewVal, Op.getOperand(1)); } -// LowerFORMAL_ARGUMENTS - In Lowering FORMAL ARGUMENTS - MERGE_VALUES nodes -// is returned. MERGE_VALUES nodes number of operands and number of values are -// equal. Therefore to construct MERGE_VALUE node, UNDEF nodes equal to the -// number of arguments of function have been created. +// LowerFORMAL_ARGUMENTS - Argument values are loaded from the +// .args + offset. All arguments are already broken to leaglized +// types, so the offset just runs from 0 to NumArgVals - 1. SDValue PIC16TargetLowering::LowerFORMAL_ARGUMENTS(SDValue Op, - SelectionDAG &DAG) { + SelectionDAG &DAG) { SmallVector ArgValues; - unsigned NumArgs = Op.getNode()->getNumValues()-1; + unsigned NumArgVals = Op.getNode()->getNumValues() - 1; DebugLoc dl = Op.getDebugLoc(); SDValue Chain = Op.getOperand(0); // Formal arguments' chain + + // Reset the map of FI and TmpOffset + ResetTmpOffsetMap(); + // Get the callee's name to create the .args label to pass args. MachineFunction &MF = DAG.getMachineFunction(); - //const TargetData *TD = getTargetData(); const Function *F = MF.getFunction(); std::string FuncName = F->getName(); + // Create the .args external symbol. char *tmpName = new char [strlen(FuncName.c_str()) + 6]; sprintf(tmpName, "%s.args", FuncName.c_str()); - SDVTList VTs = DAG.getVTList (MVT::i8, MVT::Other); SDValue ES = DAG.getTargetExternalSymbol(tmpName, MVT::i8); + + // Load arg values from the label + offset. + SDVTList VTs = DAG.getVTList (MVT::i8, MVT::Other); SDValue BS = DAG.getConstant(1, MVT::i8); - for (unsigned i=0; igetVTList(), - &ArgValues[0], - ArgValues.size()).getValue(Op.getResNo()); + &ArgValues[0], ArgValues.size()).getValue(Op.getResNo()); } // Perform DAGCombine of PIC16Load. Modified: llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.h?rev=68442&r1=68441&r2=68442&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.h Mon Apr 6 05:54:50 2009 @@ -19,6 +19,7 @@ #include "PIC16Subtarget.h" #include "llvm/CodeGen/SelectionDAG.h" #include "llvm/Target/TargetLowering.h" +#include namespace llvm { namespace PIC16ISD { @@ -117,6 +118,16 @@ SDValue PerformPIC16LoadCombine(SDNode *N, DAGCombinerInfo &DCI) const; SDValue PerformStoreCombine(SDNode *N, DAGCombinerInfo &DCI) const; + // This function returns the Tmp Offset for FrameIndex. If any TmpOffset + // already exists for the FI then it returns the same else it creates the + // new offset and returns. + unsigned GetTmpOffsetForFI(unsigned FI); + void ResetTmpOffsetMap() { FiTmpOffsetMap.clear(); SetTmpSize(0); } + + // Return the size of Tmp variable + unsigned GetTmpSize() { return TmpSize; } + void SetTmpSize(unsigned Size) { TmpSize = Size; } + private: // If the Node is a BUILD_PAIR representing a direct Address, // then this function will return true. @@ -170,6 +181,11 @@ // Check if operation has a direct load operand. inline bool isDirectLoad(const SDValue Op); + private: + // The frameindexes generated for spill/reload are stack based. + // This maps maintain zero based indexes for these FIs. + std::map FiTmpOffsetMap; + unsigned TmpSize; }; } // namespace llvm Modified: llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp?rev=68442&r1=68441&r2=68442&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp Mon Apr 6 05:54:50 2009 @@ -69,6 +69,7 @@ MachineBasicBlock::iterator I, unsigned SrcReg, bool isKill, int FI, const TargetRegisterClass *RC) const { + PIC16TargetLowering *PTLI = TM.getTargetLowering(); DebugLoc DL = DebugLoc::getUnknownLoc(); if (I != MBB.end()) DL = I->getDebugLoc(); @@ -84,7 +85,7 @@ //MachineRegisterInfo &RI = MF.getRegInfo(); BuildMI(MBB, I, DL, get(PIC16::movwf)) .addReg(SrcReg, false, false, isKill) - .addImm(FI) + .addImm(PTLI->GetTmpOffsetForFI(FI)) .addExternalSymbol(tmpName) .addImm(1); // Emit banksel for it. } @@ -98,6 +99,7 @@ MachineBasicBlock::iterator I, unsigned DestReg, int FI, const TargetRegisterClass *RC) const { + PIC16TargetLowering *PTLI = TM.getTargetLowering(); DebugLoc DL = DebugLoc::getUnknownLoc(); if (I != MBB.end()) DL = I->getDebugLoc(); @@ -112,7 +114,7 @@ //MachineFunction &MF = *MBB.getParent(); //MachineRegisterInfo &RI = MF.getRegInfo(); BuildMI(MBB, I, DL, get(PIC16::movf), DestReg) - .addImm(FI) + .addImm(PTLI->GetTmpOffsetForFI(FI)) .addExternalSymbol(tmpName) .addImm(1); // Emit banksel for it. } From gohman at apple.com Mon Apr 6 13:48:00 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 6 Apr 2009 11:48:00 -0700 Subject: [llvm-commits] [llvm] r66922 - in /llvm/trunk: lib/Target/X86/X86InstrInfo.td test/CodeGen/X86/tls13.ll test/CodeGen/X86/tls14.ll In-Reply-To: <38a0d8450904050541r5e13b580o3a66bfa69069a455@mail.gmail.com> References: <200903131837.n2DIb7PC008719@zion.cs.uiuc.edu> <38a0d8450903311517m60b40486wc1af6a391faa6b6f@mail.gmail.com> <01131E67-E237-482B-BBBE-843A1F6DE0D0@apple.com> <38a0d8450904021346y48f1d13ds2c23c13fca2a886a@mail.gmail.com> <6FC4BA6E-0E41-47E4-B4E1-D984E9A08B41@apple.com> <38a0d8450904030915g2e92040clb9c60b173f044c52@mail.gmail.com> <38a0d8450904050541r5e13b580o3a66bfa69069a455@mail.gmail.com> Message-ID: On Apr 5, 2009, at 5:41 AM, Rafael Espindola wrote: >> I think I will try the idea of always lowering to (load gs:0) + ADDR >> and then implementing some instruction folding after Select. I assume >> that is possible, right? > > The attached patch does that. I like it a lot more. All that was > needed to get performance back was a small change to MatchAddress to > handle a load inside a load. > > The only possible issue is that now we produce > > movl $i at NTPOFF, %eax > addl %gs:0, %eax > > Instead of > > movl %gs:0, %eax > leal i at NTPOFF(%eax), %eax > > I don't have enough experience with X86 to know which one is best. It probably depends on the context. The latter at least has the advantage of allowing the load from %gs:0 of being CSE'd when there are multiple TLS address computations. Can this be fixed with code in X86DAGToDAGISel::IsLegalAndProfitableToFold ? The code at the top of the function is a heuristic with a similar purpose. In any event, I don't consider this a show-stopper; we can continue to tune things like this after the patch is in. > > > What do you think of the current approach? I think this patch looks like a good approach. I think there are some tuning things that can be addressed later; I just have a few minor comments for now. In this code in isMem in X86InstrInfo.h: @@ -256,6 +256,7 @@ return Op+4 <= MI->getNumOperands() && MI->getOperand(Op ).isReg() && isScale(MI->getOperand(Op+1)) && MI->getOperand(Op+2).isReg() && + MI->getOperand(Op+4).isReg() && (MI->getOperand(Op+3).isImm() || MI->getOperand(Op+3).isGlobal() || MI->getOperand(Op+3).isCPI() || The code here only checks for getNumOperands being >= Op+4, so the call to getOperand(Op+4) could potentially go out of bounds. A simple fix would be to create a separate isLeaMem function which only expects 4 operands so that isMem can expect 5 (or X86AddrNumOperands) operands. A more involved fix would be to make all addresses have 5 operands, and just require the fifth operand in an lea to be %reg0. I don't have a strong preference at this point. Please add a comment in MatchLoad explaining why it's safe to do what it's doing. Please use spaces instead of tabs for indentation. Thanks for working on this! Dan From mrs at apple.com Mon Apr 6 14:58:12 2009 From: mrs at apple.com (Mike Stump) Date: Mon, 06 Apr 2009 19:58:12 -0000 Subject: [llvm-commits] [llvm] r68455 - /llvm/trunk/Makefile.rules Message-ID: <200904061958.n36JwC1F016795@zion.cs.uiuc.edu> Author: mrs Date: Mon Apr 6 14:58:11 2009 New Revision: 68455 URL: http://llvm.org/viewvc/llvm-project?rev=68455&view=rev Log: Avoid -O3 on Darwin for now. Modified: llvm/trunk/Makefile.rules Modified: llvm/trunk/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.rules?rev=68455&r1=68454&r2=68455&view=diff ============================================================================== --- llvm/trunk/Makefile.rules (original) +++ llvm/trunk/Makefile.rules Mon Apr 6 14:58:11 2009 @@ -229,10 +229,12 @@ CPP.Defines := # OPTIMIZE_OPTION - The optimization level option we want to build LLVM with # this can be overridden on the make command line. -ifneq ($(OS),MingW) - OPTIMIZE_OPTION := -O3 -else +# Avoid -O3 on Darwin, there are unresolved issues with +# -fstrict-aliasing and ipa-type-escape radr://6756684 +ifeq ($(OS), $(filter $(OS), MingW Darwin)) OPTIMIZE_OPTION := -O2 +else + OPTIMIZE_OPTION := -O3 endif ifdef ENABLE_PROFILING From sabre at nondot.org Mon Apr 6 15:35:21 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 06 Apr 2009 20:35:21 -0000 Subject: [llvm-commits] [llvm] r68456 - /llvm/trunk/docs/BitCodeFormat.html Message-ID: <200904062035.n36KZLsK018209@zion.cs.uiuc.edu> Author: lattner Date: Mon Apr 6 15:35:19 2009 New Revision: 68456 URL: http://llvm.org/viewvc/llvm-project?rev=68456&view=rev Log: clean up some html Modified: llvm/trunk/docs/BitCodeFormat.html Modified: llvm/trunk/docs/BitCodeFormat.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/BitCodeFormat.html?rev=68456&r1=68455&r2=68456&view=diff ============================================================================== --- llvm/trunk/docs/BitCodeFormat.html (original) +++ llvm/trunk/docs/BitCodeFormat.html Mon Apr 6 15:35:19 2009 @@ -461,24 +461,24 @@

The possible operand encodings are:

-
    -
  • 1 — Fixed — The field should be emitted as +
      +
    1. Fixed: The field should be emitted as a fixed-width value, whose width is specified by the operand's extra data.
    2. -
    3. 2 — VBR — The field should be emitted as +
    4. VBR: The field should be emitted as a variable-width value, whose width is specified by the operand's extra data.
    5. -
    6. 3 — Array — This field is an array of values. The array operand +
    7. Array: This field is an array of values. The array operand has no extra data, but expects another operand to follow it which indicates the element type of the array. When reading an array in an abbreviated record, the first integer is a vbr6 that indicates the array length, followed by the encoded elements of the array. An array may only occur as the last operand of an abbreviation (except for the one final operand that gives the array's type).
    8. -
    9. 4 — Char6 — This field should be emitted as +
    10. Char6: This field should be emitted as a char6-encoded value. This operand type takes no extra data.
    11. -
+

For example, target triples in LLVM modules are encoded as a record of the From edwintorok at gmail.com Mon Apr 6 15:49:21 2009 From: edwintorok at gmail.com (Torok Edwin) Date: Mon, 06 Apr 2009 20:49:21 -0000 Subject: [llvm-commits] [llvm] r68457 - in /llvm/trunk: examples/HowToUseJIT/HowToUseJIT.cpp lib/VMCore/Type.cpp Message-ID: <200904062049.n36KnMDn018714@zion.cs.uiuc.edu> Author: edwin Date: Mon Apr 6 15:49:21 2009 New Revision: 68457 URL: http://llvm.org/viewvc/llvm-project?rev=68457&view=rev Log: fix (part of) memory leak on shutdown. See PR2975. Modified: llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp llvm/trunk/lib/VMCore/Type.cpp Modified: llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp?rev=68457&r1=68456&r2=68457&view=diff ============================================================================== --- llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp (original) +++ llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp Mon Apr 6 15:49:21 2009 @@ -42,6 +42,7 @@ #include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/Interpreter.h" #include "llvm/ExecutionEngine/GenericValue.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -109,5 +110,8 @@ // Import result of execution: outs() << "Result: " << gv.IntVal << "\n"; + EE->freeMachineCodeForFunction(FooF); + delete EE; + llvm_shutdown(); return 0; } Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=68457&r1=68456&r2=68457&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Mon Apr 6 15:49:21 2009 @@ -666,6 +666,22 @@ std::multimap TypesByHash; public: + ~TypeMapBase() + { + for (std::multimap::iterator I + = TypesByHash.begin(), E = TypesByHash.end(); I != E;) { + Type *Ty = I->second.get(); + if (!Ty->isAbstract() && (isa(Ty) || isa(Ty) || + isa(Ty))) { + TypesByHash.erase(I++); + // PATypeHolder won't destroy it, so we must + Ty->destroy(); + } + else + ++I; + } + } + void RemoveFromTypesByHash(unsigned Hash, const Type *Ty) { std::multimap::iterator I = TypesByHash.lower_bound(Hash); From sabre at nondot.org Mon Apr 6 15:54:32 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 06 Apr 2009 20:54:32 -0000 Subject: [llvm-commits] [llvm] r68458 - in /llvm/trunk: include/llvm/Bitcode/ReaderWriter.h lib/Bitcode/Reader/BitcodeReader.cpp tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp Message-ID: <200904062054.n36KsWXj018907@zion.cs.uiuc.edu> Author: lattner Date: Mon Apr 6 15:54:32 2009 New Revision: 68458 URL: http://llvm.org/viewvc/llvm-project?rev=68458&view=rev Log: Teach llvm-bcanalyzer to skip over the header we use on LLVM IR files. Modified: llvm/trunk/include/llvm/Bitcode/ReaderWriter.h llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp Modified: llvm/trunk/include/llvm/Bitcode/ReaderWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/ReaderWriter.h?rev=68458&r1=68457&r2=68458&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/ReaderWriter.h (original) +++ llvm/trunk/include/llvm/Bitcode/ReaderWriter.h Mon Apr 6 15:54:32 2009 @@ -24,7 +24,7 @@ class ModulePass; class BitstreamWriter; class raw_ostream; - + /// getBitcodeModuleProvider - Read the header of the specified bitcode buffer /// and prepare for lazy deserialization of function bodies. If successful, /// this takes ownership of 'buffer' and returns a non-null pointer. On @@ -57,6 +57,57 @@ /// createBitcodeWriterPass - Create and return a pass that writes the module /// to the specified ostream. ModulePass *createBitcodeWriterPass(raw_ostream &Str); + + + /// isBitcodeWrapper - Return true fi this is a wrapper for LLVM IR bitcode + /// files. + static bool inline isBitcodeWrapper(unsigned char *BufPtr, + unsigned char *BufEnd) { + return (BufPtr != BufEnd && BufPtr[0] == 0xDE && BufPtr[1] == 0xC0 && + BufPtr[2] == 0x17 && BufPtr[3] == 0x0B); + } + + /// SkipBitcodeWrapperHeader - Some systems wrap bc files with a special + /// header for padding or other reasons. The format of this header is: + /// + /// struct bc_header { + /// uint32_t Magic; // 0x0B17C0DE + /// uint32_t Version; // Version, currently always 0. + /// uint32_t BitcodeOffset; // Offset to traditional bitcode file. + /// uint32_t BitcodeSize; // Size of traditional bitcode file. + /// ... potentially other gunk ... + /// }; + /// + /// This function is called when we find a file with a matching magic number. + /// In this case, skip down to the subsection of the file that is actually a + /// BC file. + static inline bool SkipBitcodeWrapperHeader(unsigned char *&BufPtr, + unsigned char *&BufEnd) { + enum { + KnownHeaderSize = 4*4, // Size of header we read. + OffsetField = 2*4, // Offset in bytes to Offset field. + SizeField = 3*4 // Offset in bytes to Size field. + }; + + // Must contain the header! + if (BufEnd-BufPtr < KnownHeaderSize) return true; + + unsigned Offset = ( BufPtr[OffsetField ] | + (BufPtr[OffsetField+1] << 8) | + (BufPtr[OffsetField+2] << 16) | + (BufPtr[OffsetField+3] << 24)); + unsigned Size = ( BufPtr[SizeField ] | + (BufPtr[SizeField +1] << 8) | + (BufPtr[SizeField +2] << 16) | + (BufPtr[SizeField +3] << 24)); + + // Verify that Offset+Size fits in the file. + if (Offset+Size > unsigned(BufEnd-BufPtr)) + return true; + BufPtr += Offset; + BufEnd = BufPtr+Size; + return false; + } } // End llvm namespace #endif Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=68458&r1=68457&r2=68458&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon Apr 6 15:54:32 2009 @@ -1330,48 +1330,6 @@ return Error("Premature end of bitstream"); } -/// SkipWrapperHeader - Some systems wrap bc files with a special header for -/// padding or other reasons. The format of this header is: -/// -/// struct bc_header { -/// uint32_t Magic; // 0x0B17C0DE -/// uint32_t Version; // Version, currently always 0. -/// uint32_t BitcodeOffset; // Offset to traditional bitcode file. -/// uint32_t BitcodeSize; // Size of traditional bitcode file. -/// ... potentially other gunk ... -/// }; -/// -/// This function is called when we find a file with a matching magic number. -/// In this case, skip down to the subsection of the file that is actually a BC -/// file. -static bool SkipWrapperHeader(unsigned char *&BufPtr, unsigned char *&BufEnd) { - enum { - KnownHeaderSize = 4*4, // Size of header we read. - OffsetField = 2*4, // Offset in bytes to Offset field. - SizeField = 3*4 // Offset in bytes to Size field. - }; - - - // Must contain the header! - if (BufEnd-BufPtr < KnownHeaderSize) return true; - - unsigned Offset = ( BufPtr[OffsetField ] | - (BufPtr[OffsetField+1] << 8) | - (BufPtr[OffsetField+2] << 16) | - (BufPtr[OffsetField+3] << 24)); - unsigned Size = ( BufPtr[SizeField ] | - (BufPtr[SizeField +1] << 8) | - (BufPtr[SizeField +2] << 16) | - (BufPtr[SizeField +3] << 24)); - - // Verify that Offset+Size fits in the file. - if (Offset+Size > unsigned(BufEnd-BufPtr)) - return true; - BufPtr += Offset; - BufEnd = BufPtr+Size; - return false; -} - bool BitcodeReader::ParseBitcode() { TheModule = 0; @@ -1383,9 +1341,8 @@ // If we have a wrapper header, parse it and ignore the non-bc file contents. // The magic number is 0x0B17C0DE stored in little endian. - if (BufPtr != BufEnd && BufPtr[0] == 0xDE && BufPtr[1] == 0xC0 && - BufPtr[2] == 0x17 && BufPtr[3] == 0x0B) - if (SkipWrapperHeader(BufPtr, BufEnd)) + if (isBitcodeWrapper(BufPtr, BufEnd)) + if (SkipBitcodeWrapperHeader(BufPtr, BufEnd)) return Error("Invalid bitcode wrapper header"); Stream.init(BufPtr, BufEnd); Modified: llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp?rev=68458&r1=68457&r2=68458&view=diff ============================================================================== --- llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp (original) +++ llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp Mon Apr 6 15:54:32 2009 @@ -30,6 +30,7 @@ #include "llvm/Analysis/Verifier.h" #include "llvm/Bitcode/BitstreamReader.h" #include "llvm/Bitcode/LLVMBitCodes.h" +#include "llvm/Bitcode/ReaderWriter.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MemoryBuffer.h" @@ -382,16 +383,24 @@ /// AnalyzeBitcode - Analyze the bitcode file specified by InputFilename. static int AnalyzeBitcode() { // Read the input file. - MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFilename.c_str()); + MemoryBuffer *MemBuf = MemoryBuffer::getFileOrSTDIN(InputFilename.c_str()); - if (Buffer == 0) + if (MemBuf == 0) return Error("Error reading '" + InputFilename + "'."); - if (Buffer->getBufferSize() & 3) + if (MemBuf->getBufferSize() & 3) return Error("Bitcode stream should be a multiple of 4 bytes in length"); - unsigned char *BufPtr = (unsigned char *)Buffer->getBufferStart(); - BitstreamReader Stream(BufPtr, BufPtr+Buffer->getBufferSize()); + unsigned char *BufPtr = (unsigned char *)MemBuf->getBufferStart(); + unsigned char *EndBufPtr = BufPtr+MemBuf->getBufferSize(); + + // If we have a wrapper header, parse it and ignore the non-bc file contents. + // The magic number is 0x0B17C0DE stored in little endian. + if (isBitcodeWrapper(BufPtr, EndBufPtr)) + if (SkipBitcodeWrapperHeader(BufPtr, EndBufPtr)) + return Error("Invalid bitcode wrapper header"); + + BitstreamReader Stream(BufPtr, EndBufPtr); // Read the stream signature. @@ -425,7 +434,7 @@ if (Dump) std::cerr << "\n\n"; - uint64_t BufferSizeBits = Buffer->getBufferSize()*CHAR_BIT; + uint64_t BufferSizeBits = (EndBufPtr-BufPtr)*CHAR_BIT; // Print a summary of the read file. std::cerr << "Summary of " << InputFilename << ":\n"; std::cerr << " Total size: "; From edwintorok at gmail.com Mon Apr 6 15:57:34 2009 From: edwintorok at gmail.com (Torok Edwin) Date: Mon, 06 Apr 2009 20:57:34 -0000 Subject: [llvm-commits] [llvm] r68459 - in /llvm/trunk: examples/HowToUseJIT/HowToUseJIT.cpp lib/VMCore/Type.cpp Message-ID: <200904062057.n36KvZjD018998@zion.cs.uiuc.edu> Author: edwin Date: Mon Apr 6 15:57:34 2009 New Revision: 68459 URL: http://llvm.org/viewvc/llvm-project?rev=68459&view=rev Log: revert r68457, its crashing in make check. Modified: llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp llvm/trunk/lib/VMCore/Type.cpp Modified: llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp?rev=68459&r1=68458&r2=68459&view=diff ============================================================================== --- llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp (original) +++ llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp Mon Apr 6 15:57:34 2009 @@ -42,7 +42,6 @@ #include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/Interpreter.h" #include "llvm/ExecutionEngine/GenericValue.h" -#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -110,8 +109,5 @@ // Import result of execution: outs() << "Result: " << gv.IntVal << "\n"; - EE->freeMachineCodeForFunction(FooF); - delete EE; - llvm_shutdown(); return 0; } Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=68459&r1=68458&r2=68459&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Mon Apr 6 15:57:34 2009 @@ -666,22 +666,6 @@ std::multimap TypesByHash; public: - ~TypeMapBase() - { - for (std::multimap::iterator I - = TypesByHash.begin(), E = TypesByHash.end(); I != E;) { - Type *Ty = I->second.get(); - if (!Ty->isAbstract() && (isa(Ty) || isa(Ty) || - isa(Ty))) { - TypesByHash.erase(I++); - // PATypeHolder won't destroy it, so we must - Ty->destroy(); - } - else - ++I; - } - } - void RemoveFromTypesByHash(unsigned Hash, const Type *Ty) { std::multimap::iterator I = TypesByHash.lower_bound(Hash); From sabre at nondot.org Mon Apr 6 16:12:29 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 06 Apr 2009 21:12:29 -0000 Subject: [llvm-commits] [llvm] r68460 - /llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h Message-ID: <200904062112.n36LCTiX019618@zion.cs.uiuc.edu> Author: lattner Date: Mon Apr 6 16:12:29 2009 New Revision: 68460 URL: http://llvm.org/viewvc/llvm-project?rev=68460&view=rev Log: simplify to reduce indentation. Modified: llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h Modified: llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h?rev=68460&r1=68459&r2=68460&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h (original) +++ llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h Mon Apr 6 16:12:29 2009 @@ -285,39 +285,7 @@ template void EmitRecord(unsigned Code, SmallVectorImpl &Vals, unsigned Abbrev = 0) { - if (Abbrev) { - unsigned AbbrevNo = Abbrev-bitc::FIRST_APPLICATION_ABBREV; - assert(AbbrevNo < CurAbbrevs.size() && "Invalid abbrev #!"); - BitCodeAbbrev *Abbv = CurAbbrevs[AbbrevNo]; - - EmitCode(Abbrev); - - // Insert the code into Vals to treat it uniformly. - Vals.insert(Vals.begin(), Code); - - unsigned RecordIdx = 0; - for (unsigned i = 0, e = static_cast(Abbv->getNumOperandInfos()); - i != e; ++i) { - const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); - if (Op.isLiteral() || Op.getEncoding() != BitCodeAbbrevOp::Array) { - assert(RecordIdx < Vals.size() && "Invalid abbrev/record"); - EmitAbbreviatedField(Op, Vals[RecordIdx]); - ++RecordIdx; - } else { - // Array case. - assert(i+2 == e && "array op not second to last?"); - const BitCodeAbbrevOp &EltEnc = Abbv->getOperandInfo(++i); - - // Emit a vbr6 to indicate the number of elements present. - EmitVBR(static_cast(Vals.size()-RecordIdx), 6); - - // Emit each field. - for (; RecordIdx != Vals.size(); ++RecordIdx) - EmitAbbreviatedField(EltEnc, Vals[RecordIdx]); - } - } - assert(RecordIdx == Vals.size() && "Not all record operands emitted!"); - } else { + if (!Abbrev) { // If we don't have an abbrev to use, emit this in its fully unabbreviated // form. EmitCode(bitc::UNABBREV_RECORD); @@ -325,7 +293,40 @@ EmitVBR(static_cast(Vals.size()), 6); for (unsigned i = 0, e = static_cast(Vals.size()); i != e; ++i) EmitVBR64(Vals[i], 6); + return; + } + + unsigned AbbrevNo = Abbrev-bitc::FIRST_APPLICATION_ABBREV; + assert(AbbrevNo < CurAbbrevs.size() && "Invalid abbrev #!"); + BitCodeAbbrev *Abbv = CurAbbrevs[AbbrevNo]; + + EmitCode(Abbrev); + + // Insert the code into Vals to treat it uniformly. + Vals.insert(Vals.begin(), Code); + + unsigned RecordIdx = 0; + for (unsigned i = 0, e = static_cast(Abbv->getNumOperandInfos()); + i != e; ++i) { + const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); + if (Op.isLiteral() || Op.getEncoding() != BitCodeAbbrevOp::Array) { + assert(RecordIdx < Vals.size() && "Invalid abbrev/record"); + EmitAbbreviatedField(Op, Vals[RecordIdx]); + ++RecordIdx; + } else { + // Array case. + assert(i+2 == e && "array op not second to last?"); + const BitCodeAbbrevOp &EltEnc = Abbv->getOperandInfo(++i); + + // Emit a vbr6 to indicate the number of elements present. + EmitVBR(static_cast(Vals.size()-RecordIdx), 6); + + // Emit each field. + for (; RecordIdx != Vals.size(); ++RecordIdx) + EmitAbbreviatedField(EltEnc, Vals[RecordIdx]); + } } + assert(RecordIdx == Vals.size() && "Not all record operands emitted!"); } //===--------------------------------------------------------------------===// From sabre at nondot.org Mon Apr 6 16:20:02 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 06 Apr 2009 21:20:02 -0000 Subject: [llvm-commits] [llvm] r68461 - /llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h Message-ID: <200904062120.n36LK2KB019967@zion.cs.uiuc.edu> Author: lattner Date: Mon Apr 6 16:20:01 2009 New Revision: 68461 URL: http://llvm.org/viewvc/llvm-project?rev=68461&view=rev Log: simplify code a bit. Modified: llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h Modified: llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h?rev=68461&r1=68460&r2=68461&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h (original) +++ llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h Mon Apr 6 16:20:01 2009 @@ -252,18 +252,23 @@ //===--------------------------------------------------------------------===// private: + /// EmitAbbreviatedLiteral - Emit a literal value according to its abbrev + /// record. This is a no-op, since the abbrev specifies the literal to use. + template + void EmitAbbreviatedLiteral(const BitCodeAbbrevOp &Op, uintty V) { + assert(Op.isLiteral() && "Not a literal"); + // If the abbrev specifies the literal value to use, don't emit + // anything. + assert(V == Op.getLiteralValue() && + "Invalid abbrev for record!"); + } + /// EmitAbbreviatedField - Emit a single scalar field value with the specified /// encoding. template 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; - } - + assert(!Op.isLiteral() && "Literals should use EmitAbbreviatedLiteral!"); + // Encode the value as we are commanded. switch (Op.getEncoding()) { default: assert(0 && "Unknown encoding!"); @@ -278,6 +283,7 @@ break; } } + public: /// EmitRecord - Emit the specified record to the stream, using an abbrev if @@ -309,7 +315,11 @@ for (unsigned i = 0, e = static_cast(Abbv->getNumOperandInfos()); i != e; ++i) { const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); - if (Op.isLiteral() || Op.getEncoding() != BitCodeAbbrevOp::Array) { + if (Op.isLiteral()) { + assert(RecordIdx < Vals.size() && "Invalid abbrev/record"); + EmitAbbreviatedLiteral(Op, Vals[RecordIdx]); + ++RecordIdx; + } else if (Op.getEncoding() != BitCodeAbbrevOp::Array) { assert(RecordIdx < Vals.size() && "Invalid abbrev/record"); EmitAbbreviatedField(Op, Vals[RecordIdx]); ++RecordIdx; From sabre at nondot.org Mon Apr 6 16:34:59 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 06 Apr 2009 21:34:59 -0000 Subject: [llvm-commits] [llvm] r68462 - /llvm/trunk/include/llvm/Bitcode/BitstreamReader.h Message-ID: <200904062134.n36LYxVm020536@zion.cs.uiuc.edu> Author: lattner Date: Mon Apr 6 16:34:58 2009 New Revision: 68462 URL: http://llvm.org/viewvc/llvm-project?rev=68462&view=rev Log: reduce indentation with early-out Modified: llvm/trunk/include/llvm/Bitcode/BitstreamReader.h Modified: llvm/trunk/include/llvm/Bitcode/BitstreamReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitstreamReader.h?rev=68462&r1=68461&r2=68462&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/BitstreamReader.h (original) +++ llvm/trunk/include/llvm/Bitcode/BitstreamReader.h Mon Apr 6 16:34:58 2009 @@ -342,20 +342,20 @@ if (Op.isLiteral()) { // If the abbrev specifies the literal value to use, use it. Vals.push_back(Op.getLiteralValue()); - } else { - // Decode the value as we are commanded. - switch (Op.getEncoding()) { - default: assert(0 && "Unknown encoding!"); - case BitCodeAbbrevOp::Fixed: - Vals.push_back(Read((unsigned)Op.getEncodingData())); - break; - case BitCodeAbbrevOp::VBR: - Vals.push_back(ReadVBR64((unsigned)Op.getEncodingData())); - break; - case BitCodeAbbrevOp::Char6: - Vals.push_back(BitCodeAbbrevOp::DecodeChar6(Read(6))); - break; - } + return; + } + // Decode the value as we are commanded. + switch (Op.getEncoding()) { + default: assert(0 && "Unknown encoding!"); + case BitCodeAbbrevOp::Fixed: + Vals.push_back(Read((unsigned)Op.getEncodingData())); + break; + case BitCodeAbbrevOp::VBR: + Vals.push_back(ReadVBR64((unsigned)Op.getEncodingData())); + break; + case BitCodeAbbrevOp::Char6: + Vals.push_back(BitCodeAbbrevOp::DecodeChar6(Read(6))); + break; } } public: From sabre at nondot.org Mon Apr 6 16:37:10 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 06 Apr 2009 21:37:10 -0000 Subject: [llvm-commits] [llvm] r68463 - /llvm/trunk/include/llvm/Bitcode/BitstreamReader.h Message-ID: <200904062137.n36LbBJX020620@zion.cs.uiuc.edu> Author: lattner Date: Mon Apr 6 16:37:10 2009 New Revision: 68463 URL: http://llvm.org/viewvc/llvm-project?rev=68463&view=rev Log: split ReadAbbreviatedLiteral out of ReadAbbreviatedField. Modified: llvm/trunk/include/llvm/Bitcode/BitstreamReader.h Modified: llvm/trunk/include/llvm/Bitcode/BitstreamReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitstreamReader.h?rev=68463&r1=68462&r2=68463&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/BitstreamReader.h (original) +++ llvm/trunk/include/llvm/Bitcode/BitstreamReader.h Mon Apr 6 16:37:10 2009 @@ -337,13 +337,17 @@ //===--------------------------------------------------------------------===// private: + void ReadAbbreviatedLiteral(const BitCodeAbbrevOp &Op, + SmallVectorImpl &Vals) { + assert(Op.isLiteral() && "Not a literal"); + // If the abbrev specifies the literal value to use, use it. + Vals.push_back(Op.getLiteralValue()); + } + void ReadAbbreviatedField(const BitCodeAbbrevOp &Op, SmallVectorImpl &Vals) { - if (Op.isLiteral()) { - // If the abbrev specifies the literal value to use, use it. - Vals.push_back(Op.getLiteralValue()); - return; - } + assert(!Op.isLiteral() && "Use ReadAbbreviatedLiteral for literals!"); + // Decode the value as we are commanded. switch (Op.getEncoding()) { default: assert(0 && "Unknown encoding!"); @@ -374,7 +378,9 @@ for (unsigned i = 0, e = Abbv->getNumOperandInfos(); i != e; ++i) { const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); - if (Op.isLiteral() || Op.getEncoding() != BitCodeAbbrevOp::Array) { + if (Op.isLiteral()) { + ReadAbbreviatedLiteral(Op, Vals); + } else if (Op.getEncoding() != BitCodeAbbrevOp::Array) { ReadAbbreviatedField(Op, Vals); } else { // Array case. Read the number of elements as a vbr6. From bob.wilson at apple.com Mon Apr 6 16:46:51 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 06 Apr 2009 21:46:51 -0000 Subject: [llvm-commits] [llvm] r68464 - in /llvm/trunk: lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/2009-04-06-AsmModifier.ll Message-ID: <200904062146.n36Lkpv2021018@zion.cs.uiuc.edu> Author: bwilson Date: Mon Apr 6 16:46:51 2009 New Revision: 68464 URL: http://llvm.org/viewvc/llvm-project?rev=68464&view=rev Log: Handle 'a' modifier in ARM inline assembly. Patch by Richard Pennington. Added: llvm/trunk/test/CodeGen/ARM/2009-04-06-AsmModifier.ll Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=68464&r1=68463&r2=68464&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Mon Apr 6 16:46:51 2009 @@ -739,7 +739,10 @@ switch (ExtraCode[0]) { default: return true; // Unknown modifier. + case 'a': // Don't print "#" before a global var name or constant. case 'c': // Don't print "$" before a global var name or constant. + printOperand(MI, OpNo, "no_hash"); + return false; case 'P': // Print a VFP double precision register. printOperand(MI, OpNo); return false; Added: llvm/trunk/test/CodeGen/ARM/2009-04-06-AsmModifier.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-04-06-AsmModifier.ll?rev=68464&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-04-06-AsmModifier.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2009-04-06-AsmModifier.ll Mon Apr 6 16:46:51 2009 @@ -0,0 +1,19 @@ +; RUN: llvm-as < %s | llc -march=arm | grep {swi 107} + +define i32 @_swilseek(i32) nounwind { +entry: + %ptr = alloca i32 ; [#uses=2] + store i32 %0, i32* %ptr + %retval = alloca i32 ; [#uses=2] + store i32 0, i32* %retval + %res = alloca i32 ; [#uses=0] + %fh = alloca i32 ; [#uses=1] + %1 = load i32* %fh ; [#uses=1] + %2 = load i32* %ptr ; [#uses=1] + %3 = call i32* asm "mov r0, $2; mov r1, $3; swi ${1:a}; mov $0, r0", "=r,i,r,r,~{r0},~{r1}"(i32 107, i32 %1, i32 %2) nounwind ; [#uses=0] + br label %return + +return: ; preds = %entry + %4 = load i32* %retval ; [#uses=1] + ret i32 %4 +} From sabre at nondot.org Mon Apr 6 16:50:40 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 06 Apr 2009 21:50:40 -0000 Subject: [llvm-commits] [llvm] r68465 - in /llvm/trunk: docs/BitCodeFormat.html include/llvm/Bitcode/BitCodes.h include/llvm/Bitcode/BitstreamReader.h include/llvm/Bitcode/BitstreamWriter.h Message-ID: <200904062150.n36LoeCY021210@zion.cs.uiuc.edu> Author: lattner Date: Mon Apr 6 16:50:39 2009 New Revision: 68465 URL: http://llvm.org/viewvc/llvm-project?rev=68465&view=rev Log: add a new Blob encoding abbreviation for bitcode files that emits elements in a form that is efficient for the reader to just get a pointer in memory and start reading. APIs to do efficient reading and writing are still todo. Modified: llvm/trunk/docs/BitCodeFormat.html llvm/trunk/include/llvm/Bitcode/BitCodes.h llvm/trunk/include/llvm/Bitcode/BitstreamReader.h llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h Modified: llvm/trunk/docs/BitCodeFormat.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/BitCodeFormat.html?rev=68465&r1=68464&r2=68465&view=diff ============================================================================== --- llvm/trunk/docs/BitCodeFormat.html (original) +++ llvm/trunk/docs/BitCodeFormat.html Mon Apr 6 16:50:39 2009 @@ -478,6 +478,13 @@

  • Char6: This field should be emitted as a char6-encoded value. This operand type takes no extra data.
  • +
  • Blob: This field is emitted as a vbr6, followed by padding to a + 32-bit boundary (for alignment) and an array of 8-bit objects. The array of + bytes is further followed by tail padding to ensure that its total length is + a multiple of 4 bytes. This makes it very efficient for the reader to + decode the data without having to make a copy of it: it can use a pointer to + the data in the mapped in file and poke directly at it. A blob may only + occur as the last operand of an abbreviation.
  • Modified: llvm/trunk/include/llvm/Bitcode/BitCodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitCodes.h?rev=68465&r1=68464&r2=68465&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/BitCodes.h (original) +++ llvm/trunk/include/llvm/Bitcode/BitCodes.h Mon Apr 6 16:50:39 2009 @@ -88,7 +88,8 @@ Fixed = 1, // A fixed width field, Val specifies number of bits. VBR = 2, // A VBR field where Val specifies the width of each chunk. Array = 3, // A sequence of fields, next field species elt encoding. - Char6 = 4 // A 6-bit fixed field which maps to [a-zA-Z0-9._]. + Char6 = 4, // A 6-bit fixed field which maps to [a-zA-Z0-9._]. + Blob = 5 // 8-bit aligned array of 8-bit characters. }; explicit BitCodeAbbrevOp(uint64_t V) : Val(V), IsLiteral(true) {} @@ -117,6 +118,7 @@ return true; case Array: case Char6: + case Blob: return false; } } Modified: llvm/trunk/include/llvm/Bitcode/BitstreamReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitstreamReader.h?rev=68465&r1=68464&r2=68465&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/BitstreamReader.h (original) +++ llvm/trunk/include/llvm/Bitcode/BitstreamReader.h Mon Apr 6 16:50:39 2009 @@ -149,7 +149,7 @@ } // If we run out of data, stop at the end of the stream. - if (LastChar == NextChar) { + if (NextChar == LastChar) { CurWord = 0; BitsInCurWord = 0; return 0; @@ -380,9 +380,7 @@ const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); if (Op.isLiteral()) { ReadAbbreviatedLiteral(Op, Vals); - } else if (Op.getEncoding() != BitCodeAbbrevOp::Array) { - ReadAbbreviatedField(Op, Vals); - } else { + } else if (Op.getEncoding() == BitCodeAbbrevOp::Array) { // Array case. Read the number of elements as a vbr6. unsigned NumElts = ReadVBR(6); @@ -393,6 +391,29 @@ // Read all the elements. for (; NumElts; --NumElts) ReadAbbreviatedField(EltEnc, Vals); + } else if (Op.getEncoding() == BitCodeAbbrevOp::Blob) { + // Blob case. Read the number of bytes as a vbr6. + unsigned NumElts = ReadVBR(6); + SkipToWord(); // 32-bit alignment + + // Figure out where the end of this blob will be including tail padding. + const unsigned char *NewEnd = NextChar+((NumElts+3)&~3); + + // If this would read off the end of the bitcode file, just set the + // record to empty and return. + if (NewEnd > LastChar) { + Vals.append(NumElts, 0); + NextChar = LastChar; + break; + } + + // Otherwise, read the number of bytes. + for (; NumElts; ++NextChar, --NumElts) + Vals.push_back(*NextChar); + // Skip over tail padding. + NextChar = NewEnd; + } else { + ReadAbbreviatedField(Op, Vals); } } Modified: llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h?rev=68465&r1=68464&r2=68465&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h (original) +++ llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h Mon Apr 6 16:50:39 2009 @@ -319,11 +319,7 @@ assert(RecordIdx < Vals.size() && "Invalid abbrev/record"); EmitAbbreviatedLiteral(Op, Vals[RecordIdx]); ++RecordIdx; - } else if (Op.getEncoding() != BitCodeAbbrevOp::Array) { - assert(RecordIdx < Vals.size() && "Invalid abbrev/record"); - EmitAbbreviatedField(Op, Vals[RecordIdx]); - ++RecordIdx; - } else { + } else if (Op.getEncoding() == BitCodeAbbrevOp::Array) { // Array case. assert(i+2 == e && "array op not second to last?"); const BitCodeAbbrevOp &EltEnc = Abbv->getOperandInfo(++i); @@ -334,6 +330,26 @@ // Emit each field. for (; RecordIdx != Vals.size(); ++RecordIdx) EmitAbbreviatedField(EltEnc, Vals[RecordIdx]); + } else if (Op.getEncoding() == BitCodeAbbrevOp::Blob) { + // Emit a vbr6 to indicate the number of elements present. + EmitVBR(static_cast(Vals.size()-RecordIdx), 6); + // Flush to a 32-bit alignment boundary. + FlushToWord(); + assert((Out.size() & 3) == 0 && "Not 32-bit aligned"); + + // Emit each field as a literal byte. + for (; RecordIdx != Vals.size(); ++RecordIdx) { + assert(Vals[RecordIdx] < 256 && "Value too large to emit as blob"); + Out.push_back((unsigned char)Vals[RecordIdx]); + } + // Align end to 32-bits. + while (Out.size() & 3) + Out.push_back(0); + + } else { // Single scalar field. + assert(RecordIdx < Vals.size() && "Invalid abbrev/record"); + EmitAbbreviatedField(Op, Vals[RecordIdx]); + ++RecordIdx; } } assert(RecordIdx == Vals.size() && "Not all record operands emitted!"); From sabre at nondot.org Mon Apr 6 17:26:26 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 06 Apr 2009 22:26:26 -0000 Subject: [llvm-commits] [llvm] r68469 - /llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h Message-ID: <200904062226.n36MQQpH022512@zion.cs.uiuc.edu> Author: lattner Date: Mon Apr 6 17:26:26 2009 New Revision: 68469 URL: http://llvm.org/viewvc/llvm-project?rev=68469&view=rev Log: Add a new EmitRecordWithBlob API that allows a blob to be emitted without converting each byte to a uint64_t to stick in a SmallVector. Modified: llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h Modified: llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h?rev=68469&r1=68468&r2=68469&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h (original) +++ llvm/trunk/include/llvm/Bitcode/BitstreamWriter.h Mon Apr 6 17:26:26 2009 @@ -284,33 +284,19 @@ } } -public: - - /// EmitRecord - Emit the specified record to the stream, using an abbrev if - /// we have one to compress the output. + /// EmitRecordWithAbbrevImpl - This is the core implementation of the record + /// emission code. If BlobData is non-null, then it specifies an array of + /// data that should be emitted as part of the Blob or Array operand that is + /// known to exist at the end of the the record. template - void EmitRecord(unsigned Code, SmallVectorImpl &Vals, - unsigned Abbrev = 0) { - if (!Abbrev) { - // If we don't have an abbrev to use, emit this in its fully unabbreviated - // form. - EmitCode(bitc::UNABBREV_RECORD); - EmitVBR(Code, 6); - EmitVBR(static_cast(Vals.size()), 6); - for (unsigned i = 0, e = static_cast(Vals.size()); i != e; ++i) - EmitVBR64(Vals[i], 6); - return; - } - + void EmitRecordWithAbbrevImpl(unsigned Abbrev, SmallVectorImpl &Vals, + const char *BlobData, unsigned BlobLen) { unsigned AbbrevNo = Abbrev-bitc::FIRST_APPLICATION_ABBREV; assert(AbbrevNo < CurAbbrevs.size() && "Invalid abbrev #!"); BitCodeAbbrev *Abbv = CurAbbrevs[AbbrevNo]; EmitCode(Abbrev); - // Insert the code into Vals to treat it uniformly. - Vals.insert(Vals.begin(), Code); - unsigned RecordIdx = 0; for (unsigned i = 0, e = static_cast(Abbv->getNumOperandInfos()); i != e; ++i) { @@ -324,23 +310,57 @@ assert(i+2 == e && "array op not second to last?"); const BitCodeAbbrevOp &EltEnc = Abbv->getOperandInfo(++i); - // Emit a vbr6 to indicate the number of elements present. - EmitVBR(static_cast(Vals.size()-RecordIdx), 6); - - // Emit each field. - for (; RecordIdx != Vals.size(); ++RecordIdx) - EmitAbbreviatedField(EltEnc, Vals[RecordIdx]); + // If this record has blob data, emit it, otherwise we must have record + // entries to encode this way. + if (BlobData) { + assert(RecordIdx == Vals.size() && + "Blob data and record entries specified for array!"); + // Emit a vbr6 to indicate the number of elements present. + EmitVBR(static_cast(BlobLen), 6); + + // Emit each field. + for (unsigned i = 0; i != BlobLen; ++i) + EmitAbbreviatedField(EltEnc, (unsigned char)BlobData[i]); + + // Know that blob data is consumed for assertion below. + BlobData = 0; + } else { + // Emit a vbr6 to indicate the number of elements present. + EmitVBR(static_cast(Vals.size()-RecordIdx), 6); + + // Emit each field. + for (unsigned e = Vals.size(); RecordIdx != e; ++RecordIdx) + EmitAbbreviatedField(EltEnc, Vals[RecordIdx]); + } } else if (Op.getEncoding() == BitCodeAbbrevOp::Blob) { + // If this record has blob data, emit it, otherwise we must have record + // entries to encode this way. + // Emit a vbr6 to indicate the number of elements present. - EmitVBR(static_cast(Vals.size()-RecordIdx), 6); + if (BlobData) { + EmitVBR(static_cast(BlobLen), 6); + assert(RecordIdx == Vals.size() && + "Blob data and record entries specified for blob operand!"); + } else { + EmitVBR(static_cast(Vals.size()-RecordIdx), 6); + } + // Flush to a 32-bit alignment boundary. FlushToWord(); assert((Out.size() & 3) == 0 && "Not 32-bit aligned"); // Emit each field as a literal byte. - for (; RecordIdx != Vals.size(); ++RecordIdx) { - assert(Vals[RecordIdx] < 256 && "Value too large to emit as blob"); - Out.push_back((unsigned char)Vals[RecordIdx]); + if (BlobData) { + for (unsigned i = 0; i != BlobLen; ++i) + Out.push_back((unsigned char)BlobData[i]); + + // Know that blob data is consumed for assertion below. + BlobData = 0; + } else { + for (unsigned e = Vals.size(); RecordIdx != e; ++RecordIdx) { + assert(Vals[RecordIdx] < 256 && "Value too large to emit as blob"); + Out.push_back((unsigned char)Vals[RecordIdx]); + } } // Align end to 32-bits. while (Out.size() & 3) @@ -353,8 +373,61 @@ } } assert(RecordIdx == Vals.size() && "Not all record operands emitted!"); + assert(BlobData == 0 && + "Blob data specified for record that doesn't use it!"); + } + +public: + + /// EmitRecord - Emit the specified record to the stream, using an abbrev if + /// we have one to compress the output. + template + void EmitRecord(unsigned Code, SmallVectorImpl &Vals, + unsigned Abbrev = 0) { + if (!Abbrev) { + // If we don't have an abbrev to use, emit this in its fully unabbreviated + // form. + EmitCode(bitc::UNABBREV_RECORD); + EmitVBR(Code, 6); + EmitVBR(static_cast(Vals.size()), 6); + for (unsigned i = 0, e = static_cast(Vals.size()); i != e; ++i) + EmitVBR64(Vals[i], 6); + return; + } + + // Insert the code into Vals to treat it uniformly. + Vals.insert(Vals.begin(), Code); + + EmitRecordWithAbbrev(Abbrev, Vals); + } + + /// EmitRecordWithAbbrev - Emit a record with the specified abbreviation. + /// Unlike EmitRecord, the code for the record should be included in Vals as + /// the first entry. + template + void EmitRecordWithAbbrev(unsigned Abbrev, SmallVectorImpl &Vals) { + EmitRecordWithAbbrevImpl(Abbrev, Vals, 0, 0); + } + + /// EmitRecordWithBlob - Emit the specified record to the stream, using an + /// abbrev that includes a blob at the end. The blob data to emit is + /// specified by the pointer and length specified at the end. In contrast to + /// EmitRecord, this routine expects that the first entry in Vals is the code + /// of the record. + template + void EmitRecordWithBlob(unsigned Abbrev, SmallVectorImpl &Vals, + const char *BlobData, unsigned BlobLen) { + EmitRecordWithAbbrevImpl(Abbrev, Vals, BlobData, BlobLen); } + /// EmitRecordWithArray - Just like EmitRecordWithBlob, works with records + /// that end with an array. + template + void EmitRecordWithArray(unsigned Abbrev, SmallVectorImpl &Vals, + const char *ArrayData, unsigned ArrayLen) { + EmitRecordWithAbbrevImpl(Abbrev, Vals, ArrayData, ArrayLen); + } + //===--------------------------------------------------------------------===// // Abbrev Emission //===--------------------------------------------------------------------===// From sabre at nondot.org Mon Apr 6 17:43:46 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 06 Apr 2009 22:43:46 -0000 Subject: [llvm-commits] [llvm] r68471 - /llvm/trunk/include/llvm/Bitcode/BitstreamReader.h Message-ID: <200904062243.n36MhkX5023209@zion.cs.uiuc.edu> Author: lattner Date: Mon Apr 6 17:43:46 2009 New Revision: 68471 URL: http://llvm.org/viewvc/llvm-project?rev=68471&view=rev Log: allow clients to look up abbrev id's Modified: llvm/trunk/include/llvm/Bitcode/BitstreamReader.h Modified: llvm/trunk/include/llvm/Bitcode/BitstreamReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitstreamReader.h?rev=68471&r1=68470&r2=68471&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/BitstreamReader.h (original) +++ llvm/trunk/include/llvm/Bitcode/BitstreamReader.h Mon Apr 6 17:43:46 2009 @@ -363,6 +363,14 @@ } } public: + + /// getAbbrev - Return the abbreviation for the specified AbbrevId. + const BitCodeAbbrev *getAbbrev(unsigned AbbrevID) { + unsigned AbbrevNo = AbbrevID-bitc::FIRST_APPLICATION_ABBREV; + assert(AbbrevNo < CurAbbrevs.size() && "Invalid abbrev #!"); + return CurAbbrevs[AbbrevNo]; + } + unsigned ReadRecord(unsigned AbbrevID, SmallVectorImpl &Vals) { if (AbbrevID == bitc::UNABBREV_RECORD) { unsigned Code = ReadVBR(6); @@ -372,9 +380,7 @@ return Code; } - unsigned AbbrevNo = AbbrevID-bitc::FIRST_APPLICATION_ABBREV; - assert(AbbrevNo < CurAbbrevs.size() && "Invalid abbrev #!"); - BitCodeAbbrev *Abbv = CurAbbrevs[AbbrevNo]; + const BitCodeAbbrev *Abbv = getAbbrev(AbbrevID); for (unsigned i = 0, e = Abbv->getNumOperandInfos(); i != e; ++i) { const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); From sabre at nondot.org Mon Apr 6 17:44:40 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 06 Apr 2009 22:44:40 -0000 Subject: [llvm-commits] [llvm] r68472 - /llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp Message-ID: <200904062244.n36Miebw023252@zion.cs.uiuc.edu> Author: lattner Date: Mon Apr 6 17:44:40 2009 New Revision: 68472 URL: http://llvm.org/viewvc/llvm-project?rev=68472&view=rev Log: stub out code for reading record with blobs as blobs. Not active yet. Modified: llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp Modified: llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp?rev=68472&r1=68471&r2=68472&view=diff ============================================================================== --- llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp (original) +++ llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp Mon Apr 6 17:44:40 2009 @@ -341,12 +341,33 @@ ++BlockStats.NumAbbrevs; break; default: + Record.clear(); + bool HasBlob = false; + ++BlockStats.NumRecords; - if (AbbrevID != bitc::UNABBREV_RECORD) + if (AbbrevID != bitc::UNABBREV_RECORD) { ++BlockStats.NumAbbreviatedRecords; - - Record.clear(); - unsigned Code = Stream.ReadRecord(AbbrevID, Record); + const BitCodeAbbrev *Abbv = Stream.getAbbrev(AbbrevID); + if (Abbv->getNumOperandInfos() != 0) { + const BitCodeAbbrevOp &LastOp = + Abbv->getOperandInfo(Abbv->getNumOperandInfos()-1); + // If the last operand is a blob, then this record has blob data. + if (LastOp.isEncoding() && + LastOp.getEncoding() == BitCodeAbbrevOp::Blob) + HasBlob = true; + } + } + + unsigned Code; + const char *BlobStart = 0; + unsigned BlobLen = 0; + if (!HasBlob) + Code = Stream.ReadRecord(AbbrevID, Record); + else { + Code = Stream.ReadRecord(AbbrevID, Record); + BlobStart = BlobStart; + BlobLen = BlobLen; + } // Increment the # occurrences of this code. if (BlockStats.CodeFreq.size() <= Code) From ed at 80386.nl Mon Apr 6 08:07:12 2009 From: ed at 80386.nl (Ed Schouten) Date: Mon, 06 Apr 2009 13:07:12 -0000 Subject: [llvm-commits] [llvm] r68443 - in /llvm/trunk: lib/Transforms/Scalar/SimplifyLibCalls.cpp test/Transforms/SimplifyLibCalls/StrCat.ll Message-ID: <200904061307.n36D7Gqo032412@zion.cs.uiuc.edu> Author: ed Date: Mon Apr 6 08:06:48 2009 New Revision: 68443 URL: http://llvm.org/viewvc/llvm-project?rev=68443&view=rev Log: Let the strcat optimizer return the pointer to the start of the buffer, instead of the place where it started to perform the string copy. - PR3661 - Patch by Benjamin Kramer! Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp llvm/trunk/test/Transforms/SimplifyLibCalls/StrCat.ll Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=68443&r1=68442&r2=68443&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Mon Apr 6 08:06:48 2009 @@ -514,11 +514,11 @@ // Now that we have the destination's length, we must index into the // destination's pointer to get the actual memcpy destination (end of // the string .. we're concatenating). - Dst = B.CreateGEP(Dst, DstLen, "endptr"); + Value *CpyDst = B.CreateGEP(Dst, DstLen, "endptr"); // We have enough information to now generate the memcpy call to do the // concatenation for us. Make a memcpy to copy the nul byte with align = 1. - EmitMemCpy(Dst, Src, ConstantInt::get(TD->getIntPtrType(), Len+1), 1, B); + EmitMemCpy(CpyDst, Src, ConstantInt::get(TD->getIntPtrType(), Len+1), 1, B); return Dst; } }; Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/StrCat.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/StrCat.ll?rev=68443&r1=68442&r2=68443&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/StrCat.ll (original) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/StrCat.ll Mon Apr 6 08:06:48 2009 @@ -1,6 +1,9 @@ ; Test that the StrCatOptimizer works correctly +; PR3661 ; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \ ; RUN: not grep {call.*strcat} +; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \ +; RUN: grep {puts.*%arg1} @hello = constant [6 x i8] c"hello\00" ; <[6 x i8]*> [#uses=1] @null = constant [1 x i8] zeroinitializer ; <[1 x i8]*> [#uses=1] From gohman at apple.com Mon Apr 6 19:26:30 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 07 Apr 2009 00:26:30 -0000 Subject: [llvm-commits] [llvm] r68479 - in /llvm/trunk/lib/Target: IA64/AsmPrinter/ Mips/AsmPrinter/ Message-ID: <200904070026.n370QUwG027547@zion.cs.uiuc.edu> Author: djg Date: Mon Apr 6 19:26:29 2009 New Revision: 68479 URL: http://llvm.org/viewvc/llvm-project?rev=68479&view=rev Log: Add svn:ignore properties. Modified: llvm/trunk/lib/Target/IA64/AsmPrinter/ (props changed) llvm/trunk/lib/Target/Mips/AsmPrinter/ (props changed) Propchange: llvm/trunk/lib/Target/IA64/AsmPrinter/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Mon Apr 6 19:26:29 2009 @@ -0,0 +1,3 @@ +Debug +Release +Release-Asserts Propchange: llvm/trunk/lib/Target/Mips/AsmPrinter/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Mon Apr 6 19:26:29 2009 @@ -0,0 +1,3 @@ +Debug +Release +Release-Asserts From sabre at nondot.org Mon Apr 6 21:55:54 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Apr 2009 02:55:54 -0000 Subject: [llvm-commits] [llvm] r68485 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Message-ID: <200904070255.n372ts3m000767@zion.cs.uiuc.edu> Author: lattner Date: Mon Apr 6 21:55:53 2009 New Revision: 68485 URL: http://llvm.org/viewvc/llvm-project?rev=68485&view=rev Log: remove empty section 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=68485&r1=68484&r2=68485&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Mon Apr 6 21:55:53 2009 @@ -569,10 +569,6 @@ } //===----------------------------------------------------------------------===// -// Addressing Mode Analysis and Optimization -//===----------------------------------------------------------------------===// - -//===----------------------------------------------------------------------===// // Memory Optimization //===----------------------------------------------------------------------===// From sabre at nondot.org Mon Apr 6 21:56:46 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Apr 2009 02:56:46 -0000 Subject: [llvm-commits] [llvm] r68486 - in /llvm/trunk: include/llvm/Bitcode/BitstreamReader.h tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp Message-ID: <200904070256.n372ukTT000833@zion.cs.uiuc.edu> Author: lattner Date: Mon Apr 6 21:56:46 2009 New Revision: 68486 URL: http://llvm.org/viewvc/llvm-project?rev=68486&view=rev Log: Add an API for the bitstream reader to read blobs and return them by reference, instead of packing each byte into a smallvector. Modified: llvm/trunk/include/llvm/Bitcode/BitstreamReader.h llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp Modified: llvm/trunk/include/llvm/Bitcode/BitstreamReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitstreamReader.h?rev=68486&r1=68485&r2=68486&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/BitstreamReader.h (original) +++ llvm/trunk/include/llvm/Bitcode/BitstreamReader.h Mon Apr 6 21:56:46 2009 @@ -371,7 +371,8 @@ return CurAbbrevs[AbbrevNo]; } - unsigned ReadRecord(unsigned AbbrevID, SmallVectorImpl &Vals) { + unsigned ReadRecord(unsigned AbbrevID, SmallVectorImpl &Vals, + const char **BlobStart = 0, unsigned *BlobLen = 0) { if (AbbrevID == bitc::UNABBREV_RECORD) { unsigned Code = ReadVBR(6); unsigned NumElts = ReadVBR(6); @@ -413,9 +414,15 @@ break; } - // Otherwise, read the number of bytes. - for (; NumElts; ++NextChar, --NumElts) - Vals.push_back(*NextChar); + // Otherwise, read the number of bytes. If we can return a reference to + // the data, do so to avoid copying it. + if (BlobStart) { + *BlobStart = (const char*)NextChar; + *BlobLen = NumElts; + } else { + for (; NumElts; ++NextChar, --NumElts) + Vals.push_back(*NextChar); + } // Skip over tail padding. NextChar = NewEnd; } else { @@ -428,6 +435,12 @@ return Code; } + unsigned ReadRecord(unsigned AbbrevID, SmallVectorImpl &Vals, + const char *&BlobStart, unsigned &BlobLen) { + return ReadRecord(AbbrevID, Vals, &BlobStart, &BlobLen); + } + + //===--------------------------------------------------------------------===// // Abbrev Processing //===--------------------------------------------------------------------===// Modified: llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp?rev=68486&r1=68485&r2=68486&view=diff ============================================================================== --- llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp (original) +++ llvm/trunk/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp Mon Apr 6 21:56:46 2009 @@ -342,32 +342,14 @@ break; default: Record.clear(); - bool HasBlob = false; ++BlockStats.NumRecords; - if (AbbrevID != bitc::UNABBREV_RECORD) { + if (AbbrevID != bitc::UNABBREV_RECORD) ++BlockStats.NumAbbreviatedRecords; - const BitCodeAbbrev *Abbv = Stream.getAbbrev(AbbrevID); - if (Abbv->getNumOperandInfos() != 0) { - const BitCodeAbbrevOp &LastOp = - Abbv->getOperandInfo(Abbv->getNumOperandInfos()-1); - // If the last operand is a blob, then this record has blob data. - if (LastOp.isEncoding() && - LastOp.getEncoding() == BitCodeAbbrevOp::Blob) - HasBlob = true; - } - } - unsigned Code; const char *BlobStart = 0; unsigned BlobLen = 0; - if (!HasBlob) - Code = Stream.ReadRecord(AbbrevID, Record); - else { - Code = Stream.ReadRecord(AbbrevID, Record); - BlobStart = BlobStart; - BlobLen = BlobLen; - } + unsigned Code = Stream.ReadRecord(AbbrevID, Record, BlobStart, BlobLen); // Increment the # occurrences of this code. if (BlockStats.CodeFreq.size() <= Code) @@ -388,7 +370,24 @@ for (unsigned i = 0, e = Record.size(); i != e; ++i) std::cerr << " op" << i << "=" << (int64_t)Record[i]; - std::cerr << "/>\n"; + std::cerr << "/>"; + + if (BlobStart) { + std::cerr << " blob data = "; + bool BlobIsPrintable = true; + for (unsigned i = 0; i != BlobLen; ++i) + if (!isprint(BlobStart[i])) { + BlobIsPrintable = false; + break; + } + + if (BlobIsPrintable) + std::cerr << "'" << std::string(BlobStart, BlobStart+BlobLen) <<"'"; + else + std::cerr << "unprintable, " << BlobLen << " bytes."; + } + + std::cerr << "\n"; } break; From kremenek at apple.com Mon Apr 6 23:59:19 2009 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 07 Apr 2009 04:59:19 -0000 Subject: [llvm-commits] [llvm] r68498 - /llvm/tags/checker/checker-0.183/ Message-ID: <200904070459.n374xJ6H004959@zion.cs.uiuc.edu> Author: kremenek Date: Mon Apr 6 23:59:19 2009 New Revision: 68498 URL: http://llvm.org/viewvc/llvm-project?rev=68498&view=rev Log: Tagging checker-0.183. Added: llvm/tags/checker/checker-0.183/ - copied from r68497, llvm/trunk/ From sabre at nondot.org Tue Apr 7 00:03:34 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Apr 2009 05:03:34 -0000 Subject: [llvm-commits] [llvm] r68500 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2009-04-06-GEP-Index-Crash.ll Message-ID: <200904070503.n3753YLS005129@zion.cs.uiuc.edu> Author: lattner Date: Tue Apr 7 00:03:34 2009 New Revision: 68500 URL: http://llvm.org/viewvc/llvm-project?rev=68500&view=rev Log: fix rdar://6762290, a crash compiling cxx filt with clang. Added: llvm/trunk/test/Transforms/InstCombine/2009-04-06-GEP-Index-Crash.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=68500&r1=68499&r2=68500&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue Apr 7 00:03:34 2009 @@ -5223,10 +5223,11 @@ // Convert to correct type. if (Op->getType() != IntPtrTy) { if (Constant *OpC = dyn_cast(Op)) - Op = ConstantExpr::getSExt(OpC, IntPtrTy); + Op = ConstantExpr::getIntegerCast(OpC, IntPtrTy, true); else - Op = IC.InsertNewInstBefore(new SExtInst(Op, IntPtrTy, - Op->getName()+".c"), I); + Op = IC.InsertNewInstBefore(CastInst::CreateIntegerCast(Op, IntPtrTy, + true, + Op->getName()+".c"), I); } if (Size != 1) { Constant *Scale = ConstantInt::get(IntPtrTy, Size); Added: llvm/trunk/test/Transforms/InstCombine/2009-04-06-GEP-Index-Crash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2009-04-06-GEP-Index-Crash.ll?rev=68500&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2009-04-06-GEP-Index-Crash.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/2009-04-06-GEP-Index-Crash.ll Tue Apr 7 00:03:34 2009 @@ -0,0 +1,24 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis +; rdar://6762290 + +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target triple = "i386-apple-darwin9" + %T = type <{ i64, i64, i64 }> + +define i32 @test(i8* %start, i32 %X) nounwind { +entry: + %tmp3 = load i64* null ; [#uses=1] + %add.ptr = getelementptr i8* %start, i64 %tmp3 ; [#uses=1] + %tmp158 = load i32* null ; [#uses=1] + %add.ptr159 = getelementptr %T* null, i32 %tmp158 + %add.ptr209 = getelementptr i8* %start, i64 0 ; [#uses=1] + %add.ptr212 = getelementptr i8* %add.ptr209, i32 %X ; [#uses=1] + %cmp214 = icmp ugt i8* %add.ptr212, %add.ptr ; [#uses=1] + br i1 %cmp214, label %if.then216, label %if.end363 + +if.then216: ; preds = %for.body162 + ret i32 1 + +if.end363: ; preds = %for.body162 + ret i32 0 +} From kremenek at apple.com Tue Apr 7 00:34:05 2009 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 07 Apr 2009 05:34:05 -0000 Subject: [llvm-commits] [llvm] r68506 - /llvm/tags/checker/checker-0.183/ Message-ID: <200904070534.n375Y5eZ006092@zion.cs.uiuc.edu> Author: kremenek Date: Tue Apr 7 00:34:05 2009 New Revision: 68506 URL: http://llvm.org/viewvc/llvm-project?rev=68506&view=rev Log: Removing checker-0.183. Removed: llvm/tags/checker/checker-0.183/ From kremenek at apple.com Tue Apr 7 00:35:24 2009 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 07 Apr 2009 05:35:24 -0000 Subject: [llvm-commits] [llvm] r68508 - /llvm/tags/checker/checker-0.183/ Message-ID: <200904070535.n375ZOSd006155@zion.cs.uiuc.edu> Author: kremenek Date: Tue Apr 7 00:35:24 2009 New Revision: 68508 URL: http://llvm.org/viewvc/llvm-project?rev=68508&view=rev Log: Tagging checker-0.183. Added: llvm/tags/checker/checker-0.183/ - copied from r68507, llvm/trunk/ From baldrick at free.fr Tue Apr 7 02:47:34 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 7 Apr 2009 09:47:34 +0200 Subject: [llvm-commits] [llvm] r68465 - in /llvm/trunk: docs/BitCodeFormat.html include/llvm/Bitcode/BitCodes.h include/llvm/Bitcode/BitstreamReader.h include/llvm/Bitcode/BitstreamWriter.h In-Reply-To: <200904062150.n36LoeCY021210@zion.cs.uiuc.edu> References: <200904062150.n36LoeCY021210@zion.cs.uiuc.edu> Message-ID: <200904070947.34963.baldrick@free.fr> Hi Chris, > +

  • Blob: This field is emitted as a vbr6, followed by padding to a > + 32-bit boundary (for alignment) and an array of 8-bit objects. The array of > + bytes is further followed by tail padding to ensure that its total length is > + a multiple of 4 bytes. This makes it very efficient for the reader to > + decode the data without having to make a copy of it: it can use a pointer to > + the data in the mapped in file and poke directly at it. A blob may only > + occur as the last operand of an abbreviation.
  • ... > + Blob = 5 // 8-bit aligned array of 8-bit characters. in the docs it says 32-bit aligned, but here it says 8-bit... > + // Align end to 32-bits. > + while (Out.size() & 3) > + Out.push_back(0); Can you use FlushToWord() here instead? Ciao, Duncan. From baldrick at free.fr Tue Apr 7 02:54:36 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 7 Apr 2009 09:54:36 +0200 Subject: [llvm-commits] [llvm] r68464 - in /llvm/trunk: lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/2009-04-06-AsmModifier.ll In-Reply-To: <200904062146.n36Lkpv2021018@zion.cs.uiuc.edu> References: <200904062146.n36Lkpv2021018@zion.cs.uiuc.edu> Message-ID: <200904070954.36539.baldrick@free.fr> Hi Bob, > Handle 'a' modifier in ARM inline assembly. > Patch by Richard Pennington. ... > + case 'a': // Don't print "#" before a global var name or constant. > case 'c': // Don't print "$" before a global var name or constant. > + printOperand(MI, OpNo, "no_hash"); > + return false; is this correct? I talked with Richard on IRC, and some testing with gcc on ARM seemed to show gcc doing something different with this modifier to what Richard expected. Ciao, Duncan. From baldrick at free.fr Tue Apr 7 02:59:00 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 7 Apr 2009 09:59:00 +0200 Subject: [llvm-commits] [llvm] r68455 - /llvm/trunk/Makefile.rules In-Reply-To: <200904061958.n36JwC1F016795@zion.cs.uiuc.edu> References: <200904061958.n36JwC1F016795@zion.cs.uiuc.edu> Message-ID: <200904070959.00884.baldrick@free.fr> Hi Mike, > Avoid -O3 on Darwin for now. is this really a Darwin issue? If it's not clear, how about using -O2 on all platforms? People using FC8 have regularly been reporting miscompilations of llvm-2.5 when building with optimization for example. So perhaps this is a more general problem. Ciao, Duncan. From rich at pennware.com Tue Apr 7 08:18:24 2009 From: rich at pennware.com (Richard Pennington) Date: Tue, 07 Apr 2009 08:18:24 -0500 Subject: [llvm-commits] [llvm] r68464 - in /llvm/trunk: lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/2009-04-06-AsmModifier.ll In-Reply-To: <200904070954.36539.baldrick@free.fr> References: <200904062146.n36Lkpv2021018@zion.cs.uiuc.edu> <200904070954.36539.baldrick@free.fr> Message-ID: <49DB52A0.8040307@pennware.com> Duncan Sands wrote: > Hi Bob, > >> Handle 'a' modifier in ARM inline assembly. >> Patch by Richard Pennington. > ... >> + case 'a': // Don't print "#" before a global var name or constant. >> case 'c': // Don't print "$" before a global var name or constant. >> + printOperand(MI, OpNo, "no_hash"); >> + return false; > > is this correct? I talked with Richard on IRC, and some > testing with gcc on ARM seemed to show gcc doing something > different with this modifier to what Richard expected. > > Ciao, > > Duncan. > Duncan, Bob put me on the right path. It was the "no_hash" that was needed. We match gcc now. -Rich From sabre at nondot.org Tue Apr 7 11:30:33 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Apr 2009 16:30:33 -0000 Subject: [llvm-commits] [llvm] r68518 - /llvm/trunk/include/llvm/Bitcode/BitCodes.h Message-ID: <200904071630.n37GUYu3008545@zion.cs.uiuc.edu> Author: lattner Date: Tue Apr 7 11:30:31 2009 New Revision: 68518 URL: http://llvm.org/viewvc/llvm-project?rev=68518&view=rev Log: fix comment to reflect the implementation I ended up settling on. Thanks to Duncan for noticing this Modified: llvm/trunk/include/llvm/Bitcode/BitCodes.h Modified: llvm/trunk/include/llvm/Bitcode/BitCodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitCodes.h?rev=68518&r1=68517&r2=68518&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/BitCodes.h (original) +++ llvm/trunk/include/llvm/Bitcode/BitCodes.h Tue Apr 7 11:30:31 2009 @@ -89,7 +89,7 @@ VBR = 2, // A VBR field where Val specifies the width of each chunk. Array = 3, // A sequence of fields, next field species elt encoding. Char6 = 4, // A 6-bit fixed field which maps to [a-zA-Z0-9._]. - Blob = 5 // 8-bit aligned array of 8-bit characters. + Blob = 5 // 32-bit aligned array of 8-bit characters. }; explicit BitCodeAbbrevOp(uint64_t V) : Val(V), IsLiteral(true) {} From clattner at apple.com Tue Apr 7 11:31:04 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 7 Apr 2009 09:31:04 -0700 Subject: [llvm-commits] [llvm] r68465 - in /llvm/trunk: docs/BitCodeFormat.html include/llvm/Bitcode/BitCodes.h include/llvm/Bitcode/BitstreamReader.h include/llvm/Bitcode/BitstreamWriter.h In-Reply-To: <200904070947.34963.baldrick@free.fr> References: <200904062150.n36LoeCY021210@zion.cs.uiuc.edu> <200904070947.34963.baldrick@free.fr> Message-ID: <382957AF-0F53-49B8-A506-5830D9DE2EE6@apple.com> On Apr 7, 2009, at 12:47 AM, Duncan Sands wrote: >> + Blob = 5 // 8-bit aligned array of 8-bit characters. > > in the docs it says 32-bit aligned, but here it says 8-bit... Nice catch, fixed! >> + // Align end to 32-bits. >> + while (Out.size() & 3) >> + Out.push_back(0); > > Can you use FlushToWord() here instead? Unfortunately no, by directly pushing bytes onto the output stream, we're subverting the bit-wise mechanism that flushtoword uses. -Chris From clattner at apple.com Tue Apr 7 11:31:56 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 7 Apr 2009 09:31:56 -0700 Subject: [llvm-commits] [llvm] r68455 - /llvm/trunk/Makefile.rules In-Reply-To: <200904070959.00884.baldrick@free.fr> References: <200904061958.n36JwC1F016795@zion.cs.uiuc.edu> <200904070959.00884.baldrick@free.fr> Message-ID: <45AFC928-ABB7-4CF5-890C-DB614B8E0604@apple.com> On Apr 7, 2009, at 12:59 AM, Duncan Sands wrote: > Hi Mike, >> Avoid -O3 on Darwin for now. > > is this really a Darwin issue? If it's not clear, > how about using -O2 on all platforms? People using > FC8 have regularly been reporting miscompilations of > llvm-2.5 when building with optimization for example. > So perhaps this is a more general problem. I would be supportive of using -O2 everywhere, but this will significantly impact our compile times (llvm will compile slower). -Chris From sabre at nondot.org Tue Apr 7 11:39:01 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 7 Apr 2009 11:39:01 -0500 Subject: [llvm-commits] CVS: llvm-www/header.incl Message-ID: <200904071639.n37Gd0LN008866@zion.cs.uiuc.edu> Changes in directory llvm-www: header.incl updated: 1.79 -> 1.80 --- Log message: add a link to the wiki --- Diffs of the changes: (+1 -0) header.incl | 1 + 1 files changed, 1 insertion(+) Index: llvm-www/header.incl diff -u llvm-www/header.incl:1.79 llvm-www/header.incl:1.80 --- llvm-www/header.incl:1.79 Fri Apr 3 12:30:10 2009 +++ llvm-www/header.incl Tue Apr 7 11:34:46 2009 @@ -32,6 +32,7 @@ LLVM Users
    LLVM Developers
    Bug Database
    +Wiki

    From bob.wilson at apple.com Tue Apr 7 11:45:29 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 7 Apr 2009 09:45:29 -0700 Subject: [llvm-commits] [llvm] r68464 - in /llvm/trunk: lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/2009-04-06-AsmModifier.ll In-Reply-To: <49DB52A0.8040307@pennware.com> References: <200904062146.n36Lkpv2021018@zion.cs.uiuc.edu> <200904070954.36539.baldrick@free.fr> <49DB52A0.8040307@pennware.com> Message-ID: On Apr 7, 2009, at 6:18 AM, Richard Pennington wrote: > Duncan Sands wrote: >> Hi Bob, >>> Handle 'a' modifier in ARM inline assembly. >>> Patch by Richard Pennington. >> ... >>> + case 'a': // Don't print "#" before a global var name or >>> constant. >>> case 'c': // Don't print "$" before a global var name or >>> constant. >>> + printOperand(MI, OpNo, "no_hash"); >>> + return false; >> is this correct? I talked with Richard on IRC, and some >> testing with gcc on ARM seemed to show gcc doing something >> different with this modifier to what Richard expected. >> Ciao, >> Duncan. > Duncan, > > Bob put me on the right path. It was the "no_hash" that was needed. > We match gcc now. There is more that could be done here. I added some comments in the bug report. GCC does all sorts of elaborate things with these operand modifiers. LLVM doesn't recognize most of them. For ARM, the "a" modifier handles all the different ARM and Thumb addressing modes. The testcase in the bug report was for an immediate operand, and for that case, I do think Richard's patch is correct. (One could argue that the testcase is not so great. The "a" modifier is supposed to be used for addresses, but the argument to an SWI instruction is not an address. A "c" modifier would make more sense in this case. But, we want to be compatible with GCC and either "a" or "c" will do the same thing in this particular case.) From edwintorok at gmail.com Tue Apr 7 12:23:03 2009 From: edwintorok at gmail.com (Torok Edwin) Date: Tue, 07 Apr 2009 17:23:03 -0000 Subject: [llvm-commits] [llvm] r68523 - in /llvm/trunk: examples/HowToUseJIT/HowToUseJIT.cpp include/llvm/AbstractTypeUser.h lib/VMCore/Type.cpp Message-ID: <200904071723.n37HN4s8018418@zion.cs.uiuc.edu> Author: edwin Date: Tue Apr 7 12:23:02 2009 New Revision: 68523 URL: http://llvm.org/viewvc/llvm-project?rev=68523&view=rev Log: Another attempt at fixing PR2975. Types can have references to eachother, so we can't just call destroy on them. Modified: llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp llvm/trunk/include/llvm/AbstractTypeUser.h llvm/trunk/lib/VMCore/Type.cpp Modified: llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp?rev=68523&r1=68522&r2=68523&view=diff ============================================================================== --- llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp (original) +++ llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp Tue Apr 7 12:23:02 2009 @@ -42,6 +42,7 @@ #include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/Interpreter.h" #include "llvm/ExecutionEngine/GenericValue.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -109,5 +110,8 @@ // Import result of execution: outs() << "Result: " << gv.IntVal << "\n"; + EE->freeMachineCodeForFunction(FooF); + delete EE; + llvm_shutdown(); return 0; } Modified: llvm/trunk/include/llvm/AbstractTypeUser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/AbstractTypeUser.h?rev=68523&r1=68522&r2=68523&view=diff ============================================================================== --- llvm/trunk/include/llvm/AbstractTypeUser.h (original) +++ llvm/trunk/include/llvm/AbstractTypeUser.h Tue Apr 7 12:23:02 2009 @@ -137,6 +137,7 @@ /// class PATypeHolder { mutable const Type *Ty; + void destroy(); public: PATypeHolder(const Type *ty) : Ty(ty) { addRef(); @@ -145,7 +146,7 @@ addRef(); } - ~PATypeHolder() { dropRef(); } + ~PATypeHolder() { if (Ty) dropRef(); } operator Type *() const { return get(); } Type *get() const; @@ -173,6 +174,7 @@ private: void addRef(); void dropRef(); + friend class TypeMapBase; }; // simplify_type - Allow clients to treat uses just like values when using Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=68523&r1=68522&r2=68523&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Tue Apr 7 12:23:02 2009 @@ -388,6 +388,10 @@ #endif } +void PATypeHolder::destroy() { + Ty = 0; +} + // dropAllTypeUses - When this (abstract) type is resolved to be equal to // another (more concrete) type, we must eliminate all references to other // types, to avoid some circular reference problems. @@ -666,6 +670,27 @@ std::multimap TypesByHash; public: + ~TypeMapBase() + { + //PATypeHolder won't destroy non-abstract types. + //We can't destroy them by simply iterating, because + //they may contain references to each-other + + for (std::multimap::iterator I + = TypesByHash.begin(), E = TypesByHash.end(); I != E; ++I) { + Type *Ty = const_cast(I->second.Ty); + I->second.destroy(); + // We can't invoke destroy or delete, because the type may + // contain references to already freed types. + // So we have to destruct the object the ugly way. + if (Ty) { + Ty->AbstractTypeUsers.clear(); + static_cast(Ty)->Type::~Type(); + operator delete(Ty); + } + } + } + void RemoveFromTypesByHash(unsigned Hash, const Type *Ty) { std::multimap::iterator I = TypesByHash.lower_bound(Hash); From lattner at apple.com Tue Apr 7 12:44:22 2009 From: lattner at apple.com (Tanya Lattner) Date: Tue, 7 Apr 2009 10:44:22 -0700 Subject: [llvm-commits] [llvm] r68187 - /llvm/trunk/autoconf/configure.ac In-Reply-To: <200904010439.n314dP2p010541@zion.cs.uiuc.edu> References: <200904010439.n314dP2p010541@zion.cs.uiuc.edu> Message-ID: <1BBB1B35-3F44-4021-B115-258C3D8814B1@apple.com> Regenerate configure? On Mar 31, 2009, at 9:39 PM, Nick Lewycky wrote: > Author: nicholas > Date: Tue Mar 31 23:39:25 2009 > New Revision: 68187 > > URL: http://llvm.org/viewvc/llvm-project?rev=68187&view=rev > Log: > Detect that we're building from a git checkout like we do for cvs > and svn. > Based on a patch by Nicolas Trangez on the unladen-swallow mailing > list! > > Modified: > llvm/trunk/autoconf/configure.ac > > Modified: llvm/trunk/autoconf/configure.ac > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=68187&r1=68186&r2=68187&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/autoconf/configure.ac (original) > +++ llvm/trunk/autoconf/configure.ac Tue Mar 31 23:39:25 2009 > @@ -255,13 +255,13 @@ > AC_SUBST(LLVM_CROSS_COMPILING, [0]) > fi > > -dnl Check to see if there's a "CVS" (or .svn) directory indicating > that this > -dnl build is being done from a checkout. This sets up several > defaults for the > -dnl command line switches. When we build with a CVS directory, we > get a > -dnl debug with assertions turned on. Without, we assume a source > release and we > -dnl get an optimized build without assertions. See --enable- > optimized and > -dnl --enable-assertions below > -if test -d "CVS" -o -d "${srcdir}/CVS" -o -d ".svn" -o -d "$ > {srcdir}/.svn"; then > +dnl Check to see if there's a "CVS" (or .svn or .git) directory > indicating > +dnl that this build is being done from a checkout. This sets up > several > +dnl defaults for the command line switches. When we build with a > CVS directory, > +dnl we get a debug with assertions turned on. Without, we assume a > source > +dnl release and we get an optimized build without assertions. > +dnl See --enable-optimized and --enable-assertions below > +if test -d "CVS" -o -d "${srcdir}/CVS" -o -d ".svn" -o -d "$ > {srcdir}/.svn" -o -d ".git" -o -d "${srcdir}/.git"; then > cvsbuild="yes" > optimize="no" > AC_SUBST(CVSBUILD,[[CVSBUILD=1]]) > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090407/c8ef677b/attachment.html From baldrick at free.fr Tue Apr 7 13:36:50 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 7 Apr 2009 20:36:50 +0200 Subject: [llvm-commits] [llvm] r68523 - in /llvm/trunk: examples/HowToUseJIT/HowToUseJIT.cpp include/llvm/AbstractTypeUser.h lib/VMCore/Type.cpp In-Reply-To: <200904071723.n37HN4s8018418@zion.cs.uiuc.edu> References: <200904071723.n37HN4s8018418@zion.cs.uiuc.edu> Message-ID: <200904072036.50777.baldrick@free.fr> Hi Edwin, > + //PATypeHolder won't destroy non-abstract types. > + //We can't destroy them by simply iterating, because > + //they may contain references to each-other there should be a space after //. Ciao, Duncan. From isanbard at gmail.com Tue Apr 7 13:40:56 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 07 Apr 2009 18:40:56 -0000 Subject: [llvm-commits] [llvm] r68528 - /llvm/trunk/docs/FAQ.html Message-ID: <200904071840.n37Ieuun022299@zion.cs.uiuc.edu> Author: void Date: Tue Apr 7 13:40:56 2009 New Revision: 68528 URL: http://llvm.org/viewvc/llvm-project?rev=68528&view=rev Log: Another reformatting. No change in docs. Modified: llvm/trunk/docs/FAQ.html Modified: llvm/trunk/docs/FAQ.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/FAQ.html?rev=68528&r1=68527&r2=68528&view=diff ============================================================================== --- llvm/trunk/docs/FAQ.html (original) +++ llvm/trunk/docs/FAQ.html Tue Apr 7 13:40:56 2009 @@ -2,6 +2,7 @@ "http://www.w3.org/TR/html4/strict.dtd"> + LLVM: Frequently Asked Questions