From bigcheesegs at gmail.com Mon Dec 6 00:02:07 2010 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Mon, 06 Dec 2010 06:02:07 -0000 Subject: [llvm-commits] [llvm] r120991 - in /llvm/trunk/lib/Support/Windows: PathV2.inc Windows.h Message-ID: <20101206060207.4DE162A6C12C@llvm.org> Author: mspencer Date: Mon Dec 6 00:02:07 2010 New Revision: 120991 URL: http://llvm.org/viewvc/llvm-project?rev=120991&view=rev Log: Support/Windows: Make MinGW happy. Modified: llvm/trunk/lib/Support/Windows/PathV2.inc llvm/trunk/lib/Support/Windows/Windows.h Modified: llvm/trunk/lib/Support/Windows/PathV2.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/PathV2.inc?rev=120991&r1=120990&r2=120991&view=diff ============================================================================== --- llvm/trunk/lib/Support/Windows/PathV2.inc (original) +++ llvm/trunk/lib/Support/Windows/PathV2.inc Mon Dec 6 00:02:07 2010 @@ -118,7 +118,7 @@ return ::CryptReleaseContext(Provider, 0); } - typedef ScopedHandle ScopedCryptContext; bool is_separator(const wchar_t value) { Modified: llvm/trunk/lib/Support/Windows/Windows.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Windows.h?rev=120991&r1=120990&r2=120991&view=diff ============================================================================== --- llvm/trunk/lib/Support/Windows/Windows.h (original) +++ llvm/trunk/lib/Support/Windows/Windows.h Mon Dec 6 00:02:07 2010 @@ -59,7 +59,7 @@ } }; -template class ScopedHandle { HandleType Handle; @@ -69,13 +69,13 @@ ScopedHandle(HandleType handle) : Handle(handle) {} ~ScopedHandle() { - if (Handle != InvalidHandle) + if (Handle != HandleType(InvalidHandle)) D(Handle); } HandleType take() { HandleType temp = Handle; - Handle = InvalidHandle; + Handle = HandleType(InvalidHandle); return temp; } @@ -91,14 +91,14 @@ // True if Handle is valid. operator unspecified_bool_type() const { - return Handle == InvalidHandle ? 0 : unspecified_bool_true; + return Handle == HandleType(InvalidHandle) ? 0 : unspecified_bool_true; } bool operator!() const { - return Handle == InvalidHandle; + return Handle == HandleType(InvalidHandle); } }; -typedef ScopedHandle ScopedFindHandle; From sabre at nondot.org Mon Dec 6 01:38:41 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 06 Dec 2010 07:38:41 -0000 Subject: [llvm-commits] [llvm] r120993 - /llvm/trunk/lib/Transforms/IPO/Inliner.cpp Message-ID: <20101206073841.2027E2A6C12C@llvm.org> Author: lattner Date: Mon Dec 6 01:38:40 2010 New Revision: 120993 URL: http://llvm.org/viewvc/llvm-project?rev=120993&view=rev Log: improve -debug output and comments a little. Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=120993&r1=120992&r2=120993&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Mon Dec 6 01:38:40 2010 @@ -153,19 +153,21 @@ // Otherwise, we *can* reuse it, RAUW AI into AvailableAlloca and declare // success! - DEBUG(dbgs() << " ***MERGED ALLOCA: " << *AI); + DEBUG(dbgs() << " ***MERGED ALLOCA: " << *AI << "\n\t\tINTO: " + << *AvailableAlloca << '\n'); AI->replaceAllUsesWith(AvailableAlloca); AI->eraseFromParent(); MergedAwayAlloca = true; ++NumMergedAllocas; + IFI.StaticAllocas[AllocaNo] = 0; break; } // If we already nuked the alloca, we're done with it. if (MergedAwayAlloca) continue; - + // If we were unable to merge away the alloca either because there are no // allocas of the right type available or because we reused them all // already, remember that this alloca came from an inlined function and mark @@ -402,7 +404,7 @@ // If this call site was obtained by inlining another function, verify // that the include path for the function did not include the callee - // itself. If so, we'd be recursively inlinling the same function, + // itself. If so, we'd be recursively inlining the same function, // which would provide the same callsites, which would cause us to // infinitely inline. int InlineHistoryID = CallSites[CSi].second; From sabre at nondot.org Mon Dec 6 01:43:04 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 06 Dec 2010 07:43:04 -0000 Subject: [llvm-commits] [llvm] r120994 - /llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Message-ID: <20101206074304.CA3342A6C12C@llvm.org> Author: lattner Date: Mon Dec 6 01:43:04 2010 New Revision: 120994 URL: http://llvm.org/viewvc/llvm-project?rev=120994&view=rev Log: improve comment Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=120994&r1=120993&r2=120994&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Mon Dec 6 01:43:04 2010 @@ -400,8 +400,7 @@ if (!isa(AI->getArraySize())) continue; - // Keep track of the static allocas that we inline into the caller if the - // StaticAllocas pointer is non-null. + // Keep track of the static allocas that we inline into the caller. IFI.StaticAllocas.push_back(AI); // Scan for the block of allocas that we can move over, and move them From sabre at nondot.org Mon Dec 6 01:52:42 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 06 Dec 2010 07:52:42 -0000 Subject: [llvm-commits] [llvm] r120995 - /llvm/trunk/lib/Transforms/IPO/Inliner.cpp Message-ID: <20101206075242.51A512A6C12C@llvm.org> Author: lattner Date: Mon Dec 6 01:52:42 2010 New Revision: 120995 URL: http://llvm.org/viewvc/llvm-project?rev=120995&view=rev Log: Fix PR8735, a really terrible problem in the inliner's "alloca merging" optimization. Consider: static void foo() { A = alloca ... } static void bar() { B = alloca ... call foo(); } void main() { bar() } The inliner proceeds bottom up, but lets pretend it decides not to inline foo into bar. When it gets to main, it inlines bar into main(), and says "hey, I just inlined an alloca "B" into main, lets remember that. Then it keeps going and finds that it now contains a call to foo. It decides to inline foo into main, and says "hey, foo has an alloca A, and I have an alloca B from another inlined call site, lets reuse it". The problem with this of course, is that the lifetime of A and B are nested, not disjoint. Unfortunately I can't create a reasonable testcase for this: the one in the PR is both huge and extremely sensitive, because you minor tweaks end up causing foo to get inlined into bar too early. We already have tests for the basic alloca merging optimization and this does not break them. Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=120995&r1=120994&r2=120995&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Mon Dec 6 01:52:42 2010 @@ -75,7 +75,8 @@ /// inline this call site we attempt to reuse already available allocas or add /// any new allocas to the set if not possible. static bool InlineCallIfPossible(CallSite CS, InlineFunctionInfo &IFI, - InlinedArrayAllocasTy &InlinedArrayAllocas) { + InlinedArrayAllocasTy &InlinedArrayAllocas, + int InlineHistory) { Function *Callee = CS.getCalledFunction(); Function *Caller = CS.getCaller(); @@ -92,7 +93,6 @@ !Caller->hasFnAttr(Attribute::StackProtectReq)) Caller->addFnAttr(Attribute::StackProtect); - // Look at all of the allocas that we inlined through this call site. If we // have already inlined other allocas through other calls into this function, // then we know that they have disjoint lifetimes and that we can merge them. @@ -116,6 +116,21 @@ // SmallPtrSet UsedAllocas; + // When processing our SCC, check to see if CS was inlined from some other + // call site. For example, if we're processing "A" in this code: + // A() { B() } + // B() { x = alloca ... C() } + // C() { y = alloca ... } + // Assume that C was not inlined into B initially, and so we're processing A + // and decide to inline B into A. Doing this makes an alloca available for + // reuse and makes a callsite (C) available for inlining. When we process + // the C call site we don't want to do any alloca merging between X and Y + // because their scopes are not disjoint. We could make this smarter by + // keeping track of the inline history for each alloca in the + // InlinedArrayAllocas but this isn't likely to be a significant win. + if (InlineHistory != -1) // Only do merging for top-level call sites in SCC. + return true; + // Loop over all the allocas we have so far and see if they can be merged with // a previously inlined alloca. If not, remember that we had it. for (unsigned AllocaNo = 0, e = IFI.StaticAllocas.size(); @@ -419,7 +434,8 @@ continue; // Attempt to inline the function. - if (!InlineCallIfPossible(CS, InlineInfo, InlinedArrayAllocas)) + if (!InlineCallIfPossible(CS, InlineInfo, InlinedArrayAllocas, + InlineHistoryID)) continue; ++NumInlined; From benny.kra at googlemail.com Mon Dec 6 02:24:02 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 6 Dec 2010 09:24:02 +0100 Subject: [llvm-commits] [llvm] r120974 - in /llvm/trunk: include/llvm/Analysis/AliasAnalysis.h lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/simple.ll In-Reply-To: <20101206014806.79E942A6C12C@llvm.org> References: <20101206014806.79E942A6C12C@llvm.org> Message-ID: <03608C35-109D-4B5A-9E39-0879DD0047AC@gmail.com> On 06.12.2010, at 02:48, Chris Lattner wrote: > Author: lattner > Date: Sun Dec 5 19:48:06 2010 > New Revision: 120974 > > URL: http://llvm.org/viewvc/llvm-project?rev=120974&view=rev > Log: > Fix PR8728, a miscompilation I recently introduced. When optimizing > memcpy's like: > memcpy(A, B) > memcpy(A, C) > > we cannot delete the first memcpy as dead if A and C might be aliases. > If so, we actually get: Aren't the operands of memcpy guaranteed not to overlap, so this would be undefined behaviour? From ismail at namtrac.org Mon Dec 6 02:27:10 2010 From: ismail at namtrac.org (=?UTF-8?B?xLBzbWFpbCBEw7ZubWV6?=) Date: Mon, 6 Dec 2010 10:27:10 +0200 Subject: [llvm-commits] [llvm] r120974 - in /llvm/trunk: include/llvm/Analysis/AliasAnalysis.h lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/simple.ll In-Reply-To: <03608C35-109D-4B5A-9E39-0879DD0047AC@gmail.com> References: <20101206014806.79E942A6C12C@llvm.org> <03608C35-109D-4B5A-9E39-0879DD0047AC@gmail.com> Message-ID: Hi; On Mon, Dec 6, 2010 at 10:24 AM, Benjamin Kramer wrote: > > On 06.12.2010, at 02:48, Chris Lattner wrote: > > > Author: lattner > > Date: Sun Dec 5 19:48:06 2010 > > New Revision: 120974 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=120974&view=rev > > Log: > > Fix PR8728, a miscompilation I recently introduced. When optimizing > > memcpy's like: > > memcpy(A, B) > > memcpy(A, C) > > > > we cannot delete the first memcpy as dead if A and C might be aliases. > > If so, we actually get: > > Aren't the operands of memcpy guaranteed not to overlap, so this would be > undefined behaviour? Apparently Adobe didn't know about it: https://bugzilla.redhat.com/show_bug.cgi?id=638477 Regards, ismail -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20101206/3b4fc786/attachment.html From fvbommel at gmail.com Mon Dec 6 04:48:11 2010 From: fvbommel at gmail.com (Frits van Bommel) Date: Mon, 06 Dec 2010 10:48:11 -0000 Subject: [llvm-commits] [llvm] r120998 - /llvm/trunk/include/llvm/Support/FileSystem.h Message-ID: <20101206104811.547B22A6C12C@llvm.org> Author: fvbommel Date: Mon Dec 6 04:48:11 2010 New Revision: 120998 URL: http://llvm.org/viewvc/llvm-project?rev=120998&view=rev Log: Fix clang warning: "extra ';' inside a class [-pedantic]". Modified: llvm/trunk/include/llvm/Support/FileSystem.h Modified: llvm/trunk/include/llvm/Support/FileSystem.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FileSystem.h?rev=120998&r1=120997&r2=120998&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/FileSystem.h (original) +++ llvm/trunk/include/llvm/Support/FileSystem.h Mon Dec 6 04:48:11 2010 @@ -607,7 +607,7 @@ } const directory_entry &operator*() const { return CurrentEntry; } - const directory_entry *operator->() const { return &CurrentEntry; }; + const directory_entry *operator->() const { return &CurrentEntry; } bool operator!=(const directory_iterator &RHS) const { return CurrentEntry != RHS.CurrentEntry; From sherpya at netfarm.it Mon Dec 6 05:36:07 2010 From: sherpya at netfarm.it (Gianluigi Tiesi) Date: Mon, 06 Dec 2010 12:36:07 +0100 Subject: [llvm-commits] [PATCH] fix complation on mingw32 Message-ID: <4CFCCAA7.1030808@netfarm.it> file: lib/Support/ErrorHandling.cpp ::write() needs inclusion of io.h either on msvc and mingw so the correct ifdef is _WIN32 attached the patch Regards -- Gianluigi Tiesi EDP Project Leader Netfarm S.r.l. - http://www.netfarm.it/ Free Software: http://oss.netfarm.it/ -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: mingw-compile-fix.diff Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20101206/9bace5df/attachment.pl From baldrick at free.fr Mon Dec 6 07:20:23 2010 From: baldrick at free.fr (Duncan Sands) Date: Mon, 06 Dec 2010 14:20:23 +0100 Subject: [llvm-commits] [llvm] r120974 - in /llvm/trunk: include/llvm/Analysis/AliasAnalysis.h lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/simple.ll In-Reply-To: References: <20101206014806.79E942A6C12C@llvm.org> <03608C35-109D-4B5A-9E39-0879DD0047AC@gmail.com> Message-ID: <4CFCE317.2030208@free.fr> Hi ?smail, > Apparently Adobe didn't know about it: > https://bugzilla.redhat.com/show_bug.cgi?id=638477 because of that the whole planet now knows that overlapping memcpy is not allowed. So while previously people might have complained if we broke code with overlapping memcpy, we may be able to get away with it now! :) Ciao, Duncan. From rafael.espindola at gmail.com Mon Dec 6 08:53:14 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Mon, 06 Dec 2010 14:53:14 -0000 Subject: [llvm-commits] [llvm] r121000 - in /llvm/trunk: include/llvm/MC/MCStreamer.h lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp lib/MC/MCDwarf.cpp lib/MC/MCStreamer.cpp Message-ID: <20101206145314.6C80E2A6C12C@llvm.org> Author: rafael Date: Mon Dec 6 08:53:14 2010 New Revision: 121000 URL: http://llvm.org/viewvc/llvm-project?rev=121000&view=rev Log: Add an EmitAbsValue helper method and use it in cases where we want to be sure that no relocations are used (on MochO). Fixes llc producing different output from llc + llvm-mc. Modified: llvm/trunk/include/llvm/MC/MCStreamer.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp llvm/trunk/lib/MC/MCDwarf.cpp llvm/trunk/lib/MC/MCStreamer.cpp Modified: llvm/trunk/include/llvm/MC/MCStreamer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=121000&r1=120999&r2=121000&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCStreamer.h (original) +++ llvm/trunk/include/llvm/MC/MCStreamer.h Mon Dec 6 08:53:14 2010 @@ -249,6 +249,11 @@ virtual void EmitIntValue(uint64_t Value, unsigned Size, unsigned AddrSpace = 0); + /// EmitAbsValue - Emit the Value, but try to avoid relocations. On MachO + /// this is done by producing + /// foo = value + /// .long foo + void EmitAbsValue(const MCExpr *Value, unsigned Size); virtual void EmitULEB128Value(const MCExpr *Value, unsigned AddrSpace = 0) = 0; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp?rev=121000&r1=120999&r2=121000&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Mon Dec 6 08:53:14 2010 @@ -156,7 +156,7 @@ const MCExpr *Exp = TLOF.getExprForDwarfReference(Sym, Mang, MMI, Encoding, OutStreamer); - OutStreamer.EmitValue(Exp, GetSizeOfEncodedValue(Encoding), /*addrspace*/0); + OutStreamer.EmitAbsValue(Exp, GetSizeOfEncodedValue(Encoding)); } void AsmPrinter::EmitReference(const GlobalValue *GV, unsigned Encoding)const{ Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=121000&r1=120999&r2=121000&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Mon Dec 6 08:53:14 2010 @@ -213,15 +213,8 @@ // The first 4 bytes is the total length of the information for this // compilation unit (not including these 4 bytes for the length). - // FIXME: We create the dummy TotalLength variable because LineEndSym points - // to the end of the section and the darwin assembler doesn't consider that - // difference an assembly time constant. It might be better for this to be - // proected by a flag. - MCSymbol *TotalLength = MCOS->getContext().CreateTempSymbol(); - MCOS->EmitAssignment(TotalLength, - MakeStartMinusEndExpr(MCOS, LineStartSym, LineEndSym, - 4)); - MCOS->EmitSymbolValue(TotalLength, 4, 0); + MCOS->EmitAbsValue(MakeStartMinusEndExpr(MCOS, LineStartSym, LineEndSym,4), + 4); // Next 2 bytes is the Version, which is Dwarf 2. MCOS->EmitIntValue(2, 2); Modified: llvm/trunk/lib/MC/MCStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=121000&r1=120999&r2=121000&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCStreamer.cpp Mon Dec 6 08:53:14 2010 @@ -72,6 +72,12 @@ EmitBytes(OSE.str(), AddrSpace); } +void MCStreamer::EmitAbsValue(const MCExpr *Value, unsigned Size) { + MCSymbol *ABS = getContext().CreateTempSymbol(); + EmitAssignment(ABS, Value); + EmitSymbolValue(ABS, Size, 0); +} + void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size, unsigned AddrSpace) { EmitValue(MCSymbolRefExpr::Create(Sym, getContext()), Size, AddrSpace); From rafael.espindola at gmail.com Mon Dec 6 09:05:36 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Mon, 06 Dec 2010 15:05:36 -0000 Subject: [llvm-commits] [llvm] r121001 - /llvm/trunk/test/CodeGen/X86/aliases.ll Message-ID: <20101206150536.5B8D42A6C12C@llvm.org> Author: rafael Date: Mon Dec 6 09:05:36 2010 New Revision: 121001 URL: http://llvm.org/viewvc/llvm-project?rev=121001&view=rev Log: Update test for the extra =. Modified: llvm/trunk/test/CodeGen/X86/aliases.ll Modified: llvm/trunk/test/CodeGen/X86/aliases.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/aliases.ll?rev=121001&r1=121000&r2=121001&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/aliases.ll (original) +++ llvm/trunk/test/CodeGen/X86/aliases.ll Mon Dec 6 09:05:36 2010 @@ -1,5 +1,5 @@ ; RUN: llc < %s -mtriple=i686-pc-linux-gnu -asm-verbose=false -o %t -; RUN: grep { = } %t | count 16 +; RUN: grep { = } %t | count 17 ; RUN: grep set %t | count 18 ; RUN: grep globl %t | count 6 ; RUN: grep weak %t | count 1 From rafael.espindola at gmail.com Mon Dec 6 09:35:15 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Mon, 06 Dec 2010 15:35:15 -0000 Subject: [llvm-commits] [llvm] r121004 - in /llvm/trunk: include/llvm/MC/MCStreamer.h lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp lib/MC/MCDwarf.cpp lib/MC/MCStreamer.cpp test/CodeGen/X86/aliases.ll Message-ID: <20101206153515.676EA2A6C12C@llvm.org> Author: rafael Date: Mon Dec 6 09:35:15 2010 New Revision: 121004 URL: http://llvm.org/viewvc/llvm-project?rev=121004&view=rev Log: Revert previous two patches while I try to find out how to make both linux and darwin assemblers happy :-( Modified: llvm/trunk/include/llvm/MC/MCStreamer.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp llvm/trunk/lib/MC/MCDwarf.cpp llvm/trunk/lib/MC/MCStreamer.cpp llvm/trunk/test/CodeGen/X86/aliases.ll Modified: llvm/trunk/include/llvm/MC/MCStreamer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=121004&r1=121003&r2=121004&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCStreamer.h (original) +++ llvm/trunk/include/llvm/MC/MCStreamer.h Mon Dec 6 09:35:15 2010 @@ -249,11 +249,6 @@ virtual void EmitIntValue(uint64_t Value, unsigned Size, unsigned AddrSpace = 0); - /// EmitAbsValue - Emit the Value, but try to avoid relocations. On MachO - /// this is done by producing - /// foo = value - /// .long foo - void EmitAbsValue(const MCExpr *Value, unsigned Size); virtual void EmitULEB128Value(const MCExpr *Value, unsigned AddrSpace = 0) = 0; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp?rev=121004&r1=121003&r2=121004&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Mon Dec 6 09:35:15 2010 @@ -156,7 +156,7 @@ const MCExpr *Exp = TLOF.getExprForDwarfReference(Sym, Mang, MMI, Encoding, OutStreamer); - OutStreamer.EmitAbsValue(Exp, GetSizeOfEncodedValue(Encoding)); + OutStreamer.EmitValue(Exp, GetSizeOfEncodedValue(Encoding), /*addrspace*/0); } void AsmPrinter::EmitReference(const GlobalValue *GV, unsigned Encoding)const{ Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=121004&r1=121003&r2=121004&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Mon Dec 6 09:35:15 2010 @@ -213,8 +213,15 @@ // The first 4 bytes is the total length of the information for this // compilation unit (not including these 4 bytes for the length). - MCOS->EmitAbsValue(MakeStartMinusEndExpr(MCOS, LineStartSym, LineEndSym,4), - 4); + // FIXME: We create the dummy TotalLength variable because LineEndSym points + // to the end of the section and the darwin assembler doesn't consider that + // difference an assembly time constant. It might be better for this to be + // proected by a flag. + MCSymbol *TotalLength = MCOS->getContext().CreateTempSymbol(); + MCOS->EmitAssignment(TotalLength, + MakeStartMinusEndExpr(MCOS, LineStartSym, LineEndSym, + 4)); + MCOS->EmitSymbolValue(TotalLength, 4, 0); // Next 2 bytes is the Version, which is Dwarf 2. MCOS->EmitIntValue(2, 2); Modified: llvm/trunk/lib/MC/MCStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=121004&r1=121003&r2=121004&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCStreamer.cpp Mon Dec 6 09:35:15 2010 @@ -72,12 +72,6 @@ EmitBytes(OSE.str(), AddrSpace); } -void MCStreamer::EmitAbsValue(const MCExpr *Value, unsigned Size) { - MCSymbol *ABS = getContext().CreateTempSymbol(); - EmitAssignment(ABS, Value); - EmitSymbolValue(ABS, Size, 0); -} - void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size, unsigned AddrSpace) { EmitValue(MCSymbolRefExpr::Create(Sym, getContext()), Size, AddrSpace); Modified: llvm/trunk/test/CodeGen/X86/aliases.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/aliases.ll?rev=121004&r1=121003&r2=121004&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/aliases.ll (original) +++ llvm/trunk/test/CodeGen/X86/aliases.ll Mon Dec 6 09:35:15 2010 @@ -1,5 +1,5 @@ ; RUN: llc < %s -mtriple=i686-pc-linux-gnu -asm-verbose=false -o %t -; RUN: grep { = } %t | count 17 +; RUN: grep { = } %t | count 16 ; RUN: grep set %t | count 18 ; RUN: grep globl %t | count 6 ; RUN: grep weak %t | count 1 From clattner at apple.com Mon Dec 6 11:20:37 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 6 Dec 2010 09:20:37 -0800 Subject: [llvm-commits] [llvm] r120974 - in /llvm/trunk: include/llvm/Analysis/AliasAnalysis.h lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/simple.ll In-Reply-To: <03608C35-109D-4B5A-9E39-0879DD0047AC@gmail.com> References: <20101206014806.79E942A6C12C@llvm.org> <03608C35-109D-4B5A-9E39-0879DD0047AC@gmail.com> Message-ID: <4A44A164-25BF-49E5-A922-9EE107337CCF@apple.com> On Dec 6, 2010, at 12:24 AM, Benjamin Kramer wrote: On 06.12.2010, at 02:48, Chris Lattner wrote: > >> Author: lattner >> Date: Sun Dec 5 19:48:06 2010 >> New Revision: 120974 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=120974&view=rev >> Log: >> Fix PR8728, a miscompilation I recently introduced. When optimizing >> memcpy's like: >> memcpy(A, B) >> memcpy(A, C) >> >> we cannot delete the first memcpy as dead if A and C might be aliases. >> If so, we actually get: > > Aren't the operands of memcpy guaranteed not to overlap, so this would be undefined behaviour? Yes, sort of! In practice, we allow memcpy's that overlap if the src/dst pointer is exactly the same. This is because we want struct copies in C to be able to compile into memcpy, not memmove. There is this code in Clang in CGExprAgg.cpp: // Aggregate assignment turns into llvm.memcpy. This is almost valid per // C99 6.5.16.1p3, which states "If the value being stored in an object is // read from another object that overlaps in anyway the storage of the first // object, then the overlap shall be exact and the two objects shall have // qualified or unqualified versions of a compatible type." // // memcpy is not defined if the source and destination pointers are exactly // equal, but other compilers do this optimization, and almost every memcpy // implementation handles this case safely. If there is a libc that does not // safely handle this, we can add a target hook. Note that the example from the PR doesn't explicitly call memcpy. -Chris From bob.wilson at apple.com Mon Dec 6 11:29:29 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 6 Dec 2010 09:29:29 -0800 Subject: [llvm-commits] [llvm] r120932 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/select.ll In-Reply-To: References: <20101205020051.C847D2A6C12C@llvm.org> <72061699-B4F6-498E-90E5-54799F2A6E31@apple.com> <0925F248-6D28-4EDB-B3AE-B1DE9F39BBDB@nondot.org> <9A7B1FA4-2E28-4EDB-9631-CD09F2C24D95@apple.com> <358DAAA5-039A-4ADE-ACEE-8051B1BE6558@nondot.org> <703382C1-9F49-4FD2-9A36-57BFE0E118BD@apple.com> Message-ID: On Dec 5, 2010, at 8:39 PM, Chris Lattner wrote: > > On Dec 5, 2010, at 8:25 PM, Evan Cheng wrote: >>>> Right, they don't handle the integer overflow case. In this particular example, what we really want is a way to say that the select is heavily biased, so that we get a jump instead of cmov (or cmov equivalent). We really want: >>>> >>>> mulq >>>> jo Lfoo >>>> jmp __Znam >>>> Lfoo: >>>> mov rdi, -1 >>>> jmp __Znam >>> >>> Along these lines, I wonder if it would be enough to just mark IR select/condbr instructions with an instruction MDNode like !highlybiased (optionally with a direction). This could be preserved down to codegen level and used for expansion there. This would also be a straight-forward way to model __builtin_expect. >> >> Do we want to make it a more generic MDNode so we can use it to encode branch probability? > > Yes, making it more general than just "biased" makes sense. I've been thinking about and talking with a few people about doing exactly that for recording profile information as well. I don't yet have enough details to make a real proposal, but if you're planning to do anything like that soon, I'd be interested. From rafael.espindola at gmail.com Mon Dec 6 11:27:56 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Mon, 06 Dec 2010 17:27:56 -0000 Subject: [llvm-commits] [llvm] r121006 - in /llvm/trunk: include/llvm/MC/MCStreamer.h lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp lib/MC/MCAsmInfoDarwin.cpp lib/MC/MCAsmStreamer.cpp lib/MC/MCDwarf.cpp lib/MC/MCStreamer.cpp lib/Target/PowerPC/PPCMCAsmInfo.cpp lib/Target/X86/X86MCAsmInfo.cpp test/MC/MachO/empty-dwarf-lines.s Message-ID: <20101206172756.9FDAD2A6C12C@llvm.org> Author: rafael Date: Mon Dec 6 11:27:56 2010 New Revision: 121006 URL: http://llvm.org/viewvc/llvm-project?rev=121006&view=rev Log: Second try at making direct object emission produce the same results as llc + llvm-mc. This time ELF is not changed and I tested that llvm-gcc bootstrap on darwin10 using darwin9's assembler and linker. Modified: llvm/trunk/include/llvm/MC/MCStreamer.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp llvm/trunk/lib/MC/MCAsmStreamer.cpp llvm/trunk/lib/MC/MCDwarf.cpp llvm/trunk/lib/MC/MCStreamer.cpp llvm/trunk/lib/Target/PowerPC/PPCMCAsmInfo.cpp llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp llvm/trunk/test/MC/MachO/empty-dwarf-lines.s Modified: llvm/trunk/include/llvm/MC/MCStreamer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=121006&r1=121005&r2=121006&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCStreamer.h (original) +++ llvm/trunk/include/llvm/MC/MCStreamer.h Mon Dec 6 11:27:56 2010 @@ -249,6 +249,12 @@ virtual void EmitIntValue(uint64_t Value, unsigned Size, unsigned AddrSpace = 0); + /// EmitAbsValue - Emit the Value, but try to avoid relocations. On MachO + /// this is done by producing + /// foo = value + /// .long foo + void EmitAbsValue(const MCExpr *Value, unsigned Size, + unsigned AddrSpace = 0); virtual void EmitULEB128Value(const MCExpr *Value, unsigned AddrSpace = 0) = 0; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp?rev=121006&r1=121005&r2=121006&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Mon Dec 6 11:27:56 2010 @@ -156,7 +156,7 @@ const MCExpr *Exp = TLOF.getExprForDwarfReference(Sym, Mang, MMI, Encoding, OutStreamer); - OutStreamer.EmitValue(Exp, GetSizeOfEncodedValue(Encoding), /*addrspace*/0); + OutStreamer.EmitAbsValue(Exp, GetSizeOfEncodedValue(Encoding)); } void AsmPrinter::EmitReference(const GlobalValue *GV, unsigned Encoding)const{ Modified: llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp?rev=121006&r1=121005&r2=121006&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp (original) +++ llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp Mon Dec 6 11:27:56 2010 @@ -40,7 +40,8 @@ // FIXME: Darwin 10 and newer don't need this. LinkerRequiresNonEmptyDwarfLines = true; - + + NeedsSetToChangeDiffSize = true; HiddenVisibilityAttr = MCSA_PrivateExtern; // Doesn't support protected visibility. ProtectedVisibilityAttr = MCSA_Global; Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=121006&r1=121005&r2=121006&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Mon Dec 6 11:27:56 2010 @@ -512,32 +512,6 @@ EmitValue(MCConstantExpr::Create(Value, getContext()), Size, AddrSpace); } -static bool hasSymbolDifference(const MCExpr *Value) { - switch (Value->getKind()) { - case MCExpr::Target: llvm_unreachable("Can't handle target exprs yet!"); - case MCExpr::Constant: - case MCExpr::SymbolRef: - return false; - case MCExpr::Unary: - return hasSymbolDifference(cast(Value)->getSubExpr()); - case MCExpr::Binary: { - const MCBinaryExpr *BE = cast(Value); - if (BE->getOpcode() == MCBinaryExpr::Sub && - BE->getLHS()->getKind() == MCExpr::SymbolRef && - BE->getRHS()->getKind() == MCExpr::SymbolRef) - return true; - return hasSymbolDifference(BE->getLHS()) || - hasSymbolDifference(BE->getRHS()); - } - } - llvm_unreachable("Switch covers all cases"); -} - -bool MCAsmStreamer::needsSet(const MCExpr *Value) { - return getContext().getAsmInfo().needsSetToChangeDiffSize() && - hasSymbolDifference(Value); -} - void MCAsmStreamer::EmitValue(const MCExpr *Value, unsigned Size, unsigned AddrSpace) { assert(CurSection && "Cannot emit contents before setting section!"); @@ -565,14 +539,6 @@ } assert(Directive && "Invalid size for machine code value!"); - if (needsSet(Value)) { - MCSymbol *SetLabel = getContext().CreateTempSymbol(); - EmitAssignment(SetLabel, Value); - OS << Directive << *SetLabel; - EmitEOL(); - return; - } - OS << Directive << *Value; EmitEOL(); } Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=121006&r1=121005&r2=121006&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Mon Dec 6 11:27:56 2010 @@ -213,15 +213,8 @@ // The first 4 bytes is the total length of the information for this // compilation unit (not including these 4 bytes for the length). - // FIXME: We create the dummy TotalLength variable because LineEndSym points - // to the end of the section and the darwin assembler doesn't consider that - // difference an assembly time constant. It might be better for this to be - // proected by a flag. - MCSymbol *TotalLength = MCOS->getContext().CreateTempSymbol(); - MCOS->EmitAssignment(TotalLength, - MakeStartMinusEndExpr(MCOS, LineStartSym, LineEndSym, - 4)); - MCOS->EmitSymbolValue(TotalLength, 4, 0); + MCOS->EmitAbsValue(MakeStartMinusEndExpr(MCOS, LineStartSym, LineEndSym,4), + 4); // Next 2 bytes is the Version, which is Dwarf 2. MCOS->EmitIntValue(2, 2); @@ -233,7 +226,7 @@ // section to the end of the prologue. Not including the 4 bytes for the // total length, the 2 bytes for the version, and these 4 bytes for the // length of the prologue. - MCOS->EmitValue(MakeStartMinusEndExpr(MCOS, LineStartSym, ProEndSym, + MCOS->EmitAbsValue(MakeStartMinusEndExpr(MCOS, LineStartSym, ProEndSym, (4 + 2 + 4)), 4, 0); Modified: llvm/trunk/lib/MC/MCStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=121006&r1=121005&r2=121006&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCStreamer.cpp Mon Dec 6 11:27:56 2010 @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCExpr.h" @@ -72,6 +73,17 @@ EmitBytes(OSE.str(), AddrSpace); } +void MCStreamer::EmitAbsValue(const MCExpr *Value, unsigned Size, + unsigned AddrSpace) { + if (!getContext().getAsmInfo().needsSetToChangeDiffSize()) { + EmitValue(Value, Size, AddrSpace); + return; + } + MCSymbol *ABS = getContext().CreateTempSymbol(); + EmitAssignment(ABS, Value); + EmitSymbolValue(ABS, Size, AddrSpace); +} + void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size, unsigned AddrSpace) { EmitValue(MCSymbolRefExpr::Create(Sym, getContext()), Size, AddrSpace); Modified: llvm/trunk/lib/Target/PowerPC/PPCMCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCMCAsmInfo.cpp?rev=121006&r1=121005&r2=121006&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCMCAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCMCAsmInfo.cpp Mon Dec 6 11:27:56 2010 @@ -22,9 +22,6 @@ if (!is64Bit) Data64bitsDirective = 0; // We can't emit a 64-bit unit in PPC32 mode. - if (is64Bit) - NeedsSetToChangeDiffSize = true; - AssemblerDialect = 1; // New-Style mnemonics. SupportsDebugInformation= true; // Debug information. } Modified: llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp?rev=121006&r1=121005&r2=121006&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp Mon Dec 6 11:27:56 2010 @@ -56,10 +56,6 @@ if (!is64Bit) Data64bitsDirective = 0; // we can't emit a 64-bit unit - // FIXME: Darwin 10 doesn't need this. - if (is64Bit) - NeedsSetToChangeDiffSize = true; - // Use ## as a comment string so that .s files generated by llvm can go // through the GCC preprocessor without causing an error. This is needed // because "clang foo.s" runs the C preprocessor, which is usually reserved Modified: llvm/trunk/test/MC/MachO/empty-dwarf-lines.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/empty-dwarf-lines.s?rev=121006&r1=121005&r2=121006&view=diff ============================================================================== --- llvm/trunk/test/MC/MachO/empty-dwarf-lines.s (original) +++ llvm/trunk/test/MC/MachO/empty-dwarf-lines.s Mon Dec 6 11:27:56 2010 @@ -16,8 +16,8 @@ // CHECK-NEXT: ('size', 44) // CHECK-NEXT: ('offset', 452) // CHECK-NEXT: ('alignment', 0) -// CHECK-NEXT: ('reloc_offset', 496) -// CHECK-NEXT: ('num_reloc', 2) +// CHECK-NEXT: ('reloc_offset', 0) +// CHECK-NEXT: ('num_reloc', 0) // CHECK-NEXT: ('flags', 0x2000000) // CHECK-NEXT: ('reserved1', 0) // CHECK-NEXT: ('reserved2', 0) From baldrick at free.fr Mon Dec 6 11:36:28 2010 From: baldrick at free.fr (Duncan Sands) Date: Mon, 06 Dec 2010 18:36:28 +0100 Subject: [llvm-commits] [llvm] r120974 - in /llvm/trunk: include/llvm/Analysis/AliasAnalysis.h lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/simple.ll In-Reply-To: <4A44A164-25BF-49E5-A922-9EE107337CCF@apple.com> References: <20101206014806.79E942A6C12C@llvm.org> <03608C35-109D-4B5A-9E39-0879DD0047AC@gmail.com> <4A44A164-25BF-49E5-A922-9EE107337CCF@apple.com> Message-ID: <4CFD1F1C.6040001@free.fr> Hi Chris, >> Aren't the operands of memcpy guaranteed not to overlap, so this would be undefined behaviour? > > Yes, sort of! In practice, we allow memcpy's that overlap if the src/dst pointer is exactly the same. This is because we want struct copies in C to be able to compile into memcpy, not memmove. There is this code in Clang in CGExprAgg.cpp: > > // Aggregate assignment turns into llvm.memcpy. This is almost valid per > // C99 6.5.16.1p3, which states "If the value being stored in an object is > // read from another object that overlaps in anyway the storage of the first > // object, then the overlap shall be exact and the two objects shall have > // qualified or unqualified versions of a compatible type." > // > // memcpy is not defined if the source and destination pointers are exactly > // equal, but other compilers do this optimization, and almost every memcpy > // implementation handles this case safely. If there is a libc that does not > // safely handle this, we can add a target hook. > > Note that the example from the PR doesn't explicitly call memcpy. I've been told that on some platforms zeroing the target memory before doing the copy speeds it up due to cache effects. It looks like clang's implementation of struct copy will not work on such targets. Ciao, Duncan. From grosbach at apple.com Mon Dec 6 11:38:44 2010 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 6 Dec 2010 09:38:44 -0800 Subject: [llvm-commits] [llvm] r120960 - in /llvm/trunk: lib/Target/ARM/ test/CodeGen/ARM/ In-Reply-To: <20101205220416.D17E72A6C12C@llvm.org> References: <20101205220416.D17E72A6C12C@llvm.org> Message-ID: <83FB2D9C-4B62-46C6-AA1B-CBA2468234DE@apple.com> Very cool. I've always felt vaguely guilty about the "just don't use them at all" heuristic for these instructions. It's great to see a real solution moving into place. It's also kinda scary just how much work is necessary to correctly model them. Yeesh. -Jim On Dec 5, 2010, at 2:04 PM, Evan Cheng wrote: > Author: evancheng > Date: Sun Dec 5 16:04:16 2010 > New Revision: 120960 > > URL: http://llvm.org/viewvc/llvm-project?rev=120960&view=rev > Log: > Making use of VFP / NEON floating point multiply-accumulate / subtraction is > difficult on current ARM implementations for a few reasons. > 1. Even though a single vmla has latency that is one cycle shorter than a pair > of vmul + vadd, a RAW hazard during the first (4? on Cortex-a8) can cause > additional pipeline stall. So it's frequently better to single codegen > vmul + vadd. > 2. A vmla folowed by a vmul, vmadd, or vsub causes the second fp instruction to > stall for 4 cycles. We need to schedule them apart. > 3. A vmla followed vmla is a special case. Obvious issuing back to back RAW > vmla + vmla is very bad. But this isn't ideal either: > vmul > vadd > vmla > Instead, we want to expand the second vmla: > vmla > vmul > vadd > Even with the 4 cycle vmul stall, the second sequence is still 2 cycles > faster. > > Up to now, isel simply avoid codegen'ing fp vmla / vmls. This works well enough > but it isn't the optimial solution. This patch attempts to make it possible to > use vmla / vmls in cases where it is profitable. > > A. Add missing isel predicates which cause vmla to be codegen'ed. > B. Make sure the fmul in (fadd (fmul)) has a single use. We don't want to > compute a fmul and a fmla. > C. Add additional isel checks for vmla, avoid cases where vmla is feeding into > fp instructions (except for the #3 exceptional case). > D. Add ARM hazard recognizer to model the vmla / vmls hazards. > E. Add a special pre-regalloc case to expand vmla / vmls when it's likely the > vmla / vmls will trigger one of the special hazards. > > Work in progress, only A+B are enabled. > > Added: > llvm/trunk/lib/Target/ARM/ARMHazardRecognizer.cpp > llvm/trunk/lib/Target/ARM/ARMHazardRecognizer.h > llvm/trunk/lib/Target/ARM/MLxExpansionPass.cpp > Removed: > llvm/trunk/lib/Target/ARM/Thumb2HazardRecognizer.cpp > llvm/trunk/lib/Target/ARM/Thumb2HazardRecognizer.h > Modified: > llvm/trunk/lib/Target/ARM/ARM.h > llvm/trunk/lib/Target/ARM/ARM.td > llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp > llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h > llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp > llvm/trunk/lib/Target/ARM/ARMInstrInfo.td > llvm/trunk/lib/Target/ARM/ARMInstrNEON.td > llvm/trunk/lib/Target/ARM/ARMInstrVFP.td > llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp > llvm/trunk/lib/Target/ARM/ARMSubtarget.h > llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp > llvm/trunk/lib/Target/ARM/CMakeLists.txt > llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp > llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp > llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h > llvm/trunk/test/CodeGen/ARM/reg_sequence.ll > > Modified: llvm/trunk/lib/Target/ARM/ARM.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARM.h?rev=120960&r1=120959&r2=120960&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARM.h (original) > +++ llvm/trunk/lib/Target/ARM/ARM.h Sun Dec 5 16:04:16 2010 > @@ -49,6 +49,7 @@ > FunctionPass *createARMGlobalMergePass(const TargetLowering* tli); > FunctionPass *createARMConstantIslandPass(); > FunctionPass *createNEONMoveFixPass(); > +FunctionPass *createMLxExpansionPass(); > FunctionPass *createThumb2ITBlockPass(); > FunctionPass *createThumb2SizeReductionPass(); > > > Modified: llvm/trunk/lib/Target/ARM/ARM.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARM.td?rev=120960&r1=120959&r2=120960&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARM.td (original) > +++ llvm/trunk/lib/Target/ARM/ARM.td Sun Dec 5 16:04:16 2010 > @@ -46,14 +46,11 @@ > def FeatureVFPOnlySP : SubtargetFeature<"fp-only-sp", "FPOnlySP", "true", > "Floating point unit supports single precision only">; > > -// Some processors have multiply-accumulate instructions that don't > -// play nicely with other VFP instructions, and it's generally better > +// Some processors have FP multiply-accumulate instructions that don't > +// play nicely with other VFP / NEON instructions, and it's generally better > // to just not use them. > -// FIXME: Currently, this is only flagged for Cortex-A8. It may be true for > -// others as well. We should do more benchmarking and confirm one way or > -// the other. > -def FeatureHasSlowVMLx : SubtargetFeature<"vmlx", "SlowVMLx", "true", > - "Disable VFP MAC instructions">; > +def FeatureHasSlowFPVMLx : SubtargetFeature<"slowfpvmlx", "SlowFPVMLx", "true", > + "Disable VFP / NEON MAC instructions">; > // Some processors benefit from using NEON instructions for scalar > // single-precision FP operations. > def FeatureNEONForFP : SubtargetFeature<"neonfp", "UseNEONForSinglePrecisionFP", > @@ -150,26 +147,29 @@ > // V6 Processors. > def : Processor<"arm1136j-s", ARMV6Itineraries, [ArchV6]>; > def : Processor<"arm1136jf-s", ARMV6Itineraries, [ArchV6, FeatureVFP2, > - FeatureHasSlowVMLx]>; > + FeatureHasSlowFPVMLx]>; > def : Processor<"arm1176jz-s", ARMV6Itineraries, [ArchV6]>; > -def : Processor<"arm1176jzf-s", ARMV6Itineraries, [ArchV6, FeatureVFP2]>; > +def : Processor<"arm1176jzf-s", ARMV6Itineraries, [ArchV6, FeatureVFP2, > + FeatureHasSlowFPVMLx]>; > def : Processor<"mpcorenovfp", ARMV6Itineraries, [ArchV6]>; > -def : Processor<"mpcore", ARMV6Itineraries, [ArchV6, FeatureVFP2]>; > +def : Processor<"mpcore", ARMV6Itineraries, [ArchV6, FeatureVFP2, > + FeatureHasSlowFPVMLx]>; > > // V6M Processors. > def : Processor<"cortex-m0", ARMV6Itineraries, [ArchV6M]>; > > // V6T2 Processors. > def : Processor<"arm1156t2-s", ARMV6Itineraries, [ArchV6T2]>; > -def : Processor<"arm1156t2f-s", ARMV6Itineraries, [ArchV6T2, FeatureVFP2]>; > +def : Processor<"arm1156t2f-s", ARMV6Itineraries, [ArchV6T2, FeatureVFP2, > + FeatureHasSlowFPVMLx]>; > > // V7 Processors. > def : Processor<"cortex-a8", CortexA8Itineraries, > [ArchV7A, ProcA8, > - FeatureHasSlowVMLx, FeatureT2XtPk]>; > + FeatureHasSlowFPVMLx, FeatureT2XtPk]>; > def : Processor<"cortex-a9", CortexA9Itineraries, > [ArchV7A, ProcA9, > - FeatureHasSlowVMLx, FeatureT2XtPk]>; > + FeatureHasSlowFPVMLx, FeatureT2XtPk]>; > > // V7M Processors. > def : ProcNoItin<"cortex-m3", [ArchV7M]>; > > Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=120960&r1=120959&r2=120960&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Sun Dec 5 16:04:16 2010 > @@ -15,6 +15,7 @@ > #include "ARM.h" > #include "ARMAddressingModes.h" > #include "ARMConstantPoolValue.h" > +#include "ARMHazardRecognizer.h" > #include "ARMMachineFunctionInfo.h" > #include "ARMRegisterInfo.h" > #include "ARMGenInstrInfo.inc" > @@ -40,9 +41,58 @@ > EnableARM3Addr("enable-arm-3-addr-conv", cl::Hidden, > cl::desc("Enable ARM 2-addr to 3-addr conv")); > > + > +/// ARM_MLxEntry - Record information about MLA / MLS instructions. > +struct ARM_MLxEntry { > + unsigned MLxOpc; // MLA / MLS opcode > + unsigned MulOpc; // Expanded multiplication opcode > + unsigned AddSubOpc; // Expanded add / sub opcode > + bool NegAcc; // True if the acc is negated before the add / sub. > + bool HasLane; // True if instruction has an extra "lane" operand. > +}; > + > +static const ARM_MLxEntry ARM_MLxTable[] = { > + // MLxOpc, MulOpc, AddSubOpc, NegAcc, HasLane > + // fp scalar ops > + { ARM::VMLAS, ARM::VMULS, ARM::VADDS, false, false }, > + { ARM::VMLSS, ARM::VMULS, ARM::VSUBS, false, false }, > + { ARM::VMLAD, ARM::VMULD, ARM::VADDD, false, false }, > + { ARM::VMLSD, ARM::VMULD, ARM::VSUBD, false, false }, > + { ARM::VMLAfd_sfp, ARM::VMULfd_sfp, ARM::VADDfd_sfp, false, false }, > + { ARM::VMLSfd_sfp, ARM::VMULfd_sfp, ARM::VSUBfd_sfp, false, false }, > + { ARM::VNMLAS, ARM::VNMULS, ARM::VSUBS, true, false }, > + { ARM::VNMLSS, ARM::VMULS, ARM::VSUBS, true, false }, > + { ARM::VNMLAD, ARM::VNMULD, ARM::VSUBD, true, false }, > + { ARM::VNMLSD, ARM::VMULD, ARM::VSUBD, true, false }, > + > + // fp SIMD ops > + { ARM::VMLAfd, ARM::VMULfd, ARM::VADDfd, false, false }, > + { ARM::VMLSfd, ARM::VMULfd, ARM::VSUBfd, false, false }, > + { ARM::VMLAfq, ARM::VMULfq, ARM::VADDfq, false, false }, > + { ARM::VMLSfq, ARM::VMULfq, ARM::VSUBfq, false, false }, > + { ARM::VMLAslfd, ARM::VMULslfd, ARM::VADDfd, false, true }, > + { ARM::VMLSslfd, ARM::VMULslfd, ARM::VSUBfd, false, true }, > + { ARM::VMLAslfq, ARM::VMULslfq, ARM::VADDfq, false, true }, > + { ARM::VMLSslfq, ARM::VMULslfq, ARM::VSUBfq, false, true }, > +}; > + > ARMBaseInstrInfo::ARMBaseInstrInfo(const ARMSubtarget& STI) > : TargetInstrInfoImpl(ARMInsts, array_lengthof(ARMInsts)), > Subtarget(STI) { > + for (unsigned i = 0, e = array_lengthof(ARM_MLxTable); i != e; ++i) { > + if (!MLxEntryMap.insert(std::make_pair(ARM_MLxTable[i].MLxOpc, i)).second) > + assert(false && "Duplicated entries?"); > + MLxHazardOpcodes.insert(ARM_MLxTable[i].AddSubOpc); > + MLxHazardOpcodes.insert(ARM_MLxTable[i].MulOpc); > + } > +} > + > +ScheduleHazardRecognizer *ARMBaseInstrInfo:: > +CreateTargetPostRAHazardRecognizer(const InstrItineraryData *II) const { > + if (Subtarget.isThumb2() || Subtarget.hasVFP2()) > + return (ScheduleHazardRecognizer *) > + new ARMHazardRecognizer(II, *this, getRegisterInfo(), Subtarget); > + return TargetInstrInfoImpl::CreateTargetPostRAHazardRecognizer(II); > } > > MachineInstr * > @@ -197,7 +247,6 @@ > return NewMIs[0]; > } > > - > // Branch analysis. > bool > ARMBaseInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,MachineBasicBlock *&TBB, > @@ -2196,3 +2245,19 @@ > } > return false; > } > + > +bool > +ARMBaseInstrInfo::isFpMLxInstruction(unsigned Opcode, unsigned &MulOpc, > + unsigned &AddSubOpc, > + bool &NegAcc, bool &HasLane) const { > + DenseMap::const_iterator I = MLxEntryMap.find(Opcode); > + if (I == MLxEntryMap.end()) > + return false; > + > + const ARM_MLxEntry &Entry = ARM_MLxTable[I->second]; > + MulOpc = Entry.MulOpc; > + AddSubOpc = Entry.AddSubOpc; > + NegAcc = Entry.NegAcc; > + HasLane = Entry.HasLane; > + return true; > +} > > Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h?rev=120960&r1=120959&r2=120960&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h (original) > +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h Sun Dec 5 16:04:16 2010 > @@ -17,6 +17,8 @@ > #include "ARM.h" > #include "llvm/CodeGen/MachineInstrBuilder.h" > #include "llvm/Target/TargetInstrInfo.h" > +#include "llvm/ADT/DenseMap.h" > +#include "llvm/ADT/SmallSet.h" > > namespace llvm { > class ARMSubtarget; > @@ -191,9 +193,11 @@ > > class ARMBaseInstrInfo : public TargetInstrInfoImpl { > const ARMSubtarget &Subtarget; > + > protected: > // Can be only subclassed. > explicit ARMBaseInstrInfo(const ARMSubtarget &STI); > + > public: > // Return the non-pre/post incrementing version of 'Opc'. Return 0 > // if there is not such an opcode. > @@ -206,7 +210,9 @@ > virtual const ARMBaseRegisterInfo &getRegisterInfo() const =0; > const ARMSubtarget &getSubtarget() const { return Subtarget; } > > -public: > + ScheduleHazardRecognizer * > + CreateTargetPostRAHazardRecognizer(const InstrItineraryData *II) const; > + > // Branch analysis. > virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, > MachineBasicBlock *&FBB, > @@ -393,6 +399,38 @@ > const MachineInstr *UseMI, unsigned UseIdx) const; > bool hasLowDefLatency(const InstrItineraryData *ItinData, > const MachineInstr *DefMI, unsigned DefIdx) const; > + > +private: > + /// Modeling special VFP / NEON fp MLA / MLS hazards. > + > + /// MLxEntryMap - Map fp MLA / MLS to the corresponding entry in the internal > + /// MLx table. > + DenseMap MLxEntryMap; > + > + /// MLxHazardOpcodes - Set of add / sub and multiply opcodes that would cause > + /// stalls when scheduled together with fp MLA / MLS opcodes. > + SmallSet MLxHazardOpcodes; > + > +public: > + /// isFpMLxInstruction - Return true if the specified opcode is a fp MLA / MLS > + /// instruction. > + bool isFpMLxInstruction(unsigned Opcode) const { > + return MLxEntryMap.count(Opcode); > + } > + > + /// isFpMLxInstruction - This version also returns the multiply opcode and the > + /// addition / subtraction opcode to expand to. Return true for 'HasLane' for > + /// the MLX instructions with an extra lane operand. > + bool isFpMLxInstruction(unsigned Opcode, unsigned &MulOpc, > + unsigned &AddSubOpc, bool &NegAcc, > + bool &HasLane) const; > + > + /// canCauseFpMLxStall - Return true if an instruction of the specified opcode > + /// will cause stalls when scheduled after (within 4-cycle window) a fp > + /// MLA / MLS instruction. > + bool canCauseFpMLxStall(unsigned Opcode) const { > + return MLxHazardOpcodes.count(Opcode); > + } > }; > > static inline > > Added: llvm/trunk/lib/Target/ARM/ARMHazardRecognizer.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMHazardRecognizer.cpp?rev=120960&view=auto > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMHazardRecognizer.cpp (added) > +++ llvm/trunk/lib/Target/ARM/ARMHazardRecognizer.cpp Sun Dec 5 16:04:16 2010 > @@ -0,0 +1,114 @@ > +//===-- ARMHazardRecognizer.cpp - ARM postra hazard recognizer ------------===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > + > +#include "ARMHazardRecognizer.h" > +#include "ARMBaseInstrInfo.h" > +#include "ARMSubtarget.h" > +#include "llvm/CodeGen/MachineInstr.h" > +#include "llvm/CodeGen/ScheduleDAG.h" > +#include "llvm/Target/TargetRegisterInfo.h" > +using namespace llvm; > + > +static bool hasRAWHazard(MachineInstr *DefMI, MachineInstr *MI, > + const TargetRegisterInfo &TRI) { > + // FIXME: Detect integer instructions properly. > + const TargetInstrDesc &TID = MI->getDesc(); > + unsigned Domain = TID.TSFlags & ARMII::DomainMask; > + if (Domain == ARMII::DomainVFP) { > + unsigned Opcode = MI->getOpcode(); > + if (Opcode == ARM::VSTRS || Opcode == ARM::VSTRD || > + Opcode == ARM::VMOVRS || Opcode == ARM::VMOVRRD) > + return false; > + } else if (Domain == ARMII::DomainNEON) { > + if (MI->getDesc().mayStore() || MI->getDesc().mayLoad()) > + return false; > + } else > + return false; > + return MI->readsRegister(DefMI->getOperand(0).getReg(), &TRI); > +} > + > +ScheduleHazardRecognizer::HazardType > +ARMHazardRecognizer::getHazardType(SUnit *SU) { > + MachineInstr *MI = SU->getInstr(); > + > + if (!MI->isDebugValue()) { > + if (ITBlockSize && MI != ITBlockMIs[ITBlockSize-1]) > + return Hazard; > + > + // Look for special VMLA / VMLS hazards. A VMUL / VADD / VSUB following > + // a VMLA / VMLS will cause 4 cycle stall. > + const TargetInstrDesc &TID = MI->getDesc(); > + if (LastMI && (TID.TSFlags & ARMII::DomainMask) != ARMII::DomainGeneral) { > + MachineInstr *DefMI = LastMI; > + const TargetInstrDesc &LastTID = LastMI->getDesc(); > + // Skip over one non-VFP / NEON instruction. > + if (!LastTID.isBarrier() && > + (LastTID.TSFlags & ARMII::DomainMask) == ARMII::DomainGeneral) { > + MachineBasicBlock::iterator I = LastMI; > + if (I != LastMI->getParent()->begin()) { > + I = llvm::prior(I); > + DefMI = &*I; > + } > + } > + > + if (TII.isFpMLxInstruction(DefMI->getOpcode()) && > + (TII.canCauseFpMLxStall(MI->getOpcode()) || > + hasRAWHazard(DefMI, MI, TRI))) { > + // Try to schedule another instruction for the next 4 cycles. > + if (Stalls == 0) > + Stalls = 4; > + return Hazard; > + } > + } > + } > + > + return PostRAHazardRecognizer::getHazardType(SU); > +} > + > +void ARMHazardRecognizer::Reset() { > + LastMI = 0; > + Stalls = 0; > + ITBlockSize = 0; > + PostRAHazardRecognizer::Reset(); > +} > + > +void ARMHazardRecognizer::EmitInstruction(SUnit *SU) { > + MachineInstr *MI = SU->getInstr(); > + unsigned Opcode = MI->getOpcode(); > + if (ITBlockSize) { > + --ITBlockSize; > + } else if (Opcode == ARM::t2IT) { > + unsigned Mask = MI->getOperand(1).getImm(); > + unsigned NumTZ = CountTrailingZeros_32(Mask); > + assert(NumTZ <= 3 && "Invalid IT mask!"); > + ITBlockSize = 4 - NumTZ; > + MachineBasicBlock::iterator I = MI; > + for (unsigned i = 0; i < ITBlockSize; ++i) { > + // Advance to the next instruction, skipping any dbg_value instructions. > + do { > + ++I; > + } while (I->isDebugValue()); > + ITBlockMIs[ITBlockSize-1-i] = &*I; > + } > + } > + > + if (!MI->isDebugValue()) { > + LastMI = MI; > + Stalls = 0; > + } > + > + PostRAHazardRecognizer::EmitInstruction(SU); > +} > + > +void ARMHazardRecognizer::AdvanceCycle() { > + if (Stalls && --Stalls == 0) > + // Stalled for 4 cycles but still can't schedule any other instructions. > + LastMI = 0; > + PostRAHazardRecognizer::AdvanceCycle(); > +} > > Added: llvm/trunk/lib/Target/ARM/ARMHazardRecognizer.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMHazardRecognizer.h?rev=120960&view=auto > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMHazardRecognizer.h (added) > +++ llvm/trunk/lib/Target/ARM/ARMHazardRecognizer.h Sun Dec 5 16:04:16 2010 > @@ -0,0 +1,53 @@ > +//===-- ARMHazardRecognizer.h - ARM Hazard Recognizers ----------*- C++ -*-===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > +// > +// This file defines hazard recognizers for scheduling ARM functions. > +// > +//===----------------------------------------------------------------------===// > + > +#ifndef ARMHAZARDRECOGNIZER_H > +#define ARMHAZARDRECOGNIZER_H > + > +#include "llvm/CodeGen/PostRAHazardRecognizer.h" > + > +namespace llvm { > + > +class ARMBaseInstrInfo; > +class ARMBaseRegisterInfo; > +class ARMSubtarget; > +class MachineInstr; > + > +class ARMHazardRecognizer : public PostRAHazardRecognizer { > + const ARMBaseInstrInfo &TII; > + const ARMBaseRegisterInfo &TRI; > + const ARMSubtarget &STI; > + > + MachineInstr *LastMI; > + unsigned Stalls; > + unsigned ITBlockSize; // No. of MIs in current IT block yet to be scheduled. > + MachineInstr *ITBlockMIs[4]; > + > +public: > + ARMHazardRecognizer(const InstrItineraryData *ItinData, > + const ARMBaseInstrInfo &tii, > + const ARMBaseRegisterInfo &tri, > + const ARMSubtarget &sti) : > + PostRAHazardRecognizer(ItinData), TII(tii), TRI(tri), STI(sti), > + LastMI(0), ITBlockSize(0) {} > + > + virtual HazardType getHazardType(SUnit *SU); > + virtual void Reset(); > + virtual void EmitInstruction(SUnit *SU); > + virtual void AdvanceCycle(); > +}; > + > + > +} // end namespace llvm > + > +#endif // ARMHAZARDRECOGNIZER_H > > Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=120960&r1=120959&r2=120960&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Sun Dec 5 16:04:16 2010 > @@ -13,6 +13,7 @@ > > #define DEBUG_TYPE "arm-isel" > #include "ARM.h" > +#include "ARMBaseInstrInfo.h" > #include "ARMAddressingModes.h" > #include "ARMTargetMachine.h" > #include "llvm/CallingConv.h" > @@ -41,6 +42,11 @@ > cl::desc("Disable isel of shifter-op"), > cl::init(false)); > > +static cl::opt > +CheckVMLxHazard("check-vmlx-hazard", cl::Hidden, > + cl::desc("Check fp vmla / vmls hazard at isel time"), > + cl::init(false)); > + > //===--------------------------------------------------------------------===// > /// ARMDAGToDAGISel - ARM specific code to select ARM machine > /// instructions for SelectionDAG operations. > @@ -54,6 +60,7 @@ > > class ARMDAGToDAGISel : public SelectionDAGISel { > ARMBaseTargetMachine &TM; > + const ARMBaseInstrInfo *TII; > > /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can > /// make the right decision when generating code for different targets. > @@ -63,7 +70,8 @@ > explicit ARMDAGToDAGISel(ARMBaseTargetMachine &tm, > CodeGenOpt::Level OptLevel) > : SelectionDAGISel(tm, OptLevel), TM(tm), > - Subtarget(&TM.getSubtarget()) { > + TII(static_cast(TM.getInstrInfo())), > + Subtarget(&TM.getSubtarget()) { > } > > virtual const char *getPassName() const { > @@ -78,6 +86,8 @@ > > SDNode *Select(SDNode *N); > > + > + bool hasNoVMLxHazardUse(SDNode *N) const; > bool isShifterOpProfitable(const SDValue &Shift, > ARM_AM::ShiftOpc ShOpcVal, unsigned ShAmt); > bool SelectShifterOperandReg(SDValue N, SDValue &A, > @@ -272,6 +282,50 @@ > isInt32Immediate(N->getOperand(1).getNode(), Imm); > } > > +/// hasNoVMLxHazardUse - Return true if it's desirable to select a FP MLA / MLS > +/// node. VFP / NEON fp VMLA / VMLS instructions have special RAW hazards (at > +/// least on current ARM implementations) which should be avoidded. > +bool ARMDAGToDAGISel::hasNoVMLxHazardUse(SDNode *N) const { > + if (OptLevel == CodeGenOpt::None) > + return true; > + > + if (!CheckVMLxHazard) > + return true; > + > + if (!Subtarget->isCortexA8() && !Subtarget->isCortexA9()) > + return true; > + > + if (!N->hasOneUse()) > + return false; > + > + SDNode *Use = *N->use_begin(); > + if (Use->getOpcode() == ISD::CopyToReg) > + return true; > + if (Use->isMachineOpcode()) { > + const TargetInstrDesc &TID = TII->get(Use->getMachineOpcode()); > + if (TID.mayStore()) > + return true; > + unsigned Opcode = TID.getOpcode(); > + if (Opcode == ARM::VMOVRS || Opcode == ARM::VMOVRRD) > + return true; > + // vmlx feeding into another vmlx. We actually want to unfold > + // the use later in the MLxExpansion pass. e.g. > + // vmla > + // vmla (stall 8 cycles) > + // > + // vmul (5 cycles) > + // vadd (5 cycles) > + // vmla > + // This adds up to about 18 - 19 cycles. > + // > + // vmla > + // vmul (stall 4 cycles) > + // vadd adds up to about 14 cycles. > + return TII->isFpMLxInstruction(Opcode); > + } > + > + return false; > +} > > bool ARMDAGToDAGISel::isShifterOpProfitable(const SDValue &Shift, > ARM_AM::ShiftOpc ShOpcVal, > > Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=120960&r1=120959&r2=120960&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) > +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Sun Dec 5 16:04:16 2010 > @@ -175,7 +175,7 @@ > // FIXME: Eventually this will be just "hasV6T2Ops". > def UseMovt : Predicate<"Subtarget->useMovt()">; > def DontUseMovt : Predicate<"!Subtarget->useMovt()">; > -def UseVMLx : Predicate<"Subtarget->useVMLx()">; > +def UseFPVMLx : Predicate<"Subtarget->useFPVMLx()">; > > //===----------------------------------------------------------------------===// > // ARM Flag Definitions. > @@ -279,6 +279,21 @@ > return N->hasOneUse(); > }]>; > > +// An 'fmul' node with a single use. > +def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{ > + return N->hasOneUse(); > +}]>; > + > +// An 'fadd' node which checks for single non-hazardous use. > +def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{ > + return hasNoVMLxHazardUse(N); > +}]>; > + > +// An 'fsub' node which checks for single non-hazardous use. > +def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{ > + return hasNoVMLxHazardUse(N); > +}]>; > + > //===----------------------------------------------------------------------===// > // Operand Definitions. > // > > Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=120960&r1=120959&r2=120960&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) > +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Sun Dec 5 16:04:16 2010 > @@ -1907,7 +1907,7 @@ > // Multiply-Add/Sub operations: single-, double- and quad-register. > class N3VSMulOp op21_20, bits<4> op11_8, bit op4, > InstrItinClass itin, string OpcodeStr, string Dt, > - ValueType Ty, SDNode MulOp, SDNode OpNode> > + ValueType Ty, SDPatternOperator MulOp, SDNode OpNode> > : N3V (outs DPR_VFP2:$Vd), > (ins DPR_VFP2:$src1, DPR_VFP2:$Vn, DPR_VFP2:$Vm), N3RegFrm, itin, > @@ -1915,7 +1915,7 @@ > > class N3VDMulOp op21_20, bits<4> op11_8, bit op4, > InstrItinClass itin, string OpcodeStr, string Dt, > - ValueType Ty, SDNode MulOp, SDNode OpNode> > + ValueType Ty, SDPatternOperator MulOp, SDPatternOperator OpNode> > : N3V (outs DPR:$Vd), (ins DPR:$src1, DPR:$Vn, DPR:$Vm), N3RegFrm, itin, > OpcodeStr, Dt, "$Vd, $Vn, $Vm", "$src1 = $Vd", > @@ -1924,7 +1924,7 @@ > > class N3VDMulOpSL op21_20, bits<4> op11_8, InstrItinClass itin, > string OpcodeStr, string Dt, > - ValueType Ty, SDNode MulOp, SDNode ShOp> > + ValueType Ty, SDPatternOperator MulOp, SDPatternOperator ShOp> > : N3V<0, 1, op21_20, op11_8, 1, 0, > (outs DPR:$Vd), > (ins DPR:$src1, DPR:$Vn, DPR_VFP2:$Vm, nohash_imm:$lane), > @@ -1951,7 +1951,7 @@ > > class N3VQMulOp op21_20, bits<4> op11_8, bit op4, > InstrItinClass itin, string OpcodeStr, string Dt, ValueType Ty, > - SDNode MulOp, SDNode OpNode> > + SDPatternOperator MulOp, SDPatternOperator OpNode> > : N3V (outs QPR:$Vd), (ins QPR:$src1, QPR:$Vn, QPR:$Vm), N3RegFrm, itin, > OpcodeStr, Dt, "$Vd, $Vn, $Vm", "$src1 = $Vd", > @@ -1959,7 +1959,7 @@ > (Ty (MulOp QPR:$Vn, QPR:$Vm)))))]>; > class N3VQMulOpSL op21_20, bits<4> op11_8, InstrItinClass itin, > string OpcodeStr, string Dt, ValueType ResTy, ValueType OpTy, > - SDNode MulOp, SDNode ShOp> > + SDPatternOperator MulOp, SDPatternOperator ShOp> > : N3V<1, 1, op21_20, op11_8, 1, 0, > (outs QPR:$Vd), > (ins QPR:$src1, QPR:$Vn, DPR_VFP2:$Vm, nohash_imm:$lane), > @@ -3282,15 +3282,19 @@ > defm VMLA : N3VMulOp_QHS<0, 0, 0b1001, 0, IIC_VMACi16D, IIC_VMACi32D, > IIC_VMACi16Q, IIC_VMACi32Q, "vmla", "i", add>; > def VMLAfd : N3VDMulOp<0, 0, 0b00, 0b1101, 1, IIC_VMACD, "vmla", "f32", > - v2f32, fmul, fadd>; > + v2f32, fmul_su, fadd_mlx>, > + Requires<[HasNEON, UseFPVMLx]>; > def VMLAfq : N3VQMulOp<0, 0, 0b00, 0b1101, 1, IIC_VMACQ, "vmla", "f32", > - v4f32, fmul, fadd>; > + v4f32, fmul_su, fadd_mlx>, > + Requires<[HasNEON, UseFPVMLx]>; > defm VMLAsl : N3VMulOpSL_HS<0b0000, IIC_VMACi16D, IIC_VMACi32D, > IIC_VMACi16Q, IIC_VMACi32Q, "vmla", "i", add>; > def VMLAslfd : N3VDMulOpSL<0b10, 0b0001, IIC_VMACD, "vmla", "f32", > - v2f32, fmul, fadd>; > + v2f32, fmul_su, fadd_mlx>, > + Requires<[HasNEON, UseFPVMLx]>; > def VMLAslfq : N3VQMulOpSL<0b10, 0b0001, IIC_VMACQ, "vmla", "f32", > - v4f32, v2f32, fmul, fadd>; > + v4f32, v2f32, fmul_su, fadd_mlx>, > + Requires<[HasNEON, UseFPVMLx]>; > > def : Pat<(v8i16 (add (v8i16 QPR:$src1), > (mul (v8i16 QPR:$src2), > @@ -3308,14 +3312,15 @@ > (DSubReg_i32_reg imm:$lane))), > (SubReg_i32_lane imm:$lane)))>; > > -def : Pat<(v4f32 (fadd (v4f32 QPR:$src1), > - (fmul (v4f32 QPR:$src2), > +def : Pat<(v4f32 (fadd_mlx (v4f32 QPR:$src1), > + (fmul_su (v4f32 QPR:$src2), > (v4f32 (NEONvduplane (v4f32 QPR:$src3), imm:$lane))))), > (v4f32 (VMLAslfq (v4f32 QPR:$src1), > (v4f32 QPR:$src2), > (v2f32 (EXTRACT_SUBREG QPR:$src3, > (DSubReg_i32_reg imm:$lane))), > - (SubReg_i32_lane imm:$lane)))>; > + (SubReg_i32_lane imm:$lane)))>, > + Requires<[HasNEON, UseFPVMLx]>; > > // VMLAL : Vector Multiply Accumulate Long (Q += D * D) > defm VMLALs : N3VLMulOp_QHS<0,1,0b1000,0, IIC_VMACi16D, IIC_VMACi32D, > @@ -3335,15 +3340,19 @@ > defm VMLS : N3VMulOp_QHS<1, 0, 0b1001, 0, IIC_VMACi16D, IIC_VMACi32D, > IIC_VMACi16Q, IIC_VMACi32Q, "vmls", "i", sub>; > def VMLSfd : N3VDMulOp<0, 0, 0b10, 0b1101, 1, IIC_VMACD, "vmls", "f32", > - v2f32, fmul, fsub>; > + v2f32, fmul_su, fsub_mlx>, > + Requires<[HasNEON, UseFPVMLx]>; > def VMLSfq : N3VQMulOp<0, 0, 0b10, 0b1101, 1, IIC_VMACQ, "vmls", "f32", > - v4f32, fmul, fsub>; > + v4f32, fmul_su, fsub_mlx>, > + Requires<[HasNEON, UseFPVMLx]>; > defm VMLSsl : N3VMulOpSL_HS<0b0100, IIC_VMACi16D, IIC_VMACi32D, > IIC_VMACi16Q, IIC_VMACi32Q, "vmls", "i", sub>; > def VMLSslfd : N3VDMulOpSL<0b10, 0b0101, IIC_VMACD, "vmls", "f32", > - v2f32, fmul, fsub>; > + v2f32, fmul_su, fsub_mlx>, > + Requires<[HasNEON, UseFPVMLx]>; > def VMLSslfq : N3VQMulOpSL<0b10, 0b0101, IIC_VMACQ, "vmls", "f32", > - v4f32, v2f32, fmul, fsub>; > + v4f32, v2f32, fmul_su, fsub_mlx>, > + Requires<[HasNEON, UseFPVMLx]>; > > def : Pat<(v8i16 (sub (v8i16 QPR:$src1), > (mul (v8i16 QPR:$src2), > @@ -3361,13 +3370,14 @@ > (DSubReg_i32_reg imm:$lane))), > (SubReg_i32_lane imm:$lane)))>; > > -def : Pat<(v4f32 (fsub (v4f32 QPR:$src1), > - (fmul (v4f32 QPR:$src2), > +def : Pat<(v4f32 (fsub_mlx (v4f32 QPR:$src1), > + (fmul_su (v4f32 QPR:$src2), > (v4f32 (NEONvduplane (v4f32 QPR:$src3), imm:$lane))))), > (v4f32 (VMLSslfq (v4f32 QPR:$src1), (v4f32 QPR:$src2), > (v2f32 (EXTRACT_SUBREG QPR:$src3, > (DSubReg_i32_reg imm:$lane))), > - (SubReg_i32_lane imm:$lane)))>; > + (SubReg_i32_lane imm:$lane)))>, > + Requires<[HasNEON, UseFPVMLx]>; > > // VMLSL : Vector Multiply Subtract Long (Q -= D * D) > defm VMLSLs : N3VLMulOp_QHS<0,1,0b1010,0, IIC_VMACi16D, IIC_VMACi32D, > @@ -4706,15 +4716,17 @@ > // vml[as].f32 can cause 4-8 cycle stalls in following ASIMD instructions, so > // we want to avoid them for now. e.g., alternating vmla/vadd instructions. > > -//let neverHasSideEffects = 1 in > -//def VMLAfd_sfp : N3VSMulOp<0,0,0b00,0b1101,1, IIC_VMACD, "vmla", "f32", > -// v2f32, fmul, fadd>; > -//def : N3VSMulOpPat; > - > -//let neverHasSideEffects = 1 in > -//def VMLSfd_sfp : N3VSMulOp<0,0,0b10,0b1101,1, IIC_VMACD, "vmls", "f32", > -// v2f32, fmul, fsub>; > -//def : N3VSMulOpPat; > +let neverHasSideEffects = 1 in > +def VMLAfd_sfp : N3VSMulOp<0,0,0b00,0b1101,1, IIC_VMACD, "vmla", "f32", > + v2f32, fmul_su, fadd>; > +def : N3VSMulOpPat, > + Requires<[HasNEON, UseNEONForFP, UseFPVMLx]>; > + > +let neverHasSideEffects = 1 in > +def VMLSfd_sfp : N3VSMulOp<0,0,0b10,0b1101,1, IIC_VMACD, "vmls", "f32", > + v2f32, fmul_su, fsub>; > +def : N3VSMulOpPat, > + Requires<[HasNEON, UseNEONForFP, UseFPVMLx]>; > > // Vector Absolute used for single-precision FP > let neverHasSideEffects = 1 in > > Modified: llvm/trunk/lib/Target/ARM/ARMInstrVFP.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrVFP.td?rev=120960&r1=120959&r2=120960&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMInstrVFP.td (original) > +++ llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Sun Dec 5 16:04:16 2010 > @@ -751,93 +751,93 @@ > def VMLAD : ADbI<0b11100, 0b00, 0, 0, > (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm), > IIC_fpMAC64, "vmla", ".f64\t$Dd, $Dn, $Dm", > - [(set DPR:$Dd, (fadd (fmul DPR:$Dn, DPR:$Dm), > - (f64 DPR:$Ddin)))]>, > + [(set DPR:$Dd, (fadd_mlx (fmul_su DPR:$Dn, DPR:$Dm), > + (f64 DPR:$Ddin)))]>, > RegConstraint<"$Ddin = $Dd">, > - Requires<[HasVFP2,UseVMLx]>; > + Requires<[HasVFP2,UseFPVMLx]>; > > def VMLAS : ASbIn<0b11100, 0b00, 0, 0, > (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm), > IIC_fpMAC32, "vmla", ".f32\t$Sd, $Sn, $Sm", > - [(set SPR:$Sd, (fadd (fmul SPR:$Sn, SPR:$Sm), > - SPR:$Sdin))]>, > + [(set SPR:$Sd, (fadd_mlx (fmul_su SPR:$Sn, SPR:$Sm), > + SPR:$Sdin))]>, > RegConstraint<"$Sdin = $Sd">, > - Requires<[HasVFP2,DontUseNEONForFP,UseVMLx]>; > + Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>; > > -def : Pat<(fadd DPR:$dstin, (fmul DPR:$a, (f64 DPR:$b))), > +def : Pat<(fadd_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))), > (VMLAD DPR:$dstin, DPR:$a, DPR:$b)>, > - Requires<[HasVFP2,UseVMLx]>; > -def : Pat<(fadd SPR:$dstin, (fmul SPR:$a, SPR:$b)), > + Requires<[HasVFP2,UseFPVMLx]>; > +def : Pat<(fadd_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)), > (VMLAS SPR:$dstin, SPR:$a, SPR:$b)>, > - Requires<[HasVFP2,DontUseNEONForFP, UseVMLx]>; > + Requires<[HasVFP2,DontUseNEONForFP, UseFPVMLx]>; > > def VMLSD : ADbI<0b11100, 0b00, 1, 0, > (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm), > IIC_fpMAC64, "vmls", ".f64\t$Dd, $Dn, $Dm", > - [(set DPR:$Dd, (fadd (fneg (fmul DPR:$Dn,DPR:$Dm)), > - (f64 DPR:$Ddin)))]>, > + [(set DPR:$Dd, (fadd_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)), > + (f64 DPR:$Ddin)))]>, > RegConstraint<"$Ddin = $Dd">, > - Requires<[HasVFP2,UseVMLx]>; > + Requires<[HasVFP2,UseFPVMLx]>; > > def VMLSS : ASbIn<0b11100, 0b00, 1, 0, > (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm), > IIC_fpMAC32, "vmls", ".f32\t$Sd, $Sn, $Sm", > - [(set SPR:$Sd, (fadd (fneg (fmul SPR:$Sn, SPR:$Sm)), > - SPR:$Sdin))]>, > + [(set SPR:$Sd, (fadd_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)), > + SPR:$Sdin))]>, > RegConstraint<"$Sdin = $Sd">, > - Requires<[HasVFP2,DontUseNEONForFP,UseVMLx]>; > + Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>; > > -def : Pat<(fsub DPR:$dstin, (fmul DPR:$a, (f64 DPR:$b))), > +def : Pat<(fsub_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))), > (VMLSD DPR:$dstin, DPR:$a, DPR:$b)>, > - Requires<[HasVFP2,UseVMLx]>; > -def : Pat<(fsub SPR:$dstin, (fmul SPR:$a, SPR:$b)), > + Requires<[HasVFP2,UseFPVMLx]>; > +def : Pat<(fsub_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)), > (VMLSS SPR:$dstin, SPR:$a, SPR:$b)>, > - Requires<[HasVFP2,DontUseNEONForFP,UseVMLx]>; > + Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>; > > def VNMLAD : ADbI<0b11100, 0b01, 1, 0, > (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm), > IIC_fpMAC64, "vnmla", ".f64\t$Dd, $Dn, $Dm", > - [(set DPR:$Dd,(fsub (fneg (fmul DPR:$Dn,DPR:$Dm)), > - (f64 DPR:$Ddin)))]>, > + [(set DPR:$Dd,(fsub_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)), > + (f64 DPR:$Ddin)))]>, > RegConstraint<"$Ddin = $Dd">, > - Requires<[HasVFP2,UseVMLx]>; > + Requires<[HasVFP2,UseFPVMLx]>; > > def VNMLAS : ASbI<0b11100, 0b01, 1, 0, > (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm), > IIC_fpMAC32, "vnmla", ".f32\t$Sd, $Sn, $Sm", > - [(set SPR:$Sd, (fsub (fneg (fmul SPR:$Sn, SPR:$Sm)), > - SPR:$Sdin))]>, > + [(set SPR:$Sd, (fsub_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)), > + SPR:$Sdin))]>, > RegConstraint<"$Sdin = $Sd">, > - Requires<[HasVFP2,DontUseNEONForFP,UseVMLx]>; > + Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>; > > -def : Pat<(fsub (fneg (fmul DPR:$a, (f64 DPR:$b))), DPR:$dstin), > +def : Pat<(fsub_mlx (fneg (fmul_su DPR:$a, (f64 DPR:$b))), DPR:$dstin), > (VNMLAD DPR:$dstin, DPR:$a, DPR:$b)>, > - Requires<[HasVFP2,UseVMLx]>; > -def : Pat<(fsub (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin), > + Requires<[HasVFP2,UseFPVMLx]>; > +def : Pat<(fsub_mlx (fneg (fmul_su SPR:$a, SPR:$b)), SPR:$dstin), > (VNMLAS SPR:$dstin, SPR:$a, SPR:$b)>, > - Requires<[HasVFP2,DontUseNEONForFP,UseVMLx]>; > + Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>; > > def VNMLSD : ADbI<0b11100, 0b01, 0, 0, > (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm), > IIC_fpMAC64, "vnmls", ".f64\t$Dd, $Dn, $Dm", > - [(set DPR:$Dd, (fsub (fmul DPR:$Dn, DPR:$Dm), > - (f64 DPR:$Ddin)))]>, > + [(set DPR:$Dd, (fsub_mlx (fmul_su DPR:$Dn, DPR:$Dm), > + (f64 DPR:$Ddin)))]>, > RegConstraint<"$Ddin = $Dd">, > - Requires<[HasVFP2,UseVMLx]>; > + Requires<[HasVFP2,UseFPVMLx]>; > > def VNMLSS : ASbI<0b11100, 0b01, 0, 0, > (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm), > IIC_fpMAC32, "vnmls", ".f32\t$Sd, $Sn, $Sm", > - [(set SPR:$Sd, (fsub (fmul SPR:$Sn, SPR:$Sm), SPR:$Sdin))]>, > + [(set SPR:$Sd, (fsub_mlx (fmul_su SPR:$Sn, SPR:$Sm), SPR:$Sdin))]>, > RegConstraint<"$Sdin = $Sd">, > - Requires<[HasVFP2,DontUseNEONForFP,UseVMLx]>; > + Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>; > > -def : Pat<(fsub (fmul DPR:$a, (f64 DPR:$b)), DPR:$dstin), > +def : Pat<(fsub_mlx (fmul_su DPR:$a, (f64 DPR:$b)), DPR:$dstin), > (VNMLSD DPR:$dstin, DPR:$a, DPR:$b)>, > - Requires<[HasVFP2,UseVMLx]>; > -def : Pat<(fsub (fmul SPR:$a, SPR:$b), SPR:$dstin), > + Requires<[HasVFP2,UseFPVMLx]>; > +def : Pat<(fsub_mlx (fmul_su SPR:$a, SPR:$b), SPR:$dstin), > (VNMLSS SPR:$dstin, SPR:$a, SPR:$b)>, > - Requires<[HasVFP2,DontUseNEONForFP,UseVMLx]>; > + Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>; > > > //===----------------------------------------------------------------------===// > > Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp?rev=120960&r1=120959&r2=120960&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Sun Dec 5 16:04:16 2010 > @@ -37,7 +37,7 @@ > , ARMProcFamily(Others) > , ARMFPUType(None) > , UseNEONForSinglePrecisionFP(false) > - , SlowVMLx(false) > + , SlowFPVMLx(false) > , SlowFPBrcc(false) > , IsThumb(isT) > , ThumbMode(Thumb1) > > Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.h?rev=120960&r1=120959&r2=120960&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMSubtarget.h (original) > +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.h Sun Dec 5 16:04:16 2010 > @@ -57,9 +57,9 @@ > /// determine if NEON should actually be used. > bool UseNEONForSinglePrecisionFP; > > - /// SlowVMLx - If the VFP2 instructions are available, indicates whether > - /// the VML[AS] instructions are slow (if so, don't use them). > - bool SlowVMLx; > + /// SlowFPVMLx - If the VFP2 / NEON instructions are available, indicates > + /// whether the FP VML[AS] instructions are slow (if so, don't use them). > + bool SlowFPVMLx; > > /// SlowFPBrcc - True if floating point compare + branch is slow. > bool SlowFPBrcc; > @@ -176,7 +176,7 @@ > bool hasDivide() const { return HasHardwareDivide; } > bool hasT2ExtractPack() const { return HasT2ExtractPack; } > bool hasDataBarrier() const { return HasDataBarrier; } > - bool useVMLx() const {return hasVFP2() && !SlowVMLx; } > + bool useFPVMLx() const { return !SlowFPVMLx; } > bool isFPBrccSlow() const { return SlowFPBrcc; } > bool isFPOnlySP() const { return FPOnlySP; } > bool prefers32BitThumb() const { return Pref32BitThumb; } > > Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=120960&r1=120959&r2=120960&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Sun Dec 5 16:04:16 2010 > @@ -16,11 +16,14 @@ > #include "ARM.h" > #include "llvm/PassManager.h" > #include "llvm/CodeGen/Passes.h" > +#include "llvm/Support/CommandLine.h" > #include "llvm/Support/FormattedStream.h" > #include "llvm/Target/TargetOptions.h" > #include "llvm/Target/TargetRegistry.h" > using namespace llvm; > > +static cl::optExpandMLx("expand-fp-mlx", cl::init(false), cl::Hidden); > + > static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) { > Triple TheTriple(TT); > switch (TheTriple.getOS()) { > @@ -146,6 +149,9 @@ > // FIXME: temporarily disabling load / store optimization pass for Thumb1. > if (OptLevel != CodeGenOpt::None && !Subtarget.isThumb1Only()) > PM.add(createARMLoadStoreOptimizationPass(true)); > + if (ExpandMLx && > + OptLevel != CodeGenOpt::None && Subtarget.hasVFP2()) > + PM.add(createMLxExpansionPass()); > > return true; > } > > Modified: llvm/trunk/lib/Target/ARM/CMakeLists.txt > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/CMakeLists.txt?rev=120960&r1=120959&r2=120960&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/CMakeLists.txt (original) > +++ llvm/trunk/lib/Target/ARM/CMakeLists.txt Sun Dec 5 16:04:16 2010 > @@ -29,6 +29,7 @@ > ARMFastISel.cpp > ARMFrameInfo.cpp > ARMGlobalMerge.cpp > + ARMHazardRecognizer.cpp > ARMISelDAGToDAG.cpp > ARMISelLowering.cpp > ARMInstrInfo.cpp > @@ -46,7 +47,6 @@ > Thumb1InstrInfo.cpp > Thumb1FrameInfo.cpp > Thumb1RegisterInfo.cpp > - Thumb2HazardRecognizer.cpp > Thumb2ITBlockPass.cpp > Thumb2InstrInfo.cpp > Thumb2RegisterInfo.cpp > > Added: llvm/trunk/lib/Target/ARM/MLxExpansionPass.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MLxExpansionPass.cpp?rev=120960&view=auto > ============================================================================== > --- llvm/trunk/lib/Target/ARM/MLxExpansionPass.cpp (added) > +++ llvm/trunk/lib/Target/ARM/MLxExpansionPass.cpp Sun Dec 5 16:04:16 2010 > @@ -0,0 +1,324 @@ > +//===-- MLxExpansionPass.cpp - Expand MLx instrs to avoid hazards ----------=// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > +// > +// Expand VFP / NEON floating point MLA / MLS instructions (each to a pair of > +// multiple and add / sub instructions) when special VMLx hazards are detected. > +// > +//===----------------------------------------------------------------------===// > + > +#define DEBUG_TYPE "mlx-expansion" > +#include "ARM.h" > +#include "ARMBaseInstrInfo.h" > +#include "llvm/CodeGen/MachineInstr.h" > +#include "llvm/CodeGen/MachineInstrBuilder.h" > +#include "llvm/CodeGen/MachineFunctionPass.h" > +#include "llvm/CodeGen/MachineRegisterInfo.h" > +#include "llvm/Target/TargetRegisterInfo.h" > +#include "llvm/ADT/DenseMap.h" > +#include "llvm/ADT/SmallSet.h" > +#include "llvm/ADT/Statistic.h" > +#include "llvm/Support/CommandLine.h" > +#include "llvm/Support/Debug.h" > +#include "llvm/Support/raw_ostream.h" > +using namespace llvm; > + > +static cl::opt > +ForceExapnd("expand-all-fp-mlx", cl::init(false), cl::Hidden); > +static cl::opt > +ExpandLimit("expand-limit", cl::init(~0U), cl::Hidden); > + > +STATISTIC(NumExpand, "Number of fp MLA / MLS instructions expanded"); > + > +namespace { > + struct MLxExpansion : public MachineFunctionPass { > + static char ID; > + MLxExpansion() : MachineFunctionPass(ID) {} > + > + virtual bool runOnMachineFunction(MachineFunction &Fn); > + > + virtual const char *getPassName() const { > + return "ARM MLA / MLS expansion pass"; > + } > + > + private: > + const ARMBaseInstrInfo *TII; > + const TargetRegisterInfo *TRI; > + MachineRegisterInfo *MRI; > + > + unsigned HazardLimit; > + unsigned MIIdx; > + MachineInstr* LastMIs[4]; > + > + void clearStack(); > + void pushStack(MachineInstr *MI); > + MachineInstr *getAccDefMI(MachineInstr *MI) const; > + unsigned getDefReg(MachineInstr *MI) const; > + bool hasRAWHazard(unsigned Reg, MachineInstr *MI) const; > + bool FindMLxHazard(MachineInstr *MI) const; > + void ExpandFPMLxInstruction(MachineBasicBlock &MBB, MachineInstr *MI, > + unsigned MulOpc, unsigned AddSubOpc, > + bool NegAcc, bool HasLane); > + bool ExpandFPMLxInstructions(MachineBasicBlock &MBB); > + }; > + char MLxExpansion::ID = 0; > +} > + > +void MLxExpansion::clearStack() { > + std::fill(LastMIs, LastMIs + 4, (MachineInstr*)0); > + MIIdx = 0; > +} > + > +void MLxExpansion::pushStack(MachineInstr *MI) { > + LastMIs[MIIdx] = MI; > + if (++MIIdx == 4) > + MIIdx = 0; > +} > + > +MachineInstr *MLxExpansion::getAccDefMI(MachineInstr *MI) const { > + // Look past COPY and INSERT_SUBREG instructions to find the > + // real definition MI. This is important for _sfp instructions. > + unsigned Reg = MI->getOperand(1).getReg(); > + if (TargetRegisterInfo::isPhysicalRegister(Reg)) > + return 0; > + > + MachineBasicBlock *MBB = MI->getParent(); > + MachineInstr *DefMI = MRI->getVRegDef(Reg); > + while (true) { > + if (DefMI->getParent() != MBB) > + break; > + if (DefMI->isCopyLike()) { > + Reg = DefMI->getOperand(1).getReg(); > + if (TargetRegisterInfo::isVirtualRegister(Reg)) { > + DefMI = MRI->getVRegDef(Reg); > + continue; > + } > + } else if (DefMI->isInsertSubreg()) { > + Reg = DefMI->getOperand(2).getReg(); > + if (TargetRegisterInfo::isVirtualRegister(Reg)) { > + DefMI = MRI->getVRegDef(Reg); > + continue; > + } > + } > + break; > + } > + return DefMI; > +} > + > +unsigned MLxExpansion::getDefReg(MachineInstr *MI) const { > + unsigned Reg = MI->getOperand(0).getReg(); > + if (TargetRegisterInfo::isPhysicalRegister(Reg) || > + !MRI->hasOneNonDBGUse(Reg)) > + return Reg; > + > + MachineBasicBlock *MBB = MI->getParent(); > + MachineInstr *UseMI = &*MRI->use_nodbg_begin(Reg); > + if (UseMI->getParent() != MBB) > + return Reg; > + > + while (UseMI->isCopy() || UseMI->isInsertSubreg()) { > + Reg = UseMI->getOperand(0).getReg(); > + if (TargetRegisterInfo::isPhysicalRegister(Reg) || > + !MRI->hasOneNonDBGUse(Reg)) > + return Reg; > + UseMI = &*MRI->use_nodbg_begin(Reg); > + if (UseMI->getParent() != MBB) > + return Reg; > + } > + > + return Reg; > +} > + > +bool MLxExpansion::hasRAWHazard(unsigned Reg, MachineInstr *MI) const { > + const TargetInstrDesc &TID = MI->getDesc(); > + // FIXME: Detect integer instructions properly. > + unsigned Domain = TID.TSFlags & ARMII::DomainMask; > + if (Domain == ARMII::DomainVFP) { > + unsigned Opcode = TID.getOpcode(); > + if (Opcode == ARM::VSTRS || Opcode == ARM::VSTRD || > + Opcode == ARM::VMOVRS || Opcode == ARM::VMOVRRD) > + return false; > + } else if (Domain == ARMII::DomainNEON) { > + if (TID.mayStore() || TID.mayLoad()) > + return false; > + } else { > + return false; > + } > + > + return MI->readsRegister(Reg, TRI); > + return false; > +} > + > + > +bool MLxExpansion::FindMLxHazard(MachineInstr *MI) const { > + if (NumExpand >= ExpandLimit) > + return false; > + > + if (ForceExapnd) > + return true; > + > + MachineInstr *DefMI = getAccDefMI(MI); > + if (TII->isFpMLxInstruction(DefMI->getOpcode())) > + // r0 = vmla > + // r3 = vmla r0, r1, r2 > + // takes 16 - 17 cycles > + // > + // r0 = vmla > + // r4 = vmul r1, r2 > + // r3 = vadd r0, r4 > + // takes about 14 - 15 cycles even with vmul stalling for 4 cycles. > + return true; > + > + // If a VMLA.F is followed by an VADD.F or VMUL.F with no RAW hazard, the > + // VADD.F or VMUL.F will stall 4 cycles before issue. The 4 cycle stall > + // preserves the in-order retirement of the instructions. > + // Look at the next few instructions, if *most* of them can cause hazards, > + // then the scheduler can't *fix* this, we'd better break up the VMLA. > + for (unsigned i = 1; i <= 4; ++i) { > + int Idx = ((int)MIIdx - i + 4) % 4; > + MachineInstr *NextMI = LastMIs[Idx]; > + if (!NextMI) > + continue; > + > + if (TII->canCauseFpMLxStall(NextMI->getOpcode())) > + return true; > + > + // Look for VMLx RAW hazard. > + if (hasRAWHazard(getDefReg(MI), NextMI)) > + return true; > + } > + > + return false; > +} > + > +/// ExpandFPMLxInstructions - Expand a MLA / MLS instruction into a pair > +/// of MUL + ADD / SUB instructions. > +void > +MLxExpansion::ExpandFPMLxInstruction(MachineBasicBlock &MBB, MachineInstr *MI, > + unsigned MulOpc, unsigned AddSubOpc, > + bool NegAcc, bool HasLane) { > + unsigned DstReg = MI->getOperand(0).getReg(); > + bool DstDead = MI->getOperand(0).isDead(); > + unsigned AccReg = MI->getOperand(1).getReg(); > + unsigned Src1Reg = MI->getOperand(2).getReg(); > + unsigned Src2Reg = MI->getOperand(3).getReg(); > + bool Src1Kill = MI->getOperand(2).isKill(); > + bool Src2Kill = MI->getOperand(3).isKill(); > + unsigned LaneImm = HasLane ? MI->getOperand(4).getImm() : 0; > + unsigned NextOp = HasLane ? 5 : 4; > + ARMCC::CondCodes Pred = (ARMCC::CondCodes)MI->getOperand(NextOp).getImm(); > + unsigned PredReg = MI->getOperand(++NextOp).getReg(); > + > + const TargetInstrDesc &TID1 = TII->get(MulOpc); > + const TargetInstrDesc &TID2 = TII->get(AddSubOpc); > + unsigned TmpReg = MRI->createVirtualRegister(TID1.getRegClass(0, TRI)); > + > + MachineInstrBuilder MIB = BuildMI(MBB, *MI, MI->getDebugLoc(), TID1, TmpReg) > + .addReg(Src1Reg, getKillRegState(Src1Kill)) > + .addReg(Src2Reg, getKillRegState(Src2Kill)); > + if (HasLane) > + MIB.addImm(LaneImm); > + MIB.addImm(Pred).addReg(PredReg); > + > + MIB = BuildMI(MBB, *MI, MI->getDebugLoc(), TID2) > + .addReg(DstReg, getDefRegState(true) | getDeadRegState(DstDead)); > + > + if (NegAcc) { > + bool AccKill = MRI->hasOneNonDBGUse(AccReg); > + MIB.addReg(TmpReg, getKillRegState(true)) > + .addReg(AccReg, getKillRegState(AccKill)); > + } else { > + MIB.addReg(AccReg).addReg(TmpReg, getKillRegState(true)); > + } > + MIB.addImm(Pred).addReg(PredReg); > + > + DEBUG({ > + dbgs() << "Expanding: " << *MI; > + dbgs() << " to:\n"; > + MachineBasicBlock::iterator MII = MI; > + MII = llvm::prior(MII); > + MachineInstr &MI2 = *MII; > + MII = llvm::prior(MII); > + MachineInstr &MI1 = *MII; > + dbgs() << " " << MI1; > + dbgs() << " " << MI2; > + }); > + > + MI->eraseFromParent(); > + ++NumExpand; > +} > + > +bool MLxExpansion::ExpandFPMLxInstructions(MachineBasicBlock &MBB) { > + bool Changed = false; > + > + clearStack(); > + > + unsigned Skip = 0; > + MachineBasicBlock::reverse_iterator MII = MBB.rbegin(), E = MBB.rend(); > + while (MII != E) { > + MachineInstr *MI = &*MII; > + > + if (MI->isLabel() || MI->isImplicitDef() || MI->isCopy()) { > + ++MII; > + continue; > + } > + > + const TargetInstrDesc &TID = MI->getDesc(); > + if (TID.isBarrier()) { > + clearStack(); > + Skip = 0; > + ++MII; > + continue; > + } > + > + unsigned Domain = TID.TSFlags & ARMII::DomainMask; > + if (Domain == ARMII::DomainGeneral) { > + if (++Skip == 2) > + // Assume dual issues of non-VFP / NEON instructions. > + pushStack(0); > + } else { > + Skip = 0; > + > + unsigned MulOpc, AddSubOpc; > + bool NegAcc, HasLane; > + if (!TII->isFpMLxInstruction(TID.getOpcode(), > + MulOpc, AddSubOpc, NegAcc, HasLane) || > + !FindMLxHazard(MI)) > + pushStack(MI); > + else { > + ExpandFPMLxInstruction(MBB, MI, MulOpc, AddSubOpc, NegAcc, HasLane); > + E = MBB.rend(); // May have changed if MI was the 1st instruction. > + Changed = true; > + continue; > + } > + } > + > + ++MII; > + } > + > + return Changed; > +} > + > +bool MLxExpansion::runOnMachineFunction(MachineFunction &Fn) { > + TII = static_cast(Fn.getTarget().getInstrInfo()); > + TRI = Fn.getTarget().getRegisterInfo(); > + MRI = &Fn.getRegInfo(); > + > + bool Modified = false; > + for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E; > + ++MFI) { > + MachineBasicBlock &MBB = *MFI; > + Modified |= ExpandFPMLxInstructions(MBB); > + } > + > + return Modified; > +} > + > +FunctionPass *llvm::createMLxExpansionPass() { > + return new MLxExpansion(); > +} > > Modified: llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp?rev=120960&r1=120959&r2=120960&view=diff > ============================================================================== > (empty) > > Removed: llvm/trunk/lib/Target/ARM/Thumb2HazardRecognizer.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2HazardRecognizer.cpp?rev=120959&view=auto > ============================================================================== > --- llvm/trunk/lib/Target/ARM/Thumb2HazardRecognizer.cpp (original) > +++ llvm/trunk/lib/Target/ARM/Thumb2HazardRecognizer.cpp (removed) > @@ -1,53 +0,0 @@ > -//===-- Thumb2HazardRecognizer.cpp - Thumb2 postra hazard recognizer ------===// > -// > -// The LLVM Compiler Infrastructure > -// > -// This file is distributed under the University of Illinois Open Source > -// License. See LICENSE.TXT for details. > -// > -//===----------------------------------------------------------------------===// > - > -#include "ARM.h" > -#include "Thumb2HazardRecognizer.h" > -#include "llvm/CodeGen/MachineInstr.h" > -#include "llvm/CodeGen/ScheduleDAG.h" > -using namespace llvm; > - > -ScheduleHazardRecognizer::HazardType > -Thumb2HazardRecognizer::getHazardType(SUnit *SU) { > - if (ITBlockSize) { > - MachineInstr *MI = SU->getInstr(); > - if (!MI->isDebugValue() && MI != ITBlockMIs[ITBlockSize-1]) > - return Hazard; > - } > - > - return PostRAHazardRecognizer::getHazardType(SU); > -} > - > -void Thumb2HazardRecognizer::Reset() { > - ITBlockSize = 0; > - PostRAHazardRecognizer::Reset(); > -} > - > -void Thumb2HazardRecognizer::EmitInstruction(SUnit *SU) { > - MachineInstr *MI = SU->getInstr(); > - unsigned Opcode = MI->getOpcode(); > - if (ITBlockSize) { > - --ITBlockSize; > - } else if (Opcode == ARM::t2IT) { > - unsigned Mask = MI->getOperand(1).getImm(); > - unsigned NumTZ = CountTrailingZeros_32(Mask); > - assert(NumTZ <= 3 && "Invalid IT mask!"); > - ITBlockSize = 4 - NumTZ; > - MachineBasicBlock::iterator I = MI; > - for (unsigned i = 0; i < ITBlockSize; ++i) { > - // Advance to the next instruction, skipping any dbg_value instructions. > - do { > - ++I; > - } while (I->isDebugValue()); > - ITBlockMIs[ITBlockSize-1-i] = &*I; > - } > - } > - > - PostRAHazardRecognizer::EmitInstruction(SU); > -} > > Removed: llvm/trunk/lib/Target/ARM/Thumb2HazardRecognizer.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2HazardRecognizer.h?rev=120959&view=auto > ============================================================================== > --- llvm/trunk/lib/Target/ARM/Thumb2HazardRecognizer.h (original) > +++ llvm/trunk/lib/Target/ARM/Thumb2HazardRecognizer.h (removed) > @@ -1,40 +0,0 @@ > -//===-- Thumb2HazardRecognizer.h - Thumb2 Hazard Recognizers ----*- C++ -*-===// > -// > -// The LLVM Compiler Infrastructure > -// > -// This file is distributed under the University of Illinois Open Source > -// License. See LICENSE.TXT for details. > -// > -//===----------------------------------------------------------------------===// > -// > -// This file defines hazard recognizers for scheduling Thumb2 functions on > -// ARM processors. > -// > -//===----------------------------------------------------------------------===// > - > -#ifndef THUMB2HAZARDRECOGNIZER_H > -#define THUMB2HAZARDRECOGNIZER_H > - > -#include "llvm/CodeGen/PostRAHazardRecognizer.h" > - > -namespace llvm { > - > -class MachineInstr; > - > -class Thumb2HazardRecognizer : public PostRAHazardRecognizer { > - unsigned ITBlockSize; // No. of MIs in current IT block yet to be scheduled. > - MachineInstr *ITBlockMIs[4]; > - > -public: > - Thumb2HazardRecognizer(const InstrItineraryData *ItinData) : > - PostRAHazardRecognizer(ItinData) {} > - > - virtual HazardType getHazardType(SUnit *SU); > - virtual void Reset(); > - virtual void EmitInstruction(SUnit *SU); > -}; > - > - > -} // end namespace llvm > - > -#endif // THUMB2HAZARDRECOGNIZER_H > > Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp?rev=120960&r1=120959&r2=120960&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp (original) > +++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp Sun Dec 5 16:04:16 2010 > @@ -17,7 +17,6 @@ > #include "ARMAddressingModes.h" > #include "ARMGenInstrInfo.inc" > #include "ARMMachineFunctionInfo.h" > -#include "Thumb2HazardRecognizer.h" > #include "Thumb2InstrInfo.h" > #include "llvm/CodeGen/MachineFrameInfo.h" > #include "llvm/CodeGen/MachineInstrBuilder.h" > @@ -175,11 +174,6 @@ > ARMBaseInstrInfo::loadRegFromStackSlot(MBB, I, DestReg, FI, RC, TRI); > } > > -ScheduleHazardRecognizer *Thumb2InstrInfo:: > -CreateTargetPostRAHazardRecognizer(const InstrItineraryData *II) const { > - return (ScheduleHazardRecognizer *)new Thumb2HazardRecognizer(II); > -} > - > void llvm::emitT2RegPlusImmediate(MachineBasicBlock &MBB, > MachineBasicBlock::iterator &MBBI, DebugLoc dl, > unsigned DestReg, unsigned BaseReg, int NumBytes, > > Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h?rev=120960&r1=120959&r2=120960&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h (original) > +++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h Sun Dec 5 16:04:16 2010 > @@ -65,9 +65,6 @@ > /// always be able to get register info as well (through this method). > /// > const Thumb2RegisterInfo &getRegisterInfo() const { return RI; } > - > - ScheduleHazardRecognizer * > - CreateTargetPostRAHazardRecognizer(const InstrItineraryData *II) const; > }; > > /// getITInstrPredicate - Valid only in Thumb2 mode. This function is identical > > Modified: llvm/trunk/test/CodeGen/ARM/reg_sequence.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/reg_sequence.ll?rev=120960&r1=120959&r2=120960&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/ARM/reg_sequence.ll (original) > +++ llvm/trunk/test/CodeGen/ARM/reg_sequence.ll Sun Dec 5 16:04:16 2010 > @@ -270,8 +270,9 @@ > define arm_aapcs_vfpcc i32 @t10() nounwind { > entry: > ; CHECK: t10: > +; CHECK: vmul.f32 q8, q8, d0[0] > ; CHECK: vmov.i32 q9, #0x3F000000 > -; CHECK: vmla.f32 q8, q8, d0[0] > +; CHECK: vadd.f32 q8, q8, q8 > %0 = shufflevector <4 x float> zeroinitializer, <4 x float> undef, <4 x i32> zeroinitializer ; <<4 x float>> [#uses=1] > %1 = insertelement <4 x float> %0, float undef, i32 1 ; <<4 x float>> [#uses=1] > %2 = insertelement <4 x float> %1, float undef, i32 2 ; <<4 x float>> [#uses=1] > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From kubastaszak at gmail.com Mon Dec 6 07:40:54 2010 From: kubastaszak at gmail.com (Jakub Staszak) Date: Mon, 6 Dec 2010 14:40:54 +0100 Subject: [llvm-commits] [llvm] r120974 - in /llvm/trunk: include/llvm/Analysis/AliasAnalysis.h lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/simple.ll In-Reply-To: <4CFCE317.2030208@free.fr> References: <20101206014806.79E942A6C12C@llvm.org> <03608C35-109D-4B5A-9E39-0879DD0047AC@gmail.com> <4CFCE317.2030208@free.fr> Message-ID: However, sometimes we change *ptr = x; into memcpy. Do we guarantee that operands won't overlap then? On Mon, Dec 6, 2010 at 2:20 PM, Duncan Sands wrote: > Hi ?smail, > >> Apparently Adobe didn't know about it: >> https://bugzilla.redhat.com/show_bug.cgi?id=638477 > > because of that the whole planet now knows that overlapping memcpy is > not allowed. ?So while previously people might have complained if we > broke code with overlapping memcpy, we may be able to get away with > it now! :) > > Ciao, Duncan. > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From daniel at zuster.org Mon Dec 6 11:45:26 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 06 Dec 2010 17:45:26 -0000 Subject: [llvm-commits] [zorg] r121009 - in /zorg/trunk/lnt/lnt: util/NTEmailReport.py viewer/simple.ptl Message-ID: <20101206174526.C56092A6C12C@llvm.org> Author: ddunbar Date: Mon Dec 6 11:45:26 2010 New Revision: 121009 URL: http://llvm.org/viewvc/llvm-project?rev=121009&view=rev Log: LNT: Re-enable noise estimation by default, it turns out to be useful, despite its other fundamental flaws. Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py zorg/trunk/lnt/lnt/viewer/simple.ptl Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/NTEmailReport.py?rev=121009&r1=121008&r2=121009&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/NTEmailReport.py (original) +++ zorg/trunk/lnt/lnt/util/NTEmailReport.py Mon Dec 6 11:45:26 2010 @@ -90,7 +90,7 @@ def getSimpleReport(result, db, run, baseurl, was_added, will_commit, only_html_body = False, show_graphs = False, - num_comparison_runs = 0): + num_comparison_runs = 10): machine = run.machine tag = run.info['tag'].value Modified: zorg/trunk/lnt/lnt/viewer/simple.ptl URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/simple.ptl?rev=121009&r1=121008&r2=121009&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/viewer/simple.ptl (original) +++ zorg/trunk/lnt/lnt/viewer/simple.ptl Mon Dec 6 11:45:26 2010 @@ -473,7 +473,7 @@ try: num_comparison_runs = int(form['num_comparison_runs']) except: - num_comparison_runs = 0 + num_comparison_runs = 10 self.renderPopupBegin('view_options', 'View Options', True) form.render() From daniel at zuster.org Mon Dec 6 11:45:34 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 06 Dec 2010 17:45:34 -0000 Subject: [llvm-commits] [zorg] r121010 - /zorg/trunk/lnt/lnt/util/NTEmailReport.py Message-ID: <20101206174534.0B0F02A6C12C@llvm.org> Author: ddunbar Date: Mon Dec 6 11:45:33 2010 New Revision: 121010 URL: http://llvm.org/viewvc/llvm-project?rev=121010&view=rev Log: LNT: Fix a thinko in show_graphs=1 functionality. Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/NTEmailReport.py?rev=121010&r1=121009&r2=121010&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/NTEmailReport.py (original) +++ zorg/trunk/lnt/lnt/util/NTEmailReport.py Mon Dec 6 11:45:33 2010 @@ -416,7 +416,7 @@ header += """ """ % view2d_js + """ % locals() html_report = """ From daniel at zuster.org Mon Dec 6 11:45:36 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 06 Dec 2010 17:45:36 -0000 Subject: [llvm-commits] [zorg] r121011 - /zorg/trunk/lnt/lnt/util/NTEmailReport.py Message-ID: <20101206174536.724682A6C12D@llvm.org> Author: ddunbar Date: Mon Dec 6 11:45:36 2010 New Revision: 121011 URL: http://llvm.org/viewvc/llvm-project?rev=121011&view=rev Log: LNT: Add links to graphs in email reports. Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/NTEmailReport.py?rev=121011&r1=121010&r2=121011&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/NTEmailReport.py (original) +++ zorg/trunk/lnt/lnt/util/NTEmailReport.py Mon Dec 6 11:45:36 2010 @@ -9,6 +9,7 @@ import os import smtplib import sys +import urllib import StringIO from lnt import viewer @@ -307,6 +308,8 @@ continue show_pset = items.items()[0][0] or len(items) > 1 + pset_names = dict((pset, 'pset.%d' % i) + for i,pset in enumerate(ts_summary.parameter_sets)) print >>report print >>report, name print >>report, '-' * len(name) @@ -353,11 +356,19 @@ """ % (graph_name) else: extra_cell_value = "" + + # Link the regression to the chart of its performance. + pset_name = pset_names[pset] + form_data = urllib.urlencode([(pset_name, 'on'), + ('test.'+name, 'on')]) + linked_name = '%s' % ( + os.path.join(report_url, "graph"), form_data, name) + pct_value = Util.PctCell(cr.pct_delta).render() if cr.stddev is not None: print >>html_report, """ %s%s%s%.4f%.4f%.4f""" %( - name, extra_cell_value, pct_value, + linked_name, extra_cell_value, pct_value, cr.previous, cr.current, cr.stddev) else: print >>html_report, """ From gohman at apple.com Mon Dec 6 11:48:00 2010 From: gohman at apple.com (Dan Gohman) Date: Mon, 6 Dec 2010 09:48:00 -0800 Subject: [llvm-commits] PathV2 review notes Message-ID: Hello, I read through the current PathV2 platform-independent and Unix code. I'm aware that it's not complete yet, but there's already a lot of code there. Below are some review comments. include/llvm/Support/PathV2.h: > /// @name Lexical Modifiers > /// @{ > /// @brief Make \a path an absolute path. > /// > /// Makes \a path absolute using the current directory if it is not already. An > /// empty \a path will result in the current directory. > /// > /// /absolute/path => /absolute/path > /// relative/../path => /path > /// > /// @param path A path that is modified to be an absolute path. > /// @returns errc::success if \a path has been made absolute, otherwise a > /// platform specific error_code. > error_code make_absolute(SmallVectorImpl &path); The top-level section comment suggests that this is a lexical operation, but it is not. > /// @brief Remove the last component from \a path if it exists. > /// > /// directory/filename.cpp => directory/ > /// directory/ => directory > /// > /// @param path A path that is modified to not have a file component. > /// @returns errc::success if \a path's file name has been removed (or there was > /// not one to begin with), otherwise a platform specific error_code. > error_code remove_filename(SmallVectorImpl &path); The words "if it exists" are a little misleading in this context, since this is actually a purely lexical transformation. The fact that this function returns an error code contributes to the ambiguity. On a related note, there are many functions (root_directory, root_path, is_absolute, etc.) like this which are purely lexical, and implemented with platform-independent code, and which always return success. It's unfortunate that clients are required to cope with "a platform specific error_code" when working with any of these interfaces, since it isn't really needed. Unlike Boost, LLVM doesn't propogate malloc errors. If malloc fails, LLVM crashes (at best). We can have interesting discussions about whether or not this is a bug, but it does simplify many things. Also unlike Boost, LLVM's libSupport can easily change its API if it ever somehow makes sense for these functions to return errors in the future. > /// @brief Replace the file extension of \a path with \a extension. > /// > /// ./filename.cpp => ./filename.extension > /// ./filename => ./filename.extension > /// ./ => ? TODO: decide what semantics this has. > /// > /// @param path A path that has its extension replaced with \a extension. > /// @param extension The extension to be added. It may be empty. It may also > /// optionally start with a '.', if it does not, one will be > /// prepended. > /// @returns errc::success if \a path's extension has been replaced, otherwise a > /// platform specific error_code. > error_code replace_extension(SmallVectorImpl &path, > const Twine &extension); The behavior of prepending a '.' if the suffix doesn't already have one is confusing. Since extension includes the dot, it would be consistent for replace_extension to require it. It could even verify this with an assert. > /// @name Lexical Observers > /// @{ > > /// @brief Get the current path. > /// > /// @param result Holds the current path on return. > /// @results errc::success if the current path has been stored in result, > /// otherwise a platform specific error_code. > error_code current_path(SmallVectorImpl &result); Same as above; this isn't a purely lexical operation. > /// @brief Get root name. > /// > /// //net/hello => //net > /// c:/hello => c: (on Windows, on other platforms nothing) > /// /hello => UNC-style double-slash pathnames are not well known in Unix circles; a comment on that first example would be helpful. As an aside, does it really make sense to implement UNC pathnames on systems where the underlying libc API doesn't implement them? I realize you're just following Boost here though. More broadly, there seem to be two major ways of bisecting paths in this API: root+relative and parent+filename (as this API names them). Parent+filename is obvious, but when would root+relative be useful for LLVM? Compilers and related tools should never go digging around in the filesystem root on their own. lib/Support/PathV2.cpp > native > // Clear result. > result.set_size(0); Should this be result.clear()? set_size is usually an indication that something special is happening, and that doesn't appear to be the case here. > error_code has_root_directory(const Twine &path, bool &result) { > SmallString<128> path_storage; > StringRef p = path.toStringRef(path_storage); > > if (error_code ec = root_directory(p, p)) return ec; > > result = !p.empty(); > return success; > } Calling root_directory(p, p) here looks unsafe: p isn't guaranteed to be pointing to path_storage, and root_directory writes through it. lib/Support/Unix/PathV2.inc: > #if HAVE_STDIO_H > #include > #endif Shouldn't stdio.h always be available? > ~AutoFD() { > if (FileDescriptor >= 0) > ::close(FileDescriptor); > } This AutoFD class not check for errors on ::close, so hopefully it'll only be used in contexts where that doesn't matter. A comment about this would be appropriate. > TempDir > (dir = std::getenv("TMPDIR" )) || It's suspicious for the path library to be using "TMPDIR" privately like this. What is this for? > error_code current_path(SmallVectorImpl &result) { > long size = ::pathconf(".", _PC_PATH_MAX); > result.reserve(size + 1); > result.set_size(size + 1); > > if (::getcwd(result.data(), result.size()) == 0) > return error_code(errno, system_category()); > > result.set_size(strlen(result.data())); > return success; > } POSIX describes _PC_PATH_MAX as indicating "the longest relative pathname that could be given if the specified directory is the process' current working directory", which isn't what it's being used for here. For a fully general implementation, just do a simple loop which starts at MAXPATHLEN and reallocates the buffer until getcwd succeeds. > namespace fs{ Whitespace before {. > copy_file FWIW, it appears copy_file is apparently only used by llvm-ld and only on Windows, so the Unix implementation is currently dead code. > // Open from. > if ((from_file = ::open(f.begin(), O_RDONLY)) < 0) > return error_code(errno, system_category()); > AutoFD from_fd(from_file); > > // Stat from. > struct stat from_stat; > if (::stat(f.begin(), &from_stat) != 0) > return error_code(errno, system_category()); It's more efficient to use fstat than stat, since the file descriptor is right there. llvm-ld's use of copy_file probably doesn't care about performance, but in general this is an idiom to watch out for. > if (copt == copy_option::fail_if_exists) > to_flags |= O_EXCL; The old CopyFile implementation doesn't have this. What is it for? > // Open to. > if ((to_file = ::open(t.begin(), to_flags, from_stat.st_mode)) < 0) > return error_code(errno, system_category()); > AutoFD to_fd(to_file); AutoFD isn't really needed here, and in fact it makes the code harder to follow. If AutoFD ever does its job, it would be calling ::close without checking for errors, so the only way this code is correct is if AutoFD is never permitted to do its job. > // After all the file operations above the return value of close actually > // matters. > if (::close(from_fd.take()) < 0) sz_read = -1; > if (::close(to_fd.take()) < 0) sz_read = -1; > > // Check for errors. > if (sz_read < 0) > return error_code(errno, system_category()); If errors from ::close on from_fd actually matter, this risks reporting the wrong error message, since errno could be clobbered by the second ::close (even if it succeeds). Also, the old CopyFile returned error messages which indicated whether the error was in the source or the destination. This API doesn't expose that information at all, so clients won't be able to produce a descriptive error message. > create_directory > if (::mkdir(p.begin(), 0700) == -1) { Please use the symbolic names instead of a raw octal value. I believe this is S_IRWXU. Also, the old createDiectoryOnDisk used S_IRWXU | S_IRWXG. Is it an intentional change to start ignoring the group portion of the user's umask settings? If so, please add comments explaining this choice. Also, is the 'existed' argument really needed? > create_hard_link > create_symlink The old Path library doesn't have these. What are they for? > remove > if (::remove(p.begin()) == -1) { > if (errno != errc::no_such_file_or_directory) > return error_code(errno, system_category()); Using the errc namespace here conflates API levels. This code should use ENOENT directly instead of no_such_file_or_directory. > resize_file The old Path doesn't have this. What is it for? > error_code exists(const Twine &path, bool &result) { The old Path::exists returned false on EACCESS. This code will return an error condition. Is this an intentional change? > file_size What is this for? Doing a full ::stat call and throwing away all the information except st_size is suspicious. > unique_file > [... lots of stuff ...] Please don't try to do what mkstemp does manually. Just use mkstemp. mkstemp is very widely available these days. For portability to exotic platforms, it's fine to put the burden on people who care to contribute patches. Dan From daniel at zuster.org Mon Dec 6 11:54:31 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 06 Dec 2010 17:54:31 -0000 Subject: [llvm-commits] [zorg] r121015 - /zorg/trunk/lnt/lnt/util/NTEmailReport.py Message-ID: <20101206175431.73F582A6C12C@llvm.org> Author: ddunbar Date: Mon Dec 6 11:54:31 2010 New Revision: 121015 URL: http://llvm.org/viewvc/llvm-project?rev=121015&view=rev Log: LNT: Turn on graphs in report emails, to see what the peanut gallery thinks. Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/NTEmailReport.py?rev=121015&r1=121014&r2=121015&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/NTEmailReport.py (original) +++ zorg/trunk/lnt/lnt/util/NTEmailReport.py Mon Dec 6 11:54:31 2010 @@ -90,7 +90,7 @@ return best def getSimpleReport(result, db, run, baseurl, was_added, will_commit, - only_html_body = False, show_graphs = False, + only_html_body = False, show_graphs = True, num_comparison_runs = 10): machine = run.machine tag = run.info['tag'].value From Renato.Golin at arm.com Mon Dec 6 12:00:51 2010 From: Renato.Golin at arm.com (Renato Golin) Date: Mon, 6 Dec 2010 18:00:51 +0000 Subject: [llvm-commits] [llvm] r120960 - in /llvm/trunk: lib/Target/ARM/ test/CodeGen/ARM/ In-Reply-To: <20101205220416.D17E72A6C12C@llvm.org> References: <20101205220416.D17E72A6C12C@llvm.org> Message-ID: <4CFD24D3.1090801@arm.com> On 05/12/10 22:04, Evan Cheng wrote: > 3. A vmla followed vmla is a special case. Obvious issuing back to back RAW > vmla + vmla is very bad. But this isn't ideal either: > vmul > vadd > vmla > Instead, we want to expand the second vmla: > vmla > vmul > vadd > Even with the 4 cycle vmul stall, the second sequence is still 2 cycles > faster. Nice catch, Evan! :D I noticed that LLVM did the first (mul+add+mla), which also saved the first vmov #0 (on a sequence of init 0 + vmlas). In that case you don't even need the first vadd (in mul+add+mla). You probably want to avoid mixing NEON with VFP instructions, is there a hazard recognizer for that, too? cheers, --renato -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. From rjmccall at apple.com Mon Dec 6 12:05:27 2010 From: rjmccall at apple.com (John McCall) Date: Mon, 6 Dec 2010 10:05:27 -0800 Subject: [llvm-commits] [llvm] r120974 - in /llvm/trunk: include/llvm/Analysis/AliasAnalysis.h lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/simple.ll In-Reply-To: References: <20101206014806.79E942A6C12C@llvm.org> <03608C35-109D-4B5A-9E39-0879DD0047AC@gmail.com> <4CFCE317.2030208@free.fr> Message-ID: On Dec 6, 2010, at 5:40 AM, Jakub Staszak wrote: > However, sometimes we change *ptr = x; into memcpy. Do we guarantee > that operands won't overlap then? C99 6.5.16.1: If the value being stored in an object is read from another object that overlaps in any way the storage of the first object, then the overlap shall be exact and the two objects shall have qualified or unqualified versions of a compatible type; otherwise, the behavior is undefined. Also, source compatibility is a lot less important than object compatibility. There are plenty of other reasons why a project that compiles correctly with some specific version (or range of versions) of gcc might fail or be miscompiled when compiled with any other compiler for the first time. Most of those reasons come down to being project bugs. John. From dpatel at apple.com Mon Dec 6 12:04:39 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 06 Dec 2010 18:04:39 -0000 Subject: [llvm-commits] [llvm] r121016 - /llvm/trunk/tools/lto/LTOCodeGenerator.cpp Message-ID: <20101206180439.6553F2A6C12C@llvm.org> Author: dpatel Date: Mon Dec 6 12:04:39 2010 New Revision: 121016 URL: http://llvm.org/viewvc/llvm-project?rev=121016&view=rev Log: Do not try luck by using given name to create temporary file. In parallel builds it may not work. This time for .s file. Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=121016&r1=121015&r2=121016&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Mon Dec 6 12:04:39 2010 @@ -184,7 +184,7 @@ { // make unique temp .s file to put generated assembly code sys::Path uniqueAsmPath("lto-llvm.s"); - if ( uniqueAsmPath.createTemporaryFileOnDisk(true, &errMsg) ) + if ( uniqueAsmPath.createTemporaryFileOnDisk(false, &errMsg) ) return NULL; sys::RemoveFileOnSignal(uniqueAsmPath); From dpatel at apple.com Mon Dec 6 12:09:32 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 6 Dec 2010 10:09:32 -0800 Subject: [llvm-commits] [llvm] r120860 - /llvm/trunk/tools/lto/LTOCodeGenerator.cpp In-Reply-To: References: <20101203235832.069492A6C12C@llvm.org> Message-ID: On Dec 3, 2010, at 7:36 PM, Rafael Esp?ndola wrote: >> Do not try luck by using given name to create temporary file. In parallel builds it may not work. > > Is this a bug in the Path API? The documentation says > > bool createTemporaryFileOnDisk( > bool reuse_current = false, ///< When set to true, this parameter > ///< indicates that if the current file name does not exist then > ///< it will be used without modification. > > So I would assume that if the name does exist a new one is created. After it is determine that name does not exit, but before the file with the name is created, someone else can also determine that name does not exit in a massively parallel build. "reuse_current = true" is not useful in parallel builds. - Devang > >> Modified: >> llvm/trunk/tools/lto/LTOCodeGenerator.cpp >> >> Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=120860&r1=120859&r2=120860&view=diff >> ============================================================================== >> --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) >> +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Fri Dec 3 17:58:31 2010 >> @@ -209,7 +209,7 @@ >> >> // make unique temp .o file to put generated object file >> sys::PathWithStatus uniqueObjPath("lto-llvm.o"); >> - if ( uniqueObjPath.createTemporaryFileOnDisk(true, &errMsg) ) { >> + if ( uniqueObjPath.createTemporaryFileOnDisk(false, &errMsg) ) { >> uniqueAsmPath.eraseFromDisk(); >> return NULL; >> } >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> From rafael.espindola at gmail.com Mon Dec 6 12:11:37 2010 From: rafael.espindola at gmail.com (=?UTF-8?Q?Rafael_Esp=C3=ADndola?=) Date: Mon, 6 Dec 2010 13:11:37 -0500 Subject: [llvm-commits] [llvm] r120860 - /llvm/trunk/tools/lto/LTOCodeGenerator.cpp In-Reply-To: References: <20101203235832.069492A6C12C@llvm.org> Message-ID: >>> Do not try luck by using given name to create temporary file. In parallel builds it may not work. >> >> Is this a bug in the Path API? ?The documentation says >> >> ? ? ?bool createTemporaryFileOnDisk( >> ? ? ? ?bool reuse_current = false, ///< When set to true, this parameter >> ? ? ? ? ?///< indicates that if the current file name does not exist then >> ? ? ? ? ?///< it will be used without modification. >> >> So I would assume that if the name does exist a new one is created. > > After it is determine that name does not exit, but before the file with the name is created, someone else can also determine that name does not exit in a massively parallel build. "reuse_current = true" is not useful in parallel builds. I would call that a bug in the API :-) Michael, what about removing this feature from v2 if it cannot be reliably implemented? > - > Devang Cheers, Rafael From daniel at zuster.org Mon Dec 6 12:14:04 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 06 Dec 2010 18:14:04 -0000 Subject: [llvm-commits] [zorg] r121017 - /zorg/trunk/lnt/lnt/util/NTEmailReport.py Message-ID: <20101206181404.55C9E2A6C12C@llvm.org> Author: ddunbar Date: Mon Dec 6 12:14:04 2010 New Revision: 121017 URL: http://llvm.org/viewvc/llvm-project?rev=121017&view=rev Log: LNT: Turns out Mail.app isn't a fan of showing my pretty HTML5 graphs inline, so turn them off again for now. Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/NTEmailReport.py?rev=121017&r1=121016&r2=121017&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/NTEmailReport.py (original) +++ zorg/trunk/lnt/lnt/util/NTEmailReport.py Mon Dec 6 12:14:04 2010 @@ -90,7 +90,7 @@ return best def getSimpleReport(result, db, run, baseurl, was_added, will_commit, - only_html_body = False, show_graphs = True, + only_html_body = False, show_graphs = False, num_comparison_runs = 10): machine = run.machine tag = run.info['tag'].value From grosbach at apple.com Mon Dec 6 12:21:12 2010 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 06 Dec 2010 18:21:12 -0000 Subject: [llvm-commits] [llvm] r121018 - in /llvm/trunk/lib/Target/ARM: ARMInstrFormats.td AsmParser/ARMAsmParser.cpp Message-ID: <20101206182112.91B492A6C12C@llvm.org> Author: grosbach Date: Mon Dec 6 12:21:12 2010 New Revision: 121018 URL: http://llvm.org/viewvc/llvm-project?rev=121018&view=rev Log: The ARM AsmMatcher needs to know that the CCOut operand is a register value, not an immediate. It stores either ARM::CPSR or reg0. Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrFormats.td?rev=121018&r1=121017&r2=121018&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrFormats.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrFormats.td Mon Dec 6 12:21:12 2010 @@ -143,6 +143,11 @@ let SuperClasses = []; } +def CCOutOperand : AsmOperandClass { + let Name = "CCOut"; + let SuperClasses = []; +} + // ARM Predicate operand. Default to 14 = always (AL). Second part is CC // register whose default is 0 (no register). def pred : PredicateOperand { let EncoderMethod = "getCCOutOpValue"; let PrintMethod = "printSBitModifierOperand"; + let ParserMatchClass = CCOutOperand; } // Same as cc_out except it defaults to setting CPSR. def s_cc_out : OptionalDefOperand { let EncoderMethod = "getCCOutOpValue"; let PrintMethod = "printSBitModifierOperand"; + let ParserMatchClass = CCOutOperand; } // ARM special operands for disassembly only. Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=121018&r1=121017&r2=121018&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Mon Dec 6 12:21:12 2010 @@ -103,6 +103,7 @@ class ARMOperand : public MCParsedAsmOperand { enum KindTy { CondCode, + CCOut, Immediate, Memory, Register, @@ -162,6 +163,7 @@ case Token: Tok = o.Tok; break; + case CCOut: case Register: Reg = o.Reg; break; @@ -195,7 +197,7 @@ } unsigned getReg() const { - assert(Kind == Register && "Invalid access!"); + assert(Kind == Register || Kind == CCOut && "Invalid access!"); return Reg.RegNum; } @@ -211,6 +213,7 @@ } bool isCondCode() const { return Kind == CondCode; } + bool isCCOut() const { return Kind == CCOut; } bool isImm() const { return Kind == Immediate; } bool isReg() const { return Kind == Register; } bool isRegList() const { return Kind == RegisterList; } @@ -264,6 +267,11 @@ Inst.addOperand(MCOperand::CreateReg(0)); } + void addCCOutOperands(MCInst &Inst, unsigned N) const { + assert(N == 1 && "Invalid number of operands!"); + Inst.addOperand(MCOperand::CreateReg(getReg())); + } + void addRegOperands(MCInst &Inst, unsigned N) const { assert(N == 1 && "Invalid number of operands!"); Inst.addOperand(MCOperand::CreateReg(getReg())); @@ -341,6 +349,14 @@ return Op; } + static ARMOperand *CreateCCOut(unsigned RegNum, SMLoc S) { + ARMOperand *Op = new ARMOperand(CCOut); + Op->Reg.RegNum = RegNum; + Op->StartLoc = S; + Op->EndLoc = S; + return Op; + } + static ARMOperand *CreateToken(StringRef Str, SMLoc S) { ARMOperand *Op = new ARMOperand(Token); Op->Tok.Data = Str.data(); @@ -418,6 +434,9 @@ case CondCode: OS << ARMCondCodeToString(getCondCode()); break; + case CCOut: + OS << ""; + break; case Immediate: getImm()->print(OS); break; From grosbach at apple.com Mon Dec 6 12:30:58 2010 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 06 Dec 2010 18:30:58 -0000 Subject: [llvm-commits] [llvm] r121020 - /llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Message-ID: <20101206183058.101392A6C12C@llvm.org> Author: grosbach Date: Mon Dec 6 12:30:57 2010 New Revision: 121020 URL: http://llvm.org/viewvc/llvm-project?rev=121020&view=rev Log: Encode the register operand of ARM CondCode operands correctly. ARM::CPSR if the instruction is predicated, reg0 otherwise. Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=121020&r1=121019&r2=121020&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Mon Dec 6 12:30:57 2010 @@ -263,8 +263,8 @@ void addCondCodeOperands(MCInst &Inst, unsigned N) const { assert(N == 2 && "Invalid number of operands!"); Inst.addOperand(MCOperand::CreateImm(unsigned(getCondCode()))); - // FIXME: What belongs here? - Inst.addOperand(MCOperand::CreateReg(0)); + unsigned RegNum = getCondCode() == ARMCC::AL ? 0: ARM::CPSR; + Inst.addOperand(MCOperand::CreateReg(RegNum)); } void addCCOutOperands(MCInst &Inst, unsigned N) const { From resistor at mac.com Mon Dec 6 12:35:51 2010 From: resistor at mac.com (Owen Anderson) Date: Mon, 06 Dec 2010 18:35:51 -0000 Subject: [llvm-commits] [llvm] r121021 - in /llvm/trunk/lib/Target/ARM: ARMExpandPseudoInsts.cpp ARMInstrThumb2.td Message-ID: <20101206183551.BFBCB2A6C12C@llvm.org> Author: resistor Date: Mon Dec 6 12:35:51 2010 New Revision: 121021 URL: http://llvm.org/viewvc/llvm-project?rev=121021&view=rev Log: Improve handling of Thumb2 PC-relative loads by converting LDRpci (and friends) to Pseudos. Modified: llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp?rev=121021&r1=121020&r2=121021&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp Mon Dec 6 12:35:51 2010 @@ -699,6 +699,36 @@ MI.eraseFromParent(); break; } + case ARM::t2LDRHpci: + case ARM::t2LDRBpci: + case ARM::t2LDRSHpci: + case ARM::t2LDRSBpci: + case ARM::t2LDRpci: { + unsigned NewLdOpc; + if (Opcode == ARM::t2LDRpci) + NewLdOpc = ARM::t2LDRi12; + else if (Opcode == ARM::t2LDRHpci) + NewLdOpc = ARM::t2LDRHi12; + else if (Opcode == ARM::t2LDRBpci) + NewLdOpc = ARM::t2LDRBi12; + else if (Opcode == ARM::t2LDRSHpci) + NewLdOpc = ARM::t2LDRSHi12; + else if (Opcode == ARM::t2LDRSBpci) + NewLdOpc = ARM::t2LDRSBi12; + else + llvm_unreachable("Not a known opcode?"); + + unsigned DstReg = MI.getOperand(0).getReg(); + bool DstIsDead = MI.getOperand(0).isDead(); + MachineInstrBuilder MIB = + BuildMI(MBB, MBBI, MI.getDebugLoc(), + TII->get(NewLdOpc), DstReg) + .addOperand(MI.getOperand(1)); + (*MIB).setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); + TransferImpOps(MI, MIB, MIB); + MI.eraseFromParent(); + break; + } case ARM::tLDRpci_pic: case ARM::t2LDRpci_pic: { unsigned NewLdOpc = (Opcode == ARM::tLDRpci_pic) @@ -706,9 +736,9 @@ unsigned DstReg = MI.getOperand(0).getReg(); bool DstIsDead = MI.getOperand(0).isDead(); MachineInstrBuilder MIB1 = - AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(), + BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(NewLdOpc), DstReg) - .addOperand(MI.getOperand(1))); + .addOperand(MI.getOperand(1)); (*MIB1).setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); MachineInstrBuilder MIB2 = BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(ARM::tPICADD)) Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=121021&r1=121020&r2=121021&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Mon Dec 6 12:35:51 2010 @@ -888,24 +888,8 @@ let Inst{5-4} = addr{1-0}; // imm } - // FIXME: Is the pci variant actually needed? - def pci : T2Ipc <(outs GPR:$Rt), (ins i32imm:$addr), iii, - opc, ".w\t$Rt, $addr", - [(set GPR:$Rt, (opnode (ARMWrapper tconstpool:$addr)))]> { - let isReMaterializable = 1; - let Inst{31-27} = 0b11111; - let Inst{26-25} = 0b00; - let Inst{24} = signed; - let Inst{23} = ?; // add = (U == '1') - let Inst{22-21} = opcod; - let Inst{20} = 1; // load - let Inst{19-16} = 0b1111; // Rn - - bits<4> Rt; - bits<12> addr; - let Inst{15-12} = Rt{3-0}; - let Inst{11-0} = addr{11-0}; - } + def pci : tPseudoInst<(outs GPR:$Rt), (ins i32imm:$addr), Size4Bytes, iis, + [(set GPR:$Rt, (opnode (ARMWrapper tconstpool:$addr)))]>; } /// T2I_st - Defines a set of (op r, {imm12|imm8|so_reg}) store patterns. From grosbach at apple.com Mon Dec 6 12:47:44 2010 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 06 Dec 2010 18:47:44 -0000 Subject: [llvm-commits] [llvm] r121024 - /llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp Message-ID: <20101206184744.582FB2A6C12C@llvm.org> Author: grosbach Date: Mon Dec 6 12:47:44 2010 New Revision: 121024 URL: http://llvm.org/viewvc/llvm-project?rev=121024&view=rev Log: Trailing whitespace. Modified: llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp Modified: llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp?rev=121024&r1=121023&r2=121024&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp Mon Dec 6 12:47:44 2010 @@ -717,7 +717,7 @@ NewLdOpc = ARM::t2LDRSBi12; else llvm_unreachable("Not a known opcode?"); - + unsigned DstReg = MI.getOperand(0).getReg(); bool DstIsDead = MI.getOperand(0).isDead(); MachineInstrBuilder MIB = From jasonwkim at google.com Mon Dec 6 12:52:11 2010 From: jasonwkim at google.com (Jason Kim) Date: Mon, 6 Dec 2010 10:52:11 -0800 Subject: [llvm-commits] [patch] ARM/MC/ELF RecordRelocation refactoring In-Reply-To: References: Message-ID: On Sat, Dec 4, 2010 at 2:30 PM, Rafael Esp?ndola wrote: >> The first patch >> It adds a new method to X86 GetRelocType() and lifts RecordRelocation >> to ELFObjectWriter >> >> + ARM/X86 no longer require their own versions of RecordRelocation >> - MBlaze still does, because it is expecting to access RelocSymbol and >> Addend when selecting the reloc type. >> >> The first patch leaves MBlaze completely alone. > > > + ?protected: > + ? ?virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool IsPCRel) { > + ? ? ?assert(0 && "GetRelocType() needs to be more specific."); > + ? ?}; > + ? ?virtual bool isFixupKindPCRel(unsigned Kind) const { > + ? ? ?assert(0 && "isFixupKindPCRel() needs to be more specific."); > + ? ?}; > > Can you make them pure virtuals? Hi Rafael. Thanks for feedback. Yup! Can do. > > Not sure if we will be able to share this much of RecordRocation, but > it is really nice if we can :-) > > The first patch is OK. > >> >> The second patch deals with MBlaze by using ERE early, and changes >> GetRelocType() to SetRelocType. >> The new set method takes in the ERE instance so that MBlaze has access >> to RelocSymbol and Addend. >> >> Peckw: question for you >> Is the RelocSymbol variable really necessary when selecting the >> relocation? or can it be done more simply? > > If I read it correctly, the check > > ? ? ?Type = (RelocSymbol || Addend !=0) ? ELF::R_MICROBLAZE_32 > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? : ELF::R_MICROBLAZE_64; > > is just that this is a relocation with a section and has a non zero > addend. Can you just add the Addend and a Boolean > IsRelocationWithSymbol to the getRelocType method? I thought about adding new parameter(s) to GetRelocType, but given that these two (RelocSymbol and Addend) are already available as part of the ERE, it was a matter of adding two arguments just for the sake of MBlaze, or isolate the arch specific code within the single (renamed) function, and to pass the ERE directly (i.e. 1 addl' param). I chose the latter - For now, I'll commit the first patch. Thanks -jason From grosbach at apple.com Mon Dec 6 12:53:24 2010 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 6 Dec 2010 10:53:24 -0800 Subject: [llvm-commits] [llvm] r121021 - in /llvm/trunk/lib/Target/ARM: ARMExpandPseudoInsts.cpp ARMInstrThumb2.td In-Reply-To: <20101206183551.BFBCB2A6C12C@llvm.org> References: <20101206183551.BFBCB2A6C12C@llvm.org> Message-ID: Hi Owen, Clang is complaining about "DstIsDead" being unused (which is correct). Since there's no PICADD instruction here, it looks like that local var can just be deleted? -Jim On Dec 6, 2010, at 10:35 AM, Owen Anderson wrote: > Author: resistor > Date: Mon Dec 6 12:35:51 2010 > New Revision: 121021 > > URL: http://llvm.org/viewvc/llvm-project?rev=121021&view=rev > Log: > Improve handling of Thumb2 PC-relative loads by converting LDRpci (and friends) to Pseudos. > > Modified: > llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp > llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td > > Modified: llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp?rev=121021&r1=121020&r2=121021&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp Mon Dec 6 12:35:51 2010 > @@ -699,6 +699,36 @@ > MI.eraseFromParent(); > break; > } > + case ARM::t2LDRHpci: > + case ARM::t2LDRBpci: > + case ARM::t2LDRSHpci: > + case ARM::t2LDRSBpci: > + case ARM::t2LDRpci: { > + unsigned NewLdOpc; > + if (Opcode == ARM::t2LDRpci) > + NewLdOpc = ARM::t2LDRi12; > + else if (Opcode == ARM::t2LDRHpci) > + NewLdOpc = ARM::t2LDRHi12; > + else if (Opcode == ARM::t2LDRBpci) > + NewLdOpc = ARM::t2LDRBi12; > + else if (Opcode == ARM::t2LDRSHpci) > + NewLdOpc = ARM::t2LDRSHi12; > + else if (Opcode == ARM::t2LDRSBpci) > + NewLdOpc = ARM::t2LDRSBi12; > + else > + llvm_unreachable("Not a known opcode?"); > + > + unsigned DstReg = MI.getOperand(0).getReg(); > + bool DstIsDead = MI.getOperand(0).isDead(); > + MachineInstrBuilder MIB = > + BuildMI(MBB, MBBI, MI.getDebugLoc(), > + TII->get(NewLdOpc), DstReg) > + .addOperand(MI.getOperand(1)); > + (*MIB).setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); > + TransferImpOps(MI, MIB, MIB); > + MI.eraseFromParent(); > + break; > + } > case ARM::tLDRpci_pic: > case ARM::t2LDRpci_pic: { > unsigned NewLdOpc = (Opcode == ARM::tLDRpci_pic) > @@ -706,9 +736,9 @@ > unsigned DstReg = MI.getOperand(0).getReg(); > bool DstIsDead = MI.getOperand(0).isDead(); > MachineInstrBuilder MIB1 = > - AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(), > + BuildMI(MBB, MBBI, MI.getDebugLoc(), > TII->get(NewLdOpc), DstReg) > - .addOperand(MI.getOperand(1))); > + .addOperand(MI.getOperand(1)); > (*MIB1).setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); > MachineInstrBuilder MIB2 = BuildMI(MBB, MBBI, MI.getDebugLoc(), > TII->get(ARM::tPICADD)) > > Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=121021&r1=121020&r2=121021&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) > +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Mon Dec 6 12:35:51 2010 > @@ -888,24 +888,8 @@ > let Inst{5-4} = addr{1-0}; // imm > } > > - // FIXME: Is the pci variant actually needed? > - def pci : T2Ipc <(outs GPR:$Rt), (ins i32imm:$addr), iii, > - opc, ".w\t$Rt, $addr", > - [(set GPR:$Rt, (opnode (ARMWrapper tconstpool:$addr)))]> { > - let isReMaterializable = 1; > - let Inst{31-27} = 0b11111; > - let Inst{26-25} = 0b00; > - let Inst{24} = signed; > - let Inst{23} = ?; // add = (U == '1') > - let Inst{22-21} = opcod; > - let Inst{20} = 1; // load > - let Inst{19-16} = 0b1111; // Rn > - > - bits<4> Rt; > - bits<12> addr; > - let Inst{15-12} = Rt{3-0}; > - let Inst{11-0} = addr{11-0}; > - } > + def pci : tPseudoInst<(outs GPR:$Rt), (ins i32imm:$addr), Size4Bytes, iis, > + [(set GPR:$Rt, (opnode (ARMWrapper tconstpool:$addr)))]>; > } > > /// T2I_st - Defines a set of (op r, {imm12|imm8|so_reg}) store patterns. > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From resistor at mac.com Mon Dec 6 12:57:40 2010 From: resistor at mac.com (Owen Anderson) Date: Mon, 06 Dec 2010 18:57:40 -0000 Subject: [llvm-commits] [llvm] r121026 - in /llvm/trunk/lib/Target/ARM: ARMExpandPseudoInsts.cpp ARMInstrThumb2.td Message-ID: <20101206185740.4CCB22A6C12C@llvm.org> Author: resistor Date: Mon Dec 6 12:57:40 2010 New Revision: 121026 URL: http://llvm.org/viewvc/llvm-project?rev=121026&view=rev Log: Revert r121021, which broke the buildbots. Modified: llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp?rev=121026&r1=121025&r2=121026&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp Mon Dec 6 12:57:40 2010 @@ -699,36 +699,6 @@ MI.eraseFromParent(); break; } - case ARM::t2LDRHpci: - case ARM::t2LDRBpci: - case ARM::t2LDRSHpci: - case ARM::t2LDRSBpci: - case ARM::t2LDRpci: { - unsigned NewLdOpc; - if (Opcode == ARM::t2LDRpci) - NewLdOpc = ARM::t2LDRi12; - else if (Opcode == ARM::t2LDRHpci) - NewLdOpc = ARM::t2LDRHi12; - else if (Opcode == ARM::t2LDRBpci) - NewLdOpc = ARM::t2LDRBi12; - else if (Opcode == ARM::t2LDRSHpci) - NewLdOpc = ARM::t2LDRSHi12; - else if (Opcode == ARM::t2LDRSBpci) - NewLdOpc = ARM::t2LDRSBi12; - else - llvm_unreachable("Not a known opcode?"); - - unsigned DstReg = MI.getOperand(0).getReg(); - bool DstIsDead = MI.getOperand(0).isDead(); - MachineInstrBuilder MIB = - BuildMI(MBB, MBBI, MI.getDebugLoc(), - TII->get(NewLdOpc), DstReg) - .addOperand(MI.getOperand(1)); - (*MIB).setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); - TransferImpOps(MI, MIB, MIB); - MI.eraseFromParent(); - break; - } case ARM::tLDRpci_pic: case ARM::t2LDRpci_pic: { unsigned NewLdOpc = (Opcode == ARM::tLDRpci_pic) @@ -736,9 +706,9 @@ unsigned DstReg = MI.getOperand(0).getReg(); bool DstIsDead = MI.getOperand(0).isDead(); MachineInstrBuilder MIB1 = - BuildMI(MBB, MBBI, MI.getDebugLoc(), + AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(NewLdOpc), DstReg) - .addOperand(MI.getOperand(1)); + .addOperand(MI.getOperand(1))); (*MIB1).setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); MachineInstrBuilder MIB2 = BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(ARM::tPICADD)) Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=121026&r1=121025&r2=121026&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Mon Dec 6 12:57:40 2010 @@ -888,8 +888,24 @@ let Inst{5-4} = addr{1-0}; // imm } - def pci : tPseudoInst<(outs GPR:$Rt), (ins i32imm:$addr), Size4Bytes, iis, - [(set GPR:$Rt, (opnode (ARMWrapper tconstpool:$addr)))]>; + // FIXME: Is the pci variant actually needed? + def pci : T2Ipc <(outs GPR:$Rt), (ins i32imm:$addr), iii, + opc, ".w\t$Rt, $addr", + [(set GPR:$Rt, (opnode (ARMWrapper tconstpool:$addr)))]> { + let isReMaterializable = 1; + let Inst{31-27} = 0b11111; + let Inst{26-25} = 0b00; + let Inst{24} = signed; + let Inst{23} = ?; // add = (U == '1') + let Inst{22-21} = opcod; + let Inst{20} = 1; // load + let Inst{19-16} = 0b1111; // Rn + + bits<4> Rt; + bits<12> addr; + let Inst{15-12} = Rt{3-0}; + let Inst{11-0} = addr{11-0}; + } } /// T2I_st - Defines a set of (op r, {imm12|imm8|so_reg}) store patterns. From rafael.espindola at gmail.com Mon Dec 6 13:08:48 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Mon, 06 Dec 2010 19:08:48 -0000 Subject: [llvm-commits] [llvm] r121028 - in /llvm/trunk: include/llvm/MC/MCAsmLayout.h include/llvm/MC/MCAssembler.h include/llvm/Target/TargetAsmBackend.h lib/MC/MCAssembler.cpp lib/Target/ARM/ARMAsmBackend.cpp lib/Target/MBlaze/MBlazeAsmBackend.cpp lib/Target/PowerPC/PPCAsmBackend.cpp lib/Target/X86/X86AsmBackend.cpp Message-ID: <20101206190849.09C942A6C12D@llvm.org> Author: rafael Date: Mon Dec 6 13:08:48 2010 New Revision: 121028 URL: http://llvm.org/viewvc/llvm-project?rev=121028&view=rev Log: Remove the instruction fragment to data fragment lowering since it was causing freed data to be read. I will open a bug to track it being reenabled. Modified: llvm/trunk/include/llvm/MC/MCAsmLayout.h llvm/trunk/include/llvm/MC/MCAssembler.h llvm/trunk/include/llvm/Target/TargetAsmBackend.h llvm/trunk/lib/MC/MCAssembler.cpp llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp llvm/trunk/lib/Target/MBlaze/MBlazeAsmBackend.cpp llvm/trunk/lib/Target/PowerPC/PPCAsmBackend.cpp llvm/trunk/lib/Target/X86/X86AsmBackend.cpp Modified: llvm/trunk/include/llvm/MC/MCAsmLayout.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmLayout.h?rev=121028&r1=121027&r2=121028&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAsmLayout.h (original) +++ llvm/trunk/include/llvm/MC/MCAsmLayout.h Mon Dec 6 13:08:48 2010 @@ -58,16 +58,6 @@ /// fragments size should have already been updated. void Invalidate(MCFragment *F); - /// \brief Update the layout, replacing Src with Dst. The contents - /// of Src and Dst are not modified, and must be copied by the caller. - /// Src will be removed from the layout, but not deleted. - void ReplaceFragment(MCFragment *Src, MCFragment *Dst); - - /// \brief Update the layout to coalesce Src into Dst. The contents - /// of Src and Dst are not modified, and must be coalesced by the caller. - /// Src will be removed from the layout, but not deleted. - void CoalesceFragments(MCFragment *Src, MCFragment *Dst); - /// \brief Perform a full layout. void LayoutFile(); Modified: llvm/trunk/include/llvm/MC/MCAssembler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAssembler.h?rev=121028&r1=121027&r2=121028&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAssembler.h (original) +++ llvm/trunk/include/llvm/MC/MCAssembler.h Mon Dec 6 13:08:48 2010 @@ -735,6 +735,9 @@ /// FinishLayout - Finalize a layout, including fragment lowering. void FinishLayout(MCAsmLayout &Layout); + uint64_t HandleFixup(MCObjectWriter &Writer, const MCAsmLayout &Layout, + MCFragment &F, const MCFixup &Fixup); + public: /// Find the symbol which defines the atom containing the given symbol, or /// null if there is no such symbol. Modified: llvm/trunk/include/llvm/Target/TargetAsmBackend.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmBackend.h?rev=121028&r1=121027&r2=121028&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetAsmBackend.h (original) +++ llvm/trunk/include/llvm/Target/TargetAsmBackend.h Mon Dec 6 13:08:48 2010 @@ -13,7 +13,6 @@ #include "llvm/Support/DataTypes.h" namespace llvm { -class MCDataFragment; class MCFixup; class MCInst; class MCObjectFormat; @@ -87,7 +86,7 @@ /// ApplyFixup - Apply the \arg Value for given \arg Fixup into the provided /// data fragment, at the offset specified by the fixup and following the /// fixup kind as appropriate. - virtual void ApplyFixup(const MCFixup &Fixup, MCDataFragment &Fragment, + virtual void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize, uint64_t Value) const = 0; /// MayNeedRelaxation - Check whether the given instruction may need Modified: llvm/trunk/lib/MC/MCAssembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=121028&r1=121027&r2=121028&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAssembler.cpp (original) +++ llvm/trunk/lib/MC/MCAssembler.cpp Mon Dec 6 13:08:48 2010 @@ -113,30 +113,6 @@ } } -void MCAsmLayout::ReplaceFragment(MCFragment *Src, MCFragment *Dst) { - MCSectionData *SD = Src->getParent(); - - // Insert Dst immediately before Src - SD->getFragmentList().insert(Src, Dst); - - // Set the data fragment's layout data. - Dst->setParent(Src->getParent()); - Dst->setAtom(Src->getAtom()); - - Dst->Offset = Src->Offset; - Dst->EffectiveSize = Src->EffectiveSize; - - // Remove Src, but don't delete it yet. - SD->getFragmentList().remove(Src); -} - -void MCAsmLayout::CoalesceFragments(MCFragment *Src, MCFragment *Dst) { - assert(Src->getPrevNode() == Dst); - Dst->EffectiveSize += Src->EffectiveSize; - // Remove Src, but don't delete it yet. - Src->getParent()->getFragmentList().remove(Src); -} - uint64_t MCAsmLayout::getFragmentAddress(const MCFragment *F) const { assert(F->getParent() && "Missing section()!"); return getSectionAddress(F->getParent()) + getFragmentOffset(F); @@ -510,9 +486,11 @@ break; } - case MCFragment::FT_Inst: - llvm_unreachable("unexpected inst fragment after lowering"); + case MCFragment::FT_Inst: { + MCInstFragment &IF = cast(F); + OW->WriteBytes(StringRef(IF.getCode().begin(), IF.getCode().size())); break; + } case MCFragment::FT_LEB: { MCLEBFragment &LF = cast(F); @@ -591,6 +569,23 @@ assert(OW->getStream().tell() - Start == Layout.getSectionFileSize(SD)); } + +uint64_t MCAssembler::HandleFixup(MCObjectWriter &Writer, + const MCAsmLayout &Layout, + MCFragment &F, + const MCFixup &Fixup) { + // Evaluate the fixup. + MCValue Target; + uint64_t FixedValue; + if (!EvaluateFixup(Writer, Layout, Fixup, &F, Target, FixedValue)) { + // The fixup was unresolved, we need a relocation. Inform the object + // writer of the relocation, and give it an opportunity to adjust the + // fixup value if need be. + Writer.RecordRelocation(*this, Layout, &F, Fixup, Target, FixedValue); + } + return FixedValue; + } + void MCAssembler::Finish(MCObjectWriter *Writer) { DEBUG_WITH_TYPE("mc-dump", { llvm::errs() << "assembler backend - pre-layout\n--\n"; @@ -680,24 +675,24 @@ for (MCSectionData::iterator it2 = it->begin(), ie2 = it->end(); it2 != ie2; ++it2) { MCDataFragment *DF = dyn_cast(it2); - if (!DF) - continue; - - for (MCDataFragment::fixup_iterator it3 = DF->fixup_begin(), - ie3 = DF->fixup_end(); it3 != ie3; ++it3) { - MCFixup &Fixup = *it3; - - // Evaluate the fixup. - MCValue Target; - uint64_t FixedValue; - if (!EvaluateFixup(*Writer, Layout, Fixup, DF, Target, FixedValue)) { - // The fixup was unresolved, we need a relocation. Inform the object - // writer of the relocation, and give it an opportunity to adjust the - // fixup value if need be. - Writer->RecordRelocation(*this, Layout, DF, Fixup, Target,FixedValue); + if (DF) { + for (MCDataFragment::fixup_iterator it3 = DF->fixup_begin(), + ie3 = DF->fixup_end(); it3 != ie3; ++it3) { + MCFixup &Fixup = *it3; + uint64_t FixedValue = HandleFixup(*Writer, Layout, *DF, Fixup); + getBackend().ApplyFixup(Fixup, DF->getContents().data(), + DF->getContents().size(), FixedValue); + } + } + MCInstFragment *IF = dyn_cast(it2); + if (IF) { + for (MCInstFragment::fixup_iterator it3 = IF->fixup_begin(), + ie3 = IF->fixup_end(); it3 != ie3; ++it3) { + MCFixup &Fixup = *it3; + uint64_t FixedValue = HandleFixup(*Writer, Layout, *IF, Fixup); + getBackend().ApplyFixup(Fixup, IF->getCode().data(), + IF->getCode().size(), FixedValue); } - - getBackend().ApplyFixup(Fixup, *DF, FixedValue); } } } @@ -877,22 +872,6 @@ return WasRelaxed; } -static void LowerInstFragment(MCInstFragment *IF, - MCDataFragment *DF) { - - uint64_t DataOffset = DF->getContents().size(); - - // Copy in the data - DF->getContents().append(IF->getCode().begin(), IF->getCode().end()); - - // Adjust the fixup offsets and add them to the data fragment. - for (unsigned i = 0, e = IF->getFixups().size(); i != e; ++i) { - MCFixup &F = IF->getFixups()[i]; - F.setOffset(DataOffset + F.getOffset()); - DF->getFixups().push_back(F); - } -} - void MCAssembler::FinishLayout(MCAsmLayout &Layout) { // Lower out any instruction fragments, to simplify the fixup application and // output. @@ -904,45 +883,6 @@ // The layout is done. Mark every fragment as valid. Layout.getFragmentOffset(&*Layout.getSectionOrder().back()->rbegin()); - - unsigned FragmentIndex = 0; - for (unsigned i = 0, e = Layout.getSectionOrder().size(); i != e; ++i) { - MCSectionData &SD = *Layout.getSectionOrder()[i]; - MCDataFragment *CurDF = NULL; - - for (MCSectionData::iterator it2 = SD.begin(), - ie2 = SD.end(); it2 != ie2; ++it2) { - switch (it2->getKind()) { - default: - CurDF = NULL; - break; - case MCFragment::FT_Data: - CurDF = cast(it2); - break; - case MCFragment::FT_Inst: { - MCInstFragment *IF = cast(it2); - // Use the existing data fragment if possible. - if (CurDF && CurDF->getAtom() == IF->getAtom()) { - Layout.CoalesceFragments(IF, CurDF); - } else { - // Otherwise, create a new data fragment. - CurDF = new MCDataFragment(); - Layout.ReplaceFragment(IF, CurDF); - } - - // Lower the Instruction Fragment - LowerInstFragment(IF, CurDF); - - // Delete the instruction fragment and update the iterator. - delete IF; - it2 = CurDF; - break; - } - } - // Since we may have merged fragments, fix the layout order. - it2->setLayoutOrder(FragmentIndex++); - } - } } // Debugging methods Modified: llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp?rev=121028&r1=121027&r2=121028&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Mon Dec 6 13:08:48 2010 @@ -138,7 +138,7 @@ return Format; } - void ApplyFixup(const MCFixup &Fixup, MCDataFragment &DF, + void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize, uint64_t Value) const; MCObjectWriter *createObjectWriter(raw_ostream &OS) const { @@ -150,8 +150,8 @@ }; // Fixme: Raise this to share code between Darwin and ELF. -void ELFARMAsmBackend::ApplyFixup(const MCFixup &Fixup, MCDataFragment &DF, - uint64_t Value) const { +void ELFARMAsmBackend::ApplyFixup(const MCFixup &Fixup, char *Data, + unsigned DataSize, uint64_t Value) const { // Fixme: 2 for Thumb unsigned NumBytes = 4; Value = adjustFixupValue(Fixup.getKind(), Value); @@ -162,7 +162,7 @@ // bits from the fixup value. // The Value has been "split up" into the appropriate bitfields above. for (unsigned i = 0; i != NumBytes; ++i) { - DF.getContents()[Fixup.getOffset() + i] |= uint8_t(Value >> (i * 8)); + Data[Fixup.getOffset() + i] |= uint8_t(Value >> (i * 8)); } } @@ -179,7 +179,7 @@ return Format; } - void ApplyFixup(const MCFixup &Fixup, MCDataFragment &DF, + void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize, uint64_t Value) const; MCObjectWriter *createObjectWriter(raw_ostream &OS) const { @@ -207,17 +207,17 @@ } } -void DarwinARMAsmBackend::ApplyFixup(const MCFixup &Fixup, MCDataFragment &DF, - uint64_t Value) const { +void DarwinARMAsmBackend::ApplyFixup(const MCFixup &Fixup, char *Data, + unsigned DataSize, uint64_t Value) const { unsigned NumBytes = getFixupKindNumBytes(Fixup.getKind()); Value = adjustFixupValue(Fixup.getKind(), Value); - assert(Fixup.getOffset() + NumBytes <= DF.getContents().size() && + assert(Fixup.getOffset() + NumBytes <= DataSize && "Invalid fixup offset!"); // For each byte of the fragment that the fixup touches, mask in the // bits from the fixup value. for (unsigned i = 0; i != NumBytes; ++i) - DF.getContents()[Fixup.getOffset() + i] |= uint8_t(Value >> (i * 8)); + Data[Fixup.getOffset() + i] |= uint8_t(Value >> (i * 8)); } } // end anonymous namespace Modified: llvm/trunk/lib/Target/MBlaze/MBlazeAsmBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/MBlazeAsmBackend.cpp?rev=121028&r1=121027&r2=121028&view=diff ============================================================================== --- llvm/trunk/lib/Target/MBlaze/MBlazeAsmBackend.cpp (original) +++ llvm/trunk/lib/Target/MBlaze/MBlazeAsmBackend.cpp Mon Dec 6 13:08:48 2010 @@ -110,7 +110,7 @@ } - void ApplyFixup(const MCFixup &Fixup, MCDataFragment &DF, + void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize, uint64_t Value) const; MCObjectWriter *createObjectWriter(raw_ostream &OS) const { @@ -121,14 +121,14 @@ } }; -void ELFMBlazeAsmBackend::ApplyFixup(const MCFixup &Fixup, MCDataFragment &DF, - uint64_t Value) const { +void ELFMBlazeAsmBackend::ApplyFixup(const MCFixup &Fixup, char *Data, + unsigned DataSize, uint64_t Value) const { unsigned Size = getFixupKindSize(Fixup.getKind()); - assert(Fixup.getOffset() + Size <= DF.getContents().size() && + assert(Fixup.getOffset() + Size <= DataSize && "Invalid fixup offset!"); - char *data = DF.getContents().data() + Fixup.getOffset(); + char *data = Data + Fixup.getOffset(); switch (Size) { default: llvm_unreachable("Cannot fixup unknown value."); case 1: llvm_unreachable("Cannot fixup 1 byte value."); Modified: llvm/trunk/lib/Target/PowerPC/PPCAsmBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCAsmBackend.cpp?rev=121028&r1=121027&r2=121028&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCAsmBackend.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCAsmBackend.cpp Mon Dec 6 13:08:48 2010 @@ -64,7 +64,7 @@ return Format; } - void ApplyFixup(const MCFixup &Fixup, MCDataFragment &DF, + void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize, uint64_t Value) const { assert(0 && "UNIMP"); } Modified: llvm/trunk/lib/Target/X86/X86AsmBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmBackend.cpp?rev=121028&r1=121027&r2=121028&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86AsmBackend.cpp (original) +++ llvm/trunk/lib/Target/X86/X86AsmBackend.cpp Mon Dec 6 13:08:48 2010 @@ -49,14 +49,14 @@ X86AsmBackend(const Target &T) : TargetAsmBackend() {} - void ApplyFixup(const MCFixup &Fixup, MCDataFragment &DF, + void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize, uint64_t Value) const { unsigned Size = 1 << getFixupKindLog2Size(Fixup.getKind()); - assert(Fixup.getOffset() + Size <= DF.getContents().size() && + assert(Fixup.getOffset() + Size <= DataSize && "Invalid fixup offset!"); for (unsigned i = 0; i != Size; ++i) - DF.getContents()[Fixup.getOffset() + i] = uint8_t(Value >> (i * 8)); + Data[Fixup.getOffset() + i] = uint8_t(Value >> (i * 8)); } bool MayNeedRelaxation(const MCInst &Inst) const; From clattner at apple.com Mon Dec 6 13:30:58 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 6 Dec 2010 11:30:58 -0800 Subject: [llvm-commits] [llvm] r120974 - in /llvm/trunk: include/llvm/Analysis/AliasAnalysis.h lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/simple.ll In-Reply-To: <4CFD1F1C.6040001@free.fr> References: <20101206014806.79E942A6C12C@llvm.org> <03608C35-109D-4B5A-9E39-0879DD0047AC@gmail.com> <4A44A164-25BF-49E5-A922-9EE107337CCF@apple.com> <4CFD1F1C.6040001@free.fr> Message-ID: <94C7775F-F91E-4C0C-8DE1-05E7117E40F4@apple.com> On Dec 6, 2010, at 9:36 AM, Duncan Sands wrote: >> // memcpy is not defined if the source and destination pointers are exactly >> // equal, but other compilers do this optimization, and almost every memcpy >> // implementation handles this case safely. If there is a libc that does not >> // safely handle this, we can add a target hook. >> >> Note that the example from the PR doesn't explicitly call memcpy. > > I've been told that on some platforms zeroing the target memory before doing the > copy speeds it up due to cache effects. It looks like clang's implementation > of struct copy will not work on such targets. GCC also uses memcpy. If we find one of these theoretical platforms, clang can always generate memmove on it. -Chris From dalej at apple.com Mon Dec 6 13:38:42 2010 From: dalej at apple.com (Dale Johannesen) Date: Mon, 6 Dec 2010 11:38:42 -0800 Subject: [llvm-commits] [llvm] r120974 - in /llvm/trunk: include/llvm/Analysis/AliasAnalysis.h lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/simple.ll In-Reply-To: <94C7775F-F91E-4C0C-8DE1-05E7117E40F4@apple.com> References: <20101206014806.79E942A6C12C@llvm.org> <03608C35-109D-4B5A-9E39-0879DD0047AC@gmail.com> <4A44A164-25BF-49E5-A922-9EE107337CCF@apple.com> <4CFD1F1C.6040001@free.fr> <94C7775F-F91E-4C0C-8DE1-05E7117E40F4@apple.com> Message-ID: On Dec 6, 2010, at 11:30 AMPST, Chris Lattner wrote: > On Dec 6, 2010, at 9:36 AM, Duncan Sands wrote: > >>> // memcpy is not defined if the source and destination pointers are exactly >>> // equal, but other compilers do this optimization, and almost every memcpy >>> // implementation handles this case safely. If there is a libc that does not >>> // safely handle this, we can add a target hook. >>> >>> Note that the example from the PR doesn't explicitly call memcpy. >> >> I've been told that on some platforms zeroing the target memory before doing the >> copy speeds it up due to cache effects. It looks like clang's implementation >> of struct copy will not work on such targets. > > GCC also uses memcpy. If we find one of these theoretical platforms, clang can always generate memmove on it. We might consider doing that anyway, to pre-emptively avoid the problem. Memmove will not be faster, but the performance difference is zero or negligible in many environments. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20101206/659b20ad/attachment.html From baldrick at free.fr Mon Dec 6 13:56:22 2010 From: baldrick at free.fr (Duncan Sands) Date: Mon, 06 Dec 2010 20:56:22 +0100 Subject: [llvm-commits] [llvm] r120974 - in /llvm/trunk: include/llvm/Analysis/AliasAnalysis.h lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/simple.ll In-Reply-To: <94C7775F-F91E-4C0C-8DE1-05E7117E40F4@apple.com> References: <20101206014806.79E942A6C12C@llvm.org> <03608C35-109D-4B5A-9E39-0879DD0047AC@gmail.com> <4A44A164-25BF-49E5-A922-9EE107337CCF@apple.com> <4CFD1F1C.6040001@free.fr> <94C7775F-F91E-4C0C-8DE1-05E7117E40F4@apple.com> Message-ID: <4CFD3FE6.1060503@free.fr> Hi Chris, >> I've been told that on some platforms zeroing the target memory before doing the >> copy speeds it up due to cache effects. It looks like clang's implementation >> of struct copy will not work on such targets. > > GCC also uses memcpy. If we find one of these theoretical platforms, clang can always generate memmove on it. I always used to think that GCC used builtin_memcpy, which it lowered to its own memcpy implementation rather than calling the system memcpy, and so was not subject to the whims of funky system memcpy implementations. But I just took a look and it seems that I was wrong and the system memcpy may be used :) By the way, presumably when the optimizers see a memcpy of a pointer to itself it removes the memcpy if it is non-volatile. Ciao, Duncan. From rafael.espindola at gmail.com Mon Dec 6 13:55:05 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Mon, 06 Dec 2010 19:55:05 -0000 Subject: [llvm-commits] [llvm] r121034 - /llvm/trunk/lib/MC/MachObjectWriter.cpp Message-ID: <20101206195505.5AE222A6C12C@llvm.org> Author: rafael Date: Mon Dec 6 13:55:05 2010 New Revision: 121034 URL: http://llvm.org/viewvc/llvm-project?rev=121034&view=rev Log: Another use of getSymbolOffset. Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=121034&r1=121033&r2=121034&view=diff ============================================================================== --- llvm/trunk/lib/MC/MachObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/MachObjectWriter.cpp Mon Dec 6 13:55:05 2010 @@ -536,10 +536,14 @@ if (A_Base == B_Base && A_Base) report_fatal_error("unsupported relocation with identical base"); - Value += Layout.getSymbolAddress(&A_SD) - - (A_Base == NULL ? 0 : Layout.getSymbolAddress(A_Base)); - Value -= Layout.getSymbolAddress(&B_SD) - - (B_Base == NULL ? 0 : Layout.getSymbolAddress(B_Base)); + assert((A_Base == NULL) == (B_Base == NULL)); + assert(A_SD.getFragment()->getParent() == + B_SD.getFragment()->getParent()); + + Value += Layout.getSymbolOffset(&A_SD) - + (A_Base == NULL ? 0 : Layout.getSymbolOffset(A_Base)); + Value -= Layout.getSymbolOffset(&B_SD) - + (B_Base == NULL ? 0 : Layout.getSymbolOffset(B_Base)); if (A_Base) { Index = A_Base->getIndex(); From bigcheesegs at gmail.com Mon Dec 6 14:00:56 2010 From: bigcheesegs at gmail.com (Michael Spencer) Date: Mon, 6 Dec 2010 15:00:56 -0500 Subject: [llvm-commits] [llvm] r120860 - /llvm/trunk/tools/lto/LTOCodeGenerator.cpp In-Reply-To: References: <20101203235832.069492A6C12C@llvm.org> Message-ID: 2010/12/6 Rafael Esp?ndola : >>>> Do not try luck by using given name to create temporary file. In parallel builds it may not work. >>> >>> Is this a bug in the Path API? ?The documentation says >>> >>> ? ? ?bool createTemporaryFileOnDisk( >>> ? ? ? ?bool reuse_current = false, ///< When set to true, this parameter >>> ? ? ? ? ?///< indicates that if the current file name does not exist then >>> ? ? ? ? ?///< it will be used without modification. >>> >>> So I would assume that if the name does exist a new one is created. >> >> After it is determine that name does not exit, but before the file with the name is created, someone else can also determine that name does not exit in a massively parallel build. "reuse_current = true" is not useful in parallel builds. > > I would call that a bug in the API :-) > > Michael, what about removing this feature from v2 if it cannot be > reliably implemented? The current design will not use a filename that already exists no matter what. I don't get the point of this feature. - Michael Spencer >> - >> Devang > > Cheers, > Rafael > From clattner at apple.com Mon Dec 6 14:37:31 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 6 Dec 2010 12:37:31 -0800 Subject: [llvm-commits] [llvm] r120974 - in /llvm/trunk: include/llvm/Analysis/AliasAnalysis.h lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/simple.ll In-Reply-To: <4CFD3FE6.1060503@free.fr> References: <20101206014806.79E942A6C12C@llvm.org> <03608C35-109D-4B5A-9E39-0879DD0047AC@gmail.com> <4A44A164-25BF-49E5-A922-9EE107337CCF@apple.com> <4CFD1F1C.6040001@free.fr> <94C7775F-F91E-4C0C-8DE1-05E7117E40F4@apple.com> <4CFD3FE6.1060503@free.fr> Message-ID: <2354B125-5E22-4021-BEBC-0FB576EFEFC1@apple.com> On Dec 6, 2010, at 11:56 AM, Duncan Sands wrote: > I always used to think that GCC used builtin_memcpy, which it lowered to its own > memcpy implementation rather than calling the system memcpy, and so was not > subject to the whims of funky system memcpy implementations. But I just took a > look and it seems that I was wrong and the system memcpy may be used :) > > By the way, presumably when the optimizers see a memcpy of a pointer to itself > it removes the memcpy if it is non-volatile. Right, it does, but the problem is that you can have memcpy(a <- b) in which a and b can be aliased, but aren't provably identical. -Chris From clattner at apple.com Mon Dec 6 14:38:32 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 6 Dec 2010 12:38:32 -0800 Subject: [llvm-commits] [llvm] r120932 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/select.ll In-Reply-To: References: <20101205020051.C847D2A6C12C@llvm.org> <72061699-B4F6-498E-90E5-54799F2A6E31@apple.com> <0925F248-6D28-4EDB-B3AE-B1DE9F39BBDB@nondot.org> <9A7B1FA4-2E28-4EDB-9631-CD09F2C24D95@apple.com> <358DAAA5-039A-4ADE-ACEE-8051B1BE6558@nondot.org> <703382C1-9F49-4FD2-9A36-57BFE0E118BD@apple.com> Message-ID: <30470950-2979-4550-A41E-4DE6A4D709F6@apple.com> On Dec 6, 2010, at 9:29 AM, Bob Wilson wrote: >>>> Along these lines, I wonder if it would be enough to just mark IR select/condbr instructions with an instruction MDNode like !highlybiased (optionally with a direction). This could be preserved down to codegen level and used for expansion there. This would also be a straight-forward way to model __builtin_expect. >>> >>> Do we want to make it a more generic MDNode so we can use it to encode branch probability? >> >> Yes, making it more general than just "biased" makes sense. > > I've been thinking about and talking with a few people about doing exactly that for recording profile information as well. I don't yet have enough details to make a real proposal, but if you're planning to do anything like that soon, I'd be interested. I don't have any plans or anything concrete to propose, I'd be happy for someone else to write up a proposal if they're interested. -Chris From anton at korobeynikov.info Mon Dec 6 14:42:39 2010 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Mon, 6 Dec 2010 23:42:39 +0300 Subject: [llvm-commits] [llvm] r120960 - in /llvm/trunk: lib/Target/ARM/ test/CodeGen/ARM/ In-Reply-To: <4CFD24D3.1090801@arm.com> References: <20101205220416.D17E72A6C12C@llvm.org> <4CFD24D3.1090801@arm.com> Message-ID: Renato, > You probably want to avoid mixing NEON with VFP instructions, is there a > hazard recognizer for that, too? This is currently modelled on A9 via the special FU acquisition policies. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From rafael.espindola at gmail.com Mon Dec 6 14:47:56 2010 From: rafael.espindola at gmail.com (=?UTF-8?Q?Rafael_Esp=C3=ADndola?=) Date: Mon, 6 Dec 2010 15:47:56 -0500 Subject: [llvm-commits] [patch] ARM/MC/ELF RecordRelocation refactoring In-Reply-To: References: Message-ID: > I thought about ?adding new parameter(s) to GetRelocType, but given > that these two (RelocSymbol and Addend) are already available as part > of the ERE, it was a matter of adding two arguments just for the sake > of MBlaze, or isolate the arch specific code within the single > (renamed) function, and to pass the ERE directly (i.e. 1 addl' param). > I chose the latter - I would say adding const parameters to a "get" method is better than turning it into a set. The signature of the first one makes it clear what it can or cannot do. > For now, I'll commit the first patch. Thanks. > Thanks > -jason > Cheers, Rafael From bob.wilson at apple.com Mon Dec 6 14:48:19 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 6 Dec 2010 12:48:19 -0800 Subject: [llvm-commits] [llvm] r120932 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/select.ll In-Reply-To: <30470950-2979-4550-A41E-4DE6A4D709F6@apple.com> References: <20101205020051.C847D2A6C12C@llvm.org> <72061699-B4F6-498E-90E5-54799F2A6E31@apple.com> <0925F248-6D28-4EDB-B3AE-B1DE9F39BBDB@nondot.org> <9A7B1FA4-2E28-4EDB-9631-CD09F2C24D95@apple.com> <358DAAA5-039A-4ADE-ACEE-8051B1BE6558@nondot.org> <703382C1-9F49-4FD2-9A36-57BFE0E118BD@apple.com> <30470950-2979-4550-A41E-4DE6A4D709F6@apple.com> Message-ID: <1890BA5C-497E-4B5C-82A3-BC73AC7A784B@apple.com> On Dec 6, 2010, at 12:38 PM, Chris Lattner wrote: > > On Dec 6, 2010, at 9:29 AM, Bob Wilson wrote: > >>>>> Along these lines, I wonder if it would be enough to just mark IR select/condbr instructions with an instruction MDNode like !highlybiased (optionally with a direction). This could be preserved down to codegen level and used for expansion there. This would also be a straight-forward way to model __builtin_expect. >>>> >>>> Do we want to make it a more generic MDNode so we can use it to encode branch probability? >>> >>> Yes, making it more general than just "biased" makes sense. >> >> I've been thinking about and talking with a few people about doing exactly that for recording profile information as well. I don't yet have enough details to make a real proposal, but if you're planning to do anything like that soon, I'd be interested. > > I don't have any plans or anything concrete to propose, I'd be happy for someone else to write up a proposal if they're interested. OK. I'm working on it in the background as time permits.... I hope to write something up soon, but it depends on what other tasks come my way. From baldrick at free.fr Mon Dec 6 14:50:38 2010 From: baldrick at free.fr (Duncan Sands) Date: Mon, 06 Dec 2010 21:50:38 +0100 Subject: [llvm-commits] [llvm] r120974 - in /llvm/trunk: include/llvm/Analysis/AliasAnalysis.h lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/simple.ll In-Reply-To: <2354B125-5E22-4021-BEBC-0FB576EFEFC1@apple.com> References: <20101206014806.79E942A6C12C@llvm.org> <03608C35-109D-4B5A-9E39-0879DD0047AC@gmail.com> <4A44A164-25BF-49E5-A922-9EE107337CCF@apple.com> <4CFD1F1C.6040001@free.fr> <94C7775F-F91E-4C0C-8DE1-05E7117E40F4@apple.com> <4CFD3FE6.1060503@free.fr> <2354B125-5E22-4021-BEBC-0FB576EFEFC1@apple.com> Message-ID: <4CFD4C9E.8030907@free.fr> Hi Chris, >> By the way, presumably when the optimizers see a memcpy of a pointer to itself >> it removes the memcpy if it is non-volatile. > > Right, it does, but the problem is that you can have memcpy(a<- b) in which a and b can be aliased, but aren't provably identical. if you can prove that they overlap, I guess you can assume that they are identical and remove the memcpy. Ciao, Duncan. From clattner at apple.com Mon Dec 6 15:02:41 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 6 Dec 2010 13:02:41 -0800 Subject: [llvm-commits] [llvm] r120974 - in /llvm/trunk: include/llvm/Analysis/AliasAnalysis.h lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/simple.ll In-Reply-To: <4CFD4C9E.8030907@free.fr> References: <20101206014806.79E942A6C12C@llvm.org> <03608C35-109D-4B5A-9E39-0879DD0047AC@gmail.com> <4A44A164-25BF-49E5-A922-9EE107337CCF@apple.com> <4CFD1F1C.6040001@free.fr> <94C7775F-F91E-4C0C-8DE1-05E7117E40F4@apple.com> <4CFD3FE6.1060503@free.fr> <2354B125-5E22-4021-BEBC-0FB576EFEFC1@apple.com> <4CFD4C9E.8030907@free.fr> Message-ID: <38EFBF49-4A47-4C0C-93BE-ED4DA42F8E96@apple.com> On Dec 6, 2010, at 12:50 PM, Duncan Sands wrote: > Hi Chris, > >>> By the way, presumably when the optimizers see a memcpy of a pointer to itself >>> it removes the memcpy if it is non-volatile. >> >> Right, it does, but the problem is that you can have memcpy(a<- b) in which a and b can be aliased, but aren't provably identical. > > if you can prove that they overlap, I guess you can assume that they are > identical and remove the memcpy. Yes, we do that. -Chris From clattner at apple.com Mon Dec 6 15:03:30 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 6 Dec 2010 13:03:30 -0800 Subject: [llvm-commits] [llvm] r120984 - in /llvm/trunk/include/llvm/ADT: SmallString.h SmallVector.h In-Reply-To: References: <20101206042742.3E11F2A6C12C@llvm.org> <9472EFC6-4AC9-4A0B-A7FF-1CEB4D7E3A52@apple.com> Message-ID: <877E861D-22F1-4782-B20A-292652EE60CC@apple.com> On Dec 5, 2010, at 9:44 PM, Michael Spencer wrote: >> I don't think this makes sense, why not just cast data? With wchar_t you usually need a multibyte 0 anyway. >> >> -Chris > > c_str() as implemented uses push_back to add the 0, thus we get a > sizeof(wchar_t) byte null terminator. The reason this is needed is > because I kept running into bugs trying to keep track of when I needed > to add a null terminator. This way I can use c_str() exactly when > passing the string to a Windows API function. Oh right, but why add this to SmallVector? It doesn't seem to make sense there. If there are weird clients that want this in the system library, can't they either take a smallstring, or just do push_back(0) + pop_back() manually? -Chris From peckw at wesleypeck.com Mon Dec 6 15:11:01 2010 From: peckw at wesleypeck.com (Wesley Peck) Date: Mon, 06 Dec 2010 21:11:01 -0000 Subject: [llvm-commits] [llvm] r121037 - in /llvm/trunk: lib/Target/MBlaze/MBlazeDelaySlotFiller.cpp test/CodeGen/MBlaze/imm.ll Message-ID: <20101206211101.C6FEF2A6C12C@llvm.org> Author: peckw Date: Mon Dec 6 15:11:01 2010 New Revision: 121037 URL: http://llvm.org/viewvc/llvm-project?rev=121037&view=rev Log: Fix a 16-bit immediate value detection bug in the MBlaze delay slot filler. Address more hazards in the MBlaze delay slot filler. patch contributed by Jack Whitham! Modified: llvm/trunk/lib/Target/MBlaze/MBlazeDelaySlotFiller.cpp llvm/trunk/test/CodeGen/MBlaze/imm.ll Modified: llvm/trunk/lib/Target/MBlaze/MBlazeDelaySlotFiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/MBlazeDelaySlotFiller.cpp?rev=121037&r1=121036&r2=121037&view=diff ============================================================================== --- llvm/trunk/lib/Target/MBlaze/MBlazeDelaySlotFiller.cpp (original) +++ llvm/trunk/lib/Target/MBlaze/MBlazeDelaySlotFiller.cpp Mon Dec 6 15:11:01 2010 @@ -29,6 +29,14 @@ STATISTIC(FilledSlots, "Number of delay slots filled"); +namespace llvm { +cl::opt DisableDelaySlotFiller( + "disable-mblaze-delay-filler", + cl::init(false), + cl::desc("Disable the MBlaze delay slot filter."), + cl::Hidden); +} + namespace { struct Filler : public MachineFunctionPass { @@ -61,15 +69,22 @@ // 16-bits requires an implicit IMM instruction. unsigned numOper = candidate->getNumOperands(); for (unsigned op = 0; op < numOper; ++op) { - if (candidate->getOperand(op).isImm() && - (candidate->getOperand(op).getImm() & 0xFFFFFFFFFFFF0000LL) != 0) - return true; + MachineOperand &mop = candidate->getOperand(op); + + // The operand requires more than 16-bits to represent. + if (mop.isImm() && (mop.getImm() < -0x8000 || mop.getImm() > 0x7fff)) + return true; + + // We must assume that unknown immediate values require more than + // 16-bits to represent. + if (mop.isGlobal() || mop.isSymbol()) + return true; // FIXME: we could probably check to see if the FP value happens // to not need an IMM instruction. For now we just always - // assume that FP values always do. - if (candidate->getOperand(op).isFPImm()) - return true; + // assume that FP values do. + if (mop.isFPImm()) + return true; } return false; @@ -77,48 +92,67 @@ static bool delayHasHazard(MachineBasicBlock::iterator &candidate, MachineBasicBlock::iterator &slot) { - // Loop over all of the operands in the branch instruction - // and make sure that none of them are defined by the - // candidate instruction. - unsigned numOper = slot->getNumOperands(); - for (unsigned op = 0; op < numOper; ++op) { - if (!slot->getOperand(op).isReg() || - !slot->getOperand(op).isUse() || - slot->getOperand(op).isImplicit()) - continue; - - unsigned cnumOper = candidate->getNumOperands(); - for (unsigned cop = 0; cop < cnumOper; ++cop) { - if (candidate->getOperand(cop).isReg() && - candidate->getOperand(cop).isDef() && - candidate->getOperand(cop).getReg() == - slot->getOperand(op).getReg()) - return true; - } + // Hazard check + MachineBasicBlock::iterator a = candidate; + MachineBasicBlock::iterator b = slot; + TargetInstrDesc desc = candidate->getDesc(); + + // MBB layout:- + // candidate := a0 = operation(a1, a2) + // ...middle bit... + // slot := b0 = operation(b1, b2) + + // Possible hazards:-/ + // 1. a1 or a2 was written during the middle bit + // 2. a0 was read or written during the middle bit + // 3. a0 is one or more of {b0, b1, b2} + // 4. b0 is one or more of {a1, a2} + // 5. a accesses memory, and the middle bit + // contains a store operation. + bool a_is_memory = desc.mayLoad() || desc.mayStore(); + + // Check hazards type 1, 2 and 5 by scanning the middle bit + MachineBasicBlock::iterator m = a; + for (++m; m != b; ++m) { + for (unsigned aop = 0, aend = a->getNumOperands(); aopgetOperand(aop).isReg(); + if (!aop_is_reg) continue; + + bool aop_is_def = a->getOperand(aop).isDef(); + unsigned aop_reg = a->getOperand(aop).getReg(); + + for (unsigned mop = 0, mend = m->getNumOperands(); mopgetOperand(mop).isReg(); + if (!mop_is_reg) continue; + + bool mop_is_def = m->getOperand(mop).isDef(); + unsigned mop_reg = m->getOperand(mop).getReg(); + + if (aop_is_def && (mop_reg == aop_reg)) + return true; // Hazard type 2, because aop = a0 + else if (mop_is_def && (mop_reg == aop_reg)) + return true; // Hazard type 1, because aop in {a1, a2} + } } - // There are no hazards between the two instructions - return false; -} + // Check hazard type 5 + if (a_is_memory && m->getDesc().mayStore()) + return true; + } -static bool usedBeforeDelaySlot(MachineBasicBlock::iterator &candidate, - MachineBasicBlock::iterator &slot) { - MachineBasicBlock::iterator I = candidate; - for (++I; I != slot; ++I) { - unsigned numOper = I->getNumOperands(); - for (unsigned op = 0; op < numOper; ++op) { - if (I->getOperand(op).isReg() && - I->getOperand(op).isUse()) { - unsigned reg = I->getOperand(op).getReg(); - unsigned cops = candidate->getNumOperands(); - for (unsigned cop = 0; cop < cops; ++cop) { - if (candidate->getOperand(cop).isReg() && - candidate->getOperand(cop).isDef() && - candidate->getOperand(cop).getReg() == reg) - return true; - } - } + // Check hazard type 3 & 4 + for (unsigned aop = 0, aend = a->getNumOperands(); aopgetOperand(aop).isReg()) { + unsigned aop_reg = a->getOperand(aop).getReg(); + + for (unsigned bop = 0, bend = b->getNumOperands(); bopgetOperand(bop).isReg() && (!b->getOperand(bop).isImplicit())) { + unsigned bop_reg = b->getOperand(bop).getReg(); + if (aop_reg == bop_reg) + return true; } + } + } } return false; @@ -142,11 +176,12 @@ --I; TargetInstrDesc desc = I->getDesc(); - if (desc.hasDelaySlot() || desc.isBranch() || isDelayFiller(MBB,I)) + if (desc.hasDelaySlot() || desc.isBranch() || isDelayFiller(MBB,I) || + desc.isCall() || desc.isReturn() || desc.isBarrier() || + desc.hasUnmodeledSideEffects()) break; - if (desc.mayLoad() || desc.mayStore() || hasImmInstruction(I) || - delayHasHazard(I,slot) || usedBeforeDelaySlot(I,slot)) + if (hasImmInstruction(I) || delayHasHazard(I,slot)) continue; return I; @@ -162,9 +197,12 @@ bool Changed = false; for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end(); ++I) if (I->getDesc().hasDelaySlot()) { - MachineBasicBlock::iterator D = findDelayInstr(MBB,I); + MachineBasicBlock::iterator D = MBB.end(); MachineBasicBlock::iterator J = I; + if (!DisableDelaySlotFiller) + D = findDelayInstr(MBB,I); + ++FilledSlots; Changed = true; Modified: llvm/trunk/test/CodeGen/MBlaze/imm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MBlaze/imm.ll?rev=121037&r1=121036&r2=121037&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MBlaze/imm.ll (original) +++ llvm/trunk/test/CodeGen/MBlaze/imm.ll Mon Dec 6 15:11:01 2010 @@ -22,7 +22,7 @@ ; FPU: retimm_i16: ; FPU: rtsd ; FPU-NEXT: add - ret i16 38212 + ret i16 31212 } define i32 @retimm_i32() { From sabre at nondot.org Mon Dec 6 15:13:51 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 06 Dec 2010 21:13:51 -0000 Subject: [llvm-commits] [llvm] r121038 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Message-ID: <20101206211351.BFB852A6C12C@llvm.org> Author: lattner Date: Mon Dec 6 15:13:51 2010 New Revision: 121038 URL: http://llvm.org/viewvc/llvm-project?rev=121038&view=rev Log: add some DEBUG statements. Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=121038&r1=121037&r2=121038&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Mon Dec 6 15:13:51 2010 @@ -23,8 +23,6 @@ #include "llvm/Instructions.h" #include "llvm/IntrinsicInst.h" #include "llvm/Pass.h" -#include "llvm/ADT/SmallPtrSet.h" -#include "llvm/ADT/Statistic.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/MemoryBuiltins.h" @@ -32,6 +30,9 @@ #include "llvm/Analysis/ValueTracking.h" #include "llvm/Target/TargetData.h" #include "llvm/Transforms/Utils/Local.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; STATISTIC(NumFastStores, "Number of stores deleted"); @@ -441,6 +442,9 @@ if (LoadInst *DepLoad = dyn_cast(InstDep.getInst())) { if (SI->getPointerOperand() == DepLoad->getPointerOperand() && SI->getOperand(0) == DepLoad && !SI->isVolatile()) { + DEBUG(dbgs() << "DSE: Remove Store Of Load from same pointer:\n " + << "LOAD: " << *DepLoad << "\n STORE: " << *SI << '\n'); + // DeleteDeadInstruction can delete the current instruction. Save BBI // in case we need it. WeakVH NextInst(BBI); @@ -484,6 +488,9 @@ // 'Inst' doesn't load from, then we can remove it. if (isRemovable(DepWrite) && isCompleteOverwrite(Loc, DepLoc, *AA) && !isPossibleSelfRead(Inst, Loc, DepWrite, *AA)) { + DEBUG(dbgs() << "DSE: Remove Dead Store:\n DEAD: " + << *DepWrite << "\n KILLER: " << *Inst << '\n'); + // Delete the store and now-dead instructions that feed it. DeleteDeadInstruction(DepWrite, *MD); ++NumFastStores; @@ -593,8 +600,12 @@ // Stores to stack values are valid candidates for removal. if (DeadStackObjects.count(Pointer)) { - // DCE instructions only used to calculate that store. Instruction *Dead = BBI++; + + DEBUG(dbgs() << "DSE: Dead Store at End of Block:\n DEAD: " + << *Dead << "\n Object: " << *Pointer << '\n'); + + // DCE instructions only used to calculate that store. DeleteDeadInstruction(Dead, *MD, &DeadStackObjects); ++NumFastStores; MadeChange = true; From baldrick at free.fr Mon Dec 6 15:20:43 2010 From: baldrick at free.fr (Duncan Sands) Date: Mon, 06 Dec 2010 22:20:43 +0100 Subject: [llvm-commits] [llvm] r120974 - in /llvm/trunk: include/llvm/Analysis/AliasAnalysis.h lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/simple.ll In-Reply-To: <38EFBF49-4A47-4C0C-93BE-ED4DA42F8E96@apple.com> References: <20101206014806.79E942A6C12C@llvm.org> <03608C35-109D-4B5A-9E39-0879DD0047AC@gmail.com> <4A44A164-25BF-49E5-A922-9EE107337CCF@apple.com> <4CFD1F1C.6040001@free.fr> <94C7775F-F91E-4C0C-8DE1-05E7117E40F4@apple.com> <4CFD3FE6.1060503@free.fr> <2354B125-5E22-4021-BEBC-0FB576EFEFC1@apple.com> <4CFD4C9E.8030907@free.fr> <38EFBF49-4A47-4C0C-93BE-ED4DA42F8E96@apple.com> Message-ID: <4CFD53AB.9080801@free.fr> >>>> By the way, presumably when the optimizers see a memcpy of a pointer to itself >>>> it removes the memcpy if it is non-volatile. >>> >>> Right, it does, but the problem is that you can have memcpy(a<- b) in which a and b can be aliased, but aren't provably identical. >> >> if you can prove that they overlap, I guess you can assume that they are >> identical and remove the memcpy. > > Yes, we do that. Excellent! Thanks for clarifying. Best wishes, Duncan. From clattner at apple.com Mon Dec 6 15:49:04 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 6 Dec 2010 13:49:04 -0800 Subject: [llvm-commits] [Review request] [PR8714] Jump threading of indirectbr blocks (and more) In-Reply-To: References: Message-ID: On Dec 5, 2010, at 12:24 PM, Frits van Bommel wrote: > On Sun, Dec 5, 2010 at 7:30 PM, Chris Lattner wrote: >> Otherwise, looks great, please commit and resend the followon patch, thanks! > > An updated version of the follow-on patch is attached. > > The description again: > Implement jump threading of 'indirectbr' by keeping track of whether > we're looking for ConstantInt*s or BlockAddress*s. > > I wasn't sure what "bonus" to give for threading over an indirectbr. I > figured a bit more than the one for threading over a switch, but I > could be completely off base here. Anyone? I think it should be a bit higher than switch, but not to much higher. indbr is actually cheaper than a switch in execution and code size cost. OTOH, indbr is much more rare, so bumping up the threshold (above that of a switch) is completely fine, because code growth is acceptable if we can get performance in cases that go through the trouble of using indbr. Here are some comments: -static Constant *getKnownConstant(Value *Val) { +static Constant *getKnownConstant(Value* Val, bool wantBlockAddress) { We've got * movement :) Also, please capitalize wantBlockAddress for consistency. Perhaps an enum would be better than a bool for the argument? That would read better than the false in: + ComputeValueKnownInPredecessors(BO->getOperand(0), BB, LHSVals, false); // Helper method for ComputeValueKnownInPredecessors. If Value is a +// ConstantInt/BlockAddress (depending on which we want) or undef, push it. +// Otherwise, do nothing. static void PushKnownConstantOrUndef(PredValueInfo &Result, Constant *Value, It's somewhat independent from this patch, but (as a result of your previous changes) PushKnownConstantOrUndef is simple enough that it should just be inlined into its call sites: the resulting code would be more clear than with it out of line. Otherwise, the patch and testcase look great. Please commit with appropriate tweaks, and resolve the bugzilla. Thanks Frits! -Chris From sabre at nondot.org Mon Dec 6 15:48:10 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 06 Dec 2010 21:48:10 -0000 Subject: [llvm-commits] [llvm] r121040 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Message-ID: <20101206214810.99E462A6C12D@llvm.org> Author: lattner Date: Mon Dec 6 15:48:10 2010 New Revision: 121040 URL: http://llvm.org/viewvc/llvm-project?rev=121040&view=rev Log: Use a stronger predicate here, pointed out by Duncan Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=121040&r1=121039&r2=121040&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Mon Dec 6 15:48:10 2010 @@ -277,7 +277,7 @@ if (const AllocaInst *AI = dyn_cast(V)) return !AI->isArrayAllocation(); if (const GlobalVariable *GV = dyn_cast(V)) - return !GV->isWeakForLinker(); + return !GV->mayBeOverridden(); if (const Argument *A = dyn_cast(V)) return A->hasByValAttr(); return false; From clattner at apple.com Mon Dec 6 15:50:40 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 6 Dec 2010 13:50:40 -0800 Subject: [llvm-commits] [llvm] r120498 - in /llvm/trunk: lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/PartialStore.ll In-Reply-To: <4CF602CE.7090902@free.fr> References: <20101130234323.657052A6C12D@llvm.org> <4CF602CE.7090902@free.fr> Message-ID: <7BCE722E-AC59-4316-B355-C28855D8E03A@apple.com> On Dec 1, 2010, at 12:09 AM, Duncan Sands wrote: >> >> >> +/// isObjectPointerWithTrustworthySize - Return true if the specified Value* is >> +/// pointing to an object with a pointer size we can trust. >> +static bool isObjectPointerWithTrustworthySize(const Value *V) { >> + if (const AllocaInst *AI = dyn_cast(V)) >> + return !AI->isArrayAllocation(); >> + if (const GlobalVariable *GV = dyn_cast(V)) >> + return !GV->isWeakForLinker(); > > this should be mayBeOverridden not isWeakForLinker. That way globals with > weak ODR linkage will be considered to have a trustworthy size. By the way > isWeakForLinker should really be moved somewhere where people can't get at > it, like the linker for example. Great point, fixed in r121040, thanks for the review! -Chris From bigcheesegs at gmail.com Mon Dec 6 15:50:59 2010 From: bigcheesegs at gmail.com (Michael Spencer) Date: Mon, 6 Dec 2010 16:50:59 -0500 Subject: [llvm-commits] PathV2 review notes In-Reply-To: References: Message-ID: On Mon, Dec 6, 2010 at 12:48 PM, Dan Gohman wrote: > Hello, > > I read through the current PathV2 platform-independent and Unix code. > I'm aware that it's not complete yet, but there's already a lot of code there. > Below are some review comments. Hello and thanks very much for looking at this. I am not a Unix/POSIX API expert, in fact, this is the first time I've looked at the documentation for most of these calls. > include/llvm/Support/PathV2.h: > >> /// @name Lexical Modifiers >> /// @{ > >> /// @brief Make \a path an absolute path. >> /// >> /// Makes \a path absolute using the current directory if it is not already. An >> /// empty \a path will result in the current directory. >> /// >> /// /absolute/path ? => /absolute/path >> /// relative/../path => /path >> /// >> /// @param path A path that is modified to be an absolute path. >> /// @returns errc::success if \a path has been made absolute, otherwise a >> /// ? ? ? ? ?platform specific error_code. >> error_code make_absolute(SmallVectorImpl &path); > > The top-level section comment suggests that this is a lexical > operation, but it is not. I wasn't completely sure where to group this function. It is lexical in that it does not resolve any symlinks or other weirdness. However, it does use the current directory if the path is not already absolute. I also just noticed that the documentation is incorrect. This function does not resolve '.' or '..', thus: relative/../path => /relative/../path As it stands, I would either agree with keeping the function as is and moving it over to sys::fs and FileSystem.h, or I would like to add a base argument and a sys::fs::initial_directory function (which returns the current directory as it would be immediately before main). This really depends on how often and when a base directory other than current is used. If make_absolute is used in any of the libraries then there is technically a race condition, because another part of the process could change the current directory at any time (although most programs don't do this). >> /// @brief Remove the last component from \a path if it exists. >> /// >> /// directory/filename.cpp => directory/ >> /// directory/ ? ? ? ? ? ? => directory >> /// >> /// @param path A path that is modified to not have a file component. >> /// @returns errc::success if \a path's file name has been removed (or there was >> /// ? ? ? ? ?not one to begin with), otherwise a platform specific error_code. >> error_code remove_filename(SmallVectorImpl &path); > > The words "if it exists" are a little misleading in this context, since > this is actually a purely lexical transformation. The fact that this function > returns an error code contributes to the ambiguity. Yes, the "if it exists" is incorrect. The function actually removes the last component unless it is the root directory. > On a related note, there are many functions (root_directory, root_path, > is_absolute, etc.) like this which are purely lexical, and implemented > with platform-independent code, and which always return success. It's > unfortunate that clients are required to cope with "a platform specific > error_code" when working with any of these interfaces, since it isn't > really needed. > > Unlike Boost, LLVM doesn't propogate malloc errors. If malloc fails, > LLVM crashes (at best). We can have interesting discussions about > whether or not this is a bug, but it does simplify many things. > Also unlike Boost, LLVM's libSupport can easily change its API if it > ever somehow makes sense for these functions to return errors in the > future. I agree that it is awkward. I decided to return error_codes to stay consistent with the rest of the API, and to allow handling memory errors. However, now that we have the path, and fs namespace split, I think it would be ok to remove the error_code return from path. I don't see SmallVector and friends getting any support for reporting memory allocation errors any time soon. This would also require moving current_path (and make_absolute as it is currently designed) into fs. >> /// @brief Replace the file extension of \a path with \a extension. >> /// >> /// ./filename.cpp => ./filename.extension >> /// ./filename ? ? => ./filename.extension >> /// ./ ? ? ? ? ? ? => ? TODO: decide what semantics this has. >> /// >> /// @param path A path that has its extension replaced with \a extension. >> /// @param extension The extension to be added. It may be empty. It may also >> /// ? ? ? ? ? ? ? ? ?optionally start with a '.', if it does not, one will be >> /// ? ? ? ? ? ? ? ? ?prepended. >> /// @returns errc::success if \a path's extension has been replaced, otherwise a >> /// ? ? ? ? ?platform specific error_code. >> error_code replace_extension(SmallVectorImpl &path, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const Twine &extension); > > The behavior of prepending a '.' if the suffix doesn't already have > one is confusing. Since extension includes the dot, it would be > consistent for replace_extension to require it. It could even > verify this with an assert. I don't have a strong opinion on this either way other than I don't feel it's confusing. >> /// @name Lexical Observers >> /// @{ >> >> /// @brief Get the current path. >> /// >> /// @param result Holds the current path on return. >> /// @results errc::success if the current path has been stored in result, >> /// ? ? ? ? ?otherwise a platform specific error_code. >> error_code current_path(SmallVectorImpl &result); > > Same as above; this isn't a purely lexical operation. I agree. >> /// @brief Get root name. >> /// >> /// //net/hello => //net >> /// c:/hello ? ?=> c: (on Windows, on other platforms nothing) >> /// /hello ? ? ?=> > > UNC-style double-slash pathnames are not well known in Unix circles; > a comment on that first example would be helpful. OK, from what I understand POSIX supports them. > As an aside, does it really make sense to implement UNC pathnames > on systems where the underlying libc API doesn't implement them? I > realize you're just following Boost here though. > > More broadly, there seem to be two major ways of bisecting paths > in this API: root+relative and parent+filename (as this API names them). > Parent+filename is obvious, but when would root+relative be useful for > LLVM? Compilers and related tools should never go digging around in > the filesystem root on their own. I do not expect these functions to be used directly, however, they are used extensively in the implementation of other functions. > lib/Support/PathV2.cpp > >> native > >> ? // Clear result. >> ? result.set_size(0); > > Should this be result.clear()? set_size is usually an indication > that something special is happening, and that doesn't appear to > be the case here. You are correct. I think I assumed that clear freed memory or something. >> error_code has_root_directory(const Twine &path, bool &result) { >> ? SmallString<128> path_storage; >> ? StringRef p = path.toStringRef(path_storage); >> >> ? if (error_code ec = root_directory(p, p)) return ec; >> >> ? result = !p.empty(); >> ? return success; >> } > > Calling root_directory(p, p) here looks unsafe: p isn't guaranteed > to be pointing to path_storage, and root_directory writes > through it. root_directory doesn't write. > lib/Support/Unix/PathV2.inc: > >> #if HAVE_STDIO_H >> #include >> #endif > > Shouldn't stdio.h always be available? I didn't add the configure check :P. I just added the HAVE_ checks either where I knew there could be a problem, or it already existed. >> ? ? ~AutoFD() { >> ? ? ? if (FileDescriptor >= 0) >> ? ? ? ? ::close(FileDescriptor); >> ? ? } > > This AutoFD class not check for errors on ::close, so hopefully it'll only > be used in contexts where that doesn't matter. A comment about this would > be appropriate. OK. >> TempDir > >> ? ? (dir = std::getenv("TMPDIR" )) || > > It's suspicious for the path library to be using "TMPDIR" privately > like this. What is this for? I implemented the function the way the Open Group standard defines tmpname as looking for the temp directory. It is private because clients should not care where the temp directory is or directly use it. >> error_code current_path(SmallVectorImpl &result) { >> ? long size = ::pathconf(".", _PC_PATH_MAX); >> ? result.reserve(size + 1); >> ? result.set_size(size + 1); >> >> ? if (::getcwd(result.data(), result.size()) == 0) >> ? ? return error_code(errno, system_category()); >> >> ? result.set_size(strlen(result.data())); >> ? return success; >> } > > POSIX describes _PC_PATH_MAX as indicating "the longest relative pathname > that could be given if the specified directory is the process' current > working directory", which isn't what it's being used for here. For a > fully general implementation, just do a simple loop which starts at > MAXPATHLEN and reallocates the buffer until getcwd succeeds. OK. >> namespace fs{ > > Whitespace before {. OK. >> copy_file > > FWIW, it appears copy_file is apparently only used by llvm-ld and only on > Windows, so the Unix implementation is currently dead code. Should it be removed? >> ? // Open from. >> ? if ((from_file = ::open(f.begin(), O_RDONLY)) < 0) >> ? ? return error_code(errno, system_category()); >> ? AutoFD from_fd(from_file); >> >> ? // Stat from. >> ? struct stat from_stat; >> ? if (::stat(f.begin(), &from_stat) != 0) >> ? ? return error_code(errno, system_category()); > > It's more efficient to use fstat than stat, since the file descriptor > is right there. llvm-ld's use of copy_file probably doesn't care about > performance, but in general this is an idiom to watch out for. OK. >> ? if (copt == copy_option::fail_if_exists) >> ? ? to_flags |= O_EXCL; > > The old CopyFile implementation doesn't have this. What is it for? It allows correctly choosing to either overwrite or error when the to file already exists. Not having an option forces a race condition. It was added because it was part of the filesystem v3 API. >> ? // Open to. >> ? if ((to_file = ::open(t.begin(), to_flags, from_stat.st_mode)) < 0) >> ? ? return error_code(errno, system_category()); >> ? AutoFD to_fd(to_file); > > AutoFD isn't really needed here, and in fact it makes the code harder > to follow. If AutoFD ever does its job, it would be calling ::close > without checking for errors, so the only way this code is correct is > if AutoFD is never permitted to do its job. You are correct that the to_fd AutoFD is unused. The from_fd is used correctly if either of the two return statements after it are reached. >> ? // After all the file operations above the return value of close actually >> ? // matters. >> ? if (::close(from_fd.take()) < 0) sz_read = -1; >> ? if (::close(to_fd.take()) < 0) sz_read = -1; >> >> ? // Check for errors. >> ? if (sz_read < 0) >> ? ? return error_code(errno, system_category()); > > If errors from ::close on from_fd actually matter, this risks reporting > the wrong error message, since errno could be clobbered by the second > ::close (even if it succeeds). It only matters if an error occurred, not which fd caused it. > Also, the old CopyFile returned error messages which indicated > whether the error was in the source or the destination. This API > doesn't expose that information at all, so clients won't be able to > produce a descriptive error message. Adding that information is easy enough. I just need to add a custom error_category for it. However, if copy_file is really not used, it doesn't seem worth it. >> create_directory > >> ? if (::mkdir(p.begin(), 0700) == -1) { > > Please use the symbolic names instead of a raw octal value. > I believe this is S_IRWXU. OK. > Also, the old createDiectoryOnDisk used S_IRWXU | S_IRWXG. Is > it an intentional change to start ignoring the group portion of > the user's umask settings? ?If so, please add comments > explaining this choice. It was not. > Also, is the 'existed' argument really needed? It helps in the implementation of some other functions. >> create_hard_link >> create_symlink > > The old Path library doesn't have these. What are they for? Mainly I wanted them to add tests for equivalence for when the clang preprocessor is switched over. I have no problem removing them. >> remove > >> ? if (::remove(p.begin()) == -1) { >> ? ? if (errno != errc::no_such_file_or_directory) >> ? ? ? return error_code(errno, system_category()); > > Using the errc namespace here conflates API levels. This code > should use ENOENT directly instead of no_such_file_or_directory. I used the errc enum constants because they are infinitely more readable than the ERRNO macros. It's safe because they are guaranteed to have the same value. >> resize_file > > The old Path doesn't have this. What is it for? It's unused. I have no problem removing it. >> error_code exists(const Twine &path, bool &result) { > > The old Path::exists returned false on EACCESS. This code will return > an error condition. Is this an intentional change? Yes. Not having permission is not the same as the file not existing. >> file_size > > What is this for? Doing a full ::stat call and throwing away all > the information except st_size is suspicious. There are a lot of functions that take both a path and a file_status, this should be one of them. If you only need the file size you just call this, otherwise you call status and reuse the file_status class (which currently only stores st_mode, but that will change). >> unique_file > >> ? [... lots of stuff ...] > > Please don't try to do what mkstemp does manually. Just use mkstemp. > > mkstemp is very widely available these days. For portability to > exotic platforms, it's fine to put the burden on people who care > to contribute patches. > > Dan There are quite a few things I don't like about using mkstemp for LLVM: * You can't specify any of the flags used to create the file. * Filenames are required to end in XXXXXX (I've never understood this requirement). * You can only use an absolute path, so you end up explicitly using /tmp. Although this can be handled before mkstemp is called. If we're OK with all that, then I don't mind switching the Unix impl over to mkstemp if it's present. Thanks very much for the detailed review! - Michael Spencer From rafael.espindola at gmail.com Mon Dec 6 15:51:55 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Mon, 06 Dec 2010 21:51:55 -0000 Subject: [llvm-commits] [llvm] r121041 - /llvm/trunk/lib/MC/MachObjectWriter.cpp Message-ID: <20101206215155.58D4C2A6C12C@llvm.org> Author: rafael Date: Mon Dec 6 15:51:55 2010 New Revision: 121041 URL: http://llvm.org/viewvc/llvm-project?rev=121041&view=rev Log: use getSymbolOffset. Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=121041&r1=121040&r2=121041&view=diff ============================================================================== --- llvm/trunk/lib/MC/MachObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/MachObjectWriter.cpp Mon Dec 6 15:51:55 2010 @@ -598,7 +598,7 @@ // Add the local offset, if needed. if (Base != &SD) - Value += Layout.getSymbolAddress(&SD) - Layout.getSymbolAddress(Base); + Value += Layout.getSymbolOffset(&SD) - Layout.getSymbolOffset(Base); } else if (Symbol->isInSection()) { // The index is the section ordinal (1-based). Index = SD.getFragment()->getParent()->getOrdinal() + 1; From sabre at nondot.org Mon Dec 6 15:53:07 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 06 Dec 2010 21:53:07 -0000 Subject: [llvm-commits] [llvm] r121042 - /llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Message-ID: <20101206215307.5C5DD2A6C12C@llvm.org> Author: lattner Date: Mon Dec 6 15:53:07 2010 New Revision: 121042 URL: http://llvm.org/viewvc/llvm-project?rev=121042&view=rev Log: replace a linear scan with a symtab lookup, reduce indentation. No functionality change. Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=121042&r1=121041&r2=121042&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Mon Dec 6 15:53:07 2010 @@ -1930,47 +1930,47 @@ /// FindGlobalCtors - Find the llvm.globalctors list, verifying that all /// initializers have an init priority of 65535. GlobalVariable *GlobalOpt::FindGlobalCtors(Module &M) { - for (Module::global_iterator I = M.global_begin(), E = M.global_end(); - I != E; ++I) - if (I->getName() == "llvm.global_ctors") { - // Found it, verify it's an array of { int, void()* }. - const ArrayType *ATy =dyn_cast(I->getType()->getElementType()); - if (!ATy) return 0; - const StructType *STy = dyn_cast(ATy->getElementType()); - if (!STy || STy->getNumElements() != 2 || - !STy->getElementType(0)->isIntegerTy(32)) return 0; - const PointerType *PFTy = dyn_cast(STy->getElementType(1)); - if (!PFTy) return 0; - const FunctionType *FTy = dyn_cast(PFTy->getElementType()); - if (!FTy || !FTy->getReturnType()->isVoidTy() || - FTy->isVarArg() || FTy->getNumParams() != 0) - return 0; - - // Verify that the initializer is simple enough for us to handle. We are - // only allowed to optimize the initializer if it is unique. - if (!I->hasUniqueInitializer()) return 0; - ConstantArray *CA = dyn_cast(I->getInitializer()); - if (!CA) return 0; - for (User::op_iterator i = CA->op_begin(), e = CA->op_end(); i != e; ++i) - if (ConstantStruct *CS = dyn_cast(*i)) { - if (isa(CS->getOperand(1))) - continue; - - // Must have a function or null ptr. - if (!isa(CS->getOperand(1))) - return 0; - - // Init priority must be standard. - ConstantInt *CI = dyn_cast(CS->getOperand(0)); - if (!CI || CI->getZExtValue() != 65535) - return 0; - } else { - return 0; - } + GlobalVariable *GV = M.getGlobalVariable("llvm.global_ctors"); + if (GV == 0) return 0; + + // Found it, verify it's an array of { int, void()* }. + const ArrayType *ATy =dyn_cast(GV->getType()->getElementType()); + if (!ATy) return 0; + const StructType *STy = dyn_cast(ATy->getElementType()); + if (!STy || STy->getNumElements() != 2 || + !STy->getElementType(0)->isIntegerTy(32)) return 0; + const PointerType *PFTy = dyn_cast(STy->getElementType(1)); + if (!PFTy) return 0; + const FunctionType *FTy = dyn_cast(PFTy->getElementType()); + if (!FTy || !FTy->getReturnType()->isVoidTy() || + FTy->isVarArg() || FTy->getNumParams() != 0) + return 0; - return I; - } - return 0; + // Verify that the initializer is simple enough for us to handle. We are + // only allowed to optimize the initializer if it is unique. + if (!GV->hasUniqueInitializer()) return 0; + + ConstantArray *CA = dyn_cast(GV->getInitializer()); + if (!CA) return 0; + + for (User::op_iterator i = CA->op_begin(), e = CA->op_end(); i != e; ++i) { + ConstantStruct *CS = dyn_cast(*i); + if (CS == 0) return 0; + + if (isa(CS->getOperand(1))) + continue; + + // Must have a function or null ptr. + if (!isa(CS->getOperand(1))) + return 0; + + // Init priority must be standard. + ConstantInt *CI = dyn_cast(CS->getOperand(0)); + if (!CI || CI->getZExtValue() != 65535) + return 0; + } + + return GV; } /// ParseGlobalCtors - Given a llvm.global_ctors list that we can understand, From bigcheesegs at gmail.com Mon Dec 6 15:59:43 2010 From: bigcheesegs at gmail.com (Michael Spencer) Date: Mon, 6 Dec 2010 16:59:43 -0500 Subject: [llvm-commits] [llvm] r120984 - in /llvm/trunk/include/llvm/ADT: SmallString.h SmallVector.h In-Reply-To: <877E861D-22F1-4782-B20A-292652EE60CC@apple.com> References: <20101206042742.3E11F2A6C12C@llvm.org> <9472EFC6-4AC9-4A0B-A7FF-1CEB4D7E3A52@apple.com> <877E861D-22F1-4782-B20A-292652EE60CC@apple.com> Message-ID: On Mon, Dec 6, 2010 at 4:03 PM, Chris Lattner wrote: > > On Dec 5, 2010, at 9:44 PM, Michael Spencer wrote: > >>> I don't think this makes sense, why not just cast data? ?With wchar_t you usually need a multibyte 0 anyway. >>> >>> -Chris >> >> c_str() as implemented uses push_back to add the 0, thus we get a >> sizeof(wchar_t) byte null terminator. The reason this is needed is >> because I kept running into bugs trying to keep track of when I needed >> to add a null terminator. This way I can use c_str() exactly when >> passing the string to a Windows API function. > > Oh right, but why add this to SmallVector? ?It doesn't seem to make sense there. ?If there are weird clients that want this in the system library, can't they either take a smallstring, or just do push_back(0) + pop_back() manually? > > -Chris They can't take a small string because that requires specifying the size, or templating on the size. And SmallString is char only. Doing push/pop manually is what I was doing before. The problem is that it ends up littered all throughout the function before every system API call. The major difference is that the null termination is explicit and obvious in the function call when using .c_str(). If this is undesired, I'm also happy with adding a free-standing template typename SmallVectorImpl::SuperClass::const_pointer c_str(SmallVectorImpl &) function someplace and using that. - Michael Spencer From jason.w.kim.2009 at gmail.com Mon Dec 6 15:57:34 2010 From: jason.w.kim.2009 at gmail.com (Jason W Kim) Date: Mon, 06 Dec 2010 21:57:34 -0000 Subject: [llvm-commits] [llvm] r121043 - /llvm/trunk/lib/MC/ELFObjectWriter.cpp Message-ID: <20101206215734.96AA22A6C12C@llvm.org> Author: jasonwkim Date: Mon Dec 6 15:57:34 2010 New Revision: 121043 URL: http://llvm.org/viewvc/llvm-project?rev=121043&view=rev Log: Refactor ELFObjectWriter. + ARM/X86/MBlaze now share a common RecordRelocation + ARM/X86/MBlaze arch specific routines are limited to GetRelocType() Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=121043&r1=121042&r2=121043&view=diff ============================================================================== --- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Mon Dec 6 15:57:34 2010 @@ -286,10 +286,8 @@ const SectionIndexMapTy &SectionIndexMap); virtual void RecordRelocation(const MCAssembler &Asm, const MCAsmLayout &Layout, - const MCFragment *Fragment, const MCFixup &Fixup, - MCValue Target, uint64_t &FixedValue) { - assert(0 && "RecordRelocation is not specific enough"); - } + const MCFragment *Fragment, const MCFixup &Fixup, + MCValue Target, uint64_t &FixedValue); virtual uint64_t getSymbolIndexInSymbolTable(const MCAssembler &Asm, const MCSymbol *S); @@ -348,6 +346,13 @@ uint32_t GroupSymbolIndex, uint64_t Offset, uint64_t Size, uint64_t Alignment, const MCSectionELF &Section); + + protected: + virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup, + bool IsPCRel, bool IsRelocWithSymbol, + int64_t Addend) = 0; + + virtual bool isFixupKindPCRel(unsigned Kind) const = 0; }; //===- X86ELFObjectWriter -------------------------------------------===// @@ -359,14 +364,12 @@ Triple::OSType _OSType); virtual ~X86ELFObjectWriter(); - virtual void RecordRelocation(const MCAssembler &Asm, - const MCAsmLayout &Layout, - const MCFragment *Fragment, - const MCFixup &Fixup, MCValue Target, - uint64_t &FixedValue); + protected: + virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup, + bool IsPCRel, bool IsRelocWithSymbol, + int64_t Addend); - private: - static bool isFixupKindPCRel(unsigned Kind) { + virtual bool isFixupKindPCRel(unsigned Kind) const { switch (Kind) { default: return false; @@ -390,18 +393,11 @@ Triple::OSType _OSType); virtual ~ARMELFObjectWriter(); - virtual void RecordRelocation(const MCAssembler &Asm, - const MCAsmLayout &Layout, - const MCFragment *Fragment, - const MCFixup &Fixup, MCValue Target, - uint64_t &FixedValue); - protected: - // Fixme: pull up to ELFObjectWriter - unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup, - bool IsPCRel); - private: - static bool isFixupKindPCRel(unsigned Kind) { + virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup, + bool IsPCRel, bool IsRelocWithSymbol, + int64_t Addend); + virtual bool isFixupKindPCRel(unsigned Kind) const { switch (Kind) { default: return false; @@ -425,14 +421,12 @@ Triple::OSType _OSType); virtual ~MBlazeELFObjectWriter(); - virtual void RecordRelocation(const MCAssembler &Asm, - const MCAsmLayout &Layout, - const MCFragment *Fragment, - const MCFixup &Fixup, MCValue Target, - uint64_t &FixedValue); + protected: + virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup, + bool IsPCRel, bool IsRelocWithSymbol, + int64_t Addend); - private: - static bool isFixupKindPCRel(unsigned Kind) { + virtual bool isFixupKindPCRel(unsigned Kind) const { switch (Kind) { default: return false; @@ -761,6 +755,70 @@ } +void ELFObjectWriter::RecordRelocation(const MCAssembler &Asm, + const MCAsmLayout &Layout, + const MCFragment *Fragment, + const MCFixup &Fixup, + MCValue Target, + uint64_t &FixedValue) { + int64_t Addend = 0; + int Index = 0; + int64_t Value = Target.getConstant(); + const MCSymbol *RelocSymbol = NULL; + + bool IsPCRel = isFixupKindPCRel(Fixup.getKind()); + if (!Target.isAbsolute()) { + const MCSymbol &Symbol = Target.getSymA()->getSymbol(); + const MCSymbol &ASymbol = Symbol.AliasedSymbol(); + RelocSymbol = SymbolToReloc(Asm, Target, *Fragment); + + if (const MCSymbolRefExpr *RefB = Target.getSymB()) { + const MCSymbol &SymbolB = RefB->getSymbol(); + MCSymbolData &SDB = Asm.getSymbolData(SymbolB); + IsPCRel = true; + + // Offset of the symbol in the section + int64_t a = Layout.getSymbolOffset(&SDB); + + // Ofeset of the relocation in the section + int64_t b = Layout.getFragmentOffset(Fragment) + Fixup.getOffset(); + Value += b - a; + } + + if (!RelocSymbol) { + MCSymbolData &SD = Asm.getSymbolData(ASymbol); + MCFragment *F = SD.getFragment(); + + Index = F->getParent()->getOrdinal() + 1; + + // Offset of the symbol in the section + Value += Layout.getSymbolOffset(&SD); + } else { + if (Asm.getSymbolData(Symbol).getFlags() & ELF_Other_Weakref) + WeakrefUsedInReloc.insert(RelocSymbol); + else + UsedInReloc.insert(RelocSymbol); + Index = -1; + } + Addend = Value; + // Compensate for the addend on i386. + if (Is64Bit) + Value = 0; + } + + FixedValue = Value; + unsigned Type = GetRelocType(Target, Fixup, IsPCRel, + (RelocSymbol != 0), Addend); + + uint64_t RelocOffset = Layout.getFragmentOffset(Fragment) + + Fixup.getOffset(); + + if (!HasRelocationAddend) Addend = 0; + ELFRelocationEntry ERE(RelocOffset, Index, Type, RelocSymbol, Addend); + Relocations[Fragment->getParent()].push_back(ERE); +} + + uint64_t ELFObjectWriter::getSymbolIndexInSymbolTable(const MCAssembler &Asm, const MCSymbol *S) { @@ -1467,7 +1525,9 @@ unsigned ARMELFObjectWriter::GetRelocType(const MCValue &Target, const MCFixup &Fixup, - bool IsPCRel) { + bool IsPCRel, + bool IsRelocWithSymbol, + int64_t Addend) { MCSymbolRefExpr::VariantKind Modifier = Target.isAbsolute() ? MCSymbolRefExpr::VK_None : Target.getSymA()->getKind(); @@ -1501,70 +1561,6 @@ return -1; } -void ARMELFObjectWriter::RecordRelocation(const MCAssembler &Asm, - const MCAsmLayout &Layout, - const MCFragment *Fragment, - const MCFixup &Fixup, - MCValue Target, - uint64_t &FixedValue) { - int64_t Addend = 0; - int Index = 0; - int64_t Value = Target.getConstant(); - const MCSymbol *RelocSymbol = NULL; - - bool IsPCRel = isFixupKindPCRel(Fixup.getKind()); - if (!Target.isAbsolute()) { - const MCSymbol &Symbol = Target.getSymA()->getSymbol(); - const MCSymbol &ASymbol = Symbol.AliasedSymbol(); - RelocSymbol = SymbolToReloc(Asm, Target, *Fragment); - - if (const MCSymbolRefExpr *RefB = Target.getSymB()) { - const MCSymbol &SymbolB = RefB->getSymbol(); - MCSymbolData &SDB = Asm.getSymbolData(SymbolB); - IsPCRel = true; - - // Offset of the symbol in the section - int64_t a = Layout.getSymbolOffset(&SDB); - - // Ofeset of the relocation in the section - int64_t b = Layout.getFragmentOffset(Fragment) + Fixup.getOffset(); - Value += b - a; - } - - if (!RelocSymbol) { - MCSymbolData &SD = Asm.getSymbolData(ASymbol); - MCFragment *F = SD.getFragment(); - - Index = F->getParent()->getOrdinal() + 1; - - // Offset of the symbol in the section - Value += Layout.getSymbolOffset(&SD); - } else { - if (Asm.getSymbolData(Symbol).getFlags() & ELF_Other_Weakref) - WeakrefUsedInReloc.insert(RelocSymbol); - else - UsedInReloc.insert(RelocSymbol); - Index = -1; - } - Addend = Value; - // Compensate for the addend on i386. - if (Is64Bit) - Value = 0; - } - - FixedValue = Value; - - // determine the type of the relocation - unsigned Type = GetRelocType(Target, Fixup, IsPCRel); - - uint64_t RelocOffset = Layout.getFragmentOffset(Fragment) + - Fixup.getOffset(); - - if (!HasRelocationAddend) Addend = 0; - ELFRelocationEntry ERE(RelocOffset, Index, Type, RelocSymbol, Addend); - Relocations[Fragment->getParent()].push_back(ERE); -} - //===- MBlazeELFObjectWriter -------------------------------------------===// MBlazeELFObjectWriter::MBlazeELFObjectWriter(raw_ostream &_OS, bool _Is64Bit, @@ -1579,54 +1575,11 @@ MBlazeELFObjectWriter::~MBlazeELFObjectWriter() { } -void MBlazeELFObjectWriter::RecordRelocation(const MCAssembler &Asm, - const MCAsmLayout &Layout, - const MCFragment *Fragment, +unsigned MBlazeELFObjectWriter::GetRelocType(const MCValue &Target, const MCFixup &Fixup, - MCValue Target, - uint64_t &FixedValue) { - int64_t Addend = 0; - int Index = 0; - int64_t Value = Target.getConstant(); - const MCSymbol &Symbol = Target.getSymA()->getSymbol(); - const MCSymbol &ASymbol = Symbol.AliasedSymbol(); - const MCSymbol *RelocSymbol = SymbolToReloc(Asm, Target, *Fragment); - - bool IsPCRel = isFixupKindPCRel(Fixup.getKind()); - if (!Target.isAbsolute()) { - if (const MCSymbolRefExpr *RefB = Target.getSymB()) { - const MCSymbol &SymbolB = RefB->getSymbol(); - MCSymbolData &SDB = Asm.getSymbolData(SymbolB); - IsPCRel = true; - - // Offset of the symbol in the section - int64_t a = Layout.getSymbolOffset(&SDB); - - // Ofeset of the relocation in the section - int64_t b = Layout.getFragmentOffset(Fragment) + Fixup.getOffset(); - Value += b - a; - } - - if (!RelocSymbol) { - MCSymbolData &SD = Asm.getSymbolData(ASymbol); - MCFragment *F = SD.getFragment(); - - Index = F->getParent()->getOrdinal(); - - // Offset of the symbol in the section - Value += Layout.getSymbolOffset(&SD); - } else { - if (Asm.getSymbolData(Symbol).getFlags() & ELF_Other_Weakref) - WeakrefUsedInReloc.insert(RelocSymbol); - else - UsedInReloc.insert(RelocSymbol); - Index = -1; - } - Addend = Value; - } - - FixedValue = Value; - + bool IsPCRel, + bool IsRelocWithSymbol, + int64_t Addend) { // determine the type of the relocation unsigned Type; if (IsPCRel) { @@ -1644,25 +1597,16 @@ switch ((unsigned)Fixup.getKind()) { default: llvm_unreachable("invalid fixup kind!"); case FK_Data_4: - Type = (RelocSymbol || Addend !=0) ? ELF::R_MICROBLAZE_32 - : ELF::R_MICROBLAZE_64; + Type = ((IsRelocWithSymbol || Addend !=0) + ? ELF::R_MICROBLAZE_32 + : ELF::R_MICROBLAZE_64); break; case FK_Data_2: Type = ELF::R_MICROBLAZE_32; break; } } - - MCSymbolRefExpr::VariantKind Modifier = Target.getSymA()->getKind(); - if (RelocNeedsGOT(Modifier)) - NeedsGOT = true; - - uint64_t RelocOffset = Layout.getFragmentOffset(Fragment) + - Fixup.getOffset(); - - if (!HasRelocationAddend) Addend = 0; - ELFRelocationEntry ERE(RelocOffset, Index, Type, RelocSymbol, Addend); - Relocations[Fragment->getParent()].push_back(ERE); + return Type; } //===- X86ELFObjectWriter -------------------------------------------===// @@ -1679,59 +1623,11 @@ X86ELFObjectWriter::~X86ELFObjectWriter() {} -void X86ELFObjectWriter::RecordRelocation(const MCAssembler &Asm, - const MCAsmLayout &Layout, - const MCFragment *Fragment, - const MCFixup &Fixup, - MCValue Target, - uint64_t &FixedValue) { - int64_t Addend = 0; - int Index = 0; - int64_t Value = Target.getConstant(); - const MCSymbol *RelocSymbol = NULL; - - bool IsPCRel = isFixupKindPCRel(Fixup.getKind()); - if (!Target.isAbsolute()) { - const MCSymbol &Symbol = Target.getSymA()->getSymbol(); - const MCSymbol &ASymbol = Symbol.AliasedSymbol(); - RelocSymbol = SymbolToReloc(Asm, Target, *Fragment); - - if (const MCSymbolRefExpr *RefB = Target.getSymB()) { - const MCSymbol &SymbolB = RefB->getSymbol(); - MCSymbolData &SDB = Asm.getSymbolData(SymbolB); - IsPCRel = true; - - // Offset of the symbol in the section - int64_t a = Layout.getSymbolOffset(&SDB); - - // Ofeset of the relocation in the section - int64_t b = Layout.getFragmentOffset(Fragment) + Fixup.getOffset(); - Value += b - a; - } - - if (!RelocSymbol) { - MCSymbolData &SD = Asm.getSymbolData(ASymbol); - MCFragment *F = SD.getFragment(); - - Index = F->getParent()->getOrdinal() + 1; - - // Offset of the symbol in the section - Value += Layout.getSymbolOffset(&SD); - } else { - if (Asm.getSymbolData(Symbol).getFlags() & ELF_Other_Weakref) - WeakrefUsedInReloc.insert(RelocSymbol); - else - UsedInReloc.insert(RelocSymbol); - Index = -1; - } - Addend = Value; - // Compensate for the addend on i386. - if (Is64Bit) - Value = 0; - } - - FixedValue = Value; - +unsigned X86ELFObjectWriter::GetRelocType(const MCValue &Target, + const MCFixup &Fixup, + bool IsPCRel, + bool IsRelocWithSymbol, + int64_t Addend) { // determine the type of the relocation MCSymbolRefExpr::VariantKind Modifier = Target.isAbsolute() ? @@ -1866,11 +1762,5 @@ if (RelocNeedsGOT(Modifier)) NeedsGOT = true; - - uint64_t RelocOffset = Layout.getFragmentOffset(Fragment) + - Fixup.getOffset(); - - if (!HasRelocationAddend) Addend = 0; - ELFRelocationEntry ERE(RelocOffset, Index, Type, RelocSymbol, Addend); - Relocations[Fragment->getParent()].push_back(ERE); + return Type; } From peckw at wesleypeck.com Mon Dec 6 16:06:49 2010 From: peckw at wesleypeck.com (Wesley Peck) Date: Mon, 06 Dec 2010 22:06:49 -0000 Subject: [llvm-commits] [llvm] r121044 - in /llvm/trunk: lib/Target/MBlaze/MBlazeInstrInfo.td test/CodeGen/MBlaze/brind.ll test/CodeGen/MBlaze/jumptable.ll Message-ID: <20101206220649.C36772A6C12C@llvm.org> Author: peckw Date: Mon Dec 6 16:06:49 2010 New Revision: 121044 URL: http://llvm.org/viewvc/llvm-project?rev=121044&view=rev Log: Fixed reversed operands for IDIV and CMP instructions in MBlaze backend. Use BRAD instead of BRD for indirect branches in MBlaze backend. patch contributed by Jack Whitham! Modified: llvm/trunk/lib/Target/MBlaze/MBlazeInstrInfo.td llvm/trunk/test/CodeGen/MBlaze/brind.ll llvm/trunk/test/CodeGen/MBlaze/jumptable.ll Modified: llvm/trunk/lib/Target/MBlaze/MBlazeInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/MBlazeInstrInfo.td?rev=121044&r1=121043&r2=121044&view=diff ============================================================================== --- llvm/trunk/lib/Target/MBlaze/MBlazeInstrInfo.td (original) +++ llvm/trunk/lib/Target/MBlaze/MBlazeInstrInfo.td Mon Dec 6 16:06:49 2010 @@ -372,8 +372,8 @@ } let Predicates=[HasDiv] in { - def IDIV : Arith<0x12, 0x000, "idiv ", sdiv, IIAlu>; - def IDIVU : Arith<0x12, 0x002, "idivu ", udiv, IIAlu>; + def IDIV : ArithR<0x12, 0x000, "idiv ", sdiv, IIAlu>; + def IDIVU : ArithR<0x12, 0x002, "idivu ", udiv, IIAlu>; } //===----------------------------------------------------------------------===// @@ -554,7 +554,7 @@ let usesCustomInserter = 1 in { def Select_CC : MBlazePseudo<(outs GPR:$dst), - (ins GPR:$T, GPR:$F, GPR:$CMP, i32imm:$CC), + (ins GPR:$T, GPR:$F, GPR:$CMP, i32imm:$CC), // F T reversed "; SELECT_CC PSEUDO!", []>; @@ -660,34 +660,34 @@ // SET_CC operations def : Pat<(setcc (i32 GPR:$L), (i32 GPR:$R), SETEQ), (Select_CC (ADDI (i32 R0), 1), (ADDI (i32 R0), 0), - (CMP GPR:$L, GPR:$R), 1)>; + (CMP GPR:$R, GPR:$L), 1)>; def : Pat<(setcc (i32 GPR:$L), (i32 GPR:$R), SETNE), (Select_CC (ADDI (i32 R0), 1), (ADDI (i32 R0), 0), - (CMP GPR:$L, GPR:$R), 2)>; + (CMP GPR:$R, GPR:$L), 2)>; def : Pat<(setcc (i32 GPR:$L), (i32 GPR:$R), SETGT), (Select_CC (ADDI (i32 R0), 1), (ADDI (i32 R0), 0), - (CMP GPR:$L, GPR:$R), 3)>; + (CMP GPR:$R, GPR:$L), 3)>; def : Pat<(setcc (i32 GPR:$L), (i32 GPR:$R), SETLT), (Select_CC (ADDI (i32 R0), 1), (ADDI (i32 R0), 0), - (CMP GPR:$L, GPR:$R), 4)>; + (CMP GPR:$R, GPR:$L), 4)>; def : Pat<(setcc (i32 GPR:$L), (i32 GPR:$R), SETGE), (Select_CC (ADDI (i32 R0), 1), (ADDI (i32 R0), 0), - (CMP GPR:$L, GPR:$R), 5)>; + (CMP GPR:$R, GPR:$L), 5)>; def : Pat<(setcc (i32 GPR:$L), (i32 GPR:$R), SETLE), (Select_CC (ADDI (i32 R0), 1), (ADDI (i32 R0), 0), - (CMP GPR:$L, GPR:$R), 6)>; + (CMP GPR:$R, GPR:$L), 6)>; def : Pat<(setcc (i32 GPR:$L), (i32 GPR:$R), SETUGT), (Select_CC (ADDI (i32 R0), 1), (ADDI (i32 R0), 0), - (CMPU GPR:$L, GPR:$R), 3)>; + (CMPU GPR:$R, GPR:$L), 3)>; def : Pat<(setcc (i32 GPR:$L), (i32 GPR:$R), SETULT), (Select_CC (ADDI (i32 R0), 1), (ADDI (i32 R0), 0), - (CMPU GPR:$L, GPR:$R), 4)>; + (CMPU GPR:$R, GPR:$L), 4)>; def : Pat<(setcc (i32 GPR:$L), (i32 GPR:$R), SETUGE), (Select_CC (ADDI (i32 R0), 1), (ADDI (i32 R0), 0), - (CMPU GPR:$L, GPR:$R), 5)>; + (CMPU GPR:$R, GPR:$L), 5)>; def : Pat<(setcc (i32 GPR:$L), (i32 GPR:$R), SETULE), (Select_CC (ADDI (i32 R0), 1), (ADDI (i32 R0), 0), - (CMPU GPR:$L, GPR:$R), 6)>; + (CMPU GPR:$R, GPR:$L), 6)>; // SELECT operations def : Pat<(select (i32 GPR:$C), (i32 GPR:$T), (i32 GPR:$F)), @@ -696,41 +696,41 @@ // SELECT_CC def : Pat<(selectcc (i32 GPR:$L), (i32 GPR:$R), (i32 GPR:$T), (i32 GPR:$F), SETEQ), - (Select_CC GPR:$T, GPR:$F, (CMP GPR:$L, GPR:$R), 1)>; + (Select_CC GPR:$T, GPR:$F, (CMP GPR:$R, GPR:$L), 1)>; def : Pat<(selectcc (i32 GPR:$L), (i32 GPR:$R), (i32 GPR:$T), (i32 GPR:$F), SETNE), - (Select_CC GPR:$T, GPR:$F, (CMP GPR:$L, GPR:$R), 2)>; + (Select_CC GPR:$T, GPR:$F, (CMP GPR:$R, GPR:$L), 2)>; def : Pat<(selectcc (i32 GPR:$L), (i32 GPR:$R), (i32 GPR:$T), (i32 GPR:$F), SETGT), - (Select_CC GPR:$T, GPR:$F, (CMP GPR:$L, GPR:$R), 3)>; + (Select_CC GPR:$T, GPR:$F, (CMP GPR:$R, GPR:$L), 3)>; def : Pat<(selectcc (i32 GPR:$L), (i32 GPR:$R), (i32 GPR:$T), (i32 GPR:$F), SETLT), - (Select_CC GPR:$T, GPR:$F, (CMP GPR:$L, GPR:$R), 4)>; + (Select_CC GPR:$T, GPR:$F, (CMP GPR:$R, GPR:$L), 4)>; def : Pat<(selectcc (i32 GPR:$L), (i32 GPR:$R), (i32 GPR:$T), (i32 GPR:$F), SETGE), - (Select_CC GPR:$T, GPR:$F, (CMP GPR:$L, GPR:$R), 5)>; + (Select_CC GPR:$T, GPR:$F, (CMP GPR:$R, GPR:$L), 5)>; def : Pat<(selectcc (i32 GPR:$L), (i32 GPR:$R), (i32 GPR:$T), (i32 GPR:$F), SETLE), - (Select_CC GPR:$T, GPR:$F, (CMP GPR:$L, GPR:$R), 6)>; + (Select_CC GPR:$T, GPR:$F, (CMP GPR:$R, GPR:$L), 6)>; def : Pat<(selectcc (i32 GPR:$L), (i32 GPR:$R), (i32 GPR:$T), (i32 GPR:$F), SETUGT), - (Select_CC GPR:$T, GPR:$F, (CMPU GPR:$L, GPR:$R), 3)>; + (Select_CC GPR:$T, GPR:$F, (CMPU GPR:$R, GPR:$L), 3)>; def : Pat<(selectcc (i32 GPR:$L), (i32 GPR:$R), (i32 GPR:$T), (i32 GPR:$F), SETULT), - (Select_CC GPR:$T, GPR:$F, (CMPU GPR:$L, GPR:$R), 4)>; + (Select_CC GPR:$T, GPR:$F, (CMPU GPR:$R, GPR:$L), 4)>; def : Pat<(selectcc (i32 GPR:$L), (i32 GPR:$R), (i32 GPR:$T), (i32 GPR:$F), SETUGE), - (Select_CC GPR:$T, GPR:$F, (CMPU GPR:$L, GPR:$R), 5)>; + (Select_CC GPR:$T, GPR:$F, (CMPU GPR:$R, GPR:$L), 5)>; def : Pat<(selectcc (i32 GPR:$L), (i32 GPR:$R), (i32 GPR:$T), (i32 GPR:$F), SETULE), - (Select_CC GPR:$T, GPR:$F, (CMPU GPR:$L, GPR:$R), 6)>; + (Select_CC GPR:$T, GPR:$F, (CMPU GPR:$R, GPR:$L), 6)>; // Ret instructions def : Pat<(MBlazeRet GPR:$target), (RTSD GPR:$target, 0x8)>; // BR instructions def : Pat<(br bb:$T), (BRID bb:$T)>; -def : Pat<(brind GPR:$T), (BRD GPR:$T)>; +def : Pat<(brind GPR:$T), (BRAD GPR:$T)>; // BRCOND instructions def : Pat<(brcond (setcc (i32 GPR:$L), (i32 GPR:$R), SETEQ), bb:$T), Modified: llvm/trunk/test/CodeGen/MBlaze/brind.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MBlaze/brind.ll?rev=121044&r1=121043&r2=121044&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MBlaze/brind.ll (original) +++ llvm/trunk/test/CodeGen/MBlaze/brind.ll Mon Dec 6 16:06:49 2010 @@ -28,7 +28,7 @@ label %L3, label %L4, label %L5 ] - ; CHECK: brd {{r[0-9]*}} + ; CHECK: brad {{r[0-9]*}} L1: %tmp.1 = add i32 %a, %b @@ -68,5 +68,5 @@ %tmp.8 = urem i32 %tmp.7, 5 br label %loop - ; CHECK: brd + ; CHECK: brad {{r[0-9]*}} } Modified: llvm/trunk/test/CodeGen/MBlaze/jumptable.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MBlaze/jumptable.ll?rev=121044&r1=121043&r2=121044&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MBlaze/jumptable.ll (original) +++ llvm/trunk/test/CodeGen/MBlaze/jumptable.ll Mon Dec 6 16:06:49 2010 @@ -18,8 +18,8 @@ i32 8, label %L8 i32 9, label %L9 ] - ; CHECK: lw [[REG:r[0-9]*]] - ; CHECK: brd [[REG]] + ; CHECK: lw [[REG:r[0-9]*]] + ; CHECK: brad [[REG]] L0: %var0 = add i32 %arg, 0 br label %DONE From peckw at wesleypeck.com Mon Dec 6 16:19:28 2010 From: peckw at wesleypeck.com (Wesley Peck) Date: Mon, 06 Dec 2010 22:19:28 -0000 Subject: [llvm-commits] [llvm] r121049 - /llvm/trunk/lib/Target/MBlaze/MBlazeISelLowering.cpp Message-ID: <20101206221928.D598F2A6C12C@llvm.org> Author: peckw Date: Mon Dec 6 16:19:28 2010 New Revision: 121049 URL: http://llvm.org/viewvc/llvm-project?rev=121049&view=rev Log: Adding bug fix that was suppose to be part of 121044. patch contributed by Jack Whitham! Modified: llvm/trunk/lib/Target/MBlaze/MBlazeISelLowering.cpp Modified: llvm/trunk/lib/Target/MBlaze/MBlazeISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/MBlazeISelLowering.cpp?rev=121049&r1=121048&r2=121049&view=diff ============================================================================== --- llvm/trunk/lib/Target/MBlaze/MBlazeISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MBlaze/MBlazeISelLowering.cpp Mon Dec 6 16:19:28 2010 @@ -333,12 +333,12 @@ unsigned Opc; switch (MI->getOperand(4).getImm()) { default: llvm_unreachable("Unknown branch condition"); - case MBlazeCC::EQ: Opc = MBlaze::BNEID; break; - case MBlazeCC::NE: Opc = MBlaze::BEQID; break; - case MBlazeCC::GT: Opc = MBlaze::BLEID; break; - case MBlazeCC::LT: Opc = MBlaze::BGEID; break; - case MBlazeCC::GE: Opc = MBlaze::BLTID; break; - case MBlazeCC::LE: Opc = MBlaze::BGTID; break; + case MBlazeCC::EQ: Opc = MBlaze::BEQID; break; + case MBlazeCC::NE: Opc = MBlaze::BNEID; break; + case MBlazeCC::GT: Opc = MBlaze::BGTID; break; + case MBlazeCC::LT: Opc = MBlaze::BLTID; break; + case MBlazeCC::GE: Opc = MBlaze::BGEID; break; + case MBlazeCC::LE: Opc = MBlaze::BLEID; break; } F->insert(It, flsBB); From rafael.espindola at gmail.com Mon Dec 6 16:30:54 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Mon, 06 Dec 2010 22:30:54 -0000 Subject: [llvm-commits] [llvm] r121050 - in /llvm/trunk: include/llvm/MC/MCExpr.h lib/MC/MCAssembler.cpp lib/MC/MCExpr.cpp lib/MC/MCObjectStreamer.cpp Message-ID: <20101206223054.50A572A6C12C@llvm.org> Author: rafael Date: Mon Dec 6 16:30:54 2010 New Revision: 121050 URL: http://llvm.org/viewvc/llvm-project?rev=121050&view=rev Log: Use references to simplify the code a bit. Modified: llvm/trunk/include/llvm/MC/MCExpr.h llvm/trunk/lib/MC/MCAssembler.cpp llvm/trunk/lib/MC/MCExpr.cpp llvm/trunk/lib/MC/MCObjectStreamer.cpp Modified: llvm/trunk/include/llvm/MC/MCExpr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCExpr.h?rev=121050&r1=121049&r2=121050&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCExpr.h (original) +++ llvm/trunk/include/llvm/MC/MCExpr.h Mon Dec 6 16:30:54 2010 @@ -41,6 +41,8 @@ MCExpr(const MCExpr&); // DO NOT IMPLEMENT void operator=(const MCExpr&); // DO NOT IMPLEMENT + bool EvaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm, + const MCAsmLayout *Layout) const; protected: explicit MCExpr(ExprKind _Kind) : Kind(_Kind) {} @@ -72,10 +74,8 @@ /// evaluated. /// @result - True on success. bool EvaluateAsAbsolute(int64_t &Res) const; - bool EvaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm) const; - bool EvaluateAsAbsolute(int64_t &Res, const MCAsmLayout *Layout) const; - bool EvaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm, - const MCAsmLayout *Layout) const; + bool EvaluateAsAbsolute(int64_t &Res, const MCAssembler &Asm) const; + bool EvaluateAsAbsolute(int64_t &Res, const MCAsmLayout &Layout) const; /// EvaluateAsRelocatable - Try to evaluate the expression to a relocatable /// value, i.e. an expression of the fixed form (a - b + constant). Modified: llvm/trunk/lib/MC/MCAssembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=121050&r1=121049&r2=121050&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAssembler.cpp (original) +++ llvm/trunk/lib/MC/MCAssembler.cpp Mon Dec 6 16:30:54 2010 @@ -780,7 +780,7 @@ MCAsmLayout &Layout, MCOrgFragment &OF) { int64_t TargetLocation; - if (!OF.getOffset().EvaluateAsAbsolute(TargetLocation, &Layout)) + if (!OF.getOffset().EvaluateAsAbsolute(TargetLocation, Layout)) report_fatal_error("expected assembly-time absolute expression"); // FIXME: We need a way to communicate this error. @@ -800,7 +800,7 @@ MCLEBFragment &LF) { int64_t Value = 0; uint64_t OldSize = LF.getContents().size(); - LF.getValue().EvaluateAsAbsolute(Value, &Layout); + LF.getValue().EvaluateAsAbsolute(Value, Layout); SmallString<8> &Data = LF.getContents(); Data.clear(); raw_svector_ostream OSE(Data); @@ -817,7 +817,7 @@ MCDwarfLineAddrFragment &DF) { int64_t AddrDelta = 0; uint64_t OldSize = DF.getContents().size(); - DF.getAddrDelta().EvaluateAsAbsolute(AddrDelta, &Layout); + DF.getAddrDelta().EvaluateAsAbsolute(AddrDelta, Layout); int64_t LineDelta; LineDelta = DF.getLineDelta(); SmallString<8> &Data = DF.getContents(); Modified: llvm/trunk/lib/MC/MCExpr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=121050&r1=121049&r2=121050&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCExpr.cpp (original) +++ llvm/trunk/lib/MC/MCExpr.cpp Mon Dec 6 16:30:54 2010 @@ -242,15 +242,12 @@ } bool MCExpr::EvaluateAsAbsolute(int64_t &Res, - const MCAsmLayout *Layout) const { - if (Layout) - return EvaluateAsAbsolute(Res, &Layout->getAssembler(), Layout); - else - return EvaluateAsAbsolute(Res, 0, 0); + const MCAsmLayout &Layout) const { + return EvaluateAsAbsolute(Res, &Layout.getAssembler(), &Layout); } -bool MCExpr::EvaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm) const { - return EvaluateAsAbsolute(Res, Asm, 0); +bool MCExpr::EvaluateAsAbsolute(int64_t &Res, const MCAssembler &Asm) const { + return EvaluateAsAbsolute(Res, &Asm, 0); } bool MCExpr::EvaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm, Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=121050&r1=121049&r2=121050&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Mon Dec 6 16:30:54 2010 @@ -83,7 +83,7 @@ // Avoid fixups when possible. int64_t AbsValue; - if (AddValueSymbols(Value)->EvaluateAsAbsolute(AbsValue, &getAssembler())) { + if (AddValueSymbols(Value)->EvaluateAsAbsolute(AbsValue, getAssembler())) { EmitIntValue(AbsValue, Size, AddrSpace); return; } @@ -114,7 +114,7 @@ void MCObjectStreamer::EmitULEB128Value(const MCExpr *Value, unsigned AddrSpace) { int64_t IntValue; - if (Value->EvaluateAsAbsolute(IntValue, &getAssembler())) { + if (Value->EvaluateAsAbsolute(IntValue, getAssembler())) { EmitULEB128IntValue(IntValue, AddrSpace); return; } @@ -124,7 +124,7 @@ void MCObjectStreamer::EmitSLEB128Value(const MCExpr *Value, unsigned AddrSpace) { int64_t IntValue; - if (Value->EvaluateAsAbsolute(IntValue, &getAssembler())) { + if (Value->EvaluateAsAbsolute(IntValue, getAssembler())) { EmitSLEB128IntValue(IntValue, AddrSpace); return; } @@ -204,7 +204,7 @@ MCBinaryExpr::Create(MCBinaryExpr::Sub, LabelRef, LastLabelRef, getContext()); int64_t Res; - if (AddrDelta->EvaluateAsAbsolute(Res, &getAssembler())) { + if (AddrDelta->EvaluateAsAbsolute(Res, getAssembler())) { MCDwarfLineAddr::Emit(this, LineDelta, Res); return; } From dpatel at apple.com Mon Dec 6 16:39:26 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 06 Dec 2010 22:39:26 -0000 Subject: [llvm-commits] [llvm] r121059 - in /llvm/trunk: lib/CodeGen/SelectionDAG/ test/CodeGen/ARM/ test/CodeGen/Alpha/ test/CodeGen/CellSPU/ test/CodeGen/MBlaze/ test/CodeGen/MSP430/ test/CodeGen/Mips/ test/CodeGen/PowerPC/ test/CodeGen/SPARC/ test/CodeGen/SystemZ/ test/CodeGen/Thumb/ test/CodeGen/X86/ test/CodeGen/XCore/ Message-ID: <20101206223926.E63532A6C12C@llvm.org> Author: dpatel Date: Mon Dec 6 16:39:26 2010 New Revision: 121059 URL: http://llvm.org/viewvc/llvm-project?rev=121059&view=rev Log: If dbg_declare() or dbg_value() is not lowered by isel then emit DEBUG message instead of creating DBG_VALUE for undefined value in reg0. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/trunk/test/CodeGen/ARM/2010-04-07-DbgValueOtherTargets.ll llvm/trunk/test/CodeGen/Alpha/2010-04-07-DbgValueOtherTargets.ll llvm/trunk/test/CodeGen/CellSPU/2010-04-07-DbgValueOtherTargets.ll llvm/trunk/test/CodeGen/MBlaze/2010-04-07-DbgValueOtherTargets.ll llvm/trunk/test/CodeGen/MSP430/2010-04-07-DbgValueOtherTargets.ll llvm/trunk/test/CodeGen/Mips/2010-04-07-DbgValueOtherTargets.ll llvm/trunk/test/CodeGen/PowerPC/2010-04-07-DbgValueOtherTargets.ll llvm/trunk/test/CodeGen/SPARC/2010-04-07-DbgValueOtherTargets.ll llvm/trunk/test/CodeGen/SystemZ/2010-04-07-DbgValueOtherTargets.ll llvm/trunk/test/CodeGen/Thumb/2010-04-07-DbgValueOtherTargets.ll llvm/trunk/test/CodeGen/X86/2010-04-07-DbgValueOtherTargets.ll llvm/trunk/test/CodeGen/XCore/2010-04-07-DbgValueOtherTargets.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=121059&r1=121058&r2=121059&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Mon Dec 6 16:39:26 2010 @@ -55,6 +55,7 @@ #include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/Debug.h" using namespace llvm; /// startNewBlock - Set the current block to which generated machine @@ -517,10 +518,7 @@ } else { // We can't yet handle anything else here because it would require // generating code, thus altering codegen because of debug info. - // Insert an undef so we can see what we dropped. - BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II) - .addReg(0U).addImm(DI->getOffset()) - .addMetadata(DI->getVariable()); + DEBUG(dbgs() << "Dropping debug info for " << DI); } return true; } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=121059&r1=121058&r2=121059&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Mon Dec 6 16:39:26 2010 @@ -908,11 +908,8 @@ Val.getResNo(), Offset, dl, DbgSDNodeOrder); DAG.AddDbgValue(SDV, Val.getNode(), false); } - } else { - SDV = DAG.getDbgValue(Variable, UndefValue::get(V->getType()), - Offset, dl, SDNodeOrder); - DAG.AddDbgValue(SDV, 0, false); - } + } else + DEBUG(dbgs() << "Dropping debug info for " << DI); DanglingDebugInfoMap[V] = DanglingDebugInfo(); } } @@ -4198,10 +4195,7 @@ // Check if address has undef value. if (isa(Address) || (Address->use_empty() && !isa(Address))) { - SDDbgValue*SDV = - DAG.getDbgValue(Variable, UndefValue::get(Address->getType()), - 0, dl, SDNodeOrder); - DAG.AddDbgValue(SDV, 0, false); + DEBUG(dbgs() << "Dropping debug info for " << DI); return 0; } @@ -4224,16 +4218,20 @@ // Byval parameter. We have a frame index at this point. SDV = DAG.getDbgValue(Variable, FINode->getIndex(), 0, dl, SDNodeOrder); - else + else { // Can't do anything with other non-AI cases yet. This might be a // parameter of a callee function that got inlined, for example. + DEBUG(dbgs() << "Dropping debug info for " << DI); return 0; + } } else if (AI) SDV = DAG.getDbgValue(Variable, N.getNode(), N.getResNo(), 0, dl, SDNodeOrder); - else + else { // Can't do anything with other non-AI cases yet. + DEBUG(dbgs() << "Dropping debug info for " << DI); return 0; + } DAG.AddDbgValue(SDV, N.getNode(), isParameter); } else { // If Address is an argument then try to emit its dbg value using @@ -4253,10 +4251,7 @@ } } } - // Otherwise add undef to help track missing debug info. - SDV = DAG.getDbgValue(Variable, UndefValue::get(Address->getType()), - 0, dl, SDNodeOrder); - DAG.AddDbgValue(SDV, 0, false); + DEBUG(dbgs() << "Dropping debug info for " << DI); } } return 0; @@ -4301,10 +4296,8 @@ DanglingDebugInfoMap[V] = DDI; } else { // We may expand this to cover more cases. One case where we have no - // data available is an unreferenced parameter; we need this fallback. - SDV = DAG.getDbgValue(Variable, UndefValue::get(V->getType()), - Offset, dl, SDNodeOrder); - DAG.AddDbgValue(SDV, 0, false); + // data available is an unreferenced parameter. + DEBUG(dbgs() << "Dropping debug info for " << DI); } } Modified: llvm/trunk/test/CodeGen/ARM/2010-04-07-DbgValueOtherTargets.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2010-04-07-DbgValueOtherTargets.ll?rev=121059&r1=121058&r2=121059&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2010-04-07-DbgValueOtherTargets.ll (original) +++ llvm/trunk/test/CodeGen/ARM/2010-04-07-DbgValueOtherTargets.ll Mon Dec 6 16:39:26 2010 @@ -1,33 +1,28 @@ ; RUN: llc -O0 -march=arm -asm-verbose < %s | FileCheck %s ; Check that DEBUG_VALUE comments come through on a variety of targets. -%tart.reflect.ComplexType = type { double, double } - - at .type.SwitchStmtTest = constant %tart.reflect.ComplexType { double 3.0, double 2.0 } - -define i32 @"main(tart.core.String[])->int32"(i32 %args) { +define i32 @main() nounwind ssp { entry: ; CHECK: DEBUG_VALUE - tail call void @llvm.dbg.value(metadata !14, i64 0, metadata !8) - tail call void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType* @.type.SwitchStmtTest) ; <%tart.core.Object*> [#uses=2] - ret i32 3 + call void @llvm.dbg.value(metadata !6, i64 0, metadata !7), !dbg !9 + ret i32 0, !dbg !10 } +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone + declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone -declare void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType*) nounwind readnone -!0 = metadata !{i32 458769, i32 0, i32 1, metadata !"sm.c", metadata !"/Volumes/MacOS9/tests/", metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] -!1 = metadata !{i32 458790, metadata !0, metadata !"", metadata !0, i32 0, i64 192, i64 64, i64 0, i32 0, metadata !2} ; [ DW_TAG_const_type ] -!2 = metadata !{i32 458771, metadata !0, metadata !"C", metadata !0, i32 1, i64 192, i64 64, i64 0, i32 0, null, metadata !3, i32 0, null} ; [ DW_TAG_structure_type ] -!3 = metadata !{metadata !4, metadata !6, metadata !7} -!4 = metadata !{i32 458765, metadata !2, metadata !"x", metadata !0, i32 1, i64 64, i64 64, i64 0, i32 0, metadata !5} ; [ DW_TAG_member ] -!5 = metadata !{i32 458788, metadata !0, metadata !"double", metadata !0, i32 0, i64 64, i64 64, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ] -!6 = metadata !{i32 458765, metadata !2, metadata !"y", metadata !0, i32 1, i64 64, i64 64, i64 64, i32 0, metadata !5} ; [ DW_TAG_member ] -!7 = metadata !{i32 458765, metadata !2, metadata !"z", metadata !0, i32 1, i64 64, i64 64, i64 128, i32 0, metadata !5} ; [ DW_TAG_member ] -!8 = metadata !{i32 459008, metadata !9, metadata !"t", metadata !0, i32 5, metadata !2} ; [ DW_TAG_auto_variable ] -!9 = metadata !{i32 458763, metadata !10} ; [ DW_TAG_lexical_block ] -!10 = metadata !{i32 458798, i32 0, metadata !0, metadata !"foo", metadata !"foo", metadata !"foo", metadata !0, i32 4, metadata !11, i1 false, i1 true, i32 0, i32 0, null} ; [ DW_TAG_subprogram ] -!11 = metadata !{i32 458773, metadata !0, metadata !"", metadata !0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !12, i32 0, null} ; [ DW_TAG_subroutine_type ] -!12 = metadata !{metadata !13} -!13 = metadata !{i32 458788, metadata !0, metadata !"int", metadata !0, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] -!14 = metadata !{%tart.reflect.ComplexType* @.type.SwitchStmtTest} +!llvm.dbg.sp = !{!0} + +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"", metadata !1, i32 2, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false, i32 ()* @main} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 589865, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !2} ; [ DW_TAG_file_type ] +!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !"clang version 2.9 (trunk 120996)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{metadata !5} +!5 = metadata !{i32 589860, metadata !2, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] +!6 = metadata !{i32 0} +!7 = metadata !{i32 590080, metadata !8, metadata !"i", metadata !1, i32 3, metadata !5, i32 0} ; [ DW_TAG_auto_variable ] +!8 = metadata !{i32 589835, metadata !0, i32 2, i32 12, metadata !1, i32 0} ; [ DW_TAG_lexical_block ] +!9 = metadata !{i32 3, i32 11, metadata !8, null} +!10 = metadata !{i32 4, i32 2, metadata !8, null} + Modified: llvm/trunk/test/CodeGen/Alpha/2010-04-07-DbgValueOtherTargets.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Alpha/2010-04-07-DbgValueOtherTargets.ll?rev=121059&r1=121058&r2=121059&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Alpha/2010-04-07-DbgValueOtherTargets.ll (original) +++ llvm/trunk/test/CodeGen/Alpha/2010-04-07-DbgValueOtherTargets.ll Mon Dec 6 16:39:26 2010 @@ -1,33 +1,28 @@ ; RUN: llc -O0 -march=alpha -asm-verbose < %s | FileCheck %s ; Check that DEBUG_VALUE comments come through on a variety of targets. -%tart.reflect.ComplexType = type { double, double } - - at .type.SwitchStmtTest = constant %tart.reflect.ComplexType { double 3.0, double 2.0 } - -define i32 @"main(tart.core.String[])->int32"(i32 %args) { +define i32 @main() nounwind ssp { entry: ; CHECK: DEBUG_VALUE - tail call void @llvm.dbg.value(metadata !14, i64 0, metadata !8) - tail call void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType* @.type.SwitchStmtTest) ; <%tart.core.Object*> [#uses=2] - ret i32 3 + call void @llvm.dbg.value(metadata !6, i64 0, metadata !7), !dbg !9 + ret i32 0, !dbg !10 } +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone + declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone -declare void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType*) nounwind readnone -!0 = metadata !{i32 458769, i32 0, i32 1, metadata !"sm.c", metadata !"/Volumes/MacOS9/tests/", metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] -!1 = metadata !{i32 458790, metadata !0, metadata !"", metadata !0, i32 0, i64 192, i64 64, i64 0, i32 0, metadata !2} ; [ DW_TAG_const_type ] -!2 = metadata !{i32 458771, metadata !0, metadata !"C", metadata !0, i32 1, i64 192, i64 64, i64 0, i32 0, null, metadata !3, i32 0, null} ; [ DW_TAG_structure_type ] -!3 = metadata !{metadata !4, metadata !6, metadata !7} -!4 = metadata !{i32 458765, metadata !2, metadata !"x", metadata !0, i32 1, i64 64, i64 64, i64 0, i32 0, metadata !5} ; [ DW_TAG_member ] -!5 = metadata !{i32 458788, metadata !0, metadata !"double", metadata !0, i32 0, i64 64, i64 64, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ] -!6 = metadata !{i32 458765, metadata !2, metadata !"y", metadata !0, i32 1, i64 64, i64 64, i64 64, i32 0, metadata !5} ; [ DW_TAG_member ] -!7 = metadata !{i32 458765, metadata !2, metadata !"z", metadata !0, i32 1, i64 64, i64 64, i64 128, i32 0, metadata !5} ; [ DW_TAG_member ] -!8 = metadata !{i32 459008, metadata !9, metadata !"t", metadata !0, i32 5, metadata !2} ; [ DW_TAG_auto_variable ] -!9 = metadata !{i32 458763, metadata !10} ; [ DW_TAG_lexical_block ] -!10 = metadata !{i32 458798, i32 0, metadata !0, metadata !"foo", metadata !"foo", metadata !"foo", metadata !0, i32 4, metadata !11, i1 false, i1 true, i32 0, i32 0, null} ; [ DW_TAG_subprogram ] -!11 = metadata !{i32 458773, metadata !0, metadata !"", metadata !0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !12, i32 0, null} ; [ DW_TAG_subroutine_type ] -!12 = metadata !{metadata !13} -!13 = metadata !{i32 458788, metadata !0, metadata !"int", metadata !0, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] -!14 = metadata !{%tart.reflect.ComplexType* @.type.SwitchStmtTest} +!llvm.dbg.sp = !{!0} + +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"", metadata !1, i32 2, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false, i32 ()* @main} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 589865, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !2} ; [ DW_TAG_file_type ] +!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !"clang version 2.9 (trunk 120996)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{metadata !5} +!5 = metadata !{i32 589860, metadata !2, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] +!6 = metadata !{i32 0} +!7 = metadata !{i32 590080, metadata !8, metadata !"i", metadata !1, i32 3, metadata !5, i32 0} ; [ DW_TAG_auto_variable ] +!8 = metadata !{i32 589835, metadata !0, i32 2, i32 12, metadata !1, i32 0} ; [ DW_TAG_lexical_block ] +!9 = metadata !{i32 3, i32 11, metadata !8, null} +!10 = metadata !{i32 4, i32 2, metadata !8, null} + Modified: llvm/trunk/test/CodeGen/CellSPU/2010-04-07-DbgValueOtherTargets.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/CellSPU/2010-04-07-DbgValueOtherTargets.ll?rev=121059&r1=121058&r2=121059&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/CellSPU/2010-04-07-DbgValueOtherTargets.ll (original) +++ llvm/trunk/test/CodeGen/CellSPU/2010-04-07-DbgValueOtherTargets.ll Mon Dec 6 16:39:26 2010 @@ -1,33 +1,28 @@ ; RUN: llc -O0 -march=cellspu -asm-verbose < %s | FileCheck %s ; Check that DEBUG_VALUE comments come through on a variety of targets. -%tart.reflect.ComplexType = type { double, double } - - at .type.SwitchStmtTest = constant %tart.reflect.ComplexType { double 3.0, double 2.0 } - -define i32 @"main(tart.core.String[])->int32"(i32 %args) { +define i32 @main() nounwind ssp { entry: ; CHECK: DEBUG_VALUE - tail call void @llvm.dbg.value(metadata !14, i64 0, metadata !8) - tail call void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType* @.type.SwitchStmtTest) ; <%tart.core.Object*> [#uses=2] - ret i32 3 + call void @llvm.dbg.value(metadata !6, i64 0, metadata !7), !dbg !9 + ret i32 0, !dbg !10 } +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone + declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone -declare void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType*) nounwind readnone -!0 = metadata !{i32 458769, i32 0, i32 1, metadata !"sm.c", metadata !"/Volumes/MacOS9/tests/", metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] -!1 = metadata !{i32 458790, metadata !0, metadata !"", metadata !0, i32 0, i64 192, i64 64, i64 0, i32 0, metadata !2} ; [ DW_TAG_const_type ] -!2 = metadata !{i32 458771, metadata !0, metadata !"C", metadata !0, i32 1, i64 192, i64 64, i64 0, i32 0, null, metadata !3, i32 0, null} ; [ DW_TAG_structure_type ] -!3 = metadata !{metadata !4, metadata !6, metadata !7} -!4 = metadata !{i32 458765, metadata !2, metadata !"x", metadata !0, i32 1, i64 64, i64 64, i64 0, i32 0, metadata !5} ; [ DW_TAG_member ] -!5 = metadata !{i32 458788, metadata !0, metadata !"double", metadata !0, i32 0, i64 64, i64 64, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ] -!6 = metadata !{i32 458765, metadata !2, metadata !"y", metadata !0, i32 1, i64 64, i64 64, i64 64, i32 0, metadata !5} ; [ DW_TAG_member ] -!7 = metadata !{i32 458765, metadata !2, metadata !"z", metadata !0, i32 1, i64 64, i64 64, i64 128, i32 0, metadata !5} ; [ DW_TAG_member ] -!8 = metadata !{i32 459008, metadata !9, metadata !"t", metadata !0, i32 5, metadata !2} ; [ DW_TAG_auto_variable ] -!9 = metadata !{i32 458763, metadata !10} ; [ DW_TAG_lexical_block ] -!10 = metadata !{i32 458798, i32 0, metadata !0, metadata !"foo", metadata !"foo", metadata !"foo", metadata !0, i32 4, metadata !11, i1 false, i1 true, i32 0, i32 0, null} ; [ DW_TAG_subprogram ] -!11 = metadata !{i32 458773, metadata !0, metadata !"", metadata !0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !12, i32 0, null} ; [ DW_TAG_subroutine_type ] -!12 = metadata !{metadata !13} -!13 = metadata !{i32 458788, metadata !0, metadata !"int", metadata !0, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] -!14 = metadata !{%tart.reflect.ComplexType* @.type.SwitchStmtTest} +!llvm.dbg.sp = !{!0} + +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"", metadata !1, i32 2, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false, i32 ()* @main} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 589865, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !2} ; [ DW_TAG_file_type ] +!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !"clang version 2.9 (trunk 120996)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{metadata !5} +!5 = metadata !{i32 589860, metadata !2, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] +!6 = metadata !{i32 0} +!7 = metadata !{i32 590080, metadata !8, metadata !"i", metadata !1, i32 3, metadata !5, i32 0} ; [ DW_TAG_auto_variable ] +!8 = metadata !{i32 589835, metadata !0, i32 2, i32 12, metadata !1, i32 0} ; [ DW_TAG_lexical_block ] +!9 = metadata !{i32 3, i32 11, metadata !8, null} +!10 = metadata !{i32 4, i32 2, metadata !8, null} + Modified: llvm/trunk/test/CodeGen/MBlaze/2010-04-07-DbgValueOtherTargets.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MBlaze/2010-04-07-DbgValueOtherTargets.ll?rev=121059&r1=121058&r2=121059&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MBlaze/2010-04-07-DbgValueOtherTargets.ll (original) +++ llvm/trunk/test/CodeGen/MBlaze/2010-04-07-DbgValueOtherTargets.ll Mon Dec 6 16:39:26 2010 @@ -1,33 +1,28 @@ ; RUN: llc -O0 -march=mblaze -asm-verbose < %s | FileCheck %s ; Check that DEBUG_VALUE comments come through on a variety of targets. -%tart.reflect.ComplexType = type { double, double } - - at .type.SwitchStmtTest = constant %tart.reflect.ComplexType { double 3.0, double 2.0 } - -define i32 @"main(tart.core.String[])->int32"(i32 %args) { +define i32 @main() nounwind ssp { entry: ; CHECK: DEBUG_VALUE - tail call void @llvm.dbg.value(metadata !14, i64 0, metadata !8) - tail call void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType* @.type.SwitchStmtTest) ; <%tart.core.Object*> [#uses=2] - ret i32 3 + call void @llvm.dbg.value(metadata !6, i64 0, metadata !7), !dbg !9 + ret i32 0, !dbg !10 } +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone + declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone -declare void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType*) nounwind readnone -!0 = metadata !{i32 458769, i32 0, i32 1, metadata !"sm.c", metadata !"/Volumes/MacOS9/tests/", metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] -!1 = metadata !{i32 458790, metadata !0, metadata !"", metadata !0, i32 0, i64 192, i64 64, i64 0, i32 0, metadata !2} ; [ DW_TAG_const_type ] -!2 = metadata !{i32 458771, metadata !0, metadata !"C", metadata !0, i32 1, i64 192, i64 64, i64 0, i32 0, null, metadata !3, i32 0, null} ; [ DW_TAG_structure_type ] -!3 = metadata !{metadata !4, metadata !6, metadata !7} -!4 = metadata !{i32 458765, metadata !2, metadata !"x", metadata !0, i32 1, i64 64, i64 64, i64 0, i32 0, metadata !5} ; [ DW_TAG_member ] -!5 = metadata !{i32 458788, metadata !0, metadata !"double", metadata !0, i32 0, i64 64, i64 64, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ] -!6 = metadata !{i32 458765, metadata !2, metadata !"y", metadata !0, i32 1, i64 64, i64 64, i64 64, i32 0, metadata !5} ; [ DW_TAG_member ] -!7 = metadata !{i32 458765, metadata !2, metadata !"z", metadata !0, i32 1, i64 64, i64 64, i64 128, i32 0, metadata !5} ; [ DW_TAG_member ] -!8 = metadata !{i32 459008, metadata !9, metadata !"t", metadata !0, i32 5, metadata !2} ; [ DW_TAG_auto_variable ] -!9 = metadata !{i32 458763, metadata !10} ; [ DW_TAG_lexical_block ] -!10 = metadata !{i32 458798, i32 0, metadata !0, metadata !"foo", metadata !"foo", metadata !"foo", metadata !0, i32 4, metadata !11, i1 false, i1 true, i32 0, i32 0, null} ; [ DW_TAG_subprogram ] -!11 = metadata !{i32 458773, metadata !0, metadata !"", metadata !0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !12, i32 0, null} ; [ DW_TAG_subroutine_type ] -!12 = metadata !{metadata !13} -!13 = metadata !{i32 458788, metadata !0, metadata !"int", metadata !0, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] -!14 = metadata !{%tart.reflect.ComplexType* @.type.SwitchStmtTest} +!llvm.dbg.sp = !{!0} + +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"", metadata !1, i32 2, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false, i32 ()* @main} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 589865, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !2} ; [ DW_TAG_file_type ] +!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !"clang version 2.9 (trunk 120996)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{metadata !5} +!5 = metadata !{i32 589860, metadata !2, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] +!6 = metadata !{i32 0} +!7 = metadata !{i32 590080, metadata !8, metadata !"i", metadata !1, i32 3, metadata !5, i32 0} ; [ DW_TAG_auto_variable ] +!8 = metadata !{i32 589835, metadata !0, i32 2, i32 12, metadata !1, i32 0} ; [ DW_TAG_lexical_block ] +!9 = metadata !{i32 3, i32 11, metadata !8, null} +!10 = metadata !{i32 4, i32 2, metadata !8, null} + Modified: llvm/trunk/test/CodeGen/MSP430/2010-04-07-DbgValueOtherTargets.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/2010-04-07-DbgValueOtherTargets.ll?rev=121059&r1=121058&r2=121059&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/2010-04-07-DbgValueOtherTargets.ll (original) +++ llvm/trunk/test/CodeGen/MSP430/2010-04-07-DbgValueOtherTargets.ll Mon Dec 6 16:39:26 2010 @@ -1,33 +1,28 @@ ; RUN: llc -O0 -march=msp430 -asm-verbose < %s | FileCheck %s ; Check that DEBUG_VALUE comments come through on a variety of targets. -%tart.reflect.ComplexType = type { double, double } - - at .type.SwitchStmtTest = constant %tart.reflect.ComplexType { double 3.0, double 2.0 } - -define i32 @"main(tart.core.String[])->int32"(i32 %args) { +define i32 @main() nounwind ssp { entry: ; CHECK: DEBUG_VALUE - tail call void @llvm.dbg.value(metadata !14, i64 0, metadata !8) - tail call void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType* @.type.SwitchStmtTest) ; <%tart.core.Object*> [#uses=2] - ret i32 3 + call void @llvm.dbg.value(metadata !6, i64 0, metadata !7), !dbg !9 + ret i32 0, !dbg !10 } +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone + declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone -declare void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType*) nounwind readnone -!0 = metadata !{i32 458769, i32 0, i32 1, metadata !"sm.c", metadata !"/Volumes/MacOS9/tests/", metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] -!1 = metadata !{i32 458790, metadata !0, metadata !"", metadata !0, i32 0, i64 192, i64 64, i64 0, i32 0, metadata !2} ; [ DW_TAG_const_type ] -!2 = metadata !{i32 458771, metadata !0, metadata !"C", metadata !0, i32 1, i64 192, i64 64, i64 0, i32 0, null, metadata !3, i32 0, null} ; [ DW_TAG_structure_type ] -!3 = metadata !{metadata !4, metadata !6, metadata !7} -!4 = metadata !{i32 458765, metadata !2, metadata !"x", metadata !0, i32 1, i64 64, i64 64, i64 0, i32 0, metadata !5} ; [ DW_TAG_member ] -!5 = metadata !{i32 458788, metadata !0, metadata !"double", metadata !0, i32 0, i64 64, i64 64, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ] -!6 = metadata !{i32 458765, metadata !2, metadata !"y", metadata !0, i32 1, i64 64, i64 64, i64 64, i32 0, metadata !5} ; [ DW_TAG_member ] -!7 = metadata !{i32 458765, metadata !2, metadata !"z", metadata !0, i32 1, i64 64, i64 64, i64 128, i32 0, metadata !5} ; [ DW_TAG_member ] -!8 = metadata !{i32 459008, metadata !9, metadata !"t", metadata !0, i32 5, metadata !2} ; [ DW_TAG_auto_variable ] -!9 = metadata !{i32 458763, metadata !10} ; [ DW_TAG_lexical_block ] -!10 = metadata !{i32 458798, i32 0, metadata !0, metadata !"foo", metadata !"foo", metadata !"foo", metadata !0, i32 4, metadata !11, i1 false, i1 true, i32 0, i32 0, null} ; [ DW_TAG_subprogram ] -!11 = metadata !{i32 458773, metadata !0, metadata !"", metadata !0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !12, i32 0, null} ; [ DW_TAG_subroutine_type ] -!12 = metadata !{metadata !13} -!13 = metadata !{i32 458788, metadata !0, metadata !"int", metadata !0, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] -!14 = metadata !{%tart.reflect.ComplexType* @.type.SwitchStmtTest} +!llvm.dbg.sp = !{!0} + +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"", metadata !1, i32 2, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false, i32 ()* @main} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 589865, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !2} ; [ DW_TAG_file_type ] +!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !"clang version 2.9 (trunk 120996)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{metadata !5} +!5 = metadata !{i32 589860, metadata !2, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] +!6 = metadata !{i32 0} +!7 = metadata !{i32 590080, metadata !8, metadata !"i", metadata !1, i32 3, metadata !5, i32 0} ; [ DW_TAG_auto_variable ] +!8 = metadata !{i32 589835, metadata !0, i32 2, i32 12, metadata !1, i32 0} ; [ DW_TAG_lexical_block ] +!9 = metadata !{i32 3, i32 11, metadata !8, null} +!10 = metadata !{i32 4, i32 2, metadata !8, null} + Modified: llvm/trunk/test/CodeGen/Mips/2010-04-07-DbgValueOtherTargets.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/2010-04-07-DbgValueOtherTargets.ll?rev=121059&r1=121058&r2=121059&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Mips/2010-04-07-DbgValueOtherTargets.ll (original) +++ llvm/trunk/test/CodeGen/Mips/2010-04-07-DbgValueOtherTargets.ll Mon Dec 6 16:39:26 2010 @@ -1,33 +1,28 @@ ; RUN: llc -O0 -march=mips -asm-verbose < %s | FileCheck %s ; Check that DEBUG_VALUE comments come through on a variety of targets. -%tart.reflect.ComplexType = type { double, double } - - at .type.SwitchStmtTest = constant %tart.reflect.ComplexType { double 3.0, double 2.0 } - -define i32 @"main(tart.core.String[])->int32"(i32 %args) { +define i32 @main() nounwind ssp { entry: ; CHECK: DEBUG_VALUE - tail call void @llvm.dbg.value(metadata !14, i64 0, metadata !8) - tail call void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType* @.type.SwitchStmtTest) ; <%tart.core.Object*> [#uses=2] - ret i32 3 + call void @llvm.dbg.value(metadata !6, i64 0, metadata !7), !dbg !9 + ret i32 0, !dbg !10 } +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone + declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone -declare void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType*) nounwind readnone -!0 = metadata !{i32 458769, i32 0, i32 1, metadata !"sm.c", metadata !"/Volumes/MacOS9/tests/", metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] -!1 = metadata !{i32 458790, metadata !0, metadata !"", metadata !0, i32 0, i64 192, i64 64, i64 0, i32 0, metadata !2} ; [ DW_TAG_const_type ] -!2 = metadata !{i32 458771, metadata !0, metadata !"C", metadata !0, i32 1, i64 192, i64 64, i64 0, i32 0, null, metadata !3, i32 0, null} ; [ DW_TAG_structure_type ] -!3 = metadata !{metadata !4, metadata !6, metadata !7} -!4 = metadata !{i32 458765, metadata !2, metadata !"x", metadata !0, i32 1, i64 64, i64 64, i64 0, i32 0, metadata !5} ; [ DW_TAG_member ] -!5 = metadata !{i32 458788, metadata !0, metadata !"double", metadata !0, i32 0, i64 64, i64 64, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ] -!6 = metadata !{i32 458765, metadata !2, metadata !"y", metadata !0, i32 1, i64 64, i64 64, i64 64, i32 0, metadata !5} ; [ DW_TAG_member ] -!7 = metadata !{i32 458765, metadata !2, metadata !"z", metadata !0, i32 1, i64 64, i64 64, i64 128, i32 0, metadata !5} ; [ DW_TAG_member ] -!8 = metadata !{i32 459008, metadata !9, metadata !"t", metadata !0, i32 5, metadata !2} ; [ DW_TAG_auto_variable ] -!9 = metadata !{i32 458763, metadata !10} ; [ DW_TAG_lexical_block ] -!10 = metadata !{i32 458798, i32 0, metadata !0, metadata !"foo", metadata !"foo", metadata !"foo", metadata !0, i32 4, metadata !11, i1 false, i1 true, i32 0, i32 0, null} ; [ DW_TAG_subprogram ] -!11 = metadata !{i32 458773, metadata !0, metadata !"", metadata !0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !12, i32 0, null} ; [ DW_TAG_subroutine_type ] -!12 = metadata !{metadata !13} -!13 = metadata !{i32 458788, metadata !0, metadata !"int", metadata !0, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] -!14 = metadata !{%tart.reflect.ComplexType* @.type.SwitchStmtTest} +!llvm.dbg.sp = !{!0} + +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"", metadata !1, i32 2, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false, i32 ()* @main} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 589865, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !2} ; [ DW_TAG_file_type ] +!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !"clang version 2.9 (trunk 120996)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{metadata !5} +!5 = metadata !{i32 589860, metadata !2, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] +!6 = metadata !{i32 0} +!7 = metadata !{i32 590080, metadata !8, metadata !"i", metadata !1, i32 3, metadata !5, i32 0} ; [ DW_TAG_auto_variable ] +!8 = metadata !{i32 589835, metadata !0, i32 2, i32 12, metadata !1, i32 0} ; [ DW_TAG_lexical_block ] +!9 = metadata !{i32 3, i32 11, metadata !8, null} +!10 = metadata !{i32 4, i32 2, metadata !8, null} + Modified: llvm/trunk/test/CodeGen/PowerPC/2010-04-07-DbgValueOtherTargets.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/2010-04-07-DbgValueOtherTargets.ll?rev=121059&r1=121058&r2=121059&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/2010-04-07-DbgValueOtherTargets.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/2010-04-07-DbgValueOtherTargets.ll Mon Dec 6 16:39:26 2010 @@ -1,33 +1,28 @@ ; RUN: llc -O0 -march=ppc32 -asm-verbose < %s | FileCheck %s ; Check that DEBUG_VALUE comments come through on a variety of targets. -%tart.reflect.ComplexType = type { double, double } - - at .type.SwitchStmtTest = constant %tart.reflect.ComplexType { double 3.0, double 2.0 } - -define i32 @"main(tart.core.String[])->int32"(i32 %args) { +define i32 @main() nounwind ssp { entry: ; CHECK: DEBUG_VALUE - tail call void @llvm.dbg.value(metadata !14, i64 0, metadata !8) - tail call void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType* @.type.SwitchStmtTest) ; <%tart.core.Object*> [#uses=2] - ret i32 3 + call void @llvm.dbg.value(metadata !6, i64 0, metadata !7), !dbg !9 + ret i32 0, !dbg !10 } +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone + declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone -declare void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType*) nounwind readnone -!0 = metadata !{i32 458769, i32 0, i32 1, metadata !"sm.c", metadata !"/Volumes/MacOS9/tests/", metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] -!1 = metadata !{i32 458790, metadata !0, metadata !"", metadata !0, i32 0, i64 192, i64 64, i64 0, i32 0, metadata !2} ; [ DW_TAG_const_type ] -!2 = metadata !{i32 458771, metadata !0, metadata !"C", metadata !0, i32 1, i64 192, i64 64, i64 0, i32 0, null, metadata !3, i32 0, null} ; [ DW_TAG_structure_type ] -!3 = metadata !{metadata !4, metadata !6, metadata !7} -!4 = metadata !{i32 458765, metadata !2, metadata !"x", metadata !0, i32 1, i64 64, i64 64, i64 0, i32 0, metadata !5} ; [ DW_TAG_member ] -!5 = metadata !{i32 458788, metadata !0, metadata !"double", metadata !0, i32 0, i64 64, i64 64, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ] -!6 = metadata !{i32 458765, metadata !2, metadata !"y", metadata !0, i32 1, i64 64, i64 64, i64 64, i32 0, metadata !5} ; [ DW_TAG_member ] -!7 = metadata !{i32 458765, metadata !2, metadata !"z", metadata !0, i32 1, i64 64, i64 64, i64 128, i32 0, metadata !5} ; [ DW_TAG_member ] -!8 = metadata !{i32 459008, metadata !9, metadata !"t", metadata !0, i32 5, metadata !2} ; [ DW_TAG_auto_variable ] -!9 = metadata !{i32 458763, metadata !10} ; [ DW_TAG_lexical_block ] -!10 = metadata !{i32 458798, i32 0, metadata !0, metadata !"foo", metadata !"foo", metadata !"foo", metadata !0, i32 4, metadata !11, i1 false, i1 true, i32 0, i32 0, null} ; [ DW_TAG_subprogram ] -!11 = metadata !{i32 458773, metadata !0, metadata !"", metadata !0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !12, i32 0, null} ; [ DW_TAG_subroutine_type ] -!12 = metadata !{metadata !13} -!13 = metadata !{i32 458788, metadata !0, metadata !"int", metadata !0, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] -!14 = metadata !{%tart.reflect.ComplexType* @.type.SwitchStmtTest} +!llvm.dbg.sp = !{!0} + +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"", metadata !1, i32 2, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false, i32 ()* @main} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 589865, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !2} ; [ DW_TAG_file_type ] +!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !"clang version 2.9 (trunk 120996)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{metadata !5} +!5 = metadata !{i32 589860, metadata !2, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] +!6 = metadata !{i32 0} +!7 = metadata !{i32 590080, metadata !8, metadata !"i", metadata !1, i32 3, metadata !5, i32 0} ; [ DW_TAG_auto_variable ] +!8 = metadata !{i32 589835, metadata !0, i32 2, i32 12, metadata !1, i32 0} ; [ DW_TAG_lexical_block ] +!9 = metadata !{i32 3, i32 11, metadata !8, null} +!10 = metadata !{i32 4, i32 2, metadata !8, null} + Modified: llvm/trunk/test/CodeGen/SPARC/2010-04-07-DbgValueOtherTargets.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/SPARC/2010-04-07-DbgValueOtherTargets.ll?rev=121059&r1=121058&r2=121059&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/SPARC/2010-04-07-DbgValueOtherTargets.ll (original) +++ llvm/trunk/test/CodeGen/SPARC/2010-04-07-DbgValueOtherTargets.ll Mon Dec 6 16:39:26 2010 @@ -1,33 +1,28 @@ ; RUN: llc -O0 -march=sparc -asm-verbose < %s | FileCheck %s ; Check that DEBUG_VALUE comments come through on a variety of targets. -%tart.reflect.ComplexType = type { double, double } - - at .type.SwitchStmtTest = constant %tart.reflect.ComplexType { double 3.0, double 2.0 } - -define i32 @"main(tart.core.String[])->int32"(i32 %args) { +define i32 @main() nounwind ssp { entry: ; CHECK: DEBUG_VALUE - tail call void @llvm.dbg.value(metadata !14, i64 0, metadata !8) - tail call void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType* @.type.SwitchStmtTest) ; <%tart.core.Object*> [#uses=2] - ret i32 3 + call void @llvm.dbg.value(metadata !6, i64 0, metadata !7), !dbg !9 + ret i32 0, !dbg !10 } +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone + declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone -declare void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType*) nounwind readnone -!0 = metadata !{i32 458769, i32 0, i32 1, metadata !"sm.c", metadata !"/Volumes/MacOS9/tests/", metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] -!1 = metadata !{i32 458790, metadata !0, metadata !"", metadata !0, i32 0, i64 192, i64 64, i64 0, i32 0, metadata !2} ; [ DW_TAG_const_type ] -!2 = metadata !{i32 458771, metadata !0, metadata !"C", metadata !0, i32 1, i64 192, i64 64, i64 0, i32 0, null, metadata !3, i32 0, null} ; [ DW_TAG_structure_type ] -!3 = metadata !{metadata !4, metadata !6, metadata !7} -!4 = metadata !{i32 458765, metadata !2, metadata !"x", metadata !0, i32 1, i64 64, i64 64, i64 0, i32 0, metadata !5} ; [ DW_TAG_member ] -!5 = metadata !{i32 458788, metadata !0, metadata !"double", metadata !0, i32 0, i64 64, i64 64, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ] -!6 = metadata !{i32 458765, metadata !2, metadata !"y", metadata !0, i32 1, i64 64, i64 64, i64 64, i32 0, metadata !5} ; [ DW_TAG_member ] -!7 = metadata !{i32 458765, metadata !2, metadata !"z", metadata !0, i32 1, i64 64, i64 64, i64 128, i32 0, metadata !5} ; [ DW_TAG_member ] -!8 = metadata !{i32 459008, metadata !9, metadata !"t", metadata !0, i32 5, metadata !2} ; [ DW_TAG_auto_variable ] -!9 = metadata !{i32 458763, metadata !10} ; [ DW_TAG_lexical_block ] -!10 = metadata !{i32 458798, i32 0, metadata !0, metadata !"foo", metadata !"foo", metadata !"foo", metadata !0, i32 4, metadata !11, i1 false, i1 true, i32 0, i32 0, null} ; [ DW_TAG_subprogram ] -!11 = metadata !{i32 458773, metadata !0, metadata !"", metadata !0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !12, i32 0, null} ; [ DW_TAG_subroutine_type ] -!12 = metadata !{metadata !13} -!13 = metadata !{i32 458788, metadata !0, metadata !"int", metadata !0, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] -!14 = metadata !{%tart.reflect.ComplexType* @.type.SwitchStmtTest} +!llvm.dbg.sp = !{!0} + +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"", metadata !1, i32 2, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false, i32 ()* @main} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 589865, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !2} ; [ DW_TAG_file_type ] +!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !"clang version 2.9 (trunk 120996)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{metadata !5} +!5 = metadata !{i32 589860, metadata !2, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] +!6 = metadata !{i32 0} +!7 = metadata !{i32 590080, metadata !8, metadata !"i", metadata !1, i32 3, metadata !5, i32 0} ; [ DW_TAG_auto_variable ] +!8 = metadata !{i32 589835, metadata !0, i32 2, i32 12, metadata !1, i32 0} ; [ DW_TAG_lexical_block ] +!9 = metadata !{i32 3, i32 11, metadata !8, null} +!10 = metadata !{i32 4, i32 2, metadata !8, null} + Modified: llvm/trunk/test/CodeGen/SystemZ/2010-04-07-DbgValueOtherTargets.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/SystemZ/2010-04-07-DbgValueOtherTargets.ll?rev=121059&r1=121058&r2=121059&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/SystemZ/2010-04-07-DbgValueOtherTargets.ll (original) +++ llvm/trunk/test/CodeGen/SystemZ/2010-04-07-DbgValueOtherTargets.ll Mon Dec 6 16:39:26 2010 @@ -1,33 +1,28 @@ ; RUN: llc -O0 -march=systemz -asm-verbose < %s | FileCheck %s ; Check that DEBUG_VALUE comments come through on a variety of targets. -%tart.reflect.ComplexType = type { double, double } - - at .type.SwitchStmtTest = constant %tart.reflect.ComplexType { double 3.0, double 2.0 } - -define i32 @"main(tart.core.String[])->int32"(i32 %args) { +define i32 @main() nounwind ssp { entry: ; CHECK: DEBUG_VALUE - tail call void @llvm.dbg.value(metadata !14, i64 0, metadata !8) - tail call void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType* @.type.SwitchStmtTest) ; <%tart.core.Object*> [#uses=2] - ret i32 3 + call void @llvm.dbg.value(metadata !6, i64 0, metadata !7), !dbg !9 + ret i32 0, !dbg !10 } +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone + declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone -declare void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType*) nounwind readnone -!0 = metadata !{i32 458769, i32 0, i32 1, metadata !"sm.c", metadata !"/Volumes/MacOS9/tests/", metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] -!1 = metadata !{i32 458790, metadata !0, metadata !"", metadata !0, i32 0, i64 192, i64 64, i64 0, i32 0, metadata !2} ; [ DW_TAG_const_type ] -!2 = metadata !{i32 458771, metadata !0, metadata !"C", metadata !0, i32 1, i64 192, i64 64, i64 0, i32 0, null, metadata !3, i32 0, null} ; [ DW_TAG_structure_type ] -!3 = metadata !{metadata !4, metadata !6, metadata !7} -!4 = metadata !{i32 458765, metadata !2, metadata !"x", metadata !0, i32 1, i64 64, i64 64, i64 0, i32 0, metadata !5} ; [ DW_TAG_member ] -!5 = metadata !{i32 458788, metadata !0, metadata !"double", metadata !0, i32 0, i64 64, i64 64, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ] -!6 = metadata !{i32 458765, metadata !2, metadata !"y", metadata !0, i32 1, i64 64, i64 64, i64 64, i32 0, metadata !5} ; [ DW_TAG_member ] -!7 = metadata !{i32 458765, metadata !2, metadata !"z", metadata !0, i32 1, i64 64, i64 64, i64 128, i32 0, metadata !5} ; [ DW_TAG_member ] -!8 = metadata !{i32 459008, metadata !9, metadata !"t", metadata !0, i32 5, metadata !2} ; [ DW_TAG_auto_variable ] -!9 = metadata !{i32 458763, metadata !10} ; [ DW_TAG_lexical_block ] -!10 = metadata !{i32 458798, i32 0, metadata !0, metadata !"foo", metadata !"foo", metadata !"foo", metadata !0, i32 4, metadata !11, i1 false, i1 true, i32 0, i32 0, null} ; [ DW_TAG_subprogram ] -!11 = metadata !{i32 458773, metadata !0, metadata !"", metadata !0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !12, i32 0, null} ; [ DW_TAG_subroutine_type ] -!12 = metadata !{metadata !13} -!13 = metadata !{i32 458788, metadata !0, metadata !"int", metadata !0, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] -!14 = metadata !{%tart.reflect.ComplexType* @.type.SwitchStmtTest} +!llvm.dbg.sp = !{!0} + +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"", metadata !1, i32 2, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false, i32 ()* @main} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 589865, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !2} ; [ DW_TAG_file_type ] +!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !"clang version 2.9 (trunk 120996)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{metadata !5} +!5 = metadata !{i32 589860, metadata !2, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] +!6 = metadata !{i32 0} +!7 = metadata !{i32 590080, metadata !8, metadata !"i", metadata !1, i32 3, metadata !5, i32 0} ; [ DW_TAG_auto_variable ] +!8 = metadata !{i32 589835, metadata !0, i32 2, i32 12, metadata !1, i32 0} ; [ DW_TAG_lexical_block ] +!9 = metadata !{i32 3, i32 11, metadata !8, null} +!10 = metadata !{i32 4, i32 2, metadata !8, null} + Modified: llvm/trunk/test/CodeGen/Thumb/2010-04-07-DbgValueOtherTargets.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb/2010-04-07-DbgValueOtherTargets.ll?rev=121059&r1=121058&r2=121059&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb/2010-04-07-DbgValueOtherTargets.ll (original) +++ llvm/trunk/test/CodeGen/Thumb/2010-04-07-DbgValueOtherTargets.ll Mon Dec 6 16:39:26 2010 @@ -1,33 +1,28 @@ ; RUN: llc -O0 -march=thumb -asm-verbose < %s | FileCheck %s ; Check that DEBUG_VALUE comments come through on a variety of targets. -%tart.reflect.ComplexType = type { double, double } - - at .type.SwitchStmtTest = constant %tart.reflect.ComplexType { double 3.0, double 2.0 } - -define i32 @"main(tart.core.String[])->int32"(i32 %args) { +define i32 @main() nounwind ssp { entry: ; CHECK: DEBUG_VALUE - tail call void @llvm.dbg.value(metadata !14, i64 0, metadata !8) - tail call void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType* @.type.SwitchStmtTest) ; <%tart.core.Object*> [#uses=2] - ret i32 3 + call void @llvm.dbg.value(metadata !6, i64 0, metadata !7), !dbg !9 + ret i32 0, !dbg !10 } +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone + declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone -declare void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType*) nounwind readnone -!0 = metadata !{i32 458769, i32 0, i32 1, metadata !"sm.c", metadata !"/Volumes/MacOS9/tests/", metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] -!1 = metadata !{i32 458790, metadata !0, metadata !"", metadata !0, i32 0, i64 192, i64 64, i64 0, i32 0, metadata !2} ; [ DW_TAG_const_type ] -!2 = metadata !{i32 458771, metadata !0, metadata !"C", metadata !0, i32 1, i64 192, i64 64, i64 0, i32 0, null, metadata !3, i32 0, null} ; [ DW_TAG_structure_type ] -!3 = metadata !{metadata !4, metadata !6, metadata !7} -!4 = metadata !{i32 458765, metadata !2, metadata !"x", metadata !0, i32 1, i64 64, i64 64, i64 0, i32 0, metadata !5} ; [ DW_TAG_member ] -!5 = metadata !{i32 458788, metadata !0, metadata !"double", metadata !0, i32 0, i64 64, i64 64, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ] -!6 = metadata !{i32 458765, metadata !2, metadata !"y", metadata !0, i32 1, i64 64, i64 64, i64 64, i32 0, metadata !5} ; [ DW_TAG_member ] -!7 = metadata !{i32 458765, metadata !2, metadata !"z", metadata !0, i32 1, i64 64, i64 64, i64 128, i32 0, metadata !5} ; [ DW_TAG_member ] -!8 = metadata !{i32 459008, metadata !9, metadata !"t", metadata !0, i32 5, metadata !2} ; [ DW_TAG_auto_variable ] -!9 = metadata !{i32 458763, metadata !10} ; [ DW_TAG_lexical_block ] -!10 = metadata !{i32 458798, i32 0, metadata !0, metadata !"foo", metadata !"foo", metadata !"foo", metadata !0, i32 4, metadata !11, i1 false, i1 true, i32 0, i32 0, null} ; [ DW_TAG_subprogram ] -!11 = metadata !{i32 458773, metadata !0, metadata !"", metadata !0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !12, i32 0, null} ; [ DW_TAG_subroutine_type ] -!12 = metadata !{metadata !13} -!13 = metadata !{i32 458788, metadata !0, metadata !"int", metadata !0, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] -!14 = metadata !{%tart.reflect.ComplexType* @.type.SwitchStmtTest} +!llvm.dbg.sp = !{!0} + +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"", metadata !1, i32 2, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false, i32 ()* @main} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 589865, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !2} ; [ DW_TAG_file_type ] +!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !"clang version 2.9 (trunk 120996)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{metadata !5} +!5 = metadata !{i32 589860, metadata !2, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] +!6 = metadata !{i32 0} +!7 = metadata !{i32 590080, metadata !8, metadata !"i", metadata !1, i32 3, metadata !5, i32 0} ; [ DW_TAG_auto_variable ] +!8 = metadata !{i32 589835, metadata !0, i32 2, i32 12, metadata !1, i32 0} ; [ DW_TAG_lexical_block ] +!9 = metadata !{i32 3, i32 11, metadata !8, null} +!10 = metadata !{i32 4, i32 2, metadata !8, null} + Modified: llvm/trunk/test/CodeGen/X86/2010-04-07-DbgValueOtherTargets.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-04-07-DbgValueOtherTargets.ll?rev=121059&r1=121058&r2=121059&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-04-07-DbgValueOtherTargets.ll (original) +++ llvm/trunk/test/CodeGen/X86/2010-04-07-DbgValueOtherTargets.ll Mon Dec 6 16:39:26 2010 @@ -2,33 +2,27 @@ ; RUN: llc -O0 -march=x86-64 -asm-verbose < %s | FileCheck %s ; Check that DEBUG_VALUE comments come through on a variety of targets. -%tart.reflect.ComplexType = type { double, double } - - at .type.SwitchStmtTest = constant %tart.reflect.ComplexType { double 3.0, double 2.0 } - -define i32 @"main(tart.core.String[])->int32"(i32 %args) { +define i32 @main() nounwind ssp { entry: ; CHECK: DEBUG_VALUE - tail call void @llvm.dbg.value(metadata !14, i64 0, metadata !8) - tail call void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType* @.type.SwitchStmtTest) ; <%tart.core.Object*> [#uses=2] - ret i32 3 + call void @llvm.dbg.value(metadata !6, i64 0, metadata !7), !dbg !9 + ret i32 0, !dbg !10 } +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone + declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone -declare void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType*) nounwind readnone -!0 = metadata !{i32 458769, i32 0, i32 1, metadata !"sm.c", metadata !"/Volumes/MacOS9/tests/", metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] -!1 = metadata !{i32 458790, metadata !0, metadata !"", metadata !0, i32 0, i64 192, i64 64, i64 0, i32 0, metadata !2} ; [ DW_TAG_const_type ] -!2 = metadata !{i32 458771, metadata !0, metadata !"C", metadata !0, i32 1, i64 192, i64 64, i64 0, i32 0, null, metadata !3, i32 0, null} ; [ DW_TAG_structure_type ] -!3 = metadata !{metadata !4, metadata !6, metadata !7} -!4 = metadata !{i32 458765, metadata !2, metadata !"x", metadata !0, i32 1, i64 64, i64 64, i64 0, i32 0, metadata !5} ; [ DW_TAG_member ] -!5 = metadata !{i32 458788, metadata !0, metadata !"double", metadata !0, i32 0, i64 64, i64 64, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ] -!6 = metadata !{i32 458765, metadata !2, metadata !"y", metadata !0, i32 1, i64 64, i64 64, i64 64, i32 0, metadata !5} ; [ DW_TAG_member ] -!7 = metadata !{i32 458765, metadata !2, metadata !"z", metadata !0, i32 1, i64 64, i64 64, i64 128, i32 0, metadata !5} ; [ DW_TAG_member ] -!8 = metadata !{i32 459008, metadata !9, metadata !"t", metadata !0, i32 5, metadata !2} ; [ DW_TAG_auto_variable ] -!9 = metadata !{i32 458763, metadata !10} ; [ DW_TAG_lexical_block ] -!10 = metadata !{i32 458798, i32 0, metadata !0, metadata !"foo", metadata !"foo", metadata !"foo", metadata !0, i32 4, metadata !11, i1 false, i1 true, i32 0, i32 0, null} ; [ DW_TAG_subprogram ] -!11 = metadata !{i32 458773, metadata !0, metadata !"", metadata !0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !12, i32 0, null} ; [ DW_TAG_subroutine_type ] -!12 = metadata !{metadata !13} -!13 = metadata !{i32 458788, metadata !0, metadata !"int", metadata !0, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] -!14 = metadata !{%tart.reflect.ComplexType* @.type.SwitchStmtTest} +!llvm.dbg.sp = !{!0} + +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"", metadata !1, i32 2, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false, i32 ()* @main} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 589865, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !2} ; [ DW_TAG_file_type ] +!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !"clang version 2.9 (trunk 120996)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{metadata !5} +!5 = metadata !{i32 589860, metadata !2, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] +!6 = metadata !{i32 0} +!7 = metadata !{i32 590080, metadata !8, metadata !"i", metadata !1, i32 3, metadata !5, i32 0} ; [ DW_TAG_auto_variable ] +!8 = metadata !{i32 589835, metadata !0, i32 2, i32 12, metadata !1, i32 0} ; [ DW_TAG_lexical_block ] +!9 = metadata !{i32 3, i32 11, metadata !8, null} +!10 = metadata !{i32 4, i32 2, metadata !8, null} Modified: llvm/trunk/test/CodeGen/XCore/2010-04-07-DbgValueOtherTargets.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/XCore/2010-04-07-DbgValueOtherTargets.ll?rev=121059&r1=121058&r2=121059&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/XCore/2010-04-07-DbgValueOtherTargets.ll (original) +++ llvm/trunk/test/CodeGen/XCore/2010-04-07-DbgValueOtherTargets.ll Mon Dec 6 16:39:26 2010 @@ -1,33 +1,28 @@ ; RUN: llc -O0 -march=xcore -asm-verbose < %s | FileCheck %s ; Check that DEBUG_VALUE comments come through on a variety of targets. -%tart.reflect.ComplexType = type { double, double } - - at .type.SwitchStmtTest = constant %tart.reflect.ComplexType { double 3.0, double 2.0 } - -define i32 @"main(tart.core.String[])->int32"(i32 %args) { +define i32 @main() nounwind ssp { entry: ; CHECK: DEBUG_VALUE - tail call void @llvm.dbg.value(metadata !14, i64 0, metadata !8) - tail call void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType* @.type.SwitchStmtTest) ; <%tart.core.Object*> [#uses=2] - ret i32 3 + call void @llvm.dbg.value(metadata !6, i64 0, metadata !7), !dbg !9 + ret i32 0, !dbg !10 } +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone + declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone -declare void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType*) nounwind readnone -!0 = metadata !{i32 458769, i32 0, i32 1, metadata !"sm.c", metadata !"/Volumes/MacOS9/tests/", metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] -!1 = metadata !{i32 458790, metadata !0, metadata !"", metadata !0, i32 0, i64 192, i64 64, i64 0, i32 0, metadata !2} ; [ DW_TAG_const_type ] -!2 = metadata !{i32 458771, metadata !0, metadata !"C", metadata !0, i32 1, i64 192, i64 64, i64 0, i32 0, null, metadata !3, i32 0, null} ; [ DW_TAG_structure_type ] -!3 = metadata !{metadata !4, metadata !6, metadata !7} -!4 = metadata !{i32 458765, metadata !2, metadata !"x", metadata !0, i32 1, i64 64, i64 64, i64 0, i32 0, metadata !5} ; [ DW_TAG_member ] -!5 = metadata !{i32 458788, metadata !0, metadata !"double", metadata !0, i32 0, i64 64, i64 64, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ] -!6 = metadata !{i32 458765, metadata !2, metadata !"y", metadata !0, i32 1, i64 64, i64 64, i64 64, i32 0, metadata !5} ; [ DW_TAG_member ] -!7 = metadata !{i32 458765, metadata !2, metadata !"z", metadata !0, i32 1, i64 64, i64 64, i64 128, i32 0, metadata !5} ; [ DW_TAG_member ] -!8 = metadata !{i32 459008, metadata !9, metadata !"t", metadata !0, i32 5, metadata !2} ; [ DW_TAG_auto_variable ] -!9 = metadata !{i32 458763, metadata !10} ; [ DW_TAG_lexical_block ] -!10 = metadata !{i32 458798, i32 0, metadata !0, metadata !"foo", metadata !"foo", metadata !"foo", metadata !0, i32 4, metadata !11, i1 false, i1 true, i32 0, i32 0, null} ; [ DW_TAG_subprogram ] -!11 = metadata !{i32 458773, metadata !0, metadata !"", metadata !0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !12, i32 0, null} ; [ DW_TAG_subroutine_type ] -!12 = metadata !{metadata !13} -!13 = metadata !{i32 458788, metadata !0, metadata !"int", metadata !0, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] -!14 = metadata !{%tart.reflect.ComplexType* @.type.SwitchStmtTest} +!llvm.dbg.sp = !{!0} + +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"", metadata !1, i32 2, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false, i32 ()* @main} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 589865, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !2} ; [ DW_TAG_file_type ] +!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"/tmp/x.c", metadata !"/Users/manav", metadata !"clang version 2.9 (trunk 120996)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{metadata !5} +!5 = metadata !{i32 589860, metadata !2, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] +!6 = metadata !{i32 0} +!7 = metadata !{i32 590080, metadata !8, metadata !"i", metadata !1, i32 3, metadata !5, i32 0} ; [ DW_TAG_auto_variable ] +!8 = metadata !{i32 589835, metadata !0, i32 2, i32 12, metadata !1, i32 0} ; [ DW_TAG_lexical_block ] +!9 = metadata !{i32 3, i32 11, metadata !8, null} +!10 = metadata !{i32 4, i32 2, metadata !8, null} + From dpatel at apple.com Mon Dec 6 16:48:22 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 06 Dec 2010 22:48:22 -0000 Subject: [llvm-commits] [llvm] r121061 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20101206224822.ECAF52A6C12C@llvm.org> Author: dpatel Date: Mon Dec 6 16:48:22 2010 New Revision: 121061 URL: http://llvm.org/viewvc/llvm-project?rev=121061&view=rev Log: Undefined value in reg 0 may need a marker to identify end of source range. This will be used to truncate live range of DBG_VALUE instruction by register allocator and friends. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=121061&r1=121060&r2=121061&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Dec 6 16:48:22 2010 @@ -2783,16 +2783,14 @@ DIVariable DV(MI->getOperand(MI->getNumOperands() - 1).getMetadata()); if (!DV.Verify()) continue; // If DBG_VALUE is for a local variable then it needs a label. - if (DV.getTag() != dwarf::DW_TAG_arg_variable - && isDbgValueInUndefinedReg(MI) == false) + if (DV.getTag() != dwarf::DW_TAG_arg_variable) InsnNeedsLabel.insert(MI); // DBG_VALUE for inlined functions argument needs a label. else if (!DISubprogram(getDISubprogram(DV.getContext())). describes(MF->getFunction())) InsnNeedsLabel.insert(MI); // DBG_VALUE indicating argument location change needs a label. - else if (isDbgValueInUndefinedReg(MI) == false - && !ProcessedArgs.insert(DV)) + else if (!ProcessedArgs.insert(DV)) InsnNeedsLabel.insert(MI); } else { // If location is unknown then instruction needs a location only if From Renato.Golin at arm.com Mon Dec 6 17:18:47 2010 From: Renato.Golin at arm.com (Renato Golin) Date: Mon, 6 Dec 2010 23:18:47 +0000 Subject: [llvm-commits] [llvm] r120960 - in /llvm/trunk: lib/Target/ARM/ test/CodeGen/ARM/ In-Reply-To: References: <20101205220416.D17E72A6C12C@llvm.org> <4CFD24D3.1090801@arm.com>, Message-ID: > > You probably want to avoid mixing NEON with VFP instructions, is there a > > hazard recognizer for that, too? > This is currently modelled on A9 via the special FU acquisition policies. You mean in ARMScheduleA9.td? cheers, --renato -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. From fvbommel at gmail.com Mon Dec 6 17:36:56 2010 From: fvbommel at gmail.com (Frits van Bommel) Date: Mon, 06 Dec 2010 23:36:56 -0000 Subject: [llvm-commits] [llvm] r121066 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/indirectbr.ll Message-ID: <20101206233656.72B992A6C12C@llvm.org> Author: fvbommel Date: Mon Dec 6 17:36:56 2010 New Revision: 121066 URL: http://llvm.org/viewvc/llvm-project?rev=121066&view=rev Log: Implement jump threading of 'indirectbr' by keeping track of whether we're looking for ConstantInt*s or BlockAddress*s. Added: llvm/trunk/test/Transforms/JumpThreading/indirectbr.ll Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=121066&r1=121065&r2=121066&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Mon Dec 6 17:36:56 2010 @@ -49,6 +49,13 @@ typedef SmallVectorImpl > PredValueInfo; typedef SmallVector, 8> PredValueInfoTy; + // This is used to keep track of what kind of constant we're currently hoping + // to find. + enum ConstantPreference { + WantInteger, + WantBlockAddress + }; + /// This pass performs 'jump threading', which looks at blocks that have /// multiple predecessors and multiple successors. If one or more of the /// predecessors of the block can be proven to always jump to one of the @@ -109,8 +116,10 @@ const SmallVectorImpl &PredBBs); bool ComputeValueKnownInPredecessors(Value *V, BasicBlock *BB, - PredValueInfo &Result); - bool ProcessThreadableEdges(Value *Cond, BasicBlock *BB); + PredValueInfo &Result, + ConstantPreference Preference); + bool ProcessThreadableEdges(Value *Cond, BasicBlock *BB, + ConstantPreference Preference); bool ProcessBranchOnDuplicateCond(BasicBlock *PredBB, BasicBlock *DestBB); @@ -247,6 +256,10 @@ if (isa(I)) Size = Size > 6 ? Size-6 : 0; + // The same holds for indirect branches, but slightly more so. + if (isa(I)) + Size = Size > 8 ? Size-8 : 0; + return Size; } @@ -275,9 +288,10 @@ /// getKnownConstant - Helper method to determine if we can thread over a /// terminator with the given value as its condition, and if so what value to -/// use for that. +/// use for that. What kind of value this is depends on whether we want an +/// integer or a block address, but an undef is always accepted. /// Returns null if Val is null or not an appropriate constant. -static Constant *getKnownConstant(Value *Val) { +static Constant *getKnownConstant(Value *Val, ConstantPreference Preference) { if (!Val) return 0; @@ -285,26 +299,22 @@ if (UndefValue *U = dyn_cast(Val)) return U; - return dyn_cast(Val); -} + if (Preference == WantBlockAddress) + return dyn_cast(Val->stripPointerCasts()); -// Helper method for ComputeValueKnownInPredecessors. If Value is a -// ConstantInt or undef, push it. Otherwise, do nothing. -static void PushKnownConstantOrUndef(PredValueInfo &Result, Constant *Value, - BasicBlock *BB) { - if (Constant *KC = getKnownConstant(Value)) - Result.push_back(std::make_pair(KC, BB)); + return dyn_cast(Val); } /// ComputeValueKnownInPredecessors - Given a basic block BB and a value V, see -/// if we can infer that the value is a known ConstantInt in any of our -/// predecessors. If so, return the known list of value and pred BB in the -/// result vector. If a value is known to be undef, it is returned as null. +/// if we can infer that the value is a known ConstantInt/BlockAddress or undef +/// in any of our predecessors. If so, return the known list of value and pred +/// BB in the result vector. /// /// This returns true if there were any known values. /// bool JumpThreading:: -ComputeValueKnownInPredecessors(Value *V, BasicBlock *BB,PredValueInfo &Result){ +ComputeValueKnownInPredecessors(Value *V, BasicBlock *BB, PredValueInfo &Result, + ConstantPreference Preference) { // This method walks up use-def chains recursively. Because of this, we could // get into an infinite loop going around loops in the use-def chain. To // prevent this, keep track of what (value, block) pairs we've already visited @@ -317,7 +327,7 @@ RecursionSetRemover remover(RecursionSet, std::make_pair(V, BB)); // If V is a constant, then it is known in all predecessors. - if (Constant *KC = getKnownConstant(V)) { + if (Constant *KC = getKnownConstant(V, Preference)) { for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) Result.push_back(std::make_pair(KC, *PI)); @@ -347,7 +357,7 @@ // If the value is known by LazyValueInfo to be a constant in a // predecessor, use that information to try to thread this block. Constant *PredCst = LVI->getConstantOnEdge(V, P, BB); - if (Constant *KC = getKnownConstant(PredCst)) + if (Constant *KC = getKnownConstant(PredCst, Preference)) Result.push_back(std::make_pair(KC, P)); } @@ -358,14 +368,13 @@ if (PHINode *PN = dyn_cast(I)) { for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { Value *InVal = PN->getIncomingValue(i); - if (Constant *KC = getKnownConstant(InVal)) { + if (Constant *KC = getKnownConstant(InVal, Preference)) { Result.push_back(std::make_pair(KC, PN->getIncomingBlock(i))); } else { Constant *CI = LVI->getConstantOnEdge(InVal, PN->getIncomingBlock(i), BB); - // LVI returns null is no value could be determined. - if (!CI) continue; - PushKnownConstantOrUndef(Result, CI, PN->getIncomingBlock(i)); + if (Constant *KC = getKnownConstant(CI, Preference)) + Result.push_back(std::make_pair(KC, PN->getIncomingBlock(i))); } } @@ -376,12 +385,15 @@ // Handle some boolean conditions. if (I->getType()->getPrimitiveSizeInBits() == 1) { + assert(Preference == WantInteger && "One-bit non-integer type?"); // X | true -> true // X & false -> false if (I->getOpcode() == Instruction::Or || I->getOpcode() == Instruction::And) { - ComputeValueKnownInPredecessors(I->getOperand(0), BB, LHSVals); - ComputeValueKnownInPredecessors(I->getOperand(1), BB, RHSVals); + ComputeValueKnownInPredecessors(I->getOperand(0), BB, LHSVals, + WantInteger); + ComputeValueKnownInPredecessors(I->getOperand(1), BB, RHSVals, + WantInteger); if (LHSVals.empty() && RHSVals.empty()) return false; @@ -421,7 +433,8 @@ if (I->getOpcode() == Instruction::Xor && isa(I->getOperand(1)) && cast(I->getOperand(1))->isOne()) { - ComputeValueKnownInPredecessors(I->getOperand(0), BB, Result); + ComputeValueKnownInPredecessors(I->getOperand(0), BB, Result, + WantInteger); if (Result.empty()) return false; @@ -434,16 +447,20 @@ // Try to simplify some other binary operator values. } else if (BinaryOperator *BO = dyn_cast(I)) { + assert(Preference != WantBlockAddress + && "A binary operator creating a block address?"); if (ConstantInt *CI = dyn_cast(BO->getOperand(1))) { PredValueInfoTy LHSVals; - ComputeValueKnownInPredecessors(BO->getOperand(0), BB, LHSVals); + ComputeValueKnownInPredecessors(BO->getOperand(0), BB, LHSVals, + WantInteger); // Try to use constant folding to simplify the binary operator. for (unsigned i = 0, e = LHSVals.size(); i != e; ++i) { Constant *V = LHSVals[i].first; Constant *Folded = ConstantExpr::get(BO->getOpcode(), V, CI); - PushKnownConstantOrUndef(Result, Folded, LHSVals[i].second); + if (Constant *KC = getKnownConstant(Folded, WantInteger)) + Result.push_back(std::make_pair(KC, LHSVals[i].second)); } } @@ -452,6 +469,7 @@ // Handle compare with phi operand, where the PHI is defined in this block. if (CmpInst *Cmp = dyn_cast(I)) { + assert(Preference == WantInteger && "Compares only produce integers"); PHINode *PN = dyn_cast(Cmp->getOperand(0)); if (PN && PN->getParent() == BB) { // We can do this simplification if any comparisons fold to true or false. @@ -474,8 +492,8 @@ Res = ConstantInt::get(Type::getInt1Ty(LHS->getContext()), ResT); } - if (Constant *ConstRes = dyn_cast(Res)) - PushKnownConstantOrUndef(Result, ConstRes, PredBB); + if (Constant *KC = getKnownConstant(Res, WantInteger)) + Result.push_back(std::make_pair(KC, PredBB)); } return !Result.empty(); @@ -510,13 +528,15 @@ // and evaluate it statically if we can. if (Constant *CmpConst = dyn_cast(Cmp->getOperand(1))) { PredValueInfoTy LHSVals; - ComputeValueKnownInPredecessors(I->getOperand(0), BB, LHSVals); + ComputeValueKnownInPredecessors(I->getOperand(0), BB, LHSVals, + WantInteger); for (unsigned i = 0, e = LHSVals.size(); i != e; ++i) { Constant *V = LHSVals[i].first; Constant *Folded = ConstantExpr::getCompare(Cmp->getPredicate(), V, CmpConst); - PushKnownConstantOrUndef(Result, Folded, LHSVals[i].second); + if (Constant *KC = getKnownConstant(Folded, WantInteger)) + Result.push_back(std::make_pair(KC, LHSVals[i].second)); } return !Result.empty(); @@ -526,7 +546,7 @@ // If all else fails, see if LVI can figure out a constant value for us. Constant *CI = LVI->getConstant(V, BB); - if (Constant *KC = getKnownConstant(CI)) { + if (Constant *KC = getKnownConstant(CI, Preference)) { for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) Result.push_back(std::make_pair(KC, *PI)); } @@ -590,17 +610,25 @@ } } - // Look to see if the terminator is a branch of switch, if not we can't thread - // it. + // What kind of constant we're looking for. + ConstantPreference Preference = WantInteger; + + // Look to see if the terminator is a conditional branch, switch or indirect + // branch, if not we can't thread it. Value *Condition; - if (BranchInst *BI = dyn_cast(BB->getTerminator())) { + Instruction *Terminator = BB->getTerminator(); + if (BranchInst *BI = dyn_cast(Terminator)) { // Can't thread an unconditional jump. if (BI->isUnconditional()) return false; Condition = BI->getCondition(); - } else if (SwitchInst *SI = dyn_cast(BB->getTerminator())) + } else if (SwitchInst *SI = dyn_cast(Terminator)) { Condition = SI->getCondition(); - else + } else if (IndirectBrInst *IB = dyn_cast(Terminator)) { + Condition = IB->getAddress()->stripPointerCasts(); + Preference = WantBlockAddress; + } else { return false; // Must be an invoke. + } // If the terminator is branching on an undef, we can pick any of the // successors to branch to. Let GetBestDestForJumpOnUndef decide. @@ -624,7 +652,7 @@ // If the terminator of this block is branching on a constant, simplify the // terminator to an unconditional branch. This can occur due to threading in // other blocks. - if (getKnownConstant(Condition)) { + if (getKnownConstant(Condition, Preference)) { DEBUG(dbgs() << " In block '" << BB->getName() << "' folding terminator: " << *BB->getTerminator() << '\n'); ++NumFolds; @@ -637,7 +665,7 @@ // All the rest of our checks depend on the condition being an instruction. if (CondInst == 0) { // FIXME: Unify this with code below. - if (ProcessThreadableEdges(Condition, BB)) + if (ProcessThreadableEdges(Condition, BB, Preference)) return true; return false; } @@ -703,7 +731,7 @@ // a PHI node in the current block. If we can prove that any predecessors // compute a predictable value based on a PHI node, thread those predecessors. // - if (ProcessThreadableEdges(CondInst, BB)) + if (ProcessThreadableEdges(CondInst, BB, Preference)) return true; // If this is an otherwise-unfoldable branch on a phi node in the current @@ -1088,14 +1116,15 @@ return MostPopularDest; } -bool JumpThreading::ProcessThreadableEdges(Value *Cond, BasicBlock *BB) { +bool JumpThreading::ProcessThreadableEdges(Value *Cond, BasicBlock *BB, + ConstantPreference Preference) { // If threading this would thread across a loop header, don't even try to // thread the edge. if (LoopHeaders.count(BB)) return false; PredValueInfoTy PredValues; - if (!ComputeValueKnownInPredecessors(Cond, BB, PredValues)) + if (!ComputeValueKnownInPredecessors(Cond, BB, PredValues, Preference)) return false; assert(!PredValues.empty() && @@ -1135,9 +1164,12 @@ DestBB = 0; else if (BranchInst *BI = dyn_cast(BB->getTerminator())) DestBB = BI->getSuccessor(cast(Val)->isZero()); - else { - SwitchInst *SI = cast(BB->getTerminator()); + else if (SwitchInst *SI = dyn_cast(BB->getTerminator())) DestBB = SI->getSuccessor(SI->findCaseValue(cast(Val))); + else { + assert(isa(BB->getTerminator()) + && "Unexpected terminator"); + DestBB = cast(Val)->getBasicBlock(); } // If we have exactly one destination, remember it for efficiency below. @@ -1256,9 +1288,11 @@ PredValueInfoTy XorOpValues; bool isLHS = true; - if (!ComputeValueKnownInPredecessors(BO->getOperand(0), BB, XorOpValues)) { + if (!ComputeValueKnownInPredecessors(BO->getOperand(0), BB, XorOpValues, + WantInteger)) { assert(XorOpValues.empty()); - if (!ComputeValueKnownInPredecessors(BO->getOperand(1), BB, XorOpValues)) + if (!ComputeValueKnownInPredecessors(BO->getOperand(1), BB, XorOpValues, + WantInteger)) return false; isLHS = false; } Added: llvm/trunk/test/Transforms/JumpThreading/indirectbr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/indirectbr.ll?rev=121066&view=auto ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/indirectbr.ll (added) +++ llvm/trunk/test/Transforms/JumpThreading/indirectbr.ll Mon Dec 6 17:36:56 2010 @@ -0,0 +1,61 @@ +; RUN: opt -S < %s -jump-threading | FileCheck %s + +; Keep block addresses alive. + at addresses = constant [4 x i8*] [ + i8* blockaddress(@test1, %L1), i8* blockaddress(@test1, %L2), + i8* blockaddress(@test2, %L1), i8* blockaddress(@test2, %L2) +] + +declare void @bar() +declare void @baz() + + + +; Check basic jump threading for indirectbr instructions. + +; CHECK: void @test1 +; CHECK: br i1 %tobool, label %L1, label %indirectgoto +; CHECK-NOT: if.else: +; CHECK: L1: +; CHECK: indirectbr i8* %address, [label %L1, label %L2] +define void @test1(i32 %i, i8* %address) nounwind { +entry: + %rem = srem i32 %i, 2 + %tobool = icmp ne i32 %rem, 0 + br i1 %tobool, label %indirectgoto, label %if.else + +if.else: ; preds = %entry + br label %indirectgoto + +L1: ; preds = %indirectgoto + call void @bar() + ret void + +L2: ; preds = %indirectgoto + call void @baz() + ret void + +indirectgoto: ; preds = %if.else, %entry + %indirect.goto.dest = phi i8* [ %address, %if.else ], [ blockaddress(@test1, %L1), %entry ] + indirectbr i8* %indirect.goto.dest, [label %L1, label %L2] +} + + +; Check constant folding of indirectbr + +; CHECK: void @test2 +; CHECK-NEXT: : +; CHECK-NEXT: call void @bar +; CHECK-NEXT: ret void +define void @test2() nounwind { +entry: + indirectbr i8* blockaddress(@test2, %L1), [label %L1, label %L2] + +L1: ; preds = %indirectgoto + call void @bar() + ret void + +L2: ; preds = %indirectgoto + call void @baz() + ret void +} From aggarwa4 at illinois.edu Mon Dec 6 17:50:35 2010 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Mon, 06 Dec 2010 23:50:35 -0000 Subject: [llvm-commits] [poolalloc] r121067 - /poolalloc/trunk/lib/DSA/DataStructureStats.cpp Message-ID: <20101206235035.9A13D2A6C12C@llvm.org> Author: aggarwa4 Date: Mon Dec 6 17:50:35 2010 New Revision: 121067 URL: http://llvm.org/viewvc/llvm-project?rev=121067&view=rev Log: Also, measure number of load and store that access type unknown nodes. Modified: poolalloc/trunk/lib/DSA/DataStructureStats.cpp Modified: poolalloc/trunk/lib/DSA/DataStructureStats.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructureStats.cpp?rev=121067&r1=121066&r2=121067&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/DataStructureStats.cpp (original) +++ poolalloc/trunk/lib/DSA/DataStructureStats.cpp Mon Dec 6 17:50:35 2010 @@ -48,6 +48,8 @@ "Number of loads/stores which are on incomplete nodes"); STATISTIC (NumUnknownAccesses, "Number of loads/stores which are on unknown nodes"); + STATISTIC (NumExternalAccesses, + "Number of loads/stores which are on external nodes"); class DSGraphStats : public FunctionPass, public InstVisitor { void countCallees(const Function &F); @@ -157,6 +159,10 @@ ++NumIncompleteAccesses; return true; } + if ( N->isExternalNode()){ + ++NumExternalAccesses; + return true; + } if (N->isUnknownNode()){ ++NumUnknownAccesses; } From aggarwa4 at illinois.edu Mon Dec 6 17:54:08 2010 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Mon, 06 Dec 2010 23:54:08 -0000 Subject: [llvm-commits] [poolalloc] r121071 - in /poolalloc/trunk: include/dsa/DataStructure.h lib/DSA/BottomUpClosure.cpp Message-ID: <20101206235408.DB0492A6C12C@llvm.org> Author: aggarwa4 Date: Mon Dec 6 17:54:08 2010 New Revision: 121071 URL: http://llvm.org/viewvc/llvm-project?rev=121071&view=rev Log: DSA no longer uses Entry Point Analysis. Remove dependency. Modified: poolalloc/trunk/include/dsa/DataStructure.h poolalloc/trunk/lib/DSA/BottomUpClosure.cpp Modified: poolalloc/trunk/include/dsa/DataStructure.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DataStructure.h?rev=121071&r1=121070&r2=121071&view=diff ============================================================================== --- poolalloc/trunk/include/dsa/DataStructure.h (original) +++ poolalloc/trunk/include/dsa/DataStructure.h Mon Dec 6 17:54:08 2010 @@ -19,7 +19,6 @@ #include "llvm/Support/CallSite.h" #include "llvm/ADT/EquivalenceClasses.h" -#include "dsa/EntryPointAnalysis.h" #include "dsa/DSCallGraph.h" #include "dsa/svset.h" #include "dsa/super_set.h" @@ -206,7 +205,6 @@ /// virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); - AU.addPreserved(); AU.setPreservesCFG(); } }; @@ -220,7 +218,6 @@ const char* debugname; - EntryPointAnalysis* EP; // filterCallees -- Whether or not we filter out illegal callees // from the CallGraph. This is useful while doing original BU, @@ -242,8 +239,6 @@ virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); - AU.addRequired(); - AU.addPreserved(); AU.setPreservesCFG(); } @@ -292,8 +287,6 @@ virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); - AU.addRequired (); - AU.addPreserved(); AU.setPreservesCFG(); } @@ -317,7 +310,6 @@ virtual bool runOnModule(Module &M); virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.addRequired(); AU.addRequired(); AU.setPreservesCFG(); } Modified: poolalloc/trunk/lib/DSA/BottomUpClosure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/BottomUpClosure.cpp?rev=121071&r1=121070&r2=121071&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/BottomUpClosure.cpp (original) +++ poolalloc/trunk/lib/DSA/BottomUpClosure.cpp Mon Dec 6 17:54:08 2010 @@ -44,7 +44,6 @@ // bool BUDataStructures::runOnModule(Module &M) { init(&getAnalysis(), false, true, false, false ); - //EP = &getAnalysis(); return runOnModuleInternal(M); } @@ -81,13 +80,6 @@ // postOrderInline (M); -#if 0 - //DSA does not use entryPoint analysis - std::vector EntryPoints; - EP = &getAnalysis(); - EP->findEntryPoints(M, EntryPoints); -#endif - // At the end of the bottom-up pass, the globals graph becomes complete. // FIXME: This is not the right way to do this, but it is sorta better than // nothing! In particular, externally visible globals and unresolvable call From grosbach at apple.com Mon Dec 6 17:57:07 2010 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 06 Dec 2010 23:57:07 -0000 Subject: [llvm-commits] [llvm] r121072 - in /llvm/trunk: lib/MC/ELFObjectWriter.cpp lib/Target/ARM/ARMAsmBackend.cpp lib/Target/ARM/ARMCodeEmitter.cpp lib/Target/ARM/ARMFixupKinds.h lib/Target/ARM/ARMInstrThumb.td lib/Target/ARM/ARMMCCodeEmitter.cpp utils/TableGen/EDEmitter.cpp Message-ID: <20101206235708.017652A6C12C@llvm.org> Author: grosbach Date: Mon Dec 6 17:57:07 2010 New Revision: 121072 URL: http://llvm.org/viewvc/llvm-project?rev=121072&view=rev Log: Add fixup for Thumb1 BL/BLX instructions. Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp llvm/trunk/lib/Target/ARM/ARMFixupKinds.h llvm/trunk/lib/Target/ARM/ARMInstrThumb.td llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp llvm/trunk/utils/TableGen/EDEmitter.cpp Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=121072&r1=121071&r2=121072&view=diff ============================================================================== --- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Mon Dec 6 17:57:07 2010 @@ -1546,6 +1546,7 @@ case ARM::fixup_arm_ldst_pcrel_12: case ARM::fixup_arm_pcrel_10: case ARM::fixup_arm_adr_pcrel_12: + case ARM::fixup_arm_thumb_bl: assert(0 && "Unimplemented"); break; case ARM::fixup_arm_branch: return ELF::R_ARM_CALL; break; Modified: llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp?rev=121072&r1=121071&r2=121072&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Mon Dec 6 17:57:07 2010 @@ -103,7 +103,18 @@ case ARM::fixup_arm_branch: // These values don't encode the low two bits since they're always zero. // Offset by 8 just as above. - return 0xFFFFFF & ((Value - 8) >> 2); + return 0xffffff & ((Value - 8) >> 2); + case ARM::fixup_arm_thumb_bl: { + // The value doesn't encode the low bit (always zero) and is offset by + // four. The value is encoded into disjoint bit positions in the destination + // opcode. x = unchanged, I = immediate value bit, S = sign extension bit + // xxxxxSIIIIIIIIII xxxxxIIIIIIIIIII + // Note that the halfwords are stored high first, low second; so we need + // to transpose the fixup value here to map properly. + uint32_t Binary = 0x3fffff & ((Value - 4) >> 1); + Binary = ((Binary & 0x7ff) << 16) | (Binary >> 11); + return Binary; + } case ARM::fixup_arm_pcrel_10: { // Offset by 8 just as above. Value = Value - 8; @@ -198,12 +209,17 @@ static unsigned getFixupKindNumBytes(unsigned Kind) { switch (Kind) { - default: llvm_unreachable("Unknown fixup kind!"); - case FK_Data_4: return 4; - case ARM::fixup_arm_ldst_pcrel_12: return 3; - case ARM::fixup_arm_pcrel_10: return 3; - case ARM::fixup_arm_adr_pcrel_12: return 3; - case ARM::fixup_arm_branch: return 3; + default: + llvm_unreachable("Unknown fixup kind!"); + case FK_Data_4: + return 4; + case ARM::fixup_arm_ldst_pcrel_12: + case ARM::fixup_arm_pcrel_10: + case ARM::fixup_arm_adr_pcrel_12: + case ARM::fixup_arm_branch: + return 3; + case ARM::fixup_arm_thumb_bl: + return 4; } } Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp?rev=121072&r1=121071&r2=121072&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Mon Dec 6 17:57:07 2010 @@ -171,6 +171,8 @@ const { return 0; } unsigned getAdrLabelOpValue(const MachineInstr &MI, unsigned Op) const { return 0; } + unsigned getThumbBLTargetOpValue(const MachineInstr &MI, unsigned Op) + const { return 0; } unsigned getBranchTargetOpValue(const MachineInstr &MI, unsigned Op) const { return 0; } unsigned getCCOutOpValue(const MachineInstr &MI, unsigned Op) Modified: llvm/trunk/lib/Target/ARM/ARMFixupKinds.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFixupKinds.h?rev=121072&r1=121071&r2=121072&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMFixupKinds.h (original) +++ llvm/trunk/lib/Target/ARM/ARMFixupKinds.h Mon Dec 6 17:57:07 2010 @@ -25,9 +25,11 @@ // fixup_arm_adr_pcrel_12 - 12-bit PC relative relocation for the ADR // instruction. fixup_arm_adr_pcrel_12, - // fixup_arm_brnach - 24-bit PC relative relocation for direct branch + // fixup_arm_branch - 24-bit PC relative relocation for direct branch // instructions. fixup_arm_branch, + // fixup_arm_thumb_bl - Fixup for Thumb BL/BLX instructions. + fixup_arm_thumb_bl, // The next two are for the movt/movw pair // the 16bit imm field are split into imm{15-12} and imm{11-0} Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=121072&r1=121071&r2=121072&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Mon Dec 6 17:57:07 2010 @@ -74,6 +74,10 @@ // Define Thumb specific addressing modes. +def t_bltarget : Operand { + let EncoderMethod = "getThumbBLTargetOpValue"; +} + def MemModeThumbAsmOperand : AsmOperandClass { let Name = "MemModeThumb"; let SuperClasses = []; @@ -366,22 +370,29 @@ Uses = [SP] in { // Also used for Thumb2 def tBL : TIx2<0b11110, 0b11, 1, - (outs), (ins i32imm:$func, variable_ops), IIC_Br, + (outs), (ins t_bltarget:$func, variable_ops), IIC_Br, "bl\t$func", [(ARMtcall tglobaladdr:$func)]>, Requires<[IsThumb, IsNotDarwin]> { + bits<21> func; + let Inst{25-16} = func{20-11}; let Inst{13} = 1; let Inst{11} = 1; + let Inst{10-0} = func{10-0}; } // ARMv5T and above, also used for Thumb2 def tBLXi : TIx2<0b11110, 0b11, 0, - (outs), (ins i32imm:$func, variable_ops), IIC_Br, + (outs), (ins t_bltarget:$func, variable_ops), IIC_Br, "blx\t$func", [(ARMcall tglobaladdr:$func)]>, Requires<[IsThumb, HasV5T, IsNotDarwin]> { + bits<21> func; + let Inst{25-16} = func{20-11}; let Inst{13} = 1; let Inst{11} = 1; + let Inst{10-1} = func{10-1}; + let Inst{0} = 0; // func{0} is assumed zero } // Also used for Thumb2 @@ -412,23 +423,29 @@ Uses = [R7, SP] in { // Also used for Thumb2 def tBLr9 : TIx2<0b11110, 0b11, 1, - (outs), (ins pred:$p, i32imm:$func, variable_ops), IIC_Br, - "bl${p}\t$func", + (outs), (ins pred:$p, t_bltarget:$func, variable_ops), + IIC_Br, "bl${p}\t$func", [(ARMtcall tglobaladdr:$func)]>, Requires<[IsThumb, IsDarwin]> { - let Inst{13} = 1; - let Inst{11} = 1; + bits<21> func; + let Inst{25-16} = func{20-11}; + let Inst{13} = 1; + let Inst{11} = 1; + let Inst{10-0} = func{10-0}; } // ARMv5T and above, also used for Thumb2 def tBLXi_r9 : TIx2<0b11110, 0b11, 0, - (outs), (ins pred:$p, i32imm:$func, variable_ops), - IIC_Br, - "blx${p}\t$func", + (outs), (ins pred:$p, t_bltarget:$func, variable_ops), + IIC_Br, "blx${p}\t$func", [(ARMcall tglobaladdr:$func)]>, Requires<[IsThumb, HasV5T, IsDarwin]> { + bits<21> func; + let Inst{25-16} = func{20-11}; let Inst{13} = 1; let Inst{11} = 1; + let Inst{10-1} = func{10-1}; + let Inst{0} = 0; // func{0} is assumed zero } // Also used for Thumb2 Modified: llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp?rev=121072&r1=121071&r2=121072&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp Mon Dec 6 17:57:07 2010 @@ -50,6 +50,7 @@ { "fixup_arm_pcrel_10", 1, 24, MCFixupKindInfo::FKF_IsPCRel }, { "fixup_arm_adr_pcrel_12", 1, 24, MCFixupKindInfo::FKF_IsPCRel }, { "fixup_arm_branch", 1, 24, MCFixupKindInfo::FKF_IsPCRel }, + { "fixup_arm_thumb_bl", 0, 32, MCFixupKindInfo::FKF_IsPCRel }, { "fixup_arm_movt_hi16", 0, 16, 0 }, { "fixup_arm_movw_lo16", 0, 16, 0 }, }; @@ -81,6 +82,11 @@ unsigned &Reg, unsigned &Imm, SmallVectorImpl &Fixups) const; + /// getThumbBLTargetOpValue - Return encoding info for Thumb immediate + /// branch target. + uint32_t getThumbBLTargetOpValue(const MCInst &MI, unsigned OpIdx, + SmallVectorImpl &Fixups) const; + /// getBranchTargetOpValue - Return encoding info for 24-bit immediate /// branch target. uint32_t getBranchTargetOpValue(const MCInst &MI, unsigned OpIdx, @@ -395,6 +401,24 @@ return isAdd; } +/// getThumbBLTargetOpValue - Return encoding info for immediate +/// branch target. +uint32_t ARMMCCodeEmitter:: +getThumbBLTargetOpValue(const MCInst &MI, unsigned OpIdx, + SmallVectorImpl &Fixups) const { + const MCOperand &MO = MI.getOperand(OpIdx); + + // If the destination is an immediate, we have nothing to do. + if (MO.isImm()) return MO.getImm(); + assert (MO.isExpr() && "Unexpected branch target type!"); + const MCExpr *Expr = MO.getExpr(); + MCFixupKind Kind = MCFixupKind(ARM::fixup_arm_thumb_bl); + Fixups.push_back(MCFixup::Create(0, Expr, Kind)); + + // All of the information is in the fixup. + return 0; +} + /// getBranchTargetOpValue - Return encoding info for 24-bit immediate /// branch target. uint32_t ARMMCCodeEmitter:: Modified: llvm/trunk/utils/TableGen/EDEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/EDEmitter.cpp?rev=121072&r1=121071&r2=121072&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/EDEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/EDEmitter.cpp Mon Dec 6 17:57:07 2010 @@ -587,6 +587,7 @@ IMM("neon_vcvt_imm32"); MISC("brtarget", "kOperandTypeARMBranchTarget"); // ? + MISC("t_bltarget", "kOperandTypeARMBranchTarget"); // ? MISC("bltarget", "kOperandTypeARMBranchTarget"); // ? MISC("so_reg", "kOperandTypeARMSoReg"); // R, R, I MISC("shift_so_reg", "kOperandTypeARMSoReg"); // R, R, I From rafael.espindola at gmail.com Mon Dec 6 18:27:37 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 07 Dec 2010 00:27:37 -0000 Subject: [llvm-commits] [llvm] r121076 - in /llvm/trunk: include/llvm/MC/MCAsmLayout.h include/llvm/MC/MCAssembler.h include/llvm/MC/MCExpr.h include/llvm/MC/MCObjectStreamer.h include/llvm/MC/MCObjectWriter.h lib/MC/ELFObjectWriter.cpp lib/MC/MCAssembler.cpp lib/MC/MCELFStreamer.cpp lib/MC/MCExpr.cpp lib/MC/MCMachOStreamer.cpp lib/MC/MCObjectStreamer.cpp lib/MC/MCPureStreamer.cpp lib/MC/MachObjectWriter.cpp lib/MC/WinCOFFObjectWriter.cpp lib/MC/WinCOFFStreamer.cpp Message-ID: <20101207002737.4093F2A6C12C@llvm.org> Author: rafael Date: Mon Dec 6 18:27:36 2010 New Revision: 121076 URL: http://llvm.org/viewvc/llvm-project?rev=121076&view=rev Log: Sorry for such a large commit. The summary is that only MachO cares about the actuall addresses in a .o file, so it is better to let the MachO writer compute it. This is good for two reasons. First, areas that shouldn't care about addresses now don't have access to it. Second, the layout of each section is independent. I should use this in a subsequent commit to speed it up. Most of the patch is just removing the section address computation. The two interesting parts are the change on how we handle padding in the end of sections and how MachO can get the address of a-b when a and b are in different sections. Since now the expression evaluation normally doesn't know the section address, it will think that a-b needs relocation and let the MachO writer know. Once it has computed the section addresses, it calls back the expression evaluation with the section addresses to resolve these expressions. The remaining problem is the handling of padding. Currently it will create a special alignment fragment at the end. Since that fragment doesn't update the alignment of the section, it needs the real address to be computed. Since now the layout will not compute a-b with a and b in different sections, the only effect that the special alignment fragment has is update the address size of the section. This can also be done by the MachO writer. Modified: llvm/trunk/include/llvm/MC/MCAsmLayout.h llvm/trunk/include/llvm/MC/MCAssembler.h llvm/trunk/include/llvm/MC/MCExpr.h llvm/trunk/include/llvm/MC/MCObjectStreamer.h llvm/trunk/include/llvm/MC/MCObjectWriter.h llvm/trunk/lib/MC/ELFObjectWriter.cpp llvm/trunk/lib/MC/MCAssembler.cpp llvm/trunk/lib/MC/MCELFStreamer.cpp llvm/trunk/lib/MC/MCExpr.cpp llvm/trunk/lib/MC/MCMachOStreamer.cpp llvm/trunk/lib/MC/MCObjectStreamer.cpp llvm/trunk/lib/MC/MCPureStreamer.cpp llvm/trunk/lib/MC/MachObjectWriter.cpp llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp llvm/trunk/lib/MC/WinCOFFStreamer.cpp Modified: llvm/trunk/include/llvm/MC/MCAsmLayout.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmLayout.h?rev=121076&r1=121075&r2=121076&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAsmLayout.h (original) +++ llvm/trunk/include/llvm/MC/MCAsmLayout.h Mon Dec 6 18:27:36 2010 @@ -66,11 +66,6 @@ /// been initialized. void LayoutFragment(MCFragment *Fragment); - /// \brief Performs initial layout for a single section, assuming that the - /// previous section (including its fragments) has already been layed out - /// correctly. - void LayoutSection(MCSectionData *SD); - /// @name Section Access (in layout order) /// @{ @@ -93,20 +88,9 @@ uint64_t getFragmentOffset(const MCFragment *F) const; /// @} - /// @name Section Layout Data - /// @{ - - /// \brief Get the computed address of the given section. - uint64_t getSectionAddress(const MCSectionData *SD) const; - - /// @} /// @name Utility Functions /// @{ - /// \brief Get the address of the given fragment, as computed in the current - /// layout. - uint64_t getFragmentAddress(const MCFragment *F) const; - /// \brief Get the address space size of the given section, as it effects /// layout. This may differ from the size reported by \see getSectionSize() by /// not including section tail padding. @@ -116,13 +100,6 @@ /// file. This may include additional padding, or be 0 for virtual sections. uint64_t getSectionFileSize(const MCSectionData *SD) const; - /// \brief Get the logical data size of the given section. - uint64_t getSectionSize(const MCSectionData *SD) const; - - /// \brief Get the address of the given symbol, as computed in the current - /// layout. - uint64_t getSymbolAddress(const MCSymbolData *SD) const; - /// \brief Get the offset of the given symbol, as computed in the current /// layout. uint64_t getSymbolOffset(const MCSymbolData *SD) const; Modified: llvm/trunk/include/llvm/MC/MCAssembler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAssembler.h?rev=121076&r1=121075&r2=121076&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAssembler.h (original) +++ llvm/trunk/include/llvm/MC/MCAssembler.h Mon Dec 6 18:27:36 2010 @@ -236,19 +236,12 @@ /// target dependent. bool EmitNops : 1; - /// OnlyAlignAddress - Flag to indicate that this align is only used to adjust - /// the address space size of a section and that it should not be included as - /// part of the section size. This flag can only be used on the last fragment - /// in a section. - bool OnlyAlignAddress : 1; - public: MCAlignFragment(unsigned _Alignment, int64_t _Value, unsigned _ValueSize, unsigned _MaxBytesToEmit, MCSectionData *SD = 0) : MCFragment(FT_Align, SD), Alignment(_Alignment), Value(_Value),ValueSize(_ValueSize), - MaxBytesToEmit(_MaxBytesToEmit), EmitNops(false), - OnlyAlignAddress(false) {} + MaxBytesToEmit(_MaxBytesToEmit), EmitNops(false) {} /// @name Accessors /// @{ @@ -264,9 +257,6 @@ bool hasEmitNops() const { return EmitNops; } void setEmitNops(bool Value) { EmitNops = Value; } - bool hasOnlyAlignAddress() const { return OnlyAlignAddress; } - void setOnlyAlignAddress(bool Value) { OnlyAlignAddress = Value; } - /// @} static bool classof(const MCFragment *F) { @@ -447,10 +437,6 @@ // // FIXME: This could all be kept private to the assembler implementation. - /// Address - The computed address of this section. This is ~0 until - /// initialized. - uint64_t Address; - /// HasInstructions - Whether this section has had instructions emitted into /// it. unsigned HasInstructions : 1; @@ -679,7 +665,6 @@ unsigned RelaxAll : 1; unsigned SubsectionsViaSymbols : 1; - unsigned PadSectionToAlignment : 1; private: /// Evaluate a fixup to a relocatable expression and the value which should be @@ -713,7 +698,6 @@ /// Compute the effective fragment size assuming it is layed out at the given /// \arg SectionAddress and \arg FragmentOffset. uint64_t ComputeFragmentSize(const MCFragment &F, - uint64_t SectionAddress, uint64_t FragmentOffset) const; /// LayoutOnce - Perform one layout iteration and return true if any offsets @@ -765,8 +749,7 @@ // option is to make this abstract, and have targets provide concrete // implementations as we do with AsmParser. MCAssembler(MCContext &_Context, TargetAsmBackend &_Backend, - MCCodeEmitter &_Emitter, bool _PadSectionToAlignment, - raw_ostream &OS); + MCCodeEmitter &_Emitter, raw_ostream &OS); ~MCAssembler(); MCContext &getContext() const { return Context; } Modified: llvm/trunk/include/llvm/MC/MCExpr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCExpr.h?rev=121076&r1=121075&r2=121076&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCExpr.h (original) +++ llvm/trunk/include/llvm/MC/MCExpr.h Mon Dec 6 18:27:36 2010 @@ -10,6 +10,7 @@ #ifndef LLVM_MC_MCEXPR_H #define LLVM_MC_MCEXPR_H +#include "llvm/ADT/DenseMap.h" #include "llvm/Support/Casting.h" #include "llvm/Support/DataTypes.h" @@ -18,10 +19,12 @@ class MCAsmLayout; class MCAssembler; class MCContext; +class MCSectionData; class MCSymbol; class MCValue; class raw_ostream; class StringRef; +typedef DenseMap SectionAddrMap; /// MCExpr - Base class for the full range of assembler expressions which are /// needed for parsing. @@ -42,12 +45,14 @@ void operator=(const MCExpr&); // DO NOT IMPLEMENT bool EvaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm, - const MCAsmLayout *Layout) const; + const MCAsmLayout *Layout, + const SectionAddrMap *Addrs) const; protected: explicit MCExpr(ExprKind _Kind) : Kind(_Kind) {} bool EvaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, const MCAsmLayout *Layout, + const SectionAddrMap *Addrs, bool InSet) const; public: /// @name Accessors @@ -76,6 +81,8 @@ bool EvaluateAsAbsolute(int64_t &Res) const; bool EvaluateAsAbsolute(int64_t &Res, const MCAssembler &Asm) const; bool EvaluateAsAbsolute(int64_t &Res, const MCAsmLayout &Layout) const; + bool EvaluateAsAbsolute(int64_t &Res, const MCAsmLayout &Layout, + const SectionAddrMap &Addrs) const; /// EvaluateAsRelocatable - Try to evaluate the expression to a relocatable /// value, i.e. an expression of the fixed form (a - b + constant). Modified: llvm/trunk/include/llvm/MC/MCObjectStreamer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectStreamer.h?rev=121076&r1=121075&r2=121076&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCObjectStreamer.h (original) +++ llvm/trunk/include/llvm/MC/MCObjectStreamer.h Mon Dec 6 18:27:36 2010 @@ -37,8 +37,7 @@ protected: MCObjectStreamer(MCContext &Context, TargetAsmBackend &TAB, - raw_ostream &_OS, MCCodeEmitter *_Emitter, - bool _PadSectionToAlignment); + raw_ostream &_OS, MCCodeEmitter *_Emitter); ~MCObjectStreamer(); MCSectionData *getCurrentSectionData() const { Modified: llvm/trunk/include/llvm/MC/MCObjectWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectWriter.h?rev=121076&r1=121075&r2=121076&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCObjectWriter.h (original) +++ llvm/trunk/include/llvm/MC/MCObjectWriter.h Mon Dec 6 18:27:36 2010 @@ -62,7 +62,8 @@ /// /// This routine is called by the assembler after layout and relaxation is /// complete. - virtual void ExecutePostLayoutBinding(MCAssembler &Asm) = 0; + virtual void ExecutePostLayoutBinding(MCAssembler &Asm, + const MCAsmLayout &Layout) = 0; /// Record a relocation entry. /// Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=121076&r1=121075&r2=121076&view=diff ============================================================================== --- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Mon Dec 6 18:27:36 2010 @@ -325,7 +325,8 @@ virtual void CreateGroupSections(MCAssembler &Asm, MCAsmLayout &Layout, GroupMapTy &GroupMap, RevGroupMapTy &RevGroupMap); - virtual void ExecutePostLayoutBinding(MCAssembler &Asm); + virtual void ExecutePostLayoutBinding(MCAssembler &Asm, + const MCAsmLayout &Layout); virtual void WriteSecHdrEntry(uint32_t Name, uint32_t Type, uint64_t Flags, uint64_t Address, uint64_t Offset, @@ -557,7 +558,8 @@ return 0; } -void ELFObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm) { +void ELFObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm, + const MCAsmLayout &Layout) { // The presence of symbol versions causes undefined symbols and // versions declared with @@@ to be renamed. @@ -1365,11 +1367,11 @@ return Layout.getSectionFileSize(&SD); } -static uint64_t GetSectionSize(const MCAsmLayout &Layout, - const MCSectionData &SD) { +static uint64_t GetSectionAddressSize(const MCAsmLayout &Layout, + const MCSectionData &SD) { if (IsELFMetaDataSection(SD)) return DataSectionSize(SD); - return Layout.getSectionSize(&SD); + return Layout.getSectionAddressSize(&SD); } static void WriteDataSectionData(ELFObjectWriter *W, const MCSectionData &SD) { @@ -1479,7 +1481,7 @@ else GroupSymbolIndex = getSymbolIndexInSymbolTable(Asm, GroupMap[&Section]); - uint64_t Size = GetSectionSize(Layout, SD); + uint64_t Size = GetSectionAddressSize(Layout, SD); WriteSection(Asm, SectionIndexMap, GroupSymbolIndex, SectionOffsetMap[&Section], Size, Modified: llvm/trunk/lib/MC/MCAssembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=121076&r1=121075&r2=121076&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAssembler.cpp (original) +++ llvm/trunk/lib/MC/MCAssembler.cpp Mon Dec 6 18:27:36 2010 @@ -38,7 +38,6 @@ STATISTIC(ObjectBytes, "Number of emitted object file bytes"); STATISTIC(RelaxationSteps, "Number of assembler layout and relaxation steps"); STATISTIC(RelaxedInstructions, "Number of relaxed instructions"); -STATISTIC(SectionLayouts, "Number of section layouts"); } } @@ -113,11 +112,6 @@ } } -uint64_t MCAsmLayout::getFragmentAddress(const MCFragment *F) const { - assert(F->getParent() && "Missing section()!"); - return getSectionAddress(F->getParent()) + getFragmentOffset(F); -} - uint64_t MCAsmLayout::getFragmentEffectiveSize(const MCFragment *F) const { EnsureValid(F); assert(F->EffectiveSize != ~UINT64_C(0) && "Address not set!"); @@ -135,17 +129,6 @@ return getFragmentOffset(SD->getFragment()) + SD->getOffset(); } -uint64_t MCAsmLayout::getSymbolAddress(const MCSymbolData *SD) const { - assert(SD->getFragment() && "Invalid getAddress() on undefined symbol!"); - return getFragmentAddress(SD->getFragment()) + SD->getOffset(); -} - -uint64_t MCAsmLayout::getSectionAddress(const MCSectionData *SD) const { - EnsureValid(SD->begin()); - assert(SD->Address != ~UINT64_C(0) && "Address not set!"); - return SD->Address; -} - uint64_t MCAsmLayout::getSectionAddressSize(const MCSectionData *SD) const { // The size is the last fragment's end offset. const MCFragment &F = SD->getFragmentList().back(); @@ -161,17 +144,6 @@ return getSectionAddressSize(SD); } -uint64_t MCAsmLayout::getSectionSize(const MCSectionData *SD) const { - // The logical size is the address space size minus any tail padding. - uint64_t Size = getSectionAddressSize(SD); - const MCAlignFragment *AF = - dyn_cast(&(SD->getFragmentList().back())); - if (AF && AF->hasOnlyAlignAddress()) - Size -= getFragmentEffectiveSize(AF); - - return Size; -} - /* *** */ MCFragment::MCFragment() : Kind(FragmentType(~0)) { @@ -196,7 +168,6 @@ : Section(&_Section), Ordinal(~UINT32_C(0)), Alignment(1), - Address(~UINT64_C(0)), HasInstructions(false) { if (A) @@ -221,11 +192,9 @@ /* *** */ MCAssembler::MCAssembler(MCContext &_Context, TargetAsmBackend &_Backend, - MCCodeEmitter &_Emitter, bool _PadSectionToAlignment, - raw_ostream &_OS) + MCCodeEmitter &_Emitter, raw_ostream &_OS) : Context(_Context), Backend(_Backend), Emitter(_Emitter), - OS(_OS), RelaxAll(false), SubsectionsViaSymbols(false), - PadSectionToAlignment(_PadSectionToAlignment) + OS(_OS), RelaxAll(false), SubsectionsViaSymbols(false) { } @@ -285,14 +254,14 @@ if (const MCSymbolRefExpr *A = Target.getSymA()) { const MCSymbol &Sym = A->getSymbol().AliasedSymbol(); if (Sym.isDefined()) - Value += Layout.getSymbolAddress(&getSymbolData(Sym)); + Value += Layout.getSymbolOffset(&getSymbolData(Sym)); else IsResolved = false; } if (const MCSymbolRefExpr *B = Target.getSymB()) { const MCSymbol &Sym = B->getSymbol().AliasedSymbol(); if (Sym.isDefined()) - Value -= Layout.getSymbolAddress(&getSymbolData(Sym)); + Value -= Layout.getSymbolOffset(&getSymbolData(Sym)); else IsResolved = false; } @@ -301,13 +270,12 @@ IsResolved = Writer.IsFixupFullyResolved(*this, Target, IsPCRel, DF); if (IsPCRel) - Value -= Layout.getFragmentAddress(DF) + Fixup.getOffset(); + Value -= Layout.getFragmentOffset(DF) + Fixup.getOffset(); return IsResolved; } uint64_t MCAssembler::ComputeFragmentSize(const MCFragment &F, - uint64_t SectionAddress, uint64_t FragmentOffset) const { switch (F.getKind()) { case MCFragment::FT_Data: @@ -323,11 +291,7 @@ case MCFragment::FT_Align: { const MCAlignFragment &AF = cast(F); - assert((!AF.hasOnlyAlignAddress() || !AF.getNextNode()) && - "Invalid OnlyAlignAddress bit, not the last fragment!"); - - uint64_t Size = OffsetToAlignment(SectionAddress + FragmentOffset, - AF.getAlignment()); + uint64_t Size = OffsetToAlignment(FragmentOffset, AF.getAlignment()); // Honor MaxBytesToEmit. if (Size > AF.getMaxBytesToEmit()) @@ -351,8 +315,6 @@ // Initialize the first section and set the valid fragment layout point. All // actual layout computations are done lazily. LastValidFragment = 0; - if (!getSectionOrder().empty()) - getSectionOrder().front()->Address = 0; } void MCAsmLayout::LayoutFragment(MCFragment *F) { @@ -371,43 +333,14 @@ ++stats::FragmentLayouts; - // Compute the fragment start address. - uint64_t StartAddress = F->getParent()->Address; - uint64_t Address = StartAddress; + // Compute fragment offset and size. + uint64_t Offset = 0; if (Prev) - Address += Prev->Offset + Prev->EffectiveSize; + Offset += Prev->Offset + Prev->EffectiveSize; - // Compute fragment offset and size. - F->Offset = Address - StartAddress; - F->EffectiveSize = getAssembler().ComputeFragmentSize(*F, StartAddress, - F->Offset); + F->Offset = Offset; + F->EffectiveSize = getAssembler().ComputeFragmentSize(*F, F->Offset); LastValidFragment = F; - - // If this is the last fragment in a section, update the next section address. - if (!F->getNextNode()) { - unsigned NextIndex = F->getParent()->getLayoutOrder() + 1; - if (NextIndex != getSectionOrder().size()) - LayoutSection(getSectionOrder()[NextIndex]); - } -} - -void MCAsmLayout::LayoutSection(MCSectionData *SD) { - unsigned SectionOrderIndex = SD->getLayoutOrder(); - - ++stats::SectionLayouts; - - // Compute the section start address. - uint64_t StartAddress = 0; - if (SectionOrderIndex) { - MCSectionData *Prev = getSectionOrder()[SectionOrderIndex - 1]; - StartAddress = getSectionAddress(Prev) + getSectionAddressSize(Prev); - } - - // Honor the section alignment requirements. - StartAddress = RoundUpToAlignment(StartAddress, SD->getAlignment()); - - // Set the section address. - SD->Address = StartAddress; } /// WriteFragmentData - Write the \arg F data to the output file. @@ -566,7 +499,7 @@ ie = SD->end(); it != ie; ++it) WriteFragmentData(*this, Layout, *it, OW); - assert(OW->getStream().tell() - Start == Layout.getSectionFileSize(SD)); + assert(OW->getStream().tell() - Start == Layout.getSectionAddressSize(SD)); } @@ -594,29 +527,7 @@ // Create the layout object. MCAsmLayout Layout(*this); - // Insert additional align fragments for concrete sections to explicitly pad - // the previous section to match their alignment requirements. This is for - // 'gas' compatibility, it shouldn't strictly be necessary. - if (PadSectionToAlignment) { - for (unsigned i = 1, e = Layout.getSectionOrder().size(); i < e; ++i) { - MCSectionData *SD = Layout.getSectionOrder()[i]; - - // Ignore sections without alignment requirements. - unsigned Align = SD->getAlignment(); - if (Align <= 1) - continue; - - // Ignore virtual sections, they don't cause file size modifications. - if (SD->getSection().isVirtualSection()) - continue; - - // Otherwise, create a new align fragment at the end of the previous - // section. - MCAlignFragment *AF = new MCAlignFragment(Align, 0, 1, Align, - Layout.getSectionOrder()[i - 1]); - AF->setOnlyAlignAddress(true); - } - } + // Create dummy fragments and assign section ordinals. unsigned SectionIndex = 0; @@ -668,7 +579,7 @@ // Allow the object writer a chance to perform post-layout binding (for // example, to set the index fields in the symbol data). - Writer->ExecutePostLayoutBinding(*this); + Writer->ExecutePostLayoutBinding(*this, Layout); // Evaluate and apply the fixups, generating relocation entries as necessary. for (MCAssembler::iterator it = begin(), ie = end(); it != ie; ++it) { @@ -920,8 +831,6 @@ const MCAlignFragment *AF = cast(this); if (AF->hasEmitNops()) OS << " (emit nops)"; - if (AF->hasOnlyAlignAddress()) - OS << " (only align section)"; OS << "\n "; OS << " Alignment:" << AF->getAlignment() << " Value:" << AF->getValue() << " ValueSize:" << AF->getValueSize() @@ -991,8 +900,7 @@ raw_ostream &OS = llvm::errs(); OS << "dump(); Modified: llvm/trunk/lib/MC/MCELFStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELFStreamer.cpp?rev=121076&r1=121075&r2=121076&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCELFStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCELFStreamer.cpp Mon Dec 6 18:27:36 2010 @@ -71,7 +71,7 @@ public: MCELFStreamer(MCContext &Context, TargetAsmBackend &TAB, raw_ostream &OS, MCCodeEmitter *Emitter) - : MCObjectStreamer(Context, TAB, OS, Emitter, false) {} + : MCObjectStreamer(Context, TAB, OS, Emitter) {} ~MCELFStreamer() {} Modified: llvm/trunk/lib/MC/MCExpr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=121076&r1=121075&r2=121076&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCExpr.cpp (original) +++ llvm/trunk/lib/MC/MCExpr.cpp Mon Dec 6 18:27:36 2010 @@ -238,20 +238,27 @@ /* *** */ bool MCExpr::EvaluateAsAbsolute(int64_t &Res) const { - return EvaluateAsAbsolute(Res, 0, 0); + return EvaluateAsAbsolute(Res, 0, 0, 0); } bool MCExpr::EvaluateAsAbsolute(int64_t &Res, const MCAsmLayout &Layout) const { - return EvaluateAsAbsolute(Res, &Layout.getAssembler(), &Layout); + return EvaluateAsAbsolute(Res, &Layout.getAssembler(), &Layout, 0); +} + +bool MCExpr::EvaluateAsAbsolute(int64_t &Res, + const MCAsmLayout &Layout, + const SectionAddrMap &Addrs) const { + return EvaluateAsAbsolute(Res, &Layout.getAssembler(), &Layout, &Addrs); } bool MCExpr::EvaluateAsAbsolute(int64_t &Res, const MCAssembler &Asm) const { - return EvaluateAsAbsolute(Res, &Asm, 0); + return EvaluateAsAbsolute(Res, &Asm, 0, 0); } bool MCExpr::EvaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm, - const MCAsmLayout *Layout) const { + const MCAsmLayout *Layout, + const SectionAddrMap *Addrs) const { MCValue Value; // Fast path constants. @@ -260,7 +267,7 @@ return true; } - if (!EvaluateAsRelocatableImpl(Value, Asm, Layout, false) || + if (!EvaluateAsRelocatableImpl(Value, Asm, Layout, Addrs, Addrs) || !Value.isAbsolute()) { // EvaluateAsAbsolute is defined to return the "current value" of // the expression if we are given a Layout object, even in cases @@ -268,11 +275,11 @@ if (Layout) { Res = Value.getConstant(); if (Value.getSymA()) { - Res += Layout->getSymbolAddress( + Res += Layout->getSymbolOffset( &Layout->getAssembler().getSymbolData(Value.getSymA()->getSymbol())); } if (Value.getSymB()) { - Res -= Layout->getSymbolAddress( + Res -= Layout->getSymbolOffset( &Layout->getAssembler().getSymbolData(Value.getSymB()->getSymbol())); } } @@ -283,8 +290,9 @@ return true; } -static bool EvaluateSymbolicAdd(const MCAsmLayout *Layout, - const MCAssembler *Asm, +static bool EvaluateSymbolicAdd(const MCAssembler *Asm, + const MCAsmLayout *Layout, + const SectionAddrMap *Addrs, bool InSet, const MCValue &LHS,const MCSymbolRefExpr *RHS_A, const MCSymbolRefExpr *RHS_B, int64_t RHS_Cst, @@ -327,10 +335,19 @@ } if (Layout) { - Res = MCValue::get(+ Layout->getSymbolAddress(&AD) - - Layout->getSymbolAddress(&BD) - + LHS.getConstant() - + RHS_Cst); + const MCSectionData &SecA = *AD.getFragment()->getParent(); + const MCSectionData &SecB = *BD.getFragment()->getParent(); + int64_t Val = + Layout->getSymbolOffset(&AD) + - Layout->getSymbolOffset(&BD) + + LHS.getConstant() + + RHS_Cst; + if (&SecA != &SecB) { + if (!Addrs) + return false; + Val += Addrs->lookup(&SecA); + Val -= Addrs->lookup(&SecB); + } + Res = MCValue::get(Val); return true; } } @@ -344,14 +361,15 @@ const MCAsmLayout *Layout) const { if (Layout) return EvaluateAsRelocatableImpl(Res, &Layout->getAssembler(), Layout, - false); + 0, false); else - return EvaluateAsRelocatableImpl(Res, 0, 0, false); + return EvaluateAsRelocatableImpl(Res, 0, 0, 0, false); } bool MCExpr::EvaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, const MCAsmLayout *Layout, + const SectionAddrMap *Addrs, bool InSet) const { ++stats::MCExprEvaluate; @@ -371,6 +389,7 @@ if (Sym.isVariable() && SRE->getKind() == MCSymbolRefExpr::VK_None) { bool Ret = Sym.getVariableValue()->EvaluateAsRelocatableImpl(Res, Asm, Layout, + Addrs, true); // If we failed to simplify this to a constant, let the target // handle it. @@ -387,7 +406,7 @@ MCValue Value; if (!AUE->getSubExpr()->EvaluateAsRelocatableImpl(Value, Asm, Layout, - InSet)) + Addrs, InSet)) return false; switch (AUE->getOpcode()) { @@ -421,9 +440,9 @@ MCValue LHSValue, RHSValue; if (!ABE->getLHS()->EvaluateAsRelocatableImpl(LHSValue, Asm, Layout, - InSet) || + Addrs, InSet) || !ABE->getRHS()->EvaluateAsRelocatableImpl(RHSValue, Asm, Layout, - InSet)) + Addrs, InSet)) return false; // We only support a few operations on non-constant expressions, handle @@ -434,13 +453,13 @@ return false; case MCBinaryExpr::Sub: // Negate RHS and add. - return EvaluateSymbolicAdd(Layout, Asm, InSet, LHSValue, + return EvaluateSymbolicAdd(Asm, Layout, Addrs, InSet, LHSValue, RHSValue.getSymB(), RHSValue.getSymA(), -RHSValue.getConstant(), Res); case MCBinaryExpr::Add: - return EvaluateSymbolicAdd(Layout, Asm, InSet, LHSValue, + return EvaluateSymbolicAdd(Asm, Layout, Addrs, InSet, LHSValue, RHSValue.getSymA(), RHSValue.getSymB(), RHSValue.getConstant(), Res); Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=121076&r1=121075&r2=121076&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Mon Dec 6 18:27:36 2010 @@ -36,7 +36,7 @@ public: MCMachOStreamer(MCContext &Context, TargetAsmBackend &TAB, raw_ostream &OS, MCCodeEmitter *Emitter) - : MCObjectStreamer(Context, TAB, OS, Emitter, true) {} + : MCObjectStreamer(Context, TAB, OS, Emitter) {} /// @name MCStreamer Interface /// @{ Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=121076&r1=121075&r2=121076&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Mon Dec 6 18:27:36 2010 @@ -19,11 +19,9 @@ using namespace llvm; MCObjectStreamer::MCObjectStreamer(MCContext &Context, TargetAsmBackend &TAB, - raw_ostream &_OS, MCCodeEmitter *_Emitter, - bool _PadSectionToAlignment) + raw_ostream &_OS, MCCodeEmitter *_Emitter) : MCStreamer(Context), Assembler(new MCAssembler(Context, TAB, *_Emitter, - _PadSectionToAlignment, _OS)), CurSectionData(0) { Modified: llvm/trunk/lib/MC/MCPureStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCPureStreamer.cpp?rev=121076&r1=121075&r2=121076&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCPureStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCPureStreamer.cpp Mon Dec 6 18:27:36 2010 @@ -30,8 +30,7 @@ public: MCPureStreamer(MCContext &Context, TargetAsmBackend &TAB, raw_ostream &OS, MCCodeEmitter *Emitter) - : MCObjectStreamer(Context, TAB, OS, Emitter, - /*PadSectionToAlignment=*/true) {} + : MCObjectStreamer(Context, TAB, OS, Emitter) {} /// @name MCStreamer Interface /// @{ Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=121076&r1=121075&r2=121076&view=diff ============================================================================== --- llvm/trunk/lib/MC/MachObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/MachObjectWriter.cpp Mon Dec 6 18:27:36 2010 @@ -197,6 +197,34 @@ /// @} + SectionAddrMap SectionAddress; + uint64_t getSectionAddress(const MCSectionData* SD) const { + return SectionAddress.lookup(SD); + } + uint64_t getSymbolAddress(const MCSymbolData* SD, + const MCAsmLayout &Layout) const { + return getSectionAddress(SD->getFragment()->getParent()) + + Layout.getSymbolOffset(SD); + } + uint64_t getFragmentAddress(const MCFragment *Fragment, + const MCAsmLayout &Layout) const { + return getSectionAddress(Fragment->getParent()) + + Layout.getFragmentOffset(Fragment); + } + + uint64_t getPaddingSize(const MCSectionData *SD, + const MCAsmLayout &Layout) const { + uint64_t EndAddr = getSectionAddress(SD) + Layout.getSectionAddressSize(SD); + unsigned Next = SD->getLayoutOrder() + 1; + if (Next >= Layout.getSectionOrder().size()) + return 0; + + const MCSectionData &NextSD = *Layout.getSectionOrder()[Next]; + if (NextSD.getSection().isVirtualSection()) + return 0; + return OffsetToAlignment(EndAddr, NextSD.getAlignment()); + } + unsigned Is64Bit : 1; uint32_t CPUType; @@ -283,7 +311,7 @@ void WriteSection(const MCAssembler &Asm, const MCAsmLayout &Layout, const MCSectionData &SD, uint64_t FileOffset, uint64_t RelocationsStart, unsigned NumRelocations) { - uint64_t SectionSize = Layout.getSectionSize(&SD); + uint64_t SectionSize = Layout.getSectionAddressSize(&SD); // The offset is unused for virtual sections. if (SD.getSection().isVirtualSection()) { @@ -301,10 +329,10 @@ WriteBytes(Section.getSectionName(), 16); WriteBytes(Section.getSegmentName(), 16); if (Is64Bit) { - Write64(Layout.getSectionAddress(&SD)); // address + Write64(getSectionAddress(&SD)); // address Write64(SectionSize); // size } else { - Write32(Layout.getSectionAddress(&SD)); // address + Write32(getSectionAddress(&SD)); // address Write32(SectionSize); // size } Write32(FileOffset); @@ -413,7 +441,7 @@ if (Symbol.isAbsolute()) { Address = cast(Symbol.getVariableValue())->getValue(); } else { - Address = Layout.getSymbolAddress(&Data); + Address = getSymbolAddress(&Data, Layout); } } else if (Data.isCommon()) { // Common symbols are encoded with the size in the address @@ -473,7 +501,7 @@ uint32_t FixupOffset = Layout.getFragmentOffset(Fragment) + Fixup.getOffset(); uint32_t FixupAddress = - Layout.getFragmentAddress(Fragment) + Fixup.getOffset(); + getFragmentAddress(Fragment, Layout) + Fixup.getOffset(); int64_t Value = 0; unsigned Index = 0; unsigned IsExtern = 0; @@ -603,10 +631,21 @@ // The index is the section ordinal (1-based). Index = SD.getFragment()->getParent()->getOrdinal() + 1; IsExtern = 0; - Value += Layout.getSymbolAddress(&SD); + Value += getSymbolAddress(&SD, Layout); if (IsPCRel) Value -= FixupAddress + (1 << Log2Size); + } else if (Symbol->isVariable()) { + const MCExpr *Value = Symbol->getVariableValue(); + int64_t Res; + bool isAbs = Value->EvaluateAsAbsolute(Res, Layout, SectionAddress); + if (isAbs) { + FixedValue = Res; + return; + } else { + report_fatal_error("unsupported relocation of variable '" + + Symbol->getName() + "'"); + } } else { report_fatal_error("unsupported relocation of undefined symbol '" + Symbol->getName() + "'"); @@ -708,7 +747,9 @@ report_fatal_error("symbol '" + A->getName() + "' can not be undefined in a subtraction expression"); - uint32_t Value = Layout.getSymbolAddress(A_SD); + uint32_t Value = getSymbolAddress(A_SD, Layout); + uint64_t SecAddr = getSectionAddress(A_SD->getFragment()->getParent()); + FixedValue += SecAddr; uint32_t Value2 = 0; if (const MCSymbolRefExpr *B = Target.getSymB()) { @@ -725,7 +766,8 @@ // for pedantic compatibility with 'as'. Type = A_SD->isExternal() ? macho::RIT_Difference : macho::RIT_LocalDifference; - Value2 = Layout.getSymbolAddress(B_SD); + Value2 = getSymbolAddress(B_SD, Layout); + FixedValue -= getSectionAddress(B_SD->getFragment()->getParent()); } // Relocations are written out in reverse order, so the PAIR comes first. @@ -774,10 +816,10 @@ if (Target.getSymB()) { // If this is a subtraction then we're pcrel. uint32_t FixupAddress = - Layout.getFragmentAddress(Fragment) + Fixup.getOffset(); + getFragmentAddress(Fragment, Layout) + Fixup.getOffset(); MCSymbolData *SD_B = &Asm.getSymbolData(Target.getSymB()->getSymbol()); IsPCRel = 1; - FixedValue = (FixupAddress - Layout.getSymbolAddress(SD_B) + + FixedValue = (FixupAddress - getSymbolAddress(SD_B, Layout) + Target.getConstant()); FixedValue += 1ULL << Log2Size; } else { @@ -855,10 +897,13 @@ // compensate for the addend of the symbol address, if it was // undefined. This occurs with weak definitions, for example. if (!SD->Symbol->isUndefined()) - FixedValue -= Layout.getSymbolAddress(SD); + FixedValue -= getSymbolAddress(SD, Layout); } else { // The index is the section ordinal (1-based). Index = SD->getFragment()->getParent()->getOrdinal() + 1; + FixedValue += getSectionAddress(SD->getFragment()->getParent()); + if (IsPCRel) + FixedValue -= getSectionAddress(Fragment->getParent()); } Type = macho::RIT_Vanilla; @@ -1039,7 +1084,25 @@ StringTable += '\x00'; } - void ExecutePostLayoutBinding(MCAssembler &Asm) { + void computeSectionAddresses(const MCAssembler &Asm, + const MCAsmLayout &Layout) { + uint64_t StartAddress = 0; + const SmallVectorImpl &Order = Layout.getSectionOrder(); + for (int i = 0, n = Order.size(); i != n ; ++i) { + const MCSectionData *SD = Order[i]; + StartAddress = RoundUpToAlignment(StartAddress, SD->getAlignment()); + SectionAddress[SD] = StartAddress; + StartAddress += Layout.getSectionAddressSize(SD); + // Explicitly pad the section to match the alignment requirements of the + // following one. This is for 'gas' compatibility, it shouldn't + /// strictly be necessary. + StartAddress += getPaddingSize(SD, Layout); + } + } + + void ExecutePostLayoutBinding(MCAssembler &Asm, const MCAsmLayout &Layout) { + computeSectionAddresses(Asm, Layout); + // Create symbol data for any indirect symbols. BindIndirectSymbols(Asm); @@ -1113,9 +1176,10 @@ for (MCAssembler::const_iterator it = Asm.begin(), ie = Asm.end(); it != ie; ++it) { const MCSectionData &SD = *it; - uint64_t Address = Layout.getSectionAddress(&SD); - uint64_t Size = Layout.getSectionSize(&SD); + uint64_t Address = getSectionAddress(&SD); + uint64_t Size = Layout.getSectionAddressSize(&SD); uint64_t FileSize = Layout.getSectionFileSize(&SD); + FileSize += getPaddingSize(&SD, Layout); VMSize = std::max(VMSize, Address + Size); @@ -1144,7 +1208,7 @@ ie = Asm.end(); it != ie; ++it) { std::vector &Relocs = Relocations[it]; unsigned NumRelocs = Relocs.size(); - uint64_t SectionStart = SectionDataStart + Layout.getSectionAddress(it); + uint64_t SectionStart = SectionDataStart + getSectionAddress(it); WriteSection(Asm, Layout, *it, SectionStart, RelocTableEnd, NumRelocs); RelocTableEnd += NumRelocs * macho::RelocationInfoSize; } @@ -1185,9 +1249,14 @@ // Write the actual section data. for (MCAssembler::const_iterator it = Asm.begin(), - ie = Asm.end(); it != ie; ++it) + ie = Asm.end(); it != ie; ++it) { Asm.WriteSectionData(it, Layout, this); + uint64_t Pad = getPaddingSize(it, Layout); + for (unsigned int i = 0; i < Pad; ++i) + Write8(0); + } + // Write the extra padding. WriteZeros(SectionDataPadding); Modified: llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp?rev=121076&r1=121075&r2=121076&view=diff ============================================================================== --- llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp Mon Dec 6 18:27:36 2010 @@ -170,7 +170,7 @@ // MCObjectWriter interface implementation. - void ExecutePostLayoutBinding(MCAssembler &Asm); + void ExecutePostLayoutBinding(MCAssembler &Asm, const MCAsmLayout &Layout); void RecordRelocation(const MCAssembler &Asm, const MCAsmLayout &Layout, @@ -616,7 +616,8 @@ //////////////////////////////////////////////////////////////////////////////// // MCObjectWriter interface implementations -void WinCOFFObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm) { +void WinCOFFObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm, + const MCAsmLayout &Layout) { // "Define" each section & symbol. This creates section & symbol // entries in the staging area. @@ -753,7 +754,7 @@ for (sections::iterator i = Sections.begin(), e = Sections.end(); i != e; i++) { - if (Layout.getSectionSize((*i)->MCData) > 0) { + if (Layout.getSectionAddressSize((*i)->MCData) > 0) { MakeSectionReal(**i, ++Header.NumberOfSections); } else { (*i)->Number = -1; Modified: llvm/trunk/lib/MC/WinCOFFStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFStreamer.cpp?rev=121076&r1=121075&r2=121076&view=diff ============================================================================== --- llvm/trunk/lib/MC/WinCOFFStreamer.cpp (original) +++ llvm/trunk/lib/MC/WinCOFFStreamer.cpp Mon Dec 6 18:27:36 2010 @@ -124,7 +124,7 @@ TargetAsmBackend &TAB, MCCodeEmitter &CE, raw_ostream &OS) - : MCObjectStreamer(Context, TAB, OS, &CE, false) + : MCObjectStreamer(Context, TAB, OS, &CE) , CurSymbol(NULL) { } From dpatel at apple.com Mon Dec 6 18:33:43 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 07 Dec 2010 00:33:43 -0000 Subject: [llvm-commits] [llvm] r121078 - /llvm/trunk/tools/opt/opt.cpp Message-ID: <20101207003343.EA87E2A6C12C@llvm.org> Author: dpatel Date: Mon Dec 6 18:33:43 2010 New Revision: 121078 URL: http://llvm.org/viewvc/llvm-project?rev=121078&view=rev Log: Add a simple breakpoint location printer. This will be used by upcoming "debug info in optimized code" quality test harness to set breakpoints at "interesting" locations. Modified: llvm/trunk/tools/opt/opt.cpp Modified: llvm/trunk/tools/opt/opt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=121078&r1=121077&r2=121078&view=diff ============================================================================== --- llvm/trunk/tools/opt/opt.cpp (original) +++ llvm/trunk/tools/opt/opt.cpp Mon Dec 6 18:33:43 2010 @@ -18,6 +18,7 @@ #include "llvm/CallGraphSCCPass.h" #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/Assembly/PrintModulePass.h" +#include "llvm/Analysis/DebugInfo.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/RegionPass.h" @@ -128,6 +129,10 @@ static cl::opt AnalyzeOnly("analyze", cl::desc("Only perform analysis, no optimization")); +static cl::opt +PrintBreakpoints("print-breakpoints-for-testing", + cl::desc("Print select breakpoints location for testing")); + static cl::opt DefaultDataLayout("default-data-layout", cl::desc("data layout string to use if not specified by module"), @@ -334,6 +339,41 @@ }; char BasicBlockPassPrinter::ID = 0; + +struct BreakpointPrinter : public FunctionPass { + raw_ostream &Out; + static char ID; + + BreakpointPrinter(raw_ostream &out) + : FunctionPass(ID), Out(out) { + } + + virtual bool runOnFunction(Function &F) { + for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) { + BasicBlock::const_iterator BI = I->end(); + --BI; + do { + const Instruction *In = BI; + const DebugLoc DL = In->getDebugLoc(); + if (!DL.isUnknown()) { + DIScope S(DL.getScope(getGlobalContext())); + Out << S.getFilename() << " " << DL.getLine() << "\n"; + break; + } + --BI; + } while (BI != I->begin()); + break; + } + return false; + } + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + } +}; + +char BreakpointPrinter::ID = 0; + inline void addPass(PassManagerBase &PM, Pass *P) { // Add the pass to the pass manager... PM.add(P); @@ -509,6 +549,24 @@ FPasses->add(new TargetData(*TD)); } + if (PrintBreakpoints) { + // Default to standard output. + if (!Out) { + if (OutputFilename.empty()) + OutputFilename = "-"; + + std::string ErrorInfo; + Out.reset(new tool_output_file(OutputFilename.c_str(), ErrorInfo, + raw_fd_ostream::F_Binary)); + if (!ErrorInfo.empty()) { + errs() << ErrorInfo << '\n'; + return 1; + } + } + Passes.add(new BreakpointPrinter(Out->os())); + NoOutput = true; + } + // If the -strip-debug command line option was specified, add it. If // -std-compile-opts was also specified, it will handle StripDebug. if (StripDebug && !StandardCompileOpts) @@ -623,7 +681,7 @@ Passes.run(*M.get()); // Declare success. - if (!NoOutput) + if (!NoOutput || PrintBreakpoints) Out->keep(); return 0; From dpatel at apple.com Mon Dec 6 18:34:59 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 07 Dec 2010 00:34:59 -0000 Subject: [llvm-commits] [llvm] r121079 - in /llvm/trunk/utils: CollectDebugInfoUsingLLDB.py CompareDebugInfo.py Message-ID: <20101207003459.C001C2A6C12C@llvm.org> Author: dpatel Date: Mon Dec 6 18:34:59 2010 New Revision: 121079 URL: http://llvm.org/viewvc/llvm-project?rev=121079&view=rev Log: Add python scripts to extract debug info using LLDB and do comparison. Added: llvm/trunk/utils/CollectDebugInfoUsingLLDB.py (with props) llvm/trunk/utils/CompareDebugInfo.py (with props) Added: llvm/trunk/utils/CollectDebugInfoUsingLLDB.py URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/CollectDebugInfoUsingLLDB.py?rev=121079&view=auto ============================================================================== --- llvm/trunk/utils/CollectDebugInfoUsingLLDB.py (added) +++ llvm/trunk/utils/CollectDebugInfoUsingLLDB.py Mon Dec 6 18:34:59 2010 @@ -0,0 +1,143 @@ +#!/usr/bin/python + +#---------------------------------------------------------------------- +# Be sure to add the python path that points to the LLDB shared library. +# On MacOSX csh, tcsh: +# setenv PYTHONPATH /Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Python +# On MacOSX sh, bash: +# export PYTHONPATH=/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Python +#---------------------------------------------------------------------- + +import lldb +import os +import sys +import time + +def print_var_value (v, file, frame): + if v.GetNumChildren() > 0: + for c in range(v.GetNumChildren()): + if v.GetChildAtIndex(c) is None: + file.write("None") + else: + if (v.GetChildAtIndex(c).GetName()) is None: + file.write("None") + else: + file.write(v.GetChildAtIndex(c).GetName()) + file.write('=') + print_var_value(v.GetChildAtIndex(c), file, frame) + file.write(',') + else: + if v.GetValue(frame) is None: + file.write("None") + else: + file.write(v.GetValue(frame)) + + +def print_vars (vars, fname, line, file, frame, target, thread): + # disable this thread. + count = thread.GetStopReasonDataCount() + bid = 0 + tid = 0 + for i in range(count): + id = thread.GetStopReasonDataAtIndex(i) + bp = target.FindBreakpointByID(id) + if bp.IsValid(): + if bp.IsEnabled() == True: + bid = bp.GetID() + tid = bp.GetThreadID() + bp.SetEnabled(False) + else: + bp_loc = bp.FindLocationByID(thread.GetStopReasonDataAtIndex(i+1)) + if bp_loc.IsValid(): + bid = bp_loc.GetBreakPoint().GetID() + tid = bp_loc.ThreadGetID() + # print " { ", bp_loc.ThreadGetID(), " : ", bp_loc.GetBreakPoint().GetID(), " }} " + bp_loc.SetEnabled(False); + + for i in range(vars.GetSize()): + file.write("#Argument ") + file.write(fname) + file.write(':') + file.write(str(line)) + file.write(' ') + file.write(str(tid)) + file.write(':') + file.write(str(bid)) + file.write(' ') + v = vars.GetValueAtIndex(i) + file.write(v.GetName()) + file.write(' ') + print_var_value (v, file, frame) + file.write('\n') + +def set_breakpoints (target, breakpoint_filename): + f = open(breakpoint_filename, "r") + lines = f.readlines() + for l in range(len(lines)): + c = lines[l].split() + # print "setting break point - ", c + bp = target.BreakpointCreateByLocation (str(c[0]), int(c[1])) + f.close() + +def stop_at_breakpoint (process): + if process.IsValid(): + state = process.GetState() + if state != lldb.eStateStopped: + return lldb.eStateInvalid + thread = process.GetThreadAtIndex(0) + if thread.IsValid(): + if thread.GetStopReason() == lldb.eStopReasonBreakpoint: + return lldb.eStateStopped + else: + return lldb.eStateInvalid + else: + return lldb.eStateInvalid + else: + return lldb.eStateInvalid + +# Create a new debugger instance +debugger = lldb.SBDebugger.Create() + +# When we step or continue, don't return from the function until the process +# stops. We do this by setting the async mode to false. +debugger.SetAsync (False) + +# Create a target from a file and arch +##print "Creating a target for '%s'" % sys.argv[1] + +target = debugger.CreateTargetWithFileAndArch (sys.argv[1], lldb.LLDB_ARCH_DEFAULT) + +if target.IsValid(): + #print "target is valid" + set_breakpoints (target, sys.argv[2]) + #main_bp = target.BreakpointCreateByLocation ("byval-alignment.c", 11) + #main_bp2 = target.BreakpointCreateByLocation ("byval-alignment.c", 20) + + ##print main_bp + + # Launch the process. Since we specified synchronous mode, we won't return + # from this function until we hit the breakpoint at main + process = target.LaunchProcess ([''], [''], "/dev/stdout", 0, False) + file=open(str(sys.argv[3]), 'w') + # Make sure the launch went ok + while stop_at_breakpoint(process) == lldb.eStateStopped: + thread = process.GetThreadAtIndex (0) + frame = thread.GetFrameAtIndex (0) + if frame.IsValid(): + # #Print some simple frame info + ##print frame + #print "frame is valid" + function = frame.GetFunction() + if function.IsValid(): + fname = function.GetMangledName() + if fname is None: + fname = function.GetName() + #print "function : ",fname + vars = frame.GetVariables(1,0,0,0) + line = frame.GetLineEntry().GetLine() + print_vars (vars, fname, line, file, frame, target, thread) + #print vars + process.Continue() + file.close() + +lldb.SBDebugger.Terminate() Propchange: llvm/trunk/utils/CollectDebugInfoUsingLLDB.py ------------------------------------------------------------------------------ svn:executable = * Added: llvm/trunk/utils/CompareDebugInfo.py URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/CompareDebugInfo.py?rev=121079&view=auto ============================================================================== --- llvm/trunk/utils/CompareDebugInfo.py (added) +++ llvm/trunk/utils/CompareDebugInfo.py Mon Dec 6 18:34:59 2010 @@ -0,0 +1,64 @@ +#!/usr/bin/python + +import os +import sys + +class BreakPoint: + def __init__(self, bp_name): + self.name = bp_name + self.values = {} + + def recordArgument(self, arg_name, value): + self.values[arg_name] = value + + def __repr__(self): + print self.name + items = self.values.items() + for i in range(len(items)): + print items[i][0]," = ",items[i][1] + return '' + + def __cmp__(self, other): + return cmp(self.values, other.values) + +def read_input(filename, dict): + f = open(filename, "r") + lines = f.readlines() + for l in range(len(lines)): + c = lines[l].split() + if c[0] == "#Argument": + bp = dict.get(c[2]) + if bp is None: + bp = BreakPoint(c[1]) + dict[c[2]] = bp + bp.recordArgument(c[3], c[4]) + + f.close() + return + +f1_breakpoints = {} +read_input(sys.argv[1], f1_breakpoints) +f1_items = f1_breakpoints.items() + +f2_breakpoints = {} +read_input(sys.argv[2], f2_breakpoints) +f2_items = f2_breakpoints.items() + +mismatch = 0 +for f2bp in range(len(f2_items)): + id = f2_items[f2bp][0] + bp = f2_items[f2bp][1] + bp1 = f1_breakpoints.get(id) + if bp1 is None: + print "bp is missing" + else: + if bp1 != bp: + mismatch = mismatch + 1 + +l2 = len(f2_items) +print "==========" +if l2 != 0: + print sys.argv[3]," success rate is", (l2-mismatch)*100/l2,"%" +else: + print sys.argv[3]," success rate is 100%" +print "==========" Propchange: llvm/trunk/utils/CompareDebugInfo.py ------------------------------------------------------------------------------ svn:executable = * From dpatel at apple.com Mon Dec 6 18:35:56 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 07 Dec 2010 00:35:56 -0000 Subject: [llvm-commits] [test-suite] r121080 - in /test-suite/trunk: Makefile.rules SingleSource/Makefile.singlesrc TEST.dbg.Makefile Message-ID: <20101207003556.DB1042A6C12C@llvm.org> Author: dpatel Date: Mon Dec 6 18:35:56 2010 New Revision: 121080 URL: http://llvm.org/viewvc/llvm-project?rev=121080&view=rev Log: Add test harness to measure quality of debug info in optimized code. MultiSource support is not yet ready. Added: test-suite/trunk/TEST.dbg.Makefile Modified: test-suite/trunk/Makefile.rules test-suite/trunk/SingleSource/Makefile.singlesrc Modified: test-suite/trunk/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/Makefile.rules?rev=121080&r1=121079&r2=121080&view=diff ============================================================================== --- test-suite/trunk/Makefile.rules (original) +++ test-suite/trunk/Makefile.rules Mon Dec 6 18:35:56 2010 @@ -123,7 +123,7 @@ # which are marked as Phony. # .PHONY: all dynamic bytecodelib install-bytecode-library -.PHONY: clean distclean install test bytecode native prdirs +.PHONY: clean distclean install test bytecode native prdirs dbg ########################################################################### # Miscellaneous paths and commands: Modified: test-suite/trunk/SingleSource/Makefile.singlesrc URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Makefile.singlesrc?rev=121080&r1=121079&r2=121080&view=diff ============================================================================== --- test-suite/trunk/SingleSource/Makefile.singlesrc (original) +++ test-suite/trunk/SingleSource/Makefile.singlesrc Mon Dec 6 18:35:56 2010 @@ -85,6 +85,30 @@ Output/%.native: $(SourceDir)/%.mm Output/.dir -$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(OPTFLAGS) $(TARGET_FLAGS) $< -lm -o $@ $(LDFLAGS) +Output/%.dbg: $(SourceDir)/%.c Output/.dir + -$(LCC) -g $(CPPFLAGS) $(CFLAGS) $(TARGET_FLAGS) $< -lm -o $@ $(LDFLAGS) + +Output/%.dbg: $(SourceDir)/%.cpp Output/.dir + -$(LCXX) -g $(CPPFLAGS) $(CXXFLAGS) $(TARGET_FLAGS) $< -lm -o $@ $(LDFLAGS) + +Output/%.dbg: $(SourceDir)/%.m Output/.dir + -$(LCC) -g $(CPPFLAGS) $(CFLAGS) $(TARGET_FLAGS) $< -lm -o $@ $(LDFLAGS) + +Output/%.dbg: $(SourceDir)/%.mm Output/.dir + -$(LCXX) -g $(CPPFLAGS) $(CXXFLAGS) $(TARGET_FLAGS) $< -lm -o $@ $(LDFLAGS) + +Output/%.dbg.opt: $(SourceDir)/%.c Output/.dir + -$(LCC) -g $(CPPFLAGS) $(CFLAGS) $(OPTFLAGS) $(TARGET_FLAGS) $< -lm -o $@ $(LDFLAGS) + +Output/%.dbg.opt: $(SourceDir)/%.cpp Output/.dir + -$(LCXX) -g $(CPPFLAGS) $(CXXFLAGS) $(OPTFLAGS) $(TARGET_FLAGS) $< -lm -o $@ $(LDFLAGS) + +Output/%.dbg.opt: $(SourceDir)/%.m Output/.dir + -$(LCC) -g $(CPPFLAGS) $(CFLAGS) $(OPTFLAGS) $(TARGET_FLAGS) $< -lm -o $@ $(LDFLAGS) + +Output/%.dbg.opt: $(SourceDir)/%.mm Output/.dir + -$(LCXX) -g $(CPPFLAGS) $(CXXFLAGS) $(OPTFLAGS) $(TARGET_FLAGS) $< -lm -o $@ $(LDFLAGS) + bugpoint-gccas bugpoint-opt bugpoint-llvm-ld bugpoint-gccld bugpoint-jit bugpoint-llc bugpoint-llc-beta: @echo "The $@ target doesn't work in SingleSource. Try:" @echo " 'make Output/[programname].$@' instead." Added: test-suite/trunk/TEST.dbg.Makefile URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/TEST.dbg.Makefile?rev=121080&view=auto ============================================================================== --- test-suite/trunk/TEST.dbg.Makefile (added) +++ test-suite/trunk/TEST.dbg.Makefile Mon Dec 6 18:35:56 2010 @@ -0,0 +1,34 @@ +##===- TEST.dbg.Makefile ----------------------------------*- Makefile -*--===## +# +# This test is used to measure quality of debugging information. +# +##===----------------------------------------------------------------------===## + +#---------------------------------------------------------------------- +# Be sure to add the python path that points to the LLDB shared library. +# On MacOSX csh, tcsh: +# setenv PYTHONPATH /Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Python +# On MacOSX sh, bash: +# export PYTHONPATH=/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Python +#---------------------------------------------------------------------- + +CURDIR := $(shell cd .; pwd) +PROGDIR := $(PROJ_SRC_ROOT) +RELDIR := $(subst $(PROGDIR),,$(CURDIR)) + +REPORTS_TO_GEN := dbg +REPORTS_SUFFIX := $(addsuffix .report.txt, $(REPORTS_TO_GEN)) + +Output/%.bp: %.c Output/.dir + $(LCC) $(CPPFLAGS) $(CFLAGS) -g -c -emit-llvm $< -o $@.bc + $(LOPT) -print-breakpoints-for-testing $@.bc -o $@ + +$(PROGRAMS_TO_TEST:%=test.$(TEST).%): \ +test.$(TEST).%: Output/%.bp Output/%.dbg Output/%.dbg.opt + echo $@ + echo $* + mv *.dSYM Output/. + $(LLVM_SRC_ROOT)/utils/CollectDebugInfoUsingLLDB.py Output/$*.dbg Output/$*.bp Output/$*.dbg.out + $(LLVM_SRC_ROOT)/utils/CollectDebugInfoUsingLLDB.py Output/$*.dbg.opt Output/$*.bp Output/$*.dbg.opt.out + $(LLVM_SRC_ROOT)/utils/CompareDebugInfo.py Output/$*.dbg.out Output/$*.dbg.opt.out $* + From resistor at mac.com Mon Dec 6 18:45:21 2010 From: resistor at mac.com (Owen Anderson) Date: Tue, 07 Dec 2010 00:45:21 -0000 Subject: [llvm-commits] [llvm] r121082 - in /llvm/trunk: lib/Target/ARM/ARMConstantIslandPass.cpp lib/Target/ARM/ARMExpandPseudoInsts.cpp lib/Target/ARM/ARMInstrThumb2.td lib/Target/ARM/ARMMCCodeEmitter.cpp lib/Target/ARM/Disassembler/ARMDisassembler.cpp lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp lib/Target/ARM/Thumb2SizeReduction.cpp test/MC/Disassembler/ARM/thumb-tests.txt Message-ID: <20101207004522.0AFFE2A6C12C@llvm.org> Author: resistor Date: Mon Dec 6 18:45:21 2010 New Revision: 121082 URL: http://llvm.org/viewvc/llvm-project?rev=121082&view=rev Log: Second attempt at converting Thumb2's LDRpci, including updating the gazillion places that need to know about it. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=121082&r1=121081&r2=121082&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Mon Dec 6 18:45:21 2010 @@ -605,7 +605,11 @@ case ARM::LDRi12: case ARM::LDRcp: - case ARM::t2LDRpci: + case ARM::t2LDRi12: + case ARM::t2LDRHi12: + case ARM::t2LDRBi12: + case ARM::t2LDRSHi12: + case ARM::t2LDRSBi12: Bits = 12; // +-offset_12 NegOk = true; break; Modified: llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp?rev=121082&r1=121081&r2=121082&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp Mon Dec 6 18:45:21 2010 @@ -699,16 +699,48 @@ MI.eraseFromParent(); break; } + case ARM::t2LDRHpci: + case ARM::t2LDRBpci: + case ARM::t2LDRSHpci: + case ARM::t2LDRSBpci: + case ARM::t2LDRpci: { + unsigned NewLdOpc; + if (Opcode == ARM::t2LDRpci) + NewLdOpc = ARM::t2LDRi12; + else if (Opcode == ARM::t2LDRHpci) + NewLdOpc = ARM::t2LDRHi12; + else if (Opcode == ARM::t2LDRBpci) + NewLdOpc = ARM::t2LDRBi12; + else if (Opcode == ARM::t2LDRSHpci) + NewLdOpc = ARM::t2LDRSHi12; + else if (Opcode == ARM::t2LDRSBpci) + NewLdOpc = ARM::t2LDRSBi12; + else + llvm_unreachable("Not a known opcode?"); + + unsigned DstReg = MI.getOperand(0).getReg(); + MachineInstrBuilder MIB = + AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(), + TII->get(NewLdOpc), DstReg) + .addReg(ARM::PC) + .addOperand(MI.getOperand(1))); + (*MIB).setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); + TransferImpOps(MI, MIB, MIB); + MI.eraseFromParent(); + break; + } case ARM::tLDRpci_pic: case ARM::t2LDRpci_pic: { unsigned NewLdOpc = (Opcode == ARM::tLDRpci_pic) - ? ARM::tLDRpci : ARM::t2LDRpci; + ? ARM::tLDRpci : ARM::t2LDRi12; unsigned DstReg = MI.getOperand(0).getReg(); bool DstIsDead = MI.getOperand(0).isDead(); MachineInstrBuilder MIB1 = - AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(), - TII->get(NewLdOpc), DstReg) - .addOperand(MI.getOperand(1))); + BuildMI(MBB, MBBI, MI.getDebugLoc(), + TII->get(NewLdOpc), DstReg); + if (Opcode == ARM::t2LDRpci_pic) MIB1.addReg(ARM::PC); + MIB1.addOperand(MI.getOperand(1)); + AddDefaultPred(MIB1); (*MIB1).setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); MachineInstrBuilder MIB2 = BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(ARM::tPICADD)) Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=121082&r1=121081&r2=121082&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Mon Dec 6 18:45:21 2010 @@ -888,24 +888,8 @@ let Inst{5-4} = addr{1-0}; // imm } - // FIXME: Is the pci variant actually needed? - def pci : T2Ipc <(outs GPR:$Rt), (ins i32imm:$addr), iii, - opc, ".w\t$Rt, $addr", - [(set GPR:$Rt, (opnode (ARMWrapper tconstpool:$addr)))]> { - let isReMaterializable = 1; - let Inst{31-27} = 0b11111; - let Inst{26-25} = 0b00; - let Inst{24} = signed; - let Inst{23} = ?; // add = (U == '1') - let Inst{22-21} = opcod; - let Inst{20} = 1; // load - let Inst{19-16} = 0b1111; // Rn - - bits<4> Rt; - bits<12> addr; - let Inst{15-12} = Rt{3-0}; - let Inst{11-0} = addr{11-0}; - } + def pci : tPseudoInst<(outs GPR:$Rt), (ins i32imm:$addr), Size4Bytes, iis, + [(set GPR:$Rt, (opnode (ARMWrapper tconstpool:$addr)))]>; } /// T2I_st - Defines a set of (op r, {imm12|imm8|so_reg}) store patterns. Modified: llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp?rev=121082&r1=121081&r2=121082&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp Mon Dec 6 18:45:21 2010 @@ -462,13 +462,18 @@ bool isAdd = true; // If The first operand isn't a register, we have a label reference. const MCOperand &MO = MI.getOperand(OpIdx); - if (!MO.isReg()) { + const MCOperand &MO2 = MI.getOperand(OpIdx+1); + if (!MO.isReg() || (MO.getReg() == ARM::PC && MO2.isExpr())) { Reg = getARMRegisterNumbering(ARM::PC); // Rn is PC. Imm12 = 0; isAdd = false ; // 'U' bit is set as part of the fixup. - assert(MO.isExpr() && "Unexpected machine operand type!"); - const MCExpr *Expr = MO.getExpr(); + const MCExpr *Expr = 0; + if (!MO.isReg()) + Expr = MO.getExpr(); + else + Expr = MO2.getExpr(); + MCFixupKind Kind = MCFixupKind(ARM::fixup_arm_ldst_pcrel_12); Fixups.push_back(MCFixup::Create(0, Expr, Kind)); Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp?rev=121082&r1=121081&r2=121082&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp Mon Dec 6 18:45:21 2010 @@ -256,27 +256,27 @@ case ARM::t2LDR_POST: case ARM::t2LDR_PRE: case ARM::t2LDRi12: case ARM::t2LDRi8: case ARM::t2LDRs: case ARM::t2LDRT: - return ARM::t2LDRpci; + return ARM::t2LDRi12; case ARM::t2LDRB_POST: case ARM::t2LDRB_PRE: case ARM::t2LDRBi12: case ARM::t2LDRBi8: case ARM::t2LDRBs: case ARM::t2LDRBT: - return ARM::t2LDRBpci; + return ARM::t2LDRBi12; case ARM::t2LDRH_POST: case ARM::t2LDRH_PRE: case ARM::t2LDRHi12: case ARM::t2LDRHi8: case ARM::t2LDRHs: case ARM::t2LDRHT: - return ARM::t2LDRHpci; + return ARM::t2LDRHi12; case ARM::t2LDRSB_POST: case ARM::t2LDRSB_PRE: case ARM::t2LDRSBi12: case ARM::t2LDRSBi8: case ARM::t2LDRSBs: case ARM::t2LDRSBT: - return ARM::t2LDRSBpci; + return ARM::t2LDRSBi12; case ARM::t2LDRSH_POST: case ARM::t2LDRSH_PRE: case ARM::t2LDRSHi12: case ARM::t2LDRSHi8: case ARM::t2LDRSHs: case ARM::t2LDRSHT: - return ARM::t2LDRSHpci; + return ARM::t2LDRSHi12; } } Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h?rev=121082&r1=121081&r2=121082&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h Mon Dec 6 18:45:21 2010 @@ -1777,37 +1777,6 @@ return true; } -// A8.6.63 LDRB (literal) -// A8.6.79 LDRSB (literal) -// A8.6.75 LDRH (literal) -// A8.6.83 LDRSH (literal) -// A8.6.59 LDR (literal) -// -// These instrs calculate an address from the PC value and an immediate offset. -// Rd Rn=PC (+/-)imm12 (+ if Inst{23} == 0b1) -static bool DisassembleThumb2Ldpci(MCInst &MI, unsigned Opcode, - uint32_t insn, unsigned short NumOps, unsigned &NumOpsAdded, BO B) { - - const TargetOperandInfo *OpInfo = ARMInsts[Opcode].OpInfo; - if (!OpInfo) return false; - - assert(NumOps >= 2 && - OpInfo[0].RegClass == ARM::GPRRegClassID && - OpInfo[1].RegClass < 0 && - "Expect >= 2 operands, first as reg, and second as imm operand"); - - // Build the register operand, followed by the (+/-)imm12 immediate. - - MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::GPRRegClassID, - decodeRd(insn)))); - - MI.addOperand(MCOperand::CreateImm(decodeImm12(insn))); - - NumOpsAdded = 2; - - return true; -} - // A6.3.10 Store single data item // A6.3.9 Load byte, memory hints // A6.3.8 Load halfword, memory hints @@ -1843,10 +1812,6 @@ if (Thumb2PreloadOpcode(Opcode)) return DisassembleThumb2PreLoad(MI, Opcode, insn, NumOps, NumOpsAdded, B); - // See, for example, A6.3.7 Load word: Table A6-18 Load word. - if (Load && Rn == 15) - return DisassembleThumb2Ldpci(MI, Opcode, insn, NumOps, NumOpsAdded, B); - const TargetInstrDesc &TID = ARMInsts[Opcode]; const TargetOperandInfo *OpInfo = TID.OpInfo; unsigned &OpIdx = NumOpsAdded; Modified: llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp?rev=121082&r1=121081&r2=121082&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp Mon Dec 6 18:45:21 2010 @@ -560,6 +560,9 @@ if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right. printOperand(MI, OpNum, O); return; + } else if (MO1.getReg() == ARM::PC && MO2.isExpr()) { + printOperand(MI, OpNum+1, O); + return; } O << "[" << getRegisterName(MO1.getReg()); Modified: llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp?rev=121082&r1=121081&r2=121082&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp Mon Dec 6 18:45:21 2010 @@ -236,7 +236,7 @@ unsigned Opc = MI->getOpcode(); bool isPCOk = (Opc == ARM::t2LDMIA_RET || Opc == ARM::t2LDMIA || Opc == ARM::t2LDMDB || Opc == ARM::t2LDMIA_UPD || - Opc == ARM::t2LDMDB_UPD); + Opc == ARM::t2LDMDB_UPD || Opc == ARM::t2LDRi12); bool isLROk = (Opc == ARM::t2STMIA_UPD || Opc == ARM::t2STMDB_UPD); bool isSPOk = isPCOk || isLROk || (Opc == ARM::t2ADDrSPi); for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { @@ -270,10 +270,12 @@ return false; unsigned Scale = 1; + bool HasBaseReg = true; bool HasImmOffset = false; bool HasShift = false; bool HasOffReg = true; bool isLdStMul = false; + bool InsertImmOffset = true; unsigned Opc = Entry.NarrowOpc1; unsigned OpNum = 3; // First 'rest' of operands. uint8_t ImmLimit = Entry.Imm1Limit; @@ -290,17 +292,50 @@ HasOffReg = false; } Scale = 4; - HasImmOffset = true; + if (MI->getOperand(2).isImm()) + HasImmOffset = true; + else { + if (Entry.WideOpc == ARM::t2LDRi12) { + Opc = ARM::tLDRpci; + OpNum = 2; + } + HasImmOffset = false; + InsertImmOffset = false; + HasBaseReg = false; + HasOffReg = false; + } break; } case ARM::t2LDRBi12: case ARM::t2STRBi12: - HasImmOffset = true; + if (MI->getOperand(2).isImm()) + HasImmOffset = true; + else { + if (Entry.WideOpc == ARM::t2LDRBi12) { + Opc = ARM::tLDRpci; + OpNum = 2; + } + HasImmOffset = false; + InsertImmOffset = false; + HasBaseReg = false; + HasOffReg = false; + } break; case ARM::t2LDRHi12: case ARM::t2STRHi12: Scale = 2; - HasImmOffset = true; + if (MI->getOperand(2).isImm()) + HasImmOffset = true; + else { + if (Entry.WideOpc == ARM::t2LDRHi12) { + Opc = ARM::tLDRpci; + OpNum = 2; + } + HasImmOffset = false; + InsertImmOffset = false; + HasBaseReg = false; + HasOffReg = false; + } break; case ARM::t2LDRs: case ARM::t2LDRBs: @@ -388,8 +423,9 @@ DebugLoc dl = MI->getDebugLoc(); MachineInstrBuilder MIB = BuildMI(MBB, *MI, dl, TII->get(Opc)); if (!isLdStMul) { - MIB.addOperand(MI->getOperand(0)).addOperand(MI->getOperand(1)); - if (Opc != ARM::tLDRSB && Opc != ARM::tLDRSH) { + MIB.addOperand(MI->getOperand(0)); + if (HasBaseReg) MIB.addOperand(MI->getOperand(1)); + if (InsertImmOffset && Opc != ARM::tLDRSB && Opc != ARM::tLDRSH) { // tLDRSB and tLDRSH do not have an immediate offset field. On the other // hand, it must have an offset register. // FIXME: Remove this special case. Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt?rev=121082&r1=121081&r2=121082&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Mon Dec 6 18:45:21 2010 @@ -27,7 +27,7 @@ # CHECK: ldmia r0!, {r1} 0x02 0xc8 -# CHECK: ldrb.w r8, #-24 +# CHECK: ldrb.w r8, [pc, #-24] 0x1f 0xf8 0x18 0x80 # CHECK: ldrd r0, r1, [r7, #64]! From rafael.espindola at gmail.com Mon Dec 6 19:09:54 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 07 Dec 2010 01:09:54 -0000 Subject: [llvm-commits] [llvm] r121085 - in /llvm/trunk: lib/MC/MachObjectWriter.cpp test/MC/MachO/symbol-diff.s Message-ID: <20101207010954.835D42A6C12C@llvm.org> Author: rafael Date: Mon Dec 6 19:09:54 2010 New Revision: 121085 URL: http://llvm.org/viewvc/llvm-project?rev=121085&view=rev Log: Fix a crash reduced from gcc produced assembly. Added: llvm/trunk/test/MC/MachO/symbol-diff.s Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=121085&r1=121084&r2=121085&view=diff ============================================================================== --- llvm/trunk/lib/MC/MachObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/MachObjectWriter.cpp Mon Dec 6 19:09:54 2010 @@ -564,14 +564,10 @@ if (A_Base == B_Base && A_Base) report_fatal_error("unsupported relocation with identical base"); - assert((A_Base == NULL) == (B_Base == NULL)); - assert(A_SD.getFragment()->getParent() == - B_SD.getFragment()->getParent()); - - Value += Layout.getSymbolOffset(&A_SD) - - (A_Base == NULL ? 0 : Layout.getSymbolOffset(A_Base)); - Value -= Layout.getSymbolOffset(&B_SD) - - (B_Base == NULL ? 0 : Layout.getSymbolOffset(B_Base)); + Value += getSymbolAddress(&A_SD, Layout) - + (A_Base == NULL ? 0 : getSymbolAddress(A_Base, Layout)); + Value -= getSymbolAddress(&B_SD, Layout) - + (B_Base == NULL ? 0 : getSymbolAddress(B_Base, Layout)); if (A_Base) { Index = A_Base->getIndex(); Added: llvm/trunk/test/MC/MachO/symbol-diff.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/symbol-diff.s?rev=121085&view=auto ============================================================================== --- llvm/trunk/test/MC/MachO/symbol-diff.s (added) +++ llvm/trunk/test/MC/MachO/symbol-diff.s Mon Dec 6 19:09:54 2010 @@ -0,0 +1,122 @@ +// RUN: llvm-mc -triple x86_64-apple-darwin10 %s -filetype=obj -o - | macho-dump --dump-section-data | FileCheck %s +_g: +LFB2: + .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support +_g.eh: + .quad LFB2-. + +// CHECK: ('cputype', 16777223) +// CHECK-NEXT: ('cpusubtype', 3) +// CHECK-NEXT: ('filetype', 1) +// CHECK-NEXT: ('num_load_commands', 3) +// CHECK-NEXT: ('load_commands_size', 336) +// CHECK-NEXT: ('flag', 0) +// CHECK-NEXT: ('reserved', 0) +// CHECK-NEXT: ('load_commands', [ +// CHECK-NEXT: # Load Command 0 +// CHECK-NEXT: (('command', 25) +// CHECK-NEXT: ('size', 232) +// CHECK-NEXT: ('segment_name', '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-NEXT: ('vm_addr', 0) +// CHECK-NEXT: ('vm_size', 8) +// CHECK-NEXT: ('file_offset', 368) +// CHECK-NEXT: ('file_size', 8) +// CHECK-NEXT: ('maxprot', 7) +// CHECK-NEXT: ('initprot', 7) +// CHECK-NEXT: ('num_sections', 2) +// CHECK-NEXT: ('flags', 0) +// CHECK-NEXT: ('sections', [ +// CHECK-NEXT: # Section 0 +// CHECK-NEXT: (('section_name', '__text\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-NEXT: ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-NEXT: ('address', 0) +// CHECK-NEXT: ('size', 0) +// CHECK-NEXT: ('offset', 368) +// CHECK-NEXT: ('alignment', 0) +// CHECK-NEXT: ('reloc_offset', 0) +// CHECK-NEXT: ('num_reloc', 0) +// CHECK-NEXT: ('flags', 0x80000000) +// CHECK-NEXT: ('reserved1', 0) +// CHECK-NEXT: ('reserved2', 0) +// CHECK-NEXT: ('reserved3', 0) +// CHECK-NEXT: ), +// CHECK-NEXT: ('_relocations', [ +// CHECK-NEXT: ]) +// CHECK-NEXT: ('_section_data', '') +// CHECK-NEXT: # Section 1 +// CHECK-NEXT: (('section_name', '__eh_frame\x00\x00\x00\x00\x00\x00') +// CHECK-NEXT: ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-NEXT: ('address', 0) +// CHECK-NEXT: ('size', 8) +// CHECK-NEXT: ('offset', 368) +// CHECK-NEXT: ('alignment', 0) +// CHECK-NEXT: ('reloc_offset', 376) +// CHECK-NEXT: ('num_reloc', 2) +// CHECK-NEXT: ('flags', 0x6800000b) +// CHECK-NEXT: ('reserved1', 0) +// CHECK-NEXT: ('reserved2', 0) +// CHECK-NEXT: ('reserved3', 0) +// CHECK-NEXT: ), +// CHECK-NEXT: ('_relocations', [ +// CHECK-NEXT: # Relocation 0 +// CHECK-NEXT: (('word-0', 0x0), +// CHECK-NEXT: ('word-1', 0x5e000001)), +// CHECK-NEXT: # Relocation 1 +// CHECK-NEXT: (('word-0', 0x0), +// CHECK-NEXT: ('word-1', 0xe000000)), +// CHECK-NEXT: ]) +// CHECK-NEXT: ('_section_data', '00000000 00000000') +// CHECK-NEXT: ]) +// CHECK-NEXT: ), +// CHECK-NEXT: # Load Command 1 +// CHECK-NEXT: (('command', 2) +// CHECK-NEXT: ('size', 24) +// CHECK-NEXT: ('symoff', 392) +// CHECK-NEXT: ('nsyms', 2) +// CHECK-NEXT: ('stroff', 424) +// CHECK-NEXT: ('strsize', 12) +// CHECK-NEXT: ('_string_data', '\x00_g\x00_g.eh\x00\x00\x00') +// CHECK-NEXT: ('_symbols', [ +// CHECK-NEXT: # Symbol 0 +// CHECK-NEXT: (('n_strx', 1) +// CHECK-NEXT: ('n_type', 0xe) +// CHECK-NEXT: ('n_sect', 1) +// CHECK-NEXT: ('n_desc', 0) +// CHECK-NEXT: ('n_value', 0) +// CHECK-NEXT: ('_string', '_g') +// CHECK-NEXT: ), +// CHECK-NEXT: # Symbol 1 +// CHECK-NEXT: (('n_strx', 4) +// CHECK-NEXT: ('n_type', 0xe) +// CHECK-NEXT: ('n_sect', 2) +// CHECK-NEXT: ('n_desc', 0) +// CHECK-NEXT: ('n_value', 0) +// CHECK-NEXT: ('_string', '_g.eh') +// CHECK-NEXT: ), +// CHECK-NEXT: ]) +// CHECK-NEXT: ), +// CHECK-NEXT: # Load Command 2 +// CHECK-NEXT: (('command', 11) +// CHECK-NEXT: ('size', 80) +// CHECK-NEXT: ('ilocalsym', 0) +// CHECK-NEXT: ('nlocalsym', 2) +// CHECK-NEXT: ('iextdefsym', 2) +// CHECK-NEXT: ('nextdefsym', 0) +// CHECK-NEXT: ('iundefsym', 2) +// CHECK-NEXT: ('nundefsym', 0) +// CHECK-NEXT: ('tocoff', 0) +// CHECK-NEXT: ('ntoc', 0) +// CHECK-NEXT: ('modtaboff', 0) +// CHECK-NEXT: ('nmodtab', 0) +// CHECK-NEXT: ('extrefsymoff', 0) +// CHECK-NEXT: ('nextrefsyms', 0) +// CHECK-NEXT: ('indirectsymoff', 0) +// CHECK-NEXT: ('nindirectsyms', 0) +// CHECK-NEXT: ('extreloff', 0) +// CHECK-NEXT: ('nextrel', 0) +// CHECK-NEXT: ('locreloff', 0) +// CHECK-NEXT: ('nlocrel', 0) +// CHECK-NEXT: ('_indirect_symbols', [ +// CHECK-NEXT: ]) +// CHECK-NEXT: ), +// CHECK-NEXT:]) From bob.wilson at apple.com Mon Dec 6 19:12:19 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 07 Dec 2010 01:12:19 -0000 Subject: [llvm-commits] [llvm] r121086 - /llvm/trunk/utils/TableGen/NeonEmitter.cpp Message-ID: <20101207011219.E09FA2A6C12C@llvm.org> Author: bwilson Date: Mon Dec 6 19:12:19 2010 New Revision: 121086 URL: http://llvm.org/viewvc/llvm-project?rev=121086&view=rev Log: Fix whitespace. Modified: llvm/trunk/utils/TableGen/NeonEmitter.cpp Modified: llvm/trunk/utils/TableGen/NeonEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.cpp?rev=121086&r1=121085&r2=121086&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/NeonEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/NeonEmitter.cpp Mon Dec 6 19:12:19 2010 @@ -1143,12 +1143,12 @@ } if (mask) OS << "case ARM::BI__builtin_neon_" - << MangleName(name, TypeVec[si], ClassB) - << ": mask = " << "0x" << utohexstr(mask) << "; break;\n"; + << MangleName(name, TypeVec[si], ClassB) + << ": mask = " << "0x" << utohexstr(mask) << "; break;\n"; if (qmask) OS << "case ARM::BI__builtin_neon_" - << MangleName(name, TypeVec[qi], ClassB) - << ": mask = " << "0x" << utohexstr(qmask) << "; break;\n"; + << MangleName(name, TypeVec[qi], ClassB) + << ": mask = " << "0x" << utohexstr(qmask) << "; break;\n"; } OS << "#endif\n\n"; @@ -1226,7 +1226,7 @@ case 'i': ie = ii + 1; break; } } - OS << "case ARM::BI__builtin_neon_" << MangleName(name, TypeVec[ti], ck) + OS << "case ARM::BI__builtin_neon_" << MangleName(name, TypeVec[ti], ck) << ": i = " << immidx << "; " << rangestr << "; break;\n"; } } From bob.wilson at apple.com Mon Dec 6 19:12:23 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 07 Dec 2010 01:12:23 -0000 Subject: [llvm-commits] [llvm] r121087 - in /llvm/trunk/utils/TableGen: NeonEmitter.cpp NeonEmitter.h Message-ID: <20101207011223.6E1682A6C12D@llvm.org> Author: bwilson Date: Mon Dec 6 19:12:23 2010 New Revision: 121087 URL: http://llvm.org/viewvc/llvm-project?rev=121087&view=rev Log: Add an OpReinterpret operation to TableGen's NeonEmitter. An OpReinterpret entry is handled by translating it to OpCast intrinsics for all combinations of source and destination types with the same total size. This will be used to generate all the vreinterpret intrinsics. Modified: llvm/trunk/utils/TableGen/NeonEmitter.cpp llvm/trunk/utils/TableGen/NeonEmitter.h Modified: llvm/trunk/utils/TableGen/NeonEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.cpp?rev=121087&r1=121086&r2=121087&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/NeonEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/NeonEmitter.cpp Mon Dec 6 19:12:23 2010 @@ -897,6 +897,55 @@ return s; } +static std::string GenIntrinsic(const std::string &name, + const std::string &proto, + StringRef outTypeStr, StringRef inTypeStr, + OpKind kind, ClassKind classKind) { + assert(!proto.empty() && ""); + bool define = proto.find('i') != std::string::npos; + std::string s; + + // static always inline + return type + if (define) + s += "#define "; + else + s += "__ai " + TypeString(proto[0], outTypeStr) + " "; + + // Function name with type suffix + std::string mangledName = MangleName(name, outTypeStr, ClassS); + if (outTypeStr != inTypeStr) { + // If the input type is different (e.g., for vreinterpret), append a suffix + // for the input type. String off a "Q" (quad) prefix so that MangleName + // does not insert another "q" in the name. + unsigned typeStrOff = (inTypeStr[0] == 'Q' ? 1 : 0); + StringRef inTypeNoQuad = inTypeStr.substr(typeStrOff); + mangledName = MangleName(mangledName, inTypeNoQuad, ClassS); + } + s += mangledName; + + // Function arguments + s += GenArgs(proto, inTypeStr); + + // Definition. + if (define) { + s += " __extension__ ({ \\\n "; + s += GenMacroLocals(proto, inTypeStr); + } else { + s += " { \\\n "; + } + + if (kind != OpNone) + s += GenOpString(kind, proto, outTypeStr); + else + s += GenBuiltin(name, proto, outTypeStr, classKind); + if (define) + s += " })"; + else + s += " }"; + s += "\n"; + return s; +} + /// run - Read the records in arm_neon.td and output arm_neon.h. arm_neon.h /// is comprised of type definitions and function declarations. void NeonEmitter::run(raw_ostream &OS) { @@ -975,50 +1024,32 @@ SmallVector TypeVec; ParseTypes(R, Types, TypeVec); - OpKind k = OpMap[R->getValueAsDef("Operand")->getName()]; + OpKind kind = OpMap[R->getValueAsDef("Operand")->getName()]; - bool define = Proto.find('i') != std::string::npos; + ClassKind classKind = ClassNone; + if (R->getSuperClasses().size() >= 2) + classKind = ClassMap[R->getSuperClasses()[1]]; + if (classKind == ClassNone && kind == OpNone) + throw TGError(R->getLoc(), "Builtin has no class kind"); for (unsigned ti = 0, te = TypeVec.size(); ti != te; ++ti) { - assert(!Proto.empty() && ""); - - // static always inline + return type - if (define) - OS << "#define"; - else - OS << "__ai " << TypeString(Proto[0], TypeVec[ti]); - - // Function name with type suffix - OS << " " << MangleName(name, TypeVec[ti], ClassS); - - // Function arguments - OS << GenArgs(Proto, TypeVec[ti]); - - // Definition. - if (define) { - OS << " __extension__ ({ \\\n "; - OS << GenMacroLocals(Proto, TypeVec[ti]); - } else { - OS << " { \\\n "; - } - - if (k != OpNone) { - OS << GenOpString(k, Proto, TypeVec[ti]); + if (kind == OpReinterpret) { + bool outQuad = false; + bool dummy = false; + (void)ClassifyType(TypeVec[ti], outQuad, dummy, dummy); + for (unsigned srcti = 0, srcte = TypeVec.size(); + srcti != srcte; ++srcti) { + bool inQuad = false; + (void)ClassifyType(TypeVec[srcti], inQuad, dummy, dummy); + if (srcti == ti || inQuad != outQuad) + continue; + OS << GenIntrinsic(name, Proto, TypeVec[ti], TypeVec[srcti], + OpCast, ClassS); + } } else { - if (R->getSuperClasses().size() < 2) - throw TGError(R->getLoc(), "Builtin has no class kind"); - - ClassKind ck = ClassMap[R->getSuperClasses()[1]]; - - if (ck == ClassNone) - throw TGError(R->getLoc(), "Builtin has no class kind"); - OS << GenBuiltin(name, Proto, TypeVec[ti], ck); + OS << GenIntrinsic(name, Proto, TypeVec[ti], TypeVec[ti], + kind, classKind); } - if (define) - OS << " })"; - else - OS << " }"; - OS << "\n"; } OS << "\n"; } Modified: llvm/trunk/utils/TableGen/NeonEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.h?rev=121087&r1=121086&r2=121087&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/NeonEmitter.h (original) +++ llvm/trunk/utils/TableGen/NeonEmitter.h Mon Dec 6 19:12:23 2010 @@ -54,7 +54,8 @@ OpSelect, OpRev16, OpRev32, - OpRev64 + OpRev64, + OpReinterpret }; enum ClassKind { @@ -107,6 +108,7 @@ OpMap["OP_REV16"] = OpRev16; OpMap["OP_REV32"] = OpRev32; OpMap["OP_REV64"] = OpRev64; + OpMap["OP_REINT"] = OpReinterpret; Record *SI = R.getClass("SInst"); Record *II = R.getClass("IInst"); From gohman at apple.com Mon Dec 6 19:21:56 2010 From: gohman at apple.com (Dan Gohman) Date: Mon, 6 Dec 2010 17:21:56 -0800 Subject: [llvm-commits] PathV2 review notes In-Reply-To: References: Message-ID: <67A23987-4A49-4902-85CD-D522E801A367@apple.com> On Dec 6, 2010, at 1:50 PM, Michael Spencer wrote: > On Mon, Dec 6, 2010 at 12:48 PM, Dan Gohman wrote: > >> include/llvm/Support/PathV2.h: >> >>> /// @name Lexical Modifiers >>> /// @{ >> >>> /// @brief Make \a path an absolute path. >>> /// >>> /// Makes \a path absolute using the current directory if it is not already. An >>> /// empty \a path will result in the current directory. >>> /// >>> /// /absolute/path => /absolute/path >>> /// relative/../path => /path >>> /// >>> /// @param path A path that is modified to be an absolute path. >>> /// @returns errc::success if \a path has been made absolute, otherwise a >>> /// platform specific error_code. >>> error_code make_absolute(SmallVectorImpl &path); >> >> The top-level section comment suggests that this is a lexical >> operation, but it is not. > > I wasn't completely sure where to group this function. It is lexical > in that it does not resolve any symlinks or other weirdness. However, > it does use the current directory if the path is not already absolute. > > I also just noticed that the documentation is incorrect. This function > does not resolve '.' or '..', thus: > relative/../path => /relative/../path > > As it stands, I would either agree with keeping the function as is and > moving it over to sys::fs and FileSystem.h, or I would like to add a > base argument and a sys::fs::initial_directory function (which returns > the current directory as it would be immediately before main). > > This really depends on how often and when a base directory other than > current is used. If make_absolute is used in any of the libraries then > there is technically a race condition, because another part of the > process could change the current directory at any time (although most > programs don't do this). Moving it to FileSystem.h makes sense to me. >> On a related note, there are many functions (root_directory, root_path, >> is_absolute, etc.) like this which are purely lexical, and implemented >> with platform-independent code, and which always return success. It's >> unfortunate that clients are required to cope with "a platform specific >> error_code" when working with any of these interfaces, since it isn't >> really needed. >> >> Unlike Boost, LLVM doesn't propogate malloc errors. If malloc fails, >> LLVM crashes (at best). We can have interesting discussions about >> whether or not this is a bug, but it does simplify many things. >> Also unlike Boost, LLVM's libSupport can easily change its API if it >> ever somehow makes sense for these functions to return errors in the >> future. > > I agree that it is awkward. I decided to return error_codes to stay > consistent with the rest of the API, and to allow handling memory > errors. However, now that we have the path, and fs namespace split, I > think it would be ok to remove the error_code return from path. I > don't see SmallVector and friends getting any support for reporting > memory allocation errors any time soon. > > This would also require moving current_path (and make_absolute as it > is currently designed) into fs. I think that sounds reasonable. > >>> /// @brief Replace the file extension of \a path with \a extension. >>> /// >>> /// ./filename.cpp => ./filename.extension >>> /// ./filename => ./filename.extension >>> /// ./ => ? TODO: decide what semantics this has. >>> /// >>> /// @param path A path that has its extension replaced with \a extension. >>> /// @param extension The extension to be added. It may be empty. It may also >>> /// optionally start with a '.', if it does not, one will be >>> /// prepended. >>> /// @returns errc::success if \a path's extension has been replaced, otherwise a >>> /// platform specific error_code. >>> error_code replace_extension(SmallVectorImpl &path, >>> const Twine &extension); >> >> The behavior of prepending a '.' if the suffix doesn't already have >> one is confusing. Since extension includes the dot, it would be >> consistent for replace_extension to require it. It could even >> verify this with an assert. > > I don't have a strong opinion on this either way other than I don't > feel it's confusing. I find it confusing when some clients use the API differently than other clients in ways that appear significant but aren't. >>> /// @brief Get root name. >>> /// >>> /// //net/hello => //net >>> /// c:/hello => c: (on Windows, on other platforms nothing) >>> /// /hello => >> >> UNC-style double-slash pathnames are not well known in Unix circles; >> a comment on that first example would be helpful. > > OK, from what I understand POSIX supports them. All POSIX says is "A pathname that begins with two successive slashes may be interpreted in an implementation-defined manner." In practice, I don't know any implementation which does anything with this. > >> As an aside, does it really make sense to implement UNC pathnames >> on systems where the underlying libc API doesn't implement them? I >> realize you're just following Boost here though. >> >> More broadly, there seem to be two major ways of bisecting paths >> in this API: root+relative and parent+filename (as this API names them). >> Parent+filename is obvious, but when would root+relative be useful for >> LLVM? Compilers and related tools should never go digging around in >> the filesystem root on their own. > > I do not expect these functions to be used directly, however, they are > used extensively in the implementation of other functions. Ok. It may make sense to make them private to the PathV2 implementation then. > >> lib/Support/PathV2.cpp > >>> error_code has_root_directory(const Twine &path, bool &result) { >>> SmallString<128> path_storage; >>> StringRef p = path.toStringRef(path_storage); >>> >>> if (error_code ec = root_directory(p, p)) return ec; >>> >>> result = !p.empty(); >>> return success; >>> } >> >> Calling root_directory(p, p) here looks unsafe: p isn't guaranteed >> to be pointing to path_storage, and root_directory writes >> through it. > > root_directory doesn't write. Ok, I see now. >>> TempDir >> >>> (dir = std::getenv("TMPDIR" )) || >> >> It's suspicious for the path library to be using "TMPDIR" privately >> like this. What is this for? > > I implemented the function the way the Open Group standard defines > tmpname as looking for the temp directory. It is private because > clients should not care where the temp directory is or directly use > it. I now see that this is just part of the unique_file implementation which I claim is unnecessary ;-). >>> copy_file >> >> FWIW, it appears copy_file is apparently only used by llvm-ld and only on >> Windows, so the Unix implementation is currently dead code. > > Should it be removed? Sure. >>> remove >> >>> if (::remove(p.begin()) == -1) { >>> if (errno != errc::no_such_file_or_directory) >>> return error_code(errno, system_category()); >> >> Using the errc namespace here conflates API levels. This code >> should use ENOENT directly instead of no_such_file_or_directory. > > I used the errc enum constants because they are infinitely more > readable than the ERRNO macros. It's safe because they are guaranteed > to have the same value. I find ENOENT more readable because it's what the API that you're using here is documented to use. >>> file_size >> >> What is this for? Doing a full ::stat call and throwing away all >> the information except st_size is suspicious. > > There are a lot of functions that take both a path and a file_status, > this should be one of them. If you only need the file size you just > call this, otherwise you call status and reuse the file_status class > (which currently only stores st_mode, but that will change). My main observation here is that nothing in LLVM ever just needs the file size without needing anything else. > >>> unique_file >> >>> [... lots of stuff ...] >> >> Please don't try to do what mkstemp does manually. Just use mkstemp. >> >> mkstemp is very widely available these days. For portability to >> exotic platforms, it's fine to put the burden on people who care >> to contribute patches. >> >> Dan > > There are quite a few things I don't like about using mkstemp for LLVM: > * You can't specify any of the flags used to create the file. That's true, but I don't think it's important here. > * Filenames are required to end in XXXXXX (I've never understood this > requirement). Those are the characters that mkstemp overwrites to make the filename unique. > * You can only use an absolute path, so you end up explicitly using > /tmp. Although this can be handled before mkstemp is called. mkstemp does support relative paths. > > If we're OK with all that, then I don't mind switching the Unix impl > over to mkstemp if it's present. Thanks, Dan From bigcheesegs at gmail.com Mon Dec 6 19:22:31 2010 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Tue, 07 Dec 2010 01:22:31 -0000 Subject: [llvm-commits] [llvm] r121090 - in /llvm/trunk: include/llvm/Support/FileSystem.h include/llvm/Support/PathV2.h lib/Support/PathV2.cpp lib/Support/Unix/PathV2.inc lib/Support/Windows/PathV2.inc Message-ID: <20101207012231.B64632A6C12C@llvm.org> Author: mspencer Date: Mon Dec 6 19:22:31 2010 New Revision: 121090 URL: http://llvm.org/viewvc/llvm-project?rev=121090&view=rev Log: Support/PathV2: Move current_path from path to fs and fix the Unix implementation. Unix bug spotted by Dan Gohman. Modified: llvm/trunk/include/llvm/Support/FileSystem.h llvm/trunk/include/llvm/Support/PathV2.h llvm/trunk/lib/Support/PathV2.cpp llvm/trunk/lib/Support/Unix/PathV2.inc llvm/trunk/lib/Support/Windows/PathV2.inc Modified: llvm/trunk/include/llvm/Support/FileSystem.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FileSystem.h?rev=121090&r1=121089&r2=121090&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/FileSystem.h (original) +++ llvm/trunk/include/llvm/Support/FileSystem.h Mon Dec 6 19:22:31 2010 @@ -148,6 +148,13 @@ /// otherwise a platform specific error_code. error_code create_symlink(const Twine &to, const Twine &from); +/// @brief Get the current path. +/// +/// @param result Holds the current path on return. +/// @results errc::success if the current path has been stored in result, +/// otherwise a platform specific error_code. +error_code current_path(SmallVectorImpl &result); + /// @brief Remove path. Equivalent to POSIX remove(). /// /// @param path Input path. Modified: llvm/trunk/include/llvm/Support/PathV2.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PathV2.h?rev=121090&r1=121089&r2=121090&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/PathV2.h (original) +++ llvm/trunk/include/llvm/Support/PathV2.h Mon Dec 6 19:22:31 2010 @@ -202,15 +202,6 @@ /// @name Lexical Observers /// @{ -/// @brief Get the current path. -/// -/// @param result Holds the current path on return. -/// @results errc::success if the current path has been stored in result, -/// otherwise a platform specific error_code. -error_code current_path(SmallVectorImpl &result); - -// The following are purely lexical. - /// @brief Get root name. /// /// //net/hello => //net Modified: llvm/trunk/lib/Support/PathV2.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/PathV2.cpp?rev=121090&r1=121089&r2=121090&view=diff ============================================================================== --- llvm/trunk/lib/Support/PathV2.cpp (original) +++ llvm/trunk/lib/Support/PathV2.cpp Mon Dec 6 19:22:31 2010 @@ -437,7 +437,7 @@ // All of the following conditions will need the current directory. SmallString<128> current_dir; - if (error_code ec = current_path(current_dir)) return ec; + if (error_code ec = fs::current_path(current_dir)) return ec; // Relative path. Prepend the current directory. if (!rootName && !rootDirectory) { Modified: llvm/trunk/lib/Support/Unix/PathV2.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/PathV2.inc?rev=121090&r1=121089&r2=121090&view=diff ============================================================================== --- llvm/trunk/lib/Support/Unix/PathV2.inc (original) +++ llvm/trunk/lib/Support/Unix/PathV2.inc Mon Dec 6 19:22:31 2010 @@ -69,24 +69,26 @@ namespace llvm { namespace sys { -namespace path { +namespace fs { error_code current_path(SmallVectorImpl &result) { - long size = ::pathconf(".", _PC_PATH_MAX); - result.reserve(size + 1); - result.set_size(size + 1); + result.reserve(MAXPATHLEN); - if (::getcwd(result.data(), result.size()) == 0) - return error_code(errno, system_category()); + while (true) { + if (::getcwd(result.data(), result.capacity()) == 0) { + // See if there was a real error. + if (errno != errc::not_enough_memory) + return error_code(errno, system_category()); + // Otherwise there just wasn't enough space. + result.reserve(result.capacity() * 2); + } else + break; + } result.set_size(strlen(result.data())); return success; } -} // end namespace path - -namespace fs{ - error_code copy_file(const Twine &from, const Twine &to, copy_option copt) { // Get arguments. SmallString<128> from_storage; Modified: llvm/trunk/lib/Support/Windows/PathV2.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/PathV2.inc?rev=121090&r1=121089&r2=121090&view=diff ============================================================================== --- llvm/trunk/lib/Support/Windows/PathV2.inc (original) +++ llvm/trunk/lib/Support/Windows/PathV2.inc Mon Dec 6 19:22:31 2010 @@ -134,7 +134,7 @@ namespace llvm { namespace sys { -namespace path { +namespace fs { error_code current_path(SmallVectorImpl &result) { SmallVector cur_path; @@ -180,10 +180,6 @@ return success; } -} // end namespace path - -namespace fs { - error_code copy_file(const Twine &from, const Twine &to, copy_option copt) { // Get arguments. SmallString<128> from_storage; From bigcheesegs at gmail.com Mon Dec 6 19:23:08 2010 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Tue, 07 Dec 2010 01:23:08 -0000 Subject: [llvm-commits] [llvm] r121091 - in /llvm/trunk: include/llvm/Support/PathV2.h lib/Support/Unix/PathV2.inc Message-ID: <20101207012308.88CB42A6C12C@llvm.org> Author: mspencer Date: Mon Dec 6 19:23:08 2010 New Revision: 121091 URL: http://llvm.org/viewvc/llvm-project?rev=121091&view=rev Log: Support/PathV2: Clarify and correct documentation. Modified: llvm/trunk/include/llvm/Support/PathV2.h llvm/trunk/lib/Support/Unix/PathV2.inc Modified: llvm/trunk/include/llvm/Support/PathV2.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PathV2.h?rev=121091&r1=121090&r2=121091&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/PathV2.h (original) +++ llvm/trunk/include/llvm/Support/PathV2.h Mon Dec 6 19:23:08 2010 @@ -123,17 +123,18 @@ /// empty \a path will result in the current directory. /// /// /absolute/path => /absolute/path -/// relative/../path => /path +/// relative/../path => /relative/../path /// /// @param path A path that is modified to be an absolute path. /// @returns errc::success if \a path has been made absolute, otherwise a /// platform specific error_code. error_code make_absolute(SmallVectorImpl &path); -/// @brief Remove the last component from \a path if it exists. +/// @brief Remove the last component from \a path unless it is the root dir. /// /// directory/filename.cpp => directory/ /// directory/ => directory +/// / => / /// /// @param path A path that is modified to not have a file component. /// @returns errc::success if \a path's file name has been removed (or there was @@ -144,7 +145,7 @@ /// /// ./filename.cpp => ./filename.extension /// ./filename => ./filename.extension -/// ./ => ? TODO: decide what semantics this has. +/// ./ => ./.extension /// /// @param path A path that has its extension replaced with \a extension. /// @param extension The extension to be added. It may be empty. It may also Modified: llvm/trunk/lib/Support/Unix/PathV2.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/PathV2.inc?rev=121091&r1=121090&r2=121091&view=diff ============================================================================== --- llvm/trunk/lib/Support/Unix/PathV2.inc (original) +++ llvm/trunk/lib/Support/Unix/PathV2.inc Mon Dec 6 19:23:08 2010 @@ -30,6 +30,11 @@ using namespace llvm; namespace { + /// This class automatically closes the given file descriptor when it goes out + /// of scope. You can take back explicit ownership of the file descriptor by + /// calling take(). The destructor does not verify that close was successful. + /// Therefore, never allow this class to call close on a file descriptor that + /// has been read from or written to. struct AutoFD { int FileDescriptor; From bigcheesegs at gmail.com Mon Dec 6 19:23:19 2010 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Tue, 07 Dec 2010 01:23:19 -0000 Subject: [llvm-commits] [llvm] r121092 - in /llvm/trunk/lib/Support: PathV2.cpp Unix/PathV2.inc Message-ID: <20101207012319.6E7892A6C12C@llvm.org> Author: mspencer Date: Mon Dec 6 19:23:19 2010 New Revision: 121092 URL: http://llvm.org/viewvc/llvm-project?rev=121092&view=rev Log: Support/PathV2: Use SmallVector::clear instead of set_size. Modified: llvm/trunk/lib/Support/PathV2.cpp llvm/trunk/lib/Support/Unix/PathV2.inc Modified: llvm/trunk/lib/Support/PathV2.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/PathV2.cpp?rev=121092&r1=121091&r2=121092&view=diff ============================================================================== --- llvm/trunk/lib/Support/PathV2.cpp (original) +++ llvm/trunk/lib/Support/PathV2.cpp Mon Dec 6 19:23:19 2010 @@ -518,7 +518,7 @@ error_code native(const Twine &path, SmallVectorImpl &result) { // Clear result. - result.set_size(0); + result.clear(); #ifdef LLVM_ON_WIN32 SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); Modified: llvm/trunk/lib/Support/Unix/PathV2.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/PathV2.inc?rev=121092&r1=121091&r2=121092&view=diff ============================================================================== --- llvm/trunk/lib/Support/Unix/PathV2.inc (original) +++ llvm/trunk/lib/Support/Unix/PathV2.inc Mon Dec 6 19:23:19 2010 @@ -65,7 +65,7 @@ #endif (dir = "/tmp"); - result.set_size(0); + result.clear(); StringRef d(dir); result.append(d.begin(), d.end()); return success; @@ -400,7 +400,7 @@ return error_code(errno, system_category()); } - result_path.set_size(0); + result_path.clear(); StringRef d(real_path_buff); result_path.append(d.begin(), d.end()); From bigcheesegs at gmail.com Mon Dec 6 19:23:29 2010 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Tue, 07 Dec 2010 01:23:29 -0000 Subject: [llvm-commits] [llvm] r121093 - /llvm/trunk/lib/Support/Unix/PathV2.inc Message-ID: <20101207012329.761D52A6C12C@llvm.org> Author: mspencer Date: Mon Dec 6 19:23:29 2010 New Revision: 121093 URL: http://llvm.org/viewvc/llvm-project?rev=121093&view=rev Log: Support/Unix/PathV2: Use 0770 instead of 0700 when creating a directory. Also use the standard macros instead of octal notation. Modified: llvm/trunk/lib/Support/Unix/PathV2.inc Modified: llvm/trunk/lib/Support/Unix/PathV2.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/PathV2.inc?rev=121093&r1=121092&r2=121093&view=diff ============================================================================== --- llvm/trunk/lib/Support/Unix/PathV2.inc (original) +++ llvm/trunk/lib/Support/Unix/PathV2.inc Mon Dec 6 19:23:29 2010 @@ -157,7 +157,7 @@ SmallString<128> path_storage; StringRef p = path.toNullTerminatedStringRef(path_storage); - if (::mkdir(p.begin(), 0700) == -1) { + if (::mkdir(p.begin(), S_IRWXU | S_IRWXG) == -1) { if (errno != errc::file_exists) return error_code(errno, system_category()); existed = true; From bigcheesegs at gmail.com Mon Dec 6 19:23:39 2010 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Tue, 07 Dec 2010 01:23:39 -0000 Subject: [llvm-commits] [llvm] r121094 - /llvm/trunk/lib/Support/Unix/PathV2.inc Message-ID: <20101207012339.934C82A6C12C@llvm.org> Author: mspencer Date: Mon Dec 6 19:23:39 2010 New Revision: 121094 URL: http://llvm.org/viewvc/llvm-project?rev=121094&view=rev Log: Support/Unix/PathV2: Return the real error from realpath instead of any error that close or unlink set. Modified: llvm/trunk/lib/Support/Unix/PathV2.inc Modified: llvm/trunk/lib/Support/Unix/PathV2.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/PathV2.inc?rev=121094&r1=121093&r2=121094&view=diff ============================================================================== --- llvm/trunk/lib/Support/Unix/PathV2.inc (original) +++ llvm/trunk/lib/Support/Unix/PathV2.inc Mon Dec 6 19:23:39 2010 @@ -395,9 +395,10 @@ // Make the path absolute. char real_path_buff[PATH_MAX + 1]; if (realpath(RandomPath.c_str(), real_path_buff) == NULL) { + int error = errno; ::close(RandomFD); ::unlink(RandomPath.c_str()); - return error_code(errno, system_category()); + return error_code(error, system_category()); } result_path.clear(); From bigcheesegs at gmail.com Mon Dec 6 19:23:49 2010 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Tue, 07 Dec 2010 01:23:49 -0000 Subject: [llvm-commits] [llvm] r121095 - in /llvm/trunk/test: Unit/lit.cfg lit.cfg Message-ID: <20101207012349.81AA22A6C12C@llvm.org> Author: mspencer Date: Mon Dec 6 19:23:49 2010 New Revision: 121095 URL: http://llvm.org/viewvc/llvm-project?rev=121095&view=rev Log: Test: Fix Support.Path and _all_ of the unittest death tests. GetTempPath defaults to \Windows\. If I typed anything else it would just decline into cursing. Modified: llvm/trunk/test/Unit/lit.cfg llvm/trunk/test/lit.cfg Modified: llvm/trunk/test/Unit/lit.cfg URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Unit/lit.cfg?rev=121095&r1=121094&r2=121095&view=diff ============================================================================== --- llvm/trunk/test/Unit/lit.cfg (original) +++ llvm/trunk/test/Unit/lit.cfg Mon Dec 6 19:23:49 2010 @@ -21,6 +21,13 @@ llvm_build_mode = getattr(config, 'llvm_build_mode', "Debug") config.test_format = lit.formats.GoogleTest(llvm_build_mode, 'Tests') +# Propagate the temp directory. Windows requires this because it uses \Windows\ +# if none of these are present. +if 'TMP' in os.environ: + config.environment['TMP'] = os.environ['TMP'] +if 'TEMP' in os.environ: + config.environment['TEMP'] = os.environ['TEMP'] + ### # If necessary, point the dynamic loader at libLLVM.so. Modified: llvm/trunk/test/lit.cfg URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/lit.cfg?rev=121095&r1=121094&r2=121095&view=diff ============================================================================== --- llvm/trunk/test/lit.cfg (original) +++ llvm/trunk/test/lit.cfg Mon Dec 6 19:23:49 2010 @@ -58,6 +58,13 @@ if 'LIB' in os.environ: config.environment['LIB'] = os.environ['LIB'] +# Propagate the temp directory. Windows requires this because it uses \Windows\ +# if none of these are present. +if 'TMP' in os.environ: + config.environment['TMP'] = os.environ['TMP'] +if 'TEMP' in os.environ: + config.environment['TEMP'] = os.environ['TEMP'] + # Propagate LLVM_SRC_ROOT into the environment. config.environment['LLVM_SRC_ROOT'] = getattr(config, 'llvm_src_root', '') From pichet2000 at gmail.com Mon Dec 6 19:25:06 2010 From: pichet2000 at gmail.com (Francois Pichet) Date: Tue, 07 Dec 2010 01:25:06 -0000 Subject: [llvm-commits] [llvm] r121096 - /llvm/trunk/CMakeLists.txt Message-ID: <20101207012506.4460B2A6C12C@llvm.org> Author: fpichet Date: Mon Dec 6 19:25:06 2010 New Revision: 121096 URL: http://llvm.org/viewvc/llvm-project?rev=121096&view=rev Log: Promote "enumerator in switch of enum is not handled" to level 1 warning on MSVC. It was disabled by default. Modified: llvm/trunk/CMakeLists.txt Modified: llvm/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=121096&r1=121095&r2=121096&view=diff ============================================================================== --- llvm/trunk/CMakeLists.txt (original) +++ llvm/trunk/CMakeLists.txt Mon Dec 6 19:25:06 2010 @@ -247,7 +247,10 @@ add_llvm_definitions( -D_SCL_SECURE_NO_DEPRECATE ) add_llvm_definitions( -wd4146 -wd4503 -wd4996 -wd4800 -wd4244 -wd4624 ) add_llvm_definitions( -wd4355 -wd4715 -wd4180 -wd4345 -wd4224 -wd4267 -wd4291 ) - add_llvm_definitions( -wd4275) + add_llvm_definitions( -wd4275 ) + + # Promote "enumerator in switch of enum is not handled" to level 1 warning. + add_llvm_definitions( -w14062 ) # Suppress 'new behavior: elements of array 'array' will be default initialized' add_llvm_definitions( -wd4351 ) From stoklund at 2pi.dk Mon Dec 6 19:32:46 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 07 Dec 2010 01:32:46 -0000 Subject: [llvm-commits] [llvm] r121098 - /llvm/trunk/lib/CodeGen/LiveIntervalUnion.h Message-ID: <20101207013246.0C22F2A6C12C@llvm.org> Author: stoklund Date: Mon Dec 6 19:32:45 2010 New Revision: 121098 URL: http://llvm.org/viewvc/llvm-project?rev=121098&view=rev Log: Remove unused member. Modified: llvm/trunk/lib/CodeGen/LiveIntervalUnion.h Modified: llvm/trunk/lib/CodeGen/LiveIntervalUnion.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalUnion.h?rev=121098&r1=121097&r2=121098&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalUnion.h (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalUnion.h Mon Dec 6 19:32:45 2010 @@ -18,7 +18,6 @@ #define LLVM_CODEGEN_LIVEINTERVALUNION #include "llvm/CodeGen/LiveInterval.h" -#include #include namespace llvm { @@ -100,13 +99,6 @@ // efficiently represent it. Probably need to roll our own B-tree. typedef std::set LiveSegments; - // A set of live virtual registers. Elements have type LiveInterval, where - // each element represents the liveness of a single live virtual register. - // This is traditionally known as a live range, but we refer is as a live - // virtual register to avoid confusing it with the misnamed LiveRange - // class. - typedef std::vector LiveVRegs; - public: // SegmentIter can advance to the next segment ordered by starting position // which may belong to a different live virtual register. We also must be able From sabre at nondot.org Mon Dec 6 19:59:33 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Dec 2010 01:59:33 -0000 Subject: [llvm-commits] [llvm] r121100 - in /llvm/trunk: lib/Transforms/IPO/GlobalOpt.cpp test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll Message-ID: <20101207015933.234362A6C12C@llvm.org> Author: lattner Date: Mon Dec 6 19:59:32 2010 New Revision: 121100 URL: http://llvm.org/viewvc/llvm-project?rev=121100&view=rev Log: fix PR8710 - teach global opt that some constantexprs are too complex to put in a global variable's initializer. Added: llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=121100&r1=121099&r2=121100&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Mon Dec 6 19:59:32 2010 @@ -2046,14 +2046,82 @@ } -static Constant *getVal(DenseMap &ComputedValues, - Value *V) { +static Constant *getVal(DenseMap &ComputedValues, Value *V) { if (Constant *CV = dyn_cast(V)) return CV; Constant *R = ComputedValues[V]; assert(R && "Reference to an uncomputed value!"); return R; } +static inline bool +isSimpleEnoughValueToCommit(Constant *C, + SmallPtrSet &SimpleConstants); + + +/// isSimpleEnoughValueToCommit - Return true if the specified constant can be +/// handled by the code generator. We don't want to generate something like: +/// void *X = &X/42; +/// because the code generator doesn't have a relocation that can handle that. +/// +/// This function should be called if C was not found (but just got inserted) +/// in SimpleConstants to avoid having to rescan the same constants all the +/// time. +static bool isSimpleEnoughValueToCommitHelper(Constant *C, + SmallPtrSet &SimpleConstants) { + // Simple integer, undef, constant aggregate zero, global addresses, etc are + // all supported. + if (C->getNumOperands() == 0 || isa(C) || + isa(C)) + return true; + + // Aggregate values are safe if all their elements are. + if (isa(C) || isa(C) || + isa(C)) { + for (unsigned i = 0, e = C->getNumOperands(); i != e; ++i) { + Constant *Op = cast(C->getOperand(i)); + if (!isSimpleEnoughValueToCommit(Op, SimpleConstants)) + return false; + } + return true; + } + + // We don't know exactly what relocations are allowed in constant expressions, + // so we allow &global+constantoffset, which is safe and uniformly supported + // across targets. + ConstantExpr *CE = cast(C); + switch (CE->getOpcode()) { + case Instruction::BitCast: + case Instruction::IntToPtr: + case Instruction::PtrToInt: + // These casts are always fine if the casted value is. + return isSimpleEnoughValueToCommit(CE->getOperand(0), SimpleConstants); + + // GEP is fine if it is simple + constant offset. + case Instruction::GetElementPtr: + for (unsigned i = 1, e = CE->getNumOperands(); i != e; ++i) + if (!isa(CE->getOperand(i))) + return false; + return isSimpleEnoughValueToCommit(CE->getOperand(0), SimpleConstants); + + case Instruction::Add: + // We allow simple+cst. + if (!isa(CE->getOperand(1))) + return false; + return isSimpleEnoughValueToCommit(CE->getOperand(0), SimpleConstants); + } + return false; +} + +static inline bool +isSimpleEnoughValueToCommit(Constant *C, + SmallPtrSet &SimpleConstants) { + // If we already checked this constant, we win. + if (!SimpleConstants.insert(C)) return true; + // Check the constant. + return isSimpleEnoughValueToCommitHelper(C, SimpleConstants); +} + + /// isSimpleEnoughPointerToCommit - Return true if this constant is simple /// enough for us to understand. In particular, if it is a cast of something, /// we punt. We basically just support direct accesses to globals and GEP's of @@ -2219,7 +2287,8 @@ const SmallVectorImpl &ActualArgs, std::vector &CallStack, DenseMap &MutatedMemory, - std::vector &AllocaTmps) { + std::vector &AllocaTmps, + SmallPtrSet &SimpleConstants) { // Check to see if this function is already executing (recursion). If so, // bail out. TODO: we might want to accept limited recursion. if (std::find(CallStack.begin(), CallStack.end(), F) != CallStack.end()) @@ -2254,7 +2323,13 @@ if (!isSimpleEnoughPointerToCommit(Ptr)) // If this is too complex for us to commit, reject it. return false; + Constant *Val = getVal(Values, SI->getOperand(0)); + + // If this might be too difficult for the backend to handle (e.g. the addr + // of one global variable divided by another) then we can't commit it. + if (!isSimpleEnoughValueToCommit(Val, SimpleConstants)) + return false; MutatedMemory[Ptr] = Val; } else if (BinaryOperator *BO = dyn_cast(CurInst)) { InstResult = ConstantExpr::get(BO->getOpcode(), @@ -2331,7 +2406,7 @@ Constant *RetVal; // Execute the call, if successful, use the return value. if (!EvaluateFunction(Callee, RetVal, Formals, CallStack, - MutatedMemory, AllocaTmps)) + MutatedMemory, AllocaTmps, SimpleConstants)) return false; InstResult = RetVal; } @@ -2417,11 +2492,16 @@ /// unbounded. std::vector CallStack; + /// SimpleConstants - These are constants we have checked and know to be + /// simple enough to live in a static initializer of a global. + SmallPtrSet SimpleConstants; + // Call the function. Constant *RetValDummy; bool EvalSuccess = EvaluateFunction(F, RetValDummy, SmallVector(), CallStack, - MutatedMemory, AllocaTmps); + MutatedMemory, AllocaTmps, + SimpleConstants); if (EvalSuccess) { // We succeeded at evaluation: commit the result. DEBUG(dbgs() << "FULLY EVALUATED GLOBAL CTOR FUNCTION '" Added: llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll?rev=121100&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll (added) +++ llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll Mon Dec 6 19:59:32 2010 @@ -0,0 +1,23 @@ +; RUN: opt -globalopt %s -S | FileCheck %s +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" +target triple = "x86_64-apple-darwin10.0.0" + +%0 = type { i32, void ()* } +%struct.foo = type { i32* } + + at G = global i32 0, align 4 + at H = global i32 0, align 4 + at X = global %struct.foo zeroinitializer, align 8 + at llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, void ()* @init }] + +; PR8710 - GlobalOpt shouldn't change the global's initializer to have this +; arbitrary constant expression, the code generator can't handle it. +define internal void @init() { +entry: + %tmp = getelementptr inbounds %struct.foo* @X, i32 0, i32 0 + store i32* inttoptr (i64 sdiv (i64 ptrtoint (i32* @G to i64), i64 ptrtoint (i32* @H to i64)) to i32*), i32** %tmp, align 8 + ret void +} + +; CHECK: @init +; CHECK: store i32* From echristo at apple.com Mon Dec 6 20:05:42 2010 From: echristo at apple.com (Eric Christopher) Date: Tue, 07 Dec 2010 02:05:42 -0000 Subject: [llvm-commits] [llvm] r121101 - in /llvm/trunk: autoconf/configure.ac configure Message-ID: <20101207020542.854772A6C12C@llvm.org> Author: echristo Date: Mon Dec 6 20:05:42 2010 New Revision: 121101 URL: http://llvm.org/viewvc/llvm-project?rev=121101&view=rev Log: Two things: Fix testcase to use extern - otherwise the link will always succeed. Also make the testcase clearer as to what we're doing and emit a checking notification to the log. Modified: llvm/trunk/autoconf/configure.ac llvm/trunk/configure Modified: llvm/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=121101&r1=121100&r2=121101&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Mon Dec 6 20:05:42 2010 @@ -1325,13 +1325,21 @@ AC_CHECK_HEADERS([CrashReporterClient.h]) dnl Try to find Darwin specific crash reporting global. -AC_LINK_IFELSE([AC_LANG_PROGRAM([[const char *__crashreporter_info__;]], [[]])],[darwin_crashreport = yes],[darwin_crashreport = no]) -AC_MSG_RESULT($darwin_crashreport) -if test "x$darwin_crashreport = xyes" -then - AC_DEFINE([HAVE_CRASHREPORTER_INFO],[1], - [Define if __crashreporter_info__ exists.]) -fi +AC_MSG_CHECKING([__crashreporter_info__]) +AC_LINK_IFELSE( + AC_LANG_SOURCE( + [[extern const char *__crashreporter_info__; + int main() { + __crashreporter_info__ = "test"; + return 0; + } + ]]), + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_CRASHREPORTER_INFO, 1, Can use __crashreporter_info__), + AC_MSG_RESULT(no) + AC_DEFINE(HAVE_CRASHREPORTER_INFO, 0, + Define if __crashreporter_info__ exists.)) + dnl===-----------------------------------------------------------------------=== dnl=== dnl=== SECTION 7: Check for types and structures Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=121101&r1=121100&r2=121101&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Mon Dec 6 20:05:42 2010 @@ -17419,20 +17419,20 @@ done +{ echo "$as_me:$LINENO: checking __crashreporter_info__" >&5 +echo $ECHO_N "checking __crashreporter_info__... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -const char *__crashreporter_info__; -int -main () -{ +extern const char *__crashreporter_info__; + int main() { + __crashreporter_info__ = "test"; + return 0; + } - ; - return 0; -} _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" @@ -17468,27 +17468,30 @@ ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - darwin_crashreport = yes + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define HAVE_CRASHREPORTER_INFO 1 +_ACEOF + else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - darwin_crashreport = no -fi - -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $darwin_crashreport" >&5 -echo "${ECHO_T}$darwin_crashreport" >&6; } -if test "x$darwin_crashreport = xyes" -then + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } cat >>confdefs.h <<\_ACEOF -#define HAVE_CRASHREPORTER_INFO 1 +#define HAVE_CRASHREPORTER_INFO 0 _ACEOF fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + { echo "$as_me:$LINENO: checking for HUGE_VAL sanity" >&5 From echristo at apple.com Mon Dec 6 20:41:11 2010 From: echristo at apple.com (Eric Christopher) Date: Tue, 07 Dec 2010 02:41:11 -0000 Subject: [llvm-commits] [llvm] r121102 - in /llvm/trunk: lib/Transforms/IPO/GlobalOpt.cpp test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll Message-ID: <20101207024111.586C82A6C12C@llvm.org> Author: echristo Date: Mon Dec 6 20:41:11 2010 New Revision: 121102 URL: http://llvm.org/viewvc/llvm-project?rev=121102&view=rev Log: Temporarily revert r121100 as it's causing clang to fail CodeGenCXX/virtual-base-ctor.cpp. Removed: llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=121102&r1=121101&r2=121102&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Mon Dec 6 20:41:11 2010 @@ -2046,82 +2046,14 @@ } -static Constant *getVal(DenseMap &ComputedValues, Value *V) { +static Constant *getVal(DenseMap &ComputedValues, + Value *V) { if (Constant *CV = dyn_cast(V)) return CV; Constant *R = ComputedValues[V]; assert(R && "Reference to an uncomputed value!"); return R; } -static inline bool -isSimpleEnoughValueToCommit(Constant *C, - SmallPtrSet &SimpleConstants); - - -/// isSimpleEnoughValueToCommit - Return true if the specified constant can be -/// handled by the code generator. We don't want to generate something like: -/// void *X = &X/42; -/// because the code generator doesn't have a relocation that can handle that. -/// -/// This function should be called if C was not found (but just got inserted) -/// in SimpleConstants to avoid having to rescan the same constants all the -/// time. -static bool isSimpleEnoughValueToCommitHelper(Constant *C, - SmallPtrSet &SimpleConstants) { - // Simple integer, undef, constant aggregate zero, global addresses, etc are - // all supported. - if (C->getNumOperands() == 0 || isa(C) || - isa(C)) - return true; - - // Aggregate values are safe if all their elements are. - if (isa(C) || isa(C) || - isa(C)) { - for (unsigned i = 0, e = C->getNumOperands(); i != e; ++i) { - Constant *Op = cast(C->getOperand(i)); - if (!isSimpleEnoughValueToCommit(Op, SimpleConstants)) - return false; - } - return true; - } - - // We don't know exactly what relocations are allowed in constant expressions, - // so we allow &global+constantoffset, which is safe and uniformly supported - // across targets. - ConstantExpr *CE = cast(C); - switch (CE->getOpcode()) { - case Instruction::BitCast: - case Instruction::IntToPtr: - case Instruction::PtrToInt: - // These casts are always fine if the casted value is. - return isSimpleEnoughValueToCommit(CE->getOperand(0), SimpleConstants); - - // GEP is fine if it is simple + constant offset. - case Instruction::GetElementPtr: - for (unsigned i = 1, e = CE->getNumOperands(); i != e; ++i) - if (!isa(CE->getOperand(i))) - return false; - return isSimpleEnoughValueToCommit(CE->getOperand(0), SimpleConstants); - - case Instruction::Add: - // We allow simple+cst. - if (!isa(CE->getOperand(1))) - return false; - return isSimpleEnoughValueToCommit(CE->getOperand(0), SimpleConstants); - } - return false; -} - -static inline bool -isSimpleEnoughValueToCommit(Constant *C, - SmallPtrSet &SimpleConstants) { - // If we already checked this constant, we win. - if (!SimpleConstants.insert(C)) return true; - // Check the constant. - return isSimpleEnoughValueToCommitHelper(C, SimpleConstants); -} - - /// isSimpleEnoughPointerToCommit - Return true if this constant is simple /// enough for us to understand. In particular, if it is a cast of something, /// we punt. We basically just support direct accesses to globals and GEP's of @@ -2287,8 +2219,7 @@ const SmallVectorImpl &ActualArgs, std::vector &CallStack, DenseMap &MutatedMemory, - std::vector &AllocaTmps, - SmallPtrSet &SimpleConstants) { + std::vector &AllocaTmps) { // Check to see if this function is already executing (recursion). If so, // bail out. TODO: we might want to accept limited recursion. if (std::find(CallStack.begin(), CallStack.end(), F) != CallStack.end()) @@ -2323,13 +2254,7 @@ if (!isSimpleEnoughPointerToCommit(Ptr)) // If this is too complex for us to commit, reject it. return false; - Constant *Val = getVal(Values, SI->getOperand(0)); - - // If this might be too difficult for the backend to handle (e.g. the addr - // of one global variable divided by another) then we can't commit it. - if (!isSimpleEnoughValueToCommit(Val, SimpleConstants)) - return false; MutatedMemory[Ptr] = Val; } else if (BinaryOperator *BO = dyn_cast(CurInst)) { InstResult = ConstantExpr::get(BO->getOpcode(), @@ -2406,7 +2331,7 @@ Constant *RetVal; // Execute the call, if successful, use the return value. if (!EvaluateFunction(Callee, RetVal, Formals, CallStack, - MutatedMemory, AllocaTmps, SimpleConstants)) + MutatedMemory, AllocaTmps)) return false; InstResult = RetVal; } @@ -2492,16 +2417,11 @@ /// unbounded. std::vector CallStack; - /// SimpleConstants - These are constants we have checked and know to be - /// simple enough to live in a static initializer of a global. - SmallPtrSet SimpleConstants; - // Call the function. Constant *RetValDummy; bool EvalSuccess = EvaluateFunction(F, RetValDummy, SmallVector(), CallStack, - MutatedMemory, AllocaTmps, - SimpleConstants); + MutatedMemory, AllocaTmps); if (EvalSuccess) { // We succeeded at evaluation: commit the result. DEBUG(dbgs() << "FULLY EVALUATED GLOBAL CTOR FUNCTION '" Removed: llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll?rev=121101&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll (removed) @@ -1,23 +0,0 @@ -; RUN: opt -globalopt %s -S | FileCheck %s -target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" -target triple = "x86_64-apple-darwin10.0.0" - -%0 = type { i32, void ()* } -%struct.foo = type { i32* } - - at G = global i32 0, align 4 - at H = global i32 0, align 4 - at X = global %struct.foo zeroinitializer, align 8 - at llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, void ()* @init }] - -; PR8710 - GlobalOpt shouldn't change the global's initializer to have this -; arbitrary constant expression, the code generator can't handle it. -define internal void @init() { -entry: - %tmp = getelementptr inbounds %struct.foo* @X, i32 0, i32 0 - store i32* inttoptr (i64 sdiv (i64 ptrtoint (i32* @G to i64), i64 ptrtoint (i32* @H to i64)) to i32*), i32** %tmp, align 8 - ret void -} - -; CHECK: @init -; CHECK: store i32* From geek4civic at gmail.com Mon Dec 6 20:43:45 2010 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Tue, 07 Dec 2010 02:43:45 -0000 Subject: [llvm-commits] [llvm] r121103 - /llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp Message-ID: <20101207024345.465992A6C12C@llvm.org> Author: chapuni Date: Mon Dec 6 20:43:45 2010 New Revision: 121103 URL: http://llvm.org/viewvc/llvm-project?rev=121103&view=rev Log: lib/Target/X86/X86MCAsmInfo.cpp: [PR8741] On Win64, specify explicit PrivateGlobalPrefix as ".L". Or, global symbols @Lxxxx might be treated as temporal symbol by MCSymbol. Modified: llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp?rev=121103&r1=121102&r2=121103&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp Mon Dec 6 20:43:45 2010 @@ -103,8 +103,10 @@ } X86MCAsmInfoCOFF::X86MCAsmInfoCOFF(const Triple &Triple) { - if (Triple.getArch() == Triple::x86_64) + if (Triple.getArch() == Triple::x86_64) { GlobalPrefix = ""; + PrivateGlobalPrefix = ".L"; + } AsmTransCBE = x86_asm_table; AssemblerDialect = AsmWriterFlavor; From geek4civic at gmail.com Mon Dec 6 20:43:51 2010 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Tue, 07 Dec 2010 02:43:51 -0000 Subject: [llvm-commits] [llvm] r121104 - /llvm/trunk/test/lit.cfg Message-ID: <20101207024351.4C61E2A6C12D@llvm.org> Author: chapuni Date: Mon Dec 6 20:43:51 2010 New Revision: 121104 URL: http://llvm.org/viewvc/llvm-project?rev=121104&view=rev Log: test: Add the feature 'shell' on LLVM_ON_UNIX. Modified: llvm/trunk/test/lit.cfg Modified: llvm/trunk/test/lit.cfg URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/lit.cfg?rev=121104&r1=121103&r2=121104&view=diff ============================================================================== --- llvm/trunk/test/lit.cfg (original) +++ llvm/trunk/test/lit.cfg Mon Dec 6 20:43:51 2010 @@ -226,6 +226,10 @@ ### Features +# Shell execution +if sys.platform not in ['win32']: + config.available_features.add('shell') + # Loadable module # FIXME: This should be supplied by Makefile or autoconf. if sys.platform in ['win32', 'cygwin']: From geek4civic at gmail.com Mon Dec 6 20:43:58 2010 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Tue, 07 Dec 2010 02:43:58 -0000 Subject: [llvm-commits] [llvm] r121105 - /llvm/trunk/test/Other/close-stderr.ll Message-ID: <20101207024358.5B26F2A6C12C@llvm.org> Author: chapuni Date: Mon Dec 6 20:43:58 2010 New Revision: 121105 URL: http://llvm.org/viewvc/llvm-project?rev=121105&view=rev Log: test/Other/close-stderr.ll: Require the feature 'shell'. It is not executable on Win32 but it is executable on MSYS-bash. Modified: llvm/trunk/test/Other/close-stderr.ll Modified: llvm/trunk/test/Other/close-stderr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/close-stderr.ll?rev=121105&r1=121104&r2=121105&view=diff ============================================================================== --- llvm/trunk/test/Other/close-stderr.ll (original) +++ llvm/trunk/test/Other/close-stderr.ll Mon Dec 6 20:43:58 2010 @@ -5,6 +5,7 @@ ; CHECK: {{^1$}} ; CHECK: {{^0$}} ; XFAIL: vg_leak +; REQUIRES: shell ; Test that the error handling when writing to stderr fails exits the ; program cleanly rather than aborting. From geek4civic at gmail.com Mon Dec 6 21:35:20 2010 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Tue, 07 Dec 2010 03:35:20 -0000 Subject: [llvm-commits] [llvm] r121106 - /llvm/trunk/test/Archive/check_binary_output.ll Message-ID: <20101207033520.733C02A6C12C@llvm.org> Author: chapuni Date: Mon Dec 6 21:35:20 2010 New Revision: 121106 URL: http://llvm.org/viewvc/llvm-project?rev=121106&view=rev Log: test/Archive/check_binary_output.ll: Add a new test to check output of 'llvm-ar -p' is sane. Thanks to Danil Malyshev! Added: llvm/trunk/test/Archive/check_binary_output.ll Added: llvm/trunk/test/Archive/check_binary_output.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Archive/check_binary_output.ll?rev=121106&view=auto ============================================================================== --- llvm/trunk/test/Archive/check_binary_output.ll (added) +++ llvm/trunk/test/Archive/check_binary_output.ll Mon Dec 6 21:35:20 2010 @@ -0,0 +1,4 @@ +; This is not an assembly file, this is just to run the test. +; The test verifies that llvm-ar produces a binary output. + +;RUN: llvm-ar p %p/GNU.a very_long_bytecode_file_name.bc | cmp -s %p/very_long_bytecode_file_name.bc - From rafael.espindola at gmail.com Mon Dec 6 21:50:15 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 07 Dec 2010 03:50:15 -0000 Subject: [llvm-commits] [llvm] r121107 - in /llvm/trunk: lib/MC/MachObjectWriter.cpp test/MC/MachO/pcrel-to-other-section.s Message-ID: <20101207035015.0FA792A6C12C@llvm.org> Author: rafael Date: Mon Dec 6 21:50:14 2010 New Revision: 121107 URL: http://llvm.org/viewvc/llvm-project?rev=121107&view=rev Log: Fix pcrel relocations that cross sections. Added: llvm/trunk/test/MC/MachO/pcrel-to-other-section.s Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=121107&r1=121106&r2=121107&view=diff ============================================================================== --- llvm/trunk/lib/MC/MachObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/MachObjectWriter.cpp Mon Dec 6 21:50:14 2010 @@ -898,9 +898,9 @@ // The index is the section ordinal (1-based). Index = SD->getFragment()->getParent()->getOrdinal() + 1; FixedValue += getSectionAddress(SD->getFragment()->getParent()); - if (IsPCRel) - FixedValue -= getSectionAddress(Fragment->getParent()); } + if (IsPCRel) + FixedValue -= getSectionAddress(Fragment->getParent()); Type = macho::RIT_Vanilla; } Added: llvm/trunk/test/MC/MachO/pcrel-to-other-section.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/pcrel-to-other-section.s?rev=121107&view=auto ============================================================================== --- llvm/trunk/test/MC/MachO/pcrel-to-other-section.s (added) +++ llvm/trunk/test/MC/MachO/pcrel-to-other-section.s Mon Dec 6 21:50:14 2010 @@ -0,0 +1,107 @@ +// RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o - | macho-dump --dump-section-data | FileCheck %s + +nop + .section __TEXT,__StaticInit,regular,pure_instructions + calll foo + +// CHECK: ('cputype', 7) +// CHECK-NEXT: ('cpusubtype', 3) +// CHECK-NEXT: ('filetype', 1) +// CHECK-NEXT: ('num_load_commands', 3) +// CHECK-NEXT: ('load_commands_size', 296) +// CHECK-NEXT: ('flag', 0) +// CHECK-NEXT: ('load_commands', [ +// CHECK-NEXT: # Load Command 0 +// CHECK-NEXT: (('command', 1) +// CHECK-NEXT: ('size', 192) +// CHECK-NEXT: ('segment_name', '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-NEXT: ('vm_addr', 0) +// CHECK-NEXT: ('vm_size', 6) +// CHECK-NEXT: ('file_offset', 324) +// CHECK-NEXT: ('file_size', 6) +// CHECK-NEXT: ('maxprot', 7) +// CHECK-NEXT: ('initprot', 7) +// CHECK-NEXT: ('num_sections', 2) +// CHECK-NEXT: ('flags', 0) +// CHECK-NEXT: ('sections', [ +// CHECK-NEXT: # Section 0 +// CHECK-NEXT: (('section_name', '__text\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-NEXT: ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-NEXT: ('address', 0) +// CHECK-NEXT: ('size', 1) +// CHECK-NEXT: ('offset', 324) +// CHECK-NEXT: ('alignment', 0) +// CHECK-NEXT: ('reloc_offset', 0) +// CHECK-NEXT: ('num_reloc', 0) +// CHECK-NEXT: ('flags', 0x80000400) +// CHECK-NEXT: ('reserved1', 0) +// CHECK-NEXT: ('reserved2', 0) +// CHECK-NEXT: ), +// CHECK-NEXT: ('_relocations', [ +// CHECK-NEXT: ]) +// CHECK-NEXT: ('_section_data', '90') +// CHECK-NEXT: # Section 1 +// CHECK-NEXT: (('section_name', '__StaticInit\x00\x00\x00\x00') +// CHECK-NEXT: ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-NEXT: ('address', 1) +// CHECK-NEXT: ('size', 5) +// CHECK-NEXT: ('offset', 325) +// CHECK-NEXT: ('alignment', 0) +// CHECK-NEXT: ('reloc_offset', 332) +// CHECK-NEXT: ('num_reloc', 1) +// CHECK-NEXT: ('flags', 0x80000400) +// CHECK-NEXT: ('reserved1', 0) +// CHECK-NEXT: ('reserved2', 0) +// CHECK-NEXT: ), +// CHECK-NEXT: ('_relocations', [ +// CHECK-NEXT: # Relocation 0 +// CHECK-NEXT: (('word-0', 0x1), +// CHECK-NEXT: ('word-1', 0xd000000)), +// CHECK-NEXT: ]) +// CHECK-NEXT: ('_section_data', 'e8faffff ff') +// CHECK-NEXT: ]) +// CHECK-NEXT: ), +// CHECK-NEXT: # Load Command 1 +// CHECK-NEXT: (('command', 2) +// CHECK-NEXT: ('size', 24) +// CHECK-NEXT: ('symoff', 340) +// CHECK-NEXT: ('nsyms', 1) +// CHECK-NEXT: ('stroff', 352) +// CHECK-NEXT: ('strsize', 8) +// CHECK-NEXT: ('_string_data', '\x00foo\x00\x00\x00\x00') +// CHECK-NEXT: ('_symbols', [ +// CHECK-NEXT: # Symbol 0 +// CHECK-NEXT: (('n_strx', 1) +// CHECK-NEXT: ('n_type', 0x1) +// CHECK-NEXT: ('n_sect', 0) +// CHECK-NEXT: ('n_desc', 0) +// CHECK-NEXT: ('n_value', 0) +// CHECK-NEXT: ('_string', 'foo') +// CHECK-NEXT: ), +// CHECK-NEXT: ]) +// CHECK-NEXT: ), +// CHECK-NEXT: # Load Command 2 +// CHECK-NEXT: (('command', 11) +// CHECK-NEXT: ('size', 80) +// CHECK-NEXT: ('ilocalsym', 0) +// CHECK-NEXT: ('nlocalsym', 0) +// CHECK-NEXT: ('iextdefsym', 0) +// CHECK-NEXT: ('nextdefsym', 0) +// CHECK-NEXT: ('iundefsym', 0) +// CHECK-NEXT: ('nundefsym', 1) +// CHECK-NEXT: ('tocoff', 0) +// CHECK-NEXT: ('ntoc', 0) +// CHECK-NEXT: ('modtaboff', 0) +// CHECK-NEXT: ('nmodtab', 0) +// CHECK-NEXT: ('extrefsymoff', 0) +// CHECK-NEXT: ('nextrefsyms', 0) +// CHECK-NEXT: ('indirectsymoff', 0) +// CHECK-NEXT: ('nindirectsyms', 0) +// CHECK-NEXT: ('extreloff', 0) +// CHECK-NEXT: ('nextrel', 0) +// CHECK-NEXT: ('locreloff', 0) +// CHECK-NEXT: ('nlocrel', 0) +// CHECK-NEXT: ('_indirect_symbols', [ +// CHECK-NEXT: ]) +// CHECK-NEXT: ), +// CHECK-NEXT: ]) From bigcheesegs at gmail.com Mon Dec 6 21:57:17 2010 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Tue, 07 Dec 2010 03:57:17 -0000 Subject: [llvm-commits] [llvm] r121108 - in /llvm/trunk: include/llvm/Support/FileSystem.h include/llvm/Support/PathV2.h lib/Support/PathV2.cpp unittests/Support/Path.cpp Message-ID: <20101207035717.4305E2A6C12C@llvm.org> Author: mspencer Date: Mon Dec 6 21:57:17 2010 New Revision: 121108 URL: http://llvm.org/viewvc/llvm-project?rev=121108&view=rev Log: Support/PathV2: Move make_absolute from path to fs. Modified: llvm/trunk/include/llvm/Support/FileSystem.h llvm/trunk/include/llvm/Support/PathV2.h llvm/trunk/lib/Support/PathV2.cpp llvm/trunk/unittests/Support/Path.cpp Modified: llvm/trunk/include/llvm/Support/FileSystem.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FileSystem.h?rev=121108&r1=121107&r2=121108&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/FileSystem.h (original) +++ llvm/trunk/include/llvm/Support/FileSystem.h Mon Dec 6 21:57:17 2010 @@ -104,6 +104,19 @@ /// @name Physical Operators /// @{ +/// @brief Make \a path an absolute path. +/// +/// Makes \a path absolute using the current directory if it is not already. An +/// empty \a path will result in the current directory. +/// +/// /absolute/path => /absolute/path +/// relative/../path => /relative/../path +/// +/// @param path A path that is modified to be an absolute path. +/// @returns errc::success if \a path has been made absolute, otherwise a +/// platform specific error_code. +error_code make_absolute(SmallVectorImpl &path); + /// @brief Copy the file at \a from to the path \a to. /// /// @param from The path to copy the file from. Modified: llvm/trunk/include/llvm/Support/PathV2.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PathV2.h?rev=121108&r1=121107&r2=121108&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/PathV2.h (original) +++ llvm/trunk/include/llvm/Support/PathV2.h Mon Dec 6 21:57:17 2010 @@ -117,19 +117,6 @@ /// @name Lexical Modifiers /// @{ -/// @brief Make \a path an absolute path. -/// -/// Makes \a path absolute using the current directory if it is not already. An -/// empty \a path will result in the current directory. -/// -/// /absolute/path => /absolute/path -/// relative/../path => /relative/../path -/// -/// @param path A path that is modified to be an absolute path. -/// @returns errc::success if \a path has been made absolute, otherwise a -/// platform specific error_code. -error_code make_absolute(SmallVectorImpl &path); - /// @brief Remove the last component from \a path unless it is the root dir. /// /// directory/filename.cpp => directory/ Modified: llvm/trunk/lib/Support/PathV2.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/PathV2.cpp?rev=121108&r1=121107&r2=121108&view=diff ============================================================================== --- llvm/trunk/lib/Support/PathV2.cpp (original) +++ llvm/trunk/lib/Support/PathV2.cpp Mon Dec 6 21:57:17 2010 @@ -424,61 +424,6 @@ return success; } -error_code make_absolute(SmallVectorImpl &path) { - StringRef p(path.data(), path.size()); - - bool rootName = false, rootDirectory = false; - if (error_code ec = has_root_name(p, rootName)) return ec; - if (error_code ec = has_root_directory(p, rootDirectory)) return ec; - - // Already absolute. - if (rootName && rootDirectory) - return success; - - // All of the following conditions will need the current directory. - SmallString<128> current_dir; - if (error_code ec = fs::current_path(current_dir)) return ec; - - // Relative path. Prepend the current directory. - if (!rootName && !rootDirectory) { - // Append path to the current directory. - if (error_code ec = append(current_dir, p)) return ec; - // Set path to the result. - path.swap(current_dir); - return success; - } - - if (!rootName && rootDirectory) { - StringRef cdrn; - if (error_code ec = root_name(current_dir, cdrn)) return ec; - SmallString<128> curDirRootName(cdrn.begin(), cdrn.end()); - if (error_code ec = append(curDirRootName, p)) return ec; - // Set path to the result. - path.swap(curDirRootName); - return success; - } - - if (rootName && !rootDirectory) { - StringRef pRootName; - StringRef bRootDirectory; - StringRef bRelativePath; - StringRef pRelativePath; - if (error_code ec = root_name(p, pRootName)) return ec; - if (error_code ec = root_directory(current_dir, bRootDirectory)) return ec; - if (error_code ec = relative_path(current_dir, bRelativePath)) return ec; - if (error_code ec = relative_path(p, pRelativePath)) return ec; - - SmallString<128> res; - if (error_code ec = append(res, pRootName, bRootDirectory, - bRelativePath, pRelativePath)) return ec; - path.swap(res); - return success; - } - - llvm_unreachable("All rootName and rootDirectory combinations should have " - "occurred above!"); -} - error_code parent_path(const StringRef &path, StringRef &result) { size_t end_pos = parent_path_end(path); if (end_pos == StringRef::npos) @@ -673,6 +618,63 @@ namespace fs { +error_code make_absolute(SmallVectorImpl &path) { + StringRef p(path.data(), path.size()); + + bool rootName = false, rootDirectory = false; + if (error_code ec = path::has_root_name(p, rootName)) return ec; + if (error_code ec = path::has_root_directory(p, rootDirectory)) return ec; + + // Already absolute. + if (rootName && rootDirectory) + return success; + + // All of the following conditions will need the current directory. + SmallString<128> current_dir; + if (error_code ec = current_path(current_dir)) return ec; + + // Relative path. Prepend the current directory. + if (!rootName && !rootDirectory) { + // Append path to the current directory. + if (error_code ec = path::append(current_dir, p)) return ec; + // Set path to the result. + path.swap(current_dir); + return success; + } + + if (!rootName && rootDirectory) { + StringRef cdrn; + if (error_code ec = path::root_name(current_dir, cdrn)) return ec; + SmallString<128> curDirRootName(cdrn.begin(), cdrn.end()); + if (error_code ec = path::append(curDirRootName, p)) return ec; + // Set path to the result. + path.swap(curDirRootName); + return success; + } + + if (rootName && !rootDirectory) { + StringRef pRootName; + StringRef bRootDirectory; + StringRef bRelativePath; + StringRef pRelativePath; + if (error_code ec = path::root_name(p, pRootName)) return ec; + if (error_code ec = path::root_directory(current_dir, bRootDirectory)) + return ec; + if (error_code ec = path::relative_path(current_dir, bRelativePath)) + return ec; + if (error_code ec = path::relative_path(p, pRelativePath)) return ec; + + SmallString<128> res; + if (error_code ec = path::append(res, pRootName, bRootDirectory, + bRelativePath, pRelativePath)) return ec; + path.swap(res); + return success; + } + + llvm_unreachable("All rootName and rootDirectory combinations should have " + "occurred above!"); +} + error_code create_directories(const Twine &path, bool &existed) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); Modified: llvm/trunk/unittests/Support/Path.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Path.cpp?rev=121108&r1=121107&r2=121108&view=diff ============================================================================== --- llvm/trunk/unittests/Support/Path.cpp (original) +++ llvm/trunk/unittests/Support/Path.cpp Mon Dec 6 21:57:17 2010 @@ -104,7 +104,7 @@ SmallString<16> temp_store; temp_store = *i; - ASSERT_FALSE(path::make_absolute(temp_store)); + ASSERT_FALSE(fs::make_absolute(temp_store)); temp_store = *i; ASSERT_FALSE(path::remove_filename(temp_store)); From bigcheesegs at gmail.com Mon Dec 6 21:57:37 2010 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Tue, 07 Dec 2010 03:57:37 -0000 Subject: [llvm-commits] [llvm] r121109 - in /llvm/trunk: include/llvm/Support/PathV2.h lib/Support/PathV2.cpp lib/Support/Unix/PathV2.inc lib/Support/Windows/PathV2.inc unittests/Support/Path.cpp Message-ID: <20101207035737.61E342A6C12C@llvm.org> Author: mspencer Date: Mon Dec 6 21:57:37 2010 New Revision: 121109 URL: http://llvm.org/viewvc/llvm-project?rev=121109&view=rev Log: Support/PathV2: Remove the error_code return type from all functions in the path namespace. None of them return anything except for success anyway. These will be converted to returning their result soon. Modified: llvm/trunk/include/llvm/Support/PathV2.h llvm/trunk/lib/Support/PathV2.cpp llvm/trunk/lib/Support/Unix/PathV2.inc llvm/trunk/lib/Support/Windows/PathV2.inc llvm/trunk/unittests/Support/Path.cpp Modified: llvm/trunk/include/llvm/Support/PathV2.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PathV2.h?rev=121109&r1=121108&r2=121109&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/PathV2.h (original) +++ llvm/trunk/include/llvm/Support/PathV2.h Mon Dec 6 21:57:37 2010 @@ -11,16 +11,7 @@ // TR2/boost filesystem (v3), but modified to remove exception handling and the // path class. // -// All functions return an error_code and their actual work via the last out -// argument. The out argument is defined if and only if errc::success is -// returned. A function may return any error code in the generic or system -// category. However, they shall be equivalent to any error conditions listed -// in each functions respective documentation if the condition applies. [ note: -// this does not guarantee that error_code will be in the set of explicitly -// listed codes, but it does guarantee that if any of the explicitly listed -// errors occur, the correct error_code will be used ]. All functions may -// return errc::not_enough_memory if there is not enough memory to complete the -// operation. +// All functions return void and their actual work via the last out argument. // //===----------------------------------------------------------------------===// @@ -30,7 +21,6 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/DataTypes.h" -#include "llvm/Support/system_error.h" #include namespace llvm { @@ -124,9 +114,7 @@ /// / => / /// /// @param path A path that is modified to not have a file component. -/// @returns errc::success if \a path's file name has been removed (or there was -/// not one to begin with), otherwise a platform specific error_code. -error_code remove_filename(SmallVectorImpl &path); +void remove_filename(SmallVectorImpl &path); /// @brief Replace the file extension of \a path with \a extension. /// @@ -138,9 +126,7 @@ /// @param extension The extension to be added. It may be empty. It may also /// optionally start with a '.', if it does not, one will be /// prepended. -/// @returns errc::success if \a path's extension has been replaced, otherwise a -/// platform specific error_code. -error_code replace_extension(SmallVectorImpl &path, +void replace_extension(SmallVectorImpl &path, const Twine &extension); /// @brief Append to path. @@ -151,9 +137,7 @@ /// /// @param path Set to \a path + \a component. /// @param component The component to be appended to \a path. -/// @returns errc::success if \a component has been appended to \a path, -/// otherwise a platform specific error_code. -error_code append(SmallVectorImpl &path, const Twine &a, +void append(SmallVectorImpl &path, const Twine &a, const Twine &b = "", const Twine &c = "", const Twine &d = ""); @@ -167,9 +151,7 @@ /// @param path Set to \a path + [\a begin, \a end). /// @param begin Start of components to append. /// @param end One past the end of components to append. -/// @returns errc::success if [\a begin, \a end) has been appended to \a path, -/// otherwise a platform specific error_code. -error_code append(SmallVectorImpl &path, +void append(SmallVectorImpl &path, const_iterator begin, const_iterator end); /// @} @@ -182,9 +164,7 @@ /// /// @param path A path that is transformed to native format. /// @param result Holds the result of the transformation. -/// @returns errc::success if \a path has been transformed and stored in result, -/// otherwise a platform specific error_code. -error_code native(const Twine &path, SmallVectorImpl &result); +void native(const Twine &path, SmallVectorImpl &result); /// @} /// @name Lexical Observers @@ -198,9 +178,7 @@ /// /// @param path Input path. /// @param result Set to the root name of \a path if it has one, otherwise "". -/// @results errc::success if result has been successfully set, otherwise a -/// platform specific error_code. -error_code root_name(const StringRef &path, StringRef &result); +void root_name(const StringRef &path, StringRef &result); /// @brief Get root directory. /// @@ -211,9 +189,7 @@ /// @param path Input path. /// @param result Set to the root directory of \a path if it has one, otherwise /// "". -/// @results errc::success if result has been successfully set, otherwise a -/// platform specific error_code. -error_code root_directory(const StringRef &path, StringRef &result); +void root_directory(const StringRef &path, StringRef &result); /// @brief Get root path. /// @@ -221,9 +197,7 @@ /// /// @param path Input path. /// @param result Set to the root path of \a path if it has one, otherwise "". -/// @results errc::success if result has been successfully set, otherwise a -/// platform specific error_code. -error_code root_path(const StringRef &path, StringRef &result); +void root_path(const StringRef &path, StringRef &result); /// @brief Get relative path. /// @@ -234,9 +208,7 @@ /// @param path Input path. /// @param result Set to the path starting after root_path if one exists, /// otherwise "". -/// @results errc::success if result has been successfully set, otherwise a -/// platform specific error_code. -error_code relative_path(const StringRef &path, StringRef &result); +void relative_path(const StringRef &path, StringRef &result); /// @brief Get parent path. /// @@ -246,9 +218,7 @@ /// /// @param path Input path. /// @param result Set to the parent path of \a path if one exists, otherwise "". -/// @results errc::success if result has been successfully set, otherwise a -/// platform specific error_code. -error_code parent_path(const StringRef &path, StringRef &result); +void parent_path(const StringRef &path, StringRef &result); /// @brief Get filename. /// @@ -260,9 +230,7 @@ /// @param path Input path. /// @param result Set to the filename part of \a path. This is defined as the /// last component of \a path. -/// @results errc::success if result has been successfully set, otherwise a -/// platform specific error_code. -error_code filename(const StringRef &path, StringRef &result); +void filename(const StringRef &path, StringRef &result); /// @brief Get stem. /// @@ -278,9 +246,7 @@ /// /// @param path Input path. /// @param result Set to the stem of \a path. -/// @results errc::success if result has been successfully set, otherwise a -/// platform specific error_code. -error_code stem(const StringRef &path, StringRef &result); +void stem(const StringRef &path, StringRef &result); /// @brief Get extension. /// @@ -294,9 +260,7 @@ /// /// @param path Input path. /// @param result Set to the extension of \a path. -/// @results errc::success if result has been successfully set, otherwise a -/// platform specific error_code. -error_code extension(const StringRef &path, StringRef &result); +void extension(const StringRef &path, StringRef &result); /// @brief Has root name? /// @@ -304,9 +268,7 @@ /// /// @param path Input path. /// @param result Set to true if the path has a root name, false otherwise. -/// @results errc::success if result has been successfully set, otherwise a -/// platform specific error_code. -error_code has_root_name(const Twine &path, bool &result); +void has_root_name(const Twine &path, bool &result); /// @brief Has root directory? /// @@ -314,9 +276,7 @@ /// /// @param path Input path. /// @param result Set to true if the path has a root directory, false otherwise. -/// @results errc::success if result has been successfully set, otherwise a -/// platform specific error_code. -error_code has_root_directory(const Twine &path, bool &result); +void has_root_directory(const Twine &path, bool &result); /// @brief Has root path? /// @@ -324,9 +284,7 @@ /// /// @param path Input path. /// @param result Set to true if the path has a root path, false otherwise. -/// @results errc::success if result has been successfully set, otherwise a -/// platform specific error_code. -error_code has_root_path(const Twine &path, bool &result); +void has_root_path(const Twine &path, bool &result); /// @brief Has relative path? /// @@ -334,9 +292,7 @@ /// /// @param path Input path. /// @param result Set to true if the path has a relative path, false otherwise. -/// @results errc::success if result has been successfully set, otherwise a -/// platform specific error_code. -error_code has_relative_path(const Twine &path, bool &result); +void has_relative_path(const Twine &path, bool &result); /// @brief Has parent path? /// @@ -344,9 +300,7 @@ /// /// @param path Input path. /// @param result Set to true if the path has a parent path, false otherwise. -/// @results errc::success if result has been successfully set, otherwise a -/// platform specific error_code. -error_code has_parent_path(const Twine &path, bool &result); +void has_parent_path(const Twine &path, bool &result); /// @brief Has filename? /// @@ -354,9 +308,7 @@ /// /// @param path Input path. /// @param result Set to true if the path has a filename, false otherwise. -/// @results errc::success if result has been successfully set, otherwise a -/// platform specific error_code. -error_code has_filename(const Twine &path, bool &result); +void has_filename(const Twine &path, bool &result); /// @brief Has stem? /// @@ -364,9 +316,7 @@ /// /// @param path Input path. /// @param result Set to true if the path has a stem, false otherwise. -/// @results errc::success if result has been successfully set, otherwise a -/// platform specific error_code. -error_code has_stem(const Twine &path, bool &result); +void has_stem(const Twine &path, bool &result); /// @brief Has extension? /// @@ -374,26 +324,19 @@ /// /// @param path Input path. /// @param result Set to true if the path has a extension, false otherwise. -/// @results errc::success if result has been successfully set, otherwise a -/// platform specific error_code. -error_code has_extension(const Twine &path, bool &result); +void has_extension(const Twine &path, bool &result); /// @brief Is path absolute? /// /// @param path Input path. /// @param result Set to true if the path is absolute, false if it is not. -/// @results errc::success if result has been successfully set, otherwise a -/// platform specific error_code. -error_code is_absolute(const Twine &path, bool &result); +void is_absolute(const Twine &path, bool &result); /// @brief Is path relative? /// /// @param path Input path. /// @param result Set to true if the path is relative, false if it is not. -/// @results errc::success if result has been successfully set, otherwise a -/// platform specific error_code. -error_code is_relative(const Twine &path, bool &result); -// end purely lexical. +void is_relative(const Twine &path, bool &result); } // end namespace path } // end namespace sys Modified: llvm/trunk/lib/Support/PathV2.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/PathV2.cpp?rev=121109&r1=121108&r2=121109&view=diff ============================================================================== --- llvm/trunk/lib/Support/PathV2.cpp (original) +++ llvm/trunk/lib/Support/PathV2.cpp Mon Dec 6 21:57:37 2010 @@ -276,7 +276,7 @@ return Position - RHS.Position; } -error_code root_path(const StringRef &path, StringRef &result) { +void root_path(const StringRef &path, StringRef &result) { const_iterator b = begin(path), pos = b, e = end(path); @@ -293,31 +293,25 @@ if ((++pos != e) && is_separator((*pos)[0])) { // {C:/,//net/}, so get the first two components. result = StringRef(path.begin(), b->size() + pos->size()); - return success; + return; } else { // just {C:,//net}, return the first component. result = *b; - return success; + return; } } // POSIX style root directory. if (is_separator((*b)[0])) { result = *b; - return success; + return; } - - // No root_path. - result = StringRef(); - return success; } - // No path :(. result = StringRef(); - return success; } -error_code root_name(const StringRef &path, StringRef &result) { +void root_name(const StringRef &path, StringRef &result) { const_iterator b = begin(path), e = end(path); if (b != e) { @@ -332,16 +326,16 @@ if (has_net || has_drive) { // just {C:,//net}, return the first component. result = *b; - return success; + return; } } // No path or no name. result = StringRef(); - return success; + return; } -error_code root_directory(const StringRef &path, StringRef &result) { +void root_directory(const StringRef &path, StringRef &result) { const_iterator b = begin(path), pos = b, e = end(path); @@ -358,32 +352,32 @@ // {C:,//net}, skip to the next component. (++pos != e) && is_separator((*pos)[0])) { result = *pos; - return success; + return; } // POSIX style root directory. if (!has_net && is_separator((*b)[0])) { result = *b; - return success; + return; } } // No path or no root. result = StringRef(); - return success; + return; } -error_code relative_path(const StringRef &path, StringRef &result) { +void relative_path(const StringRef &path, StringRef &result) { StringRef root; - if (error_code ec = root_path(path, root)) return ec; + root_path(path, root); result = StringRef(path.begin() + root.size(), path.size() - root.size()); - return success; + return; } -error_code append(SmallVectorImpl &path, const Twine &a, - const Twine &b, - const Twine &c, - const Twine &d) { +void append(SmallVectorImpl &path, const Twine &a, + const Twine &b, + const Twine &c, + const Twine &d) { SmallString<32> a_storage; SmallString<32> b_storage; SmallString<32> c_storage; @@ -401,7 +395,7 @@ bool path_has_sep = !path.empty() && is_separator(path[path.size() - 1]); bool component_has_sep = !i->empty() && is_separator((*i)[0]); bool is_root_name = false; - if (error_code ec = has_root_name(*i, is_root_name)) return ec; + has_root_name(*i, is_root_name); if (path_has_sep) { // Strip separators from beginning of component. @@ -420,28 +414,23 @@ path.append(i->begin(), i->end()); } - - return success; } -error_code parent_path(const StringRef &path, StringRef &result) { +void parent_path(const StringRef &path, StringRef &result) { size_t end_pos = parent_path_end(path); if (end_pos == StringRef::npos) result = StringRef(); else result = StringRef(path.data(), end_pos); - return success; } -error_code remove_filename(SmallVectorImpl &path) { +void remove_filename(SmallVectorImpl &path) { size_t end_pos = parent_path_end(StringRef(path.begin(), path.size())); - if (end_pos == StringRef::npos) - return success; - path.set_size(end_pos); - return success; + if (end_pos != StringRef::npos) + path.set_size(end_pos); } -error_code replace_extension(SmallVectorImpl &path, +void replace_extension(SmallVectorImpl &path, const Twine &extension) { StringRef p(path.begin(), path.size()); SmallString<32> ext_storage; @@ -458,10 +447,9 @@ // Append extension. path.append(ext.begin(), ext.end()); - return success; } -error_code native(const Twine &path, SmallVectorImpl &result) { +void native(const Twine &path, SmallVectorImpl &result) { // Clear result. result.clear(); #ifdef LLVM_ON_WIN32 @@ -480,17 +468,15 @@ #else path.toVector(result); #endif - return success; } -error_code filename(const StringRef &path, StringRef &result) { +void filename(const StringRef &path, StringRef &result) { result = *(--end(path)); - return success; } -error_code stem(const StringRef &path, StringRef &result) { +void stem(const StringRef &path, StringRef &result) { StringRef fname; - if (error_code ec = filename(path, fname)) return ec; + filename(path, fname); size_t pos = fname.find_last_of('.'); if (pos == StringRef::npos) result = fname; @@ -500,13 +486,11 @@ result = fname; else result = StringRef(fname.begin(), pos); - - return success; } -error_code extension(const StringRef &path, StringRef &result) { +void extension(const StringRef &path, StringRef &result) { StringRef fname; - if (error_code ec = filename(path, fname)) return ec; + filename(path, fname); size_t pos = fname.find_last_of('.'); if (pos == StringRef::npos) result = StringRef(); @@ -516,102 +500,91 @@ result = StringRef(); else result = StringRef(fname.begin() + pos, fname.size() - pos); - - return success; } -error_code has_root_name(const Twine &path, bool &result) { +void has_root_name(const Twine &path, bool &result) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); - if (error_code ec = root_name(p, p)) return ec; + root_name(p, p); result = !p.empty(); - return success; } -error_code has_root_directory(const Twine &path, bool &result) { +void has_root_directory(const Twine &path, bool &result) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); - if (error_code ec = root_directory(p, p)) return ec; + root_directory(p, p); result = !p.empty(); - return success; } -error_code has_root_path(const Twine &path, bool &result) { +void has_root_path(const Twine &path, bool &result) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); - if (error_code ec = root_path(p, p)) return ec; + root_path(p, p); result = !p.empty(); - return success; } -error_code has_filename(const Twine &path, bool &result) { +void has_filename(const Twine &path, bool &result) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); - if (error_code ec = filename(p, p)) return ec; + filename(p, p); result = !p.empty(); - return success; } -error_code has_parent_path(const Twine &path, bool &result) { +void has_parent_path(const Twine &path, bool &result) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); - if (error_code ec = parent_path(p, p)) return ec; + parent_path(p, p); result = !p.empty(); - return success; } -error_code has_stem(const Twine &path, bool &result) { +void has_stem(const Twine &path, bool &result) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); - if (error_code ec = stem(p, p)) return ec; + stem(p, p); result = !p.empty(); - return success; } -error_code has_extension(const Twine &path, bool &result) { +void has_extension(const Twine &path, bool &result) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); - if (error_code ec = extension(p, p)) return ec; + extension(p, p); result = !p.empty(); - return success; } -error_code is_absolute(const Twine &path, bool &result) { +void is_absolute(const Twine &path, bool &result) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); bool rootDir = false, rootName = false; - if (error_code ec = has_root_directory(p, rootDir)) return ec; + has_root_directory(p, rootDir); #ifdef LLVM_ON_WIN32 - if (error_code ec = has_root_name(p, rootName)) return ec; + has_root_name(p, rootName); #else rootName = true; #endif result = rootDir && rootName; - return success; } -error_code is_relative(const Twine &path, bool &result) { +void is_relative(const Twine &path, bool &result) { bool res; - error_code ec = is_absolute(path, res); + is_absolute(path, res); result = !res; - return ec; } } // end namespace path @@ -622,8 +595,8 @@ StringRef p(path.data(), path.size()); bool rootName = false, rootDirectory = false; - if (error_code ec = path::has_root_name(p, rootName)) return ec; - if (error_code ec = path::has_root_directory(p, rootDirectory)) return ec; + path::has_root_name(p, rootName); + path::has_root_directory(p, rootDirectory); // Already absolute. if (rootName && rootDirectory) @@ -636,7 +609,7 @@ // Relative path. Prepend the current directory. if (!rootName && !rootDirectory) { // Append path to the current directory. - if (error_code ec = path::append(current_dir, p)) return ec; + path::append(current_dir, p); // Set path to the result. path.swap(current_dir); return success; @@ -644,9 +617,9 @@ if (!rootName && rootDirectory) { StringRef cdrn; - if (error_code ec = path::root_name(current_dir, cdrn)) return ec; + path::root_name(current_dir, cdrn); SmallString<128> curDirRootName(cdrn.begin(), cdrn.end()); - if (error_code ec = path::append(curDirRootName, p)) return ec; + path::append(curDirRootName, p); // Set path to the result. path.swap(curDirRootName); return success; @@ -657,16 +630,13 @@ StringRef bRootDirectory; StringRef bRelativePath; StringRef pRelativePath; - if (error_code ec = path::root_name(p, pRootName)) return ec; - if (error_code ec = path::root_directory(current_dir, bRootDirectory)) - return ec; - if (error_code ec = path::relative_path(current_dir, bRelativePath)) - return ec; - if (error_code ec = path::relative_path(p, pRelativePath)) return ec; + path::root_name(p, pRootName); + path::root_directory(current_dir, bRootDirectory); + path::relative_path(current_dir, bRelativePath); + path::relative_path(p, pRelativePath); SmallString<128> res; - if (error_code ec = path::append(res, pRootName, bRootDirectory, - bRelativePath, pRelativePath)) return ec; + path::append(res, pRootName, bRootDirectory, bRelativePath, pRelativePath); path.swap(res); return success; } @@ -681,7 +651,7 @@ StringRef parent; bool parent_exists; - if (error_code ec = path::parent_path(p, parent)) return ec; + path::parent_path(p, parent); if (error_code ec = fs::exists(parent, parent_exists)) return ec; if (!parent_exists) Modified: llvm/trunk/lib/Support/Unix/PathV2.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/PathV2.inc?rev=121109&r1=121108&r2=121109&view=diff ============================================================================== --- llvm/trunk/lib/Support/Unix/PathV2.inc (original) +++ llvm/trunk/lib/Support/Unix/PathV2.inc Mon Dec 6 21:57:37 2010 @@ -325,11 +325,11 @@ // Make model absolute by prepending a temp directory if it's not already. bool absolute; - if (error_code ec = path::is_absolute(Twine(Model), absolute)) return ec; + path::is_absolute(Twine(Model), absolute); if (!absolute) { SmallString<128> TDir; if (error_code ec = TempDir(TDir)) return ec; - if (error_code ec = path::append(TDir, Twine(Model))) return ec; + path::append(TDir, Twine(Model)); Model.swap(TDir); } @@ -374,7 +374,7 @@ SmallString<64> dir_to_create; for (path::const_iterator i = path::begin(p), e = --path::end(p); i != e; ++i) { - if (error_code ec = path::append(dir_to_create, *i)) return ec; + path::append(dir_to_create, *i); bool Exists; if (error_code ec = exists(Twine(dir_to_create), Exists)) return ec; if (!Exists) { Modified: llvm/trunk/lib/Support/Windows/PathV2.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/PathV2.inc?rev=121109&r1=121108&r2=121109&view=diff ============================================================================== --- llvm/trunk/lib/Support/Windows/PathV2.inc (original) +++ llvm/trunk/lib/Support/Windows/PathV2.inc Mon Dec 6 21:57:37 2010 @@ -490,7 +490,7 @@ // Make model absolute by prepending a temp directory if it's not already. bool absolute; - if (error_code ec = path::is_absolute(m, absolute)) return ec; + path::is_absolute(m, absolute); if (!absolute) { SmallVector temp_dir; @@ -560,7 +560,7 @@ SmallString<64> dir_to_create; for (path::const_iterator i = path::begin(p), e = --path::end(p); i != e; ++i) { - if (error_code ec = path::append(dir_to_create, *i)) return ec; + path::append(dir_to_create, *i); bool Exists; if (error_code ec = exists(Twine(dir_to_create), Exists)) return ec; if (!Exists) { Modified: llvm/trunk/unittests/Support/Path.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Path.cpp?rev=121109&r1=121108&r2=121109&view=diff ============================================================================== --- llvm/trunk/unittests/Support/Path.cpp (original) +++ llvm/trunk/unittests/Support/Path.cpp Mon Dec 6 21:57:37 2010 @@ -85,37 +85,37 @@ bool bres; StringRef sfres; - ASSERT_FALSE(path::has_root_path(*i, bres)); - ASSERT_FALSE(path::root_path(*i, sfres)); - ASSERT_FALSE(path::has_root_name(*i, bres)); - ASSERT_FALSE(path::root_name(*i, sfres)); - ASSERT_FALSE(path::has_root_directory(*i, bres)); - ASSERT_FALSE(path::root_directory(*i, sfres)); - ASSERT_FALSE(path::has_parent_path(*i, bres)); - ASSERT_FALSE(path::parent_path(*i, sfres)); - ASSERT_FALSE(path::has_filename(*i, bres)); - ASSERT_FALSE(path::filename(*i, sfres)); - ASSERT_FALSE(path::has_stem(*i, bres)); - ASSERT_FALSE(path::stem(*i, sfres)); - ASSERT_FALSE(path::has_extension(*i, bres)); - ASSERT_FALSE(path::extension(*i, sfres)); - ASSERT_FALSE(path::is_absolute(*i, bres)); - ASSERT_FALSE(path::is_relative(*i, bres)); + path::has_root_path(*i, bres); + path::root_path(*i, sfres); + path::has_root_name(*i, bres); + path::root_name(*i, sfres); + path::has_root_directory(*i, bres); + path::root_directory(*i, sfres); + path::has_parent_path(*i, bres); + path::parent_path(*i, sfres); + path::has_filename(*i, bres); + path::filename(*i, sfres); + path::has_stem(*i, bres); + path::stem(*i, sfres); + path::has_extension(*i, bres); + path::extension(*i, sfres); + path::is_absolute(*i, bres); + path::is_relative(*i, bres); SmallString<16> temp_store; temp_store = *i; ASSERT_FALSE(fs::make_absolute(temp_store)); temp_store = *i; - ASSERT_FALSE(path::remove_filename(temp_store)); + path::remove_filename(temp_store); temp_store = *i; - ASSERT_FALSE(path::replace_extension(temp_store, "ext")); + path::replace_extension(temp_store, "ext"); StringRef filename(temp_store.begin(), temp_store.size()), stem, ext; - ASSERT_FALSE(path::stem(filename, stem)); - ASSERT_FALSE(path::extension(filename, ext)); + path::stem(filename, stem); + path::extension(filename, ext); EXPECT_EQ(*(--sys::path::end(filename)), (stem + ext).str()); - ASSERT_FALSE(path::native(*i, temp_store)); + path::native(*i, temp_store); outs().flush(); } From bigcheesegs at gmail.com Mon Dec 6 21:57:48 2010 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Tue, 07 Dec 2010 03:57:48 -0000 Subject: [llvm-commits] [llvm] r121110 - /llvm/trunk/lib/Support/PathV2.cpp Message-ID: <20101207035748.6265B2A6C12C@llvm.org> Author: mspencer Date: Mon Dec 6 21:57:48 2010 New Revision: 121110 URL: http://llvm.org/viewvc/llvm-project?rev=121110&view=rev Log: Support/PathV2: Cleanup separator handling. Modified: llvm/trunk/lib/Support/PathV2.cpp Modified: llvm/trunk/lib/Support/PathV2.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/PathV2.cpp?rev=121110&r1=121109&r2=121110&view=diff ============================================================================== --- llvm/trunk/lib/Support/PathV2.cpp (original) +++ llvm/trunk/lib/Support/PathV2.cpp Mon Dec 6 21:57:48 2010 @@ -31,7 +31,7 @@ #ifdef LLVM_ON_WIN32 const StringRef separators = "\\/"; - const char prefered_separator = '\\'; + const char prefered_separator = '\\'; #else const StringRef separators = "/"; const char prefered_separator = '/'; @@ -50,16 +50,19 @@ if (path.empty()) return path; +#ifdef LLVM_ON_WIN32 // C: if (path.size() >= 2 && std::isalpha(path[0]) && path[1] == ':') return StringRef(path.begin(), 2); +#endif // //net if ((path.size() > 2) && - (path.startswith("\\\\") || path.startswith("//")) && - (path[2] != '\\' && path[2] != '/')) { + is_separator(path[0]) && + path[0] == path[1] && + !is_separator(path[2])) { // Find the next directory separator. - size_t end = path.find_first_of("\\/", 2); + size_t end = path.find_first_of(separators, 2); if (end == StringRef::npos) return path; else @@ -67,7 +70,7 @@ } // {/,\} - if (path[0] == '\\' || path[0] == '/') + if (is_separator(path[0])) return StringRef(path.begin(), 1); if (path.startswith("..")) @@ -77,7 +80,7 @@ return StringRef(path.begin(), 1); // * {file,directory}name - size_t end = path.find_first_of("\\/", 2); + size_t end = path.find_first_of(separators, 2); if (end == StringRef::npos) return path; else @@ -89,7 +92,7 @@ size_t filename_pos(const StringRef &str) { if (str.size() == 2 && is_separator(str[0]) && - is_separator(str[1])) + str[0] == str[1]) return 0; if (str.size() > 0 && is_separator(str[str.size() - 1])) From sabre at nondot.org Mon Dec 6 22:33:30 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 07 Dec 2010 04:33:30 -0000 Subject: [llvm-commits] [llvm] r121111 - in /llvm/trunk: lib/Transforms/IPO/GlobalOpt.cpp test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll Message-ID: <20101207043330.1478B2A6C12C@llvm.org> Author: lattner Date: Mon Dec 6 22:33:29 2010 New Revision: 121111 URL: http://llvm.org/viewvc/llvm-project?rev=121111&view=rev Log: reapply r121100 with a tweak to constant fold ConstExprs with TargetData (if available) as we go so that we get simple constantexprs not insane ones. This fixes the failure of clang/test/CodeGenCXX/virtual-base-ctor.cpp that the previous iteration of this patch had. Added: llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=121111&r1=121110&r2=121111&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Mon Dec 6 22:33:29 2010 @@ -2046,14 +2046,82 @@ } -static Constant *getVal(DenseMap &ComputedValues, - Value *V) { +static Constant *getVal(DenseMap &ComputedValues, Value *V) { if (Constant *CV = dyn_cast(V)) return CV; Constant *R = ComputedValues[V]; assert(R && "Reference to an uncomputed value!"); return R; } +static inline bool +isSimpleEnoughValueToCommit(Constant *C, + SmallPtrSet &SimpleConstants); + + +/// isSimpleEnoughValueToCommit - Return true if the specified constant can be +/// handled by the code generator. We don't want to generate something like: +/// void *X = &X/42; +/// because the code generator doesn't have a relocation that can handle that. +/// +/// This function should be called if C was not found (but just got inserted) +/// in SimpleConstants to avoid having to rescan the same constants all the +/// time. +static bool isSimpleEnoughValueToCommitHelper(Constant *C, + SmallPtrSet &SimpleConstants) { + // Simple integer, undef, constant aggregate zero, global addresses, etc are + // all supported. + if (C->getNumOperands() == 0 || isa(C) || + isa(C)) + return true; + + // Aggregate values are safe if all their elements are. + if (isa(C) || isa(C) || + isa(C)) { + for (unsigned i = 0, e = C->getNumOperands(); i != e; ++i) { + Constant *Op = cast(C->getOperand(i)); + if (!isSimpleEnoughValueToCommit(Op, SimpleConstants)) + return false; + } + return true; + } + + // We don't know exactly what relocations are allowed in constant expressions, + // so we allow &global+constantoffset, which is safe and uniformly supported + // across targets. + ConstantExpr *CE = cast(C); + switch (CE->getOpcode()) { + case Instruction::BitCast: + case Instruction::IntToPtr: + case Instruction::PtrToInt: + // These casts are always fine if the casted value is. + return isSimpleEnoughValueToCommit(CE->getOperand(0), SimpleConstants); + + // GEP is fine if it is simple + constant offset. + case Instruction::GetElementPtr: + for (unsigned i = 1, e = CE->getNumOperands(); i != e; ++i) + if (!isa(CE->getOperand(i))) + return false; + return isSimpleEnoughValueToCommit(CE->getOperand(0), SimpleConstants); + + case Instruction::Add: + // We allow simple+cst. + if (!isa(CE->getOperand(1))) + return false; + return isSimpleEnoughValueToCommit(CE->getOperand(0), SimpleConstants); + } + return false; +} + +static inline bool +isSimpleEnoughValueToCommit(Constant *C, + SmallPtrSet &SimpleConstants) { + // If we already checked this constant, we win. + if (!SimpleConstants.insert(C)) return true; + // Check the constant. + return isSimpleEnoughValueToCommitHelper(C, SimpleConstants); +} + + /// isSimpleEnoughPointerToCommit - Return true if this constant is simple /// enough for us to understand. In particular, if it is a cast of something, /// we punt. We basically just support direct accesses to globals and GEP's of @@ -2219,7 +2287,9 @@ const SmallVectorImpl &ActualArgs, std::vector &CallStack, DenseMap &MutatedMemory, - std::vector &AllocaTmps) { + std::vector &AllocaTmps, + SmallPtrSet &SimpleConstants, + const TargetData *TD) { // Check to see if this function is already executing (recursion). If so, // bail out. TODO: we might want to accept limited recursion. if (std::find(CallStack.begin(), CallStack.end(), F) != CallStack.end()) @@ -2254,7 +2324,13 @@ if (!isSimpleEnoughPointerToCommit(Ptr)) // If this is too complex for us to commit, reject it. return false; + Constant *Val = getVal(Values, SI->getOperand(0)); + + // If this might be too difficult for the backend to handle (e.g. the addr + // of one global variable divided by another) then we can't commit it. + if (!isSimpleEnoughValueToCommit(Val, SimpleConstants)) + return false; MutatedMemory[Ptr] = Val; } else if (BinaryOperator *BO = dyn_cast(CurInst)) { InstResult = ConstantExpr::get(BO->getOpcode(), @@ -2331,7 +2407,7 @@ Constant *RetVal; // Execute the call, if successful, use the return value. if (!EvaluateFunction(Callee, RetVal, Formals, CallStack, - MutatedMemory, AllocaTmps)) + MutatedMemory, AllocaTmps, SimpleConstants, TD)) return false; InstResult = RetVal; } @@ -2391,8 +2467,12 @@ return false; } - if (!CurInst->use_empty()) + if (!CurInst->use_empty()) { + if (ConstantExpr *CE = dyn_cast(InstResult)) + InstResult = ConstantFoldConstantExpression(CE, TD); + Values[CurInst] = InstResult; + } // Advance program counter. ++CurInst; @@ -2401,7 +2481,7 @@ /// EvaluateStaticConstructor - Evaluate static constructors in the function, if /// we can. Return true if we can, false otherwise. -static bool EvaluateStaticConstructor(Function *F) { +static bool EvaluateStaticConstructor(Function *F, const TargetData *TD) { /// MutatedMemory - For each store we execute, we update this map. Loads /// check this to get the most up-to-date value. If evaluation is successful, /// this state is committed to the process. @@ -2417,11 +2497,17 @@ /// unbounded. std::vector CallStack; + /// SimpleConstants - These are constants we have checked and know to be + /// simple enough to live in a static initializer of a global. + SmallPtrSet SimpleConstants; + // Call the function. Constant *RetValDummy; bool EvalSuccess = EvaluateFunction(F, RetValDummy, SmallVector(), CallStack, - MutatedMemory, AllocaTmps); + MutatedMemory, AllocaTmps, + SimpleConstants, TD); + if (EvalSuccess) { // We succeeded at evaluation: commit the result. DEBUG(dbgs() << "FULLY EVALUATED GLOBAL CTOR FUNCTION '" @@ -2458,6 +2544,7 @@ bool MadeChange = false; if (Ctors.empty()) return false; + const TargetData *TD = getAnalysisIfAvailable(); // Loop over global ctors, optimizing them when we can. for (unsigned i = 0; i != Ctors.size(); ++i) { Function *F = Ctors[i]; @@ -2475,7 +2562,7 @@ if (F->empty()) continue; // If we can evaluate the ctor at compile time, do. - if (EvaluateStaticConstructor(F)) { + if (EvaluateStaticConstructor(F, TD)) { Ctors.erase(Ctors.begin()+i); MadeChange = true; --i; Added: llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll?rev=121111&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll (added) +++ llvm/trunk/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll Mon Dec 6 22:33:29 2010 @@ -0,0 +1,23 @@ +; RUN: opt -globalopt %s -S | FileCheck %s +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" +target triple = "x86_64-apple-darwin10.0.0" + +%0 = type { i32, void ()* } +%struct.foo = type { i32* } + + at G = global i32 0, align 4 + at H = global i32 0, align 4 + at X = global %struct.foo zeroinitializer, align 8 + at llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, void ()* @init }] + +; PR8710 - GlobalOpt shouldn't change the global's initializer to have this +; arbitrary constant expression, the code generator can't handle it. +define internal void @init() { +entry: + %tmp = getelementptr inbounds %struct.foo* @X, i32 0, i32 0 + store i32* inttoptr (i64 sdiv (i64 ptrtoint (i32* @G to i64), i64 ptrtoint (i32* @H to i64)) to i32*), i32** %tmp, align 8 + ret void +} + +; CHECK: @init +; CHECK: store i32* From geek4civic at gmail.com Mon Dec 6 23:57:03 2010 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Tue, 07 Dec 2010 05:57:03 -0000 Subject: [llvm-commits] [llvm] r121113 - /llvm/trunk/test/Archive/check_binary_output.ll Message-ID: <20101207055703.19A362A6C12C@llvm.org> Author: chapuni Date: Mon Dec 6 23:57:02 2010 New Revision: 121113 URL: http://llvm.org/viewvc/llvm-project?rev=121113&view=rev Log: Revert test/Archive/check_binary_output.ll". It fails on a buildbot. Removed: llvm/trunk/test/Archive/check_binary_output.ll Removed: llvm/trunk/test/Archive/check_binary_output.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Archive/check_binary_output.ll?rev=121112&view=auto ============================================================================== --- llvm/trunk/test/Archive/check_binary_output.ll (original) +++ llvm/trunk/test/Archive/check_binary_output.ll (removed) @@ -1,4 +0,0 @@ -; This is not an assembly file, this is just to run the test. -; The test verifies that llvm-ar produces a binary output. - -;RUN: llvm-ar p %p/GNU.a very_long_bytecode_file_name.bc | cmp -s %p/very_long_bytecode_file_name.bc - From rafael.espindola at gmail.com Mon Dec 6 23:57:28 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 07 Dec 2010 05:57:28 -0000 Subject: [llvm-commits] [llvm] r121114 - in /llvm/trunk: lib/MC/MachObjectWriter.cpp test/MC/MachO/weakdef.s Message-ID: <20101207055729.090C72A6C12C@llvm.org> Author: rafael Date: Mon Dec 6 23:57:28 2010 New Revision: 121114 URL: http://llvm.org/viewvc/llvm-project?rev=121114&view=rev Log: Fix relocations with weak definitions. Added: llvm/trunk/test/MC/MachO/weakdef.s Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=121114&r1=121113&r2=121114&view=diff ============================================================================== --- llvm/trunk/lib/MC/MachObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/MachObjectWriter.cpp Mon Dec 6 23:57:28 2010 @@ -893,7 +893,7 @@ // compensate for the addend of the symbol address, if it was // undefined. This occurs with weak definitions, for example. if (!SD->Symbol->isUndefined()) - FixedValue -= getSymbolAddress(SD, Layout); + FixedValue -= Layout.getSymbolOffset(SD); } else { // The index is the section ordinal (1-based). Index = SD->getFragment()->getParent()->getOrdinal() + 1; Added: llvm/trunk/test/MC/MachO/weakdef.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/weakdef.s?rev=121114&view=auto ============================================================================== --- llvm/trunk/test/MC/MachO/weakdef.s (added) +++ llvm/trunk/test/MC/MachO/weakdef.s Mon Dec 6 23:57:28 2010 @@ -0,0 +1,141 @@ +// RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o - | macho-dump --dump-section-data | FileCheck %s + + .section __DATA,__datacoal_nt,coalesced + .section __TEXT,__const_coal,coalesced + .globl __ZTS3optIbE ## @_ZTS3optIbE + .weak_definition __ZTS3optIbE +__ZTS3optIbE: + + + .section __DATA,__datacoal_nt,coalesced + .globl __ZTI3optIbE ## @_ZTI3optIbE + .weak_definition __ZTI3optIbE + +__ZTI3optIbE: + .long __ZTS3optIbE + +// CHECK: ('cputype', 7) +// CHECK-NEXT: ('cpusubtype', 3) +// CHECK-NEXT: ('filetype', 1) +// CHECK-NEXT: ('num_load_commands', 3) +// CHECK-NEXT: ('load_commands_size', 364) +// CHECK-NEXT: ('flag', 0) +// CHECK-NEXT: ('load_commands', [ +// CHECK-NEXT: # Load Command 0 +// CHECK-NEXT: (('command', 1) +// CHECK-NEXT: ('size', 260) +// CHECK-NEXT: ('segment_name', '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-NEXT: ('vm_addr', 0) +// CHECK-NEXT: ('vm_size', 4) +// CHECK-NEXT: ('file_offset', 392) +// CHECK-NEXT: ('file_size', 4) +// CHECK-NEXT: ('maxprot', 7) +// CHECK-NEXT: ('initprot', 7) +// CHECK-NEXT: ('num_sections', 3) +// CHECK-NEXT: ('flags', 0) +// CHECK-NEXT: ('sections', [ +// CHECK-NEXT: # Section 0 +// CHECK-NEXT: (('section_name', '__text\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-NEXT: ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-NEXT: ('address', 0) +// CHECK-NEXT: ('size', 0) +// CHECK-NEXT: ('offset', 392) +// CHECK-NEXT: ('alignment', 0) +// CHECK-NEXT: ('reloc_offset', 0) +// CHECK-NEXT: ('num_reloc', 0) +// CHECK-NEXT: ('flags', 0x80000000) +// CHECK-NEXT: ('reserved1', 0) +// CHECK-NEXT: ('reserved2', 0) +// CHECK-NEXT: ), +// CHECK-NEXT: ('_relocations', [ +// CHECK-NEXT: ]) +// CHECK-NEXT: ('_section_data', '') +// CHECK-NEXT: # Section 1 +// CHECK-NEXT: (('section_name', '__datacoal_nt\x00\x00\x00') +// CHECK-NEXT: ('segment_name', '__DATA\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-NEXT: ('address', 0) +// CHECK-NEXT: ('size', 4) +// CHECK-NEXT: ('offset', 392) +// CHECK-NEXT: ('alignment', 0) +// CHECK-NEXT: ('reloc_offset', 396) +// CHECK-NEXT: ('num_reloc', 1) +// CHECK-NEXT: ('flags', 0xb) +// CHECK-NEXT: ('reserved1', 0) +// CHECK-NEXT: ('reserved2', 0) +// CHECK-NEXT: ), +// CHECK-NEXT: ('_relocations', [ +// CHECK-NEXT: # Relocation 0 +// CHECK-NEXT: (('word-0', 0x0), +// CHECK-NEXT: ('word-1', 0xc000001)), +// CHECK-NEXT: ]) +// CHECK-NEXT: ('_section_data', '00000000') +// CHECK-NEXT: # Section 2 +// CHECK-NEXT: (('section_name', '__const_coal\x00\x00\x00\x00') +// CHECK-NEXT: ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-NEXT: ('address', 4) +// CHECK-NEXT: ('size', 0) +// CHECK-NEXT: ('offset', 396) +// CHECK-NEXT: ('alignment', 0) +// CHECK-NEXT: ('reloc_offset', 0) +// CHECK-NEXT: ('num_reloc', 0) +// CHECK-NEXT: ('flags', 0xb) +// CHECK-NEXT: ('reserved1', 0) +// CHECK-NEXT: ('reserved2', 0) +// CHECK-NEXT: ), +// CHECK-NEXT: ('_relocations', [ +// CHECK-NEXT: ]) +// CHECK-NEXT: ('_section_data', '') +// CHECK-NEXT: ]) +// CHECK-NEXT: ), +// CHECK-NEXT: # Load Command 1 +// CHECK-NEXT: (('command', 2) +// CHECK-NEXT: ('size', 24) +// CHECK-NEXT: ('symoff', 404) +// CHECK-NEXT: ('nsyms', 2) +// CHECK-NEXT: ('stroff', 428) +// CHECK-NEXT: ('strsize', 28) +// CHECK-NEXT: ('_string_data', '\x00__ZTS3optIbE\x00__ZTI3optIbE\x00\x00') +// CHECK-NEXT: ('_symbols', [ +// CHECK-NEXT: # Symbol 0 +// CHECK-NEXT: (('n_strx', 14) +// CHECK-NEXT: ('n_type', 0xf) +// CHECK-NEXT: ('n_sect', 2) +// CHECK-NEXT: ('n_desc', 128) +// CHECK-NEXT: ('n_value', 0) +// CHECK-NEXT: ('_string', '__ZTI3optIbE') +// CHECK-NEXT: ), +// CHECK-NEXT: # Symbol 1 +// CHECK-NEXT: (('n_strx', 1) +// CHECK-NEXT: ('n_type', 0xf) +// CHECK-NEXT: ('n_sect', 3) +// CHECK-NEXT: ('n_desc', 128) +// CHECK-NEXT: ('n_value', 4) +// CHECK-NEXT: ('_string', '__ZTS3optIbE') +// CHECK-NEXT: ), +// CHECK-NEXT: ]) +// CHECK-NEXT: ), +// CHECK-NEXT: # Load Command 2 +// CHECK-NEXT: (('command', 11) +// CHECK-NEXT: ('size', 80) +// CHECK-NEXT: ('ilocalsym', 0) +// CHECK-NEXT: ('nlocalsym', 0) +// CHECK-NEXT: ('iextdefsym', 0) +// CHECK-NEXT: ('nextdefsym', 2) +// CHECK-NEXT: ('iundefsym', 2) +// CHECK-NEXT: ('nundefsym', 0) +// CHECK-NEXT: ('tocoff', 0) +// CHECK-NEXT: ('ntoc', 0) +// CHECK-NEXT: ('modtaboff', 0) +// CHECK-NEXT: ('nmodtab', 0) +// CHECK-NEXT: ('extrefsymoff', 0) +// CHECK-NEXT: ('nextrefsyms', 0) +// CHECK-NEXT: ('indirectsymoff', 0) +// CHECK-NEXT: ('nindirectsyms', 0) +// CHECK-NEXT: ('extreloff', 0) +// CHECK-NEXT: ('nextrel', 0) +// CHECK-NEXT: ('locreloff', 0) +// CHECK-NEXT: ('nlocrel', 0) +// CHECK-NEXT: ('_indirect_symbols', [ +// CHECK-NEXT: ]) +// CHECK-NEXT: ), +// CHECK-NEXT: ]) From geek4civic at gmail.com Tue Dec 7 00:06:52 2010 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Tue, 7 Dec 2010 15:06:52 +0900 Subject: [llvm-commits] [Review request] Add the feature "sh" for LLVM::Other/close-stderr.ll, for MSVC In-Reply-To: References: Message-ID: Committed in r121104 and r121105, thank you. ...Takumi From geek4civic at gmail.com Tue Dec 7 00:09:14 2010 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Tue, 7 Dec 2010 15:09:14 +0900 Subject: [llvm-commits] Fix output stream opened in text instead of binary mode on MinGW In-Reply-To: <6AE1604EE3EC5F4296C096518C6B77EE1705A19D84@mail.accesssoftek.com> References: <6AE1604EE3EC5F4296C096518C6B77EE1705A19A78@mail.accesssoftek.com> <1D923093-7E74-457D-AF4E-CE879B273076@2pi.dk> <6AE1604EE3EC5F4296C096518C6B77EE1705A19B31@mail.accesssoftek.com> <6AE1604EE3EC5F4296C096518C6B77EE1705A19BB4@mail.accesssoftek.com> <6AE1604EE3EC5F4296C096518C6B77EE1705A19C19@mail.accesssoftek.com> <6AE1604EE3EC5F4296C096518C6B77EE1705A19C82@mail.accesssoftek.com> <6AE1604EE3EC5F4296C096518C6B77EE1705A19D84@mail.accesssoftek.com> Message-ID: Danil, I once applied it but it got failure. I have reverted it for now. http://google1.osuosl.org:8011/builders/llvm-i686-linux/builds/155 I don't know why. I will investigate later. ...Takumi From anton at korobeynikov.info Tue Dec 7 00:54:34 2010 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Tue, 7 Dec 2010 09:54:34 +0300 Subject: [llvm-commits] [llvm] r120960 - in /llvm/trunk: lib/Target/ARM/ test/CodeGen/ARM/ In-Reply-To: References: <20101205220416.D17E72A6C12C@llvm.org> <4CFD24D3.1090801@arm.com> Message-ID: > You mean in ARMScheduleA9.td? Yes. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From geek4civic at gmail.com Tue Dec 7 01:41:23 2010 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Tue, 07 Dec 2010 07:41:23 -0000 Subject: [llvm-commits] [llvm] r121117 - /llvm/trunk/unittests/CMakeLists.txt Message-ID: <20101207074123.A512E2A6C12C@llvm.org> Author: chapuni Date: Tue Dec 7 01:41:23 2010 New Revision: 121117 URL: http://llvm.org/viewvc/llvm-project?rev=121117&view=rev Log: unittests/CMakeLists.txt: Tweak unittests' layout to be identical to GNU build. Modified: llvm/trunk/unittests/CMakeLists.txt Modified: llvm/trunk/unittests/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/CMakeLists.txt?rev=121117&r1=121116&r2=121117&view=diff ============================================================================== --- llvm/trunk/unittests/CMakeLists.txt (original) +++ llvm/trunk/unittests/CMakeLists.txt Tue Dec 7 01:41:23 2010 @@ -1,10 +1,11 @@ -function(add_llvm_unittest test_name) +function(add_llvm_unittest test_dirname) + string(REGEX MATCH "([^/]+)$" test_name ${test_dirname}) if (CMAKE_BUILD_TYPE) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY - ${LLVM_BINARY_DIR}/unittests/${test_name}/${CMAKE_BUILD_TYPE}) + ${LLVM_BINARY_DIR}/unittests/${test_dirname}/${CMAKE_BUILD_TYPE}) else() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY - ${LLVM_BINARY_DIR}/unittests/${test_name}) + ${LLVM_BINARY_DIR}/unittests/${test_dirname}) endif() if( NOT LLVM_BUILD_TESTS ) set(EXCLUDE_FROM_ALL ON) @@ -79,13 +80,13 @@ list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def) endif() -add_llvm_unittest(JIT ${JITTestsSources}) +add_llvm_unittest(ExecutionEngine/JIT ${JITTestsSources}) if(MINGW) set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols) endif() -add_llvm_unittest(Transforms +add_llvm_unittest(Transforms/Utils Transforms/Utils/Cloning.cpp ) From geek4civic at gmail.com Tue Dec 7 01:41:32 2010 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Tue, 07 Dec 2010 07:41:32 -0000 Subject: [llvm-commits] [llvm] r121118 - /llvm/trunk/utils/lit/lit/TestFormats.py Message-ID: <20101207074132.347A42A6C12C@llvm.org> Author: chapuni Date: Tue Dec 7 01:41:32 2010 New Revision: 121118 URL: http://llvm.org/viewvc/llvm-project?rev=121118&view=rev Log: utils/lit/lit/TestFormats.py: [PR8438] unittests: Seek *Tests (not BUILD_MODE/*Tests) under whole unittests/ if BUILD_MODE == '.' Modified: llvm/trunk/utils/lit/lit/TestFormats.py Modified: llvm/trunk/utils/lit/lit/TestFormats.py URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/TestFormats.py?rev=121118&r1=121117&r2=121118&view=diff ============================================================================== --- llvm/trunk/utils/lit/lit/TestFormats.py (original) +++ llvm/trunk/utils/lit/lit/TestFormats.py Tue Dec 7 01:41:32 2010 @@ -59,8 +59,9 @@ source_path = testSuite.getSourcePath(path_in_suite) for filename in os.listdir(source_path): # Check for the one subdirectory (build directory) tests will be in. - if not os.path.normcase(filename) in self.test_sub_dir: - continue + if not '.' in self.test_sub_dir: + if not os.path.normcase(filename) in self.test_sub_dir: + continue filepath = os.path.join(source_path, filename) if not os.path.isdir(filepath): From resistor at mac.com Tue Dec 7 01:56:20 2010 From: resistor at mac.com (Owen Anderson) Date: Tue, 07 Dec 2010 07:56:20 -0000 Subject: [llvm-commits] [llvm] r121119 - /llvm/trunk/lib/Support/DynamicLibrary.cpp Message-ID: <20101207075620.2FEE72A6C12C@llvm.org> Author: resistor Date: Tue Dec 7 01:56:20 2010 New Revision: 121119 URL: http://llvm.org/viewvc/llvm-project?rev=121119&view=rev Log: Don't leak the mutex when loading dynamic libraries. Modified: llvm/trunk/lib/Support/DynamicLibrary.cpp Modified: llvm/trunk/lib/Support/DynamicLibrary.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/DynamicLibrary.cpp?rev=121119&r1=121118&r2=121119&view=diff ============================================================================== --- llvm/trunk/lib/Support/DynamicLibrary.cpp (original) +++ llvm/trunk/lib/Support/DynamicLibrary.cpp Tue Dec 7 01:56:20 2010 @@ -61,17 +61,12 @@ //=== independent code. //===----------------------------------------------------------------------===// -static SmartMutex* HandlesMutex; static std::vector *OpenedHandles = 0; -static bool InitializeMutex() { - HandlesMutex = new SmartMutex; - return HandlesMutex != 0; -} -static bool EnsureMutexInitialized() { - static bool result = InitializeMutex(); - return result; +static SmartMutex& getMutex() { + static SmartMutex HandlesMutex; + return HandlesMutex; } @@ -88,8 +83,7 @@ if (Filename == NULL) H = RTLD_DEFAULT; #endif - EnsureMutexInitialized(); - SmartScopedLock Lock(*HandlesMutex); + SmartScopedLock Lock(getMutex()); if (OpenedHandles == 0) OpenedHandles = new std::vector(); OpenedHandles->push_back(H); @@ -124,8 +118,7 @@ #if HAVE_DLFCN_H // Now search the libraries. - EnsureMutexInitialized(); - SmartScopedLock Lock(*HandlesMutex); + SmartScopedLock Lock(getMutex()); if (OpenedHandles) { for (std::vector::iterator I = OpenedHandles->begin(), E = OpenedHandles->end(); I != E; ++I) { From jay.foad at gmail.com Tue Dec 7 02:25:19 2010 From: jay.foad at gmail.com (Jay Foad) Date: Tue, 07 Dec 2010 08:25:19 -0000 Subject: [llvm-commits] [llvm] r121120 - in /llvm/trunk: include/llvm/ADT/ lib/Analysis/ lib/AsmParser/ lib/CodeGen/SelectionDAG/ lib/Support/ lib/Target/ARM/ lib/Transforms/InstCombine/ lib/Transforms/Scalar/ lib/VMCore/ unittests/Support/ Message-ID: <20101207082520.40D422A6C12C@llvm.org> Author: foad Date: Tue Dec 7 02:25:19 2010 New Revision: 121120 URL: http://llvm.org/viewvc/llvm-project?rev=121120&view=rev Log: PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() and zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method trunc(), to be const and to return a new value instead of modifying the object in place. Modified: llvm/trunk/include/llvm/ADT/APInt.h llvm/trunk/include/llvm/ADT/APSInt.h llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp llvm/trunk/lib/Analysis/ConstantFolding.cpp llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/lib/Analysis/ValueTracking.cpp llvm/trunk/lib/AsmParser/LLLexer.cpp llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp llvm/trunk/lib/Support/APFloat.cpp llvm/trunk/lib/Support/APInt.cpp llvm/trunk/lib/Support/ConstantRange.cpp llvm/trunk/lib/Support/StringRef.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp llvm/trunk/lib/VMCore/ConstantFold.cpp llvm/trunk/unittests/Support/ConstantRangeTest.cpp Modified: llvm/trunk/include/llvm/ADT/APInt.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APInt.h?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/APInt.h (original) +++ llvm/trunk/include/llvm/ADT/APInt.h Tue Dec 7 02:25:19 2010 @@ -342,9 +342,7 @@ if (isSingleWord()) return isUIntN(N, VAL); - APInt Tmp(N, getNumWords(), pVal); - Tmp.zext(getBitWidth()); - return Tmp == (*this); + return APInt(N, getNumWords(), pVal).zext(getBitWidth()) == (*this); } /// @brief Check if this APInt has an N-bits signed integer value. @@ -1013,30 +1011,30 @@ /// Truncate the APInt to a specified width. It is an error to specify a width /// that is greater than or equal to the current width. /// @brief Truncate to new width. - APInt &trunc(unsigned width); + APInt trunc(unsigned width) const; /// This operation sign extends the APInt to a new width. If the high order /// bit is set, the fill on the left will be done with 1 bits, otherwise zero. /// It is an error to specify a width that is less than or equal to the /// current width. /// @brief Sign extend to a new width. - APInt &sext(unsigned width); + APInt sext(unsigned width) const; /// This operation zero extends the APInt to a new width. The high order bits /// are filled with 0 bits. It is an error to specify a width that is less /// than or equal to the current width. /// @brief Zero extend to a new width. - APInt &zext(unsigned width); + APInt zext(unsigned width) const; /// Make this APInt have the bit width given by \p width. The value is sign /// extended, truncated, or left alone to make it that width. /// @brief Sign extend or truncate to width - APInt &sextOrTrunc(unsigned width); + APInt sextOrTrunc(unsigned width) const; /// Make this APInt have the bit width given by \p width. The value is zero /// extended, truncated, or left alone to make it that width. /// @brief Zero extend or truncate to width - APInt &zextOrTrunc(unsigned width); + APInt zextOrTrunc(unsigned width) const; /// @} /// @name Bit Manipulation Operators Modified: llvm/trunk/include/llvm/ADT/APSInt.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APSInt.h?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/APSInt.h (original) +++ llvm/trunk/include/llvm/ADT/APSInt.h Tue Dec 7 02:25:19 2010 @@ -68,20 +68,22 @@ } using APInt::toString; - APSInt& extend(uint32_t width) { + APSInt trunc(uint32_t width) const { + return APSInt(APInt::trunc(width), IsUnsigned); + } + + APSInt extend(uint32_t width) const { if (IsUnsigned) - zext(width); + return APSInt(zext(width), IsUnsigned); else - sext(width); - return *this; + return APSInt(sext(width), IsUnsigned); } - APSInt& extOrTrunc(uint32_t width) { + APSInt extOrTrunc(uint32_t width) const { if (IsUnsigned) - zextOrTrunc(width); + return APSInt(zextOrTrunc(width), IsUnsigned); else - sextOrTrunc(width); - return *this; + return APSInt(sextOrTrunc(width), IsUnsigned); } const APSInt &operator%=(const APSInt &RHS) { Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Tue Dec 7 02:25:19 2010 @@ -206,14 +206,14 @@ Value *CastOp = cast(V)->getOperand(0); unsigned OldWidth = Scale.getBitWidth(); unsigned SmallWidth = CastOp->getType()->getPrimitiveSizeInBits(); - Scale.trunc(SmallWidth); - Offset.trunc(SmallWidth); + Scale = Scale.trunc(SmallWidth); + Offset = Offset.trunc(SmallWidth); Extension = isa(V) ? EK_SignExt : EK_ZeroExt; Value *Result = GetLinearExpression(CastOp, Scale, Offset, Extension, TD, Depth+1); - Scale.zext(OldWidth); - Offset.zext(OldWidth); + Scale = Scale.zext(OldWidth); + Offset = Offset.zext(OldWidth); return Result; } Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original) +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Tue Dec 7 02:25:19 2010 @@ -610,10 +610,8 @@ APInt BasePtr(BitWidth, 0); if (ConstantExpr *CE = dyn_cast(Ptr)) if (CE->getOpcode() == Instruction::IntToPtr) - if (ConstantInt *Base = dyn_cast(CE->getOperand(0))) { - BasePtr = Base->getValue(); - BasePtr.zextOrTrunc(BitWidth); - } + if (ConstantInt *Base = dyn_cast(CE->getOperand(0))) + BasePtr = Base->getValue().zextOrTrunc(BitWidth); if (Ptr->isNullValue() || BasePtr != 0) { Constant *C = ConstantInt::get(Ptr->getContext(), Offset+BasePtr); return ConstantExpr::getIntToPtr(C, ResultTy); Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue Dec 7 02:25:19 2010 @@ -3367,8 +3367,8 @@ // If C is a single bit, it may be in the sign-bit position // before the zero-extend. In this case, represent the xor // using an add, which is equivalent, and re-apply the zext. - APInt Trunc = APInt(CI->getValue()).trunc(Z0TySize); - if (APInt(Trunc).zext(getTypeSizeInBits(UTy)) == CI->getValue() && + APInt Trunc = CI->getValue().trunc(Z0TySize); + if (Trunc.zext(getTypeSizeInBits(UTy)) == CI->getValue() && Trunc.isSignBit()) return getZeroExtendExpr(getAddExpr(Z0, getConstant(Trunc)), UTy); Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ValueTracking.cpp (original) +++ llvm/trunk/lib/Analysis/ValueTracking.cpp Tue Dec 7 02:25:19 2010 @@ -255,14 +255,13 @@ else SrcBitWidth = SrcTy->getScalarSizeInBits(); - APInt MaskIn(Mask); - MaskIn.zextOrTrunc(SrcBitWidth); - KnownZero.zextOrTrunc(SrcBitWidth); - KnownOne.zextOrTrunc(SrcBitWidth); + APInt MaskIn = Mask.zextOrTrunc(SrcBitWidth); + KnownZero = KnownZero.zextOrTrunc(SrcBitWidth); + KnownOne = KnownOne.zextOrTrunc(SrcBitWidth); ComputeMaskedBits(I->getOperand(0), MaskIn, KnownZero, KnownOne, TD, Depth+1); - KnownZero.zextOrTrunc(BitWidth); - KnownOne.zextOrTrunc(BitWidth); + KnownZero = KnownZero.zextOrTrunc(BitWidth); + KnownOne = KnownOne.zextOrTrunc(BitWidth); // Any top bits are known to be zero. if (BitWidth > SrcBitWidth) KnownZero |= APInt::getHighBitsSet(BitWidth, BitWidth - SrcBitWidth); @@ -284,15 +283,14 @@ // Compute the bits in the result that are not present in the input. unsigned SrcBitWidth = I->getOperand(0)->getType()->getScalarSizeInBits(); - APInt MaskIn(Mask); - MaskIn.trunc(SrcBitWidth); - KnownZero.trunc(SrcBitWidth); - KnownOne.trunc(SrcBitWidth); + APInt MaskIn = Mask.trunc(SrcBitWidth); + KnownZero = KnownZero.trunc(SrcBitWidth); + KnownOne = KnownOne.trunc(SrcBitWidth); ComputeMaskedBits(I->getOperand(0), MaskIn, KnownZero, KnownOne, TD, Depth+1); assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); - KnownZero.zext(BitWidth); - KnownOne.zext(BitWidth); + KnownZero = KnownZero.zext(BitWidth); + KnownOne = KnownOne.zext(BitWidth); // If the sign bit of the input is known set or clear, then we know the // top bits of the result. Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLLexer.cpp (original) +++ llvm/trunk/lib/AsmParser/LLLexer.cpp Tue Dec 7 02:25:19 2010 @@ -682,7 +682,7 @@ APInt Tmp(bits, StringRef(TokStart+3, len), 16); uint32_t activeBits = Tmp.getActiveBits(); if (activeBits > 0 && activeBits < bits) - Tmp.trunc(activeBits); + Tmp = Tmp.trunc(activeBits); APSIntVal = APSInt(Tmp, TokStart[0] == 'u'); return lltok::APSInt; } @@ -809,12 +809,12 @@ if (TokStart[0] == '-') { uint32_t minBits = Tmp.getMinSignedBits(); if (minBits > 0 && minBits < numBits) - Tmp.trunc(minBits); + Tmp = Tmp.trunc(minBits); APSIntVal = APSInt(Tmp, false); } else { uint32_t activeBits = Tmp.getActiveBits(); if (activeBits > 0 && activeBits < numBits) - Tmp.trunc(activeBits); + Tmp = Tmp.trunc(activeBits); APSIntVal = APSInt(Tmp, true); } return lltok::APSInt; Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Dec 7 02:25:19 2010 @@ -2575,7 +2575,7 @@ case ValID::t_APSInt: if (!Ty->isIntegerTy()) return Error(ID.Loc, "integer constant must have integer type"); - ID.APSIntVal.extOrTrunc(Ty->getPrimitiveSizeInBits()); + ID.APSIntVal = ID.APSIntVal.extOrTrunc(Ty->getPrimitiveSizeInBits()); V = ConstantInt::get(Context, ID.APSIntVal); return false; case ValID::t_APFloat: Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Tue Dec 7 02:25:19 2010 @@ -2133,7 +2133,7 @@ if (N1C && N0.getOpcode() == ISD::ANY_EXTEND) { SDValue N0Op0 = N0.getOperand(0); APInt Mask = ~N1C->getAPIntValue(); - Mask.trunc(N0Op0.getValueSizeInBits()); + Mask = Mask.trunc(N0Op0.getValueSizeInBits()); if (DAG.MaskedValueIsZero(N0Op0, Mask)) { SDValue Zext = DAG.getNode(ISD::ZERO_EXTEND, N->getDebugLoc(), N0.getValueType(), N0Op0); @@ -2866,7 +2866,7 @@ EVT TruncVT = N1.getValueType(); SDValue N100 = N1.getOperand(0).getOperand(0); APInt TruncC = N101C->getAPIntValue(); - TruncC.trunc(TruncVT.getSizeInBits()); + TruncC = TruncC.trunc(TruncVT.getSizeInBits()); return DAG.getNode(ISD::SHL, N->getDebugLoc(), VT, N0, DAG.getNode(ISD::AND, N->getDebugLoc(), TruncVT, DAG.getNode(ISD::TRUNCATE, @@ -3022,7 +3022,7 @@ EVT TruncVT = N1.getValueType(); SDValue N100 = N1.getOperand(0).getOperand(0); APInt TruncC = N101C->getAPIntValue(); - TruncC.trunc(TruncVT.getScalarType().getSizeInBits()); + TruncC = TruncC.trunc(TruncVT.getScalarType().getSizeInBits()); return DAG.getNode(ISD::SRA, N->getDebugLoc(), VT, N0, DAG.getNode(ISD::AND, N->getDebugLoc(), TruncVT, @@ -3163,7 +3163,7 @@ EVT TruncVT = N1.getValueType(); SDValue N100 = N1.getOperand(0).getOperand(0); APInt TruncC = N101C->getAPIntValue(); - TruncC.trunc(TruncVT.getSizeInBits()); + TruncC = TruncC.trunc(TruncVT.getSizeInBits()); return DAG.getNode(ISD::SRL, N->getDebugLoc(), VT, N0, DAG.getNode(ISD::AND, N->getDebugLoc(), TruncVT, @@ -3706,7 +3706,7 @@ X = DAG.getNode(ISD::TRUNCATE, X.getDebugLoc(), VT, X); } APInt Mask = cast(N0.getOperand(1))->getAPIntValue(); - Mask.zext(VT.getSizeInBits()); + Mask = Mask.zext(VT.getSizeInBits()); return DAG.getNode(ISD::AND, N->getDebugLoc(), VT, X, DAG.getConstant(Mask, VT)); } @@ -3907,7 +3907,7 @@ X = DAG.getNode(ISD::TRUNCATE, N->getDebugLoc(), VT, X); } APInt Mask = cast(N0.getOperand(1))->getAPIntValue(); - Mask.zext(VT.getSizeInBits()); + Mask = Mask.zext(VT.getSizeInBits()); return DAG.getNode(ISD::AND, N->getDebugLoc(), VT, X, DAG.getConstant(Mask, VT)); } @@ -4614,7 +4614,7 @@ if (Op.getOpcode() == ISD::UNDEF) continue; EltIsUndef = false; - NewBits |= APInt(cast(Op)->getAPIntValue()). + NewBits |= cast(Op)->getAPIntValue(). zextOrTrunc(SrcBitSize).zext(DstBitSize); } @@ -4644,13 +4644,13 @@ continue; } - APInt OpVal = APInt(cast(BV->getOperand(i))-> - getAPIntValue()).zextOrTrunc(SrcBitSize); + APInt OpVal = cast(BV->getOperand(i))-> + getAPIntValue().zextOrTrunc(SrcBitSize); for (unsigned j = 0; j != NumOutputsPerInput; ++j) { - APInt ThisVal = APInt(OpVal).trunc(DstBitSize); + APInt ThisVal = OpVal.trunc(DstBitSize); Ops.push_back(DAG.getConstant(ThisVal, DstEltVT)); - if (isS2V && i == 0 && j == 0 && APInt(ThisVal).zext(SrcBitSize) == OpVal) + if (isS2V && i == 0 && j == 0 && ThisVal.zext(SrcBitSize) == OpVal) // Simply turn this into a SCALAR_TO_VECTOR of the new type. return DAG.getNode(ISD::SCALAR_TO_VECTOR, BV->getDebugLoc(), VT, Ops[0]); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Tue Dec 7 02:25:19 2010 @@ -749,7 +749,7 @@ // stores. If the target supports neither 32- nor 64-bits, this // xform is certainly not worth it. const APInt &IntVal =CFP->getValueAPF().bitcastToAPInt(); - SDValue Lo = DAG.getConstant(APInt(IntVal).trunc(32), MVT::i32); + SDValue Lo = DAG.getConstant(IntVal.trunc(32), MVT::i32); SDValue Hi = DAG.getConstant(IntVal.lshr(32).trunc(32), MVT::i32); if (TLI.isBigEndian()) std::swap(Lo, Hi); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Tue Dec 7 02:25:19 2010 @@ -1435,7 +1435,7 @@ EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0)); unsigned NBitWidth = NVT.getSizeInBits(); const APInt &Cst = cast(N)->getAPIntValue(); - Lo = DAG.getConstant(APInt(Cst).trunc(NBitWidth), NVT); + Lo = DAG.getConstant(Cst.trunc(NBitWidth), NVT); Hi = DAG.getConstant(Cst.lshr(NBitWidth).trunc(NBitWidth), NVT); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Dec 7 02:25:19 2010 @@ -1806,7 +1806,7 @@ // If the sign extended bits are demanded, we know that the sign // bit is demanded. - InSignBit.zext(BitWidth); + InSignBit = InSignBit.zext(BitWidth); if (NewBits.getBoolValue()) InputDemandedBits |= InSignBit; @@ -1849,13 +1849,12 @@ EVT InVT = Op.getOperand(0).getValueType(); unsigned InBits = InVT.getScalarType().getSizeInBits(); APInt NewBits = APInt::getHighBitsSet(BitWidth, BitWidth - InBits) & Mask; - APInt InMask = Mask; - InMask.trunc(InBits); - KnownZero.trunc(InBits); - KnownOne.trunc(InBits); + APInt InMask = Mask.trunc(InBits); + KnownZero = KnownZero.trunc(InBits); + KnownOne = KnownOne.trunc(InBits); ComputeMaskedBits(Op.getOperand(0), InMask, KnownZero, KnownOne, Depth+1); - KnownZero.zext(BitWidth); - KnownOne.zext(BitWidth); + KnownZero = KnownZero.zext(BitWidth); + KnownOne = KnownOne.zext(BitWidth); KnownZero |= NewBits; return; } @@ -1864,16 +1863,15 @@ unsigned InBits = InVT.getScalarType().getSizeInBits(); APInt InSignBit = APInt::getSignBit(InBits); APInt NewBits = APInt::getHighBitsSet(BitWidth, BitWidth - InBits) & Mask; - APInt InMask = Mask; - InMask.trunc(InBits); + APInt InMask = Mask.trunc(InBits); // If any of the sign extended bits are demanded, we know that the sign // bit is demanded. Temporarily set this bit in the mask for our callee. if (NewBits.getBoolValue()) InMask |= InSignBit; - KnownZero.trunc(InBits); - KnownOne.trunc(InBits); + KnownZero = KnownZero.trunc(InBits); + KnownOne = KnownOne.trunc(InBits); ComputeMaskedBits(Op.getOperand(0), InMask, KnownZero, KnownOne, Depth+1); // Note if the sign bit is known to be zero or one. @@ -1885,13 +1883,12 @@ // If the sign bit wasn't actually demanded by our caller, we don't // want it set in the KnownZero and KnownOne result values. Reset the // mask and reapply it to the result values. - InMask = Mask; - InMask.trunc(InBits); + InMask = Mask.trunc(InBits); KnownZero &= InMask; KnownOne &= InMask; - KnownZero.zext(BitWidth); - KnownOne.zext(BitWidth); + KnownZero = KnownZero.zext(BitWidth); + KnownOne = KnownOne.zext(BitWidth); // If the sign bit is known zero or one, the top bits match. if (SignBitKnownZero) @@ -1903,26 +1900,24 @@ case ISD::ANY_EXTEND: { EVT InVT = Op.getOperand(0).getValueType(); unsigned InBits = InVT.getScalarType().getSizeInBits(); - APInt InMask = Mask; - InMask.trunc(InBits); - KnownZero.trunc(InBits); - KnownOne.trunc(InBits); + APInt InMask = Mask.trunc(InBits); + KnownZero = KnownZero.trunc(InBits); + KnownOne = KnownOne.trunc(InBits); ComputeMaskedBits(Op.getOperand(0), InMask, KnownZero, KnownOne, Depth+1); - KnownZero.zext(BitWidth); - KnownOne.zext(BitWidth); + KnownZero = KnownZero.zext(BitWidth); + KnownOne = KnownOne.zext(BitWidth); return; } case ISD::TRUNCATE: { EVT InVT = Op.getOperand(0).getValueType(); unsigned InBits = InVT.getScalarType().getSizeInBits(); - APInt InMask = Mask; - InMask.zext(InBits); - KnownZero.zext(InBits); - KnownOne.zext(InBits); + APInt InMask = Mask.zext(InBits); + KnownZero = KnownZero.zext(InBits); + KnownOne = KnownOne.zext(InBits); ComputeMaskedBits(Op.getOperand(0), InMask, KnownZero, KnownOne, Depth+1); assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); - KnownZero.trunc(BitWidth); - KnownOne.trunc(BitWidth); + KnownZero = KnownZero.trunc(BitWidth); + KnownOne = KnownOne.trunc(BitWidth); break; } case ISD::AssertZext: { @@ -2349,11 +2344,11 @@ switch (Opcode) { default: break; case ISD::SIGN_EXTEND: - return getConstant(APInt(Val).sextOrTrunc(VT.getSizeInBits()), VT); + return getConstant(Val.sextOrTrunc(VT.getSizeInBits()), VT); case ISD::ANY_EXTEND: case ISD::ZERO_EXTEND: case ISD::TRUNCATE: - return getConstant(APInt(Val).zextOrTrunc(VT.getSizeInBits()), VT); + return getConstant(Val.zextOrTrunc(VT.getSizeInBits()), VT); case ISD::UINT_TO_FP: case ISD::SINT_TO_FP: { // No compile time operations on ppcf128. @@ -6418,7 +6413,7 @@ if (OpVal.getOpcode() == ISD::UNDEF) SplatUndef |= APInt::getBitsSet(sz, BitPos, BitPos + EltBitSize); else if (ConstantSDNode *CN = dyn_cast(OpVal)) - SplatValue |= APInt(CN->getAPIntValue()).zextOrTrunc(EltBitSize). + SplatValue |= CN->getAPIntValue().zextOrTrunc(EltBitSize). zextOrTrunc(sz) << BitPos; else if (ConstantFPSDNode *CN = dyn_cast(OpVal)) SplatValue |= CN->getValueAPF().bitcastToAPInt().zextOrTrunc(sz) < 8) { unsigned HalfSize = sz / 2; - APInt HighValue = APInt(SplatValue).lshr(HalfSize).trunc(HalfSize); - APInt LowValue = APInt(SplatValue).trunc(HalfSize); - APInt HighUndef = APInt(SplatUndef).lshr(HalfSize).trunc(HalfSize); - APInt LowUndef = APInt(SplatUndef).trunc(HalfSize); + APInt HighValue = SplatValue.lshr(HalfSize).trunc(HalfSize); + APInt LowValue = SplatValue.trunc(HalfSize); + APInt HighUndef = SplatUndef.lshr(HalfSize).trunc(HalfSize); + APInt LowUndef = SplatUndef.trunc(HalfSize); // If the two halves do not match (ignoring undef bits), stop here. if ((HighValue & ~LowUndef) != (LowValue & ~HighUndef) || Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Tue Dec 7 02:25:19 2010 @@ -1866,9 +1866,8 @@ } static APInt ComputeRange(const APInt &First, const APInt &Last) { - APInt LastExt(Last), FirstExt(First); uint32_t BitWidth = std::max(Last.getBitWidth(), First.getBitWidth()) + 1; - LastExt.sext(BitWidth); FirstExt.sext(BitWidth); + APInt LastExt = Last.sext(BitWidth), FirstExt = First.sext(BitWidth); return (LastExt - FirstExt + 1ULL); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Tue Dec 7 02:25:19 2010 @@ -1520,8 +1520,8 @@ if ((NewBits & NewMask) == 0) return TLO.CombineTo(Op, Op.getOperand(0)); - APInt InSignBit = APInt::getSignBit(EVT.getScalarType().getSizeInBits()); - InSignBit.zext(BitWidth); + APInt InSignBit = + APInt::getSignBit(EVT.getScalarType().getSizeInBits()).zext(BitWidth); APInt InputDemandedBits = APInt::getLowBitsSet(BitWidth, EVT.getScalarType().getSizeInBits()) & @@ -1556,8 +1556,7 @@ case ISD::ZERO_EXTEND: { unsigned OperandBitWidth = Op.getOperand(0).getValueType().getScalarType().getSizeInBits(); - APInt InMask = NewMask; - InMask.trunc(OperandBitWidth); + APInt InMask = NewMask.trunc(OperandBitWidth); // If none of the top bits are demanded, convert this into an any_extend. APInt NewBits = @@ -1571,8 +1570,8 @@ KnownZero, KnownOne, TLO, Depth+1)) return true; assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); - KnownZero.zext(BitWidth); - KnownOne.zext(BitWidth); + KnownZero = KnownZero.zext(BitWidth); + KnownOne = KnownOne.zext(BitWidth); KnownZero |= NewBits; break; } @@ -1593,13 +1592,13 @@ // bit is demanded. APInt InDemandedBits = InMask & NewMask; InDemandedBits |= InSignBit; - InDemandedBits.trunc(InBits); + InDemandedBits = InDemandedBits.trunc(InBits); if (SimplifyDemandedBits(Op.getOperand(0), InDemandedBits, KnownZero, KnownOne, TLO, Depth+1)) return true; - KnownZero.zext(BitWidth); - KnownOne.zext(BitWidth); + KnownZero = KnownZero.zext(BitWidth); + KnownOne = KnownOne.zext(BitWidth); // If the sign bit is known zero, convert this to a zero extend. if (KnownZero.intersects(InSignBit)) @@ -1620,14 +1619,13 @@ case ISD::ANY_EXTEND: { unsigned OperandBitWidth = Op.getOperand(0).getValueType().getScalarType().getSizeInBits(); - APInt InMask = NewMask; - InMask.trunc(OperandBitWidth); + APInt InMask = NewMask.trunc(OperandBitWidth); if (SimplifyDemandedBits(Op.getOperand(0), InMask, KnownZero, KnownOne, TLO, Depth+1)) return true; assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); - KnownZero.zext(BitWidth); - KnownOne.zext(BitWidth); + KnownZero = KnownZero.zext(BitWidth); + KnownOne = KnownOne.zext(BitWidth); break; } case ISD::TRUNCATE: { @@ -1635,13 +1633,12 @@ // zero/one bits live out. unsigned OperandBitWidth = Op.getOperand(0).getValueType().getScalarType().getSizeInBits(); - APInt TruncMask = NewMask; - TruncMask.zext(OperandBitWidth); + APInt TruncMask = NewMask.zext(OperandBitWidth); if (SimplifyDemandedBits(Op.getOperand(0), TruncMask, KnownZero, KnownOne, TLO, Depth+1)) return true; - KnownZero.trunc(BitWidth); - KnownOne.trunc(BitWidth); + KnownZero = KnownZero.trunc(BitWidth); + KnownOne = KnownOne.trunc(BitWidth); // If the input is only used by this truncate, see if we can shrink it based // on the known demanded bits. @@ -1662,8 +1659,7 @@ break; APInt HighBits = APInt::getHighBitsSet(OperandBitWidth, OperandBitWidth - BitWidth); - HighBits = HighBits.lshr(ShAmt->getZExtValue()); - HighBits.trunc(BitWidth); + HighBits = HighBits.lshr(ShAmt->getZExtValue()).trunc(BitWidth); if (ShAmt->getZExtValue() < BitWidth && !(HighBits & NewMask)) { // None of the shifted in bits are needed. Add a truncate of the @@ -1969,7 +1965,7 @@ (isOperationLegal(ISD::SETCC, newVT) && getCondCodeAction(Cond, newVT)==Legal)) return DAG.getSetCC(dl, VT, N0.getOperand(0), - DAG.getConstant(APInt(C1).trunc(InSize), newVT), + DAG.getConstant(C1.trunc(InSize), newVT), Cond); break; } Modified: llvm/trunk/lib/Support/APFloat.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/Support/APFloat.cpp (original) +++ llvm/trunk/lib/Support/APFloat.cpp Tue Dec 7 02:25:19 2010 @@ -3310,7 +3310,7 @@ // Truncate the significand down to its active bit count, but // don't try to drop below 32. unsigned newPrecision = std::max(32U, significand.getActiveBits()); - significand.trunc(newPrecision); + significand = significand.trunc(newPrecision); } @@ -3415,7 +3415,7 @@ // Nothing to do. } else if (exp > 0) { // Just shift left. - significand.zext(semantics->precision + exp); + significand = significand.zext(semantics->precision + exp); significand <<= exp; exp = 0; } else { /* exp < 0 */ @@ -3434,7 +3434,7 @@ // Multiply significand by 5^e. // N * 5^0101 == N * 5^(1*1) * 5^(0*2) * 5^(1*4) * 5^(0*8) - significand.zext(precision); + significand = significand.zext(precision); APInt five_to_the_i(precision, 5); while (true) { if (texp & 1) significand *= five_to_the_i; Modified: llvm/trunk/lib/Support/APInt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/Support/APInt.cpp (original) +++ llvm/trunk/lib/Support/APInt.cpp Tue Dec 7 02:25:19 2010 @@ -995,96 +995,90 @@ } // Truncate to new width. -APInt &APInt::trunc(unsigned width) { +APInt APInt::trunc(unsigned width) const { assert(width < BitWidth && "Invalid APInt Truncate request"); assert(width && "Can't truncate to 0 bits"); - unsigned wordsBefore = getNumWords(); - BitWidth = width; - unsigned wordsAfter = getNumWords(); - if (wordsBefore != wordsAfter) { - if (wordsAfter == 1) { - uint64_t *tmp = pVal; - VAL = pVal[0]; - delete [] tmp; - } else { - uint64_t *newVal = getClearedMemory(wordsAfter); - for (unsigned i = 0; i < wordsAfter; ++i) - newVal[i] = pVal[i]; - delete [] pVal; - pVal = newVal; - } - } - return clearUnusedBits(); + + if (width <= APINT_BITS_PER_WORD) + return APInt(width, getRawData()[0]); + + APInt Result(getMemory(getNumWords(width)), width); + + // Copy full words. + unsigned i; + for (i = 0; i != width / APINT_BITS_PER_WORD; i++) + Result.pVal[i] = pVal[i]; + + // Truncate and copy any partial word. + unsigned bits = (0 - width) % APINT_BITS_PER_WORD; + if (bits != 0) + Result.pVal[i] = pVal[i] << bits >> bits; + + return Result; } // Sign extend to a new width. -APInt &APInt::sext(unsigned width) { +APInt APInt::sext(unsigned width) const { assert(width > BitWidth && "Invalid APInt SignExtend request"); - // If the sign bit isn't set, this is the same as zext. - if (!isNegative()) { - zext(width); - return *this; + + if (width <= APINT_BITS_PER_WORD) { + uint64_t val = VAL << (APINT_BITS_PER_WORD - BitWidth); + val = (int64_t)val >> (width - BitWidth); + return APInt(width, val >> (APINT_BITS_PER_WORD - width)); } - // The sign bit is set. First, get some facts - unsigned wordsBefore = getNumWords(); - unsigned wordBits = BitWidth % APINT_BITS_PER_WORD; - BitWidth = width; - unsigned wordsAfter = getNumWords(); - - // Mask the high order word appropriately - if (wordsBefore == wordsAfter) { - unsigned newWordBits = width % APINT_BITS_PER_WORD; - // The extension is contained to the wordsBefore-1th word. - uint64_t mask = ~0ULL; - if (newWordBits) - mask >>= APINT_BITS_PER_WORD - newWordBits; - mask <<= wordBits; - if (wordsBefore == 1) - VAL |= mask; - else - pVal[wordsBefore-1] |= mask; - return clearUnusedBits(); + APInt Result(getMemory(getNumWords(width)), width); + + // Copy full words. + unsigned i; + uint64_t word = 0; + for (i = 0; i != BitWidth / APINT_BITS_PER_WORD; i++) { + word = getRawData()[i]; + Result.pVal[i] = word; } - uint64_t mask = wordBits == 0 ? 0 : ~0ULL << wordBits; - uint64_t *newVal = getMemory(wordsAfter); - if (wordsBefore == 1) - newVal[0] = VAL | mask; - else { - for (unsigned i = 0; i < wordsBefore; ++i) - newVal[i] = pVal[i]; - newVal[wordsBefore-1] |= mask; - } - for (unsigned i = wordsBefore; i < wordsAfter; i++) - newVal[i] = -1ULL; - if (wordsBefore != 1) - delete [] pVal; - pVal = newVal; - return clearUnusedBits(); + // Read and sign-extend any partial word. + unsigned bits = (0 - BitWidth) % APINT_BITS_PER_WORD; + if (bits != 0) + word = (int64_t)getRawData()[i] << bits >> bits; + else + word = (int64_t)word >> (APINT_BITS_PER_WORD - 1); + + // Write remaining full words. + for (; i != width / APINT_BITS_PER_WORD; i++) { + Result.pVal[i] = word; + word = (int64_t)word >> (APINT_BITS_PER_WORD - 1); + } + + // Write any partial word. + bits = (0 - width) % APINT_BITS_PER_WORD; + if (bits != 0) + Result.pVal[i] = word << bits >> bits; + + return Result; } // Zero extend to a new width. -APInt &APInt::zext(unsigned width) { +APInt APInt::zext(unsigned width) const { assert(width > BitWidth && "Invalid APInt ZeroExtend request"); - unsigned wordsBefore = getNumWords(); - BitWidth = width; - unsigned wordsAfter = getNumWords(); - if (wordsBefore != wordsAfter) { - uint64_t *newVal = getClearedMemory(wordsAfter); - if (wordsBefore == 1) - newVal[0] = VAL; - else - for (unsigned i = 0; i < wordsBefore; ++i) - newVal[i] = pVal[i]; - if (wordsBefore != 1) - delete [] pVal; - pVal = newVal; - } - return *this; + + if (width <= APINT_BITS_PER_WORD) + return APInt(width, VAL); + + APInt Result(getMemory(getNumWords(width)), width); + + // Copy words. + unsigned i; + for (i = 0; i != getNumWords(); i++) + Result.pVal[i] = getRawData()[i]; + + // Zero remaining words. + memset(&Result.pVal[i], 0, (Result.getNumWords() - i) * APINT_WORD_SIZE); + + return Result; } -APInt &APInt::zextOrTrunc(unsigned width) { +APInt APInt::zextOrTrunc(unsigned width) const { if (BitWidth < width) return zext(width); if (BitWidth > width) @@ -1092,7 +1086,7 @@ return *this; } -APInt &APInt::sextOrTrunc(unsigned width) { +APInt APInt::sextOrTrunc(unsigned width) const { if (BitWidth < width) return sext(width); if (BitWidth > width) Modified: llvm/trunk/lib/Support/ConstantRange.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ConstantRange.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/Support/ConstantRange.cpp (original) +++ llvm/trunk/lib/Support/ConstantRange.cpp Tue Dec 7 02:25:19 2010 @@ -442,9 +442,7 @@ // Change into [0, 1 << src bit width) return ConstantRange(APInt(DstTySize,0), APInt(DstTySize,1).shl(SrcTySize)); - APInt L = Lower; L.zext(DstTySize); - APInt U = Upper; U.zext(DstTySize); - return ConstantRange(L, U); + return ConstantRange(Lower.zext(DstTySize), Upper.zext(DstTySize)); } /// signExtend - Return a new range in the specified integer type, which must @@ -461,9 +459,7 @@ APInt::getLowBitsSet(DstTySize, SrcTySize-1) + 1); } - APInt L = Lower; L.sext(DstTySize); - APInt U = Upper; U.sext(DstTySize); - return ConstantRange(L, U); + return ConstantRange(Lower.sext(DstTySize), Upper.sext(DstTySize)); } /// truncate - Return a new range in the specified integer type, which must be @@ -477,9 +473,7 @@ if (isFullSet() || getSetSize().ugt(Size)) return ConstantRange(DstTySize, /*isFullSet=*/true); - APInt L = Lower; L.trunc(DstTySize); - APInt U = Upper; U.trunc(DstTySize); - return ConstantRange(L, U); + return ConstantRange(Lower.trunc(DstTySize), Upper.trunc(DstTySize)); } /// zextOrTrunc - make this range have the bit width given by \p DstTySize. The Modified: llvm/trunk/lib/Support/StringRef.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringRef.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/Support/StringRef.cpp (original) +++ llvm/trunk/lib/Support/StringRef.cpp Tue Dec 7 02:25:19 2010 @@ -371,7 +371,7 @@ if (BitWidth < Result.getBitWidth()) BitWidth = Result.getBitWidth(); // don't shrink the result else - Result.zext(BitWidth); + Result = Result.zext(BitWidth); APInt RadixAP, CharAP; // unused unless !IsPowerOf2Radix if (!IsPowerOf2Radix) { Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Dec 7 02:25:19 2010 @@ -4006,7 +4006,7 @@ for (unsigned i = 0; i != NumElts; ++i) { ConstantSDNode *C = cast(N->getOperand(i)); const APInt &CInt = C->getAPIntValue(); - Ops.push_back(DAG.getConstant(APInt(CInt).trunc(EltSize), TruncVT)); + Ops.push_back(DAG.getConstant(CInt.trunc(EltSize), TruncVT)); } return DAG.getNode(ISD::BUILD_VECTOR, N->getDebugLoc(), MVT::getVectorVT(TruncVT, NumElts), Ops.data(), NumElts); Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Tue Dec 7 02:25:19 2010 @@ -939,8 +939,7 @@ // If all the high bits are known, we can do this xform. if ((KnownZero|KnownOne).countLeadingOnes() >= SrcBits-DstBits) { // Pull in the high bits from known-ones set. - APInt NewRHS(RHS->getValue()); - NewRHS.zext(SrcBits); + APInt NewRHS = RHS->getValue().zext(SrcBits); NewRHS |= KnownOne; return new ICmpInst(ICI.getPredicate(), LHSI->getOperand(0), ConstantInt::get(ICI.getContext(), NewRHS)); @@ -1022,10 +1021,8 @@ (AndCST->getValue().isNonNegative() && RHSV.isNonNegative()))) { uint32_t BitWidth = cast(Cast->getOperand(0)->getType())->getBitWidth(); - APInt NewCST = AndCST->getValue(); - NewCST.zext(BitWidth); - APInt NewCI = RHSV; - NewCI.zext(BitWidth); + APInt NewCST = AndCST->getValue().zext(BitWidth); + APInt NewCI = RHSV.zext(BitWidth); Value *NewAnd = Builder->CreateAnd(Cast->getOperand(0), ConstantInt::get(ICI.getContext(), NewCST), Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Tue Dec 7 02:25:19 2010 @@ -29,11 +29,11 @@ uint32_t W = C1->getBitWidth(); APInt LHSExt = C1->getValue(), RHSExt = C2->getValue(); if (sign) { - LHSExt.sext(W * 2); - RHSExt.sext(W * 2); + LHSExt = LHSExt.sext(W * 2); + RHSExt = RHSExt.sext(W * 2); } else { - LHSExt.zext(W * 2); - RHSExt.zext(W * 2); + LHSExt = LHSExt.zext(W * 2); + RHSExt = RHSExt.zext(W * 2); } APInt MulExt = LHSExt * RHSExt; Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp Tue Dec 7 02:25:19 2010 @@ -34,7 +34,7 @@ if (!OpC) return false; // If there are no bits set that aren't demanded, nothing to do. - Demanded.zextOrTrunc(OpC->getValue().getBitWidth()); + Demanded = Demanded.zextOrTrunc(OpC->getValue().getBitWidth()); if ((~Demanded & OpC->getValue()) == 0) return false; @@ -388,15 +388,15 @@ break; case Instruction::Trunc: { unsigned truncBf = I->getOperand(0)->getType()->getScalarSizeInBits(); - DemandedMask.zext(truncBf); - KnownZero.zext(truncBf); - KnownOne.zext(truncBf); + DemandedMask = DemandedMask.zext(truncBf); + KnownZero = KnownZero.zext(truncBf); + KnownOne = KnownOne.zext(truncBf); if (SimplifyDemandedBits(I->getOperandUse(0), DemandedMask, KnownZero, KnownOne, Depth+1)) return I; - DemandedMask.trunc(BitWidth); - KnownZero.trunc(BitWidth); - KnownOne.trunc(BitWidth); + DemandedMask = DemandedMask.trunc(BitWidth); + KnownZero = KnownZero.trunc(BitWidth); + KnownOne = KnownOne.trunc(BitWidth); assert(!(KnownZero & KnownOne) && "Bits known to be one AND zero?"); break; } @@ -426,15 +426,15 @@ // Compute the bits in the result that are not present in the input. unsigned SrcBitWidth =I->getOperand(0)->getType()->getScalarSizeInBits(); - DemandedMask.trunc(SrcBitWidth); - KnownZero.trunc(SrcBitWidth); - KnownOne.trunc(SrcBitWidth); + DemandedMask = DemandedMask.trunc(SrcBitWidth); + KnownZero = KnownZero.trunc(SrcBitWidth); + KnownOne = KnownOne.trunc(SrcBitWidth); if (SimplifyDemandedBits(I->getOperandUse(0), DemandedMask, KnownZero, KnownOne, Depth+1)) return I; - DemandedMask.zext(BitWidth); - KnownZero.zext(BitWidth); - KnownOne.zext(BitWidth); + DemandedMask = DemandedMask.zext(BitWidth); + KnownZero = KnownZero.zext(BitWidth); + KnownOne = KnownOne.zext(BitWidth); assert(!(KnownZero & KnownOne) && "Bits known to be one AND zero?"); // The top bits are known to be zero. KnownZero |= APInt::getHighBitsSet(BitWidth, BitWidth - SrcBitWidth); @@ -453,15 +453,15 @@ if ((NewBits & DemandedMask) != 0) InputDemandedBits.setBit(SrcBitWidth-1); - InputDemandedBits.trunc(SrcBitWidth); - KnownZero.trunc(SrcBitWidth); - KnownOne.trunc(SrcBitWidth); + InputDemandedBits = InputDemandedBits.trunc(SrcBitWidth); + KnownZero = KnownZero.trunc(SrcBitWidth); + KnownOne = KnownOne.trunc(SrcBitWidth); if (SimplifyDemandedBits(I->getOperandUse(0), InputDemandedBits, KnownZero, KnownOne, Depth+1)) return I; - InputDemandedBits.zext(BitWidth); - KnownZero.zext(BitWidth); - KnownOne.zext(BitWidth); + InputDemandedBits = InputDemandedBits.zext(BitWidth); + KnownZero = KnownZero.zext(BitWidth); + KnownOne = KnownOne.zext(BitWidth); assert(!(KnownZero & KnownOne) && "Bits known to be one AND zero?"); // If the sign bit of the input is known set or clear, then we know the Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Tue Dec 7 02:25:19 2010 @@ -63,8 +63,8 @@ while (Val.getBitWidth() != 8) { unsigned NextWidth = Val.getBitWidth()/2; Val2 = Val.lshr(NextWidth); - Val2.trunc(Val.getBitWidth()/2); - Val.trunc(Val.getBitWidth()/2); + Val2 = Val2.trunc(Val.getBitWidth()/2); + Val = Val.trunc(Val.getBitWidth()/2); // If the top/bottom halves aren't the same, reject it. if (Val != Val2) Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/ConstantFold.cpp (original) +++ llvm/trunk/lib/VMCore/ConstantFold.cpp Tue Dec 7 02:25:19 2010 @@ -202,7 +202,7 @@ APInt V = CI->getValue(); if (ByteStart) V = V.lshr(ByteStart*8); - V.trunc(ByteSize*8); + V = V.trunc(ByteSize*8); return ConstantInt::get(CI->getContext(), V); } @@ -647,25 +647,22 @@ case Instruction::ZExt: if (ConstantInt *CI = dyn_cast(V)) { uint32_t BitWidth = cast(DestTy)->getBitWidth(); - APInt Result(CI->getValue()); - Result.zext(BitWidth); - return ConstantInt::get(V->getContext(), Result); + return ConstantInt::get(V->getContext(), + CI->getValue().zext(BitWidth)); } return 0; case Instruction::SExt: if (ConstantInt *CI = dyn_cast(V)) { uint32_t BitWidth = cast(DestTy)->getBitWidth(); - APInt Result(CI->getValue()); - Result.sext(BitWidth); - return ConstantInt::get(V->getContext(), Result); + return ConstantInt::get(V->getContext(), + CI->getValue().sext(BitWidth)); } return 0; case Instruction::Trunc: { uint32_t DestBitWidth = cast(DestTy)->getBitWidth(); if (ConstantInt *CI = dyn_cast(V)) { - APInt Result(CI->getValue()); - Result.trunc(DestBitWidth); - return ConstantInt::get(V->getContext(), Result); + return ConstantInt::get(V->getContext(), + CI->getValue().trunc(DestBitWidth)); } // The input must be a constantexpr. See if we can simplify this based on Modified: llvm/trunk/unittests/Support/ConstantRangeTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ConstantRangeTest.cpp?rev=121120&r1=121119&r2=121120&view=diff ============================================================================== --- llvm/trunk/unittests/Support/ConstantRangeTest.cpp (original) +++ llvm/trunk/unittests/Support/ConstantRangeTest.cpp Tue Dec 7 02:25:19 2010 @@ -171,8 +171,8 @@ ConstantRange TWrap = Wrap.truncate(10); EXPECT_TRUE(TFull.isFullSet()); EXPECT_TRUE(TEmpty.isEmptySet()); - EXPECT_EQ(TOne, ConstantRange(APInt(One.getLower()).trunc(10), - APInt(One.getUpper()).trunc(10))); + EXPECT_EQ(TOne, ConstantRange(One.getLower().trunc(10), + One.getUpper().trunc(10))); EXPECT_TRUE(TSome.isFullSet()); } @@ -184,10 +184,10 @@ ConstantRange ZWrap = Wrap.zeroExtend(20); EXPECT_EQ(ZFull, ConstantRange(APInt(20, 0), APInt(20, 0x10000))); EXPECT_TRUE(ZEmpty.isEmptySet()); - EXPECT_EQ(ZOne, ConstantRange(APInt(One.getLower()).zext(20), - APInt(One.getUpper()).zext(20))); - EXPECT_EQ(ZSome, ConstantRange(APInt(Some.getLower()).zext(20), - APInt(Some.getUpper()).zext(20))); + EXPECT_EQ(ZOne, ConstantRange(One.getLower().zext(20), + One.getUpper().zext(20))); + EXPECT_EQ(ZSome, ConstantRange(Some.getLower().zext(20), + Some.getUpper().zext(20))); EXPECT_EQ(ZWrap, ConstantRange(APInt(20, 0), APInt(20, 0x10000))); } @@ -200,10 +200,10 @@ EXPECT_EQ(SFull, ConstantRange(APInt(20, (uint64_t)INT16_MIN, true), APInt(20, INT16_MAX + 1, true))); EXPECT_TRUE(SEmpty.isEmptySet()); - EXPECT_EQ(SOne, ConstantRange(APInt(One.getLower()).sext(20), - APInt(One.getUpper()).sext(20))); - EXPECT_EQ(SSome, ConstantRange(APInt(Some.getLower()).sext(20), - APInt(Some.getUpper()).sext(20))); + EXPECT_EQ(SOne, ConstantRange(One.getLower().sext(20), + One.getUpper().sext(20))); + EXPECT_EQ(SSome, ConstantRange(Some.getLower().sext(20), + Some.getUpper().sext(20))); EXPECT_EQ(SWrap, ConstantRange(APInt(20, (uint64_t)INT16_MIN, true), APInt(20, INT16_MAX + 1, true))); From jay.foad at gmail.com Tue Dec 7 02:26:04 2010 From: jay.foad at gmail.com (Jay Foad) Date: Tue, 07 Dec 2010 08:26:04 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r121122 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <20101207082604.D4BA12A6C12C@llvm.org> Author: foad Date: Tue Dec 7 02:26:04 2010 New Revision: 121122 URL: http://llvm.org/viewvc/llvm-project?rev=121122&view=rev Log: PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() and zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method trunc(), to be const and to return a new value instead of modifying the object in place. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=121122&r1=121121&r2=121122&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Dec 7 02:26:04 2010 @@ -8346,7 +8346,7 @@ ValC = 0; } else if (!BYTES_BIG_ENDIAN) { // Little endian, take bits from the bottom of the field value. - ValForPrevField.trunc(BitsInPreviousField); + ValForPrevField = ValForPrevField.trunc(BitsInPreviousField); APInt Tmp = ValC->getValue(); Tmp = Tmp.lshr(BitsInPreviousField); Tmp = Tmp.trunc(ValBitSize-BitsInPreviousField); @@ -8354,7 +8354,7 @@ } else { // Big endian, take bits from the top of the field value. ValForPrevField = ValForPrevField.lshr(ValBitSize-BitsInPreviousField); - ValForPrevField.trunc(BitsInPreviousField); + ValForPrevField = ValForPrevField.trunc(BitsInPreviousField); APInt Tmp = ValC->getValue(); Tmp = Tmp.trunc(ValBitSize-BitsInPreviousField); @@ -8363,7 +8363,7 @@ // Okay, we're going to insert ValForPrevField into the previous i8, extend // it and shift into place. - ValForPrevField.zext(8); + ValForPrevField = ValForPrevField.zext(8); if (!BYTES_BIG_ENDIAN) { ValForPrevField = ValForPrevField.shl(8-BitsInPreviousField); } else { @@ -8391,23 +8391,19 @@ if (Val.getBitWidth() > 8) { if (!BYTES_BIG_ENDIAN) { // Little endian lays out low bits first. - APInt Tmp = Val; - Tmp.trunc(8); + APInt Tmp = Val.trunc(8); ValToAppend = ConstantInt::get(Context, Tmp); Val = Val.lshr(8); } else { // Big endian lays out high bits first. - APInt Tmp = Val; - Tmp = Tmp.lshr(Tmp.getBitWidth()-8); - Tmp.trunc(8); + APInt Tmp = Val.lshr(Tmp.getBitWidth()-8).trunc(8); ValToAppend = ConstantInt::get(Context, Tmp); } } else if (Val.getBitWidth() == 8) { ValToAppend = ConstantInt::get(Context, Val); } else { - APInt Tmp = Val; - Tmp.zext(8); + APInt Tmp = Val.zext(8); if (BYTES_BIG_ENDIAN) Tmp = Tmp << 8-Val.getBitWidth(); @@ -8419,7 +8415,7 @@ if (Val.getBitWidth() <= 8) break; - Val.trunc(Val.getBitWidth()-8); + Val = Val.trunc(Val.getBitWidth()-8); } } From baldrick at free.fr Tue Dec 7 03:02:21 2010 From: baldrick at free.fr (Duncan Sands) Date: Tue, 07 Dec 2010 09:02:21 -0000 Subject: [llvm-commits] [dragonegg] r121123 - /dragonegg/trunk/llvm-convert.cpp Message-ID: <20101207090222.0B2552A6C12D@llvm.org> Author: baldrick Date: Tue Dec 7 03:02:21 2010 New Revision: 121123 URL: http://llvm.org/viewvc/llvm-project?rev=121123&view=rev Log: Port commit 121122 (foad) from llvm-gcc: PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() and zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method trunc(), to be const and to return a new value instead of modifying the object in place. Modified: dragonegg/trunk/llvm-convert.cpp Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=121123&r1=121122&r2=121123&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Tue Dec 7 03:02:21 2010 @@ -8428,7 +8428,7 @@ ValC = 0; } else if (!BYTES_BIG_ENDIAN) { // Little endian, take bits from the bottom of the field value. - ValForPrevField.trunc(BitsInPreviousField); + ValForPrevField = ValForPrevField.trunc(BitsInPreviousField); APInt Tmp = ValC->getValue(); Tmp = Tmp.lshr(BitsInPreviousField); Tmp = Tmp.trunc(ValBitSize-BitsInPreviousField); @@ -8436,7 +8436,7 @@ } else { // Big endian, take bits from the top of the field value. ValForPrevField = ValForPrevField.lshr(ValBitSize-BitsInPreviousField); - ValForPrevField.trunc(BitsInPreviousField); + ValForPrevField = ValForPrevField.trunc(BitsInPreviousField); APInt Tmp = ValC->getValue(); Tmp = Tmp.trunc(ValBitSize-BitsInPreviousField); @@ -8445,7 +8445,7 @@ // Okay, we're going to insert ValForPrevField into the previous i8, extend // it and shift into place. - ValForPrevField.zext(8); + ValForPrevField = ValForPrevField.zext(8); if (!BYTES_BIG_ENDIAN) { ValForPrevField = ValForPrevField.shl(8-BitsInPreviousField); } else { @@ -8473,23 +8473,19 @@ if (Val.getBitWidth() > 8) { if (!BYTES_BIG_ENDIAN) { // Little endian lays out low bits first. - APInt Tmp = Val; - Tmp.trunc(8); + APInt Tmp = Val.trunc(8); ValToAppend = ConstantInt::get(Context, Tmp); Val = Val.lshr(8); } else { // Big endian lays out high bits first. - APInt Tmp = Val; - Tmp = Tmp.lshr(Tmp.getBitWidth()-8); - Tmp.trunc(8); + APInt Tmp = Val.lshr(Tmp.getBitWidth()-8).trunc(8); ValToAppend = ConstantInt::get(Context, Tmp); } } else if (Val.getBitWidth() == 8) { ValToAppend = ConstantInt::get(Context, Val); } else { - APInt Tmp = Val; - Tmp.zext(8); + APInt Tmp = Val.zext(8); if (BYTES_BIG_ENDIAN) Tmp = Tmp << 8-Val.getBitWidth(); @@ -8501,7 +8497,7 @@ if (Val.getBitWidth() <= 8) break; - Val.trunc(Val.getBitWidth()-8); + Val = Val.trunc(Val.getBitWidth()-8); } } From baldrick at free.fr Tue Dec 7 03:14:21 2010 From: baldrick at free.fr (Duncan Sands) Date: Tue, 07 Dec 2010 09:14:21 -0000 Subject: [llvm-commits] [dragonegg] r121124 - /dragonegg/trunk/llvm-convert.cpp Message-ID: <20101207091421.17FAC2A6C12D@llvm.org> Author: baldrick Date: Tue Dec 7 03:14:20 2010 New Revision: 121124 URL: http://llvm.org/viewvc/llvm-project?rev=121124&view=rev Log: Fix bug introduced by the previous commit. Modified: dragonegg/trunk/llvm-convert.cpp Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=121124&r1=121123&r2=121124&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Tue Dec 7 03:14:20 2010 @@ -8479,7 +8479,7 @@ Val = Val.lshr(8); } else { // Big endian lays out high bits first. - APInt Tmp = Val.lshr(Tmp.getBitWidth()-8).trunc(8); + APInt Tmp = Val.lshr(Val.getBitWidth()-8).trunc(8); ValToAppend = ConstantInt::get(Context, Tmp); } } else if (Val.getBitWidth() == 8) { From baldrick at free.fr Tue Dec 7 03:17:50 2010 From: baldrick at free.fr (Duncan Sands) Date: Tue, 07 Dec 2010 10:17:50 +0100 Subject: [llvm-commits] [llvm-gcc-4.2] r121122 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <20101207082604.D4BA12A6C12C@llvm.org> References: <20101207082604.D4BA12A6C12C@llvm.org> Message-ID: <4CFDFBBE.5090309@free.fr> Hi Jay, > } else { > // Big endian lays out high bits first. > - APInt Tmp = Val; > - Tmp = Tmp.lshr(Tmp.getBitWidth()-8); > - Tmp.trunc(8); > + APInt Tmp = Val.lshr(Tmp.getBitWidth()-8).trunc(8); ^ should be Val.getBitWidth(), not Tmp.getBitWidth(). > ValToAppend = ConstantInt::get(Context, Tmp); > } Ciao, Duncan. From baldrick at free.fr Tue Dec 7 03:19:44 2010 From: baldrick at free.fr (Duncan Sands) Date: Tue, 07 Dec 2010 09:19:44 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r121125 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <20101207091944.489672A6C12D@llvm.org> Author: baldrick Date: Tue Dec 7 03:19:44 2010 New Revision: 121125 URL: http://llvm.org/viewvc/llvm-project?rev=121125&view=rev Log: Fix bug introduced by the previous commit. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=121125&r1=121124&r2=121125&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Dec 7 03:19:44 2010 @@ -8397,7 +8397,7 @@ Val = Val.lshr(8); } else { // Big endian lays out high bits first. - APInt Tmp = Val.lshr(Tmp.getBitWidth()-8).trunc(8); + APInt Tmp = Val.lshr(Val.getBitWidth()-8).trunc(8); ValToAppend = ConstantInt::get(Context, Tmp); } } else if (Val.getBitWidth() == 8) { From fvbommel at gmail.com Tue Dec 7 04:22:07 2010 From: fvbommel at gmail.com (Frits van Bommel) Date: Tue, 07 Dec 2010 10:22:07 -0000 Subject: [llvm-commits] [llvm] r121127 - /llvm/trunk/unittests/CMakeLists.txt Message-ID: <20101207102207.DA6732A6C12C@llvm.org> Author: fvbommel Date: Tue Dec 7 04:22:07 2010 New Revision: 121127 URL: http://llvm.org/viewvc/llvm-project?rev=121127&view=rev Log: CMake: Fix warning in gtest header used by unit tests. Modified: llvm/trunk/unittests/CMakeLists.txt Modified: llvm/trunk/unittests/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/CMakeLists.txt?rev=121127&r1=121126&r2=121127&view=diff ============================================================================== --- llvm/trunk/unittests/CMakeLists.txt (original) +++ llvm/trunk/unittests/CMakeLists.txt Tue Dec 7 04:22:07 2010 @@ -22,6 +22,10 @@ add_definitions(-DGTEST_HAS_PTHREAD=0) endif() +if(SUPPORTS_NO_VARIADIC_MACROS_FLAG) + add_definitions("-Wno-variadic-macros") +endif() + set(LLVM_LINK_COMPONENTS jit interpreter From geek4civic at gmail.com Tue Dec 7 04:28:19 2010 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Tue, 7 Dec 2010 19:28:19 +0900 Subject: [llvm-commits] [Review request][Win] CMake & Lit: the new feature "LLVM_LIT_TOOLS_DIR" Message-ID: Good evening, guys! You can run tests on Visual Studio without adding anything to %PATH%. (to set LLVM_LIT_TOOLS_DIR and PYTHON_EXECUTABLE with CMake) You can run tests with gnuwin32 on both Mingw and MSYS. You can run tests on autoconf/MSYS with bash. Please give me any comments for this feature! This patch provides new features; - Lit can pick up *sane* toolchain. LitConfig.getToolsPath() can seek and pick up directory where all of given commands [cmp, grep, sed] are in. We ought never to meet C:/windows/system32/sort.exe etc. - If the directory has "bash.exe", we can use bash shell for tests. (even on Visual Studio! :p ) Even with configure, Lit can find bash.exe. Note: Lit tests with MSYS have some issues. You can work around it. - You can specify LLVM_LIT_TOOLS_DIR. Toolchain can be picked up from there. Then you don't need to add gnuwin32 dir to %PATH%. If MSYS bash.exe is there, bash tests will be executed. [llvm] * 0001-CMake-Add-the-new-option-LLVM_LIT_TOOLS_DIR.-It-.patch.txt It adds the option "LLVM_LIT_TOOLS_DIR". With CMake GUI, it can be set by directory chooser dialog. It does nothing. It can be read from lit.config.lit_tools_dir. * 0002-lit-Util.py-Add-two-functions-checkToolsPath-dir.patch.txt It adds two functions to Util. * 0003-lit-LitConfig.py-Add-the-new-method-getToolsPath.patch.txt It adds a method to LitConfig. It depends to 0002. * 0004-test-lit.cfg-Seek-sane-tools-and-bash-in-directo.patch.txt It activates LLVM_LIT_TOOLS_DIR. [clang] * 0001-test-CMake-Be-aware-of-LLVM_LIT_TOOLS_DIR.patch.txt It activates LLVM_LIT_TOOLS_DIR. ...Takumi -------------- next part -------------- From 8a44363de50f4f06f79adc0081f43661d15a4e3a Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Tue, 9 Nov 2010 13:44:00 +0900 Subject: [PATCH 1/4] CMake: Add the new option LLVM_LIT_TOOLS_DIR. It can specify "Path to GnuWin32 tools". --- CMakeLists.txt | 2 ++ test/lit.site.cfg.in | 1 + 2 files changed, 3 insertions(+), 0 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d1f66b..2ce6301 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,6 +110,8 @@ endif() set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit") +set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools") + option(LLVM_ENABLE_THREADS "Use threads if available." ON) if( uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" ) diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in index eb5fa8c..3588aa6 100644 --- a/test/lit.site.cfg.in +++ b/test/lit.site.cfg.in @@ -4,6 +4,7 @@ config.llvm_src_root = "@LLVM_SOURCE_DIR@" config.llvm_obj_root = "@LLVM_BINARY_DIR@" config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" config.llvmgcc_dir = "@LLVMGCCDIR@" +config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" config.python_executable = "@PYTHON_EXECUTABLE@" config.enable_shared = @ENABLE_SHARED@ -- 1.7.1.GIT -------------- next part -------------- From a8d3c34a9bf2699b863759606b439841578c36da Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Tue, 9 Nov 2010 13:51:28 +0900 Subject: [PATCH 2/4] lit/Util.py: Add two functions, checkToolsPath(dir,tools) and whichTools(tools,paths). checkToolsPath(dir,tools): return True if "dir" contains all "tools". whichTools(tools,paths): return a directory that contains all "tools" in "paths". Or return None when all "tools" were not met. --- utils/lit/lit/Util.py | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/utils/lit/lit/Util.py b/utils/lit/lit/Util.py index 414b714..ad4adf2 100644 --- a/utils/lit/lit/Util.py +++ b/utils/lit/lit/Util.py @@ -75,6 +75,18 @@ def which(command, paths = None): return None +def checkToolsPath(dir, tools): + for tool in tools: + if not os.path.exists(os.path.join(dir, tool)): + return False; + return True; + +def whichTools(tools, paths): + for path in paths.split(os.pathsep): + if checkToolsPath(path, tools): + return path + return None + def printHistogram(items, title = 'Items'): import itertools, math -- 1.7.1.GIT -------------- next part -------------- From e2e9936554c1f84d085a17f9a107cdd9dfcb29ac Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Tue, 9 Nov 2010 13:57:11 +0900 Subject: [PATCH 3/4] lit/LitConfig.py: Add the new method getToolsPath(dir,paths,tools). It seeks tools(eg. [cmp, grep, sed]) in same directory, to be sane. It seeks "bash" only in the directory found at last time. Or bash would be insane (against other tools). --- utils/lit/lit/LitConfig.py | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/utils/lit/lit/LitConfig.py b/utils/lit/lit/LitConfig.py index 43ed6f1..7ca1b9c 100644 --- a/utils/lit/lit/LitConfig.py +++ b/utils/lit/lit/LitConfig.py @@ -85,6 +85,22 @@ class LitConfig: return self.bashPath + def getToolsPath(self, dir, paths, tools): + import os, Util + if dir is not None and os.path.isabs(dir) and os.path.isdir(dir): + if not Util.checkToolsPath(dir, tools): + return None + else: + dir = Util.whichTools(tools, paths) + + # bash + self.bashPath = Util.which('bash', dir) + if self.bashPath is None: + self.warning("Unable to find 'bash.exe'.") + self.bashPath = '' + + return dir + def _write_message(self, kind, message): import inspect, os, sys -- 1.7.1.GIT -------------- next part -------------- From 168ff9417ddc9b79b0122cc2712dc836cdb50b01 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Tue, 9 Nov 2010 14:12:36 +0900 Subject: [PATCH 4/4] test/lit.cfg: Seek sane tools(and bash) in directories and set to $PATH. LitConfig.getBashPath() will not seek in $PATH after LitConfig.getToolsPath() was executed. --- test/lit.cfg | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/test/lit.cfg b/test/lit.cfg index 98f7209..ca55666 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -18,6 +18,18 @@ config.suffixes = [] # test_source_root: The root path where tests are located. config.test_source_root = os.path.dirname(__file__) +# Tweak PATH for Win32 +if sys.platform in ['win32']: + # Seek sane tools in directories and set to $PATH. + path = getattr(config, 'lit_tools_dir', None) + path = lit.getToolsPath(path, + config.environment['PATH'], + ['cmp.exe', 'grep.exe', 'sed.exe']) + if path is not None: + path = os.path.pathsep.join((path, + config.environment['PATH'])) + config.environment['PATH'] = path + # test_exec_root: The root path where tests should be run. llvm_obj_root = getattr(config, 'llvm_obj_root', None) if llvm_obj_root is not None: @@ -227,7 +239,7 @@ config.on_clone = on_clone ### Features # Shell execution -if sys.platform not in ['win32']: +if sys.platform not in ['win32'] or lit.getBashPath() != '': config.available_features.add('shell') # Loadable module -- 1.7.1.GIT -------------- next part -------------- From ff857b0367a9e02f59d28fda3dbe65e3a644c150 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Tue, 9 Nov 2010 13:25:42 +0900 Subject: [PATCH] test: CMake: Be aware of LLVM_LIT_TOOLS_DIR. --- test/lit.cfg | 12 ++++++++++++ test/lit.site.cfg.in | 1 + 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/test/lit.cfg b/test/lit.cfg index 071284f..b9b815b 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -8,6 +8,18 @@ import platform # name: The name of this test suite. config.name = 'Clang' +# Tweak PATH for Win32 +if platform.system() == 'Windows': + # Seek sane tools in directories and set to $PATH. + path = getattr(config, 'lit_tools_dir', None) + path = lit.getToolsPath(path, + config.environment['PATH'], + ['cmp.exe', 'grep.exe', 'sed.exe']) + if path is not None: + path = os.path.pathsep.join((path, + config.environment['PATH'])) + config.environment['PATH'] = path + # testFormat: The test format to use to interpret tests. # # For now we require '&&' between commands, until they get globally killed and diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in index 0d452ef..df90b81 100644 --- a/test/lit.site.cfg.in +++ b/test/lit.site.cfg.in @@ -4,6 +4,7 @@ config.llvm_src_root = "@LLVM_SOURCE_DIR@" config.llvm_obj_root = "@LLVM_BINARY_DIR@" config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" config.llvm_libs_dir = "@LLVM_LIBS_DIR@" +config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" config.clang_obj_root = "@CLANG_BINARY_DIR@" config.target_triple = "@TARGET_TRIPLE@" -- 1.7.1.GIT From ofv at wanadoo.es Tue Dec 7 04:44:53 2010 From: ofv at wanadoo.es (=?utf-8?Q?=C3=93scar?= Fuentes) Date: Tue, 07 Dec 2010 11:44:53 +0100 Subject: [llvm-commits] [Review request][Win] CMake & Lit: the new feature "LLVM_LIT_TOOLS_DIR" In-Reply-To: (NAKAMURA Takumi's message of "Tue, 7 Dec 2010 19:28:19 +0900") References: Message-ID: <87zkshc15m.fsf@telefonica.net> Hello Takumi. NAKAMURA Takumi writes: [snip] > +set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools") I guess that other ports can be used (MSYS, Cygwin, etc) So instead of GnuWin32 maybe you should list the names of the required tools (cmp, sed, grep) on the docstring. +set(LLVM_LIT_TOOLS_DIR "" CACHE PATH + "Path to GNU cmp, grep and sed. Used when running tests.") From jay.foad at gmail.com Tue Dec 7 07:04:11 2010 From: jay.foad at gmail.com (Jay Foad) Date: Tue, 7 Dec 2010 13:04:11 +0000 Subject: [llvm-commits] [llvm-gcc-4.2] r121122 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <4CFDFBBE.5090309@free.fr> References: <20101207082604.D4BA12A6C12C@llvm.org> <4CFDFBBE.5090309@free.fr> Message-ID: On 7 December 2010 09:17, Duncan Sands wrote: > Hi Jay, > >> ? ? ? ? } else { >> ? ? ? ? ? // Big endian lays out high bits first. >> - ? ? ? ?APInt Tmp = Val; >> - ? ? ? ?Tmp = Tmp.lshr(Tmp.getBitWidth()-8); >> - ? ? ? ?Tmp.trunc(8); >> + ? ? ? ?APInt Tmp = Val.lshr(Tmp.getBitWidth()-8).trunc(8); > > ^ should be Val.getBitWidth(), not Tmp.getBitWidth(). > >> ? ? ? ? ? ValToAppend = ConstantInt::get(Context, Tmp); >> ? ? ? ? } > > Ciao, Duncan. Sorry. Thanks for fixing it. Jay. From fvbommel at gmail.com Tue Dec 7 07:08:07 2010 From: fvbommel at gmail.com (Frits van Bommel) Date: Tue, 07 Dec 2010 13:08:07 -0000 Subject: [llvm-commits] [llvm] r121133 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <20101207130807.EF2A52A6C12C@llvm.org> Author: fvbommel Date: Tue Dec 7 07:08:07 2010 New Revision: 121133 URL: http://llvm.org/viewvc/llvm-project?rev=121133&view=rev Log: Remove some dead code from the jump threading pass. The last uses of these functions were removed in r113852 when LazyValueInfo was permanently enabled and removed the need for them. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=121133&r1=121132&r2=121133&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Tue Dec 7 07:08:07 2010 @@ -121,10 +121,6 @@ bool ProcessThreadableEdges(Value *Cond, BasicBlock *BB, ConstantPreference Preference); - - bool ProcessBranchOnDuplicateCond(BasicBlock *PredBB, BasicBlock *DestBB); - bool ProcessSwitchOnDuplicateCond(BasicBlock *PredBB, BasicBlock *DestBB); - bool ProcessBranchOnPHI(PHINode *PN); bool ProcessBranchOnXOR(BinaryOperator *BO); @@ -753,143 +749,6 @@ return false; } -/// ProcessBranchOnDuplicateCond - We found a block and a predecessor of that -/// block that jump on exactly the same condition. This means that we almost -/// always know the direction of the edge in the DESTBB: -/// PREDBB: -/// br COND, DESTBB, BBY -/// DESTBB: -/// br COND, BBZ, BBW -/// -/// If DESTBB has multiple predecessors, we can't just constant fold the branch -/// in DESTBB, we have to thread over it. -bool JumpThreading::ProcessBranchOnDuplicateCond(BasicBlock *PredBB, - BasicBlock *BB) { - BranchInst *PredBI = cast(PredBB->getTerminator()); - - // If both successors of PredBB go to DESTBB, we don't know anything. We can - // fold the branch to an unconditional one, which allows other recursive - // simplifications. - bool BranchDir; - if (PredBI->getSuccessor(1) != BB) - BranchDir = true; - else if (PredBI->getSuccessor(0) != BB) - BranchDir = false; - else { - DEBUG(dbgs() << " In block '" << PredBB->getName() - << "' folding terminator: " << *PredBB->getTerminator() << '\n'); - ++NumFolds; - ConstantFoldTerminator(PredBB); - return true; - } - - BranchInst *DestBI = cast(BB->getTerminator()); - - // If the dest block has one predecessor, just fix the branch condition to a - // constant and fold it. - if (BB->getSinglePredecessor()) { - DEBUG(dbgs() << " In block '" << BB->getName() - << "' folding condition to '" << BranchDir << "': " - << *BB->getTerminator() << '\n'); - ++NumFolds; - Value *OldCond = DestBI->getCondition(); - DestBI->setCondition(ConstantInt::get(Type::getInt1Ty(BB->getContext()), - BranchDir)); - // Delete dead instructions before we fold the branch. Folding the branch - // can eliminate edges from the CFG which can end up deleting OldCond. - RecursivelyDeleteTriviallyDeadInstructions(OldCond); - ConstantFoldTerminator(BB); - return true; - } - - - // Next, figure out which successor we are threading to. - BasicBlock *SuccBB = DestBI->getSuccessor(!BranchDir); - - SmallVector Preds; - Preds.push_back(PredBB); - - // Ok, try to thread it! - return ThreadEdge(BB, Preds, SuccBB); -} - -/// ProcessSwitchOnDuplicateCond - We found a block and a predecessor of that -/// block that switch on exactly the same condition. This means that we almost -/// always know the direction of the edge in the DESTBB: -/// PREDBB: -/// switch COND [... DESTBB, BBY ... ] -/// DESTBB: -/// switch COND [... BBZ, BBW ] -/// -/// Optimizing switches like this is very important, because simplifycfg builds -/// switches out of repeated 'if' conditions. -bool JumpThreading::ProcessSwitchOnDuplicateCond(BasicBlock *PredBB, - BasicBlock *DestBB) { - // Can't thread edge to self. - if (PredBB == DestBB) - return false; - - SwitchInst *PredSI = cast(PredBB->getTerminator()); - SwitchInst *DestSI = cast(DestBB->getTerminator()); - - // There are a variety of optimizations that we can potentially do on these - // blocks: we order them from most to least preferable. - - // If DESTBB *just* contains the switch, then we can forward edges from PREDBB - // directly to their destination. This does not introduce *any* code size - // growth. Skip debug info first. - BasicBlock::iterator BBI = DestBB->begin(); - while (isa(BBI)) - BBI++; - - // FIXME: Thread if it just contains a PHI. - if (isa(BBI)) { - bool MadeChange = false; - // Ignore the default edge for now. - for (unsigned i = 1, e = DestSI->getNumSuccessors(); i != e; ++i) { - ConstantInt *DestVal = DestSI->getCaseValue(i); - BasicBlock *DestSucc = DestSI->getSuccessor(i); - - // Okay, DestSI has a case for 'DestVal' that goes to 'DestSucc'. See if - // PredSI has an explicit case for it. If so, forward. If it is covered - // by the default case, we can't update PredSI. - unsigned PredCase = PredSI->findCaseValue(DestVal); - if (PredCase == 0) continue; - - // If PredSI doesn't go to DestBB on this value, then it won't reach the - // case on this condition. - if (PredSI->getSuccessor(PredCase) != DestBB && - DestSI->getSuccessor(i) != DestBB) - continue; - - // Do not forward this if it already goes to this destination, this would - // be an infinite loop. - if (PredSI->getSuccessor(PredCase) == DestSucc) - continue; - - // Otherwise, we're safe to make the change. Make sure that the edge from - // DestSI to DestSucc is not critical and has no PHI nodes. - DEBUG(dbgs() << "FORWARDING EDGE " << *DestVal << " FROM: " << *PredSI); - DEBUG(dbgs() << "THROUGH: " << *DestSI); - - // If the destination has PHI nodes, just split the edge for updating - // simplicity. - if (isa(DestSucc->begin()) && !DestSucc->getSinglePredecessor()){ - SplitCriticalEdge(DestSI, i, this); - DestSucc = DestSI->getSuccessor(i); - } - FoldSingleEntryPHINodes(DestSucc); - PredSI->setSuccessor(PredCase, DestSucc); - MadeChange = true; - } - - if (MadeChange) - return true; - } - - return false; -} - /// SimplifyPartiallyRedundantLoad - If LI is an obviously partially redundant /// load instruction, eliminate it by replacing it with a PHI node. This is an From benny.kra at googlemail.com Tue Dec 7 09:50:35 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 07 Dec 2010 15:50:35 -0000 Subject: [llvm-commits] [llvm] r121142 - /llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Message-ID: <20101207155035.573CD2A6C12C@llvm.org> Author: d0k Date: Tue Dec 7 09:50:35 2010 New Revision: 121142 URL: http://llvm.org/viewvc/llvm-project?rev=121142&view=rev Log: Add parens to pacify gcc. Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=121142&r1=121141&r2=121142&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Tue Dec 7 09:50:35 2010 @@ -197,7 +197,7 @@ } unsigned getReg() const { - assert(Kind == Register || Kind == CCOut && "Invalid access!"); + assert((Kind == Register || Kind == CCOut) && "Invalid access!"); return Reg.RegNum; } From daniel at zuster.org Tue Dec 7 10:29:44 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 07 Dec 2010 16:29:44 -0000 Subject: [llvm-commits] [llvm] r121146 - /llvm/trunk/lib/Support/SearchForAddressOfSpecialSymbol.cpp Message-ID: <20101207162944.80C772A6C12C@llvm.org> Author: ddunbar Date: Tue Dec 7 10:29:44 2010 New Revision: 121146 URL: http://llvm.org/viewvc/llvm-project?rev=121146&view=rev Log: build: Go back to dropping __eprintf reference when building with Clang, see comment. Modified: llvm/trunk/lib/Support/SearchForAddressOfSpecialSymbol.cpp Modified: llvm/trunk/lib/Support/SearchForAddressOfSpecialSymbol.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/SearchForAddressOfSpecialSymbol.cpp?rev=121146&r1=121145&r2=121146&view=diff ============================================================================== --- llvm/trunk/lib/Support/SearchForAddressOfSpecialSymbol.cpp (original) +++ llvm/trunk/lib/Support/SearchForAddressOfSpecialSymbol.cpp Tue Dec 7 10:29:44 2010 @@ -44,9 +44,14 @@ EXPLICIT_SYMBOL(__umoddi3); // __eprintf is sometimes used for assert() handling on x86. + // + // FIXME: Currently disabled when using Clang, as we don't always have our + // runtime support libraries available. +#ifndef __clang__ #ifdef __i386__ EXPLICIT_SYMBOL(__eprintf); #endif +#endif } #endif From bigcheesegs at gmail.com Tue Dec 7 11:04:04 2010 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Tue, 07 Dec 2010 17:04:04 -0000 Subject: [llvm-commits] [llvm] r121149 - in /llvm/trunk: include/llvm/Support/PathV2.h lib/Support/PathV2.cpp lib/Support/Unix/PathV2.inc lib/Support/Windows/PathV2.inc unittests/Support/Path.cpp Message-ID: <20101207170404.92B6C2A6C12C@llvm.org> Author: mspencer Date: Tue Dec 7 11:04:04 2010 New Revision: 121149 URL: http://llvm.org/viewvc/llvm-project?rev=121149&view=rev Log: Support/PathV2: Change most functions in the path namespace to return their work via their return value instead of an out parameter. Modified: llvm/trunk/include/llvm/Support/PathV2.h llvm/trunk/lib/Support/PathV2.cpp llvm/trunk/lib/Support/Unix/PathV2.inc llvm/trunk/lib/Support/Windows/PathV2.inc llvm/trunk/unittests/Support/Path.cpp Modified: llvm/trunk/include/llvm/Support/PathV2.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PathV2.h?rev=121149&r1=121148&r2=121149&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/PathV2.h (original) +++ llvm/trunk/include/llvm/Support/PathV2.h Tue Dec 7 11:04:04 2010 @@ -11,8 +11,6 @@ // TR2/boost filesystem (v3), but modified to remove exception handling and the // path class. // -// All functions return void and their actual work via the last out argument. -// //===----------------------------------------------------------------------===// #ifndef LLVM_SUPPORT_PATHV2_H @@ -126,8 +124,7 @@ /// @param extension The extension to be added. It may be empty. It may also /// optionally start with a '.', if it does not, one will be /// prepended. -void replace_extension(SmallVectorImpl &path, - const Twine &extension); +void replace_extension(SmallVectorImpl &path, const Twine &extension); /// @brief Append to path. /// @@ -138,9 +135,9 @@ /// @param path Set to \a path + \a component. /// @param component The component to be appended to \a path. void append(SmallVectorImpl &path, const Twine &a, - const Twine &b = "", - const Twine &c = "", - const Twine &d = ""); + const Twine &b = "", + const Twine &c = "", + const Twine &d = ""); /// @brief Append to path. /// @@ -152,7 +149,7 @@ /// @param begin Start of components to append. /// @param end One past the end of components to append. void append(SmallVectorImpl &path, - const_iterator begin, const_iterator end); + const_iterator begin, const_iterator end); /// @} /// @name Transforms (or some other better name) @@ -177,8 +174,8 @@ /// /hello => /// /// @param path Input path. -/// @param result Set to the root name of \a path if it has one, otherwise "". -void root_name(const StringRef &path, StringRef &result); +/// @result The root name of \a path if it has one, otherwise "". +const StringRef root_name(const StringRef &path); /// @brief Get root directory. /// @@ -187,17 +184,17 @@ /// d/file.txt => /// /// @param path Input path. -/// @param result Set to the root directory of \a path if it has one, otherwise +/// @result The root directory of \a path if it has one, otherwise /// "". -void root_directory(const StringRef &path, StringRef &result); +const StringRef root_directory(const StringRef &path); /// @brief Get root path. /// /// Equivalent to root_name + root_directory. /// /// @param path Input path. -/// @param result Set to the root path of \a path if it has one, otherwise "". -void root_path(const StringRef &path, StringRef &result); +/// @result The root path of \a path if it has one, otherwise "". +const StringRef root_path(const StringRef &path); /// @brief Get relative path. /// @@ -206,9 +203,8 @@ /// /foo/bar => foo/bar /// /// @param path Input path. -/// @param result Set to the path starting after root_path if one exists, -/// otherwise "". -void relative_path(const StringRef &path, StringRef &result); +/// @result The path starting after root_path if one exists, otherwise "". +const StringRef relative_path(const StringRef &path); /// @brief Get parent path. /// @@ -217,8 +213,8 @@ /// foo/../bar => foo/.. /// /// @param path Input path. -/// @param result Set to the parent path of \a path if one exists, otherwise "". -void parent_path(const StringRef &path, StringRef &result); +/// @result The parent path of \a path if one exists, otherwise "". +const StringRef parent_path(const StringRef &path); /// @brief Get filename. /// @@ -228,9 +224,9 @@ /// / => / /// /// @param path Input path. -/// @param result Set to the filename part of \a path. This is defined as the -/// last component of \a path. -void filename(const StringRef &path, StringRef &result); +/// @result The filename part of \a path. This is defined as the last component +/// of \a path. +const StringRef filename(const StringRef &path); /// @brief Get stem. /// @@ -245,8 +241,8 @@ /// /foo/.. => .. /// /// @param path Input path. -/// @param result Set to the stem of \a path. -void stem(const StringRef &path, StringRef &result); +/// @result The stem of \a path. +const StringRef stem(const StringRef &path); /// @brief Get extension. /// @@ -259,84 +255,84 @@ /// /foo/.txt => .txt /// /// @param path Input path. -/// @param result Set to the extension of \a path. -void extension(const StringRef &path, StringRef &result); +/// @result The extension of \a path. +const StringRef extension(const StringRef &path); /// @brief Has root name? /// /// root_name != "" /// /// @param path Input path. -/// @param result Set to true if the path has a root name, false otherwise. -void has_root_name(const Twine &path, bool &result); +/// @result True if the path has a root name, false otherwise. +const bool has_root_name(const Twine &path); /// @brief Has root directory? /// /// root_directory != "" /// /// @param path Input path. -/// @param result Set to true if the path has a root directory, false otherwise. -void has_root_directory(const Twine &path, bool &result); +/// @result True if the path has a root directory, false otherwise. +const bool has_root_directory(const Twine &path); /// @brief Has root path? /// /// root_path != "" /// /// @param path Input path. -/// @param result Set to true if the path has a root path, false otherwise. -void has_root_path(const Twine &path, bool &result); +/// @result True if the path has a root path, false otherwise. +const bool has_root_path(const Twine &path); /// @brief Has relative path? /// /// relative_path != "" /// /// @param path Input path. -/// @param result Set to true if the path has a relative path, false otherwise. -void has_relative_path(const Twine &path, bool &result); +/// @result True if the path has a relative path, false otherwise. +const bool has_relative_path(const Twine &path); /// @brief Has parent path? /// /// parent_path != "" /// /// @param path Input path. -/// @param result Set to true if the path has a parent path, false otherwise. -void has_parent_path(const Twine &path, bool &result); +/// @result True if the path has a parent path, false otherwise. +const bool has_parent_path(const Twine &path); /// @brief Has filename? /// /// filename != "" /// /// @param path Input path. -/// @param result Set to true if the path has a filename, false otherwise. -void has_filename(const Twine &path, bool &result); +/// @result True if the path has a filename, false otherwise. +const bool has_filename(const Twine &path); /// @brief Has stem? /// /// stem != "" /// /// @param path Input path. -/// @param result Set to true if the path has a stem, false otherwise. -void has_stem(const Twine &path, bool &result); +/// @result True if the path has a stem, false otherwise. +const bool has_stem(const Twine &path); /// @brief Has extension? /// /// extension != "" /// /// @param path Input path. -/// @param result Set to true if the path has a extension, false otherwise. -void has_extension(const Twine &path, bool &result); +/// @result True if the path has a extension, false otherwise. +const bool has_extension(const Twine &path); /// @brief Is path absolute? /// /// @param path Input path. -/// @param result Set to true if the path is absolute, false if it is not. -void is_absolute(const Twine &path, bool &result); +/// @result True if the path is absolute, false if it is not. +const bool is_absolute(const Twine &path); /// @brief Is path relative? /// /// @param path Input path. -/// @param result Set to true if the path is relative, false if it is not. -void is_relative(const Twine &path, bool &result); +/// @result True if the path is relative, false if it is not. +const bool is_relative(const Twine &path); } // end namespace path } // end namespace sys Modified: llvm/trunk/lib/Support/PathV2.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/PathV2.cpp?rev=121149&r1=121148&r2=121149&view=diff ============================================================================== --- llvm/trunk/lib/Support/PathV2.cpp (original) +++ llvm/trunk/lib/Support/PathV2.cpp Tue Dec 7 11:04:04 2010 @@ -279,7 +279,7 @@ return Position - RHS.Position; } -void root_path(const StringRef &path, StringRef &result) { +const StringRef root_path(const StringRef &path) { const_iterator b = begin(path), pos = b, e = end(path); @@ -295,26 +295,23 @@ if (has_net || has_drive) { if ((++pos != e) && is_separator((*pos)[0])) { // {C:/,//net/}, so get the first two components. - result = StringRef(path.begin(), b->size() + pos->size()); - return; + return StringRef(path.begin(), b->size() + pos->size()); } else { // just {C:,//net}, return the first component. - result = *b; - return; + return *b; } } // POSIX style root directory. if (is_separator((*b)[0])) { - result = *b; - return; + return *b; } } - result = StringRef(); + return StringRef(); } -void root_name(const StringRef &path, StringRef &result) { +const StringRef root_name(const StringRef &path) { const_iterator b = begin(path), e = end(path); if (b != e) { @@ -328,17 +325,15 @@ if (has_net || has_drive) { // just {C:,//net}, return the first component. - result = *b; - return; + return *b; } } // No path or no name. - result = StringRef(); - return; + return StringRef(); } -void root_directory(const StringRef &path, StringRef &result) { +const StringRef root_directory(const StringRef &path) { const_iterator b = begin(path), pos = b, e = end(path); @@ -354,27 +349,22 @@ if ((has_net || has_drive) && // {C:,//net}, skip to the next component. (++pos != e) && is_separator((*pos)[0])) { - result = *pos; - return; + return *pos; } // POSIX style root directory. if (!has_net && is_separator((*b)[0])) { - result = *b; - return; + return *b; } } // No path or no root. - result = StringRef(); - return; + return StringRef(); } -void relative_path(const StringRef &path, StringRef &result) { - StringRef root; - root_path(path, root); - result = StringRef(path.begin() + root.size(), path.size() - root.size()); - return; +const StringRef relative_path(const StringRef &path) { + StringRef root = root_path(path); + return StringRef(path.begin() + root.size(), path.size() - root.size()); } void append(SmallVectorImpl &path, const Twine &a, @@ -397,8 +387,7 @@ i != e; ++i) { bool path_has_sep = !path.empty() && is_separator(path[path.size() - 1]); bool component_has_sep = !i->empty() && is_separator((*i)[0]); - bool is_root_name = false; - has_root_name(*i, is_root_name); + bool is_root_name = has_root_name(*i); if (path_has_sep) { // Strip separators from beginning of component. @@ -419,12 +408,12 @@ } } -void parent_path(const StringRef &path, StringRef &result) { +const StringRef parent_path(const StringRef &path) { size_t end_pos = parent_path_end(path); if (end_pos == StringRef::npos) - result = StringRef(); + return StringRef(); else - result = StringRef(path.data(), end_pos); + return StringRef(path.data(), end_pos); } void remove_filename(SmallVectorImpl &path) { @@ -433,8 +422,7 @@ path.set_size(end_pos); } -void replace_extension(SmallVectorImpl &path, - const Twine &extension) { +void replace_extension(SmallVectorImpl &path, const Twine &extension) { StringRef p(path.begin(), path.size()); SmallString<32> ext_storage; StringRef ext = extension.toStringRef(ext_storage); @@ -473,121 +461,101 @@ #endif } -void filename(const StringRef &path, StringRef &result) { - result = *(--end(path)); +const StringRef filename(const StringRef &path) { + return *(--end(path)); } -void stem(const StringRef &path, StringRef &result) { - StringRef fname; - filename(path, fname); +const StringRef stem(const StringRef &path) { + StringRef fname = filename(path); size_t pos = fname.find_last_of('.'); if (pos == StringRef::npos) - result = fname; + return fname; else if ((fname.size() == 1 && fname == ".") || (fname.size() == 2 && fname == "..")) - result = fname; + return fname; else - result = StringRef(fname.begin(), pos); + return StringRef(fname.begin(), pos); } -void extension(const StringRef &path, StringRef &result) { - StringRef fname; - filename(path, fname); +const StringRef extension(const StringRef &path) { + StringRef fname = filename(path); size_t pos = fname.find_last_of('.'); if (pos == StringRef::npos) - result = StringRef(); + return StringRef(); else if ((fname.size() == 1 && fname == ".") || (fname.size() == 2 && fname == "..")) - result = StringRef(); + return StringRef(); else - result = StringRef(fname.begin() + pos, fname.size() - pos); + return StringRef(fname.begin() + pos, fname.size() - pos); } -void has_root_name(const Twine &path, bool &result) { +const bool has_root_name(const Twine &path) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); - root_name(p, p); - - result = !p.empty(); + return !root_name(p).empty(); } -void has_root_directory(const Twine &path, bool &result) { +const bool has_root_directory(const Twine &path) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); - root_directory(p, p); - - result = !p.empty(); + return !root_directory(p).empty(); } -void has_root_path(const Twine &path, bool &result) { +const bool has_root_path(const Twine &path) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); - root_path(p, p); - - result = !p.empty(); + return !root_path(p).empty(); } -void has_filename(const Twine &path, bool &result) { +const bool has_filename(const Twine &path) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); - filename(p, p); - - result = !p.empty(); + return !filename(p).empty(); } -void has_parent_path(const Twine &path, bool &result) { +const bool has_parent_path(const Twine &path) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); - parent_path(p, p); - - result = !p.empty(); + return !parent_path(p).empty(); } -void has_stem(const Twine &path, bool &result) { +const bool has_stem(const Twine &path) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); - stem(p, p); - - result = !p.empty(); + return !stem(p).empty(); } -void has_extension(const Twine &path, bool &result) { +const bool has_extension(const Twine &path) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); - extension(p, p); - - result = !p.empty(); + return !extension(p).empty(); } -void is_absolute(const Twine &path, bool &result) { +const bool is_absolute(const Twine &path) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); - bool rootDir = false, - rootName = false; - has_root_directory(p, rootDir); + bool rootDir = has_root_directory(p), #ifdef LLVM_ON_WIN32 - has_root_name(p, rootName); + rootName = has_root_name(p); #else - rootName = true; + rootName = true; #endif - result = rootDir && rootName; + return rootDir && rootName; } -void is_relative(const Twine &path, bool &result) { - bool res; - is_absolute(path, res); - result = !res; +const bool is_relative(const Twine &path) { + return !is_absolute(path); } } // end namespace path @@ -597,9 +565,8 @@ error_code make_absolute(SmallVectorImpl &path) { StringRef p(path.data(), path.size()); - bool rootName = false, rootDirectory = false; - path::has_root_name(p, rootName); - path::has_root_directory(p, rootDirectory); + bool rootName = path::has_root_name(p), + rootDirectory = path::has_root_directory(p); // Already absolute. if (rootName && rootDirectory) @@ -619,8 +586,7 @@ } if (!rootName && rootDirectory) { - StringRef cdrn; - path::root_name(current_dir, cdrn); + StringRef cdrn = path::root_name(current_dir); SmallString<128> curDirRootName(cdrn.begin(), cdrn.end()); path::append(curDirRootName, p); // Set path to the result. @@ -629,14 +595,10 @@ } if (rootName && !rootDirectory) { - StringRef pRootName; - StringRef bRootDirectory; - StringRef bRelativePath; - StringRef pRelativePath; - path::root_name(p, pRootName); - path::root_directory(current_dir, bRootDirectory); - path::relative_path(current_dir, bRelativePath); - path::relative_path(p, pRelativePath); + StringRef pRootName = path::root_name(p); + StringRef bRootDirectory = path::root_directory(current_dir); + StringRef bRelativePath = path::relative_path(current_dir); + StringRef pRelativePath = path::relative_path(p); SmallString<128> res; path::append(res, pRootName, bRootDirectory, bRelativePath, pRelativePath); @@ -652,9 +614,9 @@ SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); - StringRef parent; + StringRef parent = path::parent_path(p); bool parent_exists; - path::parent_path(p, parent); + if (error_code ec = fs::exists(parent, parent_exists)) return ec; if (!parent_exists) Modified: llvm/trunk/lib/Support/Unix/PathV2.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/PathV2.inc?rev=121149&r1=121148&r2=121149&view=diff ============================================================================== --- llvm/trunk/lib/Support/Unix/PathV2.inc (original) +++ llvm/trunk/lib/Support/Unix/PathV2.inc Tue Dec 7 11:04:04 2010 @@ -324,8 +324,7 @@ Model.c_str(); // Make model absolute by prepending a temp directory if it's not already. - bool absolute; - path::is_absolute(Twine(Model), absolute); + bool absolute = path::is_absolute(Twine(Model)); if (!absolute) { SmallString<128> TDir; if (error_code ec = TempDir(TDir)) return ec; Modified: llvm/trunk/lib/Support/Windows/PathV2.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/PathV2.inc?rev=121149&r1=121148&r2=121149&view=diff ============================================================================== --- llvm/trunk/lib/Support/Windows/PathV2.inc (original) +++ llvm/trunk/lib/Support/Windows/PathV2.inc Tue Dec 7 11:04:04 2010 @@ -489,8 +489,7 @@ if (error_code ec = UTF8ToUTF16(m, model_utf16)) return ec; // Make model absolute by prepending a temp directory if it's not already. - bool absolute; - path::is_absolute(m, absolute); + bool absolute = path::is_absolute(m); if (!absolute) { SmallVector temp_dir; Modified: llvm/trunk/unittests/Support/Path.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Path.cpp?rev=121149&r1=121148&r2=121149&view=diff ============================================================================== --- llvm/trunk/unittests/Support/Path.cpp (original) +++ llvm/trunk/unittests/Support/Path.cpp Tue Dec 7 11:04:04 2010 @@ -83,24 +83,22 @@ outs() << "]\n"; #endif - bool bres; - StringRef sfres; - path::has_root_path(*i, bres); - path::root_path(*i, sfres); - path::has_root_name(*i, bres); - path::root_name(*i, sfres); - path::has_root_directory(*i, bres); - path::root_directory(*i, sfres); - path::has_parent_path(*i, bres); - path::parent_path(*i, sfres); - path::has_filename(*i, bres); - path::filename(*i, sfres); - path::has_stem(*i, bres); - path::stem(*i, sfres); - path::has_extension(*i, bres); - path::extension(*i, sfres); - path::is_absolute(*i, bres); - path::is_relative(*i, bres); + path::has_root_path(*i); + path::root_path(*i); + path::has_root_name(*i); + path::root_name(*i); + path::has_root_directory(*i); + path::root_directory(*i); + path::has_parent_path(*i); + path::parent_path(*i); + path::has_filename(*i); + path::filename(*i); + path::has_stem(*i); + path::stem(*i); + path::has_extension(*i); + path::extension(*i); + path::is_absolute(*i); + path::is_relative(*i); SmallString<16> temp_store; temp_store = *i; @@ -111,8 +109,8 @@ temp_store = *i; path::replace_extension(temp_store, "ext"); StringRef filename(temp_store.begin(), temp_store.size()), stem, ext; - path::stem(filename, stem); - path::extension(filename, ext); + stem = path::stem(filename); + ext = path::extension(filename); EXPECT_EQ(*(--sys::path::end(filename)), (stem + ext).str()); path::native(*i, temp_store); From rafael.espindola at gmail.com Tue Dec 7 11:12:32 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 07 Dec 2010 17:12:32 -0000 Subject: [llvm-commits] [llvm] r121152 - in /llvm/trunk: lib/MC/MachObjectWriter.cpp test/MC/MachO/diff-with-two-sections.s Message-ID: <20101207171232.8C1CB2A6C12C@llvm.org> Author: rafael Date: Tue Dec 7 11:12:32 2010 New Revision: 121152 URL: http://llvm.org/viewvc/llvm-project?rev=121152&view=rev Log: Fix absolute recording of differences of symbols in two sections. Reduced from ctor_dtor_count-2.cpp. Added: llvm/trunk/test/MC/MachO/diff-with-two-sections.s Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=121152&r1=121151&r2=121152&view=diff ============================================================================== --- llvm/trunk/lib/MC/MachObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/MachObjectWriter.cpp Tue Dec 7 11:12:32 2010 @@ -884,6 +884,17 @@ // FIXME: Currently, these are never generated (see code below). I cannot // find a case where they are actually emitted. Type = macho::RIT_Vanilla; + } else if (SD->getSymbol().isVariable()) { + const MCExpr *Value = SD->getSymbol().getVariableValue(); + int64_t Res; + bool isAbs = Value->EvaluateAsAbsolute(Res, Layout, SectionAddress); + if (isAbs) { + FixedValue = Res; + return; + } else { + report_fatal_error("unsupported relocation of variable '" + + SD->getSymbol().getName() + "'"); + } } else { // Check whether we need an external or internal relocation. if (doesSymbolRequireExternRelocation(SD)) { Added: llvm/trunk/test/MC/MachO/diff-with-two-sections.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/diff-with-two-sections.s?rev=121152&view=auto ============================================================================== --- llvm/trunk/test/MC/MachO/diff-with-two-sections.s (added) +++ llvm/trunk/test/MC/MachO/diff-with-two-sections.s Tue Dec 7 11:12:32 2010 @@ -0,0 +1,64 @@ +// RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o - | macho-dump --dump-section-data | FileCheck %s + + .section __TEXT,__text,regular,pure_instructions +Leh_func_begin0: + .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support +Ltmp3: +Ltmp4 = Leh_func_begin0-Ltmp3 + .long Ltmp4 + +// CHECK: ('cputype', 7) +// CHECK-NEXT: ('cpusubtype', 3) +// CHECK-NEXT: ('filetype', 1) +// CHECK-NEXT: ('num_load_commands', 1) +// CHECK-NEXT: ('load_commands_size', 192) +// CHECK-NEXT: ('flag', 0) +// CHECK-NEXT: ('load_commands', [ +// CHECK-NEXT: # Load Command 0 +// CHECK-NEXT: (('command', 1) +// CHECK-NEXT: ('size', 192) +// CHECK-NEXT: ('segment_name', '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-NEXT: ('vm_addr', 0) +// CHECK-NEXT: ('vm_size', 4) +// CHECK-NEXT: ('file_offset', 220) +// CHECK-NEXT: ('file_size', 4) +// CHECK-NEXT: ('maxprot', 7) +// CHECK-NEXT: ('initprot', 7) +// CHECK-NEXT: ('num_sections', 2) +// CHECK-NEXT: ('flags', 0) +// CHECK-NEXT: ('sections', [ +// CHECK-NEXT: # Section 0 +// CHECK-NEXT: (('section_name', '__text\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-NEXT: ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-NEXT: ('address', 0) +// CHECK-NEXT: ('size', 0) +// CHECK-NEXT: ('offset', 220) +// CHECK-NEXT: ('alignment', 0) +// CHECK-NEXT: ('reloc_offset', 0) +// CHECK-NEXT: ('num_reloc', 0) +// CHECK-NEXT: ('flags', 0x80000000) +// CHECK-NEXT: ('reserved1', 0) +// CHECK-NEXT: ('reserved2', 0) +// CHECK-NEXT: ), +// CHECK-NEXT: ('_relocations', [ +// CHECK-NEXT: ]) +// CHECK-NEXT: ('_section_data', '') +// CHECK-NEXT: # Section 1 +// CHECK-NEXT: (('section_name', '__eh_frame\x00\x00\x00\x00\x00\x00') +// CHECK-NEXT: ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-NEXT: ('address', 0) +// CHECK-NEXT: ('size', 4) +// CHECK-NEXT: ('offset', 220) +// CHECK-NEXT: ('alignment', 0) +// CHECK-NEXT: ('reloc_offset', 0) +// CHECK-NEXT: ('num_reloc', 0) +// CHECK-NEXT: ('flags', 0x6800000b) +// CHECK-NEXT: ('reserved1', 0) +// CHECK-NEXT: ('reserved2', 0) +// CHECK-NEXT: ), +// CHECK-NEXT: ('_relocations', [ +// CHECK-NEXT: ]) +// CHECK-NEXT: ('_section_data', '00000000') +// CHECK-NEXT: ]) +// CHECK-NEXT: ), +// CHECK-NEXT: ]) From bigcheesegs at gmail.com Tue Dec 7 11:46:24 2010 From: bigcheesegs at gmail.com (Michael Spencer) Date: Tue, 7 Dec 2010 12:46:24 -0500 Subject: [llvm-commits] [PATCH] Remove Support/Alarm. Message-ID: The attached patch removes Support/Alarm because it is unused. This was determined by a local grep over LLVM+Clang, and a Google Code search. - Michael Spencer -------------- next part -------------- A non-text attachment was scrubbed... Name: remove-alarm.patch Type: application/octet-stream Size: 7413 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20101207/af5411d1/attachment-0001.obj From grosbach at apple.com Tue Dec 7 11:48:24 2010 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 07 Dec 2010 17:48:24 -0000 Subject: [llvm-commits] [llvm] r121153 - /llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Message-ID: <20101207174824.B0E582A6C12C@llvm.org> Author: grosbach Date: Tue Dec 7 11:48:24 2010 New Revision: 121153 URL: http://llvm.org/viewvc/llvm-project?rev=121153&view=rev Log: Encode the literal field for tCMPzi instruction. Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=121153&r1=121152&r2=121153&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue Dec 7 11:48:24 2010 @@ -926,8 +926,9 @@ T1General<{1,0,1,?,?}> { // A8.6.35 bits<3> Rn; + bits<8> imm8; let Inst{10-8} = Rn; - let Inst{7-0} = 0x00; + let Inst{7-0} = imm8; } // CMP register From stoklund at 2pi.dk Tue Dec 7 12:05:44 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 7 Dec 2010 10:05:44 -0800 Subject: [llvm-commits] [llvm] r121149 - in /llvm/trunk: include/llvm/Support/PathV2.h lib/Support/PathV2.cpp lib/Support/Unix/PathV2.inc lib/Support/Windows/PathV2.inc unittests/Support/Path.cpp In-Reply-To: <20101207170404.92B6C2A6C12C@llvm.org> References: <20101207170404.92B6C2A6C12C@llvm.org> Message-ID: On Dec 7, 2010, at 9:04 AM, Michael J. Spencer wrote: > +const bool has_root_directory(const Twine &path); llvm/include/llvm/Support/PathV2.h:267:1: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers] const bool has_root_name(const Twine &path); ^~~~~ From bigcheesegs at gmail.com Tue Dec 7 12:11:38 2010 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Tue, 07 Dec 2010 18:11:38 -0000 Subject: [llvm-commits] [llvm] r121155 - /llvm/trunk/include/llvm/Support/DynamicLinker.h Message-ID: <20101207181138.F40B52A6C12C@llvm.org> Author: mspencer Date: Tue Dec 7 12:11:38 2010 New Revision: 121155 URL: http://llvm.org/viewvc/llvm-project?rev=121155&view=rev Log: Support: Remove DynamicLinker.h. It is unused and unimplemented. Removed: llvm/trunk/include/llvm/Support/DynamicLinker.h Removed: llvm/trunk/include/llvm/Support/DynamicLinker.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/DynamicLinker.h?rev=121154&view=auto ============================================================================== --- llvm/trunk/include/llvm/Support/DynamicLinker.h (original) +++ llvm/trunk/include/llvm/Support/DynamicLinker.h (removed) @@ -1,40 +0,0 @@ -//===-- llvm/Support/DynamicLinker.h - Portable Dynamic Linker --*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Lightweight interface to dynamic library linking and loading, and dynamic -// symbol lookup functionality, in whatever form the operating system -// provides it. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_DYNAMICLINKER_H -#define LLVM_SUPPORT_DYNAMICLINKER_H - -#include - -namespace llvm { - -/// LinkDynamicObject - Load the named file as a dynamic library -/// and link it with the currently running process. Returns false -/// on success, true if there is an error (and sets ErrorMessage -/// if it is not NULL). Analogous to dlopen(). -/// -bool LinkDynamicObject (const char *filename, std::string *ErrorMessage); - -/// GetAddressOfSymbol - Returns the address of the named symbol in -/// the currently running process, as reported by the dynamic linker, -/// or NULL if the symbol does not exist or some other error has -/// occurred. -/// -void *GetAddressOfSymbol (const char *symbolName); -void *GetAddressOfSymbol (const std::string &symbolName); - -} // End llvm namespace - -#endif // SUPPORT_DYNAMICLINKER_H From bigcheesegs at gmail.com Tue Dec 7 12:11:54 2010 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Tue, 07 Dec 2010 18:11:54 -0000 Subject: [llvm-commits] [llvm] r121156 - /llvm/trunk/include/llvm/Support/AlignOf.h Message-ID: <20101207181154.84D562A6C12D@llvm.org> Author: mspencer Date: Tue Dec 7 12:11:54 2010 New Revision: 121156 URL: http://llvm.org/viewvc/llvm-project?rev=121156&view=rev Log: Fix spelling. Modified: llvm/trunk/include/llvm/Support/AlignOf.h Modified: llvm/trunk/include/llvm/Support/AlignOf.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/AlignOf.h?rev=121156&r1=121155&r2=121156&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/AlignOf.h (original) +++ llvm/trunk/include/llvm/Support/AlignOf.h Tue Dec 7 12:11:54 2010 @@ -49,7 +49,7 @@ }; -/// alignOf - A templated function that returns the mininum alignment of +/// alignOf - A templated function that returns the minimum alignment of /// of a type. This provides no extra functionality beyond the AlignOf /// class besides some cosmetic cleanliness. Example usage: /// alignOf() returns the alignment of an int. From bigcheesegs at gmail.com Tue Dec 7 12:12:07 2010 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Tue, 07 Dec 2010 18:12:07 -0000 Subject: [llvm-commits] [llvm] r121157 - in /llvm/trunk: include/llvm/Support/PathV2.h lib/Support/PathV2.cpp Message-ID: <20101207181207.623A62A6C12C@llvm.org> Author: mspencer Date: Tue Dec 7 12:12:07 2010 New Revision: 121157 URL: http://llvm.org/viewvc/llvm-project?rev=121157&view=rev Log: Support/PathV2: Remove const from bool return types. Modified: llvm/trunk/include/llvm/Support/PathV2.h llvm/trunk/lib/Support/PathV2.cpp Modified: llvm/trunk/include/llvm/Support/PathV2.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PathV2.h?rev=121157&r1=121156&r2=121157&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/PathV2.h (original) +++ llvm/trunk/include/llvm/Support/PathV2.h Tue Dec 7 12:12:07 2010 @@ -264,7 +264,7 @@ /// /// @param path Input path. /// @result True if the path has a root name, false otherwise. -const bool has_root_name(const Twine &path); +bool has_root_name(const Twine &path); /// @brief Has root directory? /// @@ -272,7 +272,7 @@ /// /// @param path Input path. /// @result True if the path has a root directory, false otherwise. -const bool has_root_directory(const Twine &path); +bool has_root_directory(const Twine &path); /// @brief Has root path? /// @@ -280,7 +280,7 @@ /// /// @param path Input path. /// @result True if the path has a root path, false otherwise. -const bool has_root_path(const Twine &path); +bool has_root_path(const Twine &path); /// @brief Has relative path? /// @@ -288,7 +288,7 @@ /// /// @param path Input path. /// @result True if the path has a relative path, false otherwise. -const bool has_relative_path(const Twine &path); +bool has_relative_path(const Twine &path); /// @brief Has parent path? /// @@ -296,7 +296,7 @@ /// /// @param path Input path. /// @result True if the path has a parent path, false otherwise. -const bool has_parent_path(const Twine &path); +bool has_parent_path(const Twine &path); /// @brief Has filename? /// @@ -304,7 +304,7 @@ /// /// @param path Input path. /// @result True if the path has a filename, false otherwise. -const bool has_filename(const Twine &path); +bool has_filename(const Twine &path); /// @brief Has stem? /// @@ -312,7 +312,7 @@ /// /// @param path Input path. /// @result True if the path has a stem, false otherwise. -const bool has_stem(const Twine &path); +bool has_stem(const Twine &path); /// @brief Has extension? /// @@ -320,19 +320,19 @@ /// /// @param path Input path. /// @result True if the path has a extension, false otherwise. -const bool has_extension(const Twine &path); +bool has_extension(const Twine &path); /// @brief Is path absolute? /// /// @param path Input path. /// @result True if the path is absolute, false if it is not. -const bool is_absolute(const Twine &path); +bool is_absolute(const Twine &path); /// @brief Is path relative? /// /// @param path Input path. /// @result True if the path is relative, false if it is not. -const bool is_relative(const Twine &path); +bool is_relative(const Twine &path); } // end namespace path } // end namespace sys Modified: llvm/trunk/lib/Support/PathV2.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/PathV2.cpp?rev=121157&r1=121156&r2=121157&view=diff ============================================================================== --- llvm/trunk/lib/Support/PathV2.cpp (original) +++ llvm/trunk/lib/Support/PathV2.cpp Tue Dec 7 12:12:07 2010 @@ -491,56 +491,56 @@ return StringRef(fname.begin() + pos, fname.size() - pos); } -const bool has_root_name(const Twine &path) { +bool has_root_name(const Twine &path) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); return !root_name(p).empty(); } -const bool has_root_directory(const Twine &path) { +bool has_root_directory(const Twine &path) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); return !root_directory(p).empty(); } -const bool has_root_path(const Twine &path) { +bool has_root_path(const Twine &path) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); return !root_path(p).empty(); } -const bool has_filename(const Twine &path) { +bool has_filename(const Twine &path) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); return !filename(p).empty(); } -const bool has_parent_path(const Twine &path) { +bool has_parent_path(const Twine &path) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); return !parent_path(p).empty(); } -const bool has_stem(const Twine &path) { +bool has_stem(const Twine &path) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); return !stem(p).empty(); } -const bool has_extension(const Twine &path) { +bool has_extension(const Twine &path) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); return !extension(p).empty(); } -const bool is_absolute(const Twine &path) { +bool is_absolute(const Twine &path) { SmallString<128> path_storage; StringRef p = path.toStringRef(path_storage); @@ -554,7 +554,7 @@ return rootDir && rootName; } -const bool is_relative(const Twine &path) { +bool is_relative(const Twine &path) { return !is_absolute(path); } From clattner at apple.com Tue Dec 7 12:19:09 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 7 Dec 2010 10:19:09 -0800 Subject: [llvm-commits] [PATCH] Remove Support/Alarm. In-Reply-To: References: Message-ID: <15815C88-5DBA-4E35-B0E1-43BABF8AE1A4@apple.com> On Dec 7, 2010, at 9:46 AM, Michael Spencer wrote: > The attached patch removes Support/Alarm because it is unused. This > was determined by a local grep over LLVM+Clang, and a Google Code > search. Sounds great, please do! From bigcheesegs at gmail.com Tue Dec 7 12:42:00 2010 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Tue, 07 Dec 2010 18:42:00 -0000 Subject: [llvm-commits] [llvm] r121160 - in /llvm/trunk: include/llvm/Support/Alarm.h lib/Support/Alarm.cpp lib/Support/CMakeLists.txt lib/Support/Unix/Alarm.inc lib/Support/Windows/Alarm.inc Message-ID: <20101207184200.2ABC22A6C12C@llvm.org> Author: mspencer Date: Tue Dec 7 12:41:59 2010 New Revision: 121160 URL: http://llvm.org/viewvc/llvm-project?rev=121160&view=rev Log: Support: Remove Alarm. It is unused (via local grep and google code search). Removed: llvm/trunk/include/llvm/Support/Alarm.h llvm/trunk/lib/Support/Alarm.cpp llvm/trunk/lib/Support/Unix/Alarm.inc llvm/trunk/lib/Support/Windows/Alarm.inc Modified: llvm/trunk/lib/Support/CMakeLists.txt Removed: llvm/trunk/include/llvm/Support/Alarm.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Alarm.h?rev=121159&view=auto ============================================================================== --- llvm/trunk/include/llvm/Support/Alarm.h (original) +++ llvm/trunk/include/llvm/Support/Alarm.h (removed) @@ -1,51 +0,0 @@ -//===- llvm/Support/Alarm.h - Alarm Generation support ----------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file provides an operating system independent interface to alarm(2) -// type functionality. The Alarm class allows a one-shot alarm to be set up -// at some number of seconds in the future. When the alarm triggers, a method -// is called to process the event -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SYSTEM_ALARM_H -#define LLVM_SYSTEM_ALARM_H - -namespace llvm { -namespace sys { - - /// This function registers an alarm to trigger some number of \p seconds in - /// the future. When that time arrives, the AlarmStatus function will begin - /// to return 1 instead of 0. The user must poll the status of the alarm by - /// making occasional calls to AlarmStatus. If the user sends an interrupt - /// signal, AlarmStatus will begin returning -1, even if the alarm event - /// occurred. - /// @returns nothing - void SetupAlarm( - unsigned seconds ///< Number of seconds in future when alarm arrives - ); - - /// This function terminates the alarm previously set up - /// @returns nothing - void TerminateAlarm(); - - /// This function acquires the status of the alarm. - /// @returns -1=cancelled, 0=untriggered, 1=triggered - int AlarmStatus(); - - /// Sleep for n seconds. Warning: mixing calls to Sleep() and other *Alarm - /// calls may be a bad idea on some platforms (source: Linux man page). - /// @returns nothing. - void Sleep(unsigned n); - - -} // End sys namespace -} // End llvm namespace - -#endif Removed: llvm/trunk/lib/Support/Alarm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Alarm.cpp?rev=121159&view=auto ============================================================================== --- llvm/trunk/lib/Support/Alarm.cpp (original) +++ llvm/trunk/lib/Support/Alarm.cpp (removed) @@ -1,33 +0,0 @@ -//===- Alarm.cpp - Alarm Generation Support ---------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements the Alarm functionality -// -//===----------------------------------------------------------------------===// - -#include "llvm/Support/Alarm.h" -#include "llvm/Config/config.h" - -namespace llvm { -using namespace sys; - -//===----------------------------------------------------------------------===// -//=== WARNING: Implementation here must contain only TRULY operating system -//=== independent code. -//===----------------------------------------------------------------------===// - -} - -// Include the platform-specific parts of this class. -#ifdef LLVM_ON_UNIX -#include "Unix/Alarm.inc" -#endif -#ifdef LLVM_ON_WIN32 -#include "Windows/Alarm.inc" -#endif Modified: llvm/trunk/lib/Support/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CMakeLists.txt?rev=121160&r1=121159&r2=121160&view=diff ============================================================================== --- llvm/trunk/lib/Support/CMakeLists.txt (original) +++ llvm/trunk/lib/Support/CMakeLists.txt Tue Dec 7 12:41:59 2010 @@ -54,7 +54,6 @@ regstrlcpy.c # System - Alarm.cpp Atomic.cpp Disassembler.cpp DynamicLibrary.cpp @@ -75,7 +74,6 @@ Threading.cpp TimeValue.cpp Valgrind.cpp - Unix/Alarm.inc Unix/Host.inc Unix/Memory.inc Unix/Mutex.inc @@ -88,7 +86,6 @@ Unix/system_error.inc Unix/ThreadLocal.inc Unix/TimeValue.inc - Windows/Alarm.inc Windows/DynamicLibrary.inc Windows/Host.inc Windows/Memory.inc Removed: llvm/trunk/lib/Support/Unix/Alarm.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Alarm.inc?rev=121159&view=auto ============================================================================== --- llvm/trunk/lib/Support/Unix/Alarm.inc (original) +++ llvm/trunk/lib/Support/Unix/Alarm.inc (removed) @@ -1,72 +0,0 @@ -//===-- Alarm.inc - Implement Unix Alarm Support ----------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements the UNIX Alarm support. -// -//===----------------------------------------------------------------------===// - -#include -#include -#include -using namespace llvm; - -/// AlarmCancelled - This flag is set by the SIGINT signal handler if the -/// user presses CTRL-C. -static volatile bool AlarmCancelled = false; - -/// AlarmTriggered - This flag is set by the SIGALRM signal handler if the -/// alarm was triggered. -static volatile bool AlarmTriggered = false; - -/// NestedSOI - Sanity check. Alarms cannot be nested or run in parallel. -/// This ensures that they never do. -static bool NestedSOI = false; - -static RETSIGTYPE SigIntHandler(int Sig) { - AlarmCancelled = true; - signal(SIGINT, SigIntHandler); -} - -static RETSIGTYPE SigAlarmHandler(int Sig) { - AlarmTriggered = true; -} - -static void (*OldSigIntHandler) (int); - -void sys::SetupAlarm(unsigned seconds) { - assert(!NestedSOI && "sys::SetupAlarm calls cannot be nested!"); - NestedSOI = true; - AlarmCancelled = false; - AlarmTriggered = false; - ::signal(SIGALRM, SigAlarmHandler); - OldSigIntHandler = ::signal(SIGINT, SigIntHandler); - ::alarm(seconds); -} - -void sys::TerminateAlarm() { - assert(NestedSOI && "sys::TerminateAlarm called without sys::SetupAlarm!"); - ::alarm(0); - ::signal(SIGALRM, SIG_DFL); - ::signal(SIGINT, OldSigIntHandler); - AlarmCancelled = false; - AlarmTriggered = false; - NestedSOI = false; -} - -int sys::AlarmStatus() { - if (AlarmCancelled) - return -1; - if (AlarmTriggered) - return 1; - return 0; -} - -void sys::Sleep(unsigned n) { - ::sleep(n); -} Removed: llvm/trunk/lib/Support/Windows/Alarm.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Alarm.inc?rev=121159&view=auto ============================================================================== --- llvm/trunk/lib/Support/Windows/Alarm.inc (original) +++ llvm/trunk/lib/Support/Windows/Alarm.inc (removed) @@ -1,43 +0,0 @@ -//===-- Alarm.inc - Implement Win32 Alarm Support ---------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements the Win32 Alarm support. -// -//===----------------------------------------------------------------------===// - -#include -using namespace llvm; - -/// NestedSOI - Sanity check. Alarms cannot be nested or run in parallel. -/// This ensures that they never do. -static bool NestedSOI = false; - -void sys::SetupAlarm(unsigned seconds) { - assert(!NestedSOI && "sys::SetupAlarm calls cannot be nested!"); - NestedSOI = true; - // FIXME: Implement for Win32 -} - -void sys::TerminateAlarm() { - assert(NestedSOI && "sys::TerminateAlarm called without sys::SetupAlarm!"); - // FIXME: Implement for Win32 - NestedSOI = false; -} - -int sys::AlarmStatus() { - // FIXME: Implement for Win32 - return 0; -} - -// Don't pull in all of the Windows headers. -extern "C" void __stdcall Sleep(unsigned long); - -void sys::Sleep(unsigned n) { - ::Sleep(n*1000); -} From bigcheesegs at gmail.com Tue Dec 7 12:50:33 2010 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Tue, 07 Dec 2010 18:50:33 -0000 Subject: [llvm-commits] [llvm] r121161 - /llvm/trunk/include/llvm/LinkAllVMCore.h Message-ID: <20101207185033.6A3D42A6C12C@llvm.org> Author: mspencer Date: Tue Dec 7 12:50:33 2010 New Revision: 121161 URL: http://llvm.org/viewvc/llvm-project?rev=121161&view=rev Log: Missed a spot removing Alarm. Modified: llvm/trunk/include/llvm/LinkAllVMCore.h Modified: llvm/trunk/include/llvm/LinkAllVMCore.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LinkAllVMCore.h?rev=121161&r1=121160&r2=121161&view=diff ============================================================================== --- llvm/trunk/include/llvm/LinkAllVMCore.h (original) +++ llvm/trunk/include/llvm/LinkAllVMCore.h Tue Dec 7 12:50:33 2010 @@ -22,7 +22,6 @@ #include "llvm/IntrinsicInst.h" #include "llvm/InlineAsm.h" #include "llvm/Analysis/Verifier.h" -#include "llvm/Support/Alarm.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/Memory.h" #include "llvm/Support/Mutex.h" From stoklund at 2pi.dk Tue Dec 7 12:51:27 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 07 Dec 2010 18:51:27 -0000 Subject: [llvm-commits] [llvm] r121162 - /llvm/trunk/lib/CodeGen/RegAllocBasic.cpp Message-ID: <20101207185127.DA6C42A6C12C@llvm.org> Author: stoklund Date: Tue Dec 7 12:51:27 2010 New Revision: 121162 URL: http://llvm.org/viewvc/llvm-project?rev=121162&view=rev Log: Simplify assertion. Modified: llvm/trunk/lib/CodeGen/RegAllocBasic.cpp Modified: llvm/trunk/lib/CodeGen/RegAllocBasic.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocBasic.cpp?rev=121162&r1=121161&r2=121162&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocBasic.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocBasic.cpp Tue Dec 7 12:51:27 2010 @@ -443,15 +443,8 @@ if (!spillInterferences(VirtReg, *PhysRegI, SplitVRegs)) continue; - unsigned InterferingReg = checkPhysRegInterference(VirtReg, *PhysRegI); - if (InterferingReg != 0) { - const LiveSegment &seg = - *Queries[InterferingReg].firstInterference().liveUnionPos(); - - dbgs() << "spilling cannot free " << TRI->getName(*PhysRegI) << - " for " << VirtReg.reg << " with interference " << *seg.VirtReg << "\n"; - llvm_unreachable("Interference after spill."); - } + assert(checkPhysRegInterference(VirtReg, *PhysRegI) == 0 && + "Interference after spill."); // Tell the caller to allocate to this newly freed physical register. return *PhysRegI; } From bruno.cardoso at gmail.com Tue Dec 7 13:00:20 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Tue, 07 Dec 2010 19:00:20 -0000 Subject: [llvm-commits] [llvm] r121163 - in /llvm/trunk: lib/Target/Mips/MipsAsmPrinter.cpp lib/Target/Mips/MipsInstrInfo.td test/CodeGen/Mips/cmov.ll Message-ID: <20101207190020.872502A6C12C@llvm.org> Author: bruno Date: Tue Dec 7 13:00:20 2010 New Revision: 121163 URL: http://llvm.org/viewvc/llvm-project?rev=121163&view=rev Log: Match a pattern generated by a dag combiner opt where: (select (load (load tga0)) (load tga1)) => (load (select (load tga0) tga1)) Thanks to Akira for pointing that. Added: llvm/trunk/test/CodeGen/Mips/cmov.ll (with props) Modified: llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp llvm/trunk/lib/Target/Mips/MipsInstrInfo.td Modified: llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp?rev=121163&r1=121162&r2=121163&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp Tue Dec 7 13:00:20 2010 @@ -271,12 +271,16 @@ switch(MO.getTargetFlags()) { case MipsII::MO_GPREL: O << "%gp_rel("; break; case MipsII::MO_GOT_CALL: O << "%call16("; break; - case MipsII::MO_GOT: - if (MI->getOpcode() == Mips::LW) + case MipsII::MO_GOT: { + const MachineOperand &LastMO = MI->getOperand(opNum-1); + bool LastMOIsGP = LastMO.getType() == MachineOperand::MO_Register + && LastMO.getReg() == Mips::GP; + if (MI->getOpcode() == Mips::LW || LastMOIsGP) O << "%got("; else O << "%lo("; break; + } case MipsII::MO_ABS_HILO: if (MI->getOpcode() == Mips::LUi) O << "%hi("; Modified: llvm/trunk/lib/Target/Mips/MipsInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrInfo.td?rev=121163&r1=121162&r2=121163&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsInstrInfo.td (original) +++ llvm/trunk/lib/Target/Mips/MipsInstrInfo.td Tue Dec 7 13:00:20 2010 @@ -597,6 +597,12 @@ def : Pat<(select CPURegs:$cond, CPURegs:$T, CPURegs:$F), (MOVN CPURegs:$F, CPURegs:$T, CPURegs:$cond)>; +// select patterns with got access +def : Pat<(select (setne CPURegs:$lhs, CPURegs:$rhs), + (i32 tglobaladdr:$T), CPURegs:$F), + (MOVN CPURegs:$F, (ADDiu GP, tglobaladdr:$T), + (XOR CPURegs:$lhs, CPURegs:$rhs))>; + // setcc patterns def : Pat<(seteq CPURegs:$lhs, CPURegs:$rhs), (SLTu (XOR CPURegs:$lhs, CPURegs:$rhs), 1)>; Added: llvm/trunk/test/CodeGen/Mips/cmov.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/cmov.ll?rev=121163&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Mips/cmov.ll (added) +++ llvm/trunk/test/CodeGen/Mips/cmov.ll Tue Dec 7 13:00:20 2010 @@ -0,0 +1,15 @@ +; RUN: llc -march=mips -mcpu=4ke < %s | FileCheck %s + + at i1 = global [3 x i32] [i32 1, i32 2, i32 3], align 4 + at i3 = common global i32* null, align 4 + +; CHECK: lw $3, %got(i3)($gp) +; CHECK: addiu $5, $gp, %got(i1) +define i32* @cmov1(i32 %s) nounwind readonly { +entry: + %tobool = icmp ne i32 %s, 0 + %tmp1 = load i32** @i3, align 4 + %cond = select i1 %tobool, i32* getelementptr inbounds ([3 x i32]* @i1, i32 0, i32 0), i32* %tmp1 + ret i32* %cond +} + Propchange: llvm/trunk/test/CodeGen/Mips/cmov.ll ------------------------------------------------------------------------------ svn:executable = * From bruno.cardoso at gmail.com Tue Dec 7 13:04:14 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Tue, 07 Dec 2010 19:04:14 -0000 Subject: [llvm-commits] [llvm] r121164 - in /llvm/trunk/lib/Target/Mips: MipsISelLowering.cpp MipsISelLowering.h MipsInstrInfo.td Message-ID: <20101207190414.65FC62A6C12C@llvm.org> Author: bruno Date: Tue Dec 7 13:04:14 2010 New Revision: 121164 URL: http://llvm.org/viewvc/llvm-project?rev=121164&view=rev Log: Remove target specific node MipsISD::CMov, which is not used because all conditional moves are directly matched using tablegen patterns. If there's a need in the future, we can introduce it again Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp llvm/trunk/lib/Target/Mips/MipsISelLowering.h llvm/trunk/lib/Target/Mips/MipsInstrInfo.td Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp?rev=121164&r1=121163&r2=121164&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp Tue Dec 7 13:04:14 2010 @@ -41,7 +41,6 @@ case MipsISD::Lo : return "MipsISD::Lo"; case MipsISD::GPRel : return "MipsISD::GPRel"; case MipsISD::Ret : return "MipsISD::Ret"; - case MipsISD::CMov : return "MipsISD::CMov"; case MipsISD::SelectCC : return "MipsISD::SelectCC"; case MipsISD::FPSelectCC : return "MipsISD::FPSelectCC"; case MipsISD::FPBrcond : return "MipsISD::FPBrcond"; Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelLowering.h?rev=121164&r1=121163&r2=121164&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsISelLowering.h (original) +++ llvm/trunk/lib/Target/Mips/MipsISelLowering.h Tue Dec 7 13:04:14 2010 @@ -40,9 +40,6 @@ // Handle gp_rel (small data/bss sections) relocation. GPRel, - // Conditional Move - CMov, - // Select CC Pseudo Instruction SelectCC, Modified: llvm/trunk/lib/Target/Mips/MipsInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrInfo.td?rev=121164&r1=121163&r2=121164&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsInstrInfo.td (original) +++ llvm/trunk/lib/Target/Mips/MipsInstrInfo.td Tue Dec 7 13:04:14 2010 @@ -52,9 +52,6 @@ // Select Condition Code def MipsSelectCC : SDNode<"MipsISD::SelectCC", SDT_MipsSelectCC>; -// Conditional Move -def MipsCMov : SDNode<"MipsISD::CMov", SDT_MipsCMov>; - //===----------------------------------------------------------------------===// // Mips Instruction Predicate Definitions. //===----------------------------------------------------------------------===// @@ -306,8 +303,7 @@ class CondMov func, string instr_asm, PatLeaf MovCode>: FR<0x00, func, (outs CPURegs:$dst), (ins CPURegs:$F, CPURegs:$T, CPURegs:$cond), !strconcat(instr_asm, "\t$dst, $T, $cond"), - [(set CPURegs:$dst, (MipsCMov CPURegs:$F, CPURegs:$T, - CPURegs:$cond, MovCode))], NoItinerary>; + [], NoItinerary>; //===----------------------------------------------------------------------===// // Pseudo instructions From grosbach at apple.com Tue Dec 7 13:35:36 2010 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 07 Dec 2010 19:35:36 -0000 Subject: [llvm-commits] [llvm] r121166 - /llvm/trunk/utils/TableGen/FastISelEmitter.cpp Message-ID: <20101207193536.8CE9E2A6C12C@llvm.org> Author: grosbach Date: Tue Dec 7 13:35:36 2010 New Revision: 121166 URL: http://llvm.org/viewvc/llvm-project?rev=121166&view=rev Log: Change assert to diagnostic. Message still needs work, but it's better than an assert, at least. Modified: llvm/trunk/utils/TableGen/FastISelEmitter.cpp Modified: llvm/trunk/utils/TableGen/FastISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.cpp?rev=121166&r1=121165&r2=121166&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/FastISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/FastISelEmitter.cpp Tue Dec 7 13:35:36 2010 @@ -20,6 +20,7 @@ #include "FastISelEmitter.h" #include "Record.h" #include "llvm/Support/Debug.h" +#include "llvm/ADT/SmallString.h" #include "llvm/ADT/VectorExtras.h" using namespace llvm; @@ -380,9 +381,14 @@ SubRegNo, PhysRegInputs }; - assert(!SimplePatterns[Operands][OpcodeName][VT][RetVT] - .count(PredicateCheck) && - "Duplicate pattern!"); + // FIXME: Source location information for the diagnostic. + if (SimplePatterns[Operands][OpcodeName][VT][RetVT] + .count(PredicateCheck)) { + SmallString<128> PatText; + raw_svector_ostream OS(PatText); + Pattern.SrcPattern->print(OS); + throw "Duplicate record: " + OS.str().str(); + } SimplePatterns[Operands][OpcodeName][VT][RetVT][PredicateCheck] = Memo; } } From grosbach at apple.com Tue Dec 7 13:36:07 2010 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 07 Dec 2010 19:36:07 -0000 Subject: [llvm-commits] [llvm] r121167 - /llvm/trunk/utils/TableGen/FastISelEmitter.cpp Message-ID: <20101207193607.5D2832A6C12C@llvm.org> Author: grosbach Date: Tue Dec 7 13:36:07 2010 New Revision: 121167 URL: http://llvm.org/viewvc/llvm-project?rev=121167&view=rev Log: Trailing whitespace. Modified: llvm/trunk/utils/TableGen/FastISelEmitter.cpp Modified: llvm/trunk/utils/TableGen/FastISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.cpp?rev=121167&r1=121166&r2=121167&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/FastISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/FastISelEmitter.cpp Tue Dec 7 13:36:07 2010 @@ -66,23 +66,23 @@ return true; } } - + const CodeGenRegisterClass *DstRC = 0; - + for (unsigned i = 0, e = InstPatNode->getNumChildren(); i != e; ++i) { TreePatternNode *Op = InstPatNode->getChild(i); - + // For now, filter out any operand with a predicate. // For now, filter out any operand with multiple values. if (!Op->getPredicateFns().empty() || Op->getNumTypes() != 1) return false; - + assert(Op->hasTypeSet(0) && "Type infererence not done?"); // For now, all the operands must have the same type. if (Op->getType(0) != VT) return false; - + if (!Op->isLeaf()) { if (Op->getOperator()->getName() == "imm") { Operands.push_back("i"); @@ -108,7 +108,7 @@ RC = Target.getRegisterClassForRegister(OpLeafRec); else return false; - + // For now, this needs to be a register class of some sort. if (!RC) return false; @@ -213,7 +213,7 @@ typedef std::map RetPredMap; typedef std::map TypeRetPredMap; typedef std::map OpcodeTypeRetPredMap; - typedef std::map + typedef std::map OperandsOpcodeTypeRetPredMap; OperandsOpcodeTypeRetPredMap SimplePatterns; @@ -266,7 +266,7 @@ CodeGenInstruction &II = CGP.getTargetInfo().getInstruction(Op); if (II.Operands.size() == 0) continue; - + // For now, ignore multi-instruction patterns. bool MultiInsts = false; for (unsigned i = 0, e = Dst->getNumChildren(); i != e; ++i) { @@ -296,7 +296,7 @@ // If this isn't a leaf, then continue since the register classes are // a bit too complicated for now. if (!Dst->getChild(1)->isLeaf()) continue; - + DefInit *SR = dynamic_cast(Dst->getChild(1)->getLeafValue()); if (SR) SubRegNo = getQualifiedName(SR->getDef()); @@ -311,7 +311,7 @@ // Ignore multiple result nodes for now. if (InstPatNode->getNumTypes() > 1) continue; - + Record *InstPatOp = InstPatNode->getOperator(); std::string OpcodeName = getOpcodeName(InstPatOp, CGP); MVT::SimpleValueType RetVT = MVT::isVoid; @@ -335,7 +335,7 @@ OperandsSignature Operands; if (!Operands.initialize(InstPatNode, Target, VT)) continue; - + std::vector* PhysRegInputs = new std::vector(); if (!InstPatNode->isLeaf() && (InstPatNode->getOperator()->getName() == "imm" || @@ -348,7 +348,7 @@ PhysRegInputs->push_back(""); continue; } - + DefInit *OpDI = dynamic_cast(Op->getLeafValue()); Record *OpLeafRec = OpDI->getDef(); std::string PhysReg; @@ -356,7 +356,7 @@ PhysReg += static_cast(OpLeafRec->getValue( \ "Namespace")->getValue())->getValue(); PhysReg += "::"; - + std::vector Regs = Target.getRegisters(); for (unsigned i = 0; i < Regs.size(); ++i) { if (Regs[i].TheDef == OpLeafRec) { @@ -365,7 +365,7 @@ } } } - + PhysRegInputs->push_back(PhysReg); } } else @@ -435,7 +435,7 @@ PI != PE; ++PI) { std::string PredicateCheck = PI->first; const InstructionMemo &Memo = PI->second; - + if (PredicateCheck.empty()) { assert(!HasPred && "Multiple instructions match, at least one has " @@ -445,14 +445,14 @@ OS << " "; HasPred = true; } - + for (unsigned i = 0; i < Memo.PhysRegs->size(); ++i) { if ((*Memo.PhysRegs)[i] != "") OS << " BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, " << "TII.get(TargetOpcode::COPY), " << (*Memo.PhysRegs)[i] << ").addReg(Op" << i << ");\n"; } - + OS << " return FastEmitInst_"; if (Memo.SubRegNo.empty()) { Operands.PrintManglingSuffix(OS, *Memo.PhysRegs); @@ -468,10 +468,10 @@ OS << Memo.SubRegNo; OS << ");\n"; } - + if (HasPred) OS << " }\n"; - + } // Return 0 if none of the predicates were satisfied. if (HasPred) @@ -479,7 +479,7 @@ OS << "}\n"; OS << "\n"; } - + // Emit one function for the type that demultiplexes on return type. OS << "unsigned FastEmit_" << getLegalCName(Opcode) << "_" @@ -502,7 +502,7 @@ OS << ");\n"; } OS << " default: return 0;\n}\n}\n\n"; - + } else { // Non-variadic return type. OS << "unsigned FastEmit_" @@ -514,13 +514,13 @@ OS << ", "; Operands.PrintParameters(OS); OS << ") {\n"; - + OS << " if (RetVT.SimpleTy != " << getName(RM.begin()->first) << ")\n return 0;\n"; - + const PredMap &PM = RM.begin()->second; bool HasPred = false; - + // Emit code for each possible instruction. There may be // multiple if there are subtarget concerns. for (PredMap::const_iterator PI = PM.begin(), PE = PM.end(); PI != PE; @@ -537,16 +537,16 @@ OS << " "; HasPred = true; } - + for (unsigned i = 0; i < Memo.PhysRegs->size(); ++i) { if ((*Memo.PhysRegs)[i] != "") OS << " BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, " << "TII.get(TargetOpcode::COPY), " << (*Memo.PhysRegs)[i] << ").addReg(Op" << i << ");\n"; } - + OS << " return FastEmitInst_"; - + if (Memo.SubRegNo.empty()) { Operands.PrintManglingSuffix(OS, *Memo.PhysRegs); OS << "(" << InstNS << Memo.Name << ", "; @@ -560,11 +560,11 @@ OS << Memo.SubRegNo; OS << ");\n"; } - + if (HasPred) OS << " }\n"; } - + // Return 0 if none of the predicates were satisfied. if (HasPred) OS << " return 0;\n"; From echristo at apple.com Tue Dec 7 13:53:29 2010 From: echristo at apple.com (Eric Christopher) Date: Tue, 7 Dec 2010 11:53:29 -0800 Subject: [llvm-commits] [llvm] r121166 - /llvm/trunk/utils/TableGen/FastISelEmitter.cpp In-Reply-To: <20101207193536.8CE9E2A6C12C@llvm.org> References: <20101207193536.8CE9E2A6C12C@llvm.org> Message-ID: <28CC36C7-644B-49E7-8F7C-FC6D6FAB4716@apple.com> On Dec 7, 2010, at 11:35 AM, Jim Grosbach wrote: > Author: grosbach > Date: Tue Dec 7 13:35:36 2010 > New Revision: 121166 > > URL: http://llvm.org/viewvc/llvm-project?rev=121166&view=rev > Log: > Change assert to diagnostic. Message still needs work, but it's better than > an assert, at least. > > }; > - assert(!SimplePatterns[Operands][OpcodeName][VT][RetVT] > - .count(PredicateCheck) && > - "Duplicate pattern!"); > + // FIXME: Source location information for the diagnostic. > + if (SimplePatterns[Operands][OpcodeName][VT][RetVT] > + .count(PredicateCheck)) { > + SmallString<128> PatText; > + raw_svector_ostream OS(PatText); > + Pattern.SrcPattern->print(OS); > + throw "Duplicate record: " + OS.str().str(); > + } > SimplePatterns[Operands][OpcodeName][VT][RetVT][PredicateCheck] = Memo; > } > } Hmm? What's going on here? -eric -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20101207/bd813bd1/attachment.html From gohman at apple.com Tue Dec 7 13:56:52 2010 From: gohman at apple.com (Dan Gohman) Date: Tue, 07 Dec 2010 19:56:52 -0000 Subject: [llvm-commits] [llvm] r121170 - /llvm/trunk/lib/VMCore/Function.cpp Message-ID: <20101207195652.197452A6C12C@llvm.org> Author: djg Date: Tue Dec 7 13:56:51 2010 New Revision: 121170 URL: http://llvm.org/viewvc/llvm-project?rev=121170&view=rev Log: Remove the code from Function::dropAllReferences which replaced uses of the function's blocks with undef. This code isn't needed, because BasicBlock's destructor handles such uses. Also, undef isn't correct, since blockaddresses may still be used for comparisons with null. Modified: llvm/trunk/lib/VMCore/Function.cpp Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=121170&r1=121169&r2=121170&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Tue Dec 7 13:56:51 2010 @@ -227,19 +227,10 @@ for (iterator I = begin(), E = end(); I != E; ++I) I->dropAllReferences(); - // Delete all basic blocks. - while (!BasicBlocks.empty()) { - // If there is still a reference to the block, it must be a 'blockaddress' - // constant pointing to it. Just replace the BlockAddress with undef. - BasicBlock *BB = BasicBlocks.begin(); - if (!BB->use_empty()) { - BlockAddress *BA = cast(BB->use_back()); - BA->replaceAllUsesWith(UndefValue::get(BA->getType())); - BA->destroyConstant(); - } - - BB->eraseFromParent(); - } + // Delete all basic blocks. They are now unused, except possibly by + // blockaddresses, but BasicBlock's destructor takes care of those. + while (!BasicBlocks.empty()) + BasicBlocks.begin()->eraseFromParent(); } void Function::addAttribute(unsigned i, Attributes attr) { From evan.cheng at apple.com Tue Dec 7 13:59:34 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 07 Dec 2010 19:59:34 -0000 Subject: [llvm-commits] [llvm] r121172 - /llvm/trunk/lib/Target/ARM/ARMFrameInfo.cpp Message-ID: <20101207195934.859562A6C12C@llvm.org> Author: evancheng Date: Tue Dec 7 13:59:34 2010 New Revision: 121172 URL: http://llvm.org/viewvc/llvm-project?rev=121172&view=rev Log: Code clean up; no functionality change. Modified: llvm/trunk/lib/Target/ARM/ARMFrameInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMFrameInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFrameInfo.cpp?rev=121172&r1=121171&r2=121172&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMFrameInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMFrameInfo.cpp Tue Dec 7 13:59:34 2010 @@ -508,11 +508,7 @@ DebugLoc DL; if (MI != MBB.end()) DL = MI->getDebugLoc(); - MachineInstrBuilder MIB = BuildMI(MF, DL, TII.get(Opc)); - MIB.addReg(ARM::SP, getDefRegState(true)); - MIB.addReg(ARM::SP); - AddDefaultPred(MIB); - bool NumRegs = false; + SmallVector, 4> Regs; for (unsigned i = CSI.size(); i != 0; --i) { unsigned Reg = CSI[i-1].getReg(); if (!(Func)(Reg, STI.isTargetDarwin())) continue; @@ -530,15 +526,16 @@ if (isKill) MBB.addLiveIn(Reg); - NumRegs = true; - MIB.addReg(Reg, getKillRegState(isKill)); + Regs.push_back(std::make_pair(Reg, isKill)); } // It's illegal to emit push instruction without operands. - if (NumRegs) - MBB.insert(MI, &*MIB); - else - MF.DeleteMachineInstr(MIB); + if (!Regs.empty()) { + MachineInstrBuilder MIB = AddDefaultPred(BuildMI(MBB, MI, DL, TII.get(Opc), + ARM::SP).addReg(ARM::SP)); + for (unsigned i = 0, e = Regs.size(); i < e; ++i) + MIB.addReg(Regs[i].first, getKillRegState(Regs[i].second)); + } } bool ARMFrameInfo::spillCalleeSavedRegisters(MachineBasicBlock &MBB, From bob.wilson at apple.com Tue Dec 7 14:02:45 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 07 Dec 2010 20:02:45 -0000 Subject: [llvm-commits] [llvm] r121173 - in /llvm/trunk/utils/TableGen: NeonEmitter.cpp NeonEmitter.h Message-ID: <20101207200245.556022A6C12C@llvm.org> Author: bwilson Date: Tue Dec 7 14:02:45 2010 New Revision: 121173 URL: http://llvm.org/viewvc/llvm-project?rev=121173&view=rev Log: Add new built-in operations for vmull and vmull_n so they can be implemented without requiring clang builtins. Radar 8446238. Modified: llvm/trunk/utils/TableGen/NeonEmitter.cpp llvm/trunk/utils/TableGen/NeonEmitter.h Modified: llvm/trunk/utils/TableGen/NeonEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.cpp?rev=121173&r1=121172&r2=121173&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/NeonEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/NeonEmitter.cpp Tue Dec 7 14:02:45 2010 @@ -508,6 +508,15 @@ return s; } +// Use the vmovl builtin to sign-extend or zero-extend a vector. +static std::string Extend(const std::string &proto, StringRef typestr, + const std::string &a) { + std::string s; + s = MangleName("vmovl", typestr, ClassS); + s += "(" + a + ")"; + return s; +} + static std::string Duplicate(unsigned nElts, StringRef typestr, const std::string &a) { std::string s; @@ -587,6 +596,15 @@ case OpMul: s += "__a * __b;"; break; + case OpMullN: + s += Extend(proto, typestr, "__a") + " * " + + Extend(proto, typestr, + Duplicate(nElts << (int)quad, typestr, "__b")) + ";"; + break; + case OpMull: + s += Extend(proto, typestr, "__a") + " * " + + Extend(proto, typestr, "__b") + ";"; + break; case OpMlaN: s += "__a + (__b * " + Duplicate(nElts, typestr, "__c") + ");"; break; Modified: llvm/trunk/utils/TableGen/NeonEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.h?rev=121173&r1=121172&r2=121173&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/NeonEmitter.h (original) +++ llvm/trunk/utils/TableGen/NeonEmitter.h Tue Dec 7 14:02:45 2010 @@ -26,9 +26,11 @@ OpAdd, OpSub, OpMul, + OpMull, OpMla, OpMls, OpMulN, + OpMullN, OpMlaN, OpMlsN, OpMulLane, @@ -79,9 +81,11 @@ OpMap["OP_ADD"] = OpAdd; OpMap["OP_SUB"] = OpSub; OpMap["OP_MUL"] = OpMul; + OpMap["OP_MULL"] = OpMull; OpMap["OP_MLA"] = OpMla; OpMap["OP_MLS"] = OpMls; OpMap["OP_MUL_N"] = OpMulN; + OpMap["OP_MULL_N"]= OpMullN; OpMap["OP_MLA_N"] = OpMlaN; OpMap["OP_MLS_N"] = OpMlsN; OpMap["OP_MUL_LN"]= OpMulLane; From evan.cheng at apple.com Tue Dec 7 14:11:46 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 07 Dec 2010 20:11:46 -0000 Subject: [llvm-commits] [llvm] r121176 - /llvm/trunk/lib/Target/ARM/ARMFrameInfo.cpp Message-ID: <20101207201146.76ACC2A6C12C@llvm.org> Author: evancheng Date: Tue Dec 7 14:11:46 2010 New Revision: 121176 URL: http://llvm.org/viewvc/llvm-project?rev=121176&view=rev Log: Code clean up; no functionality change. Modified: llvm/trunk/lib/Target/ARM/ARMFrameInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMFrameInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFrameInfo.cpp?rev=121176&r1=121175&r2=121176&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMFrameInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMFrameInfo.cpp Tue Dec 7 14:11:46 2010 @@ -529,7 +529,6 @@ Regs.push_back(std::make_pair(Reg, isKill)); } - // It's illegal to emit push instruction without operands. if (!Regs.empty()) { MachineInstrBuilder MIB = AddDefaultPred(BuildMI(MBB, MI, DL, TII.get(Opc), ARM::SP).addReg(ARM::SP)); @@ -568,31 +567,30 @@ ARMFunctionInfo *AFI = MF.getInfo(); DebugLoc DL = MI->getDebugLoc(); - MachineInstrBuilder MIB = BuildMI(MF, DL, TII.get(Opc)); - MIB.addReg(ARM::SP, getDefRegState(true)); - MIB.addReg(ARM::SP); - AddDefaultPred(MIB); - bool NumRegs = false; + bool DeleteRet = false; + SmallVector Regs; for (unsigned i = CSI.size(); i != 0; --i) { unsigned Reg = CSI[i-1].getReg(); if (!(Func)(Reg, STI.isTargetDarwin())) continue; if (Reg == ARM::LR && !isVarArg) { Reg = ARM::PC; - unsigned Opc = AFI->isThumbFunction() ? ARM::t2LDMIA_RET : ARM::LDMIA_RET; - (*MIB).setDesc(TII.get(Opc)); - MI = MBB.erase(MI); + Opc = AFI->isThumbFunction() ? ARM::t2LDMIA_RET : ARM::LDMIA_RET; + // Fold the return instruction into the LDM. + DeleteRet = true; } - MIB.addReg(Reg, RegState::Define); - NumRegs = true; + Regs.push_back(Reg); } - // It's illegal to emit pop instruction without operands. - if (NumRegs) - MBB.insert(MI, &*MIB); - else - MF.DeleteMachineInstr(MIB); + if (!Regs.empty()) { + MachineInstrBuilder MIB = AddDefaultPred(BuildMI(MBB, MI, DL, TII.get(Opc), + ARM::SP).addReg(ARM::SP)); + for (unsigned i = 0, e = Regs.size(); i < e; ++i) + MIB.addReg(Regs[i], getDefRegState(true)); + if (DeleteRet) + MI->eraseFromParent(); + } } bool ARMFrameInfo::restoreCalleeSavedRegisters(MachineBasicBlock &MBB, From aggarwa4 at illinois.edu Tue Dec 7 14:17:27 2010 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Tue, 07 Dec 2010 20:17:27 -0000 Subject: [llvm-commits] [poolalloc] r121177 - /poolalloc/trunk/lib/DSA/DataStructure.cpp Message-ID: <20101207201727.C533F2A6C12C@llvm.org> Author: aggarwa4 Date: Tue Dec 7 14:17:27 2010 New Revision: 121177 URL: http://llvm.org/viewvc/llvm-project?rev=121177&view=rev Log: Revert this change. We need to fully understand the cases this can arise in, and handle all of them before we allow this. Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=121177&r1=121176&r2=121177&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/DataStructure.cpp (original) +++ poolalloc/trunk/lib/DSA/DataStructure.cpp Tue Dec 7 14:17:27 2010 @@ -572,19 +572,10 @@ if (CurNodeH.getNode()->isArrayNode() && NH.getNode()->isArrayNode()) { if(NH.getNode()->getSize() != 0 && CurNodeH.getNode()->getSize() != 0 && (NH.getNode()->getSize() != CurNodeH.getNode()->getSize())){ - if(((NH.getNode()->getSize() % CurNodeH.getNode()->getSize()) != 0 ) - && ((CurNodeH.getNode()->getSize() % NH.getNode()->getSize()) != 0)){ CurNodeH.getNode()->foldNodeCompletely(); NH.getNode()->foldNodeCompletely(); NSize = NH.getNode()->getSize(); NOffset = NH.getOffset(); - } else { - if(NH.getNode()->getSize() > CurNodeH.getNode()->getSize()) { - NH.getNode()->mergeArrayTypeInfo(CurNodeH.getNode()); - } else { - CurNodeH.getNode()->mergeArrayTypeInfo(NH.getNode()); - } - } } } @@ -867,17 +858,8 @@ if (SN->isArrayNode() && DN->isArrayNode()) { if((SN->getSize() != DN->getSize()) && (SN->getSize() != 0) && DN->getSize() != 0) { - if(((SN->getSize() % DN->getSize()) != 0) && - ((DN->getSize() % SN->getSize()) != 0)){ DN->foldNodeCompletely(); DN = NH.getNode(); - } else { - if(DN->getSize() > SN->getSize()) { - DN->mergeArrayTypeInfo(SN); - } else { - SrcNH.getNode()->mergeArrayTypeInfo(NH.getNode()); - } - } } } if (!DN->isNodeCompletelyFolded() && DN->getSize() < SN->getSize()) From grosbach at apple.com Tue Dec 7 14:27:30 2010 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 7 Dec 2010 12:27:30 -0800 Subject: [llvm-commits] [llvm] r121166 - /llvm/trunk/utils/TableGen/FastISelEmitter.cpp In-Reply-To: <28CC36C7-644B-49E7-8F7C-FC6D6FAB4716@apple.com> References: <20101207193536.8CE9E2A6C12C@llvm.org> <28CC36C7-644B-49E7-8F7C-FC6D6FAB4716@apple.com> Message-ID: <42E5E1F3-0FAA-48AE-A68A-5A3A5538C183@apple.com> On Dec 7, 2010, at 11:53 AM, Eric Christopher wrote: > > On Dec 7, 2010, at 11:35 AM, Jim Grosbach wrote: > >> Author: grosbach >> Date: Tue Dec 7 13:35:36 2010 >> New Revision: 121166 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=121166&view=rev >> Log: >> Change assert to diagnostic. Message still needs work, but it's better than >> an assert, at least. >> >> }; >> - assert(!SimplePatterns[Operands][OpcodeName][VT][RetVT] >> - .count(PredicateCheck) && >> - "Duplicate pattern!"); >> + // FIXME: Source location information for the diagnostic. >> + if (SimplePatterns[Operands][OpcodeName][VT][RetVT] >> + .count(PredicateCheck)) { >> + SmallString<128> PatText; >> + raw_svector_ostream OS(PatText); >> + Pattern.SrcPattern->print(OS); >> + throw "Duplicate record: " + OS.str().str(); >> + } >> SimplePatterns[Operands][OpcodeName][VT][RetVT][PredicateCheck] = Memo; >> } >> } > > Hmm? What's going on here? If two tblgen records have the same pattern, they hit this. copy/paste errors or somesuch, usually. E.g., def Pat<(add GPR:$Rd, GPR:$Rn, GPR:$Rm) (ADD GPR:$Rd, GPR:$Rn, GPR:$Rm)>; def Pat<(add GPR:$Rd, GPR:$Rn, GPR:$Rm) (SUB GPR:$Rd, GPR:$Rn, GPR:$Rm)>; These patterns have the same source pattern, and so will trigger this condition. The assert was only marginally helpful and darned ugly. The diagnostic is slightly more helpful, though still not what we really want (see FIXME), and a lot less ugly. -Jim From grosbach at apple.com Tue Dec 7 14:41:06 2010 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 07 Dec 2010 20:41:06 -0000 Subject: [llvm-commits] [llvm] r121179 - in /llvm/trunk/lib/Target/ARM: ARMBaseInstrInfo.cpp ARMConstantIslandPass.cpp ARMInstrInfo.td ARMInstrThumb.td ARMInstrThumb2.td Thumb2SizeReduction.cpp Message-ID: <20101207204106.DCBB72A6C12C@llvm.org> Author: grosbach Date: Tue Dec 7 14:41:06 2010 New Revision: 121179 URL: http://llvm.org/viewvc/llvm-project?rev=121179&view=rev Log: Refactor the ARM CMPz* patterns to just use the normal CMP instructions when possible. They were duplicates for everything exception the source pattern before. Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrThumb.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=121179&r1=121178&r2=121179&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Tue Dec 7 14:41:06 2010 @@ -1439,9 +1439,7 @@ switch (MI->getOpcode()) { default: break; case ARM::CMPri: - case ARM::CMPzri: case ARM::t2CMPri: - case ARM::t2CMPzri: SrcReg = MI->getOperand(0).getReg(); CmpMask = ~0; CmpValue = MI->getOperand(1).getImm(); Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=121179&r1=121178&r2=121179&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Tue Dec 7 14:41:06 2010 @@ -1648,7 +1648,7 @@ unsigned DestOffset = BBOffsets[DestBB->getNumber()]; if (BrOffset < DestOffset && (DestOffset - BrOffset) <= 126) { MachineBasicBlock::iterator CmpMI = Br.MI; --CmpMI; - if (CmpMI->getOpcode() == ARM::tCMPzi8) { + if (CmpMI->getOpcode() == ARM::tCMPi8) { unsigned Reg = CmpMI->getOperand(0).getReg(); Pred = llvm::getInstrPredicate(CmpMI, PredReg); if (Pred == ARMCC::AL && Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=121179&r1=121178&r2=121179&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Dec 7 14:41:06 2010 @@ -2901,6 +2901,14 @@ IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr, BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>; +// ARMcmpZ can re-use the above instruction definitions. +def : ARMPat<(ARMcmpZ GPR:$src, so_imm:$imm), + (CMPri GPR:$src, so_imm:$imm)>; +def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs), + (CMPrr GPR:$src, GPR:$rhs)>; +def : ARMPat<(ARMcmpZ GPR:$src, so_reg:$rhs), + (CMPrs GPR:$src, so_reg:$rhs)>; + // FIXME: We have to be careful when using the CMN instruction and comparison // with 0. One would expect these two pieces of code should give identical // results: @@ -2953,9 +2961,6 @@ IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr, BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>; -defm CMPz : AI1_cmp_irs<0b1010, "cmp", - IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr, - BinOpFrag<(ARMcmpZ node:$LHS, node:$RHS)>>; defm CMNz : AI1_cmp_irs<0b1011, "cmn", IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr, BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>; Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=121179&r1=121178&r2=121179&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue Dec 7 14:41:06 2010 @@ -920,17 +920,6 @@ let Inst{7-0} = imm8; } -def tCMPzi8 : T1pI<(outs), (ins tGPR:$Rn, i32imm:$imm8), IIC_iCMPi, - "cmp", "\t$Rn, $imm8", - [(ARMcmpZ tGPR:$Rn, imm0_255:$imm8)]>, - T1General<{1,0,1,?,?}> { - // A8.6.35 - bits<3> Rn; - bits<8> imm8; - let Inst{10-8} = Rn; - let Inst{7-0} = imm8; -} - // CMP register def tCMPr : // A8.6.36 T1 T1pIDPEncode<0b1010, (outs), (ins tGPR:$Rn, tGPR:$Rm), @@ -938,11 +927,6 @@ "cmp", "\t$Rn, $Rm", [(ARMcmp tGPR:$Rn, tGPR:$Rm)]>; -def tCMPzr : // A8.6.36 T1 - T1pIDPEncode<0b1010, (outs), (ins tGPR:$Rn, tGPR:$Rm), IIC_iCMPr, - "cmp", "\t$Rn, $Rm", - [(ARMcmpZ tGPR:$Rn, tGPR:$Rm)]>; - def tCMPhir : T1pI<(outs), (ins GPR:$Rn, GPR:$Rm), IIC_iCMPr, "cmp", "\t$Rn, $Rm", []>, T1Special<{0,1,?,?}> { @@ -953,17 +937,6 @@ let Inst{6-3} = Rm; let Inst{2-0} = Rn{2-0}; } -def tCMPzhir : T1pI<(outs), (ins GPR:$Rn, GPR:$Rm), IIC_iCMPr, - "cmp", "\t$Rn, $Rm", []>, - T1Special<{0,1,?,?}> { - // A8.6.36 T2 - bits<4> Rm; - bits<4> Rn; - let Inst{7} = Rn{3}; - let Inst{6-3} = Rm; - let Inst{2-0} = Rn{2-0}; -} - } // isCompare = 1, Defs = [CPSR] @@ -1319,6 +1292,12 @@ // Non-Instruction Patterns // +// Comparisons +def : T1Pat<(ARMcmpZ tGPR:$Rn, imm0_255:$imm8), + (tCMPi8 tGPR:$Rn, imm0_255:$imm8)>; +def : T1Pat<(ARMcmpZ tGPR:$Rn, tGPR:$Rm), + (tCMPr tGPR:$Rn, tGPR:$Rm)>; + // Add with carry def : T1Pat<(addc tGPR:$lhs, imm0_7:$rhs), (tADDi3 tGPR:$lhs, imm0_7:$rhs)>; Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=121179&r1=121178&r2=121179&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Tue Dec 7 14:41:06 2010 @@ -2644,9 +2644,13 @@ defm t2CMP : T2I_cmp_irs<0b1101, "cmp", IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi, BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>; -defm t2CMPz : T2I_cmp_irs<0b1101, "cmp", - IIC_iCMPi, IIC_iCMPr, IIC_iCMPsi, - BinOpFrag<(ARMcmpZ node:$LHS, node:$RHS)>>; + +def : T2Pat<(ARMcmpZ GPR:$lhs, t2_so_imm:$imm), + (t2CMPri GPR:$lhs, t2_so_imm:$imm)>; +def : T2Pat<(ARMcmpZ GPR:$lhs, rGPR:$rhs), + (t2CMPrr GPR:$lhs, rGPR:$rhs)>; +def : T2Pat<(ARMcmpZ GPR:$lhs, t2_so_reg:$rhs), + (t2CMPrs GPR:$lhs, t2_so_reg:$rhs)>; //FIXME: Disable CMN, as CCodes are backwards from compare expectations // Compare-to-zero still works out, just not the relationals Modified: llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp?rev=121179&r1=121178&r2=121179&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp Tue Dec 7 14:41:06 2010 @@ -68,9 +68,7 @@ //FIXME: Disable CMN, as CCodes are backwards from compare expectations //{ ARM::t2CMNrr, ARM::tCMN, 0, 0, 0, 1, 0, 2,0, 0 }, { ARM::t2CMPri, ARM::tCMPi8, 0, 8, 0, 1, 0, 2,0, 0 }, - { ARM::t2CMPrr, ARM::tCMPhir, 0, 0, 0, 0, 0, 2,0, 0 }, - { ARM::t2CMPzri,ARM::tCMPzi8, 0, 8, 0, 1, 0, 2,0, 0 }, - { ARM::t2CMPzrr,ARM::tCMPzhir,0, 0, 0, 0, 0, 2,0, 1 }, + { ARM::t2CMPrr, ARM::tCMPhir, 0, 0, 0, 0, 0, 2,0, 1 }, { ARM::t2EORrr, 0, ARM::tEOR, 0, 0, 0, 1, 0,0, 0 }, // FIXME: adr.n immediate offset must be multiple of 4. //{ ARM::t2LEApcrelJT,ARM::tLEApcrelJT, 0, 0, 0, 1, 0, 1,0, 0 }, @@ -493,14 +491,14 @@ if (MI->getOperand(1).isImm()) return ReduceToNarrow(MBB, MI, Entry, LiveCPSR); break; - case ARM::t2CMPzrr: { + case ARM::t2CMPrr: { // Try to reduce to the lo-reg only version first. Why there are two // versions of the instruction is a mystery. // It would be nice to just have two entries in the master table that // are prioritized, but the table assumes a unique entry for each // source insn opcode. So for now, we hack a local entry record to use. static const ReduceEntry NarrowEntry = - { ARM::t2CMPzrr,ARM::tCMPzr, 0, 0, 0, 1, 1,2, 0, 1 }; + { ARM::t2CMPrr,ARM::tCMPr, 0, 0, 0, 1, 1,2, 0, 1 }; if (ReduceToNarrow(MBB, MI, NarrowEntry, LiveCPSR)) return true; return ReduceToNarrow(MBB, MI, Entry, LiveCPSR); From grosbach at apple.com Tue Dec 7 14:44:34 2010 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 07 Dec 2010 20:44:34 -0000 Subject: [llvm-commits] [llvm] r121180 - /llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp Message-ID: <20101207204434.25CF12A6C12C@llvm.org> Author: grosbach Date: Tue Dec 7 14:44:33 2010 New Revision: 121180 URL: http://llvm.org/viewvc/llvm-project?rev=121180&view=rev Log: Remove reference to the CMPz instruction patterns for ARM. Modified: llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp Modified: llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp?rev=121180&r1=121179&r2=121180&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp Tue Dec 7 14:44:33 2010 @@ -1567,9 +1567,6 @@ return false; if (thumbInstruction(Form)) return false; - if (Name.find("CMPz") != std::string::npos /* || - Name.find("CMNz") != std::string::npos */) - return false; // Tail calls are other patterns that generate existing instructions. if (Name == "TCRETURNdi" || Name == "TCRETURNdiND" || @@ -1713,7 +1710,6 @@ // Resolve conflicts: // // tBfar conflicts with tBLr9 - // tCMNz conflicts with tCMN (with assembly format strings being equal) // tPOP_RET/t2LDMIA_RET conflict with tPOP/t2LDM (ditto) // tMOVCCi conflicts with tMOVi8 // tMOVCCr conflicts with tMOVgpr2gpr @@ -1723,10 +1719,7 @@ // t2LEApcrelJT conflicts with t2LEApcrel // t2MOVCCi16 conflicts with tMOVi16 if (Name == "tBfar" || - /* Name == "tCMNz" || */ Name == "tCMPzi8" || Name == "tCMPzr" || - Name == "tCMPzhir" || /* Name == "t2CMNzrr" || Name == "t2CMNzrs" || - Name == "t2CMNzri" || */ Name == "t2CMPzrr" || Name == "t2CMPzrs" || - Name == "t2CMPzri" || Name == "tPOP_RET" || Name == "t2LDMIA_RET" || + Name == "tPOP_RET" || Name == "t2LDMIA_RET" || Name == "tMOVCCi" || Name == "tMOVCCr" || Name == "tSpill" || Name == "tLDRcp" || Name == "tRestore" || Name == "t2LEApcrelJT" || Name == "t2MOVCCi16") From resistor at mac.com Tue Dec 7 14:50:15 2010 From: resistor at mac.com (Owen Anderson) Date: Tue, 07 Dec 2010 20:50:15 -0000 Subject: [llvm-commits] [llvm] r121182 - in /llvm/trunk/lib/Target/ARM: ARMInstrFormats.td ARMInstrThumb2.td Message-ID: <20101207205015.4752E2A6C12C@llvm.org> Author: resistor Date: Tue Dec 7 14:50:15 2010 New Revision: 121182 URL: http://llvm.org/viewvc/llvm-project?rev=121182&view=rev Log: Fix Thumb2 encoding of the S bit. Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrFormats.td?rev=121182&r1=121181&r2=121182&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrFormats.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrFormats.td Tue Dec 7 14:50:15 2010 @@ -961,6 +961,9 @@ InstrItinClass itin, string opc, string asm, string cstr, list pattern> : InstARM { + bits<1> s; // condition-code set flag ('1' if the insn should set the flags) + let Inst{20} = s; + let OutOperandList = oops; let InOperandList = !con(iops, (ins pred:$p, cc_out:$s)); let AsmString = !strconcat(opc, "${s}${p}", asm); Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=121182&r1=121181&r2=121182&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Tue Dec 7 14:50:15 2010 @@ -225,7 +225,7 @@ class T2sOneRegShiftedReg pattern> - : T2I { + : T2sI { bits<4> Rd; bits<12> ShiftedRm; @@ -414,7 +414,6 @@ let Inst{31-27} = 0b11110; let Inst{25} = 0; let Inst{24-21} = opcod; - let Inst{20} = ?; // The S bit. let Inst{19-16} = 0b1111; // Rn let Inst{15} = 0; } @@ -425,7 +424,6 @@ let Inst{31-27} = 0b11101; let Inst{26-25} = 0b01; let Inst{24-21} = opcod; - let Inst{20} = ?; // The S bit. let Inst{19-16} = 0b1111; // Rn let Inst{14-12} = 0b000; // imm3 let Inst{7-6} = 0b00; // imm2 @@ -438,7 +436,6 @@ let Inst{31-27} = 0b11101; let Inst{26-25} = 0b01; let Inst{24-21} = opcod; - let Inst{20} = ?; // The S bit. let Inst{19-16} = 0b1111; // Rn } } @@ -457,7 +454,6 @@ let Inst{31-27} = 0b11110; let Inst{25} = 0; let Inst{24-21} = opcod; - let Inst{20} = ?; // The S bit. let Inst{15} = 0; } // register @@ -468,7 +464,6 @@ let Inst{31-27} = 0b11101; let Inst{26-25} = 0b01; let Inst{24-21} = opcod; - let Inst{20} = ?; // The S bit. let Inst{14-12} = 0b000; // imm3 let Inst{7-6} = 0b00; // imm2 let Inst{5-4} = 0b00; // type @@ -481,7 +476,6 @@ let Inst{31-27} = 0b11101; let Inst{26-25} = 0b01; let Inst{24-21} = opcod; - let Inst{20} = ?; // The S bit. } } @@ -504,7 +498,6 @@ let Inst{31-27} = 0b11110; let Inst{25} = 0; let Inst{24-21} = opcod; - let Inst{20} = ?; // The S bit. let Inst{15} = 0; } // register @@ -515,7 +508,6 @@ let Inst{31-27} = 0b11101; let Inst{26-25} = 0b01; let Inst{24-21} = opcod; - let Inst{20} = ?; // The S bit. let Inst{14-12} = 0b000; // imm3 let Inst{7-6} = 0b00; // imm2 let Inst{5-4} = 0b00; // type @@ -528,7 +520,6 @@ let Inst{31-27} = 0b11101; let Inst{26-25} = 0b01; let Inst{24-21} = opcod; - let Inst{20} = ?; // The S bit. } } @@ -592,7 +583,6 @@ let Inst{25} = 0; let Inst{24} = 1; let Inst{23-21} = op23_21; - let Inst{20} = 0; // The S bit. let Inst{15} = 0; } } @@ -617,7 +607,6 @@ let Inst{26-25} = 0b01; let Inst{24} = 1; let Inst{23-21} = op23_21; - let Inst{20} = 0; // The S bit. let Inst{14-12} = 0b000; // imm3 let Inst{7-6} = 0b00; // imm2 let Inst{5-4} = 0b00; // type @@ -631,7 +620,6 @@ let Inst{26-25} = 0b01; let Inst{24} = 1; let Inst{23-21} = op23_21; - let Inst{20} = 0; // The S bit. } } @@ -649,7 +637,6 @@ let Inst{31-27} = 0b11110; let Inst{25} = 0; let Inst{24-21} = opcod; - let Inst{20} = 0; // The S bit. let Inst{15} = 0; } // register @@ -661,7 +648,6 @@ let Inst{31-27} = 0b11101; let Inst{26-25} = 0b01; let Inst{24-21} = opcod; - let Inst{20} = 0; // The S bit. let Inst{14-12} = 0b000; // imm3 let Inst{7-6} = 0b00; // imm2 let Inst{5-4} = 0b00; // type @@ -675,7 +661,6 @@ let Inst{31-27} = 0b11101; let Inst{26-25} = 0b01; let Inst{24-21} = opcod; - let Inst{20} = 0; // The S bit. } } @@ -1146,7 +1131,6 @@ let Inst{31-27} = 0b11110; let Inst{25} = 0; let Inst{24-21} = 0b1000; - let Inst{20} = ?; // The S bit. let Inst{19-16} = 0b1101; // Rn = sp let Inst{15} = 0; } @@ -1167,7 +1151,6 @@ let Inst{31-27} = 0b11101; let Inst{26-25} = 0b01; let Inst{24-21} = 0b1000; - let Inst{20} = ?; // The S bit. let Inst{19-16} = 0b1101; // Rn = sp let Inst{15} = 0; } @@ -1178,7 +1161,6 @@ let Inst{31-27} = 0b11110; let Inst{25} = 0; let Inst{24-21} = 0b1101; - let Inst{20} = ?; // The S bit. let Inst{19-16} = 0b1101; // Rn = sp let Inst{15} = 0; } @@ -1199,7 +1181,6 @@ let Inst{31-27} = 0b11101; let Inst{26-25} = 0b01; let Inst{24-21} = 0b1101; - let Inst{20} = ?; // The S bit. let Inst{19-16} = 0b1101; // Rn = sp let Inst{15} = 0; } @@ -1654,7 +1635,6 @@ let Inst{31-27} = 0b11101; let Inst{26-25} = 0b01; let Inst{24-21} = 0b0010; - let Inst{20} = ?; // The S bit. let Inst{19-16} = 0b1111; // Rn let Inst{14-12} = 0b000; let Inst{7-4} = 0b0000; @@ -1669,7 +1649,6 @@ let Inst{31-27} = 0b11110; let Inst{25} = 0; let Inst{24-21} = 0b0010; - let Inst{20} = ?; // The S bit. let Inst{19-16} = 0b1111; // Rn let Inst{15} = 0; } @@ -2027,7 +2006,6 @@ let Inst{31-27} = 0b11101; let Inst{26-25} = 0b01; let Inst{24-21} = 0b0010; - let Inst{20} = ?; // The S bit. let Inst{19-16} = 0b1111; // Rn let Inst{14-12} = 0b000; let Inst{7-4} = 0b0011; From dpatel at apple.com Tue Dec 7 15:12:05 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 07 Dec 2010 21:12:05 -0000 Subject: [llvm-commits] [llvm] r121184 - /llvm/trunk/utils/CollectDebugInfoUsingLLDB.py Message-ID: <20101207211205.305A92A6C12C@llvm.org> Author: dpatel Date: Tue Dec 7 15:12:05 2010 New Revision: 121184 URL: http://llvm.org/viewvc/llvm-project?rev=121184&view=rev Log: Handle recursive values. Add comments. Modified: llvm/trunk/utils/CollectDebugInfoUsingLLDB.py Modified: llvm/trunk/utils/CollectDebugInfoUsingLLDB.py URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/CollectDebugInfoUsingLLDB.py?rev=121184&r1=121183&r2=121184&view=diff ============================================================================== --- llvm/trunk/utils/CollectDebugInfoUsingLLDB.py (original) +++ llvm/trunk/utils/CollectDebugInfoUsingLLDB.py Tue Dec 7 15:12:05 2010 @@ -1,11 +1,24 @@ #!/usr/bin/python #---------------------------------------------------------------------- +# # Be sure to add the python path that points to the LLDB shared library. # On MacOSX csh, tcsh: # setenv PYTHONPATH /Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Python # On MacOSX sh, bash: # export PYTHONPATH=/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Python +# +# This script collect debugging information using LLDB. This script is +# used by TEST=dbg in llvm testsuite to measure quality of debug info in +# optimized builds. +# +# Usage: +# export PYTHONPATH=... +# ./CollectDebugInfUsingLLDB.py program bp_file out_file +# program - Executable program with debug info. +# bp_file - Simple text file listing breakpoints. +# +# out_file - Output file where the debug info will be emitted. #---------------------------------------------------------------------- import lldb @@ -13,26 +26,46 @@ import sys import time +# AlreadyPrintedValues - A place to keep track of recursive values. +AlreadyPrintedValues = {} + +# ISAlreadyPrinted - Return true if value is already printed. +def IsAlreadyPrinted(value_name): + if AlreadyPrintedValues.get(value_name) is None: + AlreadyPrintedValues[value_name] = 1 + return False + return True + + +# print_var_value - Print a variable's value. def print_var_value (v, file, frame): - if v.GetNumChildren() > 0: - for c in range(v.GetNumChildren()): - if v.GetChildAtIndex(c) is None: + if v.IsValid() == False: + return + if IsAlreadyPrinted(v.GetName()): + return + total_children = v.GetNumChildren() + if total_children > 0: + c = 0 + while (c < total_children) : + child = v.GetChildAtIndex(c) + if child is None: file.write("None") - else: - if (v.GetChildAtIndex(c).GetName()) is None: + else: + if (child.GetName()) is None: file.write("None") else: - file.write(v.GetChildAtIndex(c).GetName()) + file.write(child.GetName()) file.write('=') - print_var_value(v.GetChildAtIndex(c), file, frame) + print_var_value(child, file, frame) file.write(',') + c = c + 1 else: if v.GetValue(frame) is None: file.write("None") else: file.write(v.GetValue(frame)) - +# print_vars - Print variable values in output file. def print_vars (vars, fname, line, file, frame, target, thread): # disable this thread. count = thread.GetStopReasonDataCount() @@ -51,7 +84,6 @@ if bp_loc.IsValid(): bid = bp_loc.GetBreakPoint().GetID() tid = bp_loc.ThreadGetID() - # print " { ", bp_loc.ThreadGetID(), " : ", bp_loc.GetBreakPoint().GetID(), " }} " bp_loc.SetEnabled(False); for i in range(vars.GetSize()): @@ -67,9 +99,11 @@ v = vars.GetValueAtIndex(i) file.write(v.GetName()) file.write(' ') + AlreadyPrintedValues.clear() print_var_value (v, file, frame) file.write('\n') +# set_breakpoints - set breakpoints as listed in input file. def set_breakpoints (target, breakpoint_filename): f = open(breakpoint_filename, "r") lines = f.readlines() @@ -79,21 +113,17 @@ bp = target.BreakpointCreateByLocation (str(c[0]), int(c[1])) f.close() -def stop_at_breakpoint (process): +# stopeed_at_breakpoint - Return True if process is stopeed at a +# breakpoint. +def stopped_at_breakpoint (process): if process.IsValid(): state = process.GetState() - if state != lldb.eStateStopped: - return lldb.eStateInvalid - thread = process.GetThreadAtIndex(0) - if thread.IsValid(): - if thread.GetStopReason() == lldb.eStopReasonBreakpoint: - return lldb.eStateStopped - else: - return lldb.eStateInvalid - else: - return lldb.eStateInvalid - else: - return lldb.eStateInvalid + if state == lldb.eStateStopped: + thread = process.GetThreadAtIndex(0) + if thread.IsValid(): + if thread.GetStopReason() == lldb.eStopReasonBreakpoint: + return True + return False # Create a new debugger instance debugger = lldb.SBDebugger.Create() @@ -120,7 +150,7 @@ process = target.LaunchProcess ([''], [''], "/dev/stdout", 0, False) file=open(str(sys.argv[3]), 'w') # Make sure the launch went ok - while stop_at_breakpoint(process) == lldb.eStateStopped: + while stopped_at_breakpoint(process): thread = process.GetThreadAtIndex (0) frame = thread.GetFrameAtIndex (0) if frame.IsValid(): From bigcheesegs at gmail.com Tue Dec 7 15:23:44 2010 From: bigcheesegs at gmail.com (Michael Spencer) Date: Tue, 7 Dec 2010 16:23:44 -0500 Subject: [llvm-commits] [PATCH] Replace all uses of std::string* for errors with error_code in Support/MemoryBuffer. Message-ID: The two attached patches replace all uses of std::string* for error handling with error_code in Support/MemoryBuffer and updates clients to use them. This will break other projects that use MemoryBuffer directly, but the conversion is easy. Just use error_code::message(). This will actually return exactly the same thing for all except one error message, which now produces a more accurate one. - Michael Spencer -------------- next part -------------- A non-text attachment was scrubbed... Name: clang-MemoryBuffer-std-string-error_code.patch Type: application/octet-stream Size: 8026 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20101207/901b597a/attachment.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-MemoryBuffer-std-string-error_code.patch Type: application/octet-stream Size: 28074 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20101207/901b597a/attachment-0001.obj From echristo at apple.com Tue Dec 7 15:44:51 2010 From: echristo at apple.com (Eric Christopher) Date: Tue, 7 Dec 2010 13:44:51 -0800 Subject: [llvm-commits] [llvm] r121166 - /llvm/trunk/utils/TableGen/FastISelEmitter.cpp In-Reply-To: <42E5E1F3-0FAA-48AE-A68A-5A3A5538C183@apple.com> References: <20101207193536.8CE9E2A6C12C@llvm.org> <28CC36C7-644B-49E7-8F7C-FC6D6FAB4716@apple.com> <42E5E1F3-0FAA-48AE-A68A-5A3A5538C183@apple.com> Message-ID: On Dec 7, 2010, at 12:27 PM, Jim Grosbach wrote: > > On Dec 7, 2010, at 11:53 AM, Eric Christopher wrote: > >> >> On Dec 7, 2010, at 11:35 AM, Jim Grosbach wrote: >> >>> Author: grosbach >>> Date: Tue Dec 7 13:35:36 2010 >>> New Revision: 121166 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=121166&view=rev >>> Log: >>> Change assert to diagnostic. Message still needs work, but it's better than >>> an assert, at least. >>> >>> }; >>> - assert(!SimplePatterns[Operands][OpcodeName][VT][RetVT] >>> - .count(PredicateCheck) && >>> - "Duplicate pattern!"); >>> + // FIXME: Source location information for the diagnostic. >>> + if (SimplePatterns[Operands][OpcodeName][VT][RetVT] >>> + .count(PredicateCheck)) { >>> + SmallString<128> PatText; >>> + raw_svector_ostream OS(PatText); >>> + Pattern.SrcPattern->print(OS); >>> + throw "Duplicate record: " + OS.str().str(); >>> + } >>> SimplePatterns[Operands][OpcodeName][VT][RetVT][PredicateCheck] = Memo; >>> } >>> } >> >> Hmm? What's going on here? > > > If two tblgen records have the same pattern, they hit this. copy/paste errors or somesuch, usually. E.g., > > def Pat<(add GPR:$Rd, GPR:$Rn, GPR:$Rm) > (ADD GPR:$Rd, GPR:$Rn, GPR:$Rm)>; > def Pat<(add GPR:$Rd, GPR:$Rn, GPR:$Rm) > (SUB GPR:$Rd, GPR:$Rn, GPR:$Rm)>; > > These patterns have the same source pattern, and so will trigger this condition. The assert was only marginally helpful and darned ugly. The diagnostic is slightly more helpful, though still not what we really want (see FIXME), and a lot less ugly. OK I guess. The assert meant such things wouldn't be missed, but seeing the message for each duplicate pattern may outweigh that :) -eric -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20101207/ca6abe10/attachment.html From grosbach at apple.com Tue Dec 7 15:46:50 2010 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 7 Dec 2010 13:46:50 -0800 Subject: [llvm-commits] [llvm] r121166 - /llvm/trunk/utils/TableGen/FastISelEmitter.cpp In-Reply-To: References: <20101207193536.8CE9E2A6C12C@llvm.org> <28CC36C7-644B-49E7-8F7C-FC6D6FAB4716@apple.com> <42E5E1F3-0FAA-48AE-A68A-5A3A5538C183@apple.com> Message-ID: On Dec 7, 2010, at 1:44 PM, Eric Christopher wrote: > > On Dec 7, 2010, at 12:27 PM, Jim Grosbach wrote: > >> >> On Dec 7, 2010, at 11:53 AM, Eric Christopher wrote: >> >>> >>> On Dec 7, 2010, at 11:35 AM, Jim Grosbach wrote: >>> >>>> Author: grosbach >>>> Date: Tue Dec 7 13:35:36 2010 >>>> New Revision: 121166 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=121166&view=rev >>>> Log: >>>> Change assert to diagnostic. Message still needs work, but it's better than >>>> an assert, at least. >>>> >>>> }; >>>> - assert(!SimplePatterns[Operands][OpcodeName][VT][RetVT] >>>> - .count(PredicateCheck) && >>>> - "Duplicate pattern!"); >>>> + // FIXME: Source location information for the diagnostic. >>>> + if (SimplePatterns[Operands][OpcodeName][VT][RetVT] >>>> + .count(PredicateCheck)) { >>>> + SmallString<128> PatText; >>>> + raw_svector_ostream OS(PatText); >>>> + Pattern.SrcPattern->print(OS); >>>> + throw "Duplicate record: " + OS.str().str(); >>>> + } >>>> SimplePatterns[Operands][OpcodeName][VT][RetVT][PredicateCheck] = Memo; >>>> } >>>> } >>> >>> Hmm? What's going on here? >> >> >> If two tblgen records have the same pattern, they hit this. copy/paste errors or somesuch, usually. E.g., >> >> def Pat<(add GPR:$Rd, GPR:$Rn, GPR:$Rm) >> (ADD GPR:$Rd, GPR:$Rn, GPR:$Rm)>; >> def Pat<(add GPR:$Rd, GPR:$Rn, GPR:$Rm) >> (SUB GPR:$Rd, GPR:$Rn, GPR:$Rm)>; >> >> These patterns have the same source pattern, and so will trigger this condition. The assert was only marginally helpful and darned ugly. The diagnostic is slightly more helpful, though still not what we really want (see FIXME), and a lot less ugly. > > OK I guess. The assert meant such things wouldn't be missed, but seeing the message for each duplicate pattern may outweigh that :) This is a hard error, not a warning, so the build will still fail if it gets hit. The only difference in behaviour should essentially be a prettier error message. Or is there something else I'm missing? -Jim From echristo at apple.com Tue Dec 7 15:48:53 2010 From: echristo at apple.com (Eric Christopher) Date: Tue, 7 Dec 2010 13:48:53 -0800 Subject: [llvm-commits] [llvm] r121166 - /llvm/trunk/utils/TableGen/FastISelEmitter.cpp In-Reply-To: References: <20101207193536.8CE9E2A6C12C@llvm.org> <28CC36C7-644B-49E7-8F7C-FC6D6FAB4716@apple.com> <42E5E1F3-0FAA-48AE-A68A-5A3A5538C183@apple.com> Message-ID: <142A1A84-F437-4599-BFDF-AD20D7F090E2@apple.com> >> >> OK I guess. The assert meant such things wouldn't be missed, but seeing the message for each duplicate pattern may outweigh that :) > > This is a hard error, not a warning, so the build will still fail if it gets hit. The only difference in behaviour should essentially be a prettier error message. Or is there something else I'm missing? Aaaah. I read "diagnostic" as "warn" not "diagnostic" as "aaaaaaaaaa!" -eric -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20101207/80906232/attachment.html From grosbach at apple.com Tue Dec 7 15:50:47 2010 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 07 Dec 2010 21:50:47 -0000 Subject: [llvm-commits] [llvm] r121186 - in /llvm/trunk/lib/Target/ARM: ARMCodeEmitter.cpp ARMInstrThumb.td ARMMCCodeEmitter.cpp Message-ID: <20101207215047.E4A352A6C12C@llvm.org> Author: grosbach Date: Tue Dec 7 15:50:47 2010 New Revision: 121186 URL: http://llvm.org/viewvc/llvm-project?rev=121186&view=rev Log: Binary encoding for ARM tLDRspi and tSTRspi. Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp llvm/trunk/lib/Target/ARM/ARMInstrThumb.td llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp?rev=121186&r1=121185&r2=121186&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Tue Dec 7 15:50:47 2010 @@ -247,6 +247,8 @@ const { return 0;} uint32_t getAddrMode3OpValue(const MachineInstr &MI, unsigned Op) const { return 0; } + uint32_t getAddrModeThumbSPOpValue(const MachineInstr &MI, unsigned Op) + const { return 0; } uint32_t getAddrModeS4OpValue(const MachineInstr &MI, unsigned Op) const { return 0; } uint32_t getAddrModeS2OpValue(const MachineInstr &MI, unsigned Op) Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=121186&r1=121185&r2=121186&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue Dec 7 15:50:47 2010 @@ -128,6 +128,7 @@ // def t_addrmode_sp : Operand, ComplexPattern { + let EncoderMethod = "getAddrModeThumbSPOpValue"; let PrintMethod = "printThumbAddrModeSPOperand"; let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm); let ParserMatchClass = MemModeThumbAsmOperand; @@ -600,14 +601,20 @@ [(set tGPR:$dst, (sextloadi16 t_addrmode_rr:$addr))]>; let canFoldAsLoad = 1 in -def tLDRspi : T1pIs<(outs tGPR:$dst), (ins t_addrmode_sp:$addr), IIC_iLoad_i, - "ldr", "\t$dst, $addr", - [(set tGPR:$dst, (load t_addrmode_sp:$addr))]>, - T1LdStSP<{1,?,?}>; +def tLDRspi : T1pIs<(outs tGPR:$Rt), (ins t_addrmode_sp:$addr), IIC_iLoad_i, + "ldr", "\t$Rt, $addr", + [(set tGPR:$Rt, (load t_addrmode_sp:$addr))]>, + T1LdStSP<{1,?,?}> { + bits<3> Rt; + bits<8> addr; + let Inst{10-8} = Rt; + let Inst{7-0} = addr; +} // Special instruction for restore. It cannot clobber condition register // when it's expanded by eliminateCallFramePseudoInstr(). let canFoldAsLoad = 1, mayLoad = 1, neverHasSideEffects = 1 in +// FIXME: Pseudo for tLDRspi def tRestore : T1pIs<(outs tGPR:$dst), (ins t_addrmode_sp:$addr), IIC_iLoad_i, "ldr", "\t$dst, $addr", []>, T1LdStSP<{1,?,?}>; @@ -668,14 +675,20 @@ "strh", "\t$Rt, $addr", []>; -def tSTRspi : T1pIs<(outs), (ins tGPR:$src, t_addrmode_sp:$addr), IIC_iStore_i, - "str", "\t$src, $addr", - [(store tGPR:$src, t_addrmode_sp:$addr)]>, - T1LdStSP<{0,?,?}>; +def tSTRspi : T1pIs<(outs), (ins tGPR:$Rt, t_addrmode_sp:$addr), IIC_iStore_i, + "str", "\t$Rt, $addr", + [(store tGPR:$Rt, t_addrmode_sp:$addr)]>, + T1LdStSP<{0,?,?}> { + bits<3> Rt; + bits<8> addr; + let Inst{10-8} = Rt; + let Inst{7-0} = addr; +} let mayStore = 1, neverHasSideEffects = 1 in // Special instruction for spill. It cannot clobber condition register when it's // expanded by eliminateCallFramePseudoInstr(). +// FIXME: Pseudo for tSTRspi def tSpill : T1pIs<(outs), (ins tGPR:$src, t_addrmode_sp:$addr), IIC_iStore_i, "str", "\t$src, $addr", []>, T1LdStSP<{0,?,?}>; Modified: llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp?rev=121186&r1=121185&r2=121186&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp Tue Dec 7 15:50:47 2010 @@ -156,6 +156,11 @@ uint32_t getAddrMode3OpValue(const MCInst &MI, unsigned OpIdx, SmallVectorImpl &Fixups) const; + /// getAddrModeThumbSPOpValue - Return encoding info for 'reg +/- imm12' + /// operand. + uint32_t getAddrModeThumbSPOpValue(const MCInst &MI, unsigned OpIdx, + SmallVectorImpl &Fixups) const; + /// getAddrModeS4OpValue - Return encoding for t_addrmode_s4 operands. uint32_t getAddrModeS4OpValue(const MCInst &MI, unsigned OpIdx, SmallVectorImpl &Fixups) const; @@ -656,6 +661,20 @@ return (Rn << 9) | Imm8 | (isAdd << 8) | (isImm << 13); } +/// getAddrModeThumbSPOpValue- Encode the t_addrmode_sp operands. +uint32_t ARMMCCodeEmitter:: +getAddrModeThumbSPOpValue(const MCInst &MI, unsigned OpIdx, + SmallVectorImpl &Fixups) const { + // [SP, #imm] + // {7-0} = imm8 + const MCOperand &MO = MI.getOperand(OpIdx); + const MCOperand &MO1 = MI.getOperand(OpIdx + 1); + assert (MO.getReg() == ARM::SP && "Unexpected base register!"); + // The immediate is already shifted for the implicit zeroes, so no change + // here. + return MO1.getImm() & 0xff; +} + /// getAddrModeSOpValue - Encode the t_addrmode_s# operands. static unsigned getAddrModeSOpValue(const MCInst &MI, unsigned OpIdx, unsigned Scale) { From bob.wilson at apple.com Tue Dec 7 16:02:48 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 07 Dec 2010 22:02:48 -0000 Subject: [llvm-commits] [llvm] r121187 - in /llvm/trunk/utils/TableGen: NeonEmitter.cpp NeonEmitter.h Message-ID: <20101207220248.D7A012A6C12C@llvm.org> Author: bwilson Date: Tue Dec 7 16:02:48 2010 New Revision: 121187 URL: http://llvm.org/viewvc/llvm-project?rev=121187&view=rev Log: Add an operator for vmull_lane so it can be implemented without a clang builtin. Modified: llvm/trunk/utils/TableGen/NeonEmitter.cpp llvm/trunk/utils/TableGen/NeonEmitter.h Modified: llvm/trunk/utils/TableGen/NeonEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.cpp?rev=121187&r1=121186&r2=121187&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/NeonEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/NeonEmitter.cpp Tue Dec 7 16:02:48 2010 @@ -601,6 +601,11 @@ Extend(proto, typestr, Duplicate(nElts << (int)quad, typestr, "__b")) + ";"; break; + case OpMullLane: + s += Extend(proto, typestr, "__a") + " * " + + Extend(proto, typestr, + SplatLane(nElts, "__b", "__c")) + ";"; + break; case OpMull: s += Extend(proto, typestr, "__a") + " * " + Extend(proto, typestr, "__b") + ";"; Modified: llvm/trunk/utils/TableGen/NeonEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.h?rev=121187&r1=121186&r2=121187&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/NeonEmitter.h (original) +++ llvm/trunk/utils/TableGen/NeonEmitter.h Tue Dec 7 16:02:48 2010 @@ -34,6 +34,7 @@ OpMlaN, OpMlsN, OpMulLane, + OpMullLane, OpMlaLane, OpMlsLane, OpEq, @@ -89,6 +90,7 @@ OpMap["OP_MLA_N"] = OpMlaN; OpMap["OP_MLS_N"] = OpMlsN; OpMap["OP_MUL_LN"]= OpMulLane; + OpMap["OP_MULL_LN"] = OpMullLane; OpMap["OP_MLA_LN"]= OpMlaLane; OpMap["OP_MLS_LN"]= OpMlsLane; OpMap["OP_EQ"] = OpEq; From clattner at apple.com Tue Dec 7 16:36:53 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 7 Dec 2010 14:36:53 -0800 Subject: [llvm-commits] [llvm] r121166 - /llvm/trunk/utils/TableGen/FastISelEmitter.cpp In-Reply-To: <42E5E1F3-0FAA-48AE-A68A-5A3A5538C183@apple.com> References: <20101207193536.8CE9E2A6C12C@llvm.org> <28CC36C7-644B-49E7-8F7C-FC6D6FAB4716@apple.com> <42E5E1F3-0FAA-48AE-A68A-5A3A5538C183@apple.com> Message-ID: On Dec 7, 2010, at 12:27 PM, Jim Grosbach wrote: >>> } >> >> Hmm? What's going on here? > > > If two tblgen records have the same pattern, they hit this. copy/paste errors or somesuch, usually. E.g., > > def Pat<(add GPR:$Rd, GPR:$Rn, GPR:$Rm) > (ADD GPR:$Rd, GPR:$Rn, GPR:$Rm)>; > def Pat<(add GPR:$Rd, GPR:$Rn, GPR:$Rm) > (SUB GPR:$Rd, GPR:$Rn, GPR:$Rm)>; > > These patterns have the same source pattern, and so will trigger this condition. The assert was only marginally helpful and darned ugly. The diagnostic is slightly more helpful, though still not what we really want (see FIXME), and a lot less ugly. Ok, do you have the record for the Pat pattern? If you use: throw TGError(TheDef->getLoc(), "message") then you'll get a caret pointing to the duplicate def in the error message. -Chris From grosbach at apple.com Tue Dec 7 16:40:06 2010 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 7 Dec 2010 14:40:06 -0800 Subject: [llvm-commits] [llvm] r121166 - /llvm/trunk/utils/TableGen/FastISelEmitter.cpp In-Reply-To: References: <20101207193536.8CE9E2A6C12C@llvm.org> <28CC36C7-644B-49E7-8F7C-FC6D6FAB4716@apple.com> <42E5E1F3-0FAA-48AE-A68A-5A3A5538C183@apple.com> Message-ID: <56C049AA-3E4C-42A9-9C53-A2D652241619@apple.com> On Dec 7, 2010, at 2:36 PM, Chris Lattner wrote: > > On Dec 7, 2010, at 12:27 PM, Jim Grosbach wrote: > >>>> } >>> >>> Hmm? What's going on here? >> >> >> If two tblgen records have the same pattern, they hit this. copy/paste errors or somesuch, usually. E.g., >> >> def Pat<(add GPR:$Rd, GPR:$Rn, GPR:$Rm) >> (ADD GPR:$Rd, GPR:$Rn, GPR:$Rm)>; >> def Pat<(add GPR:$Rd, GPR:$Rn, GPR:$Rm) >> (SUB GPR:$Rd, GPR:$Rn, GPR:$Rm)>; >> >> These patterns have the same source pattern, and so will trigger this condition. The assert was only marginally helpful and darned ugly. The diagnostic is slightly more helpful, though still not what we really want (see FIXME), and a lot less ugly. > > Ok, do you have the record for the Pat pattern? If you use: > throw TGError(TheDef->getLoc(), "message") > then you'll get a caret pointing to the duplicate def in the error message. I couldn't find the Record for the Pat. That's definitely what I really wanted. We have have the PatternToMatch entry, and from that we get the source pattern TreePatternNode. Is there a way to go from either of those to the corresponding Record? -Jim From bob.wilson at apple.com Tue Dec 7 16:39:24 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 07 Dec 2010 22:39:24 -0000 Subject: [llvm-commits] [llvm] r121190 - in /llvm/trunk/utils/TableGen: NeonEmitter.cpp NeonEmitter.h Message-ID: <20101207223924.301DF2A6C12C@llvm.org> Author: bwilson Date: Tue Dec 7 16:39:24 2010 New Revision: 121190 URL: http://llvm.org/viewvc/llvm-project?rev=121190&view=rev Log: Add an operator for vdup_lane so it can be implemented without a clang builtin. Modified: llvm/trunk/utils/TableGen/NeonEmitter.cpp llvm/trunk/utils/TableGen/NeonEmitter.h Modified: llvm/trunk/utils/TableGen/NeonEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.cpp?rev=121190&r1=121189&r2=121190&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/NeonEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/NeonEmitter.cpp Tue Dec 7 16:39:24 2010 @@ -680,6 +680,9 @@ case OpDup: s += Duplicate(nElts, typestr, "__a") + ";"; break; + case OpDupLane: + s += SplatLane(nElts, "__a", "__b") + ";"; + break; case OpSelect: // ((0 & 1) | (~0 & 2)) s += "(" + ts + ")"; Modified: llvm/trunk/utils/TableGen/NeonEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.h?rev=121190&r1=121189&r2=121190&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/NeonEmitter.h (original) +++ llvm/trunk/utils/TableGen/NeonEmitter.h Tue Dec 7 16:39:24 2010 @@ -52,6 +52,7 @@ OpCast, OpConcat, OpDup, + OpDupLane, OpHi, OpLo, OpSelect, @@ -110,6 +111,7 @@ OpMap["OP_HI"] = OpHi; OpMap["OP_LO"] = OpLo; OpMap["OP_DUP"] = OpDup; + OpMap["OP_DUP_LN"] = OpDupLane; OpMap["OP_SEL"] = OpSelect; OpMap["OP_REV16"] = OpRev16; OpMap["OP_REV32"] = OpRev32; From clattner at apple.com Tue Dec 7 16:44:51 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 7 Dec 2010 14:44:51 -0800 Subject: [llvm-commits] [llvm] r121166 - /llvm/trunk/utils/TableGen/FastISelEmitter.cpp In-Reply-To: <56C049AA-3E4C-42A9-9C53-A2D652241619@apple.com> References: <20101207193536.8CE9E2A6C12C@llvm.org> <28CC36C7-644B-49E7-8F7C-FC6D6FAB4716@apple.com> <42E5E1F3-0FAA-48AE-A68A-5A3A5538C183@apple.com> <56C049AA-3E4C-42A9-9C53-A2D652241619@apple.com> Message-ID: <00BCCEB8-DD4F-4463-96F5-A7EE1D1CD8FE@apple.com> >> >> Ok, do you have the record for the Pat pattern? If you use: >> throw TGError(TheDef->getLoc(), "message") >> then you'll get a caret pointing to the duplicate def in the error message. > > > I couldn't find the Record for the Pat. That's definitely what I really wanted. We have have the PatternToMatch entry, and from that we get the source pattern TreePatternNode. Is there a way to go from either of those to the corresponding Record? No, there isn't. It seems reasonable to add a Record* to the PatternToMatch class, and pass in the record to the PatternToMatch ctor. -Chris From isanbard at gmail.com Tue Dec 7 17:05:20 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 07 Dec 2010 23:05:20 -0000 Subject: [llvm-commits] [llvm] r121195 - /llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Message-ID: <20101207230520.CC0BA2A6C12C@llvm.org> Author: void Date: Tue Dec 7 17:05:20 2010 New Revision: 121195 URL: http://llvm.org/viewvc/llvm-project?rev=121195&view=rev Log: A bit of cleanup: early exit ApplyFixup and cache the Fixup offset. No functionality change. Modified: llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Modified: llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp?rev=121195&r1=121194&r2=121195&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Tue Dec 7 17:05:20 2010 @@ -133,6 +133,7 @@ } namespace { + // FIXME: This should be in a separate file. // ELF is an ELF of course... class ELFARMAsmBackend : public ARMAsmBackend { @@ -160,24 +161,24 @@ } }; -// Fixme: Raise this to share code between Darwin and ELF. +// FIXME: Raise this to share code between Darwin and ELF. void ELFARMAsmBackend::ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize, uint64_t Value) const { - // Fixme: 2 for Thumb - unsigned NumBytes = 4; + unsigned NumBytes = 4; // FIXME: 2 for Thumb + Value = adjustFixupValue(Fixup.getKind(), Value); + if (!Value) return; // No need to encode nothing. - assert((Fixup.getOffset() % NumBytes == 0) - && "Offset mod NumBytes is nonzero!"); - // For each byte of the fragment that the fixup touches, mask in the - // bits from the fixup value. - // The Value has been "split up" into the appropriate bitfields above. - for (unsigned i = 0; i != NumBytes; ++i) { - Data[Fixup.getOffset() + i] |= uint8_t(Value >> (i * 8)); - } + unsigned Offset = Fixup.getOffset(); + assert(Offset % NumBytes == 0 && "Offset mod NumBytes is nonzero!"); + + // For each byte of the fragment that the fixup touches, mask in the bits from + // the fixup value. The Value has been "split up" into the appropriate + // bitfields above. + for (unsigned i = 0; i != NumBytes; ++i) + Data[Offset + i] |= uint8_t((Value >> (i * 8)) & 0xff); } -namespace { // FIXME: This should be in a separate file. class DarwinARMAsmBackend : public ARMAsmBackend { MCMachOObjectFormat Format; @@ -205,7 +206,6 @@ return false; } }; -} // end anonymous namespace static unsigned getFixupKindNumBytes(unsigned Kind) { switch (Kind) { @@ -235,6 +235,7 @@ for (unsigned i = 0; i != NumBytes; ++i) Data[Fixup.getOffset() + i] |= uint8_t(Value >> (i * 8)); } + } // end anonymous namespace TargetAsmBackend *llvm::createARMAsmBackend(const Target &T, From grosbach at apple.com Tue Dec 7 17:05:49 2010 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 07 Dec 2010 23:05:49 -0000 Subject: [llvm-commits] [llvm] r121196 - in /llvm/trunk/utils/TableGen: CodeGenDAGPatterns.cpp CodeGenDAGPatterns.h FastISelEmitter.cpp Message-ID: <20101207230549.EA8532A6C12C@llvm.org> Author: grosbach Date: Tue Dec 7 17:05:49 2010 New Revision: 121196 URL: http://llvm.org/viewvc/llvm-project?rev=121196&view=rev Log: Add source Record* reference to PatternToMatch. Allows better diagnostics. Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h llvm/trunk/utils/TableGen/FastISelEmitter.cpp Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=121196&r1=121195&r2=121196&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original) +++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Tue Dec 7 17:05:49 2010 @@ -2482,7 +2482,8 @@ Record *Instr = II->first; AddPatternToMatch(I, - PatternToMatch(Instr->getValueAsListInit("Predicates"), + PatternToMatch(Instr, + Instr->getValueAsListInit("Predicates"), SrcPattern, TheInst.getResultPattern(), TheInst.getImpResults(), @@ -2714,7 +2715,8 @@ AddPatternToMatch(Pattern, - PatternToMatch(CurPattern->getValueAsListInit("Predicates"), + PatternToMatch(CurPattern, + CurPattern->getValueAsListInit("Predicates"), Pattern->getTree(0), Temp.getOnlyTree(), InstImpResults, CurPattern->getValueAsInt("AddedComplexity"), @@ -3013,7 +3015,8 @@ // Otherwise, add it to the list of patterns we have. PatternsToMatch. - push_back(PatternToMatch(PatternsToMatch[i].getPredicates(), + push_back(PatternToMatch(PatternsToMatch[i].getSrcRecord(), + PatternsToMatch[i].getPredicates(), Variant, PatternsToMatch[i].getDstPattern(), PatternsToMatch[i].getDstRegs(), PatternsToMatch[i].getAddedComplexity(), Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h?rev=121196&r1=121195&r2=121196&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h (original) +++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h Tue Dec 7 17:05:49 2010 @@ -568,13 +568,14 @@ /// processed to produce isel. class PatternToMatch { public: - PatternToMatch(ListInit *preds, + PatternToMatch(Record *srcrecord, ListInit *preds, TreePatternNode *src, TreePatternNode *dst, const std::vector &dstregs, unsigned complexity, unsigned uid) - : Predicates(preds), SrcPattern(src), DstPattern(dst), + : SrcRecord(srcrecord), Predicates(preds), SrcPattern(src), DstPattern(dst), Dstregs(dstregs), AddedComplexity(complexity), ID(uid) {} + Record *SrcRecord; // Originating Record for the pattern. ListInit *Predicates; // Top level predicate conditions to match. TreePatternNode *SrcPattern; // Source pattern to match. TreePatternNode *DstPattern; // Resulting pattern. @@ -582,6 +583,7 @@ unsigned AddedComplexity; // Add to matching pattern complexity. unsigned ID; // Unique ID for the record. + Record *getSrcRecord() const { return SrcRecord; } ListInit *getPredicates() const { return Predicates; } TreePatternNode *getSrcPattern() const { return SrcPattern; } TreePatternNode *getDstPattern() const { return DstPattern; } Modified: llvm/trunk/utils/TableGen/FastISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.cpp?rev=121196&r1=121195&r2=121196&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/FastISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/FastISelEmitter.cpp Tue Dec 7 17:05:49 2010 @@ -381,14 +381,10 @@ SubRegNo, PhysRegInputs }; - // FIXME: Source location information for the diagnostic. if (SimplePatterns[Operands][OpcodeName][VT][RetVT] - .count(PredicateCheck)) { - SmallString<128> PatText; - raw_svector_ostream OS(PatText); - Pattern.SrcPattern->print(OS); - throw "Duplicate record: " + OS.str().str(); - } + .count(PredicateCheck)) + throw TGError(Pattern.getSrcRecord()->getLoc(), "Duplicate record!"); + SimplePatterns[Operands][OpcodeName][VT][RetVT][PredicateCheck] = Memo; } } From grosbach at apple.com Tue Dec 7 17:08:50 2010 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 7 Dec 2010 15:08:50 -0800 Subject: [llvm-commits] [llvm] r121166 - /llvm/trunk/utils/TableGen/FastISelEmitter.cpp In-Reply-To: <00BCCEB8-DD4F-4463-96F5-A7EE1D1CD8FE@apple.com> References: <20101207193536.8CE9E2A6C12C@llvm.org> <28CC36C7-644B-49E7-8F7C-FC6D6FAB4716@apple.com> <42E5E1F3-0FAA-48AE-A68A-5A3A5538C183@apple.com> <56C049AA-3E4C-42A9-9C53-A2D652241619@apple.com> <00BCCEB8-DD4F-4463-96F5-A7EE1D1CD8FE@apple.com> Message-ID: <1877C395-2420-48B6-BF8C-16F8EF98FBE6@apple.com> On Dec 7, 2010, at 2:44 PM, Chris Lattner wrote: >>> >>> Ok, do you have the record for the Pat pattern? If you use: >>> throw TGError(TheDef->getLoc(), "message") >>> then you'll get a caret pointing to the duplicate def in the error message. >> >> >> I couldn't find the Record for the Pat. That's definitely what I really wanted. We have have the PatternToMatch entry, and from that we get the source pattern TreePatternNode. Is there a way to go from either of those to the corresponding Record? > > No, there isn't. It seems reasonable to add a Record* to the PatternToMatch class, and pass in the record to the PatternToMatch ctor. Sounds good to me. Done in r121196. Thanks! -Jim From evan.cheng at apple.com Tue Dec 7 17:08:38 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 07 Dec 2010 23:08:38 -0000 Subject: [llvm-commits] [llvm] r121197 - in /llvm/trunk: lib/Target/ARM/ARMFrameInfo.cpp lib/Target/ARM/ARMFrameInfo.h test/CodeGen/ARM/2010-12-07-PEIBug.ll Message-ID: <20101207230838.8C7112A6C12C@llvm.org> Author: evancheng Date: Tue Dec 7 17:08:38 2010 New Revision: 121197 URL: http://llvm.org/viewvc/llvm-project?rev=121197&view=rev Log: Fix a bad prologue / epilogue codegen bug where the compiler would emit illegal vpush instructions to save / restore VFP / NEON registers like this: vpush {d8,d10,d11} vpop {d8,d10,d11} vpush and vpop do not allow gaps in the register list. rdar://8728956 Added: llvm/trunk/test/CodeGen/ARM/2010-12-07-PEIBug.ll Modified: llvm/trunk/lib/Target/ARM/ARMFrameInfo.cpp llvm/trunk/lib/Target/ARM/ARMFrameInfo.h Modified: llvm/trunk/lib/Target/ARM/ARMFrameInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFrameInfo.cpp?rev=121197&r1=121196&r2=121197&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMFrameInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMFrameInfo.cpp Tue Dec 7 17:08:38 2010 @@ -500,7 +500,7 @@ void ARMFrameInfo::emitPushInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector &CSI, - unsigned Opc, + unsigned Opc, bool NoGap, bool(*Func)(unsigned, bool)) const { MachineFunction &MF = *MBB.getParent(); const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); @@ -509,31 +509,90 @@ if (MI != MBB.end()) DL = MI->getDebugLoc(); SmallVector, 4> Regs; - for (unsigned i = CSI.size(); i != 0; --i) { - unsigned Reg = CSI[i-1].getReg(); - if (!(Func)(Reg, STI.isTargetDarwin())) continue; - - // Add the callee-saved register as live-in unless it's LR and - // @llvm.returnaddress is called. If LR is returned for @llvm.returnaddress - // then it's already added to the function and entry block live-in sets. - bool isKill = true; - if (Reg == ARM::LR) { - if (MF.getFrameInfo()->isReturnAddressTaken() && - MF.getRegInfo().isLiveIn(Reg)) - isKill = false; - } + unsigned i = CSI.size(); + while (i != 0) { + unsigned LastReg = 0; + for (; i != 0; --i) { + unsigned Reg = CSI[i-1].getReg(); + if (!(Func)(Reg, STI.isTargetDarwin())) continue; + + // Add the callee-saved register as live-in unless it's LR and + // @llvm.returnaddress is called. If LR is returned for @llvm.returnaddress + // then it's already added to the function and entry block live-in sets. + bool isKill = true; + if (Reg == ARM::LR) { + if (MF.getFrameInfo()->isReturnAddressTaken() && + MF.getRegInfo().isLiveIn(Reg)) + isKill = false; + } + + if (isKill) + MBB.addLiveIn(Reg); - if (isKill) - MBB.addLiveIn(Reg); + if (NoGap && LastReg) { + if (LastReg != Reg-1) + break; + } + LastReg = Reg; + Regs.push_back(std::make_pair(Reg, isKill)); + } - Regs.push_back(std::make_pair(Reg, isKill)); + if (!Regs.empty()) { + MachineInstrBuilder MIB = + AddDefaultPred(BuildMI(MBB, MI, DL, TII.get(Opc),ARM::SP) + .addReg(ARM::SP)); + for (unsigned i = 0, e = Regs.size(); i < e; ++i) + MIB.addReg(Regs[i].first, getKillRegState(Regs[i].second)); + Regs.clear(); + } } +} + +void ARMFrameInfo::emitPopInst(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MI, + const std::vector &CSI, + unsigned Opc, bool isVarArg, bool NoGap, + bool(*Func)(unsigned, bool)) const { + MachineFunction &MF = *MBB.getParent(); + const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); + ARMFunctionInfo *AFI = MF.getInfo(); + DebugLoc DL = MI->getDebugLoc(); + + SmallVector Regs; + unsigned i = CSI.size(); + while (i != 0) { + unsigned LastReg = 0; + bool DeleteRet = false; + for (; i != 0; --i) { + unsigned Reg = CSI[i-1].getReg(); + if (!(Func)(Reg, STI.isTargetDarwin())) continue; + + if (Reg == ARM::LR && !isVarArg) { + Reg = ARM::PC; + Opc = AFI->isThumbFunction() ? ARM::t2LDMIA_RET : ARM::LDMIA_RET; + // Fold the return instruction into the LDM. + DeleteRet = true; + } + + if (NoGap && LastReg) { + if (LastReg != Reg-1) + break; + } + LastReg = Reg; + Regs.push_back(Reg); + } - if (!Regs.empty()) { - MachineInstrBuilder MIB = AddDefaultPred(BuildMI(MBB, MI, DL, TII.get(Opc), - ARM::SP).addReg(ARM::SP)); - for (unsigned i = 0, e = Regs.size(); i < e; ++i) - MIB.addReg(Regs[i].first, getKillRegState(Regs[i].second)); + if (!Regs.empty()) { + MachineInstrBuilder MIB = + AddDefaultPred(BuildMI(MBB, MI, DL, TII.get(Opc), ARM::SP) + .addReg(ARM::SP)); + for (unsigned i = 0, e = Regs.size(); i < e; ++i) + MIB.addReg(Regs[i], getDefRegState(true)); + if (DeleteRet) + MI->eraseFromParent(); + MI = MIB; + Regs.clear(); + } } } @@ -550,49 +609,13 @@ unsigned PushOpc = AFI->isThumbFunction() ? ARM::t2STMDB_UPD : ARM::STMDB_UPD; unsigned FltOpc = ARM::VSTMDDB_UPD; - emitPushInst(MBB, MI, CSI, PushOpc, &isARMArea1Register); - emitPushInst(MBB, MI, CSI, PushOpc, &isARMArea2Register); - emitPushInst(MBB, MI, CSI, FltOpc, &isARMArea3Register); + emitPushInst(MBB, MI, CSI, PushOpc, false, &isARMArea1Register); + emitPushInst(MBB, MI, CSI, PushOpc, false, &isARMArea2Register); + emitPushInst(MBB, MI, CSI, FltOpc, true, &isARMArea3Register); return true; } -void ARMFrameInfo::emitPopInst(MachineBasicBlock &MBB, - MachineBasicBlock::iterator MI, - const std::vector &CSI, - unsigned Opc, bool isVarArg, - bool(*Func)(unsigned, bool)) const { - MachineFunction &MF = *MBB.getParent(); - const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); - ARMFunctionInfo *AFI = MF.getInfo(); - DebugLoc DL = MI->getDebugLoc(); - - bool DeleteRet = false; - SmallVector Regs; - for (unsigned i = CSI.size(); i != 0; --i) { - unsigned Reg = CSI[i-1].getReg(); - if (!(Func)(Reg, STI.isTargetDarwin())) continue; - - if (Reg == ARM::LR && !isVarArg) { - Reg = ARM::PC; - Opc = AFI->isThumbFunction() ? ARM::t2LDMIA_RET : ARM::LDMIA_RET; - // Fold the return instruction into the LDM. - DeleteRet = true; - } - - Regs.push_back(Reg); - } - - if (!Regs.empty()) { - MachineInstrBuilder MIB = AddDefaultPred(BuildMI(MBB, MI, DL, TII.get(Opc), - ARM::SP).addReg(ARM::SP)); - for (unsigned i = 0, e = Regs.size(); i < e; ++i) - MIB.addReg(Regs[i], getDefRegState(true)); - if (DeleteRet) - MI->eraseFromParent(); - } -} - bool ARMFrameInfo::restoreCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector &CSI, @@ -607,9 +630,9 @@ unsigned PopOpc = AFI->isThumbFunction() ? ARM::t2LDMIA_UPD : ARM::LDMIA_UPD; unsigned FltOpc = ARM::VLDMDIA_UPD; - emitPopInst(MBB, MI, CSI, FltOpc, isVarArg, &isARMArea3Register); - emitPopInst(MBB, MI, CSI, PopOpc, isVarArg, &isARMArea2Register); - emitPopInst(MBB, MI, CSI, PopOpc, isVarArg, &isARMArea1Register); + emitPopInst(MBB, MI, CSI, FltOpc, isVarArg, true, &isARMArea3Register); + emitPopInst(MBB, MI, CSI, PopOpc, isVarArg, false, &isARMArea2Register); + emitPopInst(MBB, MI, CSI, PopOpc, isVarArg, false, &isARMArea1Register); return true; } Modified: llvm/trunk/lib/Target/ARM/ARMFrameInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFrameInfo.h?rev=121197&r1=121196&r2=121197&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMFrameInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMFrameInfo.h Tue Dec 7 17:08:38 2010 @@ -58,12 +58,13 @@ RegScavenger *RS) const; private: - void emitPopInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, - const std::vector &CSI, unsigned Opc, - bool isVarArg, bool(*Func)(unsigned, bool)) const; void emitPushInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector &CSI, unsigned Opc, - bool(*Func)(unsigned, bool)) const; + bool NoGap, bool(*Func)(unsigned, bool)) const; + void emitPopInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, + const std::vector &CSI, unsigned Opc, + bool isVarArg, bool NoGap, + bool(*Func)(unsigned, bool)) const; }; } // End llvm namespace Added: llvm/trunk/test/CodeGen/ARM/2010-12-07-PEIBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2010-12-07-PEIBug.ll?rev=121197&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2010-12-07-PEIBug.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2010-12-07-PEIBug.ll Tue Dec 7 17:08:38 2010 @@ -0,0 +1,40 @@ +; RUN: llc < %s -mtriple=thumbv7-apple-darwin10 -mcpu=cortex-a8 | FileCheck %s +; rdar://8728956 + +define hidden void @foo() nounwind ssp { +entry: +; CHECK: foo: +; CHECK: push {r7, lr} +; CHECK-NEXT: mov r7, sp +; CHECK-NEXT: vpush {d8} +; CHECK-NEXT: vpush {d10, d11} + %tmp40 = load <4 x i8>* undef + %tmp41 = extractelement <4 x i8> %tmp40, i32 2 + %conv42 = zext i8 %tmp41 to i32 + %conv43 = sitofp i32 %conv42 to float + %div44 = fdiv float %conv43, 2.560000e+02 + %vecinit45 = insertelement <4 x float> undef, float %div44, i32 2 + %vecinit46 = insertelement <4 x float> %vecinit45, float 1.000000e+00, i32 3 + store <4 x float> %vecinit46, <4 x float>* undef + br i1 undef, label %if.then105, label %if.else109 + +if.then105: ; preds = %entry + br label %if.end114 + +if.else109: ; preds = %entry + br label %if.end114 + +if.end114: ; preds = %if.else109, %if.then105 + %call185 = call float @bar() + %vecinit186 = insertelement <4 x float> undef, float %call185, i32 1 + %call189 = call float @bar() + %vecinit190 = insertelement <4 x float> %vecinit186, float %call189, i32 2 + %vecinit191 = insertelement <4 x float> %vecinit190, float 1.000000e+00, i32 3 + store <4 x float> %vecinit191, <4 x float>* undef +; CHECK: vpop {d10, d11} +; CHECK-NEXT: vpop {d8} +; CHECK-NEXT: pop {r7, pc} + ret void +} + +declare hidden float @bar() nounwind readnone ssp From isanbard at gmail.com Tue Dec 7 17:11:00 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 07 Dec 2010 23:11:00 -0000 Subject: [llvm-commits] [llvm] r121198 - /llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Message-ID: <20101207231100.6ED262A6C12C@llvm.org> Author: void Date: Tue Dec 7 17:11:00 2010 New Revision: 121198 URL: http://llvm.org/viewvc/llvm-project?rev=121198&view=rev Log: Cleanup in the Darwin end. No functionality change. Modified: llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Modified: llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp?rev=121198&r1=121197&r2=121198&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Tue Dec 7 17:11:00 2010 @@ -165,9 +165,8 @@ void ELFARMAsmBackend::ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize, uint64_t Value) const { unsigned NumBytes = 4; // FIXME: 2 for Thumb - Value = adjustFixupValue(Fixup.getKind(), Value); - if (!Value) return; // No need to encode nothing. + if (!Value) return; // Doesn't change encoding. unsigned Offset = Fixup.getOffset(); assert(Offset % NumBytes == 0 && "Offset mod NumBytes is nonzero!"); @@ -207,6 +206,7 @@ } }; +/// getFixupKindNumBytes - The number of bytes the fixup may change. static unsigned getFixupKindNumBytes(unsigned Kind) { switch (Kind) { default: @@ -227,13 +227,15 @@ unsigned DataSize, uint64_t Value) const { unsigned NumBytes = getFixupKindNumBytes(Fixup.getKind()); Value = adjustFixupValue(Fixup.getKind(), Value); + if (!Value) return; // Doesn't change encoding. + + unsigned Offset = Fixup.getOffset(); + assert(Offset + NumBytes <= DataSize && "Invalid fixup offset!"); - assert(Fixup.getOffset() + NumBytes <= DataSize && - "Invalid fixup offset!"); // For each byte of the fragment that the fixup touches, mask in the // bits from the fixup value. for (unsigned i = 0; i != NumBytes; ++i) - Data[Fixup.getOffset() + i] |= uint8_t(Value >> (i * 8)); + Data[Offset + i] |= uint8_t((Value >> (i * 8)) & 0xff); } } // end anonymous namespace From stoklund at 2pi.dk Tue Dec 7 17:18:43 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 07 Dec 2010 23:18:43 -0000 Subject: [llvm-commits] [llvm] r121200 - /llvm/trunk/include/llvm/ADT/IntervalMap.h Message-ID: <20101207231843.4D97F2A6C12C@llvm.org> Author: stoklund Date: Tue Dec 7 17:18:43 2010 New Revision: 121200 URL: http://llvm.org/viewvc/llvm-project?rev=121200&view=rev Log: Fix begin() and end() on const IntervalMap. Modified: llvm/trunk/include/llvm/ADT/IntervalMap.h Modified: llvm/trunk/include/llvm/ADT/IntervalMap.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/IntervalMap.h?rev=121200&r1=121199&r2=121200&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/IntervalMap.h (original) +++ llvm/trunk/include/llvm/ADT/IntervalMap.h Tue Dec 7 17:18:43 2010 @@ -1119,7 +1119,7 @@ friend class iterator; const_iterator begin() const { - iterator I(*this); + const_iterator I(*this); I.goToBegin(); return I; } @@ -1131,7 +1131,7 @@ } const_iterator end() const { - iterator I(*this); + const_iterator I(*this); I.goToEnd(); return I; } @@ -1145,7 +1145,7 @@ /// find - Return an iterator pointing to the first interval ending at or /// after x, or end(). const_iterator find(KeyT x) const { - iterator I(*this); + const_iterator I(*this); I.find(x); return I; } @@ -1347,7 +1347,8 @@ // The path may be partially filled, but never between iterator calls. IntervalMapImpl::Path path; - explicit const_iterator(IntervalMap &map) : map(&map) {} + explicit const_iterator(const IntervalMap &map) : + map(const_cast(&map)) {} bool branched() const { assert(map && "Invalid iterator"); From stoklund at 2pi.dk Tue Dec 7 17:18:47 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 07 Dec 2010 23:18:47 -0000 Subject: [llvm-commits] [llvm] r121201 - in /llvm/trunk/lib/CodeGen: LiveIntervalUnion.cpp LiveIntervalUnion.h RegAllocBase.h RegAllocBasic.cpp Message-ID: <20101207231847.782142A6C12D@llvm.org> Author: stoklund Date: Tue Dec 7 17:18:47 2010 New Revision: 121201 URL: http://llvm.org/viewvc/llvm-project?rev=121201&view=rev Log: Switch LiveIntervalUnion from std::set to IntervalMap. This speeds up RegAllocBasic by 20%, not counting releaseMemory which becomes way faster. Modified: llvm/trunk/lib/CodeGen/LiveIntervalUnion.cpp llvm/trunk/lib/CodeGen/LiveIntervalUnion.h llvm/trunk/lib/CodeGen/RegAllocBase.h llvm/trunk/lib/CodeGen/RegAllocBasic.cpp Modified: llvm/trunk/lib/CodeGen/LiveIntervalUnion.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalUnion.cpp?rev=121201&r1=121200&r2=121201&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalUnion.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalUnion.cpp Tue Dec 7 17:18:47 2010 @@ -21,98 +21,50 @@ #include using namespace llvm; -// Find the first segment in the range [SegBegin,Segments.end()) that -// intersects with LS. If no intersection is found, return the first SI -// such that SI.start >= LS.End. -// -// This logic is tied to the underlying LiveSegments data structure. For now, we -// use set::upper_bound to find the nearest starting position, -// then reverse iterate to find the first overlap. -// -// Upon entry we have SegBegin.Start < LS.End -// SegBegin |--... -// \ . -// LS ...-| -// -// After set::upper_bound, we have SI.start >= LS.start: -// SI |--... -// / -// LS |--... -// -// Assuming intervals are disjoint, if an intersection exists, it must be the -// segment found or the one immediately preceeding it. We continue reverse -// iterating to return the first overlapping segment. -LiveIntervalUnion::SegmentIter -LiveIntervalUnion::upperBound(SegmentIter SegBegin, - const LiveSegment &LS) { - assert(LS.End > SegBegin->Start && "segment iterator precondition"); - - // Get the next LIU segment such that segI->Start is not less than seg.Start - // - // FIXME: Once we have a B+tree, we can make good use of SegBegin as a hint to - // upper_bound. For now, we're forced to search again from the root each time. - SegmentIter SI = Segments.upper_bound(LS); - while (SI != SegBegin) { - --SI; - if (LS.Start >= SI->End) - return ++SI; - } - return SI; -} // Merge a LiveInterval's segments. Guarantee no overlaps. -// -// After implementing B+tree, segments will be coalesced. void LiveIntervalUnion::unify(LiveInterval &VirtReg) { + if (VirtReg.empty()) + return; // Insert each of the virtual register's live segments into the map. - SegmentIter SegPos = Segments.begin(); - for (LiveInterval::iterator VirtRegI = VirtReg.begin(), - VirtRegEnd = VirtReg.end(); - VirtRegI != VirtRegEnd; ++VirtRegI ) { - - LiveSegment Seg(*VirtRegI, &VirtReg); - SegPos = Segments.insert(SegPos, Seg); - - assert(*SegPos == Seg && "need equal val for equal key"); -#ifndef NDEBUG - // Check for overlap (inductively). - if (SegPos != Segments.begin()) { - assert(llvm::prior(SegPos)->End <= Seg.Start && "overlapping segments" ); - } - SegmentIter NextPos = llvm::next(SegPos); - if (NextPos != Segments.end()) - assert(Seg.End <= NextPos->Start && "overlapping segments" ); -#endif // NDEBUG + LiveInterval::iterator RegPos = VirtReg.begin(); + LiveInterval::iterator RegEnd = VirtReg.end(); + SegmentIter SegPos = Segments.find(RegPos->start); + + for (;;) { + SegPos.insert(RegPos->start, RegPos->end, &VirtReg); + if (++RegPos == RegEnd) + return; + SegPos.advanceTo(RegPos->start); } } // Remove a live virtual register's segments from this union. -void LiveIntervalUnion::extract(const LiveInterval &VirtReg) { +void LiveIntervalUnion::extract(LiveInterval &VirtReg) { + if (VirtReg.empty()) + return; // Remove each of the virtual register's live segments from the map. - SegmentIter SegPos = Segments.begin(); - for (LiveInterval::const_iterator VirtRegI = VirtReg.begin(), - VirtRegEnd = VirtReg.end(); - VirtRegI != VirtRegEnd; ++VirtRegI) { - - LiveSegment Seg(*VirtRegI, const_cast(&VirtReg)); - SegPos = upperBound(SegPos, Seg); - assert(SegPos != Segments.end() && "missing VirtReg segment"); + LiveInterval::iterator RegPos = VirtReg.begin(); + LiveInterval::iterator RegEnd = VirtReg.end(); + SegmentIter SegPos = Segments.find(RegPos->start); + + for (;;) { + assert(SegPos.value() == &VirtReg && "Inconsistent LiveInterval"); + SegPos.erase(); + if (!SegPos.valid()) + return; + + // Skip all segments that may have been coalesced. + RegPos = VirtReg.advanceTo(RegPos, SegPos.start()); + if (RegPos == RegEnd) + return; - Segments.erase(SegPos++); + SegPos.advanceTo(RegPos->start); } } -raw_ostream& llvm::operator<<(raw_ostream& OS, const LiveSegment &LS) { - return OS << '[' << LS.Start << ',' << LS.End << ':' << - LS.VirtReg->reg << ")"; -} - -void LiveSegment::dump() const { - dbgs() << *this << "\n"; -} - void LiveIntervalUnion::print(raw_ostream &OS, const AbstractRegisterDescription *RegDesc) const { @@ -122,10 +74,9 @@ else { OS << RepReg; } - for (LiveSegments::const_iterator SI = Segments.begin(), - SegEnd = Segments.end(); SI != SegEnd; ++SI) { - dbgs() << " " << *SI; - } + for (LiveSegments::const_iterator SI = Segments.begin(); SI.valid(); ++SI) + dbgs() << " [" << SI.start() << ' ' << SI.stop() << "):%reg" + << SI.value()->reg; OS << "\n"; } @@ -136,14 +87,8 @@ #ifndef NDEBUG // Verify the live intervals in this union and add them to the visited set. void LiveIntervalUnion::verify(LiveVirtRegBitSet& VisitedVRegs) { - SegmentIter SI = Segments.begin(); - SegmentIter SegEnd = Segments.end(); - if (SI == SegEnd) return; - VisitedVRegs.set(SI->VirtReg->reg); - for (++SI; SI != SegEnd; ++SI) { - VisitedVRegs.set(SI->VirtReg->reg); - assert(llvm::prior(SI)->End <= SI->Start && "overlapping segments" ); - } + for (SegmentIter SI = Segments.begin(); SI.valid(); ++SI) + VisitedVRegs.set(SI.value()->reg); } #endif //!NDEBUG @@ -169,36 +114,30 @@ // Search until reaching the end of the LiveUnion segments. LiveInterval::iterator VirtRegEnd = VirtReg->end(); - SegmentIter LiveUnionEnd = LiveUnion->end(); - while (IR.LiveUnionI != LiveUnionEnd) { - + while (IR.LiveUnionI.valid()) { // Slowly advance the live virtual reg iterator until we surpass the next // segment in LiveUnion. // // Note: If this is ever used for coalescing of fixed registers and we have // a live vreg with thousands of segments, then change this code to use // upperBound instead. - while (IR.VirtRegI != VirtRegEnd && - IR.VirtRegI->end <= IR.LiveUnionI->Start) - ++IR.VirtRegI; + IR.VirtRegI = VirtReg->advanceTo(IR.VirtRegI, IR.LiveUnionI.start()); if (IR.VirtRegI == VirtRegEnd) break; // Retain current (nonoverlapping) LiveUnionI - // VirtRegI may have advanced far beyond LiveUnionI, - // do a fast intersection test to "catch up" - LiveSegment Seg(*IR.VirtRegI, VirtReg); - IR.LiveUnionI = LiveUnion->upperBound(IR.LiveUnionI, Seg); + // VirtRegI may have advanced far beyond LiveUnionI, catch up. + IR.LiveUnionI.advanceTo(IR.VirtRegI->start); // Check if no LiveUnionI exists with VirtRegI->Start < LiveUnionI.end - if (IR.LiveUnionI == LiveUnionEnd) + if (!IR.LiveUnionI.valid()) break; - if (IR.LiveUnionI->Start < IR.VirtRegI->end) { - assert(overlap(*IR.VirtRegI, *IR.LiveUnionI) && + if (IR.LiveUnionI.start() < IR.VirtRegI->end) { + assert(overlap(*IR.VirtRegI, IR.LiveUnionI) && "upperBound postcondition"); break; } } - if (IR.LiveUnionI == LiveUnionEnd) + if (!IR.LiveUnionI.valid()) IR.VirtRegI = VirtRegEnd; } @@ -221,18 +160,18 @@ // Advance either the VirtReg or LiveUnion segment to ensure that we visit all // unique overlapping pairs. - if (IR.VirtRegI->end < IR.LiveUnionI->End) { + if (IR.VirtRegI->end < IR.LiveUnionI.stop()) { if (++IR.VirtRegI == VirtReg->end()) return false; } else { - if (++IR.LiveUnionI == LiveUnion->end()) { + if (!(++IR.LiveUnionI).valid()) { IR.VirtRegI = VirtReg->end(); return false; } } // Short-circuit findIntersection() if possible. - if (overlap(*IR.VirtRegI, *IR.LiveUnionI)) + if (overlap(*IR.VirtRegI, IR.LiveUnionI)) return true; // Find the next intersection. @@ -261,55 +200,47 @@ collectInterferingVRegs(unsigned MaxInterferingRegs) { InterferenceResult IR = firstInterference(); LiveInterval::iterator VirtRegEnd = VirtReg->end(); - SegmentIter LiveUnionEnd = LiveUnion->end(); LiveInterval *RecentInterferingVReg = NULL; - while (IR.LiveUnionI != LiveUnionEnd) { + while (IR.LiveUnionI.valid()) { // Advance the union's iterator to reach an unseen interfering vreg. do { - if (IR.LiveUnionI->VirtReg == RecentInterferingVReg) + if (IR.LiveUnionI.value() == RecentInterferingVReg) continue; - if (!isSeenInterference(IR.LiveUnionI->VirtReg)) + if (!isSeenInterference(IR.LiveUnionI.value())) break; // Cache the most recent interfering vreg to bypass isSeenInterference. - RecentInterferingVReg = IR.LiveUnionI->VirtReg; + RecentInterferingVReg = IR.LiveUnionI.value(); - } while( ++IR.LiveUnionI != LiveUnionEnd); - if (IR.LiveUnionI == LiveUnionEnd) + } while ((++IR.LiveUnionI).valid()); + if (!IR.LiveUnionI.valid()) break; // Advance the VirtReg iterator until surpassing the next segment in // LiveUnion. - // - // Note: If this is ever used for coalescing of fixed registers and we have - // a live virtual register with thousands of segments, then use upperBound - // instead. - while (IR.VirtRegI != VirtRegEnd && - IR.VirtRegI->end <= IR.LiveUnionI->Start) - ++IR.VirtRegI; + IR.VirtRegI = VirtReg->advanceTo(IR.VirtRegI, IR.LiveUnionI.start()); if (IR.VirtRegI == VirtRegEnd) break; // Check for intersection with the union's segment. - if (overlap(*IR.VirtRegI, *IR.LiveUnionI)) { + if (overlap(*IR.VirtRegI, IR.LiveUnionI)) { - if (!IR.LiveUnionI->VirtReg->isSpillable()) + if (!IR.LiveUnionI.value()->isSpillable()) SeenUnspillableVReg = true; - InterferingVRegs.push_back(IR.LiveUnionI->VirtReg); + InterferingVRegs.push_back(IR.LiveUnionI.value()); if (InterferingVRegs.size() == MaxInterferingRegs) return MaxInterferingRegs; // Cache the most recent interfering vreg to bypass isSeenInterference. - RecentInterferingVReg = IR.LiveUnionI->VirtReg; + RecentInterferingVReg = IR.LiveUnionI.value(); ++IR.LiveUnionI; continue; } // VirtRegI may have advanced far beyond LiveUnionI, // do a fast intersection test to "catch up" - LiveSegment Seg(*IR.VirtRegI, VirtReg); - IR.LiveUnionI = LiveUnion->upperBound(IR.LiveUnionI, Seg); + IR.LiveUnionI.advanceTo(IR.VirtRegI->start); } SeenAllInterferences = true; return InterferingVRegs.size(); Modified: llvm/trunk/lib/CodeGen/LiveIntervalUnion.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalUnion.h?rev=121201&r1=121200&r2=121201&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalUnion.h (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalUnion.h Tue Dec 7 17:18:47 2010 @@ -17,8 +17,8 @@ #ifndef LLVM_CODEGEN_LIVEINTERVALUNION #define LLVM_CODEGEN_LIVEINTERVALUNION +#include "llvm/ADT/IntervalMap.h" #include "llvm/CodeGen/LiveInterval.h" -#include namespace llvm { @@ -28,58 +28,6 @@ typedef SparseBitVector<128> LiveVirtRegBitSet; #endif -/// A LiveSegment is a copy of a LiveRange object used within -/// LiveIntervalUnion. LiveSegment additionally contains a pointer to its -/// original live virtual register (LiveInterval). This allows quick lookup of -/// the live virtual register as we iterate over live segments in a union. Note -/// that LiveRange is misnamed and actually represents only a single contiguous -/// interval within a virtual register's liveness. To limit confusion, in this -/// file we refer it as a live segment. -/// -/// Note: This currently represents a half-open interval [Start,End). -/// If LiveRange is modified to represent a closed interval, so should this. -struct LiveSegment { - SlotIndex Start; - SlotIndex End; - LiveInterval *VirtReg; - - LiveSegment(const LiveRange& LR, LiveInterval *VReg) - : Start(LR.start), End(LR.end), VirtReg(VReg) {} - - bool operator==(const LiveSegment &LS) const { - return Start == LS.Start && End == LS.End && VirtReg == LS.VirtReg; - } - - bool operator!=(const LiveSegment &LS) const { - return !operator==(LS); - } - - // Order segments by starting point only--we expect them to be disjoint. - bool operator<(const LiveSegment &LS) const { return Start < LS.Start; } - - void dump() const; - void print(raw_ostream &OS) const; -}; - -inline bool operator<(SlotIndex Idx, const LiveSegment &LS) { - return Idx < LS.Start; -} - -inline bool operator<(const LiveSegment &LS, SlotIndex Idx) { - return LS.Start < Idx; -} - -/// Compare a live virtual register segment to a LiveIntervalUnion segment. -inline bool overlap(const LiveRange &VirtRegSegment, - const LiveSegment &LiveUnionSegment) { - return VirtRegSegment.start < LiveUnionSegment.End && - LiveUnionSegment.Start < VirtRegSegment.end; -} - -template <> struct isPodLike { static const bool value = true; }; - -raw_ostream& operator<<(raw_ostream& OS, const LiveSegment &LS); - /// Abstraction to provide info for the representative register. class AbstractRegisterDescription { public: @@ -87,6 +35,13 @@ virtual ~AbstractRegisterDescription() {} }; +/// Compare a live virtual register segment to a LiveIntervalUnion segment. +inline bool +overlap(const LiveRange &VRSeg, + const IntervalMap::const_iterator &LUSeg) { + return VRSeg.start < LUSeg.stop() && LUSeg.start() < VRSeg.end; +} + /// Union of live intervals that are strong candidates for coalescing into a /// single register (either physical or virtual depending on the context). We /// expect the constituent live intervals to be disjoint, although we may @@ -94,10 +49,8 @@ class LiveIntervalUnion { // A set of live virtual register segments that supports fast insertion, // intersection, and removal. - // - // FIXME: std::set is a placeholder until we decide how to - // efficiently represent it. Probably need to roll our own B-tree. - typedef std::set LiveSegments; + // Mapping SlotIndex intervals to virtual register numbers. + typedef IntervalMap LiveSegments; public: // SegmentIter can advance to the next segment ordered by starting position @@ -105,36 +58,29 @@ // to reach the current segment's containing virtual register. typedef LiveSegments::iterator SegmentIter; + // LiveIntervalUnions share an external allocator. + typedef LiveSegments::Allocator Allocator; + class InterferenceResult; class Query; private: - unsigned RepReg; // representative register number - LiveSegments Segments; // union of virtual reg segements + const unsigned RepReg; // representative register number + LiveSegments Segments; // union of virtual reg segments public: - // default ctor avoids placement new - LiveIntervalUnion() : RepReg(0) {} - - // Initialize the union by associating it with a representative register - // number. - void init(unsigned Reg) { RepReg = Reg; } + LiveIntervalUnion(unsigned r, Allocator &a) : RepReg(r), Segments(a) {} // Iterate over all segments in the union of live virtual registers ordered // by their starting position. SegmentIter begin() { return Segments.begin(); } SegmentIter end() { return Segments.end(); } - // Return an iterator to the first segment after or including begin that - // intersects with LS. - SegmentIter upperBound(SegmentIter SegBegin, const LiveSegment &LS); - // Add a live virtual register to this union and merge its segments. - // Holds a nonconst reference to the VirtReg for later maniplution. void unify(LiveInterval &VirtReg); // Remove a live virtual register's segments from this union. - void extract(const LiveInterval &VirtReg); + void extract(LiveInterval &VirtReg); void dump(const AbstractRegisterDescription *RegDesc) const; @@ -171,7 +117,7 @@ LiveInterval::iterator virtRegPos() const { return VirtRegI; } // Access the LiveUnion segment. - SegmentIter liveUnionPos() const { return LiveUnionI; } + const SegmentIter &liveUnionPos() const { return LiveUnionI; } bool operator==(const InterferenceResult &IR) const { return VirtRegI == IR.VirtRegI && LiveUnionI == IR.LiveUnionI; @@ -228,7 +174,7 @@ bool isInterference(const InterferenceResult &IR) const { if (IR.VirtRegI != VirtReg->end()) { - assert(overlap(*IR.VirtRegI, *IR.LiveUnionI) && + assert(overlap(*IR.VirtRegI, IR.LiveUnionI) && "invalid segment iterators"); return true; } Modified: llvm/trunk/lib/CodeGen/RegAllocBase.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocBase.h?rev=121201&r1=121200&r2=121201&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocBase.h (original) +++ llvm/trunk/lib/CodeGen/RegAllocBase.h Tue Dec 7 17:18:47 2010 @@ -38,6 +38,7 @@ #define LLVM_CODEGEN_REGALLOCBASE #include "llvm/ADT/OwningPtr.h" +#include "LiveIntervalUnion.h" namespace llvm { @@ -69,17 +70,19 @@ /// live range splitting. LessSpillWeightPriority is provided as a standard /// comparator, but we may add an interface to override it if necessary. class RegAllocBase { + LiveIntervalUnion::Allocator UnionAllocator; protected: // Array of LiveIntervalUnions indexed by physical register. class LiveUnionArray { unsigned NumRegs; - OwningArrayPtr Array; + LiveIntervalUnion *Array; public: - LiveUnionArray(): NumRegs(0) {} + LiveUnionArray(): NumRegs(0), Array(0) {} + ~LiveUnionArray() { clear(); } unsigned numRegs() const { return NumRegs; } - void init(unsigned NRegs); + void init(LiveIntervalUnion::Allocator &, unsigned NRegs); void clear(); Modified: llvm/trunk/lib/CodeGen/RegAllocBasic.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocBasic.cpp?rev=121201&r1=121200&r2=121201&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocBasic.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocBasic.cpp Tue Dec 7 17:18:47 2010 @@ -19,6 +19,7 @@ #include "Spiller.h" #include "VirtRegMap.h" #include "VirtRegRewriter.h" +#include "llvm/ADT/OwningPtr.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Function.h" #include "llvm/PassAnalysisSupport.h" @@ -44,6 +45,7 @@ #include #include +#include using namespace llvm; @@ -198,12 +200,13 @@ //===----------------------------------------------------------------------===// // Instantiate a LiveIntervalUnion for each physical register. -void RegAllocBase::LiveUnionArray::init(unsigned NRegs) { - Array.reset(new LiveIntervalUnion[NRegs]); +void RegAllocBase::LiveUnionArray::init(LiveIntervalUnion::Allocator &allocator, + unsigned NRegs) { NumRegs = NRegs; - for (unsigned RegNum = 0; RegNum < NRegs; ++RegNum) { - Array[RegNum].init(RegNum); - } + Array = + static_cast(malloc(sizeof(LiveIntervalUnion)*NRegs)); + for (unsigned r = 0; r != NRegs; ++r) + new(Array + r) LiveIntervalUnion(r, allocator); } void RegAllocBase::init(const TargetRegisterInfo &tri, VirtRegMap &vrm, @@ -211,14 +214,19 @@ TRI = &tri; VRM = &vrm; LIS = &lis; - PhysReg2LiveUnion.init(TRI->getNumRegs()); + PhysReg2LiveUnion.init(UnionAllocator, TRI->getNumRegs()); // Cache an interferece query for each physical reg Queries.reset(new LiveIntervalUnion::Query[PhysReg2LiveUnion.numRegs()]); } void RegAllocBase::LiveUnionArray::clear() { + if (!Array) + return; + for (unsigned r = 0; r != NumRegs; ++r) + Array[r].~LiveIntervalUnion(); + free(Array); NumRegs = 0; - Array.reset(0); + Array = 0; } void RegAllocBase::releaseMemory() { @@ -427,7 +435,7 @@ return PhysReg; } LiveInterval *interferingVirtReg = - Queries[interfReg].firstInterference().liveUnionPos()->VirtReg; + Queries[interfReg].firstInterference().liveUnionPos().value(); // The current VirtReg must either spillable, or one of its interferences // must have less spill weight. @@ -474,7 +482,7 @@ // Find the set of basic blocks which this range is live into... liveInMBBs.clear(); - if (!LIS->findLiveInMBBs(SI->Start, SI->End, liveInMBBs)) continue; + if (!LIS->findLiveInMBBs(SI.start(), SI.stop(), liveInMBBs)) continue; // And add the physreg for this interval to their live-in sets. for (MBBVec::iterator I = liveInMBBs.begin(), E = liveInMBBs.end(); From dpatel at apple.com Tue Dec 7 17:25:47 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 07 Dec 2010 23:25:47 -0000 Subject: [llvm-commits] [llvm] r121205 - in /llvm/trunk: include/llvm/Analysis/DIBuilder.h include/llvm/Analysis/DebugInfo.h lib/Analysis/DIBuilder.cpp lib/Analysis/DebugInfo.cpp Message-ID: <20101207232547.5838E2A6C12C@llvm.org> Author: dpatel Date: Tue Dec 7 17:25:47 2010 New Revision: 121205 URL: http://llvm.org/viewvc/llvm-project?rev=121205&view=rev Log: Add support to create variables, structs etc.. using DIBuilder. This is still work in progress. Modified: llvm/trunk/include/llvm/Analysis/DIBuilder.h llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/lib/Analysis/DIBuilder.cpp llvm/trunk/lib/Analysis/DebugInfo.cpp Modified: llvm/trunk/include/llvm/Analysis/DIBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DIBuilder.h?rev=121205&r1=121204&r2=121205&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DIBuilder.h (original) +++ llvm/trunk/include/llvm/Analysis/DIBuilder.h Tue Dec 7 17:25:47 2010 @@ -19,7 +19,11 @@ #include "llvm/ADT/StringRef.h" namespace llvm { + class BasicBlock; + class Instruction; + class Function; class Module; + class Value; class LLVMContext; class MDNode; class StringRef; @@ -27,6 +31,10 @@ class DIFile; class DIEnumerator; class DIType; + class DIArray; + class DIGlobalVariable; + class DINameSpace; + class DIVariable; class DIBuilder { private: @@ -34,6 +42,9 @@ LLVMContext & VMContext; MDNode *TheCU; + Function *DeclareFn; // llvm.dbg.declare + Function *ValueFn; // llvm.dbg.value + DIBuilder(const DIBuilder &); // DO NOT IMPLEMENT void operator=(const DIBuilder &); // DO NOT IMPLEMENT @@ -82,31 +93,161 @@ DIType CreateQualifiedType(unsigned Tag, DIType FromTy); /// CreatePointerType - Create debugging information entry for a pointer. + /// @param PointeeTy Type pointed by this pointer. + /// @param SizeInBits Size. + /// @param AlignInBits Alignment. (optional) + /// @param Name Pointer type name. (optional) DIType CreatePointerType(DIType PointeeTy, uint64_t SizeInBits, - uint64_t AlignInBits = 0, StringRef Name = StringRef()); + uint64_t AlignInBits = 0, + StringRef Name = StringRef()); - /// CreateReferenceType - Create debugging information entry for a reference. + /// CreateReferenceType - Create debugging information entry for a c++ + /// style reference. DIType CreateReferenceType(DIType RTy); /// CreateTypedef - Create debugging information entry for a typedef. - DIType CreateTypedef(DIType Ty, StringRef Name, DIFile F, unsigned LineNo); + /// @param Ty Original type. + /// @param Name Typedef name. + /// @param File File where this type is defined. + /// @param LineNo Line number. + DIType CreateTypedef(DIType Ty, StringRef Name, DIFile File, + unsigned LineNo); /// CreateFriend - Create debugging information entry for a 'friend'. DIType CreateFriend(DIType Ty, DIType FriendTy); /// CreateInheritance - Create debugging information entry to establish /// inheritance relationship between two types. + /// @param Ty Original type. + /// @param BaseTy Base type. Ty is inherits from base. + /// @param BaseOffset Base offset. + /// @param Flags Flags to describe inheritance attribute, + /// e.g. private DIType CreateInheritance(DIType Ty, DIType BaseTy, uint64_t BaseOffset, unsigned Flags); /// CreateMemberType - Create debugging information entry for a member. - DIType CreateMemberType(DIDescriptor Context, StringRef Name, DIFile F, - unsigned LineNumber, uint64_t SizeInBits, + /// @param Name Member name. + /// @param File File where this member is defined. + /// @param LineNo Line number. + /// @param SizeInBits Member size. + /// @param AlignInBits Member alignment. + /// @param OffsetInBits Member offset. + /// @param Flags Flags to encode member attribute, e.g. private + /// @param Ty Parent type. + DIType CreateMemberType(StringRef Name, DIFile File, + unsigned LineNo, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, DIType Ty); + /// CreateStructType - Create debugging information entry for a struct. + DIType CreateStructType(DIDescriptor Context, StringRef Name, DIFile F, + unsigned LineNumber, uint64_t SizeInBits, + uint64_t AlignInBits, unsigned Flags, + DIArray Elements, unsigned RunTimeLang = 0); + /// CreateArtificialType - Create a new DIType with "artificial" flag set. DIType CreateArtificialType(DIType Ty); + + /// CreateTemporaryType - Create a temporary forward-declared type. + DIType CreateTemporaryType(); + DIType CreateTemporaryType(DIFile F); + + /// GetOrCreateArray - Get a DIArray, create one if required. + DIArray GetOrCreateArray(Value *const *Elements, unsigned NumElements); + + /// CreateGlobalVariable - Create a new descriptor for the specified global. + /// @param Name Name of the variable. + /// @param LinakgeName Mangled name of the variable. + /// @param File File where this variable is defined. + /// @param LineNo Line number. + /// @param Ty Variable Type. + /// @param isLocalToUnit Boolean flag indicate whether this variable is + /// externally visible or not. + /// @param Val llvm::Value of the variable. + DIGlobalVariable + CreateGlobalVariable(StringRef Name, + StringRef LinkageName, DIFile File, unsigned LineNo, + DIType Ty, bool isLocalToUnit, llvm::Value *Val); + + + /// CreateStaticVariable - Create a new descriptor for the specified + /// variable. + /// @param Conext Variable scope. + /// @param Name Name of the variable. + /// @param LinakgeName Mangled name of the variable. + /// @param File File where this variable is defined. + /// @param LineNo Line number. + /// @param Ty Variable Type. + /// @param isLocalToUnit Boolean flag indicate whether this variable is + /// externally visible or not. + /// @param Val llvm::Value of the variable. + DIGlobalVariable + CreateStaticVariable(DIDescriptor Context, StringRef Name, + StringRef LinkageName, DIFile File, unsigned LineNo, + DIType Ty, bool isLocalToUnit, llvm::Value *Val); + + + /// CreateComplexVariable - Create a new descriptor for the specified + /// variable which has a complex address expression for its address. + /// @param Tag Dwarf TAG. Usually DW_TAG_auto_variable or + /// DW_TAG_arg_variable. + /// @param Scope Variable scope. + /// @param Name Variable name. + /// @param File File where this variable is defined. + /// @param LineNo Line number. + /// @param Ty Variable Type + /// @param Addr A pointer to a vector of complex address operations. + /// @param NumAddr Num of address operations in the vector. + DIVariable CreateComplexVariable(unsigned Tag, DIDescriptor Scope, + StringRef Name, DIFile F, unsigned LineNo, + DIType Ty, Value *const *Addr, + unsigned NumAddr); + + + /// CreateNameSpace - This creates new descriptor for a namespace + /// with the specified parent scope. + /// @param Scope Namespace scope + /// @param Name Name of this namespace + /// @param File Source file + /// @param LineNo Line number + DINameSpace CreateNameSpace(DIDescriptor Scope, StringRef Name, + DIFile File, unsigned LineNo); + + + /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. + /// @param Storage llvm::Value of the variable + /// @param VarInfo Variable's debug info descriptor. + /// @param InsertAtEnd Location for the new intrinsic. + Instruction *InsertDeclare(llvm::Value *Storage, DIVariable VarInfo, + BasicBlock *InsertAtEnd); + + /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. + /// @param Storage llvm::Value of the variable + /// @param VarInfo Variable's debug info descriptor. + /// @param InsertBefore Location for the new intrinsic. + Instruction *InsertDeclare(llvm::Value *Storage, DIVariable VarInfo, + Instruction *InsertBefore); + + + /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. + /// @param Val llvm::Value of the variable + /// @param Offset Offset + /// @param VarInfo Variable's debug info descriptor. + /// @param InsertAtEnd Location for the new intrinsic. + Instruction *InsertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset, + DIVariable VarInfo, + BasicBlock *InsertAtEnd); + + /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. + /// @param Val llvm::Value of the variable + /// @param Offset Offset + /// @param VarInfo Variable's debug info descriptor. + /// @param InsertBefore Location for the new intrinsic. + Instruction *InsertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset, + DIVariable VarInfo, + Instruction *InsertBefore); + }; } // end namespace llvm Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=121205&r1=121204&r2=121205&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Tue Dec 7 17:25:47 2010 @@ -715,6 +715,7 @@ /// CreateTemporaryType - Create a temporary forward-declared type. DIType CreateTemporaryType(); + DIType CreateTemporaryType(DIFile F); /// CreateArtificialType - Create a new DIType with "artificial" flag set. DIType CreateArtificialType(DIType Ty); Modified: llvm/trunk/lib/Analysis/DIBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DIBuilder.cpp?rev=121205&r1=121204&r2=121205&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DIBuilder.cpp (original) +++ llvm/trunk/lib/Analysis/DIBuilder.cpp Tue Dec 7 17:25:47 2010 @@ -28,7 +28,7 @@ return ConstantInt::get(Type::getInt32Ty(VMContext), Tag | LLVMDebugVersion); } DIBuilder::DIBuilder(Module &m) - : M(m), VMContext(M.getContext()), TheCU(0) {} + : M(m), VMContext(M.getContext()), TheCU(0), DeclareFn(0), ValueFn(0) {} /// CreateCompileUnit - A CompileUnit provides an anchor for all debugging /// information generated during this instance of compilation. @@ -214,17 +214,17 @@ } /// CreateMemberType - Create debugging information entry for a member. -DIType DIBuilder::CreateMemberType(DIDescriptor Context, StringRef Name, - DIFile F, unsigned LineNumber, +DIType DIBuilder::CreateMemberType(StringRef Name, + DIFile File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, DIType Ty) { // TAG_member is encoded in DIDerivedType format. Value *Elts[] = { GetTagConstant(VMContext, dwarf::DW_TAG_member), - Context, + File, // Or TheCU ? Ty ? MDString::get(VMContext, Name), - F, + File, ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits), ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits), @@ -235,6 +235,30 @@ return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts))); } +/// CreateStructType - Create debugging information entry for a struct. +DIType DIBuilder::CreateStructType(DIDescriptor Context, StringRef Name, DIFile F, + unsigned LineNumber, uint64_t SizeInBits, + uint64_t AlignInBits, unsigned Flags, + DIArray Elements, unsigned RunTimeLang) { + // TAG_structure_type is encoded in DICompositeType format. + Value *Elts[] = { + GetTagConstant(VMContext, dwarf::DW_TAG_structure_type), + Context, + MDString::get(VMContext, Name), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), + ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits), + ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits), + ConstantInt::get(Type::getInt32Ty(VMContext), Flags), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + Elements, + ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeLang), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + }; + return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts))); +} + + /// CreateArtificialType - Create a new DIType with "artificial" flag set. DIType DIBuilder::CreateArtificialType(DIType Ty) { if (Ty.isArtificial()) @@ -258,3 +282,183 @@ return DIType(MDNode::get(VMContext, Elts.data(), Elts.size())); } + +/// CreateTemporaryType - Create a temporary forward-declared type. +DIType DIBuilder::CreateTemporaryType() { + // Give the temporary MDNode a tag. It doesn't matter what tag we + // use here as long as DIType accepts it. + Value *Elts[] = { GetTagConstant(VMContext, DW_TAG_base_type) }; + MDNode *Node = MDNode::getTemporary(VMContext, Elts, array_lengthof(Elts)); + return DIType(Node); +} + +/// CreateTemporaryType - Create a temporary forward-declared type. +DIType DIBuilder::CreateTemporaryType(DIFile F) { + // Give the temporary MDNode a tag. It doesn't matter what tag we + // use here as long as DIType accepts it. + Value *Elts[] = { + GetTagConstant(VMContext, DW_TAG_base_type), + F.getCompileUnit(), + NULL, + F + }; + MDNode *Node = MDNode::getTemporary(VMContext, Elts, array_lengthof(Elts)); + return DIType(Node); +} + +/// GetOrCreateArray - Get a DIArray, create one if required. +DIArray DIBuilder::GetOrCreateArray(Value *const *Elements, unsigned NumElements) { + if (NumElements == 0) { + Value *Null = llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)); + return DIArray(MDNode::get(VMContext, &Null, 1)); + } + return DIArray(MDNode::get(VMContext, Elements, NumElements)); +} + +/// CreateGlobalVariable - Create a new descriptor for the specified global. +DIGlobalVariable DIBuilder:: +CreateGlobalVariable(StringRef Name, + StringRef LinkageName, DIFile F, unsigned LineNumber, + DIType Ty, bool isLocalToUnit, llvm::Value *Val) { + Value *Elts[] = { + GetTagConstant(VMContext, dwarf::DW_TAG_variable), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + TheCU, + MDString::get(VMContext, Name), + MDString::get(VMContext, Name), + MDString::get(VMContext, LinkageName), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), + Ty, + ConstantInt::get(Type::getInt32Ty(VMContext), isLocalToUnit), + ConstantInt::get(Type::getInt32Ty(VMContext), 1), /* isDefinition*/ + Val + }; + MDNode *Node = MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)); + // Create a named metadata so that we do not lose this mdnode. + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.gv"); + NMD->addOperand(Node); + return DIGlobalVariable(Node); +} + +/// CreateStaticVariable - Create a new descriptor for the specified static +/// variable. +DIGlobalVariable DIBuilder:: +CreateStaticVariable(DIDescriptor Context, StringRef Name, + StringRef LinkageName, DIFile F, unsigned LineNumber, + DIType Ty, bool isLocalToUnit, llvm::Value *Val) { + Value *Elts[] = { + GetTagConstant(VMContext, dwarf::DW_TAG_variable), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + Context, + MDString::get(VMContext, Name), + MDString::get(VMContext, Name), + MDString::get(VMContext, LinkageName), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), + Ty, + ConstantInt::get(Type::getInt32Ty(VMContext), isLocalToUnit), + ConstantInt::get(Type::getInt32Ty(VMContext), 1), /* isDefinition*/ + Val + }; + MDNode *Node = MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)); + // Create a named metadata so that we do not lose this mdnode. + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.gv"); + NMD->addOperand(Node); + return DIGlobalVariable(Node); +} + +/// CreateComplexVariable - Create a new descriptor for the specified variable +/// which has a complex address expression for its address. +DIVariable DIBuilder::CreateComplexVariable(unsigned Tag, DIDescriptor Scope, + StringRef Name, DIFile F, + unsigned LineNo, + DIType Ty, Value *const *Addr, + unsigned NumAddr) { + SmallVector Elts; + Elts.push_back(GetTagConstant(VMContext, Tag)); + Elts.push_back(Scope); + Elts.push_back(MDString::get(VMContext, Name)); + Elts.push_back(F); + Elts.push_back(ConstantInt::get(Type::getInt32Ty(VMContext), LineNo)); + Elts.push_back(Ty); + Elts.append(Addr, Addr+NumAddr); + + return DIVariable(MDNode::get(VMContext, Elts.data(), Elts.size())); +} + + +/// CreateNameSpace - This creates new descriptor for a namespace +/// with the specified parent scope. +DINameSpace DIBuilder::CreateNameSpace(DIDescriptor Scope, StringRef Name, + DIFile File, unsigned LineNo) { + Value *Elts[] = { + GetTagConstant(VMContext, dwarf::DW_TAG_namespace), + Scope, + MDString::get(VMContext, Name), + File, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNo) + }; + return DINameSpace(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts))); +} + +/// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. +Instruction *DIBuilder::InsertDeclare(Value *Storage, DIVariable VarInfo, + Instruction *InsertBefore) { + assert(Storage && "no storage passed to dbg.declare"); + assert(VarInfo.Verify() && "empty DIVariable passed to dbg.declare"); + if (!DeclareFn) + DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); + + Value *Args[] = { MDNode::get(Storage->getContext(), &Storage, 1), VarInfo }; + return CallInst::Create(DeclareFn, Args, Args+2, "", InsertBefore); +} + +/// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. +Instruction *DIBuilder::InsertDeclare(Value *Storage, DIVariable VarInfo, + BasicBlock *InsertAtEnd) { + assert(Storage && "no storage passed to dbg.declare"); + assert(VarInfo.Verify() && "invalid DIVariable passed to dbg.declare"); + if (!DeclareFn) + DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); + + Value *Args[] = { MDNode::get(Storage->getContext(), &Storage, 1), VarInfo }; + + // If this block already has a terminator then insert this intrinsic + // before the terminator. + if (TerminatorInst *T = InsertAtEnd->getTerminator()) + return CallInst::Create(DeclareFn, Args, Args+2, "", T); + else + return CallInst::Create(DeclareFn, Args, Args+2, "", InsertAtEnd); +} + +/// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. +Instruction *DIBuilder::InsertDbgValueIntrinsic(Value *V, uint64_t Offset, + DIVariable VarInfo, + Instruction *InsertBefore) { + assert(V && "no value passed to dbg.value"); + assert(VarInfo.Verify() && "invalid DIVariable passed to dbg.value"); + if (!ValueFn) + ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value); + + Value *Args[] = { MDNode::get(V->getContext(), &V, 1), + ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset), + VarInfo }; + return CallInst::Create(ValueFn, Args, Args+3, "", InsertBefore); +} + +/// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call. +Instruction *DIBuilder::InsertDbgValueIntrinsic(Value *V, uint64_t Offset, + DIVariable VarInfo, + BasicBlock *InsertAtEnd) { + assert(V && "no value passed to dbg.value"); + assert(VarInfo.Verify() && "invalid DIVariable passed to dbg.value"); + if (!ValueFn) + ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value); + + Value *Args[] = { MDNode::get(V->getContext(), &V, 1), + ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset), + VarInfo }; + return CallInst::Create(ValueFn, Args, Args+3, "", InsertAtEnd); +} + Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=121205&r1=121204&r2=121205&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Tue Dec 7 17:25:47 2010 @@ -308,7 +308,8 @@ unsigned Tag = getTag(); if (!isBasicType() && Tag != dwarf::DW_TAG_const_type && Tag != dwarf::DW_TAG_volatile_type && Tag != dwarf::DW_TAG_pointer_type && - Tag != dwarf::DW_TAG_restrict_type && getFilename().empty()) + Tag != dwarf::DW_TAG_reference_type && Tag != dwarf::DW_TAG_restrict_type + && getFilename().empty()) return false; return true; } @@ -960,7 +961,6 @@ return DICompositeType(Node); } - /// CreateTemporaryType - Create a temporary forward-declared type. DIType DIFactory::CreateTemporaryType() { // Give the temporary MDNode a tag. It doesn't matter what tag we @@ -972,6 +972,19 @@ return DIType(Node); } +/// CreateTemporaryType - Create a temporary forward-declared type. +DIType DIFactory::CreateTemporaryType(DIFile F) { + // Give the temporary MDNode a tag. It doesn't matter what tag we + // use here as long as DIType accepts it. + Value *Elts[] = { + GetTagConstant(DW_TAG_base_type), + F.getCompileUnit(), + NULL, + F + }; + MDNode *Node = MDNode::getTemporary(VMContext, Elts, array_lengthof(Elts)); + return DIType(Node); +} /// CreateCompositeType - Create a composite type like array, struct, etc. DICompositeType DIFactory::CreateCompositeTypeEx(unsigned Tag, From matthewbg at google.com Tue Dec 7 17:26:21 2010 From: matthewbg at google.com (Matt Beaumont-Gay) Date: Tue, 07 Dec 2010 23:26:21 -0000 Subject: [llvm-commits] [llvm] r121206 - /llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp Message-ID: <20101207232621.970CC2A6C12C@llvm.org> Author: matthewbg Date: Tue Dec 7 17:26:21 2010 New Revision: 121206 URL: http://llvm.org/viewvc/llvm-project?rev=121206&view=rev Log: Fix a warning about a variable which is only used in an assertion. Modified: llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp?rev=121206&r1=121205&r2=121206&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp Tue Dec 7 17:26:21 2010 @@ -667,9 +667,9 @@ SmallVectorImpl &Fixups) const { // [SP, #imm] // {7-0} = imm8 - const MCOperand &MO = MI.getOperand(OpIdx); const MCOperand &MO1 = MI.getOperand(OpIdx + 1); - assert (MO.getReg() == ARM::SP && "Unexpected base register!"); + assert (MI.getOperand(OpIdx).getReg() == ARM::SP && + "Unexpected base register!"); // The immediate is already shifted for the implicit zeroes, so no change // here. return MO1.getImm() & 0xff; From rafael.espindola at gmail.com Tue Dec 7 17:32:26 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 07 Dec 2010 23:32:26 -0000 Subject: [llvm-commits] [llvm] r121207 - in /llvm/trunk: include/llvm/MC/MCAsmLayout.h include/llvm/MC/MCAssembler.h lib/MC/MCAssembler.cpp Message-ID: <20101207233226.6581F2A6C12C@llvm.org> Author: rafael Date: Tue Dec 7 17:32:26 2010 New Revision: 121207 URL: http://llvm.org/viewvc/llvm-project?rev=121207&view=rev Log: Layout each section independently. With the testcase in PR8711: before: 4 assembler - Number of assembler layout and relaxation steps 78563 assembler - Number of emitted assembler fragments 8693904 assembler - Number of emitted object file bytes 271223 assembler - Number of evaluated fixups 330771677 assembler - Number of fragment layouts 5958 assembler - Number of relaxed instructions 2508361 mcexpr - Number of MCExpr evaluations real 0m26.123s user 0m25.694s sys 0m0.388s after: 4 assembler - Number of assembler layout and relaxation steps 78563 assembler - Number of emitted assembler fragments 8693904 assembler - Number of emitted object file bytes 271223 assembler - Number of evaluated fixups 231507 assembler - Number of fragment layouts 5958 assembler - Number of relaxed instructions 2508361 mcexpr - Number of MCExpr evaluations real 0m2.500s user 0m2.113s sys 0m0.273s And yes, the outputs are identical :-) Modified: llvm/trunk/include/llvm/MC/MCAsmLayout.h llvm/trunk/include/llvm/MC/MCAssembler.h llvm/trunk/lib/MC/MCAssembler.cpp Modified: llvm/trunk/include/llvm/MC/MCAsmLayout.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmLayout.h?rev=121207&r1=121206&r2=121207&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAsmLayout.h (original) +++ llvm/trunk/include/llvm/MC/MCAsmLayout.h Tue Dec 7 17:32:26 2010 @@ -39,13 +39,12 @@ /// The last fragment which was layed out, or 0 if nothing has been layed /// out. Fragments are always layed out in order, so all fragments with a /// lower ordinal will be up to date. - mutable MCFragment *LastValidFragment; + mutable DenseMap LastValidFragment; /// \brief Make sure that the layout for the given fragment is valid, lazily /// computing it if necessary. void EnsureValid(const MCFragment *F) const; - bool isSectionUpToDate(const MCSectionData *SD) const; bool isFragmentUpToDate(const MCFragment *F) const; public: @@ -58,9 +57,6 @@ /// fragments size should have already been updated. void Invalidate(MCFragment *F); - /// \brief Perform a full layout. - void LayoutFile(); - /// \brief Perform layout for a single fragment, assuming that the previous /// fragment has already been layed out correctly, and the parent section has /// been initialized. Modified: llvm/trunk/include/llvm/MC/MCAssembler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAssembler.h?rev=121207&r1=121206&r2=121207&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAssembler.h (original) +++ llvm/trunk/include/llvm/MC/MCAssembler.h Tue Dec 7 17:32:26 2010 @@ -78,8 +78,7 @@ /// initialized. uint64_t EffectiveSize; - /// LayoutOrder - The global layout order of this fragment. This is the index - /// across all fragments in the file, not just within the section. + /// LayoutOrder - The layout order of this fragment. unsigned LayoutOrder; /// @} Modified: llvm/trunk/lib/MC/MCAssembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=121207&r1=121206&r2=121207&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAssembler.cpp (original) +++ llvm/trunk/lib/MC/MCAssembler.cpp Tue Dec 7 17:32:26 2010 @@ -49,7 +49,7 @@ /* *** */ MCAsmLayout::MCAsmLayout(MCAssembler &Asm) - : Assembler(Asm), LastValidFragment(0) + : Assembler(Asm), LastValidFragment() { // Compute the section layout order. Virtual sections must go last. for (MCAssembler::iterator it = Asm.begin(), ie = Asm.end(); it != ie; ++it) @@ -60,21 +60,13 @@ SectionOrder.push_back(&*it); } -bool MCAsmLayout::isSectionUpToDate(const MCSectionData *SD) const { - // The first section is always up-to-date. - unsigned Index = SD->getLayoutOrder(); - if (!Index) - return true; - - // Otherwise, sections are always implicitly computed when the preceeding - // fragment is layed out. - const MCSectionData *Prev = getSectionOrder()[Index - 1]; - return isFragmentUpToDate(&(Prev->getFragmentList().back())); -} - bool MCAsmLayout::isFragmentUpToDate(const MCFragment *F) const { - return (LastValidFragment && - F->getLayoutOrder() <= LastValidFragment->getLayoutOrder()); + const MCSectionData &SD = *F->getParent(); + const MCFragment *LastValid = LastValidFragment.lookup(&SD); + if (!LastValid) + return false; + assert(LastValid->getParent() == F->getParent()); + return F->getLayoutOrder() <= LastValid->getLayoutOrder(); } void MCAsmLayout::Invalidate(MCFragment *F) { @@ -84,31 +76,23 @@ // Otherwise, reset the last valid fragment to the predecessor of the // invalidated fragment. - LastValidFragment = F->getPrevNode(); - if (!LastValidFragment) { - unsigned Index = F->getParent()->getLayoutOrder(); - if (Index != 0) { - MCSectionData *Prev = getSectionOrder()[Index - 1]; - LastValidFragment = &(Prev->getFragmentList().back()); - } - } + const MCSectionData &SD = *F->getParent(); + LastValidFragment[&SD] = F->getPrevNode(); } void MCAsmLayout::EnsureValid(const MCFragment *F) const { + MCSectionData &SD = *F->getParent(); + + MCFragment *Cur = LastValidFragment[&SD]; + if (!Cur) + Cur = &*SD.begin(); + else + Cur = Cur->getNextNode(); + // Advance the layout position until the fragment is up-to-date. while (!isFragmentUpToDate(F)) { - // Advance to the next fragment. - MCFragment *Cur = LastValidFragment; - if (Cur) - Cur = Cur->getNextNode(); - if (!Cur) { - unsigned NextIndex = 0; - if (LastValidFragment) - NextIndex = LastValidFragment->getParent()->getLayoutOrder() + 1; - Cur = SectionOrder[NextIndex]->begin(); - } - const_cast(this)->LayoutFragment(Cur); + Cur = Cur->getNextNode(); } } @@ -311,21 +295,11 @@ return 0; } -void MCAsmLayout::LayoutFile() { - // Initialize the first section and set the valid fragment layout point. All - // actual layout computations are done lazily. - LastValidFragment = 0; -} - void MCAsmLayout::LayoutFragment(MCFragment *F) { MCFragment *Prev = F->getPrevNode(); // We should never try to recompute something which is up-to-date. assert(!isFragmentUpToDate(F) && "Attempt to recompute up-to-date fragment!"); - // We should never try to compute the fragment layout if the section isn't - // up-to-date. - assert(isSectionUpToDate(F->getParent()) && - "Attempt to compute fragment before it's section!"); // We should never try to compute the fragment layout if it's predecessor // isn't up-to-date. assert((!Prev || isFragmentUpToDate(Prev)) && @@ -340,7 +314,7 @@ F->Offset = Offset; F->EffectiveSize = getAssembler().ComputeFragmentSize(*F, F->Offset); - LastValidFragment = F; + LastValidFragment[F->getParent()] = F; } /// WriteFragmentData - Write the \arg F data to the output file. @@ -541,11 +515,11 @@ } // Assign layout order indices to sections and fragments. - unsigned FragmentIndex = 0; for (unsigned i = 0, e = Layout.getSectionOrder().size(); i != e; ++i) { MCSectionData *SD = Layout.getSectionOrder()[i]; SD->setLayoutOrder(i); + unsigned FragmentIndex = 0; for (MCSectionData::iterator it2 = SD->begin(), ie2 = SD->end(); it2 != ie2; ++it2) it2->setLayoutOrder(FragmentIndex++); @@ -743,9 +717,6 @@ MCAsmLayout &Layout) { ++stats::RelaxationSteps; - // Layout the sections in order. - Layout.LayoutFile(); - // Scan for fragments that need relaxation. bool WasRelaxed = false; for (iterator it = begin(), ie = end(); it != ie; ++it) { @@ -784,16 +755,10 @@ } void MCAssembler::FinishLayout(MCAsmLayout &Layout) { - // Lower out any instruction fragments, to simplify the fixup application and - // output. - // - // FIXME-PERF: We don't have to do this, but the assumption is that it is - // cheap (we will mostly end up eliminating fragments and appending on to data - // fragments), so the extra complexity downstream isn't worth it. Evaluate - // this assumption. - // The layout is done. Mark every fragment as valid. - Layout.getFragmentOffset(&*Layout.getSectionOrder().back()->rbegin()); + for (unsigned int i = 0, n = Layout.getSectionOrder().size(); i != n; ++i) { + Layout.getFragmentOffset(&*Layout.getSectionOrder()[i]->rbegin()); + } } // Debugging methods From echristo at apple.com Tue Dec 7 17:44:04 2010 From: echristo at apple.com (Eric Christopher) Date: Tue, 7 Dec 2010 15:44:04 -0800 Subject: [llvm-commits] [llvm] r121197 - in /llvm/trunk: lib/Target/ARM/ARMFrameInfo.cpp lib/Target/ARM/ARMFrameInfo.h test/CodeGen/ARM/2010-12-07-PEIBug.ll In-Reply-To: <20101207230838.8C7112A6C12C@llvm.org> References: <20101207230838.8C7112A6C12C@llvm.org> Message-ID: On Dec 7, 2010, at 3:08 PM, Evan Cheng wrote: > Fix a bad prologue / epilogue codegen bug where the compiler would emit illegal > vpush instructions to save / restore VFP / NEON registers like this: > vpush {d8,d10,d11} > vpop {d8,d10,d11} > > vpush and vpop do not allow gaps in the register list. > rdar://8728956 > Thanks for fixing this! This was somewhat hard to follow, I had to read it a couple of times to make sure I knew the looping order. It could use a couple of comments as to what's going on, something like: "If NoGap is enabled then split up the pushes to ensure that the registers are adjacent, e.g. vpush {d8, d10, d11} becomes the two pushes vpush {d8 } ; vpush { d10, d11 }" Might be clearer what's going on if we just did a second pass through the Regs vector after grabbing all of the matching registers? while (!Regs.empty()) ? and then just pop regs as we iterate through? Thoughts? -eric -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20101207/df975cb4/attachment.html From evan.cheng at apple.com Tue Dec 7 17:47:26 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 7 Dec 2010 15:47:26 -0800 Subject: [llvm-commits] [llvm] r120960 - in /llvm/trunk: lib/Target/ARM/ test/CodeGen/ARM/ In-Reply-To: References: <20101205220416.D17E72A6C12C@llvm.org> <4CFD24D3.1090801@arm.com> Message-ID: Question: are vldr.f64 / vstr.f64 considered NEON or VFP instructions? I believe they are executed in NEON unit (in RunFast mode) but the current scheduling itinerary models they as being executed in VFP pipeline. Evan On Dec 6, 2010, at 12:42 PM, Anton Korobeynikov wrote: > Renato, > >> You probably want to avoid mixing NEON with VFP instructions, is there a >> hazard recognizer for that, too? > This is currently modelled on A9 via the special FU acquisition policies. > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State University -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20101207/39d41327/attachment.html From bob.wilson at apple.com Tue Dec 7 17:53:32 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 07 Dec 2010 23:53:32 -0000 Subject: [llvm-commits] [llvm] r121208 - in /llvm/trunk/utils/TableGen: NeonEmitter.cpp NeonEmitter.h Message-ID: <20101207235332.46FA32A6C12C@llvm.org> Author: bwilson Date: Tue Dec 7 17:53:32 2010 New Revision: 121208 URL: http://llvm.org/viewvc/llvm-project?rev=121208&view=rev Log: Emit vmovl intrinsics first in the arm_neon.h header so they can be used in the implementations of other intrinsics. Modified: llvm/trunk/utils/TableGen/NeonEmitter.cpp llvm/trunk/utils/TableGen/NeonEmitter.h Modified: llvm/trunk/utils/TableGen/NeonEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.cpp?rev=121208&r1=121207&r2=121208&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/NeonEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/NeonEmitter.cpp Tue Dec 7 17:53:32 2010 @@ -1040,47 +1040,58 @@ std::vector RV = Records.getAllDerivedDefinitions("Inst"); + // Emit vmovl intrinsics first so they can be used by other intrinsics. + emitIntrinsic(OS, Records.getDef("VMOVL")); + // Unique the return+pattern types, and assign them. for (unsigned i = 0, e = RV.size(); i != e; ++i) { Record *R = RV[i]; - std::string name = R->getValueAsString("Name"); - std::string Proto = R->getValueAsString("Prototype"); - std::string Types = R->getValueAsString("Types"); - - SmallVector TypeVec; - ParseTypes(R, Types, TypeVec); - - OpKind kind = OpMap[R->getValueAsDef("Operand")->getName()]; + if (R->getName() != "VMOVL") + emitIntrinsic(OS, R); + } - ClassKind classKind = ClassNone; - if (R->getSuperClasses().size() >= 2) - classKind = ClassMap[R->getSuperClasses()[1]]; - if (classKind == ClassNone && kind == OpNone) - throw TGError(R->getLoc(), "Builtin has no class kind"); + OS << "#undef __ai\n\n"; + OS << "#endif /* __ARM_NEON_H */\n"; +} - for (unsigned ti = 0, te = TypeVec.size(); ti != te; ++ti) { - if (kind == OpReinterpret) { - bool outQuad = false; - bool dummy = false; - (void)ClassifyType(TypeVec[ti], outQuad, dummy, dummy); - for (unsigned srcti = 0, srcte = TypeVec.size(); - srcti != srcte; ++srcti) { - bool inQuad = false; - (void)ClassifyType(TypeVec[srcti], inQuad, dummy, dummy); - if (srcti == ti || inQuad != outQuad) - continue; - OS << GenIntrinsic(name, Proto, TypeVec[ti], TypeVec[srcti], - OpCast, ClassS); - } - } else { - OS << GenIntrinsic(name, Proto, TypeVec[ti], TypeVec[ti], - kind, classKind); +/// emitIntrinsic - Write out the arm_neon.h header file definitions for the +/// intrinsics specified by record R. +void NeonEmitter::emitIntrinsic(raw_ostream &OS, Record *R) { + std::string name = R->getValueAsString("Name"); + std::string Proto = R->getValueAsString("Prototype"); + std::string Types = R->getValueAsString("Types"); + + SmallVector TypeVec; + ParseTypes(R, Types, TypeVec); + + OpKind kind = OpMap[R->getValueAsDef("Operand")->getName()]; + + ClassKind classKind = ClassNone; + if (R->getSuperClasses().size() >= 2) + classKind = ClassMap[R->getSuperClasses()[1]]; + if (classKind == ClassNone && kind == OpNone) + throw TGError(R->getLoc(), "Builtin has no class kind"); + + for (unsigned ti = 0, te = TypeVec.size(); ti != te; ++ti) { + if (kind == OpReinterpret) { + bool outQuad = false; + bool dummy = false; + (void)ClassifyType(TypeVec[ti], outQuad, dummy, dummy); + for (unsigned srcti = 0, srcte = TypeVec.size(); + srcti != srcte; ++srcti) { + bool inQuad = false; + (void)ClassifyType(TypeVec[srcti], inQuad, dummy, dummy); + if (srcti == ti || inQuad != outQuad) + continue; + OS << GenIntrinsic(name, Proto, TypeVec[ti], TypeVec[srcti], + OpCast, ClassS); } + } else { + OS << GenIntrinsic(name, Proto, TypeVec[ti], TypeVec[ti], + kind, classKind); } - OS << "\n"; } - OS << "#undef __ai\n\n"; - OS << "#endif /* __ARM_NEON_H */\n"; + OS << "\n"; } static unsigned RangeFromType(StringRef typestr) { Modified: llvm/trunk/utils/TableGen/NeonEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.h?rev=121208&r1=121207&r2=121208&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/NeonEmitter.h (original) +++ llvm/trunk/utils/TableGen/NeonEmitter.h Tue Dec 7 17:53:32 2010 @@ -131,6 +131,9 @@ // runHeader - Emit all the __builtin prototypes used in arm_neon.h void runHeader(raw_ostream &o); + + private: + void emitIntrinsic(raw_ostream &OS, Record *R); }; } // End llvm namespace From bob.wilson at apple.com Tue Dec 7 17:53:38 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 07 Dec 2010 23:53:38 -0000 Subject: [llvm-commits] [llvm] r121209 - in /llvm/trunk/utils/TableGen: NeonEmitter.cpp NeonEmitter.h Message-ID: <20101207235338.0A64B2A6C12D@llvm.org> Author: bwilson Date: Tue Dec 7 17:53:37 2010 New Revision: 121209 URL: http://llvm.org/viewvc/llvm-project?rev=121209&view=rev Log: Add operators for vmlal{_n,_lane} and vmlsl{_n,_lane} so they can be implemented without clang builtins. Modified: llvm/trunk/utils/TableGen/NeonEmitter.cpp llvm/trunk/utils/TableGen/NeonEmitter.h Modified: llvm/trunk/utils/TableGen/NeonEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.cpp?rev=121209&r1=121208&r2=121209&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/NeonEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/NeonEmitter.cpp Tue Dec 7 17:53:37 2010 @@ -603,8 +603,7 @@ break; case OpMullLane: s += Extend(proto, typestr, "__a") + " * " + - Extend(proto, typestr, - SplatLane(nElts, "__b", "__c")) + ";"; + Extend(proto, typestr, SplatLane(nElts, "__b", "__c")) + ";"; break; case OpMull: s += Extend(proto, typestr, "__a") + " * " + @@ -619,6 +618,18 @@ case OpMla: s += "__a + (__b * __c);"; break; + case OpMlalN: + s += "__a + (" + Extend(proto, typestr, "__b") + " * " + + Extend(proto, typestr, Duplicate(nElts, typestr, "__c")) + ");"; + break; + case OpMlalLane: + s += "__a + (" + Extend(proto, typestr, "__b") + " * " + + Extend(proto, typestr, SplatLane(nElts, "__c", "__d")) + ");"; + break; + case OpMlal: + s += "__a + (" + Extend(proto, typestr, "__b") + " * " + + Extend(proto, typestr, "__c") + ");"; + break; case OpMlsN: s += "__a - (__b * " + Duplicate(nElts, typestr, "__c") + ");"; break; @@ -628,6 +639,18 @@ case OpMls: s += "__a - (__b * __c);"; break; + case OpMlslN: + s += "__a - (" + Extend(proto, typestr, "__b") + " * " + + Extend(proto, typestr, Duplicate(nElts, typestr, "__c")) + ");"; + break; + case OpMlslLane: + s += "__a - (" + Extend(proto, typestr, "__b") + " * " + + Extend(proto, typestr, SplatLane(nElts, "__c", "__d")) + ");"; + break; + case OpMlsl: + s += "__a - (" + Extend(proto, typestr, "__b") + " * " + + Extend(proto, typestr, "__c") + ");"; + break; case OpEq: s += "(" + ts + ")(__a == __b);"; break; Modified: llvm/trunk/utils/TableGen/NeonEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.h?rev=121209&r1=121208&r2=121209&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/NeonEmitter.h (original) +++ llvm/trunk/utils/TableGen/NeonEmitter.h Tue Dec 7 17:53:37 2010 @@ -28,15 +28,21 @@ OpMul, OpMull, OpMla, + OpMlal, OpMls, + OpMlsl, OpMulN, OpMullN, OpMlaN, OpMlsN, + OpMlalN, + OpMlslN, OpMulLane, OpMullLane, OpMlaLane, OpMlsLane, + OpMlalLane, + OpMlslLane, OpEq, OpGe, OpLe, @@ -85,15 +91,21 @@ OpMap["OP_MUL"] = OpMul; OpMap["OP_MULL"] = OpMull; OpMap["OP_MLA"] = OpMla; + OpMap["OP_MLAL"] = OpMlal; OpMap["OP_MLS"] = OpMls; + OpMap["OP_MLSL"] = OpMlsl; OpMap["OP_MUL_N"] = OpMulN; OpMap["OP_MULL_N"]= OpMullN; OpMap["OP_MLA_N"] = OpMlaN; OpMap["OP_MLS_N"] = OpMlsN; + OpMap["OP_MLAL_N"] = OpMlalN; + OpMap["OP_MLSL_N"] = OpMlslN; OpMap["OP_MUL_LN"]= OpMulLane; OpMap["OP_MULL_LN"] = OpMullLane; OpMap["OP_MLA_LN"]= OpMlaLane; OpMap["OP_MLS_LN"]= OpMlsLane; + OpMap["OP_MLAL_LN"] = OpMlalLane; + OpMap["OP_MLSL_LN"] = OpMlslLane; OpMap["OP_EQ"] = OpEq; OpMap["OP_GE"] = OpGe; OpMap["OP_LE"] = OpLe; From dpatel at apple.com Tue Dec 7 17:58:00 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 07 Dec 2010 23:58:00 -0000 Subject: [llvm-commits] [llvm] r121211 - in /llvm/trunk: include/llvm/Analysis/DIBuilder.h lib/Analysis/DIBuilder.cpp Message-ID: <20101207235800.A20B92A6C12C@llvm.org> Author: dpatel Date: Tue Dec 7 17:58:00 2010 New Revision: 121211 URL: http://llvm.org/viewvc/llvm-project?rev=121211&view=rev Log: Add support to create local variable's debug info. Modified: llvm/trunk/include/llvm/Analysis/DIBuilder.h llvm/trunk/lib/Analysis/DIBuilder.cpp Modified: llvm/trunk/include/llvm/Analysis/DIBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DIBuilder.h?rev=121211&r1=121210&r2=121211&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DIBuilder.h (original) +++ llvm/trunk/include/llvm/Analysis/DIBuilder.h Tue Dec 7 17:58:00 2010 @@ -188,6 +188,25 @@ DIType Ty, bool isLocalToUnit, llvm::Value *Val); + /// CreateLocalVariable - Create a new descriptor for the specified + /// local variable. + /// @param Tag Dwarf TAG. Usually DW_TAG_auto_variable or + /// DW_TAG_arg_variable. + /// @param Scope Variable scope. + /// @param Name Variable name. + /// @param File File where this variable is defined. + /// @param LineNo Line number. + /// @param Ty Variable Type + /// @param AlwaysPreserve Boolean. Set to true if debug info for this + /// variable should be preserved in optimized build. + /// @param Flags Flags, e.g. artificial variable. + DIVariable CreateLocalVariable(unsigned Tag, DIDescriptor Scope, + StringRef Name, + DIFile File, unsigned LineNo, + DIType Ty, bool AlwaysPreserve = false, + unsigned Flags = 0); + + /// CreateComplexVariable - Create a new descriptor for the specified /// variable which has a complex address expression for its address. /// @param Tag Dwarf TAG. Usually DW_TAG_auto_variable or Modified: llvm/trunk/lib/Analysis/DIBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DIBuilder.cpp?rev=121211&r1=121210&r2=121211&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DIBuilder.cpp (original) +++ llvm/trunk/lib/Analysis/DIBuilder.cpp Tue Dec 7 17:58:00 2010 @@ -27,6 +27,7 @@ "Tag too large for debug encoding!"); return ConstantInt::get(Type::getInt32Ty(VMContext), Tag | LLVMDebugVersion); } + DIBuilder::DIBuilder(Module &m) : M(m), VMContext(M.getContext()), TheCU(0), DeclareFn(0), ValueFn(0) {} @@ -368,6 +369,38 @@ return DIGlobalVariable(Node); } +/// CreateVariable - Create a new descriptor for the specified variable. +DIVariable DIBuilder::CreateLocalVariable(unsigned Tag, DIDescriptor Scope, + StringRef Name, DIFile File, + unsigned LineNo, DIType Ty, + bool AlwaysPreserve, unsigned Flags) { + Value *Elts[] = { + GetTagConstant(VMContext, Tag), + Scope, + MDString::get(VMContext, Name), + File, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), + Ty, + ConstantInt::get(Type::getInt32Ty(VMContext), Flags) + }; + MDNode *Node = MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)); + if (AlwaysPreserve) { + // The optimizer may remove local variable. If there is an interest + // to preserve variable info in such situation then stash it in a + // named mdnode. + DISubprogram Fn(getDISubprogram(Scope)); + StringRef FName = "fn"; + if (Fn.getFunction()) + FName = Fn.getFunction()->getName(); + char One = '\1'; + if (FName.startswith(StringRef(&One, 1))) + FName = FName.substr(1); + NamedMDNode *FnLocals = getOrInsertFnSpecificMDNode(M, FName); + FnLocals->addOperand(Node); + } + return DIVariable(Node); +} + /// CreateComplexVariable - Create a new descriptor for the specified variable /// which has a complex address expression for its address. DIVariable DIBuilder::CreateComplexVariable(unsigned Tag, DIDescriptor Scope, From dpatel at apple.com Tue Dec 7 18:06:22 2010 From: dpatel at apple.com (Devang Patel) Date: Wed, 08 Dec 2010 00:06:22 -0000 Subject: [llvm-commits] [llvm] r121212 - in /llvm/trunk: include/llvm/Analysis/DIBuilder.h lib/Analysis/DIBuilder.cpp Message-ID: <20101208000622.D8CA92A6C12C@llvm.org> Author: dpatel Date: Tue Dec 7 18:06:22 2010 New Revision: 121212 URL: http://llvm.org/viewvc/llvm-project?rev=121212&view=rev Log: Global variable does not need linkage name. Modified: llvm/trunk/include/llvm/Analysis/DIBuilder.h llvm/trunk/lib/Analysis/DIBuilder.cpp Modified: llvm/trunk/include/llvm/Analysis/DIBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DIBuilder.h?rev=121212&r1=121211&r2=121212&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DIBuilder.h (original) +++ llvm/trunk/include/llvm/Analysis/DIBuilder.h Tue Dec 7 18:06:22 2010 @@ -158,7 +158,6 @@ /// CreateGlobalVariable - Create a new descriptor for the specified global. /// @param Name Name of the variable. - /// @param LinakgeName Mangled name of the variable. /// @param File File where this variable is defined. /// @param LineNo Line number. /// @param Ty Variable Type. @@ -166,8 +165,7 @@ /// externally visible or not. /// @param Val llvm::Value of the variable. DIGlobalVariable - CreateGlobalVariable(StringRef Name, - StringRef LinkageName, DIFile File, unsigned LineNo, + CreateGlobalVariable(StringRef Name, DIFile File, unsigned LineNo, DIType Ty, bool isLocalToUnit, llvm::Value *Val); Modified: llvm/trunk/lib/Analysis/DIBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DIBuilder.cpp?rev=121212&r1=121211&r2=121212&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DIBuilder.cpp (original) +++ llvm/trunk/lib/Analysis/DIBuilder.cpp Tue Dec 7 18:06:22 2010 @@ -318,8 +318,7 @@ /// CreateGlobalVariable - Create a new descriptor for the specified global. DIGlobalVariable DIBuilder:: -CreateGlobalVariable(StringRef Name, - StringRef LinkageName, DIFile F, unsigned LineNumber, +CreateGlobalVariable(StringRef Name, DIFile F, unsigned LineNumber, DIType Ty, bool isLocalToUnit, llvm::Value *Val) { Value *Elts[] = { GetTagConstant(VMContext, dwarf::DW_TAG_variable), @@ -327,7 +326,7 @@ TheCU, MDString::get(VMContext, Name), MDString::get(VMContext, Name), - MDString::get(VMContext, LinkageName), + MDString::get(VMContext, Name), F, ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), Ty, From bob.wilson at apple.com Tue Dec 7 18:14:04 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 08 Dec 2010 00:14:04 -0000 Subject: [llvm-commits] [llvm] r121213 - in /llvm/trunk/utils/TableGen: NeonEmitter.cpp NeonEmitter.h Message-ID: <20101208001404.F2E1A2A6C12C@llvm.org> Author: bwilson Date: Tue Dec 7 18:14:04 2010 New Revision: 121213 URL: http://llvm.org/viewvc/llvm-project?rev=121213&view=rev Log: Add operators for vadd[lw] and vsub[lw] so they can be implemented without clang builtins. Modified: llvm/trunk/utils/TableGen/NeonEmitter.cpp llvm/trunk/utils/TableGen/NeonEmitter.h Modified: llvm/trunk/utils/TableGen/NeonEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.cpp?rev=121213&r1=121212&r2=121213&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/NeonEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/NeonEmitter.cpp Tue Dec 7 18:14:04 2010 @@ -584,9 +584,23 @@ case OpAdd: s += "__a + __b;"; break; + case OpAddl: + s += Extend(proto, typestr, "__a") + " + " + + Extend(proto, typestr, "__b") + ";"; + break; + case OpAddw: + s += "__a + " + Extend(proto, typestr, "__b") + ";"; + break; case OpSub: s += "__a - __b;"; break; + case OpSubl: + s += Extend(proto, typestr, "__a") + " - " + + Extend(proto, typestr, "__b") + ";"; + break; + case OpSubw: + s += "__a - " + Extend(proto, typestr, "__b") + ";"; + break; case OpMulN: s += "__a * " + Duplicate(nElts, typestr, "__b") + ";"; break; Modified: llvm/trunk/utils/TableGen/NeonEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.h?rev=121213&r1=121212&r2=121213&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/NeonEmitter.h (original) +++ llvm/trunk/utils/TableGen/NeonEmitter.h Tue Dec 7 18:14:04 2010 @@ -24,7 +24,11 @@ enum OpKind { OpNone, OpAdd, + OpAddl, + OpAddw, OpSub, + OpSubl, + OpSubw, OpMul, OpMull, OpMla, @@ -87,7 +91,11 @@ NeonEmitter(RecordKeeper &R) : Records(R) { OpMap["OP_NONE"] = OpNone; OpMap["OP_ADD"] = OpAdd; + OpMap["OP_ADDL"] = OpAddl; + OpMap["OP_ADDW"] = OpAddw; OpMap["OP_SUB"] = OpSub; + OpMap["OP_SUBL"] = OpSubl; + OpMap["OP_SUBW"] = OpSubw; OpMap["OP_MUL"] = OpMul; OpMap["OP_MULL"] = OpMull; OpMap["OP_MLA"] = OpMla; From resistor at mac.com Tue Dec 7 18:18:36 2010 From: resistor at mac.com (Owen Anderson) Date: Wed, 08 Dec 2010 00:18:36 -0000 Subject: [llvm-commits] [llvm] r121215 - in /llvm/trunk/lib/Target/ARM: ARMAsmBackend.cpp ARMFixupKinds.h ARMMCCodeEmitter.cpp Message-ID: <20101208001836.679D12A6C12C@llvm.org> Author: resistor Date: Tue Dec 7 18:18:36 2010 New Revision: 121215 URL: http://llvm.org/viewvc/llvm-project?rev=121215&view=rev Log: VLDR fixups need special handling under Thumb. While the encoding is the same, the order of the bytes in the data stream is flipped around. Modified: llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp llvm/trunk/lib/Target/ARM/ARMFixupKinds.h llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp?rev=121215&r1=121214&r2=121215&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Tue Dec 7 18:18:36 2010 @@ -115,6 +115,7 @@ Binary = ((Binary & 0x7ff) << 16) | (Binary >> 11); return Binary; } + case ARM::fixup_t2_pcrel_10: case ARM::fixup_arm_pcrel_10: { // Offset by 8 just as above. Value = Value - 8; @@ -127,6 +128,16 @@ Value >>= 2; assert ((Value < 256) && "Out of range pc-relative fixup value!"); Value |= isAdd << 23; + + // Same addressing mode as fixup_arm_pcrel_10, but with the bytes reordered. + if (Kind == ARM::fixup_t2_pcrel_10) { + uint64_t swapped = (Value & 0x00FF0000) >> 16; + swapped |= (Value & 0xFF000000) >> 16; + swapped |= (Value & 0x000000FF) << 16; + swapped |= (Value & 0x0000FF00) << 16; + return swapped; + } + return Value; } } @@ -218,6 +229,7 @@ case ARM::fixup_arm_adr_pcrel_12: case ARM::fixup_arm_branch: return 3; + case ARM::fixup_t2_pcrel_10: case ARM::fixup_arm_thumb_bl: return 4; } Modified: llvm/trunk/lib/Target/ARM/ARMFixupKinds.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFixupKinds.h?rev=121215&r1=121214&r2=121215&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMFixupKinds.h (original) +++ llvm/trunk/lib/Target/ARM/ARMFixupKinds.h Tue Dec 7 18:18:36 2010 @@ -19,9 +19,12 @@ // addresses fixup_arm_ldst_pcrel_12 = FirstTargetFixupKind, // fixup_arm_pcrel_10 - 10-bit PC relative relocation for symbol addresses - // used in VFP and Thumb2 instructions where the lower 2 bits are not encoded + // used in VFP instructions where the lower 2 bits are not encoded // (so it's encoded as an 8-bit immediate). fixup_arm_pcrel_10, + // fixup_t2_pcrel_10 - Equivalent to fixup_arm_pcrel_10, accounting for + // the byteswapped encoding of Thumb2 instructions. + fixup_t2_pcrel_10, // fixup_arm_adr_pcrel_12 - 12-bit PC relative relocation for the ADR // instruction. fixup_arm_adr_pcrel_12, Modified: llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp?rev=121215&r1=121214&r2=121215&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp Tue Dec 7 18:18:36 2010 @@ -48,6 +48,7 @@ // name off bits flags { "fixup_arm_ldst_pcrel_12", 1, 24, MCFixupKindInfo::FKF_IsPCRel }, { "fixup_arm_pcrel_10", 1, 24, MCFixupKindInfo::FKF_IsPCRel }, + { "fixup_t2_pcrel_10", 0, 32, MCFixupKindInfo::FKF_IsPCRel }, { "fixup_arm_adr_pcrel_12", 1, 24, MCFixupKindInfo::FKF_IsPCRel }, { "fixup_arm_branch", 1, 24, MCFixupKindInfo::FKF_IsPCRel }, { "fixup_arm_thumb_bl", 0, 32, MCFixupKindInfo::FKF_IsPCRel }, @@ -737,7 +738,12 @@ assert(MO.isExpr() && "Unexpected machine operand type!"); const MCExpr *Expr = MO.getExpr(); - MCFixupKind Kind = MCFixupKind(ARM::fixup_arm_pcrel_10); + MCFixupKind Kind; + const ARMSubtarget &Subtarget = TM.getSubtarget(); + if (Subtarget.isThumb2()) + Kind = MCFixupKind(ARM::fixup_t2_pcrel_10); + else + Kind = MCFixupKind(ARM::fixup_arm_pcrel_10); Fixups.push_back(MCFixup::Create(0, Expr, Kind)); ++MCNumCPRelocations; From resistor at mac.com Tue Dec 7 18:21:33 2010 From: resistor at mac.com (Owen Anderson) Date: Wed, 08 Dec 2010 00:21:33 -0000 Subject: [llvm-commits] [llvm] r121216 - /llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Message-ID: <20101208002133.DBE6F2A6C12C@llvm.org> Author: resistor Date: Tue Dec 7 18:21:33 2010 New Revision: 121216 URL: http://llvm.org/viewvc/llvm-project?rev=121216&view=rev Log: Simplify the byte reordering logic slightly. Modified: llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Modified: llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp?rev=121216&r1=121215&r2=121216&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Tue Dec 7 18:21:33 2010 @@ -131,10 +131,8 @@ // Same addressing mode as fixup_arm_pcrel_10, but with the bytes reordered. if (Kind == ARM::fixup_t2_pcrel_10) { - uint64_t swapped = (Value & 0x00FF0000) >> 16; - swapped |= (Value & 0xFF000000) >> 16; - swapped |= (Value & 0x000000FF) << 16; - swapped |= (Value & 0x0000FF00) << 16; + uint64_t swapped = (Value & 0xFFFF0000) >> 16; + swapped |= (Value & 0x0000FFFF) << 16; return swapped; } From stoklund at 2pi.dk Tue Dec 7 19:06:06 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 08 Dec 2010 01:06:06 -0000 Subject: [llvm-commits] [llvm] r121217 - in /llvm/trunk/lib/CodeGen: LiveIntervalUnion.h RegAllocBase.h RegAllocBasic.cpp Message-ID: <20101208010606.62F0F2A6C12C@llvm.org> Author: stoklund Date: Tue Dec 7 19:06:06 2010 New Revision: 121217 URL: http://llvm.org/viewvc/llvm-project?rev=121217&view=rev Log: Move RABasic::addMBBLiveIns to the base class, it is generally useful. Minor optimization to the use of IntervalMap iterators. They are fairly heavyweight, so prefer SI.valid() over SI != end(). Modified: llvm/trunk/lib/CodeGen/LiveIntervalUnion.h llvm/trunk/lib/CodeGen/RegAllocBase.h llvm/trunk/lib/CodeGen/RegAllocBasic.cpp Modified: llvm/trunk/lib/CodeGen/LiveIntervalUnion.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalUnion.h?rev=121217&r1=121216&r2=121217&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalUnion.h (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalUnion.h Tue Dec 7 19:06:06 2010 @@ -75,6 +75,7 @@ // by their starting position. SegmentIter begin() { return Segments.begin(); } SegmentIter end() { return Segments.end(); } + bool empty() { return Segments.empty(); } // Add a live virtual register to this union and merge its segments. void unify(LiveInterval &VirtReg); Modified: llvm/trunk/lib/CodeGen/RegAllocBase.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocBase.h?rev=121217&r1=121216&r2=121217&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocBase.h (original) +++ llvm/trunk/lib/CodeGen/RegAllocBase.h Tue Dec 7 19:06:06 2010 @@ -149,6 +149,9 @@ bool spillInterferences(LiveInterval &VirtReg, unsigned PhysReg, SmallVectorImpl &SplitVRegs); + /// addMBBLiveIns - Add physreg liveins to basic blocks. + void addMBBLiveIns(MachineFunction *); + #ifndef NDEBUG // Verify each LiveIntervalUnion. void verify(); Modified: llvm/trunk/lib/CodeGen/RegAllocBasic.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocBasic.cpp?rev=121217&r1=121216&r2=121217&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocBasic.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocBasic.cpp Tue Dec 7 19:06:06 2010 @@ -110,9 +110,6 @@ virtual bool runOnMachineFunction(MachineFunction &mf); static char ID; - -private: - void addMBBLiveIns(); }; char RABasic::ID = 0; @@ -395,6 +392,36 @@ return true; } +// Add newly allocated physical registers to the MBB live in sets. +void RegAllocBase::addMBBLiveIns(MachineFunction *MF) { + typedef SmallVector MBBVec; + MBBVec liveInMBBs; + MachineBasicBlock &entryMBB = *MF->begin(); + + for (unsigned PhysReg = 0; PhysReg < PhysReg2LiveUnion.numRegs(); ++PhysReg) { + LiveIntervalUnion &LiveUnion = PhysReg2LiveUnion[PhysReg]; + if (LiveUnion.empty()) + continue; + for (LiveIntervalUnion::SegmentIter SI = LiveUnion.begin(); SI.valid(); + ++SI) { + + // Find the set of basic blocks which this range is live into... + liveInMBBs.clear(); + if (!LIS->findLiveInMBBs(SI.start(), SI.stop(), liveInMBBs)) continue; + + // And add the physreg for this interval to their live-in sets. + for (MBBVec::iterator I = liveInMBBs.begin(), E = liveInMBBs.end(); + I != E; ++I) { + MachineBasicBlock *MBB = *I; + if (MBB == &entryMBB) continue; + if (MBB->isLiveIn(PhysReg)) continue; + MBB->addLiveIn(PhysReg); + } + } + } +} + + //===----------------------------------------------------------------------===// // RABasic Implementation //===----------------------------------------------------------------------===// @@ -467,35 +494,6 @@ return 0; } -// Add newly allocated physical registers to the MBB live in sets. -void RABasic::addMBBLiveIns() { - typedef SmallVector MBBVec; - MBBVec liveInMBBs; - MachineBasicBlock &entryMBB = *MF->begin(); - - for (unsigned PhysReg = 0; PhysReg < PhysReg2LiveUnion.numRegs(); ++PhysReg) { - LiveIntervalUnion &LiveUnion = PhysReg2LiveUnion[PhysReg]; - - for (LiveIntervalUnion::SegmentIter SI = LiveUnion.begin(), - SegEnd = LiveUnion.end(); - SI != SegEnd; ++SI) { - - // Find the set of basic blocks which this range is live into... - liveInMBBs.clear(); - if (!LIS->findLiveInMBBs(SI.start(), SI.stop(), liveInMBBs)) continue; - - // And add the physreg for this interval to their live-in sets. - for (MBBVec::iterator I = liveInMBBs.begin(), E = liveInMBBs.end(); - I != E; ++I) { - MachineBasicBlock *MBB = *I; - if (MBB == &entryMBB) continue; - if (MBB->isLiveIn(PhysReg)) continue; - MBB->addLiveIn(PhysReg); - } - } - } -} - bool RABasic::runOnMachineFunction(MachineFunction &mf) { DEBUG(dbgs() << "********** BASIC REGISTER ALLOCATION **********\n" << "********** Function: " @@ -517,7 +515,7 @@ allocatePhysRegs(); - addMBBLiveIns(); + addMBBLiveIns(MF); // Diagnostic output before rewriting DEBUG(dbgs() << "Post alloc VirtRegMap:\n" << *VRM << "\n"); From grosbach at apple.com Tue Dec 7 19:16:55 2010 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 08 Dec 2010 01:16:55 -0000 Subject: [llvm-commits] [llvm] r121219 - in /llvm/trunk: include/llvm/Target/TargetAsmBackend.h lib/MC/MCMachOStreamer.cpp lib/Target/ARM/ARMAsmBackend.cpp Message-ID: <20101208011655.59A7E2A6C12C@llvm.org> Author: grosbach Date: Tue Dec 7 19:16:55 2010 New Revision: 121219 URL: http://llvm.org/viewvc/llvm-project?rev=121219&view=rev Log: Let target asm backends see assembler flags as they go by. Use that to handle thumb vs. arm mode differences in WriteNopData(). Modified: llvm/trunk/include/llvm/Target/TargetAsmBackend.h llvm/trunk/lib/MC/MCMachOStreamer.cpp llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Modified: llvm/trunk/include/llvm/Target/TargetAsmBackend.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmBackend.h?rev=121219&r1=121218&r2=121219&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetAsmBackend.h (original) +++ llvm/trunk/include/llvm/Target/TargetAsmBackend.h Tue Dec 7 19:16:55 2010 @@ -10,6 +10,7 @@ #ifndef LLVM_TARGET_TARGETASMBACKEND_H #define LLVM_TARGET_TARGETASMBACKEND_H +#include "llvm/MC/MCDirectives.h" #include "llvm/Support/DataTypes.h" namespace llvm { @@ -109,6 +110,10 @@ /// /// \return - True on success. virtual bool WriteNopData(uint64_t Count, MCObjectWriter *OW) const = 0; + + /// HandleAssemblerFlag - Handle any target-specific assembler flags. + /// By default, do nothing. + virtual void HandleAssemblerFlag(MCAssemblerFlag Flag) {} }; } // End llvm namespace Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=121219&r1=121218&r2=121219&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Tue Dec 7 19:16:55 2010 @@ -124,6 +124,9 @@ } void MCMachOStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) { + // Let the target do whatever target specific stuff it needs to do. + getAssembler().getBackend().HandleAssemblerFlag(Flag); + // Do any generic stuff we need to do. switch (Flag) { case MCAF_SyntaxUnified: return; // no-op here. case MCAF_Code16: return; // no-op here. Modified: llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp?rev=121219&r1=121218&r2=121219&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Tue Dec 7 19:16:55 2010 @@ -12,6 +12,7 @@ #include "ARMFixupKinds.h" #include "llvm/ADT/Twine.h" #include "llvm/MC/MCAssembler.h" +#include "llvm/MC/MCDirectives.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCObjectFormat.h" #include "llvm/MC/MCObjectWriter.h" @@ -27,6 +28,7 @@ namespace { class ARMAsmBackend : public TargetAsmBackend { + bool isThumbMode; // Currently emitting Thumb code. public: ARMAsmBackend(const Target &T) : TargetAsmBackend() {} @@ -36,9 +38,21 @@ bool WriteNopData(uint64_t Count, MCObjectWriter *OW) const; - unsigned getPointerSize() const { - return 4; + void HandleAssemblerFlag(MCAssemblerFlag Flag) { + switch (Flag) { + default: break; + case MCAF_Code16: + setIsThumb(true); + break; + case MCAF_Code32: + setIsThumb(false); + break; + } } + + unsigned getPointerSize() const { return 4; } + bool isThumb() const { return isThumbMode; } + void setIsThumb(bool it) { isThumbMode = it; } }; } // end anonymous namespace @@ -53,10 +67,19 @@ } bool ARMAsmBackend::WriteNopData(uint64_t Count, MCObjectWriter *OW) const { - // FIXME: Zero fill for now. That's not right, but at least will get the - // section size right. + if (isThumb()) { + assert (((Count & 1) == 0) && "Unaligned Nop data fragment!"); + // FIXME: 0xbf00 is the ARMv7 value. For v6 and before, we'll need to + // use 0x46c0 (which is a 'mov r8, r8' insn). + Count /= 2; + for (uint64_t i = 0; i != Count; ++i) + OW->Write16(0xbf00); + return true; + } + // ARM mode + Count /= 4; for (uint64_t i = 0; i != Count; ++i) - OW->Write8(0); + OW->Write32(0xe1a00000); return true; } From echristo at apple.com Tue Dec 7 19:23:44 2010 From: echristo at apple.com (Eric Christopher) Date: Tue, 7 Dec 2010 17:23:44 -0800 Subject: [llvm-commits] [llvm] r121197 - in /llvm/trunk: lib/Target/ARM/ARMFrameInfo.cpp lib/Target/ARM/ARMFrameInfo.h test/CodeGen/ARM/2010-12-07-PEIBug.ll In-Reply-To: References: <20101207230838.8C7112A6C12C@llvm.org> Message-ID: On Dec 7, 2010, at 3:44 PM, Eric Christopher wrote: > > On Dec 7, 2010, at 3:08 PM, Evan Cheng wrote: > >> Fix a bad prologue / epilogue codegen bug where the compiler would emit illegal >> vpush instructions to save / restore VFP / NEON registers like this: >> vpush {d8,d10,d11} >> vpop {d8,d10,d11} >> >> vpush and vpop do not allow gaps in the register list. >> rdar://8728956 >> > > Thanks for fixing this! > > This was somewhat hard to follow, I had to read it a couple of times to make sure I knew the looping order. It could use a couple of comments as to what's going on, something like: > > "If NoGap is enabled then split up the pushes to ensure that the registers are adjacent, e.g. > vpush {d8, d10, d11} becomes the two pushes vpush {d8 } ; vpush { d10, d11 }" > > Might be clearer what's going on if we just did a second pass through the Regs vector after grabbing all of the matching registers? > > while (!Regs.empty()) > ? > > and then just pop regs as we iterate through? > > Thoughts? Enh, that wouldn't be any better :) The comments would still be awesome though. -eric -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20101207/82ab5c3f/attachment.html From daniel at zuster.org Tue Dec 7 19:48:03 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 08 Dec 2010 01:48:03 -0000 Subject: [llvm-commits] [llvm] r121222 - /llvm/trunk/autoconf/configure.ac Message-ID: <20101208014803.9629E2A6C12C@llvm.org> Author: ddunbar Date: Tue Dec 7 19:48:03 2010 New Revision: 121222 URL: http://llvm.org/viewvc/llvm-project?rev=121222&view=rev Log: autoconf: Stop lying to me. 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=121222&r1=121221&r2=121222&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Tue Dec 7 19:48:03 2010 @@ -1156,10 +1156,10 @@ AC_MSG_ERROR([gcc|icc required but not found]) fi -dnl Ensure that compilation tools are GCC; we use GCC specific extensions +dnl Ensure that compilation tools are compatible with GCC extensions if test "$GXX" != "yes" && test "$IXX" != "yes" then - AC_MSG_ERROR([g++|icc required but not found]) + AC_MSG_ERROR([g++|clang++|icc required but not found]) fi dnl Verify that GCC is version 3.0 or higher From daniel at zuster.org Tue Dec 7 19:48:05 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 08 Dec 2010 01:48:05 -0000 Subject: [llvm-commits] [llvm] r121223 - /llvm/trunk/Makefile.rules Message-ID: <20101208014805.E059E2A6C12D@llvm.org> Author: ddunbar Date: Tue Dec 7 19:48:05 2010 New Revision: 121223 URL: http://llvm.org/viewvc/llvm-project?rev=121223&view=rev Log: build: Don't force -flat_namespace or '-undefined suppress' on unsuspecting users of LLVM makefiles, these options really shouldn't be used on Darwin. Modified: llvm/trunk/Makefile.rules Modified: llvm/trunk/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.rules?rev=121223&r1=121222&r2=121223&view=diff ============================================================================== --- llvm/trunk/Makefile.rules (original) +++ llvm/trunk/Makefile.rules Tue Dec 7 19:48:05 2010 @@ -507,8 +507,8 @@ # Get "4" out of 10.4 for later pieces in the makefile. DARWIN_MAJVERS := $(shell echo $(DARWIN_VERSION)| sed -E 's/10.([0-9]).*/\1/') - SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined,suppress \ - -dynamiclib + LoadableModuleOptions := -Wl,-flat_namespace -Wl,-undefined,suppress + SharedLinkOptions := -dynamiclib ifneq ($(ARCH),ARM) SharedLinkOptions += -mmacosx-version-min=$(DARWIN_VERSION) endif @@ -1113,6 +1113,7 @@ ifdef LINK_LIBS_IN_SHARED ifdef LOADABLE_MODULE SharedLibKindMessage := "Loadable Module" +SharedLinkOptions := $(LoadableModuleOptions) $(SharedLinkOptions) else SharedLibKindMessage := "Shared Library" endif From dpatel at apple.com Tue Dec 7 19:50:16 2010 From: dpatel at apple.com (Devang Patel) Date: Wed, 08 Dec 2010 01:50:16 -0000 Subject: [llvm-commits] [llvm] r121224 - in /llvm/trunk: include/llvm/Analysis/DIBuilder.h lib/Analysis/DIBuilder.cpp lib/Analysis/DebugInfo.cpp Message-ID: <20101208015016.0FE172A6C12C@llvm.org> Author: dpatel Date: Tue Dec 7 19:50:15 2010 New Revision: 121224 URL: http://llvm.org/viewvc/llvm-project?rev=121224&view=rev Log: Add support to create vector, array, enums etc... Modified: llvm/trunk/include/llvm/Analysis/DIBuilder.h llvm/trunk/lib/Analysis/DIBuilder.cpp llvm/trunk/lib/Analysis/DebugInfo.cpp Modified: llvm/trunk/include/llvm/Analysis/DIBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DIBuilder.h?rev=121224&r1=121223&r2=121224&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DIBuilder.h (original) +++ llvm/trunk/include/llvm/Analysis/DIBuilder.h Tue Dec 7 19:50:15 2010 @@ -35,6 +35,8 @@ class DIGlobalVariable; class DINameSpace; class DIVariable; + class DISubrange; + class DILexicalBlock; class DIBuilder { private: @@ -141,11 +143,73 @@ unsigned Flags, DIType Ty); /// CreateStructType - Create debugging information entry for a struct. - DIType CreateStructType(DIDescriptor Context, StringRef Name, DIFile F, + /// @param Scope Scope in which this struct is defined. + /// @param Name Struct name. + /// @param File File where this member is defined. + /// @param LineNo Line number. + /// @param SizeInBits Member size. + /// @param AlignInBits Member alignment. + /// @param OffsetInBits Member offset. + /// @param Flags Flags to encode member attribute, e.g. private + /// @param Elements Struct elements. + /// @param RunTimeLang Optional parameter, Objective-C runtime version. + DIType CreateStructType(DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, DIArray Elements, unsigned RunTimeLang = 0); + /// CreateUnionType - Create debugging information entry for an union. + /// @param Scope Scope in which this union is defined. + /// @param Name Union name. + /// @param File File where this member is defined. + /// @param LineNo Line number. + /// @param SizeInBits Member size. + /// @param AlignInBits Member alignment. + /// @param OffsetInBits Member offset. + /// @param Flags Flags to encode member attribute, e.g. private + /// @param Elements Union elements. + /// @param RunTimeLang Optional parameter, Objective-C runtime version. + DIType CreateUnionType(DIDescriptor Scope, StringRef Name, DIFile File, + unsigned LineNumber, uint64_t SizeInBits, + uint64_t AlignInBits, unsigned Flags, + DIArray Elements, unsigned RunTimeLang = 0); + + /// CreateArrayType - Create debugging information entry for an array. + /// @param Size Array size. + /// @param AlignInBits Alignment. + /// @param Ty Element type. + /// @param Subscripts Subscripts. + DIType CreateArrayType(uint64_t Size, uint64_t AlignInBits, + DIType Ty, DIArray Subscripts); + + /// CreateVectorType - Create debugging information entry for a vector type. + /// @param Size Array size. + /// @param AlignInBits Alignment. + /// @param Ty Element type. + /// @param Subscripts Subscripts. + DIType CreateVectorType(uint64_t Size, uint64_t AlignInBits, + DIType Ty, DIArray Subscripts); + + /// CreateEnumerationType - Create debugging information entry for an + /// enumeration. + /// @param Scope Scope in which this enumeration is defined. + /// @param Name Union name. + /// @param File File where this member is defined. + /// @param LineNo Line number. + /// @param SizeInBits Member size. + /// @param AlignInBits Member alignment. + /// @param Elements Enumeration elements. + DIType CreateEnumerationType(DIDescriptor Scope, StringRef Name, + DIFile File, unsigned LineNumber, + uint64_t SizeInBits, + uint64_t AlignInBits, DIArray Elements); + + /// CreateSubroutineType - Create subroutine type. + /// @param File File in which this subroutine is defined. + /// @param ParamterTypes An array of subroutine parameter types. This + /// includes return type at 0th index. + DIType CreateSubroutineType(DIFile File, DIArray ParameterTypes); + /// CreateArtificialType - Create a new DIType with "artificial" flag set. DIType CreateArtificialType(DIType Ty); @@ -153,9 +217,21 @@ DIType CreateTemporaryType(); DIType CreateTemporaryType(DIFile F); + /// RetainType - Retain DIType in a module even if it is not referenced + /// through debug info anchors. + void RetainType(DIType T); + + /// CreateUnspecifiedParameter - Create unspeicified type descriptor + /// for a subroutine type. + DIDescriptor CreateUnspecifiedParameter(); + /// GetOrCreateArray - Get a DIArray, create one if required. DIArray GetOrCreateArray(Value *const *Elements, unsigned NumElements); + /// GetOrCreateSubrange - Create a descriptor for a value range. This + /// implicitly uniques the values returned. + DISubrange GetOrCreateSubrange(int64_t Lo, int64_t Hi); + /// CreateGlobalVariable - Create a new descriptor for the specified global. /// @param Name Name of the variable. /// @param File File where this variable is defined. @@ -232,6 +308,15 @@ DIFile File, unsigned LineNo); + /// CreateLexicalBlock - This creates a descriptor for a lexical block + /// with the specified parent context. + /// @param Scope Parent lexical scope. + /// @param File Source file + /// @param Line Line number + /// @param Col Column number + DILexicalBlock CreateLexicalBlock(DIDescriptor Scope, DIFile File, + unsigned Line, unsigned Col); + /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. /// @param Storage llvm::Value of the variable /// @param VarInfo Variable's debug info descriptor. Modified: llvm/trunk/lib/Analysis/DIBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DIBuilder.cpp?rev=121224&r1=121223&r2=121224&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DIBuilder.cpp (original) +++ llvm/trunk/lib/Analysis/DIBuilder.cpp Tue Dec 7 19:50:15 2010 @@ -237,19 +237,46 @@ } /// CreateStructType - Create debugging information entry for a struct. -DIType DIBuilder::CreateStructType(DIDescriptor Context, StringRef Name, DIFile F, - unsigned LineNumber, uint64_t SizeInBits, - uint64_t AlignInBits, unsigned Flags, - DIArray Elements, unsigned RunTimeLang) { +DIType DIBuilder::CreateStructType(DIDescriptor Context, StringRef Name, + DIFile File, unsigned LineNumber, + uint64_t SizeInBits, uint64_t AlignInBits, + unsigned Flags, DIArray Elements, + unsigned RunTimeLang) { // TAG_structure_type is encoded in DICompositeType format. Value *Elts[] = { GetTagConstant(VMContext, dwarf::DW_TAG_structure_type), Context, MDString::get(VMContext, Name), - F, + File, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), + ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits), + ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits), + ConstantInt::get(Type::getInt32Ty(VMContext), 0), + ConstantInt::get(Type::getInt32Ty(VMContext), Flags), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + Elements, + ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeLang), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + }; + return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts))); +} + +/// CreateUnionType - Create debugging information entry for an union. +DIType DIBuilder::CreateUnionType(DIDescriptor Scope, StringRef Name, + DIFile File, + unsigned LineNumber, uint64_t SizeInBits, + uint64_t AlignInBits, unsigned Flags, + DIArray Elements, unsigned RunTimeLang) { + // TAG_union_type is encoded in DICompositeType format. + Value *Elts[] = { + GetTagConstant(VMContext, dwarf::DW_TAG_union_type), + Scope, + MDString::get(VMContext, Name), + File, ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits), ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits), + ConstantInt::get(Type::getInt64Ty(VMContext), 0), ConstantInt::get(Type::getInt32Ty(VMContext), Flags), llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), Elements, @@ -259,6 +286,98 @@ return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts))); } +/// CreateSubroutineType - Create subroutine type. +DIType DIBuilder::CreateSubroutineType(DIFile File, DIArray ParameterTypes) { + // TAG_subroutine_type is encoded in DICompositeType format. + Value *Elts[] = { + GetTagConstant(VMContext, dwarf::DW_TAG_subroutine_type), + File, + MDString::get(VMContext, ""), + File, + ConstantInt::get(Type::getInt32Ty(VMContext), 0), + ConstantInt::get(Type::getInt64Ty(VMContext), 0), + ConstantInt::get(Type::getInt64Ty(VMContext), 0), + ConstantInt::get(Type::getInt32Ty(VMContext), 0), + ConstantInt::get(Type::getInt32Ty(VMContext), 0), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + ParameterTypes, + ConstantInt::get(Type::getInt32Ty(VMContext), 0), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + }; + return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts))); +} + +/// CreateEnumerationType - Create debugging information entry for an +/// enumeration. +DIType DIBuilder::CreateEnumerationType(DIDescriptor Scope, StringRef Name, + DIFile File, unsigned LineNumber, + uint64_t SizeInBits, + uint64_t AlignInBits, DIArray Elements) { + // TAG_enumeration_type is encoded in DICompositeType format. + Value *Elts[] = { + GetTagConstant(VMContext, dwarf::DW_TAG_enumeration_type), + Scope, + MDString::get(VMContext, Name), + File, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), + ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits), + ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits), + ConstantInt::get(Type::getInt32Ty(VMContext), 0), + ConstantInt::get(Type::getInt32Ty(VMContext), 0), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + Elements, + ConstantInt::get(Type::getInt32Ty(VMContext), 0), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + }; + MDNode *Node = MDNode::get(VMContext, &Elts[0], array_lengthof(Elts)); + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.enum"); + NMD->addOperand(Node); + return DIType(Node); +} + +/// CreateArrayType - Create debugging information entry for an array. +DIType DIBuilder::CreateArrayType(uint64_t Size, uint64_t AlignInBits, + DIType Ty, DIArray Subscripts) { + // TAG_array_type is encoded in DICompositeType format. + Value *Elts[] = { + GetTagConstant(VMContext, dwarf::DW_TAG_array_type), + TheCU, + MDString::get(VMContext, ""), + TheCU, + ConstantInt::get(Type::getInt32Ty(VMContext), 0), + ConstantInt::get(Type::getInt64Ty(VMContext), Size), + ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits), + ConstantInt::get(Type::getInt32Ty(VMContext), 0), + ConstantInt::get(Type::getInt32Ty(VMContext), 0), + Ty, + Subscripts, + ConstantInt::get(Type::getInt32Ty(VMContext), 0), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + }; + return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts))); +} + +/// CreateVectorType - Create debugging information entry for a vector. +DIType DIBuilder::CreateVectorType(uint64_t Size, uint64_t AlignInBits, + DIType Ty, DIArray Subscripts) { + // TAG_vector_type is encoded in DICompositeType format. + Value *Elts[] = { + GetTagConstant(VMContext, dwarf::DW_TAG_vector_type), + TheCU, + MDString::get(VMContext, ""), + TheCU, + ConstantInt::get(Type::getInt32Ty(VMContext), 0), + ConstantInt::get(Type::getInt64Ty(VMContext), Size), + ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits), + ConstantInt::get(Type::getInt32Ty(VMContext), 0), + ConstantInt::get(Type::getInt32Ty(VMContext), 0), + Ty, + Subscripts, + ConstantInt::get(Type::getInt32Ty(VMContext), 0), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + }; + return DIType(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts))); +} /// CreateArtificialType - Create a new DIType with "artificial" flag set. DIType DIBuilder::CreateArtificialType(DIType Ty) { @@ -284,6 +403,22 @@ return DIType(MDNode::get(VMContext, Elts.data(), Elts.size())); } +/// RetainType - Retain DIType in a module even if it is not referenced +/// through debug info anchors. +void DIBuilder::RetainType(DIType T) { + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.ty"); + NMD->addOperand(T); +} + +/// CreateUnspecifiedParameter - Create unspeicified type descriptor +/// for the subroutine type. +DIDescriptor DIBuilder::CreateUnspecifiedParameter() { + Value *Elts[] = { + GetTagConstant(VMContext, dwarf::DW_TAG_unspecified_parameters) + }; + return DIDescriptor(MDNode::get(VMContext, &Elts[0], 1)); +} + /// CreateTemporaryType - Create a temporary forward-declared type. DIType DIBuilder::CreateTemporaryType() { // Give the temporary MDNode a tag. It doesn't matter what tag we @@ -316,6 +451,18 @@ return DIArray(MDNode::get(VMContext, Elements, NumElements)); } +/// GetOrCreateSubrange - Create a descriptor for a value range. This +/// implicitly uniques the values returned. +DISubrange DIBuilder::GetOrCreateSubrange(int64_t Lo, int64_t Hi) { + Value *Elts[] = { + GetTagConstant(VMContext, dwarf::DW_TAG_subrange_type), + ConstantInt::get(Type::getInt64Ty(VMContext), Lo), + ConstantInt::get(Type::getInt64Ty(VMContext), Hi) + }; + + return DISubrange(MDNode::get(VMContext, &Elts[0], 3)); +} + /// CreateGlobalVariable - Create a new descriptor for the specified global. DIGlobalVariable DIBuilder:: CreateGlobalVariable(StringRef Name, DIFile F, unsigned LineNumber, @@ -419,7 +566,6 @@ return DIVariable(MDNode::get(VMContext, Elts.data(), Elts.size())); } - /// CreateNameSpace - This creates new descriptor for a namespace /// with the specified parent scope. DINameSpace DIBuilder::CreateNameSpace(DIDescriptor Scope, StringRef Name, @@ -434,6 +580,21 @@ return DINameSpace(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts))); } +DILexicalBlock DIBuilder::CreateLexicalBlock(DIDescriptor Scope, DIFile File, + unsigned Line, unsigned Col) { + // Defeat MDNode uniqing for lexical blocks by using unique id. + static unsigned int unique_id = 0; + Value *Elts[] = { + GetTagConstant(VMContext, dwarf::DW_TAG_lexical_block), + Scope, + ConstantInt::get(Type::getInt32Ty(VMContext), Line), + ConstantInt::get(Type::getInt32Ty(VMContext), Col), + File, + ConstantInt::get(Type::getInt32Ty(VMContext), unique_id++) + }; + return DILexicalBlock(MDNode::get(VMContext, &Elts[0], array_lengthof(Elts))); +} + /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. Instruction *DIBuilder::InsertDeclare(Value *Storage, DIVariable VarInfo, Instruction *InsertBefore) { Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=121224&r1=121223&r2=121224&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Tue Dec 7 19:50:15 2010 @@ -309,6 +309,8 @@ if (!isBasicType() && Tag != dwarf::DW_TAG_const_type && Tag != dwarf::DW_TAG_volatile_type && Tag != dwarf::DW_TAG_pointer_type && Tag != dwarf::DW_TAG_reference_type && Tag != dwarf::DW_TAG_restrict_type + && Tag != dwarf::DW_TAG_vector_type && Tag != dwarf::DW_TAG_array_type + && Tag != dwarf::DW_TAG_enumeration_type && getFilename().empty()) return false; return true; From echristo at apple.com Tue Dec 7 19:54:33 2010 From: echristo at apple.com (Eric Christopher) Date: Tue, 7 Dec 2010 17:54:33 -0800 Subject: [llvm-commits] [llvm] r121222 - /llvm/trunk/autoconf/configure.ac In-Reply-To: <20101208014803.9629E2A6C12C@llvm.org> References: <20101208014803.9629E2A6C12C@llvm.org> Message-ID: <1185C4C1-6F43-4D25-A24F-D59DB2143D4F@apple.com> On Dec 7, 2010, at 5:48 PM, Daniel Dunbar wrote: > llvm/trunk/autoconf/configure.ac Regenerate? :) (or do you need me to?) -eric -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20101207/eddd2b61/attachment.html From isanbard at gmail.com Tue Dec 7 19:57:09 2010 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 08 Dec 2010 01:57:09 -0000 Subject: [llvm-commits] [llvm] r121226 - in /llvm/trunk: lib/MC/ELFObjectWriter.cpp lib/Target/ARM/ARMAsmBackend.cpp lib/Target/ARM/ARMCodeEmitter.cpp lib/Target/ARM/ARMFixupKinds.h lib/Target/ARM/ARMInstrThumb.td lib/Target/ARM/ARMMCCodeEmitter.cpp utils/TableGen/EDEmitter.cpp Message-ID: <20101208015710.0B1A42A6C12C@llvm.org> Author: void Date: Tue Dec 7 19:57:09 2010 New Revision: 121226 URL: http://llvm.org/viewvc/llvm-project?rev=121226&view=rev Log: Add support for loading from a constant pool. Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp llvm/trunk/lib/Target/ARM/ARMFixupKinds.h llvm/trunk/lib/Target/ARM/ARMInstrThumb.td llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp llvm/trunk/utils/TableGen/EDEmitter.cpp Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=121226&r1=121225&r2=121226&view=diff ============================================================================== --- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Tue Dec 7 19:57:09 2010 @@ -1549,6 +1549,7 @@ case ARM::fixup_arm_pcrel_10: case ARM::fixup_arm_adr_pcrel_12: case ARM::fixup_arm_thumb_bl: + case ARM::fixup_arm_thumb_cp: assert(0 && "Unimplemented"); break; case ARM::fixup_arm_branch: return ELF::R_ARM_CALL; break; Modified: llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp?rev=121226&r1=121225&r2=121226&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Tue Dec 7 19:57:09 2010 @@ -138,6 +138,9 @@ Binary = ((Binary & 0x7ff) << 16) | (Binary >> 11); return Binary; } + case ARM::fixup_arm_thumb_cp: + // Offset by 4, and don't encode the low two bits. + return ((Value - 4) >> 2) & 0xff; case ARM::fixup_t2_pcrel_10: case ARM::fixup_arm_pcrel_10: { // Offset by 8 just as above. @@ -243,13 +246,17 @@ switch (Kind) { default: llvm_unreachable("Unknown fixup kind!"); - case FK_Data_4: - return 4; + + case ARM::fixup_arm_thumb_cp: + return 1; + case ARM::fixup_arm_ldst_pcrel_12: case ARM::fixup_arm_pcrel_10: case ARM::fixup_arm_adr_pcrel_12: case ARM::fixup_arm_branch: return 3; + + case FK_Data_4: case ARM::fixup_t2_pcrel_10: case ARM::fixup_arm_thumb_bl: return 4; Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp?rev=121226&r1=121225&r2=121226&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Tue Dec 7 19:57:09 2010 @@ -255,6 +255,8 @@ const { return 0; } uint32_t getAddrModeS1OpValue(const MachineInstr &MI, unsigned Op) const { return 0; } + uint32_t getAddrModePCOpValue(const MachineInstr &MI, unsigned Op) + const { return 0; } uint32_t getAddrMode5OpValue(const MachineInstr &MI, unsigned Op) const { // {17-13} = reg // {12} = (U)nsigned (add == '1', sub == '0') Modified: llvm/trunk/lib/Target/ARM/ARMFixupKinds.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFixupKinds.h?rev=121226&r1=121225&r2=121226&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMFixupKinds.h (original) +++ llvm/trunk/lib/Target/ARM/ARMFixupKinds.h Tue Dec 7 19:57:09 2010 @@ -34,6 +34,9 @@ // fixup_arm_thumb_bl - Fixup for Thumb BL/BLX instructions. fixup_arm_thumb_bl, + // fixup_arm_thumb_cp - Fixup for Thumb load/store from constant pool instrs. + fixup_arm_thumb_cp, + // The next two are for the movt/movw pair // the 16bit imm field are split into imm{15-12} and imm{11-0} // Fixme: We need new ones for Thumb. Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=121226&r1=121225&r2=121226&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue Dec 7 19:57:09 2010 @@ -134,6 +134,13 @@ let ParserMatchClass = MemModeThumbAsmOperand; } +// t_addrmode_pc :=